asn_parse_nlength:
  325|    625|{
  326|    625|    int len_len;
  327|       |
  328|    625|    if (pkt_len < 1)
  ------------------
  |  Branch (328:9): [True: 0, False: 625]
  ------------------
  329|      0|        return NULL;               /* always too short */
  330|       |
  331|    625|    if (NULL == pkt || NULL == data_len)
  ------------------
  |  Branch (331:9): [True: 0, False: 625]
  |  Branch (331:24): [True: 0, False: 625]
  ------------------
  332|      0|        return NULL;
  333|       |
  334|    625|    *data_len = 0;
  335|       |
  336|    625|    if (*pkt & 0x80) {
  ------------------
  |  Branch (336:9): [True: 9, False: 616]
  ------------------
  337|       |        /*
  338|       |         * long length; first byte is length of length (after masking high bit)
  339|       |         */
  340|      9|        len_len = (int) ((*pkt & ~0x80) + 1);
  341|      9|        if (pkt_len < len_len)
  ------------------
  |  Branch (341:13): [True: 1, False: 8]
  ------------------
  342|      1|            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: 8, False: 0]
  ------------------
  346|      8|            return NULL;           /* propagate error from asn_parse_length */
  347|    616|    } else {
  348|       |        /*
  349|       |         * short length; first byte is the length
  350|       |         */
  351|    616|        len_len = 1;
  352|    616|        *data_len = *pkt;
  353|    616|    }
  354|       |
  355|    616|    if ((*data_len + len_len) > pkt_len)
  ------------------
  |  Branch (355:9): [True: 1, False: 615]
  ------------------
  356|      1|        return NULL;
  357|       |
  358|    615|    return (pkt + len_len);
  359|    616|}
asn_check_packet:
  484|    227|{
  485|    227|    u_long          asn_length;
  486|       |
  487|    227|    if (len < 2)
  ------------------
  |  Branch (487:9): [True: 10, False: 217]
  ------------------
  488|     10|        return 0;               /* always too short */
  489|       |
  490|    217|    if (*pkt != (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR))
  ------------------
  |  |   84|    217|#define ASN_SEQUENCE	    0x10U
  ------------------
                  if (*pkt != (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR))
  ------------------
  |  |   96|    217|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  |  Branch (490:9): [True: 16, False: 201]
  ------------------
  491|     16|        return -1;              /* wrong type */
  492|       |
  493|    201|    if (*(pkt + 1) & 0x80) {
  ------------------
  |  Branch (493:9): [True: 5, False: 196]
  ------------------
  494|       |        /*
  495|       |         * long length 
  496|       |         */
  497|      5|        if ((int) len < (int) (*(pkt + 1) & ~0x80) + 2)
  ------------------
  |  Branch (497:13): [True: 2, False: 3]
  ------------------
  498|      2|            return 0;           /* still to short, incomplete length */
  499|      3|        if (NULL == asn_parse_length(pkt + 1, &asn_length))
  ------------------
  |  Branch (499:13): [True: 1, False: 2]
  ------------------
  500|      1|            return 0;           /* propagate error from asn_parse_length() */
  501|      2|        return (asn_length + 2 + (*(pkt + 1) & ~0x80));
  502|    196|    } else {
  503|       |        /*
  504|       |         * short length 
  505|       |         */
  506|    196|        return (*(pkt + 1) + 2);
  507|    196|    }
  508|    201|}
asn_parse_int:
  557|    344|{
  558|       |    /*
  559|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  560|       |     */
  561|    344|    static const char *errpre = "parse int";
  562|    344|    register u_char *bufp = data;
  563|    344|    u_long          asn_length;
  564|    344|    int             i;
  565|    344|    union {
  566|    344|        long          l;
  567|    344|        unsigned char b[sizeof(long)];
  568|    344|    } value;
  569|       |
  570|    344|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (570:9): [True: 0, False: 344]
  |  Branch (570:25): [True: 0, False: 344]
  |  Branch (570:47): [True: 0, False: 344]
  |  Branch (570:63): [True: 0, False: 344]
  ------------------
  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|    344|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (575:9): [True: 0, False: 344]
  ------------------
  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|    344|    if (*datalength < 2) {
  ------------------
  |  Branch (581:9): [True: 129, False: 215]
  ------------------
  582|    129|        _asn_short_err(errpre, *datalength, 2);
  583|    129|        return NULL;
  584|    129|    }
  585|       |
  586|    215|    *type = *bufp++;
  587|    215|    if (*type != ASN_INTEGER) {
  ------------------
  |  |   75|    215|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (587:9): [True: 7, False: 208]
  ------------------
  588|      7|        _asn_type_err(errpre, *type);
  589|      7|        return NULL;
  590|      7|    }
  591|       |
  592|    208|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  593|    208|    if (NULL == bufp) {
  ------------------
  |  Branch (593:9): [True: 8, False: 200]
  ------------------
  594|      8|        _asn_short_err(errpre, *datalength - 1, asn_length);
  595|      8|        return NULL;
  596|      8|    }
  597|       |
  598|    200|    if ((size_t) asn_length > intsize || (int) asn_length == 0) {
  ------------------
  |  Branch (598:9): [True: 1, False: 199]
  |  Branch (598:42): [True: 5, False: 194]
  ------------------
  599|      6|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  600|      6|        return NULL;
  601|      6|    }
  602|       |
  603|    194|    *datalength -= (int) asn_length + (bufp - data);
  604|       |
  605|    194|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|    194|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    194|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 194]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 194]
  |  |  ------------------
  ------------------
  606|       |
  607|    194|    memset(&value.b, *bufp & 0x80 ? 0xff : 0, sizeof(value.b));
  ------------------
  |  Branch (607:22): [True: 1, False: 193]
  ------------------
  608|    194|    if (NETSNMP_BIGENDIAN) {
  ------------------
  |  | 2396|    194|#  define NETSNMP_BIGENDIAN 0
  |  |  ------------------
  |  |  |  Branch (2396:29): [Folded, False: 194]
  |  |  ------------------
  ------------------
  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|    194|    } else {
  612|    635|        for (i = asn_length - 1; asn_length--; i--)
  ------------------
  |  Branch (612:34): [True: 441, False: 194]
  ------------------
  613|    441|            value.b[i] = *bufp++;
  614|    194|    }
  615|       |
  616|    194|    CHECK_OVERFLOW_S(value.l, 1);
  ------------------
  |  |  214|    194|#define CHECK_OVERFLOW_S(x,y) do {                                      \
  |  |  215|    194|        if (x > INT32_MAX) {                                            \
  |  |  ------------------
  |  |  |  Branch (215:13): [True: 1, False: 193]
  |  |  ------------------
  |  |  216|      1|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   61|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  217|      1|            x &= 0xffffffff;                                            \
  |  |  218|    193|        } else if (x < INT32_MIN) {                                     \
  |  |  ------------------
  |  |  |  Branch (218:20): [True: 0, False: 193]
  |  |  ------------------
  |  |  219|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  220|      0|            x = 0 - (x & 0xffffffff);                                   \
  |  |  221|      0|        }                                                               \
  |  |  222|    194|    } while(0)
  |  |  ------------------
  |  |  |  Branch (222:13): [Folded, False: 194]
  |  |  ------------------
  ------------------
  617|       |
  618|    194|    DEBUGMSG(("dumpv_recv", "  Integer:\t%ld (0x%.2lX)\n", value.l, value.l));
  ------------------
  |  |   61|    194|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    194|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 194]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 194]
  |  |  ------------------
  ------------------
  619|       |
  620|    194|    *intp = value.l;
  621|    194|    return bufp;
  622|    200|}
asn_parse_string:
  910|    121|{
  911|    121|    static const char *errpre = "parse string";
  912|    121|    u_char         *bufp = data;
  913|    121|    u_long          asn_length;
  914|       |
  915|    121|    if (NULL == data || NULL == datalength || NULL == type || NULL == str ||
  ------------------
  |  Branch (915:9): [True: 0, False: 121]
  |  Branch (915:25): [True: 0, False: 121]
  |  Branch (915:47): [True: 0, False: 121]
  |  Branch (915:63): [True: 0, False: 121]
  ------------------
  916|    121|        NULL == strlength) {
  ------------------
  |  Branch (916:9): [True: 0, False: 121]
  ------------------
  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|    121|    if (*datalength < 2) {
  ------------------
  |  Branch (922:9): [True: 0, False: 121]
  ------------------
  923|      0|        _asn_short_err(errpre, *datalength, 2);
  924|      0|        return NULL;
  925|      0|    }
  926|       |
  927|    121|    *type = *bufp++;
  928|    121|    if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   78|    242|#define ASN_OCTET_STR	    0x04U
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   88|    149|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|     28|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   93|    149|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     28|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (928:9): [True: 28, False: 93]
  |  Branch (928:35): [True: 28, False: 0]
  |  Branch (928:61): [True: 25, False: 3]
  ------------------
  929|     25|            && *type != ASN_NSAP) {
  ------------------
  |  |   98|     25|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     25|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (929:16): [True: 25, False: 0]
  ------------------
  930|     25|        _asn_type_err(errpre, *type);
  931|     25|        return NULL;
  932|     25|    }
  933|       |
  934|     96|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  935|     96|    if (NULL == bufp) {
  ------------------
  |  Branch (935:9): [True: 0, False: 96]
  ------------------
  936|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
  937|      0|        return NULL;
  938|      0|    }
  939|       |
  940|     96|    if (asn_length > *strlength) {
  ------------------
  |  Branch (940:9): [True: 0, False: 96]
  ------------------
  941|      0|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
  942|      0|        return NULL;
  943|      0|    }
  944|       |
  945|     96|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|     96|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     96|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 96]
  |  |  ------------------
  ------------------
  946|       |
  947|     96|    memmove(str, bufp, asn_length);
  948|     96|    if (*strlength > asn_length)
  ------------------
  |  Branch (948:9): [True: 96, False: 0]
  ------------------
  949|     96|        str[asn_length] = 0;
  950|     96|    *strlength = asn_length;
  951|     96|    *datalength -= asn_length + (bufp - data);
  952|       |
  953|     96|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|     96|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    192|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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|     96|    return bufp + asn_length;
  974|     96|}
asn_parse_header:
 1071|    319|{
 1072|    319|    register u_char *bufp;
 1073|    319|    u_long          asn_length = 0;
 1074|    319|    const char      *errpre = "parse header";
 1075|       |
 1076|    319|    if (!data || !datalength || !type) {
  ------------------
  |  Branch (1076:9): [True: 0, False: 319]
  |  Branch (1076:18): [True: 0, False: 319]
  |  Branch (1076:33): [True: 0, False: 319]
  ------------------
 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|    319|    if (*datalength < 2) {
  ------------------
  |  Branch (1082:9): [True: 0, False: 319]
  ------------------
 1083|      0|        _asn_short_err(errpre, *datalength, 2);
 1084|      0|        return NULL;
 1085|      0|    }
 1086|       |
 1087|    319|    bufp = data;
 1088|       |    /*
 1089|       |     * this only works on data types < 30, i.e. no extension octets 
 1090|       |     */
 1091|    319|    if (IS_EXTENSION_ID(*bufp)) {
  ------------------
  |  |  103|    319|#define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    319|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |               #define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    319|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |  |  Branch (103:31): [True: 0, False: 319]
  |  |  ------------------
  ------------------
 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|    319|    *type = *bufp++;
 1096|       |
 1097|    319|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1098|    319|    if (NULL == bufp) {
  ------------------
  |  Branch (1098:9): [True: 2, False: 317]
  ------------------
 1099|      2|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1100|      2|        return NULL;
 1101|      2|    }
 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|    317|#endif
 1113|       |
 1114|    317|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1115|       |
 1116|    317|    if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |   93|    173|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    173|#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: 173, False: 144]
  |  Branch (1116:29): [True: 0, False: 173]
  |  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|    317|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 1148|       |
 1149|    317|    *datalength = (int) asn_length;
 1150|       |
 1151|    317|    return bufp;
 1152|    317|}
asn_parse_sequence:
 1171|    317|{                               /* error message prefix */
 1172|    317|    data = asn_parse_header(data, datalength, type);
 1173|    317|    if (data && (*type != expected_type)) {
  ------------------
  |  Branch (1173:9): [True: 315, False: 2]
  |  Branch (1173:17): [True: 14, False: 301]
  ------------------
 1174|     14|        char            ebuf[128];
 1175|     14|        snprintf(ebuf, sizeof(ebuf),
 1176|     14|                 "%s header type %02X: s/b %02X", estr,
 1177|     14|                (u_char) * type, (u_char) expected_type);
 1178|     14|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|     14|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1179|     14|        return NULL;
 1180|     14|    }
 1181|    303|    return data;
 1182|    317|}
asn_parse_length:
 1293|     11|{
 1294|     11|    static const char *errpre = "parse length";
 1295|     11|    char            ebuf[128];
 1296|     11|    register u_char lengthbyte;
 1297|       |
 1298|     11|    if (!data || !length) {
  ------------------
  |  Branch (1298:9): [True: 0, False: 11]
  |  Branch (1298:18): [True: 0, False: 11]
  ------------------
 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|     11|    lengthbyte = *data;
 1303|       |
 1304|     11|    if (lengthbyte & ASN_LONG_LEN) {
  ------------------
  |  |   98|     11|#define ASN_LONG_LEN	    0x80U
  ------------------
  |  Branch (1304:9): [True: 11, False: 0]
  ------------------
 1305|     11|        lengthbyte &= ~ASN_LONG_LEN;    /* turn MSb off */
  ------------------
  |  |   98|     11|#define ASN_LONG_LEN	    0x80U
  ------------------
 1306|     11|        if (lengthbyte == 0) {
  ------------------
  |  Branch (1306:13): [True: 0, False: 11]
  ------------------
 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|     11|        if (lengthbyte > sizeof(long)) {
  ------------------
  |  Branch (1312:13): [True: 9, False: 2]
  ------------------
 1313|      9|            snprintf(ebuf, sizeof(ebuf),
 1314|      9|                    "%s: data length %d > %lu not supported", errpre,
 1315|      9|                    lengthbyte, (unsigned long)sizeof(long));
 1316|      9|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      9|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1317|      9|            return NULL;
 1318|      9|        }
 1319|      2|        data++;
 1320|      2|        *length = 0;            /* protect against short lengths */
 1321|     11|        while (lengthbyte--) {
  ------------------
  |  Branch (1321:16): [True: 9, False: 2]
  ------------------
 1322|      9|            *length <<= 8;
 1323|      9|            *length |= *data++;
 1324|      9|        }
 1325|      2|        if ((long) *length < 0) {
  ------------------
  |  Branch (1325:13): [True: 0, False: 2]
  ------------------
 1326|      0|            snprintf(ebuf, sizeof(ebuf),
 1327|      0|                     "%s: negative data length %ld\n", errpre,
 1328|      0|                     (long) *length);
 1329|      0|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1330|      0|            return NULL;
 1331|      0|        }
 1332|      2|        return data;
 1333|      2|    } else {                    /* short asnlength */
 1334|      0|        *length = (long) lengthbyte;
 1335|      0|        return data + 1;
 1336|      0|    }
 1337|     11|}
asn_parse_objid:
 1435|      2|{
 1436|      2|    static const char *errpre = "parse objid";
 1437|       |    /*
 1438|       |     * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
 1439|       |     * subidentifier ::= {leadingbyte}* lastbyte
 1440|       |     * leadingbyte ::= 1 7bitvalue
 1441|       |     * lastbyte ::= 0 7bitvalue
 1442|       |     */
 1443|      2|    register u_char *bufp = data;
 1444|      2|    register oid   *oidp = objid + 1;
 1445|      2|    register u_long subidentifier;
 1446|      2|    register long   length;
 1447|      2|    u_long          asn_length;
 1448|      2|    size_t          original_length = *objidlength;
 1449|       |
 1450|      2|    if (NULL == data || NULL == datalength || NULL == type || NULL == objid) {
  ------------------
  |  Branch (1450:9): [True: 0, False: 2]
  |  Branch (1450:25): [True: 0, False: 2]
  |  Branch (1450:47): [True: 0, False: 2]
  |  Branch (1450:63): [True: 0, False: 2]
  ------------------
 1451|      0|        ERROR_MSG("parse objid: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1452|      0|        return NULL;
 1453|      0|    }
 1454|       |
 1455|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1456|      2|    if (*datalength < 2) {
  ------------------
  |  Branch (1456:9): [True: 0, False: 2]
  ------------------
 1457|      0|        _asn_short_err(errpre, *datalength, 2);
 1458|      0|        return NULL;
 1459|      0|    }
 1460|       |
 1461|      2|    *type = *bufp++;
 1462|      2|    if (*type != ASN_OBJECT_ID) {
  ------------------
  |  |   81|      2|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (1462:9): [True: 0, False: 2]
  ------------------
 1463|      0|        _asn_type_err(errpre, *type);
 1464|      0|        return NULL;
 1465|      0|    }
 1466|      2|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1467|      2|    if (NULL == bufp) {
  ------------------
  |  Branch (1467:9): [True: 0, False: 2]
  ------------------
 1468|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1469|      0|        return NULL;
 1470|      0|    }
 1471|       |
 1472|      2|    *datalength -= (int) asn_length + (bufp - data);
 1473|       |
 1474|      2|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|      2|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 2]
  |  |  ------------------
  ------------------
 1475|       |
 1476|       |    /*
 1477|       |     * Handle invalid object identifier encodings of the form 06 00 robustly 
 1478|       |     */
 1479|      2|    if (asn_length == 0)
  ------------------
  |  Branch (1479:9): [True: 0, False: 2]
  ------------------
 1480|      0|        objid[0] = objid[1] = 0;
 1481|       |
 1482|      2|    length = asn_length;
 1483|      2|    (*objidlength)--;           /* account for expansion of first byte */
 1484|       |
 1485|      9|    while (length > 0 && (*objidlength)-- > 0) {
  ------------------
  |  Branch (1485:12): [True: 8, False: 1]
  |  Branch (1485:26): [True: 8, False: 0]
  ------------------
 1486|      8|        subidentifier = 0;
 1487|     14|        do {                    /* shift and add in low order 7 bits */
 1488|     14|            if (subidentifier > (MAX_SUBID >> 7)) {
  ------------------
  |  |   18|     14|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1488:17): [True: 0, False: 14]
  ------------------
 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|     14|            subidentifier =
 1493|     14|                (subidentifier << 7) + (*(u_char *) bufp & ~ASN_BIT8);
  ------------------
  |  |  100|     14|#define ASN_BIT8	    0x80U
  ------------------
 1494|     14|            length--;
 1495|     14|        } while ((*(u_char *) bufp++ & ASN_BIT8) && (length > 0));        /* last byte has high bit clear */
  ------------------
  |  |  100|     14|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1495:18): [True: 7, False: 7]
  |  Branch (1495:53): [True: 6, False: 1]
  ------------------
 1496|       |
 1497|      8|	if (length == 0) {
  ------------------
  |  Branch (1497:6): [True: 2, False: 6]
  ------------------
 1498|      2|            u_char *last_byte = bufp - 1;
 1499|      2|            if (*last_byte & ASN_BIT8) {
  ------------------
  |  |  100|      2|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1499:17): [True: 1, False: 1]
  ------------------
 1500|       |                /* last byte has high bit set -> wrong BER encoded OID */
 1501|      1|                ERROR_MSG("subidentifier syntax error");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1502|      1|                return NULL;
 1503|      1|            }
 1504|      2|        }
 1505|      7|        if (subidentifier > MAX_SUBID) {
  ------------------
  |  |   18|      7|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1505:13): [True: 0, False: 7]
  ------------------
 1506|      0|            ERROR_MSG("subidentifier too large");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1507|      0|            return NULL;
 1508|      0|        }
 1509|      7|        *oidp++ = (oid) subidentifier;
 1510|      7|    }
 1511|       |
 1512|      1|    if (length || oidp < objid + 1) {
  ------------------
  |  Branch (1512:9): [True: 0, False: 1]
  |  Branch (1512:19): [True: 0, False: 1]
  ------------------
 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|      1|    subidentifier = oidp - objid >= 2 ? objid[1] : 0;
  ------------------
  |  Branch (1524:21): [True: 1, False: 0]
  ------------------
 1525|      1|    if (subidentifier == 0x2B) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 1]
  ------------------
 1526|      0|        objid[0] = 1;
 1527|      0|        objid[1] = 3;
 1528|      1|    } else {
 1529|      1|        if (subidentifier < 40) {
  ------------------
  |  Branch (1529:13): [True: 0, False: 1]
  ------------------
 1530|      0|            objid[0] = 0;
 1531|      0|            objid[1] = subidentifier;
 1532|      1|        } else if (subidentifier < 80) {
  ------------------
  |  Branch (1532:20): [True: 0, False: 1]
  ------------------
 1533|      0|            objid[0] = 1;
 1534|      0|            objid[1] = subidentifier - 40;
 1535|      1|        } else {
 1536|      1|            objid[0] = 2;
 1537|      1|            objid[1] = subidentifier - 80;
 1538|      1|        }
 1539|      1|    }
 1540|       |
 1541|      1|    *objidlength = (int) (oidp - objid);
 1542|       |
 1543|      1|    DEBUGMSG(("dumpv_recv", "  ObjID: "));
  ------------------
  |  |   61|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1544|      1|    DEBUGMSGOID(("dumpv_recv", objid, *objidlength));
  ------------------
  |  |   67|      1|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1545|      1|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   61|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1546|      1|    return bufp;
 1547|      1|}
asn_realloc_rbuild_length:
 2853|    520|{
 2854|    520|    static const char *errpre = "build length";
 2855|    520|    char            ebuf[128];
 2856|    520|    int             tmp_int;
 2857|    520|    size_t          start_offset = *offset;
 2858|       |
 2859|    520|    if (length <= 0x7f) {
  ------------------
  |  Branch (2859:9): [True: 520, False: 0]
  ------------------
 2860|    520|        if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (2860:13): [True: 0, False: 520]
  ------------------
 2861|      0|            && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2861:18): [True: 0, False: 0]
  |  Branch (2861:23): [True: 0, False: 0]
  ------------------
 2862|      0|            snprintf(ebuf, sizeof(ebuf),
 2863|      0|                    "%s: bad length < 1 :%ld, %lu", errpre,
 2864|      0|                    (long)(*pkt_len - *offset), (unsigned long)length);
 2865|      0|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2866|      0|            return 0;
 2867|      0|        }
 2868|    520|        *(*pkt + *pkt_len - (++*offset)) = length;
 2869|    520|    } else {
 2870|      0|        while (length > 0xff) {
  ------------------
  |  Branch (2870:16): [True: 0, False: 0]
  ------------------
 2871|      0|            if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (2871:17): [True: 0, False: 0]
  ------------------
 2872|      0|                && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2872:22): [True: 0, False: 0]
  |  Branch (2872:27): [True: 0, False: 0]
  ------------------
 2873|      0|                snprintf(ebuf, sizeof(ebuf),
 2874|      0|                        "%s: bad length < 1 :%ld, %lu", errpre,
 2875|      0|                        (long)(*pkt_len - *offset), (unsigned long)length);
 2876|      0|                ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2877|      0|                return 0;
 2878|      0|            }
 2879|      0|            *(*pkt + *pkt_len - (++*offset)) = length & 0xff;
 2880|      0|            length >>= 8;
 2881|      0|        }
 2882|       |
 2883|      0|        while ((*pkt_len - *offset) < 2) {
  ------------------
  |  Branch (2883:16): [True: 0, False: 0]
  ------------------
 2884|      0|            if (!(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2884:19): [True: 0, False: 0]
  |  Branch (2884:24): [True: 0, False: 0]
  ------------------
 2885|      0|                snprintf(ebuf, sizeof(ebuf),
 2886|      0|                        "%s: bad length < 1 :%ld, %lu", errpre,
 2887|      0|                        (long)(*pkt_len - *offset), (unsigned long)length);
 2888|      0|                ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2889|      0|                return 0;
 2890|      0|            }
 2891|      0|        }
 2892|       |
 2893|      0|        *(*pkt + *pkt_len - (++*offset)) = length & 0xff;
 2894|      0|        tmp_int = *offset - start_offset;
 2895|      0|        *(*pkt + *pkt_len - (++*offset)) = tmp_int | 0x80;
 2896|      0|    }
 2897|       |
 2898|    520|    return 1;
 2899|    520|}
asn_realloc_rbuild_header:
 2922|    520|{
 2923|    520|    char            ebuf[128];
 2924|       |
 2925|    520|    if (asn_realloc_rbuild_length(pkt, pkt_len, offset, r, length)) {
  ------------------
  |  Branch (2925:9): [True: 520, False: 0]
  ------------------
 2926|    520|        if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (2926:13): [True: 0, False: 520]
  ------------------
 2927|      0|            && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2927:18): [True: 0, False: 0]
  |  Branch (2927:23): [True: 0, False: 0]
  ------------------
 2928|      0|            snprintf(ebuf, sizeof(ebuf),
 2929|      0|                    "bad header length < 1 :%ld, %lu",
 2930|      0|                    (long)(*pkt_len - *offset), (unsigned long)length);
 2931|      0|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2932|      0|            return 0;
 2933|      0|        }
 2934|    520|        *(*pkt + *pkt_len - (++*offset)) = type;
 2935|    520|        return 1;
 2936|    520|    }
 2937|      0|    return 0;
 2938|    520|}
asn_realloc_rbuild_int:
 2961|    180|{
 2962|    180|    static const char *errpre = "build int";
 2963|    180|    register long   integer = *intp;
 2964|    180|    int             testvalue;
 2965|    180|    size_t          start_offset = *offset;
 2966|       |
 2967|    180|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (2967:9): [True: 0, False: 180]
  ------------------
 2968|      0|        _asn_size_err(errpre, intsize, sizeof(long));
 2969|      0|        return 0;
 2970|      0|    }
 2971|       |
 2972|    180|    CHECK_OVERFLOW_S(integer,10);
  ------------------
  |  |  214|    180|#define CHECK_OVERFLOW_S(x,y) do {                                      \
  |  |  215|    180|        if (x > INT32_MAX) {                                            \
  |  |  ------------------
  |  |  |  Branch (215:13): [True: 0, False: 180]
  |  |  ------------------
  |  |  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|    180|        } else if (x < INT32_MIN) {                                     \
  |  |  ------------------
  |  |  |  Branch (218:20): [True: 0, False: 180]
  |  |  ------------------
  |  |  219|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  220|      0|            x = 0 - (x & 0xffffffff);                                   \
  |  |  221|      0|        }                                                               \
  |  |  222|    180|    } while(0)
  |  |  ------------------
  |  |  |  Branch (222:13): [Folded, False: 180]
  |  |  ------------------
  ------------------
 2973|    180|    testvalue = (integer < 0) ? -1 : 0;
  ------------------
  |  Branch (2973:17): [True: 0, False: 180]
  ------------------
 2974|       |
 2975|    180|    if (((*pkt_len - *offset) < 1) && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2975:9): [True: 0, False: 180]
  |  Branch (2975:41): [True: 0, False: 0]
  |  Branch (2975:46): [True: 0, False: 0]
  ------------------
 2976|      0|        return 0;
 2977|      0|    }
 2978|    180|    *(*pkt + *pkt_len - (++*offset)) = (u_char) integer;
 2979|    180|    integer >>= 8;
 2980|       |
 2981|    260|    while (integer != testvalue) {
  ------------------
  |  Branch (2981:12): [True: 80, False: 180]
  ------------------
 2982|     80|        if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (2982:13): [True: 0, False: 80]
  ------------------
 2983|      0|            && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2983:18): [True: 0, False: 0]
  |  Branch (2983:23): [True: 0, False: 0]
  ------------------
 2984|      0|            return 0;
 2985|      0|        }
 2986|     80|        *(*pkt + *pkt_len - (++*offset)) = (u_char) integer;
 2987|     80|        integer >>= 8;
 2988|     80|    }
 2989|       |
 2990|    180|    if ((*(*pkt + *pkt_len - *offset) & 0x80) != (testvalue & 0x80)) {
  ------------------
  |  Branch (2990:9): [True: 20, False: 160]
  ------------------
 2991|       |        /*
 2992|       |         * Make sure left most bit is representational of the rest of the bits
 2993|       |         * that aren't encoded.  
 2994|       |         */
 2995|     20|        if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (2995:13): [True: 0, False: 20]
  ------------------
 2996|      0|            && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (2996:18): [True: 0, False: 0]
  |  Branch (2996:23): [True: 0, False: 0]
  ------------------
 2997|      0|            return 0;
 2998|      0|        }
 2999|     20|        *(*pkt + *pkt_len - (++*offset)) = testvalue & 0xff;
 3000|     20|    }
 3001|       |
 3002|    180|    if (asn_realloc_rbuild_header(pkt, pkt_len, offset, r, type,
  ------------------
  |  Branch (3002:9): [True: 180, False: 0]
  ------------------
 3003|    180|                                  (*offset - start_offset))) {
 3004|    180|        if (_asn_realloc_build_header_check(errpre, pkt, pkt_len,
  ------------------
  |  Branch (3004:13): [True: 0, False: 180]
  ------------------
 3005|    180|                                            (*offset - start_offset))) {
 3006|      0|            return 0;
 3007|    180|        } else {
 3008|    180|            DEBUGDUMPSETUP("send", (*pkt + *pkt_len - *offset),
  ------------------
  |  |   83|    180|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    180|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 180]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 180]
  |  |  ------------------
  ------------------
 3009|    180|                           (*offset - start_offset));
 3010|    180|            DEBUGMSG(("dumpv_send", "  Integer:\t%ld (0x%.2lX)\n", *intp,
  ------------------
  |  |   61|    180|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    180|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 180]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 180]
  |  |  ------------------
  ------------------
 3011|    180|                      *intp));
 3012|    180|            return 1;
 3013|    180|        }
 3014|    180|    }
 3015|       |
 3016|      0|    return 0;
 3017|    180|}
asn_realloc_rbuild_string:
 3042|    140|{
 3043|    140|    static const char *errpre = "build string";
 3044|    140|    size_t          start_offset = *offset;
 3045|       |
 3046|    140|    if (str == NULL && strlength > 0) {
  ------------------
  |  Branch (3046:9): [True: 0, False: 140]
  |  Branch (3046:24): [True: 0, False: 0]
  ------------------
 3047|      0|        ERROR_MSG("no string passed into asn_realloc_rbuild_string()\n");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3048|      0|        return 0;
 3049|      0|    }
 3050|       |
 3051|    140|    while ((*pkt_len - *offset) < strlength) {
  ------------------
  |  Branch (3051:12): [True: 0, False: 140]
  ------------------
 3052|      0|        if (!(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (3052:15): [True: 0, False: 0]
  |  Branch (3052:20): [True: 0, False: 0]
  ------------------
 3053|      0|            return 0;
 3054|      0|        }
 3055|      0|    }
 3056|       |
 3057|    140|    *offset += strlength;
 3058|    140|    if (str)
  ------------------
  |  Branch (3058:9): [True: 140, False: 0]
  ------------------
 3059|    140|        memcpy(*pkt + *pkt_len - *offset, str, strlength);
 3060|       |
 3061|    140|    if (asn_realloc_rbuild_header
  ------------------
  |  Branch (3061:9): [True: 140, False: 0]
  ------------------
 3062|    140|        (pkt, pkt_len, offset, r, type, strlength)) {
 3063|    140|        if (_asn_realloc_build_header_check
  ------------------
  |  Branch (3063:13): [True: 0, False: 140]
  ------------------
 3064|    140|            (errpre, pkt, pkt_len, strlength)) {
 3065|      0|            return 0;
 3066|    140|        } else {
 3067|    140|            DEBUGDUMPSETUP("send", (*pkt + *pkt_len - *offset),
  ------------------
  |  |   83|    140|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    140|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 140]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 140]
  |  |  ------------------
  ------------------
 3068|    140|                           *offset - start_offset);
 3069|    140|            DEBUGIF("dumpv_send") {
  ------------------
  |  |  145|    140|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    280|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 140]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
 3070|      0|                if (strlength == 0) {
  ------------------
  |  Branch (3070:21): [True: 0, False: 0]
  ------------------
 3071|      0|                    DEBUGMSG(("dumpv_send", "  String: [NULL]\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]
  |  |  ------------------
  ------------------
 3072|      0|                } else {
 3073|      0|                    u_char         *buf = (u_char *) malloc(2 * strlength);
 3074|      0|                    size_t          l =
 3075|      0|                        (buf != NULL) ? (2 * strlength) : 0, ol = 0;
  ------------------
  |  Branch (3075:25): [True: 0, False: 0]
  ------------------
 3076|       |
 3077|      0|                    if (sprint_realloc_asciistring
  ------------------
  |  Branch (3077:25): [True: 0, False: 0]
  ------------------
 3078|      0|                        (&buf, &l, &ol, 1, str, strlength)) {
 3079|      0|                        DEBUGMSG(("dumpv_send", "  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]
  |  |  ------------------
  ------------------
 3080|      0|                    } else {
 3081|      0|                        if (buf == NULL) {
  ------------------
  |  Branch (3081:29): [True: 0, False: 0]
  ------------------
 3082|      0|                            DEBUGMSG(("dumpv_send",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3083|      0|                                      "  String:\t[TRUNCATED]\n"));
 3084|      0|                        } else {
 3085|      0|                            DEBUGMSG(("dumpv_send",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3086|      0|                                      "  String:\t%s [TRUNCATED]\n", buf));
 3087|      0|                        }
 3088|      0|                    }
 3089|      0|                    if (buf != NULL) {
  ------------------
  |  Branch (3089:25): [True: 0, False: 0]
  ------------------
 3090|      0|                        free(buf);
 3091|      0|                    }
 3092|      0|                }
 3093|      0|            }
 3094|    140|        }
 3095|    140|        return 1;
 3096|    140|    }
 3097|       |
 3098|      0|    return 0;
 3099|    140|}
asn_realloc_rbuild_unsigned_int:
 3122|     20|{
 3123|     20|    static const char *errpre = "build uint";
 3124|     20|    register u_long integer = *intp;
 3125|     20|    size_t          start_offset = *offset;
 3126|       |
 3127|     20|    if (intsize != sizeof(unsigned long)) {
  ------------------
  |  Branch (3127:9): [True: 0, False: 20]
  ------------------
 3128|      0|        _asn_size_err(errpre, intsize, sizeof(unsigned long));
 3129|      0|        return 0;
 3130|      0|    }
 3131|       |
 3132|     20|    CHECK_OVERFLOW_U(integer,11);
  ------------------
  |  |  224|     20|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|     20|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 20]
  |  |  ------------------
  |  |  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|     20|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3133|       |
 3134|     20|    if (((*pkt_len - *offset) < 1) && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (3134:9): [True: 0, False: 20]
  |  Branch (3134:41): [True: 0, False: 0]
  |  Branch (3134:46): [True: 0, False: 0]
  ------------------
 3135|      0|        return 0;
 3136|      0|    }
 3137|     20|    *(*pkt + *pkt_len - (++*offset)) = (u_char) integer;
 3138|     20|    integer >>= 8;
 3139|       |
 3140|     20|    while (integer != 0) {
  ------------------
  |  Branch (3140:12): [True: 0, False: 20]
  ------------------
 3141|      0|        if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (3141:13): [True: 0, False: 0]
  ------------------
 3142|      0|            && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (3142:18): [True: 0, False: 0]
  |  Branch (3142:23): [True: 0, False: 0]
  ------------------
 3143|      0|            return 0;
 3144|      0|        }
 3145|      0|        *(*pkt + *pkt_len - (++*offset)) = (u_char) integer;
 3146|      0|        integer >>= 8;
 3147|      0|    }
 3148|       |
 3149|     20|    if ((*(*pkt + *pkt_len - *offset) & 0x80) != (0 & 0x80)) {
  ------------------
  |  Branch (3149:9): [True: 0, False: 20]
  ------------------
 3150|       |        /*
 3151|       |         * Make sure left most bit is representational of the rest of the bits
 3152|       |         * that aren't encoded.  
 3153|       |         */
 3154|      0|        if (((*pkt_len - *offset) < 1)
  ------------------
  |  Branch (3154:13): [True: 0, False: 0]
  ------------------
 3155|      0|            && !(r && asn_realloc(pkt, pkt_len))) {
  ------------------
  |  Branch (3155:18): [True: 0, False: 0]
  |  Branch (3155:23): [True: 0, False: 0]
  ------------------
 3156|      0|            return 0;
 3157|      0|        }
 3158|      0|        *(*pkt + *pkt_len - (++*offset)) = 0;
 3159|      0|    }
 3160|       |
 3161|     20|    if (asn_realloc_rbuild_header(pkt, pkt_len, offset, r, type,
  ------------------
  |  Branch (3161:9): [True: 20, False: 0]
  ------------------
 3162|     20|                                  (*offset - start_offset))) {
 3163|     20|        if (_asn_realloc_build_header_check(errpre, pkt, pkt_len,
  ------------------
  |  Branch (3163:13): [True: 0, False: 20]
  ------------------
 3164|     20|                                            (*offset - start_offset))) {
 3165|      0|            return 0;
 3166|     20|        } else {
 3167|     20|            DEBUGDUMPSETUP("send", (*pkt + *pkt_len - *offset),
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3168|     20|                           (*offset - start_offset));
 3169|     20|            DEBUGMSG(("dumpv_send", "  UInteger:\t%lu (0x%.2lX)\n", *intp,
  ------------------
  |  |   61|     20|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3170|     20|                      *intp));
 3171|     20|            return 1;
 3172|     20|        }
 3173|     20|    }
 3174|       |
 3175|      0|    return 0;
 3176|     20|}
asn_realloc_rbuild_sequence:
 3199|    140|{
 3200|    140|    return asn_realloc_rbuild_header(pkt, pkt_len, offset, r, type,
 3201|    140|                                     length);
 3202|    140|}
asn_realloc_rbuild_objid:
 3273|     20|{
 3274|       |    /*
 3275|       |     * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
 3276|       |     * subidentifier ::= {leadingbyte}* lastbyte
 3277|       |     * leadingbyte ::= 1 7bitvalue
 3278|       |     * lastbyte ::= 0 7bitvalue
 3279|       |     */
 3280|     20|    register size_t i;
 3281|     20|    register oid    tmpint;
 3282|     20|    size_t          start_offset = *offset;
 3283|     20|    const char     *errpre = "build objid";
 3284|       |
 3285|       |    /*
 3286|       |     * Check if there are at least 2 sub-identifiers.  
 3287|       |     */
 3288|     20|    if (objidlength == 0) {
  ------------------
  |  Branch (3288:9): [True: 0, False: 20]
  ------------------
 3289|       |        /*
 3290|       |         * There are not, so make the OID have two sub-identifiers with value
 3291|       |         * zero. Encode both sub-identifiers as a single byte.
 3292|       |         */
 3293|      0|        if (!store_byte(pkt, pkt_len, offset, r, 0))
  ------------------
  |  Branch (3293:13): [True: 0, False: 0]
  ------------------
 3294|      0|            return 0;
 3295|     20|    } else if (objid[0] > 2) {
  ------------------
  |  Branch (3295:16): [True: 0, False: 20]
  ------------------
 3296|      0|        ERROR_MSG("build objid: bad first subidentifier");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3297|      0|        return 0;
 3298|     20|    } else if (objidlength == 1) {
  ------------------
  |  Branch (3298:16): [True: 0, False: 20]
  ------------------
 3299|       |        /*
 3300|       |         * Encode the first value.  
 3301|       |         */
 3302|      0|        if (!store_byte(pkt, pkt_len, offset, r, 40 * objid[0]))
  ------------------
  |  Branch (3302:13): [True: 0, False: 0]
  ------------------
 3303|      0|            return 0;
 3304|     20|    } else {
 3305|    200|        for (i = objidlength - 1; i >= 2; i--) {
  ------------------
  |  Branch (3305:35): [True: 180, False: 20]
  ------------------
 3306|    180|            tmpint = objid[i];
 3307|    180|            CHECK_OVERFLOW_U(tmpint, 12);
  ------------------
  |  |  224|    180|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|    180|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 180]
  |  |  ------------------
  |  |  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|    180|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 180]
  |  |  ------------------
  ------------------
 3308|    180|            if (!store_uint32(pkt, pkt_len, offset, r, tmpint))
  ------------------
  |  Branch (3308:17): [True: 0, False: 180]
  ------------------
 3309|      0|                return 0;
 3310|    180|        }
 3311|       |
 3312|       |        /*
 3313|       |         * Combine the first two values.  
 3314|       |         */
 3315|     20|        if ((objid[1] >= 40 && objid[0] < 2) ||
  ------------------
  |  Branch (3315:14): [True: 0, False: 20]
  |  Branch (3315:32): [True: 0, False: 0]
  ------------------
 3316|     20|            objid[1] > UINT32_MAX - objid[0] * 40) {
  ------------------
  |  Branch (3316:13): [True: 0, False: 20]
  ------------------
 3317|      0|            return 0;
 3318|      0|        }
 3319|     20|        if (!store_uint32(pkt, pkt_len, offset, r, objid[0] * 40 + objid[1]))
  ------------------
  |  Branch (3319:13): [True: 0, False: 20]
  ------------------
 3320|      0|            return 0;
 3321|     20|    }
 3322|       |
 3323|     20|    tmpint = *offset - start_offset;
 3324|     20|    if (asn_realloc_rbuild_header(pkt, pkt_len, offset, r, type, tmpint)) {
  ------------------
  |  Branch (3324:9): [True: 20, False: 0]
  ------------------
 3325|     20|        if (_asn_realloc_build_header_check(errpre, pkt, pkt_len, tmpint)) {
  ------------------
  |  Branch (3325:13): [True: 0, False: 20]
  ------------------
 3326|      0|            return 0;
 3327|     20|        } else {
 3328|     20|            DEBUGDUMPSETUP("send", (*pkt + *pkt_len - *offset), tmpint);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3329|     20|            DEBUGMSG(("dumpv_send", "  ObjID: "));
  ------------------
  |  |   61|     20|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3330|     20|            DEBUGMSGOID(("dumpv_send", objid, objidlength));
  ------------------
  |  |   67|     20|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3331|     20|            DEBUGMSG(("dumpv_send", "\n"));
  ------------------
  |  |   61|     20|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3332|     20|            return 1;
 3333|     20|        }
 3334|     20|    }
 3335|       |
 3336|      0|    return 0;
 3337|     20|}
asn1.c:_asn_short_err:
  299|    139|{
  300|    139|    char            ebuf[128];
  301|       |
  302|    139|    snprintf(ebuf, sizeof(ebuf), "%s length %lu too short: need %lu", str,
  303|    139|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  304|    139|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|    139|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  305|    139|}
asn1.c:_asn_type_err:
  261|     32|{
  262|     32|    char            ebuf[128];
  263|       |
  264|     32|    snprintf(ebuf, sizeof(ebuf), "%s type %d", str, wrongtype);
  265|     32|    ebuf[ sizeof(ebuf)-1 ] = 0;
  266|     32|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|     32|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  267|     32|}
asn1.c:_asn_length_err:
  280|      6|{
  281|      6|    char            ebuf[128];
  282|       |
  283|      6|    snprintf(ebuf, sizeof(ebuf),
  284|      6|            "%s length %lu too large: exceeds %lu", str,
  285|      6|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  286|      6|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|      6|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  287|      6|}
asn1.c:_asn_realloc_build_header_check:
  453|    360|{
  454|    360|    char            ebuf[128];
  455|       |
  456|    360|    if (pkt == NULL || *pkt == NULL) {
  ------------------
  |  Branch (456:9): [True: 0, False: 360]
  |  Branch (456:24): [True: 0, False: 360]
  ------------------
  457|       |        /*
  458|       |         * Error message is set.  
  459|       |         */
  460|      0|        return 1;
  461|      0|    }
  462|       |
  463|    360|    if (*pkt_len < typedlen) {
  ------------------
  |  Branch (463:9): [True: 0, False: 360]
  ------------------
  464|      0|        snprintf(ebuf, sizeof(ebuf),
  465|      0|                "%s: bad header, length too short: %lu < %lu", str,
  466|      0|                (unsigned long)*pkt_len, (unsigned long)typedlen);
  467|      0|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  468|      0|        return 1;
  469|      0|    }
  470|    360|    return 0;
  471|    360|}
asn1.c:store_byte:
 3217|    200|{
 3218|    200|    netsnmp_assert(*offset <= *pkt_len);
  ------------------
  |  |   47|    200|#      define netsnmp_assert(x)  do { \
  |  |   48|    200|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 200, False: 0]
  |  |  ------------------
  |  |   49|    200|                 ; \
  |  |   50|    200|              else \
  |  |   51|    200|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    200|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 200]
  |  |  ------------------
  ------------------
 3219|    200|    if (*offset >= *pkt_len && (!r || !asn_realloc(pkt, pkt_len)))
  ------------------
  |  Branch (3219:9): [True: 0, False: 200]
  |  Branch (3219:33): [True: 0, False: 0]
  |  Branch (3219:39): [True: 0, False: 0]
  ------------------
 3220|      0|        return 0;
 3221|    200|    netsnmp_assert(*offset < *pkt_len);
  ------------------
  |  |   47|    200|#      define netsnmp_assert(x)  do { \
  |  |   48|    200|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 200, False: 0]
  |  |  ------------------
  |  |   49|    200|                 ; \
  |  |   50|    200|              else \
  |  |   51|    200|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    200|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 200]
  |  |  ------------------
  ------------------
 3222|    200|    *(*pkt + *pkt_len - (++*offset)) = byte;
 3223|    200|    return 1;
 3224|    200|}
asn1.c:store_uint32:
 3239|    200|{
 3240|    200|    if (!store_byte(pkt, pkt_len, offset, r, subid & 0x7f))
  ------------------
  |  Branch (3240:9): [True: 0, False: 200]
  ------------------
 3241|      0|        return 0;
 3242|       |
 3243|    200|    for (subid >>= 7; subid; subid >>= 7)
  ------------------
  |  Branch (3243:23): [True: 0, False: 200]
  ------------------
 3244|      0|        if (!store_byte(pkt, pkt_len, offset, r, subid | 0x80))
  ------------------
  |  Branch (3244:13): [True: 0, False: 0]
  ------------------
 3245|      0|            return 0;
 3246|       |
 3247|    200|    return 1;
 3248|    200|}

init_callbacks:
  196|     48|{
  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|     48|    if (0 == _callback_need_init)
  ------------------
  |  Branch (202:9): [True: 47, False: 1]
  ------------------
  203|     47|        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|    517|{
  257|    517|    return netsnmp_register_callback( major, minor, new_callback, arg,
  258|    517|                                      NETSNMP_CALLBACK_DEFAULT_PRIORITY);
  ------------------
  |  |   40|    517|#define NETSNMP_CALLBACK_DEFAULT_PRIORITY       0
  ------------------
  259|    517|}
netsnmp_register_callback:
  278|    517|{
  279|    517|    struct snmp_gen_callback *newscp = NULL, *scp = NULL;
  280|       |
  281|    517|    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   12|  1.03k|#define MAX_CALLBACK_IDS    2
  ------------------
                  if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|    517|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (281:9): [True: 0, False: 517]
  |  Branch (281:38): [True: 0, False: 517]
  ------------------
  282|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|    517|    if (_callback_need_init)
  ------------------
  |  Branch (285:9): [True: 1, False: 516]
  ------------------
  286|      1|        init_callbacks();
  287|       |
  288|    517|    _callback_lock(major,minor, "netsnmp_register_callback", 1);
  289|       |    
  290|    517|    if ((newscp = SNMP_MALLOC_STRUCT(snmp_gen_callback)) == NULL) {
  ------------------
  |  |   69|    517|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  |  Branch (290:9): [True: 0, False: 517]
  ------------------
  291|      0|        _callback_unlock(major,minor);
  292|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  293|    517|    } else {
  294|    517|        struct snmp_gen_callback **prevNext = &(thecallbacks[major][minor]);
  295|       |
  296|    517|        newscp->priority = priority;
  297|    517|        newscp->sc_client_arg = arg;
  298|    517|        newscp->sc_callback = new_callback;
  299|    517|        newscp->next = NULL;
  300|       |
  301|    940|        for (scp = thecallbacks[major][minor]; scp != NULL;
  ------------------
  |  Branch (301:48): [True: 423, False: 517]
  ------------------
  302|    517|             scp = scp->next) {
  303|    423|            if (newscp->priority < scp->priority) {
  ------------------
  |  Branch (303:17): [True: 0, False: 423]
  ------------------
  304|      0|                newscp->next = scp;
  305|      0|                break;
  306|      0|            }
  307|    423|            prevNext = &(scp->next);
  308|    423|        }
  309|       |
  310|    517|        *prevNext = newscp;
  311|       |
  312|    517|        DEBUGMSGTL(("callback", "registered (%d,%d) at %p with priority %d\n",
  ------------------
  |  |   66|    517|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    517|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 517]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 517]
  |  |  ------------------
  ------------------
  313|    517|                    major, minor, newscp, priority));
  314|    517|        _callback_unlock(major,minor);
  315|    517|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    517|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  316|    517|    }
  317|    517|}
snmp_call_callbacks:
  338|    329|{
  339|    329|    struct snmp_gen_callback *scp;
  340|    329|    unsigned int    count = 0;
  341|       |    
  342|    329|    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   12|    658|#define MAX_CALLBACK_IDS    2
  ------------------
                  if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|    329|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (342:9): [True: 0, False: 329]
  |  Branch (342:38): [True: 0, False: 329]
  ------------------
  343|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  344|      0|    }
  345|       |    
  346|    329|    if (_callback_need_init)
  ------------------
  |  Branch (346:9): [True: 0, False: 329]
  ------------------
  347|      0|        init_callbacks();
  348|       |
  349|    329|#ifdef LOCK_PER_CALLBACK_SUBID
  350|    329|    _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|    329|    DEBUGMSGTL(("callback", "START calling callbacks for maj=%d min=%d\n",
  ------------------
  |  |   66|    329|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    329|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 329]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 329]
  |  |  ------------------
  ------------------
  361|    329|                major, minor));
  362|       |
  363|       |    /*
  364|       |     * for each registered callback of type major and minor 
  365|       |     */
  366|    846|    for (scp = thecallbacks[major][minor]; scp != NULL; scp = scp->next) {
  ------------------
  |  Branch (366:44): [True: 517, False: 329]
  ------------------
  367|       |
  368|       |        /*
  369|       |         * skip unregistered callbacks
  370|       |         */
  371|    517|        if(NULL == scp->sc_callback)
  ------------------
  |  Branch (371:12): [True: 0, False: 517]
  ------------------
  372|      0|            continue;
  373|       |
  374|    517|        DEBUGMSGTL(("callback", "calling a callback for maj=%d min=%d\n",
  ------------------
  |  |   66|    517|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    517|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 517]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 517]
  |  |  ------------------
  ------------------
  375|    517|                    major, minor));
  376|       |
  377|       |        /*
  378|       |         * call them 
  379|       |         */
  380|    517|        (*(scp->sc_callback)) (major, minor, caller_arg,
  381|    517|                               scp->sc_client_arg);
  382|    517|        count++;
  383|    517|    }
  384|       |
  385|    329|    DEBUGMSGTL(("callback",
  ------------------
  |  |   66|    329|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    329|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 329]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 329]
  |  |  ------------------
  ------------------
  386|    329|                "END calling callbacks for maj=%d min=%d (%d called)\n",
  387|    329|                major, minor, count));
  388|       |
  389|    329|    _callback_unlock(major,minor);
  390|    329|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    329|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  391|    329|}
netsnmp_callback_clear_client_arg:
  516|     94|{
  517|     94|    struct snmp_gen_callback *scp = NULL;
  518|     94|    int rc = 0;
  519|       |
  520|       |    /*
  521|       |     * don't init i and j before loop, since the caller specified
  522|       |     * the starting point explicitly. But *after* the i loop has
  523|       |     * finished executing once, init j to 0 for the next pass
  524|       |     * through the subids.
  525|       |     */
  526|    282|    for (; i < MAX_CALLBACK_IDS; i++,j=0) {
  ------------------
  |  |   12|    282|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (526:12): [True: 188, False: 94]
  ------------------
  527|  3.52k|        for (; j < MAX_CALLBACK_SUBIDS; j++) {
  ------------------
  |  |   13|  3.52k|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (527:16): [True: 3.33k, False: 188]
  ------------------
  528|  3.33k|            scp = thecallbacks[i][j]; 
  529|  4.18k|            while (scp != NULL) {
  ------------------
  |  Branch (529:20): [True: 846, False: 3.33k]
  ------------------
  530|    846|                if ((NULL != scp->sc_callback) &&
  ------------------
  |  Branch (530:21): [True: 846, False: 0]
  ------------------
  531|    846|                    (scp->sc_client_arg != NULL) &&
  ------------------
  |  Branch (531:21): [True: 47, False: 799]
  ------------------
  532|     47|                    (scp->sc_client_arg == ptr)) {
  ------------------
  |  Branch (532:21): [True: 0, False: 47]
  ------------------
  533|      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]
  |  |  ------------------
  ------------------
  534|      0|                    scp->sc_client_arg = NULL;
  535|      0|                    ++rc;
  536|      0|                }
  537|    846|                scp = scp->next;
  538|    846|            }
  539|  3.33k|        }
  540|    188|    }
  541|       |
  542|     94|    if (0 != rc) {
  ------------------
  |  Branch (542:9): [True: 0, False: 94]
  ------------------
  543|      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]
  |  |  ------------------
  ------------------
  544|      0|    }
  545|       |
  546|     94|    return rc;
  547|     94|}
clear_callback:
  551|     47|{
  552|     47|    unsigned int i = 0, j = 0;
  553|     47|    struct snmp_gen_callback *scp = NULL;
  554|       |
  555|     47|    if (_callback_need_init)
  ------------------
  |  Branch (555:9): [True: 0, False: 47]
  ------------------
  556|      0|        init_callbacks();
  557|       |
  558|     47|    DEBUGMSGTL(("callback", "clear callback\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  559|    141|    for (i = 0; i < MAX_CALLBACK_IDS; i++) {
  ------------------
  |  |   12|    141|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (559:17): [True: 94, False: 47]
  ------------------
  560|  1.78k|        for (j = 0; j < MAX_CALLBACK_SUBIDS; j++) {
  ------------------
  |  |   13|  1.78k|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (560:21): [True: 1.69k, False: 94]
  ------------------
  561|  1.69k|            _callback_lock(i,j, "clear_callback", 1);
  562|  1.69k|            scp = thecallbacks[i][j];
  563|  2.20k|            while (scp != NULL) {
  ------------------
  |  Branch (563:20): [True: 517, False: 1.69k]
  ------------------
  564|    517|                thecallbacks[i][j] = scp->next;
  565|       |                /*
  566|       |                 * if there is a client arg, check for duplicates
  567|       |                 * and then free it.
  568|       |                 */
  569|    517|                if ((NULL != scp->sc_callback) &&
  ------------------
  |  Branch (569:21): [True: 517, False: 0]
  ------------------
  570|    517|                    (scp->sc_client_arg != NULL)) {
  ------------------
  |  Branch (570:21): [True: 47, False: 470]
  ------------------
  571|     47|                    void *tmp_arg;
  572|       |                    /*
  573|       |                     * save the client arg, then set it to null so that it
  574|       |                     * won't look like a duplicate, then check for duplicates
  575|       |                     * starting at the current i,j (earlier dups should have
  576|       |                     * already been found) and free the pointer.
  577|       |                     */
  578|     47|                    tmp_arg = scp->sc_client_arg;
  579|     47|                    scp->sc_client_arg = NULL;
  580|     47|                    DEBUGMSGTL(("9:callback", "  freeing %p at [%d,%d]\n", tmp_arg, i, j));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  581|     47|                    (void)netsnmp_callback_clear_client_arg(tmp_arg, i, j);
  582|     47|                    free(tmp_arg);
  583|     47|                }
  584|       |                SNMP_FREE(scp);
  ------------------
  |  |   62|    517|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 517, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 517]
  |  |  ------------------
  ------------------
  585|    517|                scp = thecallbacks[i][j];
  586|    517|            }
  587|  1.69k|            _callback_unlock(i,j);
  588|  1.69k|        }
  589|     94|    }
  590|     47|}
callback.c:_callback_lock:
  119|  2.53k|{
  120|  2.53k|    int lock_holded=0;
  121|  2.53k|    NETSNMP_SELECT_TIMEVAL lock_time;
  ------------------
  |  | 1755|  2.53k|#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|  2.53k|#ifdef CALLBACK_NAME_LOGGING
  131|  2.53k|    DEBUGMSGTL(("9:callback:lock", "locked (%s,%s)\n",
  ------------------
  |  |   66|  2.53k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.53k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#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: 2.53k]
  |  |  ------------------
  ------------------
  132|  2.53k|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  133|  2.53k|                SNMP_STRORNULL(lib[minor]) : "null"));
  134|  2.53k|#endif
  135|  2.53k|    while (CALLBACK_LOCK_COUNT(major,minor) >= 1 && ++lock_holded < 100) {
  ------------------
  |  |  109|  2.53k|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (135:12): [True: 0, False: 2.53k]
  |  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|  2.53k|    if(lock_holded >= 100) {
  ------------------
  |  Branch (141:8): [True: 0, False: 2.53k]
  ------------------
  142|      0|        if (NULL != warn)
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|            snmp_log(LOG_WARNING,
  144|      0|                     "lock in _callback_lock sleeps more than 100 milliseconds in %s\n", warn);
  145|      0|        if (do_assert)
  ------------------
  |  Branch (145:13): [True: 0, False: 0]
  ------------------
  146|      0|            netsnmp_assert(lock_holded < 100);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  147|       |        
  148|      0|        return 1;
  149|      0|    }
  150|       |
  151|  2.53k|    CALLBACK_LOCK(major,minor);
  ------------------
  |  |  107|  2.53k|#define CALLBACK_LOCK(maj,min) ++_locks[maj][min]
  ------------------
  152|  2.53k|    return 0;
  153|  2.53k|}
callback.c:_callback_unlock:
  157|  2.53k|{
  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|  2.53k|    CALLBACK_UNLOCK(major,minor);
  ------------------
  |  |  108|  2.53k|#define CALLBACK_UNLOCK(maj,min) --_locks[maj][min]
  ------------------
  166|       |
  167|  2.53k|    if (CALLBACK_LOCK_COUNT(major,minor) == 0) {
  ------------------
  |  |  109|  2.53k|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (167:9): [True: 2.53k, False: 0]
  ------------------
  168|  2.53k|        struct snmp_gen_callback *scp, **prevNext;
  169|  2.53k|        scp = thecallbacks[major][minor];
  170|  2.53k|        prevNext = &(thecallbacks[major][minor]);
  171|  3.99k|        while (scp != NULL) {
  ------------------
  |  Branch (171:16): [True: 1.45k, False: 2.53k]
  ------------------
  172|  1.45k|            if (scp->sc_callback == NULL) {
  ------------------
  |  Branch (172:17): [True: 0, False: 1.45k]
  ------------------
  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.45k|            } else {
  177|  1.45k|                prevNext = &(scp->next);
  178|  1.45k|                scp = scp->next;
  179|  1.45k|            }
  180|  1.45k|        }
  181|  2.53k|    }
  182|       |
  183|  2.53k|#ifdef CALLBACK_NAME_LOGGING
  184|  2.53k|    DEBUGMSGTL(("9:callback:lock", "unlocked (%s,%s)\n",
  ------------------
  |  |   66|  2.53k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.53k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#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: 2.53k]
  |  |  ------------------
  ------------------
  185|  2.53k|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  186|  2.53k|                SNMP_STRORNULL(lib[minor]) : "null"));
  187|  2.53k|#endif
  188|  2.53k|}

_netsnmp_release_trustcerts:
  175|    141|{
  176|    141|    if (NULL != _trusted_certs) {
  ------------------
  |  Branch (176:9): [True: 47, False: 94]
  ------------------
  177|     47|        CONTAINER_FREE_ALL(_trusted_certs, NULL);
  178|     47|        CONTAINER_FREE(_trusted_certs);
  179|       |        _trusted_certs = NULL;
  180|     47|    }
  181|    141|}
_setup_trusted_certs:
  185|     47|{
  186|     47|    _trusted_certs = netsnmp_container_find("trusted_certs:fifo");
  187|     47|    if (NULL == _trusted_certs) {
  ------------------
  |  Branch (187:9): [True: 0, False: 47]
  ------------------
  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|     47|    _trusted_certs->container_name = strdup("trusted certificates");
  193|     47|    _trusted_certs->compare = netsnmp_str_compare;
  194|     47|}
netsnmp_certs_init:
  209|     47|{
  210|     47|    const char *trustCert_help = TRUSTCERT_CONFIG_TOKEN
  ------------------
  |  |  140|     47|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  211|     47|        " FINGERPRINT|FILENAME";
  212|       |
  213|     47|    register_config_handler("snmp", TRUSTCERT_CONFIG_TOKEN,
  ------------------
  |  |  140|     47|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  214|     47|                            _parse_trustcert, _netsnmp_release_trustcerts,
  215|     47|                            trustCert_help);
  216|     47|    _setup_containers();
  217|       |
  218|       |    /** add certificate type mapping */
  219|     47|    se_add_pair_to_slist("cert_types", strdup("pem"), NS_CERT_TYPE_PEM);
  220|     47|    se_add_pair_to_slist("cert_types", strdup("crt"), NS_CERT_TYPE_DER);
  221|     47|    se_add_pair_to_slist("cert_types", strdup("cer"), NS_CERT_TYPE_DER);
  222|     47|    se_add_pair_to_slist("cert_types", strdup("cert"), NS_CERT_TYPE_DER);
  223|     47|    se_add_pair_to_slist("cert_types", strdup("der"), NS_CERT_TYPE_DER);
  224|     47|    se_add_pair_to_slist("cert_types", strdup("key"), NS_CERT_TYPE_KEY);
  225|     47|    se_add_pair_to_slist("cert_types", strdup("private"), NS_CERT_TYPE_KEY);
  226|       |
  227|       |    /** hash algs */
  228|     47|    se_add_pair_to_slist("cert_hash_alg", strdup("sha1"), NS_HASH_SHA1);
  ------------------
  |  |   85|     47|#define NS_HASH_SHA1        2
  ------------------
  229|     47|    se_add_pair_to_slist("cert_hash_alg", strdup("md5"), NS_HASH_MD5);
  ------------------
  |  |   84|     47|#define NS_HASH_MD5         1
  ------------------
  230|     47|    se_add_pair_to_slist("cert_hash_alg", strdup("sha224"), NS_HASH_SHA224);
  ------------------
  |  |   86|     47|#define NS_HASH_SHA224      3
  ------------------
  231|     47|    se_add_pair_to_slist("cert_hash_alg", strdup("sha256"), NS_HASH_SHA256);
  ------------------
  |  |   87|     47|#define NS_HASH_SHA256      4
  ------------------
  232|     47|    se_add_pair_to_slist("cert_hash_alg", strdup("sha384"), NS_HASH_SHA384);
  ------------------
  |  |   88|     47|#define NS_HASH_SHA384      5
  ------------------
  233|     47|    se_add_pair_to_slist("cert_hash_alg", strdup("sha512"), NS_HASH_SHA512);
  ------------------
  |  |   89|     47|#define NS_HASH_SHA512      6
  ------------------
  234|       |
  235|       |    /** map types */
  236|     47|    se_add_pair_to_slist("cert_map_type", strdup("cn"),
  237|     47|                         TSNM_tlstmCertCommonName);
  ------------------
  |  |  129|     47|#define TSNM_tlstmCertCommonName                6
  ------------------
  238|     47|    se_add_pair_to_slist("cert_map_type", strdup("ip"),
  239|     47|                         TSNM_tlstmCertSANIpAddress);
  ------------------
  |  |  127|     47|#define TSNM_tlstmCertSANIpAddress              4
  ------------------
  240|     47|    se_add_pair_to_slist("cert_map_type", strdup("rfc822"),
  241|     47|                         TSNM_tlstmCertSANRFC822Name);
  ------------------
  |  |  125|     47|#define TSNM_tlstmCertSANRFC822Name             2
  ------------------
  242|     47|    se_add_pair_to_slist("cert_map_type", strdup("dns"),
  243|     47|                         TSNM_tlstmCertSANDNSName);
  ------------------
  |  |  126|     47|#define TSNM_tlstmCertSANDNSName                3
  ------------------
  244|     47|    se_add_pair_to_slist("cert_map_type", strdup("any"), TSNM_tlstmCertSANAny);
  ------------------
  |  |  128|     47|#define TSNM_tlstmCertSANAny                    5
  ------------------
  245|     47|    se_add_pair_to_slist("cert_map_type", strdup("sn"),
  246|     47|                         TSNM_tlstmCertSpecified);
  ------------------
  |  |  124|     47|#define TSNM_tlstmCertSpecified                 1
  ------------------
  247|       |
  248|     47|}
netsnmp_certs_shutdown:
  252|     47|{
  253|     47|    netsnmp_container ***c, **containers[] = {
  254|     47|        &_tlstmParams, &_tlstmAddr, &_maps, &_certs, &_keys, NULL
  255|     47|    };
  256|       |
  257|     47|    DEBUGMSGT(("cert:util:shutdown","shutdown\n"));
  ------------------
  |  |   62|     47|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 47]
  |  |  ------------------
  ------------------
  258|       |
  259|    282|    for (c = containers; *c; c++) {
  ------------------
  |  Branch (259:26): [True: 235, False: 47]
  ------------------
  260|    235|        if (!**c)
  ------------------
  |  Branch (260:13): [True: 141, False: 94]
  ------------------
  261|    141|            continue;
  262|     94|        CONTAINER_FREE_ALL(**c, NULL);
  263|     94|        CONTAINER_FREE(**c);
  264|       |        **c = NULL;
  265|     94|    }
  266|     47|    _netsnmp_release_trustcerts();
  267|     47|}
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|     47|{
  354|     47|    netsnmp_container *additional_keys;
  355|       |
  356|     47|    int rc;
  357|       |
  358|     47|    _certs = _get_cert_container("netsnmp certificates");
  359|     47|    if (NULL == _certs)
  ------------------
  |  Branch (359:9): [True: 0, False: 47]
  ------------------
  360|      0|        return;
  361|       |
  362|       |    /** additional keys: common name */
  363|     47|    additional_keys = netsnmp_container_find("certs_cn:binary_array");
  364|     47|    if (NULL == additional_keys) {
  ------------------
  |  Branch (364:9): [True: 0, False: 47]
  ------------------
  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|     47|    additional_keys->container_name = strdup("certs_cn");
  370|     47|    additional_keys->free_item = NULL;
  371|     47|    additional_keys->compare = _cert_cn_compare;
  372|     47|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     47|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     47|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 47]
  |  |  ------------------
  |  |  377|     47|            rc = -1;                                                    \
  |  |  378|     47|        else {                                                          \
  |  |  379|     47|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     47|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 47, False: 0]
  |  |  ------------------
  |  |  381|     47|                (x)->flags |= o;                                        \
  |  |  382|     47|        }                                                               \
  |  |  383|     47|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 47]
  |  |  ------------------
  ------------------
  373|     47|    netsnmp_container_add_index(_certs, additional_keys);
  374|       |
  375|       |    /** additional keys: subject name */
  376|     47|    additional_keys = netsnmp_container_find("certs_sn:binary_array");
  377|     47|    if (NULL == additional_keys) {
  ------------------
  |  Branch (377:9): [True: 0, False: 47]
  ------------------
  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|     47|    additional_keys->container_name = strdup("certs_sn");
  383|     47|    additional_keys->free_item = NULL;
  384|     47|    additional_keys->compare = _cert_sn_compare;
  385|     47|    additional_keys->ncompare = _cert_sn_ncompare;
  386|     47|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     47|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     47|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 47]
  |  |  ------------------
  |  |  377|     47|            rc = -1;                                                    \
  |  |  378|     47|        else {                                                          \
  |  |  379|     47|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     47|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 47, False: 0]
  |  |  ------------------
  |  |  381|     47|                (x)->flags |= o;                                        \
  |  |  382|     47|        }                                                               \
  |  |  383|     47|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 47]
  |  |  ------------------
  ------------------
  387|     47|    netsnmp_container_add_index(_certs, additional_keys);
  388|       |
  389|       |    /** additional keys: file name */
  390|     47|    additional_keys = netsnmp_container_find("certs_fn:binary_array");
  391|     47|    if (NULL == additional_keys) {
  ------------------
  |  Branch (391:9): [True: 0, False: 47]
  ------------------
  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|     47|    additional_keys->container_name = strdup("certs_fn");
  397|     47|    additional_keys->free_item = NULL;
  398|     47|    additional_keys->compare = _cert_fn_compare;
  399|     47|    additional_keys->ncompare = _cert_fn_ncompare;
  400|     47|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     47|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     47|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 47]
  |  |  ------------------
  |  |  377|     47|            rc = -1;                                                    \
  |  |  378|     47|        else {                                                          \
  |  |  379|     47|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     47|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 47, False: 0]
  |  |  ------------------
  |  |  381|     47|                (x)->flags |= o;                                        \
  |  |  382|     47|        }                                                               \
  |  |  383|     47|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 47]
  |  |  ------------------
  ------------------
  401|     47|    netsnmp_container_add_index(_certs, additional_keys);
  402|       |
  403|     47|    _keys = netsnmp_container_find("cert_keys:binary_array");
  404|     47|    if (NULL == _keys) {
  ------------------
  |  Branch (404:9): [True: 0, False: 47]
  ------------------
  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|     47|    _keys->container_name = strdup("netsnmp certificate keys");
  410|     47|    _keys->free_item = _key_free;
  411|     47|    _keys->compare = _cert_fn_compare;
  412|       |
  413|     47|    _setup_trusted_certs();
  414|     47|}
cert_util.c:_get_cert_container:
  332|     47|{
  333|     47|    netsnmp_container *c;
  334|       |
  335|     47|    int rc;
  336|       |
  337|     47|    c = netsnmp_container_find("certs:binary_array");
  338|     47|    if (NULL == c) {
  ------------------
  |  Branch (338:9): [True: 0, False: 47]
  ------------------
  339|      0|        snmp_log(LOG_ERR, "could not create container for %s\n", use);
  340|      0|        return NULL;
  341|      0|    }
  342|     47|    c->container_name = strdup(use);
  343|     47|    c->free_item = _cert_free;
  344|     47|    c->compare = _cert_compare;
  345|       |
  346|     47|    CONTAINER_SET_OPTIONS(c, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     47|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     47|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 47]
  |  |  ------------------
  |  |  377|     47|            rc = -1;                                                    \
  |  |  378|     47|        else {                                                          \
  |  |  379|     47|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     47|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 47, False: 0]
  |  |  ------------------
  |  |  381|     47|                (x)->flags |= o;                                        \
  |  |  382|     47|        }                                                               \
  |  |  383|     47|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 47]
  |  |  ------------------
  ------------------
  347|       |
  348|     47|    return c;
  349|     47|}
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);
  ------------------
  |  | 2008|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1639|       |
 1640|     12|    DEBUGMSGT(("9:cert:dir:add", " config dir: %s\n", dirname ));
  ------------------
  |  |   62|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 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|     47|{
   83|     47|    if (NULL != containers)
  ------------------
  |  Branch (83:9): [True: 0, False: 47]
  ------------------
   84|      0|        return;
   85|       |
   86|       |    /*
   87|       |     * create a binary array container to hold container
   88|       |     * factories
   89|       |     */
   90|     47|    containers = netsnmp_container_get_binary_array();
   91|     47|    containers->compare = netsnmp_compare_cstring;
   92|     47|    containers->container_name = strdup("container list");
   93|       |
   94|       |    /*
   95|       |     * register containers
   96|       |     */
   97|     47|    netsnmp_container_binary_array_init();
   98|     47|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
   99|     47|    netsnmp_container_ssll_init();
  100|     47|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  101|     47|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_NULL
  102|     47|    netsnmp_container_null_init();
  103|     47|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_NULL */
  104|       |
  105|       |    /*
  106|       |     * default aliases for some containers
  107|       |     */
  108|     47|    netsnmp_container_register("table_container",
  109|     47|                               netsnmp_container_get_factory("binary_array"));
  110|       |
  111|     47|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
  112|     47|    netsnmp_container_register("linked_list",
  113|     47|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  114|     47|    netsnmp_container_register("ssll_container",
  115|     47|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  116|     47|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  117|       |
  118|     47|    netsnmp_container_register_with_compare
  119|     47|        ("cstring", netsnmp_container_get_factory("binary_array"),
  120|     47|         netsnmp_compare_direct_cstring);
  121|       |
  122|     47|    netsnmp_container_register_with_compare
  123|     47|        ("string", netsnmp_container_get_factory("binary_array"),
  124|     47|         netsnmp_compare_cstring);
  125|     47|    netsnmp_container_register_with_compare
  126|     47|        ("string_binary_array", netsnmp_container_get_factory("binary_array"),
  127|     47|         netsnmp_compare_cstring);
  128|       |
  129|     47|}
netsnmp_container_free_list:
  133|     47|{
  134|     47|    DEBUGMSGTL(("container", "netsnmp_container_free_list() called\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  135|     47|    if (containers == NULL)
  ------------------
  |  Branch (135:9): [True: 0, False: 47]
  ------------------
  136|      0|	return;
  137|       |
  138|       |    /*
  139|       |     * free memory used by each factory entry
  140|       |     */
  141|     47|    CONTAINER_FOR_EACH(containers, _factory_free, NULL);
  ------------------
  |  |  406|     47|#define CONTAINER_FOR_EACH(x,f,c)   (x)->for_each(x,f,c)
  ------------------
  142|       |
  143|       |    /*
  144|       |     * free factory container
  145|       |     */
  146|     47|    CONTAINER_FREE(containers);
  147|       |    containers = NULL;
  148|     47|}
netsnmp_container_register_with_compare:
  153|    564|{
  154|    564|    container_type *ct, tmp;
  155|       |
  156|    564|    if (NULL==containers)
  ------------------
  |  Branch (156:9): [True: 0, False: 564]
  ------------------
  157|      0|        return -1;
  158|       |
  159|    564|    tmp.name = name;
  160|    564|    ct = (container_type *)CONTAINER_FIND(containers, &tmp);
  ------------------
  |  |  394|    564|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  161|    564|    if (NULL!=ct) {
  ------------------
  |  Branch (161:9): [True: 0, False: 564]
  ------------------
  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|    564|    else {
  167|    564|        ct = SNMP_MALLOC_TYPEDEF(container_type);
  ------------------
  |  |   73|    564|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  168|    564|        if (NULL == ct)
  ------------------
  |  Branch (168:13): [True: 0, False: 564]
  ------------------
  169|      0|            return -1;
  170|    564|        ct->name = strdup(name);
  171|    564|        ct->factory = f;
  172|    564|        ct->compare = c;
  173|    564|        CONTAINER_INSERT(containers, ct);
  174|    564|    }
  175|    564|    DEBUGMSGT(("container_registry", "registered container factory %s (%s)\n",
  ------------------
  |  |   62|    564|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    564|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 564]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 564]
  |  |  ------------------
  ------------------
  176|    564|               ct->name, f->product));
  177|       |
  178|    564|    return 0;
  179|    564|}
netsnmp_container_register:
  183|    423|{
  184|       |    return netsnmp_container_register_with_compare(name, f, NULL);
  185|    423|}
netsnmp_container_get_factory:
  191|    282|{
  192|    282|    container_type ct, *found;
  193|       |    
  194|    282|    if (NULL==containers)
  ------------------
  |  Branch (194:9): [True: 0, False: 282]
  ------------------
  195|      0|        return NULL;
  196|       |
  197|    282|    ct.name = type;
  198|    282|    found = (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  394|    282|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  199|       |
  200|    282|    return found ? found->factory : NULL;
  ------------------
  |  Branch (200:12): [True: 282, False: 0]
  ------------------
  201|    282|}
netsnmp_container_find:
  300|    282|{
  301|    282|    container_type *ct = netsnmp_container_find_ct(type);
  302|    282|    netsnmp_container *c = ct ? (netsnmp_container *)(ct->factory->produce()) : NULL;
  ------------------
  |  Branch (302:28): [True: 282, False: 0]
  ------------------
  303|       |
  304|       |    /*
  305|       |     * provide default compare and ncompare
  306|       |     */
  307|    282|    if (c) {
  ------------------
  |  Branch (307:9): [True: 282, False: 0]
  ------------------
  308|    282|        if (ct->compare)
  ------------------
  |  Branch (308:13): [True: 0, False: 282]
  ------------------
  309|      0|            c->compare = ct->compare;
  310|    282|        else if (NULL == c->compare)
  ------------------
  |  Branch (310:18): [True: 282, False: 0]
  ------------------
  311|    282|            c->compare = netsnmp_compare_netsnmp_index;
  312|       |
  313|    282|        if (NULL == c->ncompare)
  ------------------
  |  Branch (313:13): [True: 282, False: 0]
  ------------------
  314|    282|            c->ncompare = netsnmp_ncompare_netsnmp_index;
  315|    282|    }
  316|       |
  317|    282|    return c;
  318|    282|}
netsnmp_container_add_index:
  325|    141|{
  326|    141|    netsnmp_container *curr = primary;
  327|       |
  328|    141|    if((NULL == new_index) || (NULL == primary)) {
  ------------------
  |  Branch (328:8): [True: 0, False: 141]
  |  Branch (328:31): [True: 0, False: 141]
  ------------------
  329|      0|        snmp_log(LOG_ERR, "add index called with null pointer\n");
  330|      0|        return;
  331|      0|    }
  332|       |
  333|    282|    while(curr->next)
  ------------------
  |  Branch (333:11): [True: 141, False: 141]
  ------------------
  334|    141|        curr = curr->next;
  335|       |
  336|    141|    curr->next = new_index;
  337|    141|    new_index->prev = curr;
  338|    141|}
CONTAINER_INSERT_HELPER:
  341|  1.12k|{
  342|  1.12k|    while(x && x->insert_filter && x->insert_filter(x,k) == 1)
  ------------------
  |  Branch (342:11): [True: 564, False: 564]
  |  Branch (342:16): [True: 0, False: 564]
  |  Branch (342:36): [True: 0, False: 0]
  ------------------
  343|      0|        x = x->next;
  344|  1.12k|    if(x) {
  ------------------
  |  Branch (344:8): [True: 564, False: 564]
  ------------------
  345|    564|        int rc = x->insert(x,k);
  346|    564|        if(rc)
  ------------------
  |  Branch (346:12): [True: 0, False: 564]
  ------------------
  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|    564|        else {
  350|    564|            rc = CONTAINER_INSERT_HELPER(x->next, k);
  351|    564|            if(rc)
  ------------------
  |  Branch (351:16): [True: 0, False: 564]
  ------------------
  352|      0|                x->remove(x,k);
  353|    564|        }
  354|    564|        return rc;
  355|    564|    }
  356|    564|    return 0;
  357|  1.12k|}
CONTAINER_INSERT:
  360|    564|{
  361|       |    /** start at first container */
  362|    564|    while(x->prev)
  ------------------
  |  Branch (362:11): [True: 0, False: 564]
  ------------------
  363|      0|        x = x->prev;
  364|    564|    return CONTAINER_INSERT_HELPER(x, k);
  365|    564|}
CONTAINER_FREE:
  469|    188|{
  470|    188|    int  rc2, rc = 0;
  471|       |
  472|    188|    if (!x)
  ------------------
  |  Branch (472:9): [True: 0, False: 188]
  ------------------
  473|      0|        return rc;
  474|       |
  475|       |    /** start at last container */
  476|    329|    while(x->next)
  ------------------
  |  Branch (476:11): [True: 141, False: 188]
  ------------------
  477|    141|        x = x->next;
  478|    517|    while(x) {
  ------------------
  |  Branch (478:11): [True: 329, False: 188]
  ------------------
  479|    329|        netsnmp_container *tmp;
  480|    329|        char *name;
  481|    329|        tmp = x->prev;
  482|    329|        name = x->container_name;
  483|    329|        x->container_name = NULL;
  484|    329|        rc2 = x->cfree(x);
  485|    329|        if (rc2) {
  ------------------
  |  Branch (485:13): [True: 0, False: 329]
  ------------------
  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|    329|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 329, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 329]
  |  |  ------------------
  ------------------
  491|    329|        x = tmp;
  492|    329|    }
  493|    188|    return rc;
  494|    188|}
CONTAINER_CLEAR:
  503|    141|{
  504|       |    /** start at last container */
  505|    282|    while(x->next)
  ------------------
  |  Branch (505:11): [True: 141, False: 141]
  ------------------
  506|    141|        x = x->next;
  507|    282|    while(x->prev) {
  ------------------
  |  Branch (507:11): [True: 141, False: 141]
  ------------------
  508|       |        x->clear(x, NULL, c);
  509|    141|        x = x->prev;
  510|    141|    }
  511|    141|    x->clear(x, f, c);
  512|    141|#ifdef HAVE_MALLOC_TRIM
  513|    141|    malloc_trim(0);
  514|    141|#endif
  515|    141|}
CONTAINER_FREE_ALL:
  524|    141|{
  525|    141|    CONTAINER_CLEAR(x, x->free_item, c);
  526|    141|}
netsnmp_init_container:
  563|    329|{
  564|    329|    if (c == NULL)
  ------------------
  |  Branch (564:9): [True: 0, False: 329]
  ------------------
  565|      0|        return;
  566|       |
  567|    329|    c->init = init;
  568|    329|    c->cfree = cfree;
  569|    329|    c->get_size = size;
  570|    329|    c->compare = cmp;
  571|    329|    c->insert = ins;
  572|    329|    c->remove = rem;
  573|    329|    c->find = fnd;
  574|    329|    c->free_item = netsnmp_container_simple_free;
  575|    329|}
netsnmp_compare_cstring:
  643|  7.00k|{
  644|  7.00k|    const container_type *lhs = lhs_arg;
  645|  7.00k|    const container_type *rhs = rhs_arg;
  646|       |
  647|  7.00k|    return strcmp(lhs->name, rhs->name);
  648|  7.00k|}
container.c:_factory_free:
   65|    564|{
   66|    564|    container_type *data = (container_type *)dat;
   67|    564|    if (data == NULL)
  ------------------
  |  Branch (67:9): [True: 0, False: 564]
  ------------------
   68|      0|	return;
   69|       |    
   70|    564|    if (data->name != NULL) {
  ------------------
  |  Branch (70:9): [True: 564, False: 0]
  ------------------
   71|    564|        DEBUGMSGTL(("container", "  _factory_free_list() called for %s\n",
  ------------------
  |  |   66|    564|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    564|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 564]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 564]
  |  |  ------------------
  ------------------
   72|    564|                    data->name));
   73|    564|	free(NETSNMP_REMOVE_CONST(void *, data->name)); /* SNMP_FREE wasted on object about to be freed */
  ------------------
  |  |   91|    564|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
   74|    564|    }
   75|    564|    free(data); /* SNMP_FREE wasted on param */
   76|    564|}
container.c:netsnmp_container_get_ct:
  234|    564|{
  235|    564|    container_type ct;
  236|       |
  237|    564|    if (NULL == containers)
  ------------------
  |  Branch (237:9): [True: 0, False: 564]
  ------------------
  238|      0|        return NULL;
  239|       |    
  240|    564|    ct.name = type;
  241|    564|    return (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  394|    564|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  242|    564|}
container.c:netsnmp_container_find_ct:
  246|    282|{
  247|    282|    container_type    *ct = NULL;
  248|    282|    char              *list, *entry;
  249|    282|    char              *st = NULL;
  250|       |
  251|    282|    if (NULL==type_list)
  ------------------
  |  Branch (251:9): [True: 0, False: 282]
  ------------------
  252|      0|        return NULL;
  253|       |
  254|    282|    list = strdup(type_list);
  255|    282|    if (!list)
  ------------------
  |  Branch (255:9): [True: 0, False: 282]
  ------------------
  256|      0|        return NULL;
  257|    282|    entry = strtok_r(list, ":", &st);
  258|    564|    while (entry) {
  ------------------
  |  Branch (258:12): [True: 564, False: 0]
  ------------------
  259|    564|        ct = netsnmp_container_get_ct(entry);
  260|    564|        if (NULL != ct)
  ------------------
  |  Branch (260:13): [True: 282, False: 282]
  ------------------
  261|    282|            break;
  262|    282|        entry = strtok_r(NULL, ":", &st);
  263|    282|    }
  264|       |
  265|    282|    free(list);
  266|    282|    return ct;
  267|    282|}

netsnmp_binary_array_release:
  216|    282|{
  217|    282|    binary_array_table *t = (binary_array_table*)c->container_data;
  218|    282|    SNMP_FREE(t->data);
  ------------------
  |  |   62|    282|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 235]
  |  |  |  Branch (62:66): [Folded, False: 282]
  |  |  ------------------
  ------------------
  219|    282|    SNMP_FREE(t);
  ------------------
  |  |   62|    282|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 282, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 282]
  |  |  ------------------
  ------------------
  220|    282|    SNMP_FREE(c->container_name);
  ------------------
  |  |   62|    282|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 282]
  |  |  |  Branch (62:66): [Folded, False: 282]
  |  |  ------------------
  ------------------
  221|       |    SNMP_FREE(c);
  ------------------
  |  |   62|    282|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 282, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 282]
  |  |  ------------------
  ------------------
  222|    282|}
netsnmp_binary_array_options_set:
  232|    188|{
  233|    188|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  234|       |
  235|    188|    if (set) {
  ------------------
  |  Branch (235:9): [True: 188, False: 0]
  ------------------
  236|    188|        if ((flags & BA_FLAGS) == flags) {
  ------------------
  |  |  233|    188|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  370|    188|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  |  |  ------------------
  |  |               #define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  371|    188|#define CONTAINER_KEY_UNSORTED                     0x00000002
  |  |  ------------------
  ------------------
  |  Branch (236:13): [True: 188, False: 0]
  ------------------
  237|       |            /** if turning off unsorted, do sort */
  238|    188|            int sort = ((c->flags & CONTAINER_KEY_UNSORTED) &&
  ------------------
  |  |  371|    188|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (238:25): [True: 0, False: 188]
  ------------------
  239|      0|                        ! (flags & CONTAINER_KEY_UNSORTED));
  ------------------
  |  |  371|      0|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (239:25): [True: 0, False: 0]
  ------------------
  240|    188|            c->flags = flags;
  241|    188|            if (sort) {
  ------------------
  |  Branch (241:17): [True: 0, False: 188]
  ------------------
  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|    188|            return flags;
  247|    188|        } else {
  248|      0|            return -1; /* unsupported flag */
  249|      0|        }
  250|    188|    } else {
  251|      0|        return ((c->flags & flags) == flags);
  252|      0|    }
  253|    188|}
netsnmp_container_get_binary_array:
  816|    282|{
  817|       |    /*
  818|       |     * allocate memory
  819|       |     */
  820|    282|    netsnmp_container *c = SNMP_MALLOC_TYPEDEF(netsnmp_container);
  ------------------
  |  |   73|    282|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  821|    282|    if (NULL==c) {
  ------------------
  |  Branch (821:9): [True: 0, False: 282]
  ------------------
  822|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  823|      0|        return NULL;
  824|      0|    }
  825|       |
  826|    282|    c->container_data = netsnmp_binary_array_initialize();
  827|    282|    if (NULL == c->container_data) {
  ------------------
  |  Branch (827:9): [True: 0, False: 282]
  ------------------
  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|    282|    netsnmp_init_container(c, NULL, _ba_free, _ba_size, NULL, _ba_insert,
  837|    282|                           _ba_remove, _ba_find);
  838|    282|    c->find_next = _ba_find_next;
  839|    282|    c->get_subset = _ba_get_subset;
  840|    282|    c->get_iterator = _ba_iterator_get;
  841|    282|    c->for_each = _ba_for_each;
  842|    282|    c->clear = _ba_clear;
  843|    282|    c->options = _ba_options;
  844|    282|    c->duplicate = _ba_duplicate;
  845|    282|    c->get_at = netsnmp_binary_array_get_at;
  846|    282|    c->remove_at = netsnmp_binary_array_remove_at;
  847|    282|    c->insert_before = _ba_insert_before;
  848|       |
  849|    282|    return c;
  850|    282|}
netsnmp_container_get_binary_array_factory:
  854|     47|{
  855|     47|    static netsnmp_factory f = { "binary_array",
  856|     47|                                 netsnmp_container_get_binary_array };
  857|       |    
  858|     47|    return &f;
  859|     47|}
netsnmp_container_binary_array_init:
  863|     47|{
  864|     47|    netsnmp_container_register("binary_array",
  865|     47|                               netsnmp_container_get_binary_array_factory());
  866|     47|}
container_binary_array.c:_ba_is_sorted:
  336|    564|{
  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|    564|    return 1;
  351|    564|}
container_binary_array.c:binary_search:
  125|  1.88k|{
  126|  1.88k|    binary_array_table *t = (binary_array_table*)c->container_data;
  127|  1.88k|    size_t             len = t->count;
  128|  1.88k|    size_t             half;
  129|  1.88k|    size_t             first = 0;
  130|  1.88k|    size_t             middle = 0; /* init not needed; keeps compiler happy */
  131|  1.88k|    int                result = 0; /* init not needed; keeps compiler happy */
  132|       |
  133|  1.88k|    if (!len) {
  ------------------
  |  Branch (133:9): [True: 0, False: 1.88k]
  ------------------
  134|      0|        if (NULL != next)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  ------------------
  135|      0|            *next = 0;
  136|      0|        return -1;
  137|      0|    }
  138|       |
  139|  1.88k|    if (c->flags & CONTAINER_KEY_UNSORTED) {
  ------------------
  |  |  371|  1.88k|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (139:9): [True: 0, False: 1.88k]
  ------------------
  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|  1.88k|    if (t->dirty)
  ------------------
  |  Branch (148:9): [True: 0, False: 1.88k]
  ------------------
  149|      0|        Sort_Array(c);
  150|       |
  151|  7.37k|    while (len > 0) {
  ------------------
  |  Branch (151:12): [True: 6.06k, False: 1.31k]
  ------------------
  152|  6.06k|        half = len >> 1;
  153|  6.06k|        middle = first + half;
  154|  6.06k|        if ((result = c->compare(t->data[middle], val)) < 0) {
  ------------------
  |  Branch (154:13): [True: 2.02k, False: 4.04k]
  ------------------
  155|  2.02k|            first = middle + 1;
  156|  2.02k|            len = len - half - 1;
  157|  4.04k|        } else if (result == 0) {
  ------------------
  |  Branch (157:20): [True: 564, False: 3.47k]
  ------------------
  158|    564|            first = middle;
  159|    564|            break;
  160|  3.47k|        } else {
  161|  3.47k|            len = half;
  162|  3.47k|        }
  163|  6.06k|    }
  164|       |
  165|  1.88k|    if (first >= t->count) {
  ------------------
  |  Branch (165:9): [True: 188, False: 1.69k]
  ------------------
  166|    188|        if (exact && NULL != next)
  ------------------
  |  Branch (166:13): [True: 188, False: 0]
  |  Branch (166:22): [True: 94, False: 94]
  ------------------
  167|     94|            *next = t->count;
  168|    188|        return -1;
  169|    188|    }
  170|       |
  171|  1.69k|    if (first != middle) {
  ------------------
  |  Branch (171:9): [True: 940, False: 752]
  ------------------
  172|       |        /* last compare wasn't against first, so get actual result */
  173|    940|        result = c->compare(t->data[first], val);
  174|    940|    }
  175|       |
  176|  1.69k|    if(result == 0) {
  ------------------
  |  Branch (176:8): [True: 564, False: 1.12k]
  ------------------
  177|    564|        if (exact && NULL != next)
  ------------------
  |  Branch (177:13): [True: 564, False: 0]
  |  Branch (177:22): [True: 0, False: 564]
  ------------------
  178|      0|            *next = first+1;
  179|    564|        else if (!exact && ++first == t->count) {
  ------------------
  |  Branch (179:18): [True: 0, False: 564]
  |  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.12k|    } else if(exact) {
  ------------------
  |  Branch (184:15): [True: 1.12k, False: 0]
  ------------------
  185|  1.12k|        if (NULL != next) {
  ------------------
  |  Branch (185:13): [True: 423, False: 705]
  ------------------
  186|    423|            if (result > 0)
  ------------------
  |  Branch (186:17): [True: 423, False: 0]
  ------------------
  187|    423|                *next = first;
  188|      0|            else
  189|      0|                *next = t->count;
  190|    423|        }
  191|  1.12k|        first = -1;
  192|  1.12k|    }
  193|       |
  194|  1.69k|    return first;
  195|  1.88k|}
container_binary_array.c:netsnmp_binary_array_initialize:
  199|    282|{
  200|    282|    binary_array_table *t;
  201|       |
  202|    282|    t = SNMP_MALLOC_TYPEDEF(binary_array_table);
  ------------------
  |  |   73|    282|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  203|    282|    if (t == NULL)
  ------------------
  |  Branch (203:9): [True: 0, False: 282]
  ------------------
  204|      0|        return NULL;
  205|       |
  206|    282|    t->max_size = 0;
  207|    282|    t->count = 0;
  208|    282|    t->dirty = 0;
  209|    282|    t->data = NULL;
  210|       |
  211|    282|    return t;
  212|    282|}
container_binary_array.c:_ba_free:
  712|    282|{
  713|    282|    netsnmp_binary_array_release(container);
  714|    282|    return 0;
  715|    282|}
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|    564|{
  694|    564|    return netsnmp_binary_array_insert(container, data);
  695|    564|}
container_binary_array.c:netsnmp_binary_array_insert:
  532|    564|{
  533|    564|    binary_array_table *t = (binary_array_table*)c->container_data;
  534|    564|    const int duplicates_allowed = c->flags & CONTAINER_KEY_ALLOW_DUPLICATES;
  ------------------
  |  |  370|    564|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  535|    564|    const int sorted = !(c->flags & CONTAINER_KEY_UNSORTED);
  ------------------
  |  |  371|    564|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  536|    564|    int             i = -2;
  537|    564|    size_t          next, pos;
  538|    564|    void           *entry = NETSNMP_REMOVE_CONST(void *, const_entry);
  ------------------
  |  |   91|    564|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  539|       |
  540|    564|    if (NULL == entry)
  ------------------
  |  Branch (540:9): [True: 0, False: 564]
  ------------------
  541|      0|        return -1;
  542|       |
  543|       |    /*
  544|       |     * check key if we have at least 1 item and duplicates aren't allowed
  545|       |     */
  546|    564|    if (!duplicates_allowed && t->count) {
  ------------------
  |  Branch (546:9): [True: 564, False: 0]
  |  Branch (546:32): [True: 517, False: 47]
  ------------------
  547|    517|        i = binary_search(entry, c, 1, &next);
  548|    517|        if (i >= 0) {
  ------------------
  |  Branch (548:13): [True: 0, False: 517]
  ------------------
  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|    517|    }
  553|       | 
  554|       |    /*
  555|       |     * if unsorted, just add at the end
  556|       |     */
  557|    564|    if (!sorted) {
  ------------------
  |  Branch (557:9): [True: 0, False: 564]
  ------------------
  558|      0|        pos = t->count;
  559|    564|    } else {
  560|       |        /** if we haven't searched for key yet, do it now */
  561|    564|        if (-2 == i) {
  ------------------
  |  Branch (561:13): [True: 47, False: 517]
  ------------------
  562|     47|            if (0 == t->count) {
  ------------------
  |  Branch (562:17): [True: 47, False: 0]
  ------------------
  563|     47|                next = 0;
  564|     47|                i = -1;
  565|     47|            } else {
  566|      0|                i = binary_search(entry, c, 1, &next);
  567|      0|            }
  568|     47|        }
  569|       |
  570|    564|        pos = next;
  571|       |        /* if key found, advance past any duplicates */
  572|    564|        if (duplicates_allowed && i >= 0)
  ------------------
  |  Branch (572:13): [True: 0, False: 564]
  |  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|    564|    }
  576|       |
  577|    564|    return netsnmp_binary_array_insert_before(c, pos, entry, !sorted);
  578|    564|}
container_binary_array.c:netsnmp_binary_array_insert_before:
  487|    564|{
  488|    564|    binary_array_table *t = (binary_array_table*)c->container_data;
  489|       |
  490|    564|    if (NULL == entry)
  ------------------
  |  Branch (490:9): [True: 0, False: 564]
  ------------------
  491|      0|        return -1;
  492|       |
  493|    564|    if (index > t->count) {
  ------------------
  |  Branch (493:9): [True: 0, False: 564]
  ------------------
  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|    564|    _ba_resize_check(t);
  502|       |
  503|    564|    netsnmp_assert(t->count < t->max_size);
  ------------------
  |  |   47|    564|#      define netsnmp_assert(x)  do { \
  |  |   48|    564|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 564, False: 0]
  |  |  ------------------
  |  |   49|    564|                 ; \
  |  |   50|    564|              else \
  |  |   51|    564|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    564|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 564]
  |  |  ------------------
  ------------------
  504|       |
  505|       |    /*
  506|       |     * shift array
  507|       |     */
  508|    564|    memmove(&t->data[index+1], &t->data[index],
  509|    564|            sizeof(void*) * (t->count - index));
  510|       |
  511|       |    /*
  512|       |     * Insert the new entry into the data array
  513|       |     */
  514|    564|    t->data[index] = NETSNMP_REMOVE_CONST(void *, entry);
  ------------------
  |  |   91|    564|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  515|    564|    ++t->count;
  516|       |
  517|    564|    netsnmp_assert(index < t->count);
  ------------------
  |  |   47|    564|#      define netsnmp_assert(x)  do { \
  |  |   48|    564|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 564, False: 0]
  |  |  ------------------
  |  |   49|    564|                 ; \
  |  |   50|    564|              else \
  |  |   51|    564|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    564|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 564]
  |  |  ------------------
  ------------------
  518|    564|    netsnmp_assert(t->count <= t->max_size);
  ------------------
  |  |   47|    564|#      define netsnmp_assert(x)  do { \
  |  |   48|    564|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 564, False: 0]
  |  |  ------------------
  |  |   49|    564|                 ; \
  |  |   50|    564|              else \
  |  |   51|    564|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    564|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 564]
  |  |  ------------------
  ------------------
  519|       |
  520|    564|    if (dirty)
  ------------------
  |  Branch (520:9): [True: 0, False: 564]
  ------------------
  521|      0|        t->dirty = 1;
  522|       |
  523|    564|    netsnmp_assert(t->dirty || _ba_is_sorted(c));
  ------------------
  |  |   47|    564|#      define netsnmp_assert(x)  do { \
  |  |   48|  1.69k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 564]
  |  |  |  Branch (48:20): [True: 564, False: 0]
  |  |  ------------------
  |  |   49|    564|                 ; \
  |  |   50|    564|              else \
  |  |   51|    564|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    564|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 564]
  |  |  ------------------
  ------------------
  524|       |
  525|    564|    ++c->sync;
  526|       |
  527|    564|    return 0;
  528|    564|}
container_binary_array.c:_ba_resize_check:
  458|    564|{
  459|    564|    size_t new_max;
  460|    564|    void ** new_data;
  461|    564|    if (t->max_size > t->count)
  ------------------
  |  Branch (461:9): [True: 470, False: 94]
  ------------------
  462|    470|        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|     94|    new_max = t->max_size > 0 ? 2 * t->max_size : 10;
  ------------------
  |  Branch (468:15): [True: 47, False: 47]
  ------------------
  469|     94|    new_data = (void**) realloc(t->data, new_max * sizeof(void*));
  470|     94|    if (new_data == NULL) {
  ------------------
  |  Branch (470:9): [True: 0, False: 94]
  ------------------
  471|      0|        snmp_log(LOG_ERR, "malloc failed in _ba_resize_check\n");
  472|      0|        return -1; /* error */
  473|      0|    }
  474|       |
  475|     94|    memset(new_data + t->max_size, 0x0,
  476|     94|           (new_max - t->max_size) * sizeof(void*));
  477|       |
  478|     94|    t->data = new_data;
  479|     94|    t->max_size = new_max;
  480|       |
  481|     94|    return 1; /* resized */
  482|     94|}
container_binary_array.c:_ba_find:
  681|  1.41k|{
  682|  1.41k|    return netsnmp_binary_array_get(container, data, 1);
  683|  1.41k|}
container_binary_array.c:netsnmp_binary_array_get:
  267|  1.41k|{
  268|  1.41k|    binary_array_table *t = (binary_array_table*)c->container_data;
  269|  1.41k|    int             index = 0;
  270|       |
  271|       |    /*
  272|       |     * if there is no data, return NULL;
  273|       |     */
  274|  1.41k|    if (!t->count)
  ------------------
  |  Branch (274:9): [True: 47, False: 1.36k]
  ------------------
  275|     47|        return NULL;
  276|       |
  277|       |    /*
  278|       |     * if the table is dirty, sort it.
  279|       |     */
  280|  1.36k|    if (t->dirty)
  ------------------
  |  Branch (280:9): [True: 0, False: 1.36k]
  ------------------
  281|      0|        Sort_Array(c);
  282|       |
  283|       |    /*
  284|       |     * if there is a key, search. Otherwise default is 0;
  285|       |     */
  286|  1.36k|    if (key) {
  ------------------
  |  Branch (286:9): [True: 1.36k, False: 0]
  ------------------
  287|  1.36k|        if ((index = binary_search(key, c, exact, NULL)) == -1)
  ------------------
  |  Branch (287:13): [True: 799, False: 564]
  ------------------
  288|    799|            return NULL;
  289|    564|        if (!exact &&
  ------------------
  |  Branch (289:13): [True: 0, False: 564]
  ------------------
  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|    564|    }
  308|       |
  309|    564|    return t->data[index];
  310|  1.36k|}
container_binary_array.c:_ba_for_each:
  726|     47|{
  727|     47|    netsnmp_binary_array_for_each(container, f, context, 1);
  728|     47|}
container_binary_array.c:netsnmp_binary_array_for_each:
  426|     47|{
  427|     47|    binary_array_table *t = (binary_array_table*)c->container_data;
  428|     47|    size_t             i;
  429|       |
  430|     47|    if (sort && t->dirty)
  ------------------
  |  Branch (430:9): [True: 47, False: 0]
  |  Branch (430:17): [True: 0, False: 47]
  ------------------
  431|      0|        Sort_Array(c);
  432|       |
  433|    611|    for (i = 0; i < t->count; ++i)
  ------------------
  |  Branch (433:17): [True: 564, False: 47]
  ------------------
  434|    564|        (*fe) (t->data[i], context);
  435|     47|}
container_binary_array.c:_ba_clear:
  733|    235|{
  734|    235|    netsnmp_binary_array_clear(container, f, context);
  735|    235|}
container_binary_array.c:netsnmp_binary_array_clear:
  441|    235|{
  442|    235|    binary_array_table *t = (binary_array_table*)c->container_data;
  443|       |
  444|    235|    if( NULL != fe ) {
  ------------------
  |  Branch (444:9): [True: 94, False: 141]
  ------------------
  445|     94|        size_t             i;
  446|       |
  447|     94|        for (i = 0; i < t->count; ++i)
  ------------------
  |  Branch (447:21): [True: 0, False: 94]
  ------------------
  448|      0|            (*fe) (t->data[i], context);
  449|     94|    }
  450|       |
  451|    235|    t->count = 0;
  452|    235|    t->dirty = 0;
  453|    235|    ++c->sync;
  454|    235|}
container_binary_array.c:_ba_options:
  761|    188|{
  762|    188|    return netsnmp_binary_array_options_set(c, set, flags);
  763|    188|}
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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      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|     47|{
  387|       |    /*
  388|       |     * allocate memory
  389|       |     */
  390|     47|    sl_container *sl = (sl_container *)netsnmp_container_get_ssll();
  391|     47|    if (NULL==sl)
  ------------------
  |  Branch (391:9): [True: 0, False: 47]
  ------------------
  392|      0|        return NULL; /* msg already logged */
  393|       |
  394|     47|    sl->unsorted = 1;
  395|       |
  396|     47|    return (netsnmp_container*)sl;
  397|     47|}
netsnmp_container_get_singly_linked_list:
  401|     47|{
  402|     47|    sl_container *sl = (sl_container *)netsnmp_container_get_usll();
  403|     47|    if (NULL == sl)
  ------------------
  |  Branch (403:9): [True: 0, False: 47]
  ------------------
  404|      0|        return NULL; /* error already logged */
  405|       |
  406|     47|    sl->fifo = fifo;
  407|       |
  408|     47|    return (netsnmp_container *)sl;
  409|     47|}
netsnmp_container_get_fifo:
  413|     47|{
  414|     47|    return netsnmp_container_get_singly_linked_list(1);
  415|     47|}
netsnmp_container_ssll_init:
  419|     47|{
  420|     47|    static netsnmp_factory ssll = {
  421|     47|        "sorted_singly_linked_list",
  422|     47|        netsnmp_container_get_ssll
  423|     47|    };
  424|     47|    static netsnmp_factory usll = {
  425|     47|        "unsorted_singly_linked_list-lifo",
  426|     47|        netsnmp_container_get_usll
  427|     47|    };
  428|     47|    static netsnmp_factory fifo = {
  429|     47|        "unsorted_singly_linked_list-fifo",
  430|     47|        netsnmp_container_get_fifo
  431|     47|    };
  432|       |
  433|     47|    netsnmp_container_register("sorted_singly_linked_list", &ssll);
  434|     47|    netsnmp_container_register("unsorted_singly_linked_list", &usll);
  435|     47|    netsnmp_container_register("lifo", &usll);
  436|     47|    netsnmp_container_register("fifo", &fifo);
  437|     47|}
container_list_ssll.c:netsnmp_container_get_ssll:
  361|     47|{
  362|       |    /*
  363|       |     * allocate memory
  364|       |     */
  365|     47|    sl_container *sl = SNMP_MALLOC_TYPEDEF(sl_container);
  ------------------
  |  |   73|     47|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  366|     47|    if (NULL==sl) {
  ------------------
  |  Branch (366:9): [True: 0, False: 47]
  ------------------
  367|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  368|      0|        return NULL;
  369|      0|    }
  370|       |
  371|     47|    netsnmp_init_container((netsnmp_container *)sl, NULL, _ssll_free,
  372|     47|                           _ssll_size, NULL, _ssll_insert, _ssll_remove,
  373|     47|                           _ssll_find);
  374|     47|    sl->c.find_next = _ssll_find_next;
  375|     47|    sl->c.get_subset = NULL;
  376|     47|    sl->c.get_iterator =_ssll_iterator_get;
  377|     47|    sl->c.for_each = _ssll_for_each;
  378|     47|    sl->c.clear = _ssll_clear;
  379|     47|    sl->c.duplicate = _ssll_duplicate;
  380|       |
  381|     47|    return &sl->c;
  382|     47|}
container_list_ssll.c:_ssll_free:
  110|     47|{
  111|     47|    if(c) {
  ------------------
  |  Branch (111:8): [True: 47, False: 0]
  ------------------
  112|     47|        free(c);
  113|     47|    }
  114|     47|    return 0;
  115|     47|}
container_list_ssll.c:_ssll_clear:
  287|     47|{
  288|     47|    sl_container *sl = (sl_container*)c;
  289|     47|    sl_node  *curr, *next;
  290|       |    
  291|     47|    if(NULL == c)
  ------------------
  |  Branch (291:8): [True: 0, False: 47]
  ------------------
  292|      0|        return;
  293|       |    
  294|     47|    for(curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (294:26): [True: 0, False: 47]
  ------------------
  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|     47|    sl->count = 0;
  310|     47|    ++c->sync;
  311|     47|}

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

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

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

netsnmp_large_fd_setfd:
  120|     46|{
  121|     46|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     46|#      define netsnmp_assert(x)  do { \
  |  |   48|     46|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 46, False: 0]
  |  |  ------------------
  |  |   49|     46|                 ; \
  |  |   50|     46|              else \
  |  |   51|     46|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     46|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 46]
  |  |  ------------------
  ------------------
  122|       |
  123|     46|    while (fd >= (int)fdset->lfs_setsize)
  ------------------
  |  Branch (123:12): [True: 0, False: 46]
  ------------------
  124|      0|        netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1));
  125|       |
  126|     46|    LFD_SET(fd, fdset->lfs_setptr);
  127|     46|}
netsnmp_large_fd_is_set:
  140|     46|{
  141|     46|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     46|#      define netsnmp_assert(x)  do { \
  |  |   48|     46|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 46, False: 0]
  |  |  ------------------
  |  |   49|     46|                 ; \
  |  |   50|     46|              else \
  |  |   51|     46|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     46|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 46]
  |  |  ------------------
  ------------------
  142|       |
  143|     46|    return ((unsigned)fd < fdset->lfs_setsize &&
  ------------------
  |  Branch (143:13): [True: 46, False: 0]
  ------------------
  144|     46|            LFD_ISSET(fd, fdset->lfs_setptr));
  ------------------
  |  Branch (144:13): [True: 46, False: 0]
  ------------------
  145|     46|}
netsnmp_large_fd_set_init:
  151|     92|{
  152|     92|    fdset->lfs_setsize = 0;
  153|     92|    fdset->lfs_setptr  = NULL;
  154|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  155|       |    fdset->lfs_set.fd_count = 0;
  156|       |#endif
  157|     92|    netsnmp_large_fd_set_resize(fdset, setsize);
  158|     92|}
netsnmp_large_fd_set_resize:
  192|    276|{
  193|    276|    int             fd_set_bytes;
  194|       |
  195|    276|    if (fdset->lfs_setsize == setsize)
  ------------------
  |  Branch (195:9): [True: 92, False: 184]
  ------------------
  196|     92|        goto success;
  197|       |
  198|    184|    if (setsize > FD_SETSIZE) {
  ------------------
  |  Branch (198:9): [True: 0, False: 184]
  ------------------
  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|    184|    } else {
  211|    184|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (211:13): [True: 0, False: 184]
  ------------------
  212|      0|            fdset->lfs_set = *fdset->lfs_setptr;
  213|      0|            free(fdset->lfs_setptr);
  214|      0|        }
  215|    184|        fdset->lfs_setptr = &fdset->lfs_set;
  216|    184|    }
  217|       |
  218|    184|#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|    184|    if ( fdset->lfs_setsize == 0 && setsize == FD_SETSIZE ) {
  ------------------
  |  Branch (223:10): [True: 92, False: 92]
  |  Branch (223:37): [True: 92, False: 0]
  ------------------
  224|       |        /* In this case we can use the OS's FD_ZERO */
  225|     92|        FD_ZERO(fdset->lfs_setptr);
  ------------------
  |  Branch (225:9): [Folded, False: 92]
  ------------------
  226|     92|    } else {
  227|     92|        int             i;
  228|       |
  229|     92|        for (i = fdset->lfs_setsize; i < setsize; i++)
  ------------------
  |  Branch (229:38): [True: 0, False: 92]
  ------------------
  230|      0|            LFD_CLR(i, fdset->lfs_setptr);
  231|     92|    }
  232|    184|#endif
  233|       |
  234|    184|    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|    276|success:
  240|    276|    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|    184|}
netsnmp_large_fd_set_cleanup:
  252|     92|{
  253|     92|    netsnmp_large_fd_set_resize(fdset, 0);
  254|     92|    fdset->lfs_setsize = 0;
  255|       |    fdset->lfs_setptr  = NULL;
  256|     92|}
netsnmp_copy_fd_set_to_large_fd_set:
  261|     92|{
  262|       |    netsnmp_large_fd_set_resize(dst, FD_SETSIZE);
  263|     92|    *dst->lfs_setptr = *src;
  264|     92|}
netsnmp_copy_large_fd_set_to_fd_set:
  269|     46|{
  270|       |    /* Report failure if *src is larger than FD_SETSIZE. */
  271|     46|    if (src->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (271:9): [True: 0, False: 46]
  ------------------
  272|      0|        FD_ZERO(dst);
  ------------------
  |  Branch (272:9): [Folded, False: 0]
  ------------------
  273|      0|        return -1;
  274|      0|    }
  275|       |
  276|     46|    *dst = *src->lfs_setptr;
  277|       |
  278|     46|#if !(!defined(cygwin) && defined(HAVE_WINSOCK_H))
  279|     46|    {
  280|     46|        int             i;
  281|       |
  282|       |        /* Unix: clear any file descriptors defined in *dst but not in *src. */
  283|     46|        for (i = src->lfs_setsize; i < FD_SETSIZE; ++i)
  ------------------
  |  Branch (283:36): [True: 0, False: 46]
  ------------------
  284|     46|            FD_CLR(i, dst);
  285|     46|    }
  286|     46|#endif
  287|       |
  288|     46|    return 0;
  289|     46|}
large_fd_set.c:LFD_SET:
   95|     46|{
   96|     46|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
   97|     46|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1699|     46|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
   98|       |
   99|     46|    fds_array[n / nfdbits] |= (1ULL << (n % nfdbits));
  100|     46|}
large_fd_set.c:LFD_ISSET:
  111|     46|{
  112|     46|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  113|     46|    const NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  114|       |
  115|     46|    return (fds_array[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
  116|     46|}

get_enginetime:
   98|     28|{
   99|     28|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|     28|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  100|     28|    int             timediff = 0;
  101|     28|    Enginetime      e = NULL;
  102|       |
  103|       |
  104|       |
  105|       |    /*
  106|       |     * Sanity check.
  107|       |     */
  108|     28|    if (!engine_time || !engineboot) {
  ------------------
  |  Branch (108:9): [True: 0, False: 28]
  |  Branch (108:25): [True: 0, False: 28]
  ------------------
  109|      0|        QUITFUN(SNMPERR_GENERR, get_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|	}
  ------------------
  110|      0|    }
  111|       |
  112|       |
  113|       |    /*
  114|       |     * Compute estimated current engine_time tuple at engineID if
  115|       |     * a record is cached for it.
  116|       |     */
  117|     28|    *engine_time = *engineboot = 0;
  118|       |
  119|     28|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (119:9): [True: 0, False: 28]
  |  Branch (119:22): [True: 0, False: 28]
  ------------------
  120|      0|        QUITFUN(SNMPERR_GENERR, get_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|	}
  ------------------
  121|      0|    }
  122|       |
  123|     28|    if (!(e = search_enginetime_list(engineID, engineID_len))) {
  ------------------
  |  Branch (123:9): [True: 8, False: 20]
  ------------------
  124|      8|        QUITFUN(SNMPERR_GENERR, get_enginetime_quit);
  ------------------
  |  |  143|      8|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 8, Folded]
  |  |  ------------------
  |  |  144|      8|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      8|		goto l ;		\
  |  |  146|      8|	}
  ------------------
  125|      0|    }
  126|     20|#ifdef LCD_TIME_SYNC_OPT
  127|     20|    if (!authenticated || e->authenticatedFlag) {
  ------------------
  |  Branch (127:9): [True: 20, False: 0]
  |  Branch (127:27): [True: 0, False: 0]
  ------------------
  128|     20|#endif
  129|     20|        *engine_time = e->engineTime;
  130|     20|        *engineboot = e->engineBoot;
  131|       |
  132|     20|       timediff = (int) (snmpv3_local_snmpEngineTime() - e->lastReceivedEngineTime);
  133|       |
  134|     20|#ifdef LCD_TIME_SYNC_OPT
  135|     20|    }
  136|     20|#endif
  137|       |
  138|     20|    if (timediff > (int) (ENGINETIME_MAX - *engine_time)) {
  ------------------
  |  |  182|     20|#define ENGINETIME_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (138:9): [True: 0, False: 20]
  ------------------
  139|      0|        *engine_time = (timediff - (ENGINETIME_MAX - *engine_time));
  ------------------
  |  |  182|      0|#define ENGINETIME_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  140|       |
  141|       |        /*
  142|       |         * FIX -- move this check up... should not change anything
  143|       |         * * if engineboot is already locked.  ???
  144|       |         */
  145|      0|        if (*engineboot < ENGINEBOOT_MAX) {
  ------------------
  |  |  183|      0|#define ENGINEBOOT_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (145:13): [True: 0, False: 0]
  ------------------
  146|      0|            *engineboot += 1;
  147|      0|        }
  148|       |
  149|     20|    } else {
  150|     20|        *engine_time += timediff;
  151|     20|    }
  152|       |
  153|     20|    DEBUGMSGTL(("lcd_get_enginetime", "engineID "));
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
  154|     20|    DEBUGMSGHEX(("lcd_get_enginetime", engineID, engineID_len));
  ------------------
  |  |   71|     20|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 20]
  |  |  ------------------
  ------------------
  155|     20|    DEBUGMSG(("lcd_get_enginetime", ": boots=%d, time=%d\n", *engineboot,
  ------------------
  |  |   61|     20|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 20]
  |  |  ------------------
  ------------------
  156|     20|              *engine_time));
  157|       |
  158|     28|  get_enginetime_quit:
  159|     28|    return rval;
  160|       |
  161|     20|}                               /* end get_enginetime() */
free_etimelist:
  295|     47|{
  296|     47|     int index = 0;
  297|     47|     Enginetime e = NULL;
  298|     47|     Enginetime nextE = NULL;
  299|       |
  300|  1.12k|     for( ; index < ETIMELIST_SIZE; ++index)
  ------------------
  |  |   21|  1.12k|#define ETIMELIST_SIZE	23
  ------------------
  |  Branch (300:13): [True: 1.08k, False: 47]
  ------------------
  301|  1.08k|     {
  302|  1.08k|           e = etimelist[index];
  303|       |
  304|  1.12k|           while(e != NULL)
  ------------------
  |  Branch (304:18): [True: 47, False: 1.08k]
  ------------------
  305|     47|           {
  306|     47|                 nextE = e->next;
  307|     47|                 SNMP_FREE(e->engineID);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  308|     47|                 SNMP_FREE(e);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  309|     47|                 e = nextE;
  310|     47|           }
  311|       |
  312|       |           etimelist[index] = NULL;
  313|  1.08k|     }
  314|     47|     return;
  315|     47|}
set_enginetime:
  344|     47|{
  345|     47|    int             rval = SNMPERR_SUCCESS, iindex;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  346|     47|    Enginetime      e = NULL;
  347|       |
  348|       |
  349|       |
  350|       |    /*
  351|       |     * Sanity check.
  352|       |     */
  353|     47|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (353:9): [True: 0, False: 47]
  |  Branch (353:22): [True: 0, False: 47]
  ------------------
  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|     47|    if (!(e = search_enginetime_list(engineID, engineID_len))) {
  ------------------
  |  Branch (362:9): [True: 47, False: 0]
  ------------------
  363|     47|        if ((iindex = hash_engineID(engineID, engineID_len)) < 0) {
  ------------------
  |  Branch (363:13): [True: 0, False: 47]
  ------------------
  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|     47|        e = calloc(1, sizeof(*e));
  368|       |
  369|     47|        e->next = etimelist[iindex];
  370|     47|        etimelist[iindex] = e;
  371|       |
  372|     47|        e->engineID = calloc(1, engineID_len);
  373|     47|        memcpy(e->engineID, engineID, engineID_len);
  374|       |
  375|     47|        e->engineID_len = engineID_len;
  376|     47|    }
  377|     47|#ifdef LCD_TIME_SYNC_OPT
  378|     47|    if (authenticated || !e->authenticatedFlag) {
  ------------------
  |  Branch (378:9): [True: 47, False: 0]
  |  Branch (378:26): [True: 0, False: 0]
  ------------------
  379|     47|        e->authenticatedFlag = authenticated;
  380|       |#else
  381|       |    if (authenticated) {
  382|       |#endif
  383|     47|        e->engineTime = engine_time;
  384|     47|        e->engineBoot = engineboot;
  385|     47|        e->lastReceivedEngineTime = snmpv3_local_snmpEngineTime();
  386|     47|    }
  387|       |
  388|     47|    e = NULL;                   /* Indicates a successful update. */
  389|       |
  390|     47|    DEBUGMSGTL(("lcd_set_enginetime", "engineID "));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  391|     47|    DEBUGMSGHEX(("lcd_set_enginetime", engineID, engineID_len));
  ------------------
  |  |   71|     47|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 47]
  |  |  ------------------
  ------------------
  392|     47|    DEBUGMSG(("lcd_set_enginetime", ": boots=%d, time=%d\n", engineboot,
  ------------------
  |  |   61|     47|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 47]
  |  |  ------------------
  ------------------
  393|     47|              engine_time));
  394|       |
  395|     47|  set_enginetime_quit:
  396|     47|    SNMP_FREE(e);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 47]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  397|       |
  398|     47|    return rval;
  399|       |
  400|     47|}                               /* end set_enginetime() */
search_enginetime_list:
  423|     75|{
  424|     75|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|     75|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  425|     75|    Enginetime      e = NULL;
  426|       |
  427|       |
  428|       |    /*
  429|       |     * Sanity check.
  430|       |     */
  431|     75|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (431:9): [True: 0, False: 75]
  |  Branch (431:22): [True: 0, False: 75]
  ------------------
  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|     75|    rval = hash_engineID(engineID, engineID_len);
  440|     75|    if (rval < 0) {
  ------------------
  |  Branch (440:9): [True: 0, False: 75]
  ------------------
  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|     75|    e = etimelist[rval];
  444|       |
  445|     75|    for ( /*EMPTY*/; e; e = e->next) {
  ------------------
  |  Branch (445:22): [True: 20, False: 55]
  ------------------
  446|     20|        if ((engineID_len == e->engineID_len)
  ------------------
  |  Branch (446:13): [True: 20, False: 0]
  ------------------
  447|     20|            && !memcmp(e->engineID, engineID, engineID_len)) {
  ------------------
  |  Branch (447:16): [True: 20, False: 0]
  ------------------
  448|     20|            break;
  449|     20|        }
  450|     20|    }
  451|       |
  452|       |
  453|     75|  search_enginetime_list_quit:
  454|     75|    return e;
  455|       |
  456|     75|}                               /* end search_enginetime_list() */
hash_engineID:
  481|    122|{
  482|    122|    int             rval = SNMPERR_GENERR;
  ------------------
  |  |  185|    122|#define SNMPERR_GENERR			(-1)
  ------------------
  483|    122|    size_t          buf_len = SNMP_MAXBUF;
  ------------------
  |  |   43|    122|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  484|    122|    u_int           additive = 0;
  485|    122|    u_char         *bufp, buf[SNMP_MAXBUF];
  486|    122|    void           *context = NULL;
  487|       |
  488|       |
  489|       |
  490|       |    /*
  491|       |     * Sanity check.
  492|       |     */
  493|    122|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (493:9): [True: 0, False: 122]
  |  Branch (493:22): [True: 0, False: 122]
  ------------------
  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|    122|#ifndef NETSNMP_DISABLE_MD5
  502|    122|    rval = sc_hash(usmHMACMD5AuthProtocol,
  503|    122|                   OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|    122|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|    122|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  504|    122|                   engineID, engineID_len, buf, &buf_len);
  505|    122|    if (rval == SNMPERR_SC_NOT_CONFIGURED) {
  ------------------
  |  |  223|    122|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
  |  Branch (505:9): [True: 0, False: 122]
  ------------------
  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|    122|    QUITFUN(rval, hash_engineID_quit);
  ------------------
  |  |  143|    122|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|    122|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, False: 122]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  517|       |
  518|    610|    for (bufp = buf; (bufp - buf) < (int) buf_len; bufp += 4) {
  ------------------
  |  Branch (518:22): [True: 488, False: 122]
  ------------------
  519|    488|        additive += (u_int) * bufp;
  520|    488|    }
  521|       |
  522|    122|  hash_engineID_quit:
  523|    122|    SNMP_FREE(context);
  ------------------
  |  |   62|    122|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 122]
  |  |  |  Branch (62:66): [Folded, False: 122]
  |  |  ------------------
  ------------------
  524|    122|    memset(buf, 0, SNMP_MAXBUF);
  ------------------
  |  |   43|    122|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  525|       |
  526|    122|    return (rval < 0) ? rval : (int)(additive % ETIMELIST_SIZE);
  ------------------
  |  |   21|    122|#define ETIMELIST_SIZE	23
  ------------------
  |  Branch (526:12): [True: 0, False: 122]
  ------------------
  527|       |
  528|    122|}                               /* end hash_engineID() */

register_mib_handlers:
 2480|     47|{
 2481|     47|#ifndef NETSNMP_DISABLE_MIB_LOADING
 2482|     47|    register_prenetsnmp_mib_handler("snmp", "mibdirs",
 2483|     47|                                    handle_mibdirs_conf, NULL,
 2484|     47|                                    "[mib-dirs|+mib-dirs|-mib-dirs]");
 2485|     47|    register_prenetsnmp_mib_handler("snmp", "mibs",
 2486|     47|                                    handle_mibs_conf, NULL,
 2487|     47|                                    "[mib-tokens|+mib-tokens|-mib-tokens]");
 2488|     47|    register_config_handler("snmp", "mibfile",
 2489|     47|                            handle_mibfile_conf, NULL, "mibfile-to-read");
 2490|       |    /*
 2491|       |     * register the snmp.conf configuration handlers for default
 2492|       |     * parsing behaviour 
 2493|       |     */
 2494|       |
 2495|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "showMibErrors",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2496|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   59|     47|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
 2497|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "commentToEOL",     /* Describes actual behaviour */
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2498|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|     47|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2499|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "strictCommentTerm",    /* Backward compatibility */
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2500|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|     47|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2501|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibAllowUnderline",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2502|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   62|     47|#define NETSNMP_DS_LIB_MIB_PARSE_LABEL     3
  ------------------
 2503|     47|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "mibWarningLevel",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
 2504|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |  114|     47|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 2505|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibReplaceWithLatest",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2506|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   67|     47|#define NETSNMP_DS_LIB_MIB_REPLACE         7    /* replace objects from latest module */
  ------------------
 2507|     47|#endif
 2508|       |
 2509|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printNumericEnums",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2510|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   68|     47|#define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM  8    /* print only numeric enum values */
  ------------------
 2511|     47|    register_prenetsnmp_mib_handler("snmp", "printNumericOids",
 2512|     47|                       handle_print_numeric, NULL, "(1|yes|true|0|no|false)");
 2513|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "escapeQuotes",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2514|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   79|     47|#define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
  ------------------
 2515|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontBreakdownOids",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2516|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   70|     47|#define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10   /* dont print oid indexes specially */
  ------------------
 2517|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "quickPrinting",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2518|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   73|     47|#define NETSNMP_DS_LIB_QUICK_PRINT         13   /* print very brief output for parsing */
  ------------------
 2519|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "numericTimeticks",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2520|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   78|     47|#define NETSNMP_DS_LIB_NUMERIC_TIMETICKS   18   /* print timeticks as a number */
  ------------------
 2521|     47|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "oidOutputFormat",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
 2522|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|     47|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2523|     47|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "suffixPrinting",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
 2524|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|     47|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2525|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "extendedIndex",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2526|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   82|     47|#define NETSNMP_DS_LIB_EXTENDED_INDEX	   22   /* print extended index format [x1][x2] */
  ------------------
 2527|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printHexText",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2528|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   83|     47|#define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
  ------------------
 2529|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printValueOnly",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2530|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   81|     47|#define NETSNMP_DS_LIB_PRINT_BARE_VALUE	   21   /* just print value (not OID = value) */
  ------------------
 2531|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontPrintUnits",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
 2532|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   89|     47|#define NETSNMP_DS_LIB_DONT_PRINT_UNITS    29 /* don't print UNITS suffix */
  ------------------
 2533|     47|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "hexOutputLength",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
 2534|     47|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |  121|     47|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
 2535|     47|}
netsnmp_set_mib_directory:
 2550|     47|{
 2551|     47|    const char *newdir;
 2552|     47|    char *olddir, *tmpdir = NULL;
 2553|       |
 2554|     47|    DEBUGTRACE;
  ------------------
  |  |   63|     47|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 47]
  |  |  ------------------
  ------------------
 2555|     47|    if (NULL == dir) {
  ------------------
  |  Branch (2555:9): [True: 0, False: 47]
  ------------------
 2556|      0|        return;
 2557|      0|    }
 2558|       |    
 2559|     47|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2560|     47|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|     47|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2561|     47|    if (olddir) {
  ------------------
  |  Branch (2561:9): [True: 47, False: 0]
  ------------------
 2562|     47|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2562:13): [True: 0, False: 47]
  |  Branch (2562:30): [True: 0, False: 47]
  ------------------
 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|     47|        } else {
 2577|     47|            newdir = dir;
 2578|     47|        }
 2579|     47|    } else {
 2580|       |        /** If dir starts with '+' skip '+' it. */
 2581|      0|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2581:19): [True: 0, False: 0]
  ------------------
 2582|      0|    }
 2583|     47|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |  162|     47|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2584|     47|                          newdir);
 2585|       |
 2586|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2587|     47|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2587:9): [True: 0, False: 47]
  ------------------
 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|     47|}
netsnmp_get_mib_directory:
 2607|    141|{
 2608|    141|    char *dir;
 2609|       |
 2610|    141|    DEBUGTRACE;
  ------------------
  |  |   63|    141|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    141|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 141]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 141]
  |  |  ------------------
  ------------------
 2611|    141|    dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|    141|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|    141|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2612|    141|    if (dir == NULL) {
  ------------------
  |  Branch (2612:9): [True: 0, False: 141]
  ------------------
 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);
  ------------------
  |  | 1647|      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);
  ------------------
  |  | 1647|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2627|      0|                netsnmp_set_mib_directory(confmibdir);
 2628|      0|            }
 2629|      0|            else {
 2630|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2631|      0|                netsnmp_set_mib_directory(confmibdir);
 2632|      0|            }
 2633|      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);
  ------------------
  |  | 1647|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2636|      0|            netsnmp_set_mib_directory(dir);
 2637|      0|        } else {
 2638|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2639|      0|            netsnmp_set_mib_directory(dir);
 2640|      0|        }
 2641|      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|    141|    DEBUGMSGTL(("get_mib_directory", "mib directories set '%s'\n", dir));
  ------------------
  |  |   66|    141|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    141|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 141]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 141]
  |  |  ------------------
  ------------------
 2644|    141|    return(dir);
 2645|    141|}
netsnmp_fixup_mib_directory:
 2654|     47|{
 2655|     47|    const char *homepath = netsnmp_gethomedir();
 2656|     47|    char *mibpath = netsnmp_get_mib_directory();
 2657|     47|    char *oldmibpath = NULL;
 2658|     47|    char *ptr_home;
 2659|     47|    char *new_mibpath;
 2660|       |
 2661|     47|    DEBUGTRACE;
  ------------------
  |  |   63|     47|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 47]
  |  |  ------------------
  ------------------
 2662|     47|    if (homepath && mibpath) {
  ------------------
  |  Branch (2662:9): [True: 47, False: 0]
  |  Branch (2662:21): [True: 47, False: 0]
  ------------------
 2663|     47|        DEBUGMSGTL(("fixup_mib_directory", "mib directories '%s'\n", mibpath));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2664|     47|        while ((ptr_home = strstr(mibpath, "$HOME"))) {
  ------------------
  |  Branch (2664:16): [True: 0, False: 47]
  ------------------
 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|     47|        netsnmp_set_mib_directory(mibpath);
 2683|       |	
 2684|       |	/*  The above copies the mibpath for us, so...  */
 2685|       |
 2686|     47|	if (oldmibpath != NULL) {
  ------------------
  |  Branch (2686:6): [True: 0, False: 47]
  ------------------
 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|     47|    }
 2691|       |
 2692|     47|}
netsnmp_init_mib:
 2701|     47|{
 2702|     47|    const char     *prefix;
 2703|     47|    char           *env_var, *entry;
 2704|     47|    PrefixListPtr   pp = &mib_prefixes[0];
 2705|     47|    char           *st = NULL;
 2706|       |
 2707|     47|    if (Mib)
  ------------------
  |  Branch (2707:9): [True: 0, False: 47]
  ------------------
 2708|      0|        return;
 2709|     47|    netsnmp_init_mib_internals();
 2710|       |
 2711|       |    /*
 2712|       |     * Initialise the MIB directory/ies 
 2713|       |     */
 2714|     47|    netsnmp_fixup_mib_directory();
 2715|     47|    env_var = strdup(netsnmp_get_mib_directory());
 2716|     47|    if (!env_var)
  ------------------
  |  Branch (2716:9): [True: 0, False: 47]
  ------------------
 2717|      0|        return;
 2718|       |
 2719|     47|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2720|     47|                "Seen MIBDIRS: Looking in '%s' for mib dirs ...\n",
 2721|     47|                env_var));
 2722|       |
 2723|     47|    entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     47|#define ENV_SEPARATOR ":"
  ------------------
 2724|     94|    while (entry) {
  ------------------
  |  Branch (2724:12): [True: 47, False: 47]
  ------------------
 2725|     47|        add_mibdir(entry);
 2726|     47|        entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     47|#define ENV_SEPARATOR ":"
  ------------------
 2727|     47|    }
 2728|     47|    SNMP_FREE(env_var);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2729|       |
 2730|     47|    env_var = netsnmp_getenv("MIBFILES");
 2731|     47|    if (env_var != NULL) {
  ------------------
  |  Branch (2731:9): [True: 0, False: 47]
  ------------------
 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|     47|    netsnmp_init_mib_internals();
 2743|       |
 2744|       |    /*
 2745|       |     * Read in any modules or mibs requested 
 2746|       |     */
 2747|       |
 2748|     47|    env_var = netsnmp_getenv("MIBS");
 2749|     47|    if (env_var == NULL) {
  ------------------
  |  Branch (2749:9): [True: 47, False: 0]
  ------------------
 2750|     47|        if (confmibs != NULL)
  ------------------
  |  Branch (2750:13): [True: 0, False: 47]
  ------------------
 2751|      0|            env_var = strdup(confmibs);
 2752|     47|        else
 2753|     47|            env_var = strdup(NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 1988|     47|#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|     47|    } else {
 2755|      0|        env_var = strdup(env_var);
 2756|      0|    }
 2757|     47|    if (env_var && ((*env_var == '+') || (*env_var == '-'))) {
  ------------------
  |  Branch (2757:9): [True: 47, False: 0]
  |  Branch (2757:21): [True: 0, False: 47]
  |  Branch (2757:42): [True: 0, False: 47]
  ------------------
 2758|      0|        int res;
 2759|       |
 2760|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2760:13): [True: 0, False: 0]
  ------------------
 2761|      0|            res = asprintf(&entry, "%s%c%s", NETSNMP_DEFAULT_MIBS,
  ------------------
  |  | 1988|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2762|      0|                           ENV_SEPARATOR_CHAR, env_var + 1);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2763|      0|        else
 2764|      0|            res = asprintf(&entry, "%s%c%s", env_var + 1, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2765|      0|                           NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 1988|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2766|      0|        SNMP_FREE(env_var);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2767|      0|        if (res < 0) {
  ------------------
  |  Branch (2767:13): [True: 0, False: 0]
  ------------------
 2768|      0|            DEBUGMSGTL(("init_mib", "env mibs malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2769|      0|            return;
 2770|      0|        }
 2771|      0|        env_var = entry;
 2772|      0|    }
 2773|       |
 2774|     47|    if (env_var != NULL) {
  ------------------
  |  Branch (2774:9): [True: 47, False: 0]
  ------------------
 2775|     47|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2776|     47|                    "Seen MIBS: Looking in '%s' for mib files ...\n",
 2777|     47|                    env_var));
 2778|     47|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     47|#define ENV_SEPARATOR ":"
  ------------------
 2779|  2.30k|        while (entry) {
  ------------------
  |  Branch (2779:16): [True: 2.25k, False: 47]
  ------------------
 2780|  2.25k|            if (strcasecmp(entry, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  227|  2.25k|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (2780:17): [True: 0, False: 2.25k]
  ------------------
 2781|      0|                read_all_mibs();
 2782|  2.25k|            } else if (strstr(entry, "/") != NULL) {
  ------------------
  |  Branch (2782:24): [True: 0, False: 2.25k]
  ------------------
 2783|      0|                read_mib(entry);
 2784|  2.25k|            } else {
 2785|  2.25k|                netsnmp_read_module(entry);
 2786|  2.25k|            }
 2787|  2.25k|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|  2.25k|#define ENV_SEPARATOR ":"
  ------------------
 2788|  2.25k|        }
 2789|     47|        adopt_orphans();
 2790|     47|        SNMP_FREE(env_var);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2791|     47|    }
 2792|       |
 2793|     47|    env_var = netsnmp_getenv("MIBFILES");
 2794|     47|    if (env_var != NULL) {
  ------------------
  |  Branch (2794:9): [True: 0, False: 47]
  ------------------
 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|     47|    } else {
 2819|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2820|       |        env_var = strdup(NETSNMP_DEFAULT_MIBFILES);
 2821|       |#endif
 2822|     47|    }
 2823|       |
 2824|     47|    if (env_var != NULL) {
  ------------------
  |  Branch (2824:9): [True: 0, False: 47]
  ------------------
 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|     47|    prefix = netsnmp_getenv("PREFIX");
 2837|       |
 2838|     47|    if (!prefix)
  ------------------
  |  Branch (2838:9): [True: 47, False: 0]
  ------------------
 2839|     47|        prefix = Standard_Prefix;
 2840|       |
 2841|     47|    Prefix = (char *) malloc(strlen(prefix) + 2);
 2842|     47|    if (!Prefix)
  ------------------
  |  Branch (2842:9): [True: 0, False: 47]
  ------------------
 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|     47|    else
 2845|     47|        strcpy(Prefix, prefix);
 2846|       |
 2847|     47|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2848|     47|                "Seen PREFIX: Looking in '%s' for prefix ...\n", Prefix));
 2849|       |
 2850|       |    /*
 2851|       |     * remove trailing dot 
 2852|       |     */
 2853|     47|    if (Prefix) {
  ------------------
  |  Branch (2853:9): [True: 47, False: 0]
  ------------------
 2854|     47|        env_var = &Prefix[strlen(Prefix) - 1];
 2855|     47|        if (*env_var == '.')
  ------------------
  |  Branch (2855:13): [True: 0, False: 47]
  ------------------
 2856|      0|            *env_var = '\0';
 2857|     47|    }
 2858|       |
 2859|     47|    pp->str = Prefix;           /* fixup first mib_prefix entry */
 2860|       |    /*
 2861|       |     * now that the list of prefixes is built, save each string length. 
 2862|       |     */
 2863|    329|    while (pp->str) {
  ------------------
  |  Branch (2863:12): [True: 282, False: 47]
  ------------------
 2864|    282|        pp->len = strlen(pp->str);
 2865|    282|        pp++;
 2866|    282|    }
 2867|       |
 2868|     47|    Mib = tree_head;            /* Backwards compatibility */
 2869|     47|    tree_top = calloc(1, sizeof(struct tree));
 2870|       |    /*
 2871|       |     * XX error check ? 
 2872|       |     */
 2873|     47|    if (tree_top) {
  ------------------
  |  Branch (2873:9): [True: 47, False: 0]
  ------------------
 2874|     47|        tree_top->label = strdup("(top)");
 2875|     47|        tree_top->child_list = tree_head;
 2876|     47|    }
 2877|     47|}
shutdown_mib:
 2893|     47|{
 2894|     47|    unload_all_mibs();
 2895|     47|    if (tree_top) {
  ------------------
  |  Branch (2895:9): [True: 47, False: 0]
  ------------------
 2896|     47|        if (tree_top->label)
  ------------------
  |  Branch (2896:13): [True: 47, False: 0]
  ------------------
 2897|     47|            SNMP_FREE(tree_top->label);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2898|     47|        SNMP_FREE(tree_top);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2899|     47|    }
 2900|     47|    tree_head = NULL;
 2901|     47|    Mib = NULL;
 2902|     47|    if (Prefix != NULL && Prefix != &Standard_Prefix[0])
  ------------------
  |  Branch (2902:9): [True: 47, False: 0]
  |  Branch (2902:27): [True: 47, False: 0]
  ------------------
 2903|     47|        SNMP_FREE(Prefix);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2904|     47|    if (Prefix)
  ------------------
  |  Branch (2904:9): [True: 0, False: 47]
  ------------------
 2905|      0|        Prefix = NULL;
 2906|     47|    SNMP_FREE(confmibs);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 47]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2907|       |    SNMP_FREE(confmibdir);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 47]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2908|     47|}
set_function:
 2940|    141|{
 2941|    141|    subtree->printer = NULL;
 2942|    141|    switch (subtree->type) {
 2943|      0|    case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2943:5): [True: 0, False: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 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: 141]
  ------------------
 2989|      0|        subtree->printomat = sprint_realloc_gauge;
 2990|      0|        break;
 2991|    141|    case TYPE_OTHER:
  ------------------
  |  |  154|    141|#define TYPE_OTHER          0
  ------------------
  |  Branch (2991:5): [True: 141, False: 0]
  ------------------
 2992|    141|    default:
  ------------------
  |  Branch (2992:5): [True: 0, False: 141]
  ------------------
 2993|    141|        subtree->printomat = sprint_realloc_by_type;
 2994|    141|        break;
 2995|    141|    }
 2996|    141|}

netsnmp_init_mib_internals:
  700|  2.39k|{
  701|  2.39k|    register struct tok *tp;
  702|  2.39k|    register int    b, i;
  703|  2.39k|    int             max_modc;
  704|       |
  705|  2.39k|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 2.35k, False: 47]
  ------------------
  706|  2.35k|        return;
  707|       |
  708|       |    /*
  709|       |     * Set up hash list of pre-defined tokens
  710|       |     */
  711|     47|    memset(buckets, 0, sizeof(buckets));
  712|  4.37k|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (712:23): [True: 4.32k, False: 47]
  ------------------
  713|  4.32k|        tp->hash = name_hash(tp->name);
  714|  4.32k|        b = BUCKET(tp->hash);
  ------------------
  |  |  527|  4.32k|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  526|  4.32k|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  715|  4.32k|        if (buckets[b])
  ------------------
  |  Branch (715:13): [True: 2.82k, False: 1.50k]
  ------------------
  716|  2.82k|            tp->next = buckets[b];      /* BUG ??? */
  717|  4.32k|        buckets[b] = tp;
  718|  4.32k|    }
  719|       |
  720|       |    /*
  721|       |     * Initialise other internal structures
  722|       |     */
  723|       |
  724|     47|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  725|  1.03k|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (725:17): [True: 987, False: 47]
  ------------------
  726|    987|        module_map[i].next = &(module_map[i + 1]);
  727|     47|    module_map[max_modc].next = NULL;
  728|     47|    module_map_head = module_map;
  729|       |
  730|     47|    memset(nbuckets, 0, sizeof(nbuckets));
  731|     47|    memset(tbuckets, 0, sizeof(tbuckets));
  732|     47|    free(tclist);
  733|     47|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|     47|#define TC_INCR 100
  ------------------
  734|     47|    tclist = calloc(tc_alloc, sizeof(struct tc));
  735|     47|    build_translation_table();
  736|     47|    init_tree_roots();          /* Set up initial roots */
  737|       |    /*
  738|       |     * Relies on 'add_mibdir' having set up the modules 
  739|       |     */
  740|     47|}
which_module:
 3835|    141|{
 3836|    141|    struct module  *mp;
 3837|       |
 3838|    141|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3838:28): [True: 0, False: 141]
  ------------------
 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|    141|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    141|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    141|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 141]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 141]
  |  |  ------------------
  ------------------
 3843|    141|    return (-1);
 3844|    141|}
adopt_orphans:
 4033|     47|{
 4034|     47|    struct node    *np = NULL, *onp;
 4035|     47|    struct tree    *tp;
 4036|     47|    int             i, adopted = 1;
 4037|       |
 4038|     47|    if (!orphan_nodes)
  ------------------
  |  Branch (4038:9): [True: 47, False: 0]
  ------------------
 4039|     47|        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.25k|{
 4112|  2.25k|    int status = 0;
 4113|  2.25k|    status = read_module_internal(name);
 4114|       |
 4115|  2.25k|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|  2.25k|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4115:9): [True: 2.25k, False: 0]
  ------------------
 4116|  2.25k|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4116:13): [True: 2.25k, False: 0]
  ------------------
 4117|  2.25k|            print_module_not_found(name);
 4118|  2.25k|    } 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.25k|    return tree_head;
 4127|  2.25k|}
unload_module_by_ID:
 4136|     47|{
 4137|     47|    struct tree    *tp, *next;
 4138|     47|    int             i;
 4139|       |
 4140|    188|    for (tp = tree_top; tp; tp = next) {
  ------------------
  |  Branch (4140:25): [True: 141, False: 47]
  ------------------
 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|    141|        int             nmod = tp->number_modules;
 4149|    141|        if (nmod > 0) {         /* in some module */
  ------------------
  |  Branch (4149:13): [True: 141, False: 0]
  ------------------
 4150|       |            /*
 4151|       |             * Remove all copies of this module ID
 4152|       |             */
 4153|    141|            int             cnt = 0, *pi1, *pi2 = tp->module_list;
 4154|    282|            for (i = 0, pi1 = pi2; i < nmod; i++, pi2++) {
  ------------------
  |  Branch (4154:36): [True: 141, False: 141]
  ------------------
 4155|    141|                if (*pi2 == modID)
  ------------------
  |  Branch (4155:21): [True: 141, False: 0]
  ------------------
 4156|    141|                    continue;
 4157|      0|                cnt++;
 4158|      0|                *pi1++ = *pi2;
 4159|      0|            }
 4160|    141|            if (nmod != cnt) {  /* in this module */
  ------------------
  |  Branch (4160:17): [True: 141, 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|    141|                tp->number_modules = cnt;
 4166|    141|                switch (cnt) {
 4167|    141|                case 0:
  ------------------
  |  Branch (4167:17): [True: 141, False: 0]
  ------------------
 4168|    141|                    tp->module_list[0] = -1;    /* Mark unused, */
 4169|    141|		    NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|    141|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4170|       |
 4171|    141|                case 1:        /* save the remaining module */
  ------------------
  |  Branch (4171:17): [True: 0, False: 141]
  ------------------
 4172|    141|                    if (&(tp->modid) != tp->module_list) {
  ------------------
  |  Branch (4172:25): [True: 0, False: 141]
  ------------------
 4173|      0|                        tp->modid = tp->module_list[0];
 4174|      0|                        free(tp->module_list);
 4175|      0|                        tp->module_list = &(tp->modid);
 4176|      0|                    }
 4177|    141|                    break;
 4178|       |
 4179|      0|                default:
  ------------------
  |  Branch (4179:17): [True: 0, False: 141]
  ------------------
 4180|      0|                    break;
 4181|    141|                }
 4182|    141|            }                   /* if tree node is in this module */
 4183|    141|        }
 4184|       |        /*
 4185|       |         * if tree node is in some module 
 4186|       |         */
 4187|    141|        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|    141|        if (tp->child_list)
  ------------------
  |  Branch (4195:13): [True: 0, False: 141]
  ------------------
 4196|      0|            unload_module_by_ID(modID, tp->child_list);
 4197|       |
 4198|       |
 4199|    141|        if (tp->number_modules == 0) {
  ------------------
  |  Branch (4199:13): [True: 141, False: 0]
  ------------------
 4200|       |            /*
 4201|       |             * This node isn't needed any more (except perhaps
 4202|       |             * for the sake of the children) 
 4203|       |             */
 4204|    141|            if (tp->child_list == NULL) {
  ------------------
  |  Branch (4204:17): [True: 141, False: 0]
  ------------------
 4205|    141|                unlink_tree(tp);
 4206|    141|                free_tree(tp);
 4207|    141|            } else {
 4208|      0|                free_partial_tree(tp, TRUE);
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
 4209|      0|            }
 4210|    141|        }
 4211|    141|    }
 4212|     47|}
unload_all_mibs:
 4249|     47|{
 4250|     47|    struct module  *mp;
 4251|     47|    struct module_compatability *mcp;
 4252|     47|    struct tc      *ptc;
 4253|     47|    unsigned int    i;
 4254|       |
 4255|     47|    for (mcp = module_map_head; mcp; mcp = module_map_head) {
  ------------------
  |  Branch (4255:33): [True: 47, False: 0]
  ------------------
 4256|     47|        if (mcp == module_map)
  ------------------
  |  Branch (4256:13): [True: 47, False: 0]
  ------------------
 4257|     47|            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|     47|    for (mp = module_head; mp; mp = module_head) {
  ------------------
  |  Branch (4265:28): [True: 0, False: 47]
  ------------------
 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|     47|    unload_module_by_ID(-1, tree_head);
 4285|       |    /*
 4286|       |     * tree nodes are cleared 
 4287|       |     */
 4288|       |
 4289|  4.74k|    for (i = 0, ptc = tclist; i < tc_alloc; i++, ptc++) {
  ------------------
  |  Branch (4289:31): [True: 4.70k, False: 47]
  ------------------
 4290|  4.70k|        if (ptc->type == 0)
  ------------------
  |  Branch (4290:13): [True: 4.70k, False: 0]
  ------------------
 4291|  4.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|     47|    SNMP_FREE(tclist);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 4301|     47|    tc_alloc = 0;
 4302|       |
 4303|     47|    memset(buckets, 0, sizeof(buckets));
 4304|     47|    memset(nbuckets, 0, sizeof(nbuckets));
 4305|     47|    memset(tbuckets, 0, sizeof(tbuckets));
 4306|       |
 4307|    188|    for (i = 0; i < sizeof(root_imports) / sizeof(root_imports[0]); i++) {
  ------------------
  |  Branch (4307:17): [True: 141, False: 47]
  ------------------
 4308|    141|        SNMP_FREE(root_imports[i].label);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 141, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
 4309|    141|    }
 4310|       |
 4311|     47|    max_module = 0;
 4312|     47|    current_module = 0;
 4313|     47|    module_map_head = NULL;
 4314|     47|    SNMP_FREE(last_err_module);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 4315|       |
 4316|     47|    {
 4317|     47|        struct node *np = orphan_nodes;
 4318|       |
 4319|     47|        while (np) {
  ------------------
  |  Branch (4319:16): [True: 0, False: 47]
  ------------------
 4320|      0|            struct node *nnp = np->next;
 4321|      0|            free_node(np);
 4322|      0|            np = nnp;
 4323|      0|        }
 4324|       |        orphan_nodes = NULL;
 4325|     47|    }
 4326|     47|    erroneousMibs = 0;
 4327|     47|    first_err_module = 1;
 4328|     47|}
add_mibdir:
 5124|     47|{
 5125|     47|    const char     *oldFile = File;
 5126|     47|    int             oldLine = mibLine;
 5127|     47|    char          **filenames;
 5128|     47|    int             count = 0;
 5129|     47|    int             filename_count, i;
 5130|       |
 5131|     47|    DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 5132|       |
 5133|     47|    filename_count = scan_directory(&filenames, dirname);
 5134|       |
 5135|     47|    if (filename_count >= 0) {
  ------------------
  |  Branch (5135:9): [True: 0, False: 47]
  ------------------
 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|     47|    else
 5147|     47|        DEBUGMSGTL(("parse-mibs","cannot open MIB directory %s\n", dirname));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 5148|       |
 5149|     47|    return (-1);
 5150|     47|}
parse.c:name_hash:
  687|  4.60k|{
  688|  4.60k|    int             hash = 0;
  689|  4.60k|    const char     *cp;
  690|       |
  691|  4.60k|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 4.60k]
  ------------------
  692|      0|        return 0;
  693|  48.3k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 43.7k, False: 4.60k]
  ------------------
  694|  43.7k|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [Folded, False: 43.7k]
  ------------------
  695|  4.60k|    return (hash);
  696|  4.60k|}
parse.c:build_translation_table:
 1071|     47|{
 1072|     47|    int             count;
 1073|       |
 1074|  12.0k|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1074:21): [True: 12.0k, False: 47]
  ------------------
 1075|  12.0k|        switch (count) {
 1076|     47|        case OBJID:
  ------------------
  |  |  167|     47|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1076:9): [True: 47, False: 11.9k]
  ------------------
 1077|     47|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  155|     47|#define TYPE_OBJID          1
  ------------------
 1078|     47|            break;
 1079|     47|        case OCTETSTR:
  ------------------
  |  |  168|     47|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1079:9): [True: 47, False: 11.9k]
  ------------------
 1080|     47|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  156|     47|#define TYPE_OCTETSTR       2
  ------------------
 1081|     47|            break;
 1082|     47|        case INTEGER:
  ------------------
  |  |  169|     47|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 47, False: 11.9k]
  ------------------
 1083|     47|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  157|     47|#define TYPE_INTEGER        3
  ------------------
 1084|     47|            break;
 1085|     47|        case NETADDR:
  ------------------
  |  |  170|     47|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1085:9): [True: 47, False: 11.9k]
  ------------------
 1086|     47|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  158|     47|#define TYPE_NETADDR        4
  ------------------
 1087|     47|            break;
 1088|     47|        case IPADDR:
  ------------------
  |  |  171|     47|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1088:9): [True: 47, False: 11.9k]
  ------------------
 1089|     47|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  159|     47|#define TYPE_IPADDR         5
  ------------------
 1090|     47|            break;
 1091|     47|        case COUNTER:
  ------------------
  |  |  172|     47|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1091:9): [True: 47, False: 11.9k]
  ------------------
 1092|     47|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  160|     47|#define TYPE_COUNTER        6
  ------------------
 1093|     47|            break;
 1094|     47|        case GAUGE:
  ------------------
  |  |  173|     47|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1094:9): [True: 47, False: 11.9k]
  ------------------
 1095|     47|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  161|     47|#define TYPE_GAUGE          7
  ------------------
 1096|     47|            break;
 1097|     47|        case TIMETICKS:
  ------------------
  |  |  174|     47|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1097:9): [True: 47, False: 11.9k]
  ------------------
 1098|     47|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  162|     47|#define TYPE_TIMETICKS      8
  ------------------
 1099|     47|            break;
 1100|     47|        case KW_OPAQUE:
  ------------------
  |  |  175|     47|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1100:9): [True: 47, False: 11.9k]
  ------------------
 1101|     47|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  163|     47|#define TYPE_OPAQUE         9
  ------------------
 1102|     47|            break;
 1103|     47|        case NUL:
  ------------------
  |  |  176|     47|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1103:9): [True: 47, False: 11.9k]
  ------------------
 1104|     47|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  164|     47|#define TYPE_NULL           10
  ------------------
 1105|     47|            break;
 1106|     47|        case COUNTER64:
  ------------------
  |  |  211|     47|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1106:9): [True: 47, False: 11.9k]
  ------------------
 1107|     47|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  165|     47|#define TYPE_COUNTER64      11
  ------------------
 1108|     47|            break;
 1109|     47|        case BITSTRING:
  ------------------
  |  |  209|     47|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1109:9): [True: 47, False: 11.9k]
  ------------------
 1110|     47|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  166|     47|#define TYPE_BITSTRING      12
  ------------------
 1111|     47|            break;
 1112|     47|        case NSAPADDRESS:
  ------------------
  |  |  210|     47|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1112:9): [True: 47, False: 11.9k]
  ------------------
 1113|     47|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  167|     47|#define TYPE_NSAPADDRESS    13
  ------------------
 1114|     47|            break;
 1115|     47|        case INTEGER32:
  ------------------
  |  |  274|     47|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1115:9): [True: 47, False: 11.9k]
  ------------------
 1116|     47|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  170|     47|#define TYPE_INTEGER32      16
  ------------------
 1117|     47|            break;
 1118|     47|        case UINTEGER32:
  ------------------
  |  |  224|     47|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1118:9): [True: 47, False: 11.9k]
  ------------------
 1119|     47|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  168|     47|#define TYPE_UINTEGER       14
  ------------------
 1120|     47|            break;
 1121|     47|        case UNSIGNED32:
  ------------------
  |  |  273|     47|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     47|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1121:9): [True: 47, False: 11.9k]
  ------------------
 1122|     47|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  169|     47|#define TYPE_UNSIGNED32     15
  ------------------
 1123|     47|            break;
 1124|     47|        case TRAPTYPE:
  ------------------
  |  |  229|     47|#define TRAPTYPE    61
  ------------------
  |  Branch (1124:9): [True: 47, False: 11.9k]
  ------------------
 1125|     47|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  174|     47|#define TYPE_TRAPTYPE	    20
  ------------------
 1126|     47|            break;
 1127|     47|        case NOTIFTYPE:
  ------------------
  |  |  213|     47|#define NOTIFTYPE   45
  ------------------
  |  Branch (1127:9): [True: 47, False: 11.9k]
  ------------------
 1128|     47|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  175|     47|#define TYPE_NOTIFTYPE      21
  ------------------
 1129|     47|            break;
 1130|     47|        case NOTIFGROUP:
  ------------------
  |  |  258|     47|#define NOTIFGROUP  88
  ------------------
  |  Branch (1130:9): [True: 47, False: 11.9k]
  ------------------
 1131|     47|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  177|     47|#define TYPE_NOTIFGROUP	    23
  ------------------
 1132|     47|            break;
 1133|     47|        case OBJGROUP:
  ------------------
  |  |  212|     47|#define OBJGROUP    44
  ------------------
  |  Branch (1133:9): [True: 47, False: 11.9k]
  ------------------
 1134|     47|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  176|     47|#define TYPE_OBJGROUP	    22
  ------------------
 1135|     47|            break;
 1136|     47|        case MODULEIDENTITY:
  ------------------
  |  |  220|     47|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1136:9): [True: 47, False: 11.9k]
  ------------------
 1137|     47|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  178|     47|#define TYPE_MODID	    24
  ------------------
 1138|     47|            break;
 1139|     47|        case OBJIDENTITY:
  ------------------
  |  |  275|     47|#define OBJIDENTITY	106
  ------------------
  |  Branch (1139:9): [True: 47, False: 11.9k]
  ------------------
 1140|     47|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  181|     47|#define TYPE_OBJIDENTITY    27
  ------------------
 1141|     47|            break;
 1142|     47|        case AGENTCAP:
  ------------------
  |  |  243|     47|#define AGENTCAP    73
  ------------------
  |  Branch (1142:9): [True: 47, False: 11.9k]
  ------------------
 1143|     47|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  179|     47|#define TYPE_AGENTCAP       25
  ------------------
 1144|     47|            break;
 1145|     47|        case COMPLIANCE:
  ------------------
  |  |  215|     47|#define COMPLIANCE  47
  ------------------
  |  Branch (1145:9): [True: 47, False: 11.9k]
  ------------------
 1146|     47|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  180|     47|#define TYPE_MODCOMP        26
  ------------------
 1147|     47|            break;
 1148|  10.9k|        default:
  ------------------
  |  Branch (1148:9): [True: 10.9k, False: 1.12k]
  ------------------
 1149|  10.9k|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  154|  10.9k|#define TYPE_OTHER          0
  ------------------
 1150|  10.9k|            break;
 1151|  12.0k|        }
 1152|  12.0k|    }
 1153|     47|}
parse.c:init_tree_roots:
 1157|     47|{
 1158|     47|    struct tree    *tp, *lasttp;
 1159|     47|    int             base_modid;
 1160|     47|    int             hash;
 1161|       |
 1162|     47|    base_modid = which_module("SNMPv2-SMI");
 1163|     47|    if (base_modid == -1)
  ------------------
  |  Branch (1163:9): [True: 47, False: 0]
  ------------------
 1164|     47|        base_modid = which_module("RFC1155-SMI");
 1165|     47|    if (base_modid == -1)
  ------------------
  |  Branch (1165:9): [True: 47, False: 0]
  ------------------
 1166|     47|        base_modid = which_module("RFC1213-MIB");
 1167|       |
 1168|       |    /*
 1169|       |     * build root node 
 1170|       |     */
 1171|     47|    tp = calloc(1, sizeof(struct tree));
 1172|     47|    if (tp == NULL)
  ------------------
  |  Branch (1172:9): [True: 0, False: 47]
  ------------------
 1173|      0|        return;
 1174|     47|    tp->label = strdup("joint-iso-ccitt");
 1175|     47|    tp->modid = base_modid;
 1176|     47|    tp->number_modules = 1;
 1177|     47|    tp->module_list = &(tp->modid);
 1178|     47|    tp->subid = 2;
 1179|     47|    tp->tc_index = -1;
 1180|     47|    set_function(tp);           /* from mib.c */
 1181|     47|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     47|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     47|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1182|     47|    tp->next = tbuckets[hash];
 1183|     47|    tbuckets[hash] = tp;
 1184|     47|    lasttp = tp;
 1185|     47|    root_imports[0].label = strdup(tp->label);
 1186|     47|    root_imports[0].modid = base_modid;
 1187|       |
 1188|       |    /*
 1189|       |     * build root node 
 1190|       |     */
 1191|     47|    tp = calloc(1, sizeof(struct tree));
 1192|     47|    if (tp == NULL)
  ------------------
  |  Branch (1192:9): [True: 0, False: 47]
  ------------------
 1193|      0|        return;
 1194|     47|    tp->next_peer = lasttp;
 1195|     47|    tp->label = strdup("ccitt");
 1196|     47|    tp->modid = base_modid;
 1197|     47|    tp->number_modules = 1;
 1198|     47|    tp->module_list = &(tp->modid);
 1199|     47|    tp->subid = 0;
 1200|     47|    tp->tc_index = -1;
 1201|     47|    set_function(tp);           /* from mib.c */
 1202|     47|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     47|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     47|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1203|     47|    tp->next = tbuckets[hash];
 1204|     47|    tbuckets[hash] = tp;
 1205|     47|    lasttp = tp;
 1206|     47|    root_imports[1].label = strdup(tp->label);
 1207|     47|    root_imports[1].modid = base_modid;
 1208|       |
 1209|       |    /*
 1210|       |     * build root node 
 1211|       |     */
 1212|     47|    tp = calloc(1, sizeof(struct tree));
 1213|     47|    if (tp == NULL)
  ------------------
  |  Branch (1213:9): [True: 0, False: 47]
  ------------------
 1214|      0|        return;
 1215|     47|    tp->next_peer = lasttp;
 1216|     47|    tp->label = strdup("iso");
 1217|     47|    tp->modid = base_modid;
 1218|     47|    tp->number_modules = 1;
 1219|     47|    tp->module_list = &(tp->modid);
 1220|     47|    tp->subid = 1;
 1221|     47|    tp->tc_index = -1;
 1222|     47|    set_function(tp);           /* from mib.c */
 1223|     47|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     47|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     47|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1224|     47|    tp->next = tbuckets[hash];
 1225|     47|    tbuckets[hash] = tp;
 1226|     47|    lasttp = tp;
 1227|     47|    root_imports[2].label = strdup(tp->label);
 1228|     47|    root_imports[2].modid = base_modid;
 1229|       |
 1230|     47|    tree_head = tp;
 1231|     47|}
parse.c:unlink_tbucket:
  830|    141|{
  831|    141|    int             hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|    141|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    141|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
  832|    141|    struct tree    *otp = NULL, *ntp = tbuckets[hash];
  833|       |
  834|    141|    while (ntp && ntp != tp) {
  ------------------
  |  Branch (834:12): [True: 141, False: 0]
  |  Branch (834:19): [True: 0, False: 141]
  ------------------
  835|      0|        otp = ntp;
  836|      0|        ntp = ntp->next;
  837|      0|    }
  838|    141|    if (!ntp)
  ------------------
  |  Branch (838:9): [True: 0, False: 141]
  ------------------
  839|      0|        snmp_log(LOG_EMERG, "Can't find %s in tbuckets\n", tp->label);
  840|    141|    else if (otp)
  ------------------
  |  Branch (840:14): [True: 0, False: 141]
  ------------------
  841|      0|        otp->next = ntp->next;
  842|    141|    else
  843|    141|        tbuckets[hash] = tp->next;
  844|    141|}
parse.c:read_module_internal:
 4019|  2.25k|{
 4020|  2.25k|    struct module  *mp;
 4021|       |
 4022|  2.25k|    netsnmp_init_mib_internals();
 4023|       |
 4024|  2.25k|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4024:28): [True: 0, False: 2.25k]
  ------------------
 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.25k|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|  2.25k|#define MODULE_NOT_FOUND	0
  ------------------
 4029|  2.25k|}
parse.c:print_error:
  780|  2.25k|{
  781|  2.25k|    erroneousMibs++;
  782|  2.25k|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  2.25k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 0, False: 2.25k]
  ------------------
  783|  2.25k|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|  2.25k|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|      0|	return;
  785|  2.25k|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|  2.25k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.25k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%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.25k]
  |  |  ------------------
  ------------------
  786|  2.25k|    if (type == ENDOFFILE)
  ------------------
  |  |  163|  2.25k|#define ENDOFFILE   0
  ------------------
  |  Branch (786:9): [True: 0, False: 2.25k]
  ------------------
  787|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  788|      0|                 File);
  789|  2.25k|    else if (token && *token)
  ------------------
  |  Branch (789:14): [True: 2.25k, False: 0]
  |  Branch (789:23): [True: 2.25k, False: 0]
  ------------------
  790|  2.25k|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  791|  2.25k|                 mibLine, File);
  792|      0|    else
  793|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  794|  2.25k|}
parse.c:free_indexes:
 5366|    141|{
 5367|    141|    if (spp && *spp) {
  ------------------
  |  Branch (5367:9): [True: 141, False: 0]
  |  Branch (5367:16): [True: 0, False: 141]
  ------------------
 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|    141|}
parse.c:free_varbinds:
 5385|    141|{
 5386|    141|    if (spp && *spp) {
  ------------------
  |  Branch (5386:9): [True: 141, False: 0]
  |  Branch (5386:16): [True: 0, False: 141]
  ------------------
 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|    141|}
parse.c:read_module_replacements:
 3899|  2.25k|{
 3900|  2.25k|    struct module_compatability *mcp;
 3901|       |
 3902|  51.8k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3902:33): [True: 49.6k, False: 2.25k]
  ------------------
 3903|  49.6k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  49.6k|#define	label_compare	strcmp
  ------------------
  |  Branch (3903:13): [True: 0, False: 49.6k]
  ------------------
 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|  49.6k|    }
 3914|  2.25k|    return 0;
 3915|  2.25k|}
parse.c:print_module_not_found:
  798|  2.25k|{
  799|  2.25k|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 47, False: 2.20k]
  ------------------
  800|     47|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  801|     47|                           netsnmp_get_mib_directory());
  802|     47|        first_err_module = 0;
  803|     47|    }
  804|  2.25k|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 47, False: 2.20k]
  |  Branch (804:29): [True: 2.20k, False: 0]
  ------------------
  805|  2.25k|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|  2.25k|#define CONTINUE    -1
  ------------------
  806|  2.25k|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 2.20k, False: 47]
  ------------------
  807|  2.20k|        free(last_err_module);
  808|  2.25k|    last_err_module = strdup(cp);
  809|  2.25k|}
parse.c:unlink_tree:
  848|    141|{
  849|    141|    struct tree    *otp = NULL, *ntp = tp->parent;
  850|       |
  851|    141|    if (!ntp) {                 /* this tree has no parent */
  ------------------
  |  Branch (851:9): [True: 141, False: 0]
  ------------------
  852|    141|        DEBUGMSGTL(("unlink_tree", "Tree node %s has no parent\n",
  ------------------
  |  |   66|    141|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    141|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 141]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 141]
  |  |  ------------------
  ------------------
  853|    141|                    tp->label));
  854|    141|    } 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|    141|    if (tree_head == tp)
  ------------------
  |  Branch (870:9): [True: 141, False: 0]
  ------------------
  871|    141|        tree_head = tp->next_peer;
  872|    141|}
parse.c:free_tree:
  903|    141|{
  904|    141|    if (!Tree)
  ------------------
  |  Branch (904:9): [True: 0, False: 141]
  ------------------
  905|      0|        return;
  906|       |
  907|    141|    unlink_tbucket(Tree);
  908|    141|    free_partial_tree(Tree, FALSE);
  ------------------
  |  |  125|    141|#define FALSE 0
  ------------------
  909|    141|    if (Tree->module_list != &Tree->modid)
  ------------------
  |  Branch (909:9): [True: 0, False: 141]
  ------------------
  910|      0|        free(Tree->module_list);
  911|    141|    free(Tree);
  912|    141|}
parse.c:free_partial_tree:
  876|    141|{
  877|    141|    if (!tp)
  ------------------
  |  Branch (877:9): [True: 0, False: 141]
  ------------------
  878|      0|        return;
  879|       |
  880|       |    /*
  881|       |     * remove the data from this tree node 
  882|       |     */
  883|    141|    free_enums(&tp->enums);
  884|    141|    free_ranges(&tp->ranges);
  885|    141|    free_indexes(&tp->indexes);
  886|    141|    free_varbinds(&tp->varbinds);
  887|    141|    if (!keep_label)
  ------------------
  |  Branch (887:9): [True: 141, False: 0]
  ------------------
  888|    141|        SNMP_FREE(tp->label);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 141, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  889|    141|    SNMP_FREE(tp->hint);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 141]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  890|    141|    SNMP_FREE(tp->units);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 141]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  891|    141|    SNMP_FREE(tp->description);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 141]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  892|    141|    SNMP_FREE(tp->reference);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 141]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  893|    141|    SNMP_FREE(tp->augments);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 141]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  894|       |    SNMP_FREE(tp->defaultValue);
  ------------------
  |  |   62|    141|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 141]
  |  |  |  Branch (62:66): [Folded, False: 141]
  |  |  ------------------
  ------------------
  895|    141|}
parse.c:scan_directory:
 5054|     47|{
 5055|     47|    DIR            *dir, *dir2;
 5056|     47|    struct dirent  *file;
 5057|     47|    char          **filenames = NULL;
 5058|     47|    int             fname_len, i, filename_count = 0, array_size = 0;
 5059|     47|    char           *tmpstr;
 5060|       |
 5061|     47|    *result = NULL;
 5062|       |
 5063|     47|    dir = opendir(dirname);
 5064|     47|    if (!dir)
  ------------------
  |  Branch (5064:9): [True: 47, False: 0]
  ------------------
 5065|     47|        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|    141|{
 5405|    141|    if (spp && *spp) {
  ------------------
  |  Branch (5405:9): [True: 141, False: 0]
  |  Branch (5405:16): [True: 0, False: 141]
  ------------------
 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|    141|}
parse.c:free_enums:
 5421|    141|{
 5422|    141|    if (spp && *spp) {
  ------------------
  |  Branch (5422:9): [True: 141, False: 0]
  |  Branch (5422:16): [True: 0, False: 141]
  ------------------
 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|    141|}

register_prenetsnmp_mib_handler:
  256|  1.64k|{
  257|  1.64k|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  258|  1.64k|					    help, PREMIB_CONFIG);
  ------------------
  |  |   15|  1.64k|#define PREMIB_CONFIG 1
  ------------------
  259|  1.64k|}
register_config_handler:
  311|  2.96k|{
  312|  2.96k|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  313|  2.96k|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|  2.96k|#define NORMAL_CONFIG 0
  ------------------
  314|  2.96k|}
register_const_config_handler:
  321|     47|{
  322|     47|    return internal_register_config_handler(type, token, NULL, parser, releaser,
  323|     47|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|     47|#define NORMAL_CONFIG 0
  ------------------
  324|     47|}
register_app_config_handler:
  330|     94|{
  331|       |    return register_config_handler(NULL, token, parser, releaser, help);
  332|     94|}
unregister_config_handler:
  356|  7.84k|{
  357|  7.84k|    struct config_files **ctmp = &config_files;
  358|  7.84k|    struct config_line  **ltmp;
  359|  7.84k|    const char           *type = type_param;
  360|       |
  361|  7.84k|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (361:9): [True: 0, False: 7.84k]
  |  Branch (361:25): [True: 0, False: 7.84k]
  ------------------
  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|  7.84k|    if (strchr(type, ':')) {
  ------------------
  |  Branch (369:9): [True: 0, False: 7.84k]
  ------------------
  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|  7.84k|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (389:12): [True: 4.74k, False: 3.10k]
  |  Branch (389:29): [True: 0, False: 4.74k]
  ------------------
  390|      0|        ctmp = &((*ctmp)->next);
  391|      0|    }
  392|       |
  393|  7.84k|    if (*ctmp == NULL) {
  ------------------
  |  Branch (393:9): [True: 3.10k, False: 4.74k]
  ------------------
  394|       |        /*
  395|       |         * Not found, return. 
  396|       |         */
  397|  3.10k|        return;
  398|  3.10k|    }
  399|       |
  400|  4.74k|    ltmp = &((*ctmp)->start);
  401|  4.74k|    if (*ltmp == NULL) {
  ------------------
  |  Branch (401:9): [True: 0, False: 4.74k]
  ------------------
  402|       |        /*
  403|       |         * Not found, return. 
  404|       |         */
  405|      0|        return;
  406|      0|    }
  407|  4.74k|    if (strcmp((*ltmp)->config_token, token) == 0) {
  ------------------
  |  Branch (407:9): [True: 4.74k, False: 0]
  ------------------
  408|       |        /*
  409|       |         * found it at the top of the list 
  410|       |         */
  411|  4.74k|        struct config_line *ltmp2 = (*ltmp)->next;
  412|  4.74k|        if ((*ltmp)->free_func)
  ------------------
  |  Branch (412:13): [True: 329, False: 4.41k]
  ------------------
  413|    329|            (*ltmp)->free_func();
  414|  4.74k|        SNMP_FREE((*ltmp)->config_token);
  ------------------
  |  |   62|  4.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 4.74k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  415|  4.74k|        SNMP_FREE((*ltmp)->help);
  ------------------
  |  |   62|  4.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 4.18k, False: 564]
  |  |  |  Branch (62:66): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  416|  4.74k|        SNMP_FREE(*ltmp);
  ------------------
  |  |   62|  4.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 4.74k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  417|  4.74k|        (*ctmp)->start = ltmp2;
  418|  4.74k|        return;
  419|  4.74k|    }
  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|     47|{
  446|     47|    struct config_files *ctmp, *save;
  447|     47|    struct config_line *ltmp;
  448|       |
  449|       |    /*
  450|       |     * Keep using config_files until there are no more! 
  451|       |     */
  452|    141|    for (ctmp = config_files; ctmp;) {
  ------------------
  |  Branch (452:31): [True: 94, False: 47]
  ------------------
  453|  4.84k|        for (ltmp = ctmp->start; ltmp; ltmp = ctmp->start) {
  ------------------
  |  Branch (453:34): [True: 4.74k, False: 94]
  ------------------
  454|  4.74k|            unregister_config_handler(ctmp->fileHeader,
  455|  4.74k|                                      ltmp->config_token);
  456|  4.74k|        }
  457|     94|        SNMP_FREE(ctmp->fileHeader);
  ------------------
  |  |   62|     94|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 94, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 94]
  |  |  ------------------
  ------------------
  458|     94|        save = ctmp->next;
  459|       |        SNMP_FREE(ctmp);
  ------------------
  |  |   62|     94|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 94, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 94]
  |  |  ------------------
  ------------------
  460|     94|        ctmp = save;
  461|     94|        config_files = save;
  462|     94|    }
  463|     47|}
netsnmp_config_remember_free_list:
  691|     47|{
  692|     47|    struct read_config_memory *tmpmem;
  693|     47|    while (*mem) {
  ------------------
  |  Branch (693:12): [True: 0, False: 47]
  ------------------
  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|     47|}
netsnmp_config_process_memory_list:
  704|     94|{
  705|       |
  706|     94|    struct read_config_memory *mem;
  707|       |
  708|     94|    if (!memp)
  ------------------
  |  Branch (708:9): [True: 0, False: 94]
  ------------------
  709|      0|        return;
  710|       |
  711|     94|    mem = *memp;
  712|       |
  713|     94|    while (mem) {
  ------------------
  |  Branch (713:12): [True: 0, False: 94]
  ------------------
  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|     94|    if (clear)
  ------------------
  |  Branch (719:9): [True: 47, False: 47]
  ------------------
  720|     47|        netsnmp_config_remember_free_list(memp);
  721|     94|}
netsnmp_config_process_memories_when:
  742|     94|{
  743|     94|    netsnmp_config_process_memory_list(&memorylist, when, clear);
  744|     94|}
free_config:
 1029|     47|{
 1030|     47|    struct config_files *ctmp = config_files;
 1031|     47|    struct config_line *ltmp;
 1032|       |
 1033|    141|    for (; ctmp != NULL; ctmp = ctmp->next)
  ------------------
  |  Branch (1033:12): [True: 94, False: 47]
  ------------------
 1034|  4.84k|        for (ltmp = ctmp->start; ltmp != NULL; ltmp = ltmp->next)
  ------------------
  |  Branch (1034:34): [True: 4.74k, False: 94]
  ------------------
 1035|  4.74k|            if (ltmp->free_func)
  ------------------
  |  Branch (1035:17): [True: 329, False: 4.41k]
  ------------------
 1036|    329|                (*(ltmp->free_func)) ();
 1037|     47|}
read_configs:
 1082|     47|{
 1083|     47|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1084|     47|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|     47|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1085|       |
 1086|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1087|     47|                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
  ------------------
  |  |   30|     47|#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
  ------------------
 1088|       |
 1089|     47|    DEBUGMSGTL(("read_config", "reading normal configuration tokens\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1090|       |
 1091|     47|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1091:9): [True: 0, False: 47]
  |  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|     47|    (void)read_config_files(NORMAL_CONFIG);
  ------------------
  |  |   14|     47|#define NORMAL_CONFIG 0
  ------------------
 1097|       |
 1098|       |    /*
 1099|       |     * do this even when the normal above wasn't done 
 1100|       |     */
 1101|     47|    if (NULL != optional_config)
  ------------------
  |  Branch (1101:9): [True: 0, False: 47]
  ------------------
 1102|      0|        (void)read_configs_optional(optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1103|       |
 1104|     47|    netsnmp_config_process_memories_when(NORMAL_CONFIG, 1);
  ------------------
  |  |   14|     47|#define NORMAL_CONFIG 0
  ------------------
 1105|       |
 1106|     47|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1107|     47|			   NETSNMP_DS_LIB_HAVE_READ_CONFIG, 1);
  ------------------
  |  |   87|     47|#define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
  ------------------
 1108|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1109|     47|                        SNMP_CALLBACK_POST_READ_CONFIG, NULL);
  ------------------
  |  |   24|     47|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
 1110|     47|}
read_premib_configs:
 1114|     47|{
 1115|     47|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1116|     47|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|     47|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1117|       |
 1118|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1119|     47|                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   31|     47|#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
  ------------------
 1120|       |
 1121|     47|    DEBUGMSGTL(("read_config", "reading premib configuration tokens\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1122|       |
 1123|     47|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 47]
  |  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|     47|    (void)read_config_files(PREMIB_CONFIG);
  ------------------
  |  |   15|     47|#define PREMIB_CONFIG 1
  ------------------
 1129|       |
 1130|     47|    if (NULL != optional_config)
  ------------------
  |  Branch (1130:9): [True: 0, False: 47]
  ------------------
 1131|      0|        (void)read_configs_optional(optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1132|       |
 1133|     47|    netsnmp_config_process_memories_when(PREMIB_CONFIG, 0);
  ------------------
  |  |   15|     47|#define PREMIB_CONFIG 1
  ------------------
 1134|       |
 1135|     47|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1136|     47|			   NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG, 1);
  ------------------
  |  |   86|     47|#define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26       /* have the pre-mib parsing config tokens been processed */
  ------------------
 1137|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1138|     47|                        SNMP_CALLBACK_POST_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   27|     47|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1139|     47|}
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,
  ------------------
  |  | 2033|      1|#define SNMPCONFPATH "/usr/local/net-snmp-master/etc/snmp"
  ------------------
                              SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 1179|      1|                SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2032|      1|#define SNMPSHAREPATH "/usr/local/net-snmp-master/share/snmp"
  ------------------
                              SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
                              SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2031|      1|#define SNMPLIBPATH "/usr/local/net-snmp-master/lib/snmp"
  ------------------
 1180|      1|                ((homepath == NULL) ? "" : ENV_SEPARATOR),
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1180:18): [True: 0, False: 1]
  ------------------
 1181|      1|                ((homepath == NULL) ? "" : homepath),
  ------------------
  |  Branch (1181:18): [True: 0, False: 1]
  ------------------
 1182|      1|                ((homepath == NULL) ? "" : "/.snmp"));
  ------------------
  |  Branch (1182:18): [True: 0, False: 1]
  ------------------
 1183|      1|        defaultPath[ sizeof(defaultPath)-1 ] = 0;
 1184|      1|        set_configuration_directory(defaultPath);
 1185|      1|    }
 1186|      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;
  ------------------
  |  | 2003|      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|    188|{
 1413|    188|    const char     *confpath, *persfile, *envconfpath;
 1414|    188|    char           *perspath;
 1415|    188|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  185|    188|#define SNMPERR_GENERR			(-1)
  ------------------
 1416|       |
 1417|    188|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    188|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1417:9): [True: 188, False: 0]
  ------------------
 1418|    188|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|    188|#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|    188|        || (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|     94|read_config_files(int when) {
 1477|       |
 1478|     94|    struct config_files *ctmp = config_files;
 1479|     94|    int                  ret  = SNMPERR_GENERR;
  ------------------
  |  |  185|     94|#define SNMPERR_GENERR			(-1)
  ------------------
 1480|       |
 1481|     94|    config_errors = 0;
 1482|       |
 1483|     94|    if (when == PREMIB_CONFIG)
  ------------------
  |  |   15|     94|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (1483:9): [True: 47, False: 47]
  ------------------
 1484|     47|        free_config();
 1485|       |
 1486|       |    /*
 1487|       |     * read all config file types 
 1488|       |     */
 1489|    282|    for (; ctmp != NULL; ctmp = ctmp->next) {
  ------------------
  |  Branch (1489:12): [True: 188, False: 94]
  ------------------
 1490|    188|        if ( read_config_files_of_type(when, ctmp) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|    188|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1490:14): [True: 0, False: 188]
  ------------------
 1491|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1492|    188|    }
 1493|       |
 1494|     94|    if (config_errors) {
  ------------------
  |  Branch (1494:9): [True: 0, False: 94]
  ------------------
 1495|       |        snmp_log(LOG_ERR, "net-snmp: %d error(s) in config file(s)\n",
 1496|      0|                 config_errors);
 1497|      0|    }
 1498|     94|    return ret;
 1499|     94|}
read_config_store:
 1548|     94|{
 1549|     94|#ifdef NETSNMP_PERSISTENT_DIRECTORY
 1550|     94|    char            file[512], *filep;
 1551|     94|    FILE           *fout;
 1552|     94|#ifdef NETSNMP_PERSISTENT_MASK
 1553|     94|    mode_t          oldmask;
 1554|     94|#endif
 1555|       |
 1556|     94|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     94|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1556:9): [True: 94, False: 0]
  ------------------
 1557|     94|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     94|#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|     94|                               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);
  ------------------
  |  | 1745|      0|#define NETSNMP_PERSISTENT_MASK 077
  ------------------
 1573|      0|#endif
 1574|      0|    if (mkdirhier(filep, NETSNMP_AGENT_DIRECTORY_MODE, 1)) {
  ------------------
  |  | 2008|      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|     47|{
 1653|     47|    char            file[512], fileold[SPRINT_MAX_LEN];
 1654|     47|    struct stat     statbuf;
 1655|     47|    int             j;
 1656|       |
 1657|     47|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1657:9): [True: 47, False: 0]
  ------------------
 1658|     47|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     47|#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|     47|                               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++) {
  ------------------
  |  | 2015|      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|     47|{
 1717|     47|    char            file[512];
 1718|     47|    struct stat     statbuf;
 1719|     47|    int             j;
 1720|       |
 1721|     47|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1721:9): [True: 47, False: 0]
  ------------------
 1722|     47|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     47|#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|     47|                               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++) {
  ------------------
  |  | 2015|      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|    188|{
 1807|    188|    if (ptr == NULL)
  ------------------
  |  Branch (1807:9): [True: 0, False: 188]
  ------------------
 1808|      0|        return (NULL);
 1809|    282|    while (*ptr != 0 && isspace((unsigned char)*ptr))
  ------------------
  |  Branch (1809:12): [True: 188, False: 94]
  |  Branch (1809:25): [True: 94, False: 94]
  ------------------
 1810|     94|        ptr++;
 1811|    188|    if (*ptr == 0 || *ptr == '#')
  ------------------
  |  Branch (1811:9): [True: 94, False: 94]
  |  Branch (1811:22): [True: 0, False: 94]
  ------------------
 1812|     94|        return (NULL);
 1813|     94|    return (ptr);
 1814|    188|}
copy_nword_const:
 1871|    188|{
 1872|    188|    char            quote;
 1873|    188|    if (!from || !to)
  ------------------
  |  Branch (1873:9): [True: 0, False: 188]
  |  Branch (1873:18): [True: 0, False: 188]
  ------------------
 1874|      0|        return NULL;
 1875|    188|    if ((*from == '\"') || (*from == '\'')) {
  ------------------
  |  Branch (1875:9): [True: 0, False: 188]
  |  Branch (1875:28): [True: 0, False: 188]
  ------------------
 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|    188|    } else {
 1900|    846|        while (*from != 0 && !isspace((unsigned char)(*from))) {
  ------------------
  |  Branch (1900:16): [True: 752, False: 94]
  |  Branch (1900:30): [True: 658, False: 94]
  ------------------
 1901|    658|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1901:17): [True: 0, False: 658]
  |  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|    658|            } else {
 1909|    658|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1909:21): [True: 658, False: 0]
  ------------------
 1910|    658|                    *to++ = *from++;
 1911|    658|                    if (--len == 0)
  ------------------
  |  Branch (1911:25): [True: 0, False: 658]
  ------------------
 1912|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1913|    658|                } else
 1914|      0|                    from++;
 1915|    658|            }
 1916|    658|        }
 1917|    188|    }
 1918|    188|    if (len > 0)
  ------------------
  |  Branch (1918:9): [True: 188, False: 0]
  ------------------
 1919|    188|        *to = 0;
 1920|    188|    from = skip_white_const(from);
 1921|    188|    return (from);
 1922|    188|}                               /* copy_nword */
read_config_save_octet_string:
 1963|     47|{
 1964|     47|    size_t          i;
 1965|     47|    const u_char   *cp;
 1966|       |
 1967|       |    /*
 1968|       |     * is everything easily printable
 1969|       |     */
 1970|     47|    for (i = 0, cp = str; i < len && cp &&
  ------------------
  |  Branch (1970:27): [True: 47, False: 0]
  |  Branch (1970:38): [True: 47, False: 0]
  ------------------
 1971|     47|         (isalpha(*cp) || isdigit(*cp) || *cp == ' '); cp++, i++);
  ------------------
  |  Branch (1971:11): [True: 0, False: 47]
  |  Branch (1971:27): [True: 0, False: 47]
  |  Branch (1971:43): [True: 0, False: 47]
  ------------------
 1972|       |
 1973|     47|    if (len != 0 && i == len) {
  ------------------
  |  Branch (1973:9): [True: 47, False: 0]
  |  Branch (1973:21): [True: 0, False: 47]
  ------------------
 1974|      0|        *saveto++ = '"';
 1975|      0|        memcpy(saveto, str, len);
 1976|      0|        saveto += len;
 1977|      0|        *saveto++ = '"';
 1978|      0|        *saveto = '\0';
 1979|     47|    } else {
 1980|     47|        if (str != NULL) {
  ------------------
  |  Branch (1980:13): [True: 47, False: 0]
  ------------------
 1981|     47|            sprintf(saveto, "0x");
 1982|     47|            saveto += 2;
 1983|    846|            for (i = 0; i < len; i++) {
  ------------------
  |  Branch (1983:25): [True: 799, False: 47]
  ------------------
 1984|    799|                sprintf(saveto, "%02x", str[i]);
 1985|    799|                saveto = saveto + 2;
 1986|    799|            }
 1987|     47|        } else {
 1988|      0|            sprintf(saveto, "\"\"");
 1989|      0|            saveto += 2;
 1990|      0|        }
 1991|     47|    }
 1992|     47|    return saveto;
 1993|     47|}
read_config.c:internal_register_config_handler:
  153|  4.84k|{
  154|  4.84k|    struct config_files **ctmp = &config_files;
  155|  4.84k|    struct config_line  **ltmp;
  156|  4.84k|    const char           *type = type_param;
  157|       |
  158|  4.84k|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (158:9): [True: 94, False: 4.74k]
  |  Branch (158:25): [True: 94, False: 4.65k]
  ------------------
  159|    188|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|    188|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  160|    188|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|    188|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  161|    188|    }
  162|       |
  163|       |    /*
  164|       |     * Handle multiple types (recursively)
  165|       |     */
  166|  4.84k|    if (strchr(type, ':')) {
  ------------------
  |  Branch (166:9): [True: 94, False: 4.74k]
  ------------------
  167|     94|        struct config_line *ltmp2 = NULL;
  168|     94|        char                buf[STRINGMAX];
  169|     94|        char               *cptr = buf;
  170|       |
  171|     94|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|     94|#define STRINGMAX 1024
  ------------------
  172|    282|        while (cptr) {
  ------------------
  |  Branch (172:16): [True: 188, False: 94]
  ------------------
  173|    188|            char* c = cptr;
  174|    188|            cptr = strchr(cptr, ':');
  175|    188|            if(cptr) {
  ------------------
  |  Branch (175:16): [True: 94, False: 94]
  ------------------
  176|     94|                *cptr = '\0';
  177|     94|                ++cptr;
  178|     94|            }
  179|    188|            ltmp2 = internal_register_config_handler(c, token, parser1, parser2,
  180|    188|                                                     releaser, help, when);
  181|    188|        }
  182|     94|        return ltmp2;
  183|     94|    }
  184|       |    
  185|       |    /*
  186|       |     * Find type in current list  -OR-  create a new file type.
  187|       |     */
  188|  5.54k|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (188:12): [True: 5.45k, False: 94]
  |  Branch (188:29): [True: 799, False: 4.65k]
  ------------------
  189|    799|        ctmp = &((*ctmp)->next);
  190|    799|    }
  191|       |
  192|  4.74k|    if (*ctmp == NULL) {
  ------------------
  |  Branch (192:9): [True: 94, False: 4.65k]
  ------------------
  193|     94|        *ctmp = (struct config_files *)
  194|     94|            calloc(1, sizeof(struct config_files));
  195|     94|        if (!*ctmp) {
  ------------------
  |  Branch (195:13): [True: 0, False: 94]
  ------------------
  196|      0|            return NULL;
  197|      0|        }
  198|       |
  199|     94|        (*ctmp)->fileHeader = strdup(type);
  200|     94|        if (!(*ctmp)->fileHeader) {
  ------------------
  |  Branch (200:13): [True: 0, False: 94]
  ------------------
  201|      0|            free(*ctmp);
  202|      0|            *ctmp = NULL;
  203|      0|            return NULL;
  204|      0|        }
  205|     94|        DEBUGMSGTL(("9:read_config:type", "new type %s\n", type));
  ------------------
  |  |   66|     94|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     94|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 94]
  |  |  ------------------
  ------------------
  206|     94|    }
  207|       |
  208|  4.74k|    DEBUGMSGTL(("9:read_config:register_handler", "registering %s %s\n",
  ------------------
  |  |   66|  4.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  4.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%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.74k]
  |  |  ------------------
  ------------------
  209|  4.74k|                type, token));
  210|       |    /*
  211|       |     * Find parser type in current list  -OR-  create a new
  212|       |     * line parser entry.
  213|       |     */
  214|  4.74k|    ltmp = &((*ctmp)->start);
  215|       |
  216|   174k|    while (*ltmp != NULL && strcmp((*ltmp)->config_token, token)) {
  ------------------
  |  Branch (216:12): [True: 170k, False: 4.74k]
  |  Branch (216:29): [True: 170k, False: 0]
  ------------------
  217|   170k|        ltmp = &((*ltmp)->next);
  218|   170k|    }
  219|       |
  220|  4.74k|    if (*ltmp == NULL) {
  ------------------
  |  Branch (220:9): [True: 4.74k, False: 0]
  ------------------
  221|  4.74k|        *ltmp = (struct config_line *)
  222|  4.74k|            calloc(1, sizeof(struct config_line));
  223|  4.74k|        if (!*ltmp) {
  ------------------
  |  Branch (223:13): [True: 0, False: 4.74k]
  ------------------
  224|      0|            return NULL;
  225|      0|        }
  226|       |
  227|  4.74k|        (*ltmp)->config_time = when;
  228|  4.74k|        (*ltmp)->config_token = strdup(token);
  229|  4.74k|        if (!(*ltmp)->config_token) {
  ------------------
  |  Branch (229:13): [True: 0, False: 4.74k]
  ------------------
  230|      0|            free(*ltmp);
  231|      0|            *ltmp = NULL;
  232|      0|            return NULL;
  233|      0|        }
  234|       |
  235|  4.74k|        if (help != NULL)
  ------------------
  |  Branch (235:13): [True: 4.18k, False: 564]
  ------------------
  236|  4.18k|            (*ltmp)->help = strdup(help);
  237|  4.74k|    }
  238|       |
  239|       |    /*
  240|       |     * Add/Replace the parse/free functions for the given line type
  241|       |     * in the given file type.
  242|       |     */
  243|  4.74k|    (*ltmp)->parse_line1 = parser1;
  244|  4.74k|    (*ltmp)->parse_line2 = parser2;
  245|  4.74k|    (*ltmp)->free_func = releaser;
  246|       |
  247|  4.74k|    return (*ltmp);
  248|       |
  249|  4.74k|}                               /* end register_config_handler() */

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

netsnmp_sd_listen_fds:
   72|     47|int netsnmp_sd_listen_fds(int unset_environment) {
   73|       |
   74|     47|        int r, fd;
   75|     47|        const char *e;
   76|     47|        char *p = NULL;
   77|     47|        unsigned long l;
   78|       |
   79|     47|        if (!(e = getenv("LISTEN_PID"))) {
  ------------------
  |  Branch (79:13): [True: 47, False: 0]
  ------------------
   80|     47|                r = 0;
   81|     47|                goto finish;
   82|     47|        }
   83|       |
   84|     47|        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|     47|finish:
  141|     47|        if (unset_environment) {
  ------------------
  |  Branch (141:13): [True: 0, False: 47]
  ------------------
  142|      0|                unsetenv("LISTEN_PID");
  143|      0|                unsetenv("LISTEN_FDS");
  144|      0|        }
  145|       |
  146|     47|        return r;
  147|      0|}
netsnmp_sd_find_inet_socket:
  356|     47|{
  357|     47|    int count, fd;
  358|       |
  359|     47|    count = netsnmp_sd_listen_fds(0);
  360|     47|    if (count <= 0) {
  ------------------
  |  Branch (360:9): [True: 47, False: 0]
  ------------------
  361|     47|        DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  362|     47|        return -1;
  363|     47|    }
  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|}

snmp_realloc_rbuild_var_op:
  327|     20|{
  328|     20|    size_t          start_offset = *offset;
  329|     20|    int             rc = 0;
  330|       |
  331|       |    /*
  332|       |     * Encode the value.  
  333|       |     */
  334|     20|    DEBUGDUMPHEADER("send", "Value");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
  335|       |
  336|     20|    switch (var_val_type) {
  337|      0|    case ASN_INTEGER:
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (337:5): [True: 0, False: 20]
  ------------------
  338|      0|        rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, allow_realloc,
  339|      0|                                    var_val_type, (long *) var_val,
  340|      0|                                    var_val_len);
  341|      0|        break;
  342|       |
  343|      0|    case ASN_GAUGE:
  ------------------
  |  |   90|      0|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (343:5): [True: 0, False: 20]
  ------------------
  344|     20|    case ASN_COUNTER:
  ------------------
  |  |   89|     20|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (344:5): [True: 20, False: 0]
  ------------------
  345|     20|    case ASN_TIMETICKS:
  ------------------
  |  |   92|     20|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (345:5): [True: 0, False: 20]
  ------------------
  346|     20|    case ASN_UINTEGER:
  ------------------
  |  |  100|     20|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (346:5): [True: 0, False: 20]
  ------------------
  347|     20|        rc = asn_realloc_rbuild_unsigned_int(pkt, pkt_len, offset,
  348|     20|                                             allow_realloc, var_val_type,
  349|     20|                                             (u_long *) var_val,
  350|     20|                                             var_val_len);
  351|     20|        break;
  352|       |
  353|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
  354|      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 (354:5): [True: 0, False: 20]
  ------------------
  355|      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 (355:5): [True: 0, False: 20]
  ------------------
  356|      0|#endif
  357|      0|    case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (357:5): [True: 0, False: 20]
  ------------------
  358|      0|        rc = asn_realloc_rbuild_unsigned_int64(pkt, pkt_len, offset,
  359|      0|                                               allow_realloc, var_val_type,
  360|      0|                                               (struct counter64 *)
  361|      0|                                               var_val, var_val_len);
  362|      0|        break;
  363|       |
  364|      0|    case ASN_OCTET_STR:
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (364:5): [True: 0, False: 20]
  ------------------
  365|      0|    case ASN_IPADDRESS:
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (365:5): [True: 0, False: 20]
  ------------------
  366|      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 (366:5): [True: 0, False: 20]
  ------------------
  367|      0|    case ASN_NSAP:
  ------------------
  |  |   98|      0|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (367:5): [True: 0, False: 20]
  ------------------
  368|      0|        rc = asn_realloc_rbuild_string(pkt, pkt_len, offset, allow_realloc,
  369|      0|                                       var_val_type, var_val, var_val_len);
  370|      0|        break;
  371|       |
  372|      0|    case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (372:5): [True: 0, False: 20]
  ------------------
  373|      0|        rc = asn_realloc_rbuild_objid(pkt, pkt_len, offset, allow_realloc,
  374|      0|                                      var_val_type, (oid *) var_val,
  375|      0|                                      var_val_len / sizeof(oid));
  376|      0|        break;
  377|       |
  378|      0|    case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (378:5): [True: 0, False: 20]
  ------------------
  379|      0|        rc = asn_realloc_rbuild_null(pkt, pkt_len, offset, allow_realloc,
  380|      0|                                     var_val_type);
  381|      0|        break;
  382|       |
  383|      0|    case ASN_BIT_STR:
  ------------------
  |  |   77|      0|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (383:5): [True: 0, False: 20]
  ------------------
  384|      0|        rc = asn_realloc_rbuild_bitstring(pkt, pkt_len, offset,
  385|      0|                                          allow_realloc, var_val_type,
  386|      0|                                          var_val, var_val_len);
  387|      0|        break;
  388|       |
  389|      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 (389:5): [True: 0, False: 20]
  ------------------
  390|      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 (390:5): [True: 0, False: 20]
  ------------------
  391|      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 (391:5): [True: 0, False: 20]
  ------------------
  392|      0|        rc = asn_realloc_rbuild_null(pkt, pkt_len, offset, allow_realloc,
  393|      0|                                     var_val_type);
  394|      0|        break;
  395|       |
  396|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
  397|      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 (397:5): [True: 0, False: 20]
  ------------------
  398|      0|        rc = asn_realloc_rbuild_float(pkt, pkt_len, offset, allow_realloc,
  399|      0|                                      var_val_type, (float *) var_val,
  400|      0|                                      var_val_len);
  401|      0|        break;
  402|       |
  403|      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 (403:5): [True: 0, False: 20]
  ------------------
  404|      0|        rc = asn_realloc_rbuild_double(pkt, pkt_len, offset, allow_realloc,
  405|      0|                                       var_val_type, (double *) var_val,
  406|      0|                                       var_val_len);
  407|      0|        break;
  408|       |
  409|      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 (409:5): [True: 0, False: 20]
  ------------------
  410|      0|        rc = asn_realloc_rbuild_signed_int64(pkt, pkt_len, offset,
  411|      0|                                             allow_realloc, var_val_type,
  412|      0|                                             (struct counter64 *) var_val,
  413|      0|                                             var_val_len);
  414|      0|        break;
  415|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
  416|      0|    default:
  ------------------
  |  Branch (416:5): [True: 0, False: 20]
  ------------------
  417|      0|	{
  418|      0|	char error_buf[64];
  419|      0|	snprintf(error_buf, sizeof(error_buf),
  420|      0|		"wrong type in snmp_realloc_rbuild_var_op: %d", var_val_type);
  421|      0|        ERROR_MSG(error_buf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  422|      0|        rc = 0;
  423|      0|	}
  424|     20|    }
  425|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
  426|       |
  427|     20|    if (rc == 0) {
  ------------------
  |  Branch (427:9): [True: 0, False: 20]
  ------------------
  428|      0|        return 0;
  429|      0|    }
  430|       |
  431|       |    /*
  432|       |     * Build the OID.  
  433|       |     */
  434|       |
  435|     20|    DEBUGDUMPHEADER("send", "Name");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
  436|     20|    rc = asn_realloc_rbuild_objid(pkt, pkt_len, offset, allow_realloc,
  437|     20|                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
  438|     20|                                            ASN_OBJECT_ID), var_name,
  ------------------
  |  |   81|     20|#define ASN_OBJECT_ID	    0x06U
  ------------------
  439|     20|                                  *var_name_len);
  440|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
  441|     20|    if (rc == 0) {
  ------------------
  |  Branch (441:9): [True: 0, False: 20]
  ------------------
  442|      0|        ERROR_MSG("Can't build OID for variable");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  443|      0|        return 0;
  444|      0|    }
  445|       |
  446|       |    /*
  447|       |     * Build the sequence header.  
  448|       |     */
  449|       |
  450|     20|    rc = asn_realloc_rbuild_sequence(pkt, pkt_len, offset, allow_realloc,
  451|     20|                                     (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|     20|#define ASN_SEQUENCE	    0x10U
  ------------------
  452|     20|                                               ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  453|     20|                                     *offset - start_offset);
  454|     20|    return rc;
  455|     20|}

init_alarm_post_config:
   63|     47|{
   64|     47|    start_alarms = 1;
   65|     47|    set_an_alarm();
   66|     47|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
   67|     47|}
init_snmp_alarm:
   71|     47|{
   72|     47|    start_alarms = 0;
   73|     47|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   74|     47|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|     47|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
   75|       |                           init_alarm_post_config, NULL);
   76|     47|}
snmp_alarm_unregister_all:
  156|     47|{
  157|     47|  struct snmp_alarm *sa_ptr, *sa_tmp;
  158|       |
  159|     47|  for (sa_ptr = thealarms; sa_ptr != NULL; sa_ptr = sa_tmp) {
  ------------------
  |  Branch (159:28): [True: 0, False: 47]
  ------------------
  160|      0|    sa_tmp = sa_ptr->next;
  161|      0|    free(sa_ptr);
  162|      0|  }
  163|     47|  DEBUGMSGTL(("snmp_alarm", "ALL alarms unregistered\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  164|       |  thealarms = NULL;
  165|     47|}  
sa_find_next:
  169|     47|{
  170|     47|    struct snmp_alarm *a, *lowest = NULL;
  171|       |
  172|     47|    for (a = thealarms; a != NULL; a = a->next)
  ------------------
  |  Branch (172:25): [True: 0, False: 47]
  ------------------
  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|     47|    return lowest;
  178|     47|}
netsnmp_get_next_alarm_time:
  253|     47|{
  254|     47|    struct snmp_alarm *sa_ptr;
  255|       |
  256|     47|    sa_ptr = sa_find_next();
  257|       |
  258|     47|    if (sa_ptr) {
  ------------------
  |  Branch (258:9): [True: 0, False: 47]
  ------------------
  259|      0|        netsnmp_assert(alarm_tm);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  260|      0|        netsnmp_assert(timerisset(&sa_ptr->t_nextM));
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  261|      0|        if (timercmp(&sa_ptr->t_nextM, now, >))
  ------------------
  |  Branch (261:13): [True: 0, False: 0]
  |  Branch (261:13): [True: 0, False: 0]
  ------------------
  262|      0|            *alarm_tm = sa_ptr->t_nextM;
  263|      0|        else
  264|      0|            *alarm_tm = *now;
  265|      0|        return sa_ptr->clientreg;
  266|     47|    } else {
  267|     47|        return 0;
  268|     47|    }
  269|     47|}
get_next_alarm_delay_time:
  282|     47|{
  283|     47|    struct timeval t_now, alarm_tm;
  284|     47|    int res;
  285|       |
  286|     47|    netsnmp_get_monotonic_clock(&t_now);
  287|     47|    res = netsnmp_get_next_alarm_time(&alarm_tm, &t_now);
  288|     47|    if (res)
  ------------------
  |  Branch (288:9): [True: 0, False: 47]
  ------------------
  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|     47|    return res;
  291|     47|}
set_an_alarm:
  296|     47|{
  297|     47|    struct timeval  delta;
  298|     47|    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|     47|    if (nextalarm && !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (306:9): [True: 0, False: 47]
  |  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|     47|    } else {
  326|     47|        DEBUGMSGTL(("snmp_alarm", "no alarms found to schedule\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  327|     47|    }
  328|     47|}

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|     47|{
  487|     47|    long            retVal;
  488|     47|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   79|     47|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 47]
  |  |  ------------------
  ------------------
  489|     47|    retVal = 1 + Sessid;        /*MTCRITICAL_RESOURCE */
  490|     47|    if (!retVal)
  ------------------
  |  Branch (490:9): [True: 0, False: 47]
  ------------------
  491|      0|        retVal = 2;
  492|     47|    Sessid = retVal;
  493|     47|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|     47|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (493:9): [True: 0, False: 47]
  ------------------
  494|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  495|     47|    else
  496|     47|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  497|       |
  498|     47|    if (!retVal) {
  ------------------
  |  Branch (498:9): [True: 0, False: 47]
  ------------------
  499|      0|        Sessid = retVal = 2;
  500|      0|    }
  501|     47|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   80|     47|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 47]
  |  |  ------------------
  ------------------
  502|     47|    return retVal;
  503|     47|}
snmp_get_next_transid:
  507|    183|{
  508|    183|    long            retVal;
  509|    183|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   79|    183|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 183]
  |  |  ------------------
  ------------------
  510|    183|    retVal = 1 + Transid;       /*MTCRITICAL_RESOURCE */
  511|    183|    if (!retVal)
  ------------------
  |  Branch (511:9): [True: 0, False: 183]
  ------------------
  512|      0|        retVal = 2;
  513|    183|    Transid = retVal;
  514|    183|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|    183|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|    183|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (514:9): [True: 0, False: 183]
  ------------------
  515|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  516|    183|    else
  517|    183|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  518|       |
  519|    183|    if (!retVal) {
  ------------------
  |  Branch (519:9): [True: 0, False: 183]
  ------------------
  520|      0|        Transid = retVal = 2;
  521|      0|    }
  522|    183|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   80|    183|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 183]
  |  |  ------------------
  ------------------
  523|    183|    return retVal;
  524|    183|}
snmp_set_detail:
  538|    367|{
  539|    367|    if (detail_string != NULL) {
  ------------------
  |  Branch (539:9): [True: 367, False: 0]
  ------------------
  540|    367|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  541|    367|        snmp_detail_f = 1;
  542|    367|    }
  543|    367|}
netsnmp_random:
  661|    141|{
  662|    141|#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|    141|    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|    141|}
netsnmp_srandom:
  694|     47|{
  695|     47|#if defined(HAVE_SRANDOM)
  696|     47|    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|     47|}
snmp_sess_init:
  797|     47|{
  798|     47|    _init_snmp();
  799|       |
  800|       |    /*
  801|       |     * initialize session to default values 
  802|       |     */
  803|       |
  804|     47|    memset(session, 0, sizeof(netsnmp_session));
  805|     47|    session->timeout = SNMP_DEFAULT_TIMEOUT;
  ------------------
  |  |   80|     47|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  806|     47|    session->retries = SNMP_DEFAULT_RETRIES;
  ------------------
  |  |   79|     47|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  807|     47|    session->version = SNMP_DEFAULT_VERSION;
  ------------------
  |  |   90|     47|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  808|     47|    session->securityModel = SNMP_DEFAULT_SECMODEL;
  ------------------
  |  |   91|     47|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  809|     47|    session->rcvMsgMaxSize = netsnmp_max_send_msg_size();
  810|     47|    session->sndMsgMaxSize = netsnmp_max_send_msg_size();
  811|     47|    session->flags |= SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     47|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
  812|     47|}
init_snmp:
  901|     47|{
  902|     47|    if (init_snmp_init_done) {
  ------------------
  |  Branch (902:9): [True: 0, False: 47]
  ------------------
  903|      0|        return;
  904|      0|    }
  905|       |
  906|     47|    init_snmp_init_done = 1;
  907|       |
  908|       |    /*
  909|       |     * make the type available everywhere else 
  910|       |     */
  911|     47|    if (type && !netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (911:9): [True: 47, False: 0]
  |  Branch (911:17): [True: 47, False: 0]
  ------------------
  912|     47|				       NETSNMP_DS_LIB_APPTYPE)) {
  ------------------
  |  |  157|     47|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  913|     47|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  914|     47|			      NETSNMP_DS_LIB_APPTYPE, type);
  ------------------
  |  |  157|     47|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  915|     47|    }
  916|       |
  917|     47|    _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|     47|#if defined(HAVE_SETLOCALE) && !defined(__QNX__)
  926|     47|    setlocale(LC_CTYPE, "");
  927|     47|#endif
  928|       |
  929|     47|    snmp_debug_init();    /* should be done first, to turn on debugging ASAP */
  930|     47|    netsnmp_container_init_list();
  931|     47|    init_callbacks();
  932|     47|    init_snmp_logging();
  933|     47|    snmp_init_statistics();
  934|     47|    register_mib_handlers();
  935|     47|    register_default_handlers();
  936|     47|    init_snmp_transport();
  937|     47|    init_snmpv3(type);
  938|     47|    init_snmp_alarm();
  939|     47|    init_snmp_enum(type);
  940|     47|    init_vacm();
  941|     47|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
  942|     47|    netsnmp_certs_init();
  943|     47|#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|     47|    read_premib_configs();
  951|     47|#ifndef NETSNMP_DISABLE_MIB_LOADING
  952|     47|    netsnmp_init_mib();
  953|     47|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  954|       |
  955|     47|    read_configs();
  956|       |
  957|     47|}                               /* end init_snmp() */
snmp_store:
  983|     47|{
  984|     47|    DEBUGMSGTL(("snmp_store", "storing stuff...\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  985|     47|    snmp_save_persistent(type);
  986|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, NULL);
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, NULL);
  ------------------
  |  |   25|     47|#define SNMP_CALLBACK_STORE_DATA	        1
  ------------------
  987|     47|    snmp_clean_persistent(type);
  988|     47|}
snmp_shutdown:
 1001|     47|{
 1002|     47|    snmp_store(type);
 1003|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN, NULL);
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN, NULL);
  ------------------
  |  |   26|     47|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 1004|     47|    shutdown_snmp_logging();
 1005|     47|    snmp_alarm_unregister_all();
 1006|     47|    netsnmp_query_shutdown();
 1007|     47|    snmp_close_sessions();
 1008|     47|#ifndef NETSNMP_DISABLE_MIB_LOADING
 1009|     47|    shutdown_mib();
 1010|     47|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 1011|     47|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
 1012|     47|    netsnmp_certs_shutdown();
 1013|     47|#endif
 1014|     47|#if !defined(NETSNMP_FEATURE_REMOVE_FILTER_SOURCE)
 1015|     47|    netsnmp_transport_filter_cleanup();
 1016|     47|#endif
 1017|     47|    unregister_all_config_handlers();
 1018|     47|    netsnmp_container_free_list();
 1019|     47|    clear_sec_mod();
 1020|     47|    clear_snmp_enum();
 1021|     47|    netsnmp_clear_tdomain_list();
 1022|     47|    clear_callback();
 1023|     47|    netsnmp_ds_shutdown();
 1024|     47|    netsnmp_clear_default_target();
 1025|     47|    netsnmp_clear_default_domain();
 1026|     47|    shutdown_secmod();
 1027|     47|    shutdown_snmp_transport();
 1028|     47|    shutdown_data_list();
 1029|     47|    snmp_debug_shutdown();    /* should be done last */
 1030|       |
 1031|     47|    init_snmp_init_done  = 0;
 1032|     47|    _init_snmp_init_done = 0;
 1033|     47|}
snmp_session_insert:
 1039|     47|{
 1040|     47|    if (NULL == slp)
  ------------------
  |  Branch (1040:9): [True: 0, False: 47]
  ------------------
 1041|      0|        return;
 1042|       |
 1043|     47|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     47|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1044|     47|    slp->next = Sessions;
 1045|     47|    Sessions = slp;
 1046|     47|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     47|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1047|     47|}
netsnmp_sess_config_transport:
 1627|     47|{
 1628|       |    /* Optional supplemental transport configuration information and
 1629|       |       final call to actually open the transport */
 1630|     47|    if (transport_configuration) {
  ------------------
  |  Branch (1630:9): [True: 0, False: 47]
  ------------------
 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|     47|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1657|     47|}
netsnmp_sess_config_and_open_transport:
 1689|     47|{
 1690|     47|    int rc;
 1691|       |    
 1692|     47|    DEBUGMSGTL(("snmp_sess", "opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1693|       |
 1694|       |    /* don't double open */
 1695|     47|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED)
  ------------------
  |  |   57|     47|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
  |  Branch (1695:9): [True: 0, False: 47]
  ------------------
 1696|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1697|       |
 1698|     47|    if ((rc = netsnmp_sess_config_transport(in_session->transport_configuration,
  ------------------
  |  Branch (1698:9): [True: 0, False: 47]
  ------------------
 1699|     47|                                            transport)) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#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|     47|    if (transport->f_open)
  ------------------
  |  Branch (1705:9): [True: 0, False: 47]
  ------------------
 1706|      0|        transport = transport->f_open(transport);
 1707|       |
 1708|     47|    if (transport == NULL) {
  ------------------
  |  Branch (1708:9): [True: 0, False: 47]
  ------------------
 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|     47|    if (in_session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1717:9): [True: 47, False: 0]
  ------------------
 1718|     47|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1719|     47|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1720|     47|                    in_session->rcvMsgMaxSize, transport->msgMaxSize));
 1721|     47|        in_session->rcvMsgMaxSize = transport->msgMaxSize;
 1722|     47|    }
 1723|       |
 1724|     47|    if (in_session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1724:9): [True: 47, False: 0]
  ------------------
 1725|     47|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1726|     47|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1727|     47|                    in_session->sndMsgMaxSize, transport->msgMaxSize));
 1728|     47|        in_session->sndMsgMaxSize = transport->msgMaxSize;
 1729|     47|    }
 1730|       |
 1731|     47|    transport->flags |= NETSNMP_TRANSPORT_FLAG_OPENED;
  ------------------
  |  |   57|     47|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
 1732|     47|    DEBUGMSGTL(("snmp_sess", "done opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1733|     47|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1734|     47|}
snmp_add:
 1848|     47|{
 1849|     47|    struct session_list *slp;
 1850|       |
 1851|     47|    slp = snmp_sess_add_ex(in_session, transport, fpre_parse, NULL,
 1852|     47|                           fpost_parse, NULL, NULL, NULL, NULL);
 1853|     47|    if (slp == NULL) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 47]
  ------------------
 1854|      0|        return NULL;
 1855|      0|    }
 1856|       |
 1857|     47|    snmp_session_insert(slp);
 1858|       |
 1859|     47|    return (slp->session);
 1860|     47|}
snmp_sess_add_ex:
 1909|     47|{
 1910|     47|    struct session_list *slp;
 1911|     47|    int rc;
 1912|       |    
 1913|     47|    _init_snmp();
 1914|       |
 1915|     47|    if (transport == NULL)
  ------------------
  |  Branch (1915:9): [True: 0, False: 47]
  ------------------
 1916|      0|        return NULL;
 1917|       |
 1918|     47|    if (NULL != in_session && (in_session->rcvMsgMaxSize < SNMP_MIN_MAX_LEN ||
  ------------------
  |  |   48|     94|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1918:9): [True: 47, False: 0]
  |  Branch (1918:32): [True: 0, False: 47]
  ------------------
 1919|     47|                               in_session->sndMsgMaxSize < SNMP_MIN_MAX_LEN)) {
  ------------------
  |  |   48|     47|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1919:32): [True: 0, False: 47]
  ------------------
 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|     47|    if (in_session == NULL) {
  ------------------
  |  Branch (1925:9): [True: 0, False: 47]
  ------------------
 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|     47|    if ((rc = netsnmp_sess_config_and_open_transport(in_session, transport))
  ------------------
  |  Branch (1932:9): [True: 0, False: 47]
  ------------------
 1933|     47|        != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1934|      0|        return NULL;
 1935|      0|    }
 1936|       |
 1937|     47|    DEBUGMSGTL(("snmp_sess_add", "fd %" NETSNMP_FMT_SKT "\n",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 1938|     47|                transport->sock));
 1939|       |
 1940|     47|    if ((slp = snmp_sess_copy(in_session)) == NULL) {
  ------------------
  |  Branch (1940:9): [True: 0, False: 47]
  ------------------
 1941|      0|        transport->f_close(transport);
 1942|      0|        netsnmp_transport_free(transport);
 1943|      0|        return (NULL);
 1944|      0|    }
 1945|       |
 1946|     47|    slp->transport = transport;
 1947|     47|    slp->internal->hook_pre = fpre_parse;
 1948|     47|    slp->internal->hook_parse = fparse;
 1949|     47|    slp->internal->hook_post = fpost_parse;
 1950|     47|    slp->internal->hook_build = fbuild;
 1951|     47|    slp->internal->hook_realloc_build = frbuild;
 1952|     47|    slp->internal->check_packet = fcheck;
 1953|     47|    slp->internal->hook_create_pdu = fcreate_pdu;
 1954|       |
 1955|       |    /** don't let session max exceed transport max */
 1956|     47|    if (slp->session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1956:9): [True: 0, False: 47]
  ------------------
 1957|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1958|      0|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1959|      0|                    slp->session->rcvMsgMaxSize, transport->msgMaxSize));
 1960|      0|        slp->session->rcvMsgMaxSize = transport->msgMaxSize;
 1961|      0|    }
 1962|     47|    if (slp->session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1962:9): [True: 0, False: 47]
  ------------------
 1963|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1964|      0|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1965|      0|                    slp->session->sndMsgMaxSize, transport->msgMaxSize));
 1966|      0|        slp->session->sndMsgMaxSize = transport->msgMaxSize;
 1967|      0|    }
 1968|       |
 1969|     47|    if (transport->f_setup_session &&
  ------------------
  |  Branch (1969:9): [True: 47, False: 0]
  ------------------
 1970|     47|        transport->f_setup_session(transport, slp->session) != SNMPERR_SUCCESS)
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1970:9): [True: 0, False: 47]
  ------------------
 1971|      0|        goto close_session;
 1972|       |
 1973|       |    /* Anything below this point should only be done if the transport
 1974|       |       had no say in the matter */
 1975|     47|    if (slp->session->securityLevel == 0)
  ------------------
  |  Branch (1975:9): [True: 47, False: 0]
  ------------------
 1976|     47|        slp->session->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|     47|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 1977|       |
 1978|     47|    if (slp->session->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|     47|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (1978:9): [True: 0, False: 47]
  ------------------
 1979|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1980|      0|                    "adding v3 session -- maybe engineID probe now\n"));
 1981|      0|        if (!snmpv3_engineID_probe(slp, slp->session)) {
  ------------------
  |  Branch (1981:13): [True: 0, False: 0]
  ------------------
 1982|      0|            DEBUGMSGTL(("snmp_sess_add", "engine ID probe failed\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1983|      0|            goto close_session;
 1984|      0|        }
 1985|      0|    }
 1986|       |
 1987|     47|    slp->session->flags &= ~SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     47|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
 1988|       |
 1989|     47|    return slp;
 1990|       |
 1991|      0|close_session:
 1992|      0|    snmp_sess_close(slp);
 1993|       |    return NULL;
 1994|     47|}                               /*  end snmp_sess_add_ex()  */
netsnmp_cleanup_session:
 2054|     47|{
 2055|     47|    free(s->localname);
 2056|     47|    free(s->peername);
 2057|     47|    free(s->community);
 2058|     47|    free(s->contextEngineID);
 2059|     47|    free(s->contextName);
 2060|     47|    free(s->securityEngineID);
 2061|     47|    free(s->securityName);
 2062|     47|    free(s->securityAuthProto);
 2063|     47|    free(s->securityAuthLocalKey);
 2064|     47|    free(s->securityPrivProto);
 2065|     47|    free(s->securityPrivLocalKey);
 2066|     47|    free(s->paramName);
 2067|     47|#ifndef NETSNMP_NO_TRAP_STATS
 2068|     47|    free(s->trap_stats);
 2069|     47|#endif /* NETSNMP_NO_TRAP_STATS */
 2070|     47|    usm_free_user(s->sessUser);
 2071|     47|    netsnmp_free_transport_config(s->transport_configuration);
 2072|     47|    memset(s, 0, sizeof(*s));
 2073|     47|}
snmp_sess_close:
 2104|     47|{
 2105|     47|    netsnmp_transport *transport;
 2106|     47|    struct snmp_internal_session *isp;
 2107|     47|    netsnmp_session *sesp = NULL;
 2108|     47|    struct snmp_secmod_def *sptr;
 2109|       |
 2110|     47|    if (slp == NULL) {
  ------------------
  |  Branch (2110:9): [True: 0, False: 47]
  ------------------
 2111|      0|        return 0;
 2112|      0|    }
 2113|       |
 2114|     47|    if (slp->session != NULL &&
  ------------------
  |  Branch (2114:9): [True: 47, False: 0]
  ------------------
 2115|     47|        (sptr = find_sec_mod(slp->session->securityModel)) != NULL &&
  ------------------
  |  Branch (2115:9): [True: 47, False: 0]
  ------------------
 2116|     47|        sptr->session_close != NULL) {
  ------------------
  |  Branch (2116:9): [True: 0, False: 47]
  ------------------
 2117|      0|        (*sptr->session_close) (slp->session);
 2118|      0|    }
 2119|       |
 2120|     47|    isp = slp->internal;
 2121|     47|    slp->internal = NULL;
 2122|       |
 2123|     47|    if (isp) {
  ------------------
  |  Branch (2123:9): [True: 47, False: 0]
  ------------------
 2124|     47|        netsnmp_request_list *rp, *orp;
 2125|       |
 2126|     47|        SNMP_FREE(isp->packet);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 47]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2127|       |
 2128|       |        /*
 2129|       |         * Free each element in the input request list.  
 2130|       |         */
 2131|     47|        rp = isp->requests;
 2132|     47|        while (rp) {
  ------------------
  |  Branch (2132:16): [True: 0, False: 47]
  ------------------
 2133|      0|            orp = rp;
 2134|      0|            rp = rp->next_request;
 2135|      0|            if (orp->callback) {
  ------------------
  |  Branch (2135:17): [True: 0, False: 0]
  ------------------
 2136|      0|                orp->callback(NETSNMP_CALLBACK_OP_TIMED_OUT,
  ------------------
  |  |  320|      0|#define NETSNMP_CALLBACK_OP_TIMED_OUT		2
  ------------------
 2137|      0|                              slp->session, orp->pdu->reqid,
 2138|      0|                              orp->pdu, orp->cb_data);
 2139|      0|            }
 2140|      0|            remove_request(isp, NULL, orp);
 2141|      0|            free(orp);
 2142|      0|        }
 2143|       |
 2144|     47|        free(isp);
 2145|     47|    }
 2146|       |
 2147|     47|    transport = slp->transport;
 2148|     47|    slp->transport = NULL;
 2149|       |
 2150|     47|    if (transport) {
  ------------------
  |  Branch (2150:9): [True: 47, False: 0]
  ------------------
 2151|     47|        transport->f_close(transport);
 2152|     47|        netsnmp_transport_free(transport);
 2153|     47|    }
 2154|       |
 2155|     47|    sesp = slp->session;
 2156|     47|    slp->session = NULL;
 2157|       |
 2158|       |    /*
 2159|       |     * The following is necessary to avoid memory leakage when closing AgentX 
 2160|       |     * sessions that may have multiple subsessions.  These hang off the main
 2161|       |     * session at ->subsession, and chain through ->next.  
 2162|       |     */
 2163|       |
 2164|     47|    if (sesp != NULL && sesp->subsession != NULL) {
  ------------------
  |  Branch (2164:9): [True: 47, False: 0]
  |  Branch (2164:25): [True: 0, False: 47]
  ------------------
 2165|      0|        netsnmp_session *subsession = sesp->subsession, *tmpsub;
 2166|       |
 2167|      0|        while (subsession != NULL) {
  ------------------
  |  Branch (2167:16): [True: 0, False: 0]
  ------------------
 2168|      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]
  |  |  ------------------
  ------------------
 2169|      0|                        "closing session %p, subsession %p\n", sesp,
 2170|      0|                        subsession));
 2171|      0|            tmpsub = subsession->next;
 2172|      0|            snmp_free_session(subsession);
 2173|      0|            subsession = tmpsub;
 2174|      0|        }
 2175|      0|    }
 2176|       |
 2177|     47|    snmp_free_session(sesp);
 2178|     47|    free(slp);
 2179|     47|    return 1;
 2180|     47|}
snmp_close:
 2184|     47|{
 2185|     47|    struct session_list *slp = NULL, *oslp = NULL;
 2186|       |
 2187|     47|    {                           /*MTCRITICAL_RESOURCE */
 2188|     47|        snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     47|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2189|     47|        if (Sessions && Sessions->session == session) { /* If first entry */
  ------------------
  |  Branch (2189:13): [True: 0, False: 47]
  |  Branch (2189:25): [True: 0, False: 0]
  ------------------
 2190|      0|            slp = Sessions;
 2191|      0|            Sessions = slp->next;
 2192|     47|        } else {
 2193|     47|            for (slp = Sessions; slp; slp = slp->next) {
  ------------------
  |  Branch (2193:34): [True: 0, False: 47]
  ------------------
 2194|      0|                if (slp->session == session) {
  ------------------
  |  Branch (2194:21): [True: 0, False: 0]
  ------------------
 2195|      0|                    if (oslp)   /* if we found entry that points here */
  ------------------
  |  Branch (2195:25): [True: 0, False: 0]
  ------------------
 2196|      0|                        oslp->next = slp->next; /* link around this entry */
 2197|      0|                    break;
 2198|      0|                }
 2199|      0|                oslp = slp;
 2200|      0|            }
 2201|     47|        }
 2202|     47|        snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     47|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2203|     47|    }                           /*END MTCRITICAL_RESOURCE */
 2204|     47|    if (slp == NULL) {
  ------------------
  |  Branch (2204:9): [True: 47, False: 0]
  ------------------
 2205|     47|        return 0;
 2206|     47|    }
 2207|      0|    return snmp_sess_close(slp);
 2208|     47|}
snmp_close_sessions:
 2212|     47|{
 2213|     47|    struct session_list *slp;
 2214|       |
 2215|     47|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     47|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2216|     94|    while (Sessions) {
  ------------------
  |  Branch (2216:12): [True: 47, False: 47]
  ------------------
 2217|     47|        slp = Sessions;
 2218|     47|        Sessions = Sessions->next;
 2219|     47|        snmp_sess_close(slp);
 2220|     47|    }
 2221|     47|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     47|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 47]
  |  |  ------------------
  ------------------
 2222|     47|    return 1;
 2223|     47|}
snmpv3_header_realloc_rbuild:
 2588|     20|{
 2589|     20|    size_t          start_offset = *offset;
 2590|     20|    u_char          msg_flags;
 2591|     20|    long            max_size, sec_model;
 2592|     20|    int             rc = 0;
 2593|       |
 2594|       |    /*
 2595|       |     * msgSecurityModel.  
 2596|       |     */
 2597|     20|    sec_model = pdu->securityModel;
 2598|     20|    DEBUGDUMPHEADER("send", "msgSecurityModel");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2599|     20|    rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 2600|     20|                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                              (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2601|     20|                                          ASN_INTEGER), &sec_model,
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 2602|     20|                                sizeof(sec_model));
 2603|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2604|     20|    if (rc == 0) {
  ------------------
  |  Branch (2604:9): [True: 0, False: 20]
  ------------------
 2605|      0|        return 0;
 2606|      0|    }
 2607|       |
 2608|       |    /*
 2609|       |     * msgFlags.  
 2610|       |     */
 2611|     20|    snmpv3_calc_msg_flags(pdu->securityLevel, pdu->command, &msg_flags);
 2612|     20|    DEBUGDUMPHEADER("send", "msgFlags");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2613|     20|    rc = asn_realloc_rbuild_string(pkt, pkt_len, offset, 1,
 2614|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2615|     20|                                             | ASN_OCTET_STR), &msg_flags,
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2616|     20|                                   sizeof(msg_flags));
 2617|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2618|     20|    if (rc == 0) {
  ------------------
  |  Branch (2618:9): [True: 0, False: 20]
  ------------------
 2619|      0|        return 0;
 2620|      0|    }
 2621|       |
 2622|       |    /*
 2623|       |     * msgMaxSize.  
 2624|       |     */
 2625|     20|    max_size = netsnmp_max_send_msg_size();
 2626|     20|    if (session->rcvMsgMaxSize < max_size)
  ------------------
  |  Branch (2626:9): [True: 20, False: 0]
  ------------------
 2627|     20|        max_size = session->rcvMsgMaxSize;
 2628|     20|    DEBUGDUMPHEADER("send:msgMaxSize2", "msgMaxSize");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2629|     20|    rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 2630|     20|                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                              (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2631|     20|                                          ASN_INTEGER), &max_size,
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 2632|     20|                                sizeof(max_size));
 2633|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2634|     20|    if (rc == 0) {
  ------------------
  |  Branch (2634:9): [True: 0, False: 20]
  ------------------
 2635|      0|        return 0;
 2636|      0|    }
 2637|       |
 2638|       |    /*
 2639|       |     * msgID.  
 2640|       |     */
 2641|     20|    DEBUGDUMPHEADER("send", "msgID");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2642|     20|    rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 2643|     20|                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                              (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2644|     20|                                          ASN_INTEGER), &pdu->msgid,
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 2645|     20|                                sizeof(pdu->msgid));
 2646|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2647|     20|    if (rc == 0) {
  ------------------
  |  Branch (2647:9): [True: 0, False: 20]
  ------------------
 2648|      0|        return 0;
 2649|      0|    }
 2650|       |
 2651|       |    /*
 2652|       |     * Global data sequence.  
 2653|       |     */
 2654|     20|    rc = asn_realloc_rbuild_sequence(pkt, pkt_len, offset, 1,
 2655|     20|                                     (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|     20|#define ASN_SEQUENCE	    0x10U
  ------------------
 2656|     20|                                               ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2657|     20|                                     *offset - start_offset);
 2658|     20|    if (rc == 0) {
  ------------------
  |  Branch (2658:9): [True: 0, False: 20]
  ------------------
 2659|      0|        return 0;
 2660|      0|    }
 2661|       |
 2662|       |    /*
 2663|       |     * Store the version field - msgVersion.  
 2664|       |     */
 2665|     20|    DEBUGDUMPHEADER("send", "SNMP Version Number");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2666|     20|    rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 2667|     20|                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                              (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2668|     20|                                          ASN_INTEGER),
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 2669|     20|                                (long *) &pdu->version,
 2670|     20|                                sizeof(pdu->version));
 2671|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2672|     20|    return rc;
 2673|     20|}                               /* end snmpv3_header_realloc_rbuild() */
snmpv3_scopedPDU_header_realloc_rbuild:
 2718|     20|{
 2719|     20|    size_t          start_offset = *offset;
 2720|     20|    int             rc = 0;
 2721|       |
 2722|       |    /*
 2723|       |     * contextName.  
 2724|       |     */
 2725|     20|    DEBUGDUMPHEADER("send", "contextName");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2726|     20|    rc = asn_realloc_rbuild_string(pkt, pkt_len, offset, 1,
 2727|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2728|     20|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2729|     20|                                   (u_char *) pdu->contextName,
 2730|     20|                                   pdu->contextNameLen);
 2731|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2732|     20|    if (rc == 0) {
  ------------------
  |  Branch (2732:9): [True: 0, False: 20]
  ------------------
 2733|      0|        return 0;
 2734|      0|    }
 2735|       |
 2736|       |    /*
 2737|       |     * contextEngineID.  
 2738|       |     */
 2739|     20|    DEBUGDUMPHEADER("send", "contextEngineID");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2740|     20|    rc = asn_realloc_rbuild_string(pkt, pkt_len, offset, 1,
 2741|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2742|     20|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2743|     20|                                   pdu->contextEngineID,
 2744|     20|                                   pdu->contextEngineIDLen);
 2745|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2746|     20|    if (rc == 0) {
  ------------------
  |  Branch (2746:9): [True: 0, False: 20]
  ------------------
 2747|      0|        return 0;
 2748|      0|    }
 2749|       |
 2750|     20|    rc = asn_realloc_rbuild_sequence(pkt, pkt_len, offset, 1,
 2751|     20|                                     (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|     20|#define ASN_SEQUENCE	    0x10U
  ------------------
 2752|     20|                                               ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2753|     20|                                     *offset - start_offset + body_len);
 2754|       |
 2755|     20|    return rc;
 2756|     20|}                               /* end snmpv3_scopedPDU_header_realloc_rbuild() */
snmpv3_packet_realloc_rbuild:
 2768|     20|{
 2769|     20|    u_char         *scoped_pdu, *hdrbuf = NULL, *hdr = NULL;
 2770|     20|    size_t          hdrbuf_len = SNMP_MAX_MSG_V3_HDRS, hdr_offset =
  ------------------
  |  |  110|     20|#define SNMP_MAX_MSG_V3_HDRS       (4+3+4+7+7+3+7+16)   /* fudge factor=16 */
  ------------------
 2771|     20|        0, spdu_offset = 0;
 2772|     20|    size_t          body_end_offset = *offset, body_len = 0;
 2773|     20|    struct snmp_secmod_def *sptr = NULL;
 2774|     20|    int             rc = 0;
 2775|       |
 2776|       |    /*
 2777|       |     * Build a scopedPDU structure into the packet buffer.  
 2778|       |     */
 2779|     20|    DEBUGPRINTPDUTYPE("send", pdu->command);
  ------------------
  |  |  440|     20|    DEBUGDUMPSECTION(token, snmp_pdu_type(type))
  |  |  ------------------
  |  |  |  |   81|     20|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               	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: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2780|     20|    if (pdu_data) {
  ------------------
  |  Branch (2780:9): [True: 0, False: 20]
  ------------------
 2781|      0|        while ((*pkt_len - *offset) < pdu_data_len) {
  ------------------
  |  Branch (2781:16): [True: 0, False: 0]
  ------------------
 2782|      0|            if (!asn_realloc(pkt, pkt_len)) {
  ------------------
  |  Branch (2782:17): [True: 0, False: 0]
  ------------------
 2783|      0|                return -1;
 2784|      0|            }
 2785|      0|        }
 2786|       |
 2787|      0|        *offset += pdu_data_len;
 2788|      0|        memcpy(*pkt + *pkt_len - *offset, pdu_data, pdu_data_len);
 2789|     20|    } else {
 2790|     20|        rc = snmp_pdu_realloc_rbuild(pkt, pkt_len, offset, pdu);
 2791|     20|        if (rc == 0) {
  ------------------
  |  Branch (2791:13): [True: 0, False: 20]
  ------------------
 2792|      0|            return -1;
 2793|      0|        }
 2794|     20|    }
 2795|     20|    body_len = *offset - body_end_offset;
 2796|       |
 2797|     20|    DEBUGDUMPSECTION("send", "ScopedPdu");
  ------------------
  |  |   81|     20|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2798|     20|    rc = snmpv3_scopedPDU_header_realloc_rbuild(pkt, pkt_len, offset,
 2799|     20|                                                pdu, body_len);
 2800|     20|    if (rc == 0) {
  ------------------
  |  Branch (2800:9): [True: 0, False: 20]
  ------------------
 2801|      0|        return -1;
 2802|      0|    }
 2803|     20|    spdu_offset = *offset;
 2804|     20|    DEBUGINDENTADD(-4);         /*  Return from Scoped PDU.  */
  ------------------
  |  |   73|     20|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 20]
  |  |  ------------------
  ------------------
 2805|       |
 2806|     20|    if ((hdrbuf = (u_char *) malloc(hdrbuf_len)) == NULL) {
  ------------------
  |  Branch (2806:9): [True: 0, False: 20]
  ------------------
 2807|      0|        return -1;
 2808|      0|    }
 2809|       |
 2810|     20|    rc = snmpv3_header_realloc_rbuild(&hdrbuf, &hdrbuf_len, &hdr_offset,
 2811|     20|                                      session, pdu);
 2812|     20|    if (rc == 0) {
  ------------------
  |  Branch (2812:9): [True: 0, False: 20]
  ------------------
 2813|      0|        SNMP_FREE(hdrbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2814|      0|        return -1;
 2815|      0|    }
 2816|     20|    hdr = hdrbuf + hdrbuf_len - hdr_offset;
 2817|     20|    scoped_pdu = *pkt + *pkt_len - spdu_offset;
 2818|       |
 2819|       |    /*
 2820|       |     * Call the security module to possibly encrypt and authenticate the
 2821|       |     * message---the entire message to transmitted on the wire is returned.  
 2822|       |     */
 2823|       |
 2824|     20|    sptr = find_sec_mod(pdu->securityModel);
 2825|     20|    DEBUGDUMPSECTION("send", "SM msgSecurityParameters");
  ------------------
  |  |   81|     20|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2826|     20|    if (sptr && sptr->encode_reverse) {
  ------------------
  |  Branch (2826:9): [True: 20, False: 0]
  |  Branch (2826:17): [True: 20, False: 0]
  ------------------
 2827|     20|        struct snmp_secmod_outgoing_params parms;
 2828|       |
 2829|     20|        parms.msgProcModel = pdu->msgParseModel;
 2830|     20|        parms.globalData = hdr;
 2831|     20|        parms.globalDataLen = hdr_offset;
 2832|     20|        parms.maxMsgSize = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|     20|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 2833|     20|        parms.secModel = pdu->securityModel;
 2834|     20|        parms.secEngineID = pdu->securityEngineID;
 2835|     20|        parms.secEngineIDLen = pdu->securityEngineIDLen;
 2836|     20|        parms.secName = pdu->securityName;
 2837|     20|        parms.secNameLen = pdu->securityNameLen;
 2838|     20|        parms.secLevel = pdu->securityLevel;
 2839|     20|        parms.scopedPdu = scoped_pdu;
 2840|     20|        parms.scopedPduLen = spdu_offset;
 2841|     20|        parms.secStateRef = pdu->securityStateRef;
 2842|     20|        parms.wholeMsg = pkt;
 2843|     20|        parms.wholeMsgLen = pkt_len;
 2844|     20|        parms.wholeMsgOffset = offset;
 2845|     20|        parms.session = session;
 2846|     20|        parms.pdu = pdu;
 2847|       |
 2848|     20|        rc = (*sptr->encode_reverse) (&parms);
 2849|     20|    } else {
 2850|      0|        if (!sptr) {
  ------------------
  |  Branch (2850:13): [True: 0, False: 0]
  ------------------
 2851|      0|            snmp_log(LOG_ERR,
 2852|      0|                     "no such security service available: %d\n",
 2853|      0|                     pdu->securityModel);
 2854|      0|        } else if (!sptr->encode_reverse) {
  ------------------
  |  Branch (2854:20): [True: 0, False: 0]
  ------------------
 2855|      0|            snmp_log(LOG_ERR,
 2856|      0|                     "security service %d doesn't support reverse encoding.\n",
 2857|      0|                     pdu->securityModel);
 2858|      0|        }
 2859|      0|        rc = -1;
 2860|      0|    }
 2861|       |
 2862|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2863|       |    SNMP_FREE(hdrbuf);
  ------------------
  |  |   62|     20|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 20, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2864|     20|    return rc;
 2865|     20|}                               /* end snmpv3_packet_realloc_rbuild() */
snmp_build:
 3369|     20|{
 3370|     20|    int             rc;
 3371|       |
 3372|     20|    rc = _snmp_build(pkt, pkt_len, offset, pss, pdu);
 3373|     20|    if (rc) {
  ------------------
  |  Branch (3373:9): [True: 0, False: 20]
  ------------------
 3374|      0|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (3374:13): [True: 0, False: 0]
  ------------------
 3375|      0|            snmp_log(LOG_ERR, "snmp_build: unknown failure\n");
 3376|      0|            pss->s_snmp_errno = SNMPERR_BAD_ASN1_BUILD;
  ------------------
  |  |  195|      0|#define SNMPERR_BAD_ASN1_BUILD		(-11)
  ------------------
 3377|      0|        }
 3378|      0|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3379|      0|        rc = -1;
 3380|      0|    }
 3381|     20|    return rc;
 3382|     20|}
snmp_pdu_realloc_rbuild:
 3601|     20|{
 3602|     20|#ifndef VPCACHE_SIZE
 3603|     20|#define VPCACHE_SIZE 50
 3604|     20|#endif
 3605|     20|    netsnmp_variable_list *vpcache[VPCACHE_SIZE];
 3606|     20|    netsnmp_variable_list *vp, *tmpvp;
 3607|     20|    size_t          start_offset = *offset;
 3608|     20|    int             i, wrapped = 0, notdone, final, rc = 0;
 3609|       |
 3610|     20|    DEBUGMSGTL(("snmp_pdu_realloc_rbuild", "starting\n"));
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3611|     40|    for (vp = pdu->variables, i = VPCACHE_SIZE - 1; vp;
  ------------------
  |  | 3603|     20|#define VPCACHE_SIZE 50
  ------------------
  |  Branch (3611:53): [True: 20, False: 20]
  ------------------
 3612|     20|         vp = vp->next_variable, i--) {
 3613|       |        /*
 3614|       |         * if estimated getbulk response size exceeded packet max size,
 3615|       |         * processing was stopped before bulk cache was filled and type
 3616|       |         * was set to ASN_PRIV_STOP, indicating that the rest of the varbinds
 3617|       |         * in the cache are empty and we can stop encoding them.
 3618|       |         */
 3619|     20|        if (ASN_PRIV_STOP == vp->type)
  ------------------
  |  |  207|     20|#define ASN_PRIV_STOP       (ASN_PRIVATE | 8)   /* 200 */
  |  |  ------------------
  |  |  |  |   93|     20|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  ------------------
  |  Branch (3619:13): [True: 0, False: 20]
  ------------------
 3620|      0|            break;
 3621|     20|        if (i < 0) {
  ------------------
  |  Branch (3621:13): [True: 0, False: 20]
  ------------------
 3622|      0|            wrapped = notdone = 1;
 3623|      0|            i = VPCACHE_SIZE - 1;
  ------------------
  |  | 3603|      0|#define VPCACHE_SIZE 50
  ------------------
 3624|      0|            DEBUGMSGTL(("snmp_pdu_realloc_rbuild", "wrapped\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]
  |  |  ------------------
  ------------------
 3625|      0|        }
 3626|     20|        vpcache[i] = vp;
 3627|     20|    }
 3628|     20|    final = i + 1;
 3629|       |
 3630|     20|    do {
 3631|     40|        for (i = final; i < VPCACHE_SIZE; i++) {
  ------------------
  |  | 3603|     40|#define VPCACHE_SIZE 50
  ------------------
  |  Branch (3631:25): [True: 20, False: 20]
  ------------------
 3632|     20|            vp = vpcache[i];
 3633|     20|            DEBUGDUMPSECTION("send", "VarBind");
  ------------------
  |  |   81|     20|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 3634|     20|            rc = snmp_realloc_rbuild_var_op(pkt, pkt_len, offset, 1,
 3635|     20|                                            vp->name, &vp->name_length,
 3636|     20|                                            vp->type,
 3637|     20|                                            (u_char *) vp->val.string,
 3638|     20|                                            vp->val_len);
 3639|     20|            DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3640|     20|            if (rc == 0) {
  ------------------
  |  Branch (3640:17): [True: 0, False: 20]
  ------------------
 3641|      0|                return 0;
 3642|      0|            }
 3643|     20|        }
 3644|       |
 3645|     20|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3646|     20|        if (wrapped) {
  ------------------
  |  Branch (3646:13): [True: 0, False: 20]
  ------------------
 3647|      0|            notdone = 1;
 3648|      0|            for (i = 0; i < final; i++) {
  ------------------
  |  Branch (3648:25): [True: 0, False: 0]
  ------------------
 3649|      0|                vp = vpcache[i];
 3650|      0|                DEBUGDUMPSECTION("send", "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]
  |  |  ------------------
  ------------------
 3651|      0|                rc = snmp_realloc_rbuild_var_op(pkt, pkt_len, offset, 1,
 3652|      0|                                                vp->name, &vp->name_length,
 3653|      0|                                                vp->type,
 3654|      0|                                                (u_char *) vp->val.string,
 3655|      0|                                                vp->val_len);
 3656|      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]
  |  |  ------------------
  ------------------
 3657|      0|                if (rc == 0) {
  ------------------
  |  Branch (3657:21): [True: 0, False: 0]
  ------------------
 3658|      0|                    return 0;
 3659|      0|                }
 3660|      0|            }
 3661|       |
 3662|      0|            if (final == 0) {
  ------------------
  |  Branch (3662:17): [True: 0, False: 0]
  ------------------
 3663|      0|                tmpvp = vpcache[VPCACHE_SIZE - 1];
  ------------------
  |  | 3603|      0|#define VPCACHE_SIZE 50
  ------------------
 3664|      0|            } else {
 3665|      0|                tmpvp = vpcache[final - 1];
 3666|      0|            }
 3667|      0|            wrapped = 0;
 3668|       |
 3669|      0|            for (vp = pdu->variables, i = VPCACHE_SIZE - 1;
  ------------------
  |  | 3603|      0|#define VPCACHE_SIZE 50
  ------------------
 3670|      0|                 vp && vp != tmpvp; vp = vp->next_variable, i--) {
  ------------------
  |  Branch (3670:18): [True: 0, False: 0]
  |  Branch (3670:24): [True: 0, False: 0]
  ------------------
 3671|      0|                if (i < 0) {
  ------------------
  |  Branch (3671:21): [True: 0, False: 0]
  ------------------
 3672|      0|                    wrapped = 1;
 3673|      0|                    i = VPCACHE_SIZE - 1;
  ------------------
  |  | 3603|      0|#define VPCACHE_SIZE 50
  ------------------
 3674|      0|                    DEBUGMSGTL(("snmp_pdu_realloc_rbuild", "wrapped\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]
  |  |  ------------------
  ------------------
 3675|      0|                }
 3676|      0|                vpcache[i] = vp;
 3677|      0|            }
 3678|      0|            final = i + 1;
 3679|     20|        } else {
 3680|     20|            notdone = 0;
 3681|     20|        }
 3682|     20|    } while (notdone);
  ------------------
  |  Branch (3682:14): [True: 0, False: 20]
  ------------------
 3683|       |
 3684|       |    /*
 3685|       |     * Save current location and build SEQUENCE tag and length placeholder for
 3686|       |     * variable-bindings sequence (actual length will be inserted later).  
 3687|       |     */
 3688|       |
 3689|     20|    rc = asn_realloc_rbuild_sequence(pkt, pkt_len, offset, 1,
 3690|     20|                                     (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|     20|#define ASN_SEQUENCE	    0x10U
  ------------------
 3691|     20|                                               ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3692|     20|                                     *offset - start_offset);
 3693|       |
 3694|       |    /*
 3695|       |     * Store fields in the PDU preceding the variable-bindings sequence.
 3696|       |     */
 3697|     20|    if (pdu->command != SNMP_MSG_TRAP) {
  ------------------
  |  |  135|     20|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (3697:9): [True: 20, False: 0]
  ------------------
 3698|       |        /*
 3699|       |         * Error index (getbulk max-repetitions).  
 3700|       |         */
 3701|     20|        DEBUGDUMPHEADER("send", "error index");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 3702|     20|        rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 3703|     20|                                    (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3704|     20|                                              | ASN_INTEGER),
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 3705|     20|                                    &pdu->errindex, sizeof(pdu->errindex));
 3706|     20|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3707|     20|        if (rc == 0) {
  ------------------
  |  Branch (3707:13): [True: 0, False: 20]
  ------------------
 3708|      0|            return 0;
 3709|      0|        }
 3710|       |
 3711|       |        /*
 3712|       |         * Error status (getbulk non-repeaters).  
 3713|       |         */
 3714|     20|        DEBUGDUMPHEADER("send", "error status");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 3715|     20|        rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 3716|     20|                                    (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3717|     20|                                              | ASN_INTEGER),
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 3718|     20|                                    &pdu->errstat, sizeof(pdu->errstat));
 3719|     20|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3720|     20|        if (rc == 0) {
  ------------------
  |  Branch (3720:13): [True: 0, False: 20]
  ------------------
 3721|      0|            return 0;
 3722|      0|        }
 3723|       |
 3724|       |        /*
 3725|       |         * Request ID.  
 3726|       |         */
 3727|     20|        DEBUGDUMPHEADER("send", "request_id");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 3728|     20|        rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 3729|     20|                                    (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3730|     20|                                              | ASN_INTEGER), &pdu->reqid,
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 3731|     20|                                    sizeof(pdu->reqid));
 3732|     20|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 3733|     20|        if (rc == 0) {
  ------------------
  |  Branch (3733:13): [True: 0, False: 20]
  ------------------
 3734|      0|            return 0;
 3735|      0|        }
 3736|     20|    } else {
 3737|       |        /*
 3738|       |         * An SNMPv1 trap PDU.  
 3739|       |         */
 3740|       |
 3741|       |        /*
 3742|       |         * Timestamp.  
 3743|       |         */
 3744|      0|        DEBUGDUMPHEADER("send", "timestamp");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3745|      0|        rc = asn_realloc_rbuild_unsigned_int(pkt, pkt_len, offset, 1,
 3746|      0|                                             (u_char) (ASN_TIMETICKS |
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
 3747|      0|                                                       ASN_PRIMITIVE),
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3748|      0|                                             &pdu->time,
 3749|      0|                                             sizeof(pdu->time));
 3750|      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]
  |  |  ------------------
  ------------------
 3751|      0|        if (rc == 0) {
  ------------------
  |  Branch (3751:13): [True: 0, False: 0]
  ------------------
 3752|      0|            return 0;
 3753|      0|        }
 3754|       |
 3755|       |        /*
 3756|       |         * Specific trap.  
 3757|       |         */
 3758|      0|        DEBUGDUMPHEADER("send", "specific trap number");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3759|      0|        rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 3760|      0|                                    (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3761|      0|                                              | ASN_INTEGER),
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
 3762|      0|                                    (const long *) &pdu->specific_type,
 3763|      0|                                    sizeof(pdu->specific_type));
 3764|      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]
  |  |  ------------------
  ------------------
 3765|      0|        if (rc == 0) {
  ------------------
  |  Branch (3765:13): [True: 0, False: 0]
  ------------------
 3766|      0|            return 0;
 3767|      0|        }
 3768|       |
 3769|       |        /*
 3770|       |         * Generic trap.  
 3771|       |         */
 3772|      0|        DEBUGDUMPHEADER("send", "generic trap number");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3773|      0|        rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 3774|      0|                                    (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3775|      0|                                              | ASN_INTEGER),
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
 3776|      0|                                    (const long *) &pdu->trap_type,
 3777|      0|                                    sizeof(pdu->trap_type));
 3778|      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]
  |  |  ------------------
  ------------------
 3779|      0|        if (rc == 0) {
  ------------------
  |  Branch (3779:13): [True: 0, False: 0]
  ------------------
 3780|      0|            return 0;
 3781|      0|        }
 3782|       |
 3783|       |        /*
 3784|       |         * Agent-addr.  
 3785|       |         */
 3786|      0|        DEBUGDUMPHEADER("send", "agent Address");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3787|      0|        rc = asn_realloc_rbuild_string(pkt, pkt_len, offset, 1,
 3788|      0|                                       (u_char) (ASN_IPADDRESS |
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
 3789|      0|                                                 ASN_PRIMITIVE),
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3790|      0|                                       (const u_char *) pdu->agent_addr, 4);
 3791|      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]
  |  |  ------------------
  ------------------
 3792|      0|        if (rc == 0) {
  ------------------
  |  Branch (3792:13): [True: 0, False: 0]
  ------------------
 3793|      0|            return 0;
 3794|      0|        }
 3795|       |
 3796|       |        /*
 3797|       |         * Enterprise.  
 3798|       |         */
 3799|      0|        DEBUGDUMPHEADER("send", "enterprise OBJID");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3800|      0|        rc = asn_realloc_rbuild_objid(pkt, pkt_len, offset, 1,
 3801|      0|                                      (u_char) (ASN_UNIVERSAL |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
 3802|      0|                                                ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3803|      0|                                                ASN_OBJECT_ID),
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
 3804|      0|                                      (oid *) pdu->enterprise,
 3805|      0|                                      pdu->enterprise_length);
 3806|      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]
  |  |  ------------------
  ------------------
 3807|      0|        if (rc == 0) {
  ------------------
  |  Branch (3807:13): [True: 0, False: 0]
  ------------------
 3808|      0|            return 0;
 3809|      0|        }
 3810|      0|    }
 3811|       |
 3812|       |    /*
 3813|       |     * Build the PDU sequence.  
 3814|       |     */
 3815|     20|    rc = asn_realloc_rbuild_sequence(pkt, pkt_len, offset, 1,
 3816|     20|                                     (u_char) pdu->command,
 3817|     20|                                     *offset - start_offset);
 3818|     20|    return rc;
 3819|     20|}
snmpv3_parse:
 3852|     33|{
 3853|     33|    u_char          type, msg_flags;
 3854|     33|    long            ver, msg_sec_model;
 3855|     33|    size_t          max_size_response;
 3856|     33|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 3857|     33|    size_t          tmp_buf_len;
 3858|     33|    u_char          pdu_buf[SNMP_MAX_MSG_SIZE];
 3859|     33|    u_char         *mallocbuf = NULL;
 3860|     33|    size_t          pdu_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|     33|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 3861|     33|    u_char         *sec_params;
 3862|     33|    u_char         *msg_data;
 3863|     33|    u_char         *cp;
 3864|     33|    size_t          asn_len, msg_len;
 3865|     33|    int             ret, ret_val;
 3866|     33|    struct snmp_secmod_def *sptr;
 3867|       |
 3868|       |
 3869|     33|    msg_data = data;
 3870|     33|    msg_len = *length;
 3871|       |
 3872|       |
 3873|       |    /*
 3874|       |     * message is an ASN.1 SEQUENCE  
 3875|       |     */
 3876|     33|    DEBUGDUMPSECTION("recv", "SNMPv3 Message");
  ------------------
  |  |   81|     33|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     33|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 33]
  |  |  ------------------
  ------------------
 3877|     33|    data = asn_parse_sequence(data, length, &type,
 3878|     33|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   84|     33|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   96|     33|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3879|     33|    if (data == NULL) {
  ------------------
  |  Branch (3879:9): [True: 0, False: 33]
  ------------------
 3880|       |        /*
 3881|       |         * error msg detail is set 
 3882|       |         */
 3883|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3884|      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]
  |  |  ------------------
  ------------------
 3885|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3886|      0|    }
 3887|       |
 3888|       |    /*
 3889|       |     * parse msgVersion  
 3890|       |     */
 3891|     33|    DEBUGDUMPHEADER("recv", "SNMP Version Number");
  ------------------
  |  |   79|     33|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     33|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 33]
  |  |  ------------------
  ------------------
 3892|     33|    data = asn_parse_int(data, length, &type, &ver, sizeof(ver));
 3893|     33|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     33|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     33|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 33]
  |  |  ------------------
  ------------------
 3894|     33|    if (data == NULL) {
  ------------------
  |  Branch (3894:9): [True: 0, False: 33]
  ------------------
 3895|      0|        ERROR_MSG("bad parse of version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3896|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3897|      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]
  |  |  ------------------
  ------------------
 3898|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3899|      0|    }
 3900|     33|    pdu->version = ver;
 3901|       |
 3902|       |    /*
 3903|       |     * parse msgGlobalData sequence  
 3904|       |     */
 3905|     33|    cp = data;
 3906|     33|    asn_len = *length;
 3907|     33|    DEBUGDUMPSECTION("recv", "msgGlobalData");
  ------------------
  |  |   81|     33|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     33|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 33]
  |  |  ------------------
  ------------------
 3908|     33|    data = asn_parse_sequence(data, &asn_len, &type,
 3909|     33|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|     33|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     33|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3910|     33|                              "msgGlobalData");
 3911|     33|    if (data == NULL) {
  ------------------
  |  Branch (3911:9): [True: 1, False: 32]
  ------------------
 3912|       |        /*
 3913|       |         * error msg detail is set 
 3914|       |         */
 3915|      1|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3916|      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]
  |  |  ------------------
  ------------------
 3917|      1|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3918|      1|    }
 3919|     32|    *length -= data - cp;       /* subtract off the length of the header */
 3920|       |
 3921|       |    /*
 3922|       |     * msgID 
 3923|       |     */
 3924|     32|    DEBUGDUMPHEADER("recv", "msgID");
  ------------------
  |  |   79|     32|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 32]
  |  |  ------------------
  ------------------
 3925|     32|    data =
 3926|     32|        asn_parse_int(data, length, &type, &pdu->msgid,
 3927|     32|                      sizeof(pdu->msgid));
 3928|     32|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     32|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     32|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 32]
  |  |  ------------------
  ------------------
 3929|     32|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|     27|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3929:9): [True: 5, False: 27]
  |  Branch (3929:25): [True: 0, False: 27]
  ------------------
 3930|      5|        ERROR_MSG("error parsing msgID");
  ------------------
  |  |  188|      5|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3931|      5|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      5|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      5|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 5]
  |  |  ------------------
  ------------------
 3932|      5|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      5|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3933|      5|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      5|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3934|      5|    }
 3935|       |
 3936|       |    /*
 3937|       |     * Check the msgID we received is a legal value.  If not, then increment
 3938|       |     * snmpInASNParseErrs and return the appropriate error (see RFC 2572,
 3939|       |     * para. 7.2, section 2 -- note that a bad msgID means that the received
 3940|       |     * message is NOT a serialization of an SNMPv3Message, since the msgID
 3941|       |     * field is out of bounds).  
 3942|       |     */
 3943|       |
 3944|     27|    if (pdu->msgid < 0 || pdu->msgid > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|     27|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (3944:9): [True: 0, False: 27]
  |  Branch (3944:27): [True: 0, False: 27]
  ------------------
 3945|      0|        snmp_log(LOG_ERR, "Received bad msgID (%ld %s %s).\n", pdu->msgid,
 3946|      0|                 (pdu->msgid < 0) ? "<" : ">",
  ------------------
  |  Branch (3946:18): [True: 0, False: 0]
  ------------------
 3947|      0|                 (pdu->msgid < 0) ? "0" : "2^31 - 1");
  ------------------
  |  Branch (3947:18): [True: 0, False: 0]
  ------------------
 3948|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3949|      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]
  |  |  ------------------
  ------------------
 3950|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3951|      0|    }
 3952|       |
 3953|       |    /*
 3954|       |     * msgMaxSize 
 3955|       |     */
 3956|     27|    DEBUGDUMPHEADER("recv:msgMaxSize", "msgMaxSize");
  ------------------
  |  |   79|     27|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     27|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 27]
  |  |  ------------------
  ------------------
 3957|     27|    data = asn_parse_int(data, length, &type, &pdu->msgMaxSize,
 3958|     27|                         sizeof(pdu->msgMaxSize));
 3959|     27|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     27|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     27|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 27]
  |  |  ------------------
  ------------------
 3960|     27|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|     26|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3960:9): [True: 1, False: 26]
  |  Branch (3960:25): [True: 0, False: 26]
  ------------------
 3961|      1|        ERROR_MSG("error parsing msgMaxSize");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3962|      1|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3963|      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]
  |  |  ------------------
  ------------------
 3964|      1|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3965|      1|    }
 3966|       |
 3967|       |    /*
 3968|       |     * Check the msgMaxSize we received is a legal value.  If not, then
 3969|       |     * increment snmpInASNParseErrs and return the appropriate error (see RFC
 3970|       |     * 2572, para. 7.2, section 2 -- note that a bad msgMaxSize means that the
 3971|       |     * received message is NOT a serialization of an SNMPv3Message, since the
 3972|       |     * msgMaxSize field is out of bounds).
 3973|       |     */
 3974|       |
 3975|     26|    if (pdu->msgMaxSize < SNMP_MIN_MAX_LEN) {
  ------------------
  |  |   48|     26|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (3975:9): [True: 0, False: 26]
  ------------------
 3976|      0|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu < 484).\n",
 3977|      0|                 pdu->msgMaxSize);
 3978|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3979|      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]
  |  |  ------------------
  ------------------
 3980|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3981|     26|    } else if (pdu->msgMaxSize > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|     26|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (3981:16): [True: 0, False: 26]
  ------------------
 3982|      0|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu > 2^31 - 1).\n",
 3983|      0|                 pdu->msgMaxSize);
 3984|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3985|      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]
  |  |  ------------------
  ------------------
 3986|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3987|     26|    } else {
 3988|     26|        DEBUGMSGTL(("snmpv3_parse:msgMaxSize", "msgMaxSize %lu received\n",
  ------------------
  |  |   66|     26|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     26|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 26]
  |  |  ------------------
  ------------------
 3989|     26|                    pdu->msgMaxSize));
 3990|       |        /** don't increase max msg size if we've already got one */
 3991|     26|        if (sess->sndMsgMaxSize < pdu->msgMaxSize) {
  ------------------
  |  Branch (3991:13): [True: 23, False: 3]
  ------------------
 3992|     23|            DEBUGMSGTL(("snmpv3_parse:msgMaxSize",
  ------------------
  |  |   66|     23|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     23|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 23]
  |  |  ------------------
  ------------------
 3993|     23|                        "msgMaxSize %" NETSNMP_PRIz "d greater than session max %ld; reducing\n",
 3994|     23|                        sess->sndMsgMaxSize, pdu->msgMaxSize));
 3995|     23|            pdu->msgMaxSize = sess->sndMsgMaxSize;
 3996|     23|        }
 3997|     26|    }
 3998|       |
 3999|       |    /*
 4000|       |     * msgFlags 
 4001|       |     */
 4002|     26|    tmp_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|     26|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 4003|     26|    DEBUGDUMPHEADER("recv", "msgFlags");
  ------------------
  |  |   79|     26|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     26|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 26]
  |  |  ------------------
  ------------------
 4004|     26|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 4005|     26|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     26|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     26|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 26]
  |  |  ------------------
  ------------------
 4006|     26|    if (data == NULL || type != ASN_OCTET_STR || tmp_buf_len != 1) {
  ------------------
  |  |   78|     48|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4006:9): [True: 4, False: 22]
  |  Branch (4006:25): [True: 0, False: 22]
  |  Branch (4006:50): [True: 0, False: 22]
  ------------------
 4007|      4|        ERROR_MSG("error parsing msgFlags");
  ------------------
  |  |  188|      4|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4008|      4|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      4|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4009|      4|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      4|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4010|      4|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      4|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4011|      4|    }
 4012|     22|    msg_flags = *tmp_buf;
 4013|     22|    if (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)
  ------------------
  |  |  305|     22|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (4013:9): [True: 20, False: 2]
  ------------------
 4014|     20|        pdu->flags |= SNMP_MSG_FLAG_RPRT_BIT;
  ------------------
  |  |  305|     20|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4015|      2|    else
 4016|      2|        pdu->flags &= (~SNMP_MSG_FLAG_RPRT_BIT);
  ------------------
  |  |  305|      2|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4017|       |
 4018|       |    /*
 4019|       |     * msgSecurityModel 
 4020|       |     */
 4021|     22|    DEBUGDUMPHEADER("recv", "msgSecurityModel");
  ------------------
  |  |   79|     22|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 22]
  |  |  ------------------
  ------------------
 4022|     22|    data = asn_parse_int(data, length, &type, &msg_sec_model,
 4023|     22|                         sizeof(msg_sec_model));
 4024|     22|    DEBUGINDENTADD(-4);         /* return from global data indent */
  ------------------
  |  |   73|     22|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 22]
  |  |  ------------------
  ------------------
 4025|     22|    if (data == NULL || type != ASN_INTEGER ||
  ------------------
  |  |   75|     44|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4025:9): [True: 0, False: 22]
  |  Branch (4025:25): [True: 0, False: 22]
  ------------------
 4026|     22|        msg_sec_model < 1 || msg_sec_model > 0x7fffffff) {
  ------------------
  |  Branch (4026:9): [True: 0, False: 22]
  |  Branch (4026:30): [True: 0, False: 22]
  ------------------
 4027|      0|        ERROR_MSG("error parsing msgSecurityModel");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4028|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4029|      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]
  |  |  ------------------
  ------------------
 4030|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4031|      0|    }
 4032|     22|    sptr = find_sec_mod(msg_sec_model);
 4033|     22|    if (!sptr) {
  ------------------
  |  Branch (4033:9): [True: 0, False: 22]
  ------------------
 4034|      0|        snmp_log(LOG_WARNING, "unknown security model: %ld\n",
 4035|      0|                 msg_sec_model);
 4036|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNSECURITYMODELS);
  ------------------
  |  |  611|      0|#define   STAT_SNMPUNKNOWNSECURITYMODELS     0
  ------------------
 4037|      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]
  |  |  ------------------
  ------------------
 4038|      0|        return SNMPERR_UNKNOWN_SEC_MODEL;
  ------------------
  |  |  214|      0|#define SNMPERR_UNKNOWN_SEC_MODEL 	(-30)
  ------------------
 4039|      0|    }
 4040|     22|    pdu->securityModel = msg_sec_model;
 4041|       |
 4042|     22|    if (msg_flags & SNMP_MSG_FLAG_PRIV_BIT &&
  ------------------
  |  |  304|     44|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4042:9): [True: 0, False: 22]
  ------------------
 4043|      0|        !(msg_flags & SNMP_MSG_FLAG_AUTH_BIT)) {
  ------------------
  |  |  303|      0|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4043:9): [True: 0, False: 0]
  ------------------
 4044|      0|        ERROR_MSG("invalid message, illegal msgFlags");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4045|      0|        snmp_increment_statistic(STAT_SNMPINVALIDMSGS);
  ------------------
  |  |  612|      0|#define   STAT_SNMPINVALIDMSGS               1
  ------------------
 4046|      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]
  |  |  ------------------
  ------------------
 4047|      0|        return SNMPERR_INVALID_MSG;
  ------------------
  |  |  215|      0|#define SNMPERR_INVALID_MSG             (-31)
  ------------------
 4048|      0|    }
 4049|     22|    pdu->securityLevel = ((msg_flags & SNMP_MSG_FLAG_AUTH_BIT)
  ------------------
  |  |  303|     22|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4049:27): [True: 22, False: 0]
  ------------------
 4050|     22|                          ? ((msg_flags & SNMP_MSG_FLAG_PRIV_BIT)
  ------------------
  |  |  304|     22|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4050:30): [True: 0, False: 22]
  ------------------
 4051|     22|                             ? SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
 4052|     22|                             : SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|     22|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
 4053|     22|                          : SNMP_SEC_LEVEL_NOAUTH);
  ------------------
  |  |  299|      0|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4054|       |    /*
 4055|       |     * end of msgGlobalData 
 4056|       |     */
 4057|       |
 4058|       |    /*
 4059|       |     * securtityParameters OCTET STRING begins after msgGlobalData 
 4060|       |     */
 4061|     22|    sec_params = data;
 4062|     22|    pdu->contextEngineID = calloc(1, SNMP_MAX_ENG_SIZE);
  ------------------
  |  |  111|     22|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4063|     22|    pdu->contextEngineIDLen = SNMP_MAX_ENG_SIZE;
  ------------------
  |  |  111|     22|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4064|       |
 4065|       |    /*
 4066|       |     * Note: there is no length limit on the msgAuthoritativeEngineID field,
 4067|       |     * although we would EXPECT it to be limited to 32 (the SnmpEngineID TC
 4068|       |     * limit).  We'll use double that here to be on the safe side.  
 4069|       |     */
 4070|       |
 4071|     22|    pdu->securityEngineID = calloc(1, SNMP_MAX_ENG_SIZE * 2);
  ------------------
  |  |  111|     22|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4072|     22|    pdu->securityEngineIDLen = SNMP_MAX_ENG_SIZE * 2;
  ------------------
  |  |  111|     22|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4073|     22|    pdu->securityName = calloc(1, SNMP_MAX_SEC_NAME_SIZE);
  ------------------
  |  |  112|     22|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4074|     22|    pdu->securityNameLen = SNMP_MAX_SEC_NAME_SIZE;
  ------------------
  |  |  112|     22|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4075|       |
 4076|     22|    if ((pdu->securityName == NULL) ||
  ------------------
  |  Branch (4076:9): [True: 0, False: 22]
  ------------------
 4077|     22|        (pdu->securityEngineID == NULL) ||
  ------------------
  |  Branch (4077:9): [True: 0, False: 22]
  ------------------
 4078|     22|        (pdu->contextEngineID == NULL)) {
  ------------------
  |  Branch (4078:9): [True: 0, False: 22]
  ------------------
 4079|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4080|      0|    }
 4081|       |
 4082|     22|    if (pdu_buf_len < msg_len
  ------------------
  |  Branch (4082:9): [True: 0, False: 22]
  ------------------
 4083|      0|        && pdu->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (4083:12): [True: 0, False: 0]
  ------------------
 4084|       |        /*
 4085|       |         * space needed is larger than we have in the default buffer 
 4086|       |         */
 4087|      0|        mallocbuf = calloc(1, msg_len);
 4088|      0|        pdu_buf_len = msg_len;
 4089|      0|        cp = mallocbuf;
 4090|     22|    } else {
 4091|     22|        memset(pdu_buf, 0, pdu_buf_len);
 4092|     22|        cp = pdu_buf;
 4093|     22|    }
 4094|       |
 4095|     22|    DEBUGDUMPSECTION("recv", "SM msgSecurityParameters");
  ------------------
  |  |   81|     22|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 22]
  |  |  ------------------
  ------------------
 4096|     22|    if (sptr->decode) {
  ------------------
  |  Branch (4096:9): [True: 22, False: 0]
  ------------------
 4097|     22|        struct snmp_secmod_incoming_params parms;
 4098|     22|        parms.msgProcModel = pdu->msgParseModel;
 4099|     22|        parms.maxMsgSize = pdu->msgMaxSize;
 4100|     22|        parms.secParams = sec_params;
 4101|     22|        parms.secModel = msg_sec_model;
 4102|     22|        parms.secLevel = pdu->securityLevel;
 4103|     22|        parms.wholeMsg = msg_data;
 4104|     22|        parms.wholeMsgLen = msg_len;
 4105|     22|        parms.secEngineID = pdu->securityEngineID;
 4106|     22|        parms.secEngineIDLen = &pdu->securityEngineIDLen;
 4107|     22|        parms.secName = pdu->securityName;
 4108|     22|        parms.secNameLen = &pdu->securityNameLen;
 4109|     22|        parms.scopedPdu = &cp;
 4110|     22|        parms.scopedPduLen = &pdu_buf_len;
 4111|     22|        parms.maxSizeResponse = &max_size_response;
 4112|     22|        parms.secStateRef = &pdu->securityStateRef;
 4113|     22|        parms.sess = sess;
 4114|     22|        parms.pdu = pdu;
 4115|     22|        parms.msg_flags = msg_flags;
 4116|     22|        ret_val = (*sptr->decode) (&parms);
 4117|     22|    } else {
 4118|      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]
  |  |  ------------------
  ------------------
 4119|      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]
  |  |  ------------------
  ------------------
 4120|      0|        snmp_log(LOG_WARNING, "security service %ld can't decode packets\n",
 4121|      0|                 msg_sec_model);
 4122|      0|        return (-1);
 4123|      0|    }
 4124|       |
 4125|     22|    if (ret_val != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     22|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4125:9): [True: 22, False: 0]
  ------------------
 4126|     22|        DEBUGDUMPSECTION("recv", "ScopedPDU");
  ------------------
  |  |   81|     22|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 22]
  |  |  ------------------
  ------------------
 4127|       |        /*
 4128|       |         * Parse as much as possible -- though I don't see the point? [jbpn].  
 4129|       |         */
 4130|     22|        if (cp) {
  ------------------
  |  Branch (4130:13): [True: 22, False: 0]
  ------------------
 4131|     22|            cp = snmpv3_scopedPDU_parse(pdu, cp, &pdu_buf_len);
 4132|     22|        }
 4133|     22|        if (cp) {
  ------------------
  |  Branch (4133:13): [True: 0, False: 22]
  ------------------
 4134|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4135|      0|            snmp_pdu_parse(pdu, cp, &pdu_buf_len);
 4136|      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]
  |  |  ------------------
  ------------------
 4137|     22|        } else {
 4138|     22|            DEBUGINDENTADD(-4);
  ------------------
  |  |   73|     22|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 22]
  |  |  ------------------
  ------------------
 4139|     22|        }
 4140|       |
 4141|     22|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|     22|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 22]
  |  |  |  Branch (62:66): [Folded, False: 22]
  |  |  ------------------
  ------------------
 4142|     22|        return ret_val;
 4143|     22|    }
 4144|       |
 4145|       |    /*
 4146|       |     * parse plaintext ScopedPDU sequence 
 4147|       |     */
 4148|      0|    *length = pdu_buf_len;
 4149|      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]
  |  |  ------------------
  ------------------
 4150|      0|    data = snmpv3_scopedPDU_parse(pdu, cp, length);
 4151|      0|    if (data == NULL) {
  ------------------
  |  Branch (4151:9): [True: 0, False: 0]
  ------------------
 4152|      0|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4153|      0|                 msg_sec_model);
 4154|      0|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4155|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4156|      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]
  |  |  ------------------
  ------------------
 4157|      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]
  |  |  ------------------
  ------------------
 4158|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4159|      0|    }
 4160|       |
 4161|       |    /*
 4162|       |     * parse the PDU.  
 4163|       |     */
 4164|      0|    if (after_header != NULL) {
  ------------------
  |  Branch (4164:9): [True: 0, False: 0]
  ------------------
 4165|      0|        *after_header = data;
 4166|      0|        tmp_buf_len = *length;
 4167|      0|    }
 4168|       |
 4169|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4170|      0|    ret = snmp_pdu_parse(pdu, data, length);
 4171|      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]
  |  |  ------------------
  ------------------
 4172|       |
 4173|      0|    if (after_header != NULL) {
  ------------------
  |  Branch (4173:9): [True: 0, False: 0]
  ------------------
 4174|      0|        *length = tmp_buf_len;
 4175|      0|    }
 4176|       |
 4177|      0|    if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4177:9): [True: 0, False: 0]
  ------------------
 4178|      0|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4179|      0|                 msg_sec_model);
 4180|      0|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4181|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4182|      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]
  |  |  ------------------
  ------------------
 4183|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4184|      0|    }
 4185|       |
 4186|      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]
  |  |  ------------------
  ------------------
 4187|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 4188|      0|}                               /* end snmpv3_parse() */
snmpv3_make_report:
 4219|     20|{
 4220|       |
 4221|     20|    long            ltmp;
 4222|     20|    static const oid unknownSecurityLevel[] =
 4223|     20|        { 1, 3, 6, 1, 6, 3, 15, 1, 1, 1, 0 };
 4224|     20|    static const oid notInTimeWindow[] =
 4225|     20|        { 1, 3, 6, 1, 6, 3, 15, 1, 1, 2, 0 };
 4226|     20|    static const oid unknownUserName[] =
 4227|     20|        { 1, 3, 6, 1, 6, 3, 15, 1, 1, 3, 0 };
 4228|     20|    static const oid unknownEngineID[] =
 4229|     20|        { 1, 3, 6, 1, 6, 3, 15, 1, 1, 4, 0 };
 4230|     20|    static const oid wrongDigest[] = { 1, 3, 6, 1, 6, 3, 15, 1, 1, 5, 0 };
 4231|     20|    static const oid decryptionError[] =
 4232|     20|        { 1, 3, 6, 1, 6, 3, 15, 1, 1, 6, 0 };
 4233|     20|    const oid      *err_var;
 4234|     20|    int             err_var_len;
 4235|     20|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4236|     20|    int             stat_ind;
 4237|     20|#endif
 4238|       |
 4239|     20|    switch (error) {
 4240|      8|    case SNMPERR_USM_UNKNOWNENGINEID:
  ------------------
  |  |  232|      8|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
  |  Branch (4240:5): [True: 8, False: 12]
  ------------------
 4241|      8|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4242|      8|        stat_ind = STAT_USMSTATSUNKNOWNENGINEIDS;
  ------------------
  |  |  623|      8|#define   STAT_USMSTATSUNKNOWNENGINEIDS      6
  ------------------
 4243|      8|#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4244|      8|        err_var = unknownEngineID;
 4245|      8|        err_var_len = ERROR_STAT_LENGTH;
  ------------------
  |  | 4215|      8|#define ERROR_STAT_LENGTH 11
  ------------------
 4246|      8|        break;
 4247|      0|    case SNMPERR_USM_UNKNOWNSECURITYNAME:
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4247:5): [True: 0, False: 20]
  ------------------
 4248|      0|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4249|      0|        stat_ind = STAT_USMSTATSUNKNOWNUSERNAMES;
  ------------------
  |  |  622|      0|#define   STAT_USMSTATSUNKNOWNUSERNAMES      5
  ------------------
 4250|      0|#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4251|      0|        err_var = unknownUserName;
 4252|      0|        err_var_len = ERROR_STAT_LENGTH;
  ------------------
  |  | 4215|      0|#define ERROR_STAT_LENGTH 11
  ------------------
 4253|      0|        break;
 4254|      0|    case SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL:
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
  |  Branch (4254:5): [True: 0, False: 20]
  ------------------
 4255|      0|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4256|      0|        stat_ind = STAT_USMSTATSUNSUPPORTEDSECLEVELS;
  ------------------
  |  |  620|      0|#define   STAT_USMSTATSUNSUPPORTEDSECLEVELS  3
  ------------------
 4257|      0|#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4258|      0|        err_var = unknownSecurityLevel;
 4259|      0|        err_var_len = ERROR_STAT_LENGTH;
  ------------------
  |  | 4215|      0|#define ERROR_STAT_LENGTH 11
  ------------------
 4260|      0|        break;
 4261|      0|    case SNMPERR_USM_AUTHENTICATIONFAILURE:
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
  |  Branch (4261:5): [True: 0, False: 20]
  ------------------
 4262|      0|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4263|      0|        stat_ind = STAT_USMSTATSWRONGDIGESTS;
  ------------------
  |  |  624|      0|#define   STAT_USMSTATSWRONGDIGESTS          7
  ------------------
 4264|      0|#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4265|      0|        err_var = wrongDigest;
 4266|      0|        err_var_len = ERROR_STAT_LENGTH;
  ------------------
  |  | 4215|      0|#define ERROR_STAT_LENGTH 11
  ------------------
 4267|      0|        break;
 4268|      0|    case SNMPERR_USM_NOTINTIMEWINDOW:
  ------------------
  |  |  233|      0|#define SNMPERR_USM_NOTINTIMEWINDOW		(-49)
  ------------------
  |  Branch (4268:5): [True: 0, False: 20]
  ------------------
 4269|      0|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4270|      0|        stat_ind = STAT_USMSTATSNOTINTIMEWINDOWS;
  ------------------
  |  |  621|      0|#define   STAT_USMSTATSNOTINTIMEWINDOWS      4
  ------------------
 4271|      0|#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4272|      0|        err_var = notInTimeWindow;
 4273|      0|        err_var_len = ERROR_STAT_LENGTH;
  ------------------
  |  | 4215|      0|#define ERROR_STAT_LENGTH 11
  ------------------
 4274|      0|        break;
 4275|     12|    case SNMPERR_USM_DECRYPTIONERROR:
  ------------------
  |  |  234|     12|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
  |  Branch (4275:5): [True: 12, False: 8]
  ------------------
 4276|     12|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4277|     12|        stat_ind = STAT_USMSTATSDECRYPTIONERRORS;
  ------------------
  |  |  625|     12|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 4278|     12|#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4279|     12|        err_var = decryptionError;
 4280|     12|        err_var_len = ERROR_STAT_LENGTH;
  ------------------
  |  | 4215|     12|#define ERROR_STAT_LENGTH 11
  ------------------
 4281|     12|        break;
 4282|      0|    default:
  ------------------
  |  Branch (4282:5): [True: 0, False: 20]
  ------------------
 4283|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 4284|     20|    }
 4285|       |
 4286|     20|    snmp_free_varbind(pdu->variables);  /* free the current varbind */
 4287|       |
 4288|     20|    pdu->variables = NULL;
 4289|     20|    SNMP_FREE(pdu->securityEngineID);
  ------------------
  |  |   62|     20|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 20, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 20]
  |  |  ------------------
  ------------------
 4290|     20|    pdu->securityEngineID =
 4291|     20|        snmpv3_generate_engineID(&pdu->securityEngineIDLen);
 4292|     20|    SNMP_FREE(pdu->contextEngineID);
  ------------------
  |  |   62|     20|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 20, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 20]
  |  |  ------------------
  ------------------
 4293|     20|    pdu->contextEngineID =
 4294|     20|        snmpv3_generate_engineID(&pdu->contextEngineIDLen);
 4295|     20|    pdu->command = SNMP_MSG_REPORT;
  ------------------
  |  |  147|     20|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
 4296|     20|    pdu->errstat = 0;
 4297|     20|    pdu->errindex = 0;
 4298|     20|    SNMP_FREE(pdu->contextName);
  ------------------
  |  |   62|     20|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 20]
  |  |  |  Branch (62:66): [Folded, False: 20]
  |  |  ------------------
  ------------------
 4299|     20|    pdu->contextName = strdup("");
 4300|     20|    pdu->contextNameLen = strlen(pdu->contextName);
 4301|       |
 4302|       |    /*
 4303|       |     * reports shouldn't cache previous data. 
 4304|       |     */
 4305|       |    /*
 4306|       |     * FIX - yes they should but USM needs to follow new EoP to determine
 4307|       |     * which cached values to use 
 4308|       |     */
 4309|     20|    free_securityStateRef(pdu);
 4310|       |
 4311|     20|    if (error == SNMPERR_USM_NOTINTIMEWINDOW) {
  ------------------
  |  |  233|     20|#define SNMPERR_USM_NOTINTIMEWINDOW		(-49)
  ------------------
  |  Branch (4311:9): [True: 0, False: 20]
  ------------------
 4312|      0|        pdu->securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
  ------------------
  |  |  300|      0|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
 4313|     20|    } else {
 4314|     20|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|     20|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4315|     20|    }
 4316|       |
 4317|       |    /*
 4318|       |     * find the appropriate error counter  
 4319|       |     */
 4320|     20|#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
 4321|     20|    ltmp = snmp_get_statistic(stat_ind);
 4322|       |#else /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4323|       |    ltmp = 1;
 4324|       |#endif /* !NETSNMP_FEATURE_REMOVE_STATISTICS */
 4325|       |
 4326|       |    /*
 4327|       |     * return the appropriate error counter  
 4328|       |     */
 4329|     20|    snmp_pdu_add_variable(pdu, err_var, err_var_len,
 4330|     20|                          ASN_COUNTER, & ltmp, sizeof(ltmp));
  ------------------
  |  |   89|     20|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
 4331|       |
 4332|     20|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     20|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 4333|     20|}                               /* end snmpv3_make_report() */
snmp_parse:
 4714|    183|{
 4715|    183|    int             rc;
 4716|       |
 4717|    183|    rc = _snmp_parse(slp, pss, pdu, data, length);
 4718|    183|    if (rc) {
  ------------------
  |  Branch (4718:9): [True: 183, False: 0]
  ------------------
 4719|    183|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (4719:13): [True: 36, False: 147]
  ------------------
 4720|     36|            pss->s_snmp_errno = SNMPERR_BAD_PARSE;
  ------------------
  |  |  197|     36|#define SNMPERR_BAD_PARSE		(-13)
  ------------------
 4721|     36|        }
 4722|    183|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|    183|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 4723|    183|    }
 4724|       |
 4725|    183|    return rc;
 4726|    183|}
snmp_pdu_parse:
 4730|      2|{
 4731|      2|    u_char          type;
 4732|      2|    u_char          msg_type;
 4733|      2|    u_char         *var_val;
 4734|      2|    size_t          len;
 4735|      2|    size_t          four;
 4736|      2|    netsnmp_variable_list *vp = NULL, *vplast = NULL;
 4737|      2|    oid             objid[MAX_OID_LEN];
 4738|      2|    u_char         *p;
 4739|       |
 4740|       |    /*
 4741|       |     * Get the PDU type 
 4742|       |     */
 4743|      2|    data = asn_parse_header(data, length, &msg_type);
 4744|      2|    if (data == NULL)
  ------------------
  |  Branch (4744:9): [True: 0, False: 2]
  ------------------
 4745|      0|        return -1;
 4746|      2|    DEBUGMSGTL(("dumpv_recv","    Command %s\n", snmp_pdu_type(msg_type)));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4747|      2|    pdu->command = msg_type;
 4748|      2|    pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);
  ------------------
  |  |  311|      2|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4749|       |
 4750|       |    /*
 4751|       |     * get the fields in the PDU preceding the variable-bindings sequence
 4752|       |     */
 4753|      2|    switch (pdu->command) {
 4754|      2|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|      2|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|      2|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|      2|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4754:5): [True: 2, False: 0]
  ------------------
 4755|       |        /*
 4756|       |         * enterprise 
 4757|       |         */
 4758|      2|        pdu->enterprise_length = MAX_OID_LEN;
  ------------------
  |  |  120|      2|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4759|      2|        data = asn_parse_objid(data, length, &type, objid,
 4760|      2|                               &pdu->enterprise_length);
 4761|      2|        if (data == NULL)
  ------------------
  |  Branch (4761:13): [True: 1, False: 1]
  ------------------
 4762|      1|            return -1;
 4763|      1|        pdu->enterprise = netsnmp_memdup(objid,
 4764|      1|                                         pdu->enterprise_length * sizeof(oid));
 4765|      1|        if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (4765:13): [True: 0, False: 1]
  ------------------
 4766|      0|            return -1;
 4767|      0|        }
 4768|       |
 4769|       |        /*
 4770|       |         * agent-addr 
 4771|       |         */
 4772|      1|        four = 4;
 4773|      1|        data = asn_parse_string(data, length, &type,
 4774|      1|                                (u_char *) pdu->agent_addr, &four);
 4775|      1|        if (data == NULL)
  ------------------
  |  Branch (4775:13): [True: 0, False: 1]
  ------------------
 4776|      0|            return -1;
 4777|       |
 4778|       |        /*
 4779|       |         * generic trap 
 4780|       |         */
 4781|      1|        data = asn_parse_int(data, length, &type, (long *) &pdu->trap_type,
 4782|      1|                             sizeof(pdu->trap_type));
 4783|      1|        if (data == NULL)
  ------------------
  |  Branch (4783:13): [True: 0, False: 1]
  ------------------
 4784|      0|            return -1;
 4785|       |        /*
 4786|       |         * specific trap 
 4787|       |         */
 4788|      1|        data =
 4789|      1|            asn_parse_int(data, length, &type,
 4790|      1|                          (long *) &pdu->specific_type,
 4791|      1|                          sizeof(pdu->specific_type));
 4792|      1|        if (data == NULL)
  ------------------
  |  Branch (4792:13): [True: 1, False: 0]
  ------------------
 4793|      1|            return -1;
 4794|       |
 4795|       |        /*
 4796|       |         * timestamp  
 4797|       |         */
 4798|      0|        data = asn_parse_unsigned_int(data, length, &type, &pdu->time,
 4799|      0|                                      sizeof(pdu->time));
 4800|      0|        if (data == NULL)
  ------------------
  |  Branch (4800:13): [True: 0, False: 0]
  ------------------
 4801|      0|            return -1;
 4802|       |
 4803|      0|        break;
 4804|       |
 4805|      0|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4805:5): [True: 0, False: 2]
  ------------------
 4806|      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 (4806:5): [True: 0, False: 2]
  ------------------
 4807|      0|        pdu->flags |= UCD_MSG_FLAG_RESPONSE_PDU;
  ------------------
  |  |  311|      0|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4808|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4809|       |
 4810|      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 (4810:5): [True: 0, False: 2]
  ------------------
 4811|      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 (4811:5): [True: 0, False: 2]
  ------------------
 4812|      0|#ifndef NETSNMP_NOTIFY_ONLY
 4813|      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 (4813:5): [True: 0, False: 2]
  ------------------
 4814|      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 (4814:5): [True: 0, False: 2]
  ------------------
 4815|      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 (4815:5): [True: 0, False: 2]
  ------------------
 4816|      0|#endif /* ! NETSNMP_NOTIFY_ONLY */
 4817|      0|#ifndef NETSNMP_NO_WRITE_SUPPORT
 4818|      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 (4818:5): [True: 0, False: 2]
  ------------------
 4819|      0|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 4820|       |        /*
 4821|       |         * PDU is not an SNMPv1 TRAP 
 4822|       |         */
 4823|       |
 4824|       |        /*
 4825|       |         * request id 
 4826|       |         */
 4827|      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]
  |  |  ------------------
  ------------------
 4828|      0|        data = asn_parse_int(data, length, &type, &pdu->reqid,
 4829|      0|                             sizeof(pdu->reqid));
 4830|      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]
  |  |  ------------------
  ------------------
 4831|      0|        if (data == NULL) {
  ------------------
  |  Branch (4831:13): [True: 0, False: 0]
  ------------------
 4832|      0|            return -1;
 4833|      0|        }
 4834|       |
 4835|       |        /*
 4836|       |         * error status (getbulk non-repeaters) 
 4837|       |         */
 4838|      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]
  |  |  ------------------
  ------------------
 4839|      0|        data = asn_parse_int(data, length, &type, &pdu->errstat,
 4840|      0|                             sizeof(pdu->errstat));
 4841|      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]
  |  |  ------------------
  ------------------
 4842|      0|        if (data == NULL) {
  ------------------
  |  Branch (4842:13): [True: 0, False: 0]
  ------------------
 4843|      0|            return -1;
 4844|      0|        }
 4845|       |
 4846|       |        /*
 4847|       |         * error index (getbulk max-repetitions) 
 4848|       |         */
 4849|      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]
  |  |  ------------------
  ------------------
 4850|      0|        data = asn_parse_int(data, length, &type, &pdu->errindex,
 4851|      0|                             sizeof(pdu->errindex));
 4852|      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]
  |  |  ------------------
  ------------------
 4853|      0|        if (data == NULL) {
  ------------------
  |  Branch (4853:13): [True: 0, False: 0]
  ------------------
 4854|      0|            return -1;
 4855|      0|        }
 4856|      0|	break;
 4857|       |
 4858|      0|    default:
  ------------------
  |  Branch (4858:5): [True: 0, False: 2]
  ------------------
 4859|      0|        snmp_log(LOG_ERR, "Bad PDU type received: 0x%.2x\n", pdu->command);
 4860|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4861|      0|        return -1;
 4862|      2|    }
 4863|       |
 4864|       |    /*
 4865|       |     * get header for variable-bindings sequence 
 4866|       |     */
 4867|      0|    DEBUGDUMPSECTION("recv", "VarBindList");
  ------------------
  |  |   81|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4868|      0|    data = asn_parse_sequence(data, length, &type,
 4869|      0|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      0|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 4870|      0|                              "varbinds");
 4871|      0|    if (data == NULL)
  ------------------
  |  Branch (4871:9): [True: 0, False: 0]
  ------------------
 4872|      0|        goto fail;
 4873|       |
 4874|       |    /*
 4875|       |     * get each varBind sequence 
 4876|       |     */
 4877|      0|    while ((int) *length > 0) {
  ------------------
  |  Branch (4877:12): [True: 0, False: 0]
  ------------------
 4878|      0|        vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 4879|      0|        if (NULL == vp)
  ------------------
  |  Branch (4879:13): [True: 0, False: 0]
  ------------------
 4880|      0|            goto fail;
 4881|       |
 4882|      0|        vp->name_length = MAX_OID_LEN;
  ------------------
  |  |  120|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4883|      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]
  |  |  ------------------
  ------------------
 4884|      0|        data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
 4885|      0|                                 &vp->val_len, &var_val, length);
 4886|      0|        if (data == NULL)
  ------------------
  |  Branch (4886:13): [True: 0, False: 0]
  ------------------
 4887|      0|            goto fail;
 4888|      0|        if (snmp_set_var_objid(vp, objid, vp->name_length))
  ------------------
  |  Branch (4888:13): [True: 0, False: 0]
  ------------------
 4889|      0|            goto fail;
 4890|       |
 4891|      0|        len = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 4892|      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]
  |  |  ------------------
  ------------------
 4893|      0|        switch ((short) vp->type) {
 4894|      0|        case ASN_INTEGER:
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4894:9): [True: 0, False: 0]
  ------------------
 4895|      0|            vp->val.integer = (long *) vp->buf;
 4896|      0|            vp->val_len = sizeof(long);
 4897|      0|            p = asn_parse_int(var_val, &len, &vp->type,
 4898|      0|                          (long *) vp->val.integer,
 4899|      0|                          sizeof(*vp->val.integer));
 4900|      0|            if (!p)
  ------------------
  |  Branch (4900:17): [True: 0, False: 0]
  ------------------
 4901|      0|                goto fail;
 4902|      0|            break;
 4903|      0|        case ASN_COUNTER:
  ------------------
  |  |   89|      0|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4903:9): [True: 0, False: 0]
  ------------------
 4904|      0|        case ASN_GAUGE:
  ------------------
  |  |   90|      0|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4904:9): [True: 0, False: 0]
  ------------------
 4905|      0|        case ASN_TIMETICKS:
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4905:9): [True: 0, False: 0]
  ------------------
 4906|      0|        case ASN_UINTEGER:
  ------------------
  |  |  100|      0|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4906:9): [True: 0, False: 0]
  ------------------
 4907|      0|            vp->val.integer = (long *) vp->buf;
 4908|      0|            vp->val_len = sizeof(u_long);
 4909|      0|            p = asn_parse_unsigned_int(var_val, &len, &vp->type,
 4910|      0|                                   (u_long *) vp->val.integer,
 4911|      0|                                   vp->val_len);
 4912|      0|            if (!p)
  ------------------
  |  Branch (4912:17): [True: 0, False: 0]
  ------------------
 4913|      0|                goto fail;
 4914|      0|            break;
 4915|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4916|      0|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|      0|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|      0|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4916:9): [True: 0, False: 0]
  ------------------
 4917|      0|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|      0|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|      0|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4917:9): [True: 0, False: 0]
  ------------------
 4918|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4919|      0|        case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4919:9): [True: 0, False: 0]
  ------------------
 4920|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4921|      0|            vp->val_len = sizeof(struct counter64);
 4922|      0|            p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
 4923|      0|                                     (struct counter64 *) vp->val.
 4924|      0|                                     counter64, vp->val_len);
 4925|      0|            if (!p)
  ------------------
  |  Branch (4925:17): [True: 0, False: 0]
  ------------------
 4926|      0|                goto fail;
 4927|      0|            break;
 4928|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4929|      0|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|      0|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|      0|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4929:9): [True: 0, False: 0]
  ------------------
 4930|      0|            vp->val.floatVal = (float *) vp->buf;
 4931|      0|            vp->val_len = sizeof(float);
 4932|      0|            p = asn_parse_float(var_val, &len, &vp->type,
 4933|      0|                            vp->val.floatVal, vp->val_len);
 4934|      0|            if (!p)
  ------------------
  |  Branch (4934:17): [True: 0, False: 0]
  ------------------
 4935|      0|                goto fail;
 4936|      0|            break;
 4937|      0|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|      0|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|      0|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4937:9): [True: 0, False: 0]
  ------------------
 4938|      0|            vp->val.doubleVal = (double *) vp->buf;
 4939|      0|            vp->val_len = sizeof(double);
 4940|      0|            p = asn_parse_double(var_val, &len, &vp->type,
 4941|      0|                             vp->val.doubleVal, vp->val_len);
 4942|      0|            if (!p)
  ------------------
  |  Branch (4942:17): [True: 0, False: 0]
  ------------------
 4943|      0|                goto fail;
 4944|      0|            break;
 4945|      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 (4945:9): [True: 0, False: 0]
  ------------------
 4946|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4947|      0|            vp->val_len = sizeof(struct counter64);
 4948|      0|            p = asn_parse_signed_int64(var_val, &len, &vp->type,
 4949|      0|                                   (struct counter64 *) vp->val.counter64,
 4950|      0|                                   sizeof(*vp->val.counter64));
 4951|       |
 4952|      0|            if (!p)
  ------------------
  |  Branch (4952:17): [True: 0, False: 0]
  ------------------
 4953|      0|                goto fail;
 4954|      0|            break;
 4955|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4956|      0|        case ASN_IPADDRESS:
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4956:9): [True: 0, False: 0]
  ------------------
 4957|      0|            if (vp->val_len != 4)
  ------------------
  |  Branch (4957:17): [True: 0, False: 0]
  ------------------
 4958|      0|                goto fail;
 4959|      0|            NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4960|      0|        case ASN_OCTET_STR:
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4960:9): [True: 0, False: 0]
  ------------------
 4961|      0|        case ASN_OPAQUE:
  ------------------
  |  |   93|      0|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4961:9): [True: 0, False: 0]
  ------------------
 4962|      0|        case ASN_NSAP:
  ------------------
  |  |   98|      0|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4962:9): [True: 0, False: 0]
  ------------------
 4963|      0|            if (vp->val_len < sizeof(vp->buf)) {
  ------------------
  |  Branch (4963:17): [True: 0, False: 0]
  ------------------
 4964|      0|                vp->val.string = (u_char *) vp->buf;
 4965|      0|            } else {
 4966|      0|                vp->val.string = (u_char *) malloc(vp->val_len);
 4967|      0|            }
 4968|      0|            if (vp->val.string == NULL) {
  ------------------
  |  Branch (4968:17): [True: 0, False: 0]
  ------------------
 4969|      0|                goto fail;
 4970|      0|            }
 4971|      0|            p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
 4972|      0|                             &vp->val_len);
 4973|      0|            if (!p)
  ------------------
  |  Branch (4973:17): [True: 0, False: 0]
  ------------------
 4974|      0|                goto fail;
 4975|      0|            break;
 4976|      0|        case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (4976:9): [True: 0, False: 0]
  ------------------
 4977|      0|            vp->val_len = MAX_OID_LEN;
  ------------------
  |  |  120|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4978|      0|            p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
 4979|      0|            if (!p)
  ------------------
  |  Branch (4979:17): [True: 0, False: 0]
  ------------------
 4980|      0|                goto fail;
 4981|      0|            vp->val_len *= sizeof(oid);
 4982|      0|            vp->val.objid = netsnmp_memdup(objid, vp->val_len);
 4983|      0|            if (vp->val.objid == NULL)
  ------------------
  |  Branch (4983:17): [True: 0, False: 0]
  ------------------
 4984|      0|                goto fail;
 4985|      0|            break;
 4986|      0|        case SNMP_NOSUCHOBJECT:
  ------------------
  |  |  201|      0|#define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4986:9): [True: 0, False: 0]
  ------------------
 4987|      0|        case SNMP_NOSUCHINSTANCE:
  ------------------
  |  |  202|      0|#define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4987:9): [True: 0, False: 0]
  ------------------
 4988|      0|        case SNMP_ENDOFMIBVIEW:
  ------------------
  |  |  203|      0|#define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4988:9): [True: 0, False: 0]
  ------------------
 4989|      0|        case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (4989:9): [True: 0, False: 0]
  ------------------
 4990|      0|            break;
 4991|      0|        case ASN_BIT_STR:
  ------------------
  |  |   77|      0|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (4991:9): [True: 0, False: 0]
  ------------------
 4992|      0|            vp->val.bitstring = (u_char *) malloc(vp->val_len);
 4993|      0|            if (vp->val.bitstring == NULL) {
  ------------------
  |  Branch (4993:17): [True: 0, False: 0]
  ------------------
 4994|      0|                goto fail;
 4995|      0|            }
 4996|      0|            p = asn_parse_bitstring(var_val, &len, &vp->type,
 4997|      0|                                vp->val.bitstring, &vp->val_len);
 4998|      0|            if (!p)
  ------------------
  |  Branch (4998:17): [True: 0, False: 0]
  ------------------
 4999|      0|                goto fail;
 5000|      0|            break;
 5001|      0|        default:
  ------------------
  |  Branch (5001:9): [True: 0, False: 0]
  ------------------
 5002|      0|            snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
 5003|      0|            goto fail;
 5004|      0|            break;
 5005|      0|        }
 5006|      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]
  |  |  ------------------
  ------------------
 5007|       |
 5008|      0|        if (NULL == vplast) {
  ------------------
  |  Branch (5008:13): [True: 0, False: 0]
  ------------------
 5009|      0|            pdu->variables = vp;
 5010|      0|        } else {
 5011|      0|            vplast->next_variable = vp;
 5012|      0|        }
 5013|      0|        vplast = vp;
 5014|      0|        vp = NULL;
 5015|      0|    }
 5016|      0|    return 0;
 5017|       |
 5018|      0|  fail:
 5019|      0|    {
 5020|      0|        const char *errstr = snmp_api_errstring(SNMPERR_SUCCESS);
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5021|      0|        DEBUGMSGTL(("recv", "error while parsing VarBindList:%s\n", errstr));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5022|      0|    }
 5023|       |    /** if we were parsing a var, remove it from the pdu and free it */
 5024|      0|    if (vp)
  ------------------
  |  Branch (5024:9): [True: 0, False: 0]
  ------------------
 5025|      0|        snmp_free_var(vp);
 5026|       |
 5027|      0|    return -1;
 5028|      0|}
snmpv3_scopedPDU_parse:
 5039|     22|{
 5040|     22|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 5041|     22|    size_t          tmp_buf_len;
 5042|     22|    u_char          type;
 5043|     22|    size_t          asn_len;
 5044|     22|    u_char         *data;
 5045|       |
 5046|     22|    pdu->command = 0;           /* initialize so we know if it got parsed */
 5047|     22|    asn_len = *length;
 5048|     22|    data = asn_parse_sequence(cp, &asn_len, &type,
 5049|     22|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|     22|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     22|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 5050|     22|                              "plaintext scopedPDU");
 5051|     22|    if (data == NULL) {
  ------------------
  |  Branch (5051:9): [True: 14, False: 8]
  ------------------
 5052|     14|        return NULL;
 5053|     14|    }
 5054|      8|    *length -= data - cp;
 5055|       |
 5056|       |    /*
 5057|       |     * contextEngineID from scopedPdu  
 5058|       |     */
 5059|      8|    DEBUGDUMPHEADER("recv", "contextEngineID");
  ------------------
  |  |   79|      8|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 8]
  |  |  ------------------
  ------------------
 5060|      8|    data = asn_parse_string(data, length, &type, pdu->contextEngineID,
 5061|      8|                            &pdu->contextEngineIDLen);
 5062|      8|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      8|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 8]
  |  |  ------------------
  ------------------
 5063|      8|    if (data == NULL) {
  ------------------
  |  Branch (5063:9): [True: 8, False: 0]
  ------------------
 5064|      8|        ERROR_MSG("error parsing contextEngineID from scopedPdu");
  ------------------
  |  |  188|      8|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5065|      8|        return NULL;
 5066|      8|    }
 5067|       |
 5068|       |    /*
 5069|       |     * parse contextName from scopedPdu
 5070|       |     */
 5071|      0|    tmp_buf_len = SNMP_MAX_CONTEXT_SIZE;
  ------------------
  |  |  113|      0|#define SNMP_MAX_CONTEXT_SIZE      256
  ------------------
 5072|      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]
  |  |  ------------------
  ------------------
 5073|      0|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 5074|      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]
  |  |  ------------------
  ------------------
 5075|      0|    if (data == NULL) {
  ------------------
  |  Branch (5075:9): [True: 0, False: 0]
  ------------------
 5076|      0|        ERROR_MSG("error parsing contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5077|      0|        return NULL;
 5078|      0|    }
 5079|       |
 5080|      0|    if (tmp_buf_len) {
  ------------------
  |  Branch (5080:9): [True: 0, False: 0]
  ------------------
 5081|      0|        pdu->contextName = netsnmp_memdup(tmp_buf, tmp_buf_len);
 5082|      0|        pdu->contextNameLen = tmp_buf_len;
 5083|      0|    } else {
 5084|      0|        pdu->contextName = strdup("");
 5085|      0|        pdu->contextNameLen = 0;
 5086|      0|    }
 5087|      0|    if (pdu->contextName == NULL) {
  ------------------
  |  Branch (5087:9): [True: 0, False: 0]
  ------------------
 5088|      0|        ERROR_MSG("error copying contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5089|      0|        return NULL;
 5090|      0|    }
 5091|       |
 5092|       |    /*
 5093|       |     * Get the PDU type 
 5094|       |     */
 5095|      0|    asn_len = *length;
 5096|      0|    cp = asn_parse_header(data, &asn_len, &type);
 5097|      0|    if (cp == NULL)
  ------------------
  |  Branch (5097:9): [True: 0, False: 0]
  ------------------
 5098|      0|        return NULL;
 5099|       |
 5100|      0|    pdu->command = type;
 5101|       |
 5102|      0|    return data;
 5103|      0|}
_build_initial_pdu_packet:
 5149|     20|{
 5150|     20|    netsnmp_session *session;
 5151|     20|    struct snmp_internal_session *isp;
 5152|     20|    netsnmp_transport *transport = NULL;
 5153|     20|    u_char         *pktbuf = NULL, *packet = NULL;
 5154|     20|    size_t          pktbuf_len = 0, length = 0, orig_length = 0;
 5155|     20|    int             result, orig_count = 0, curr_count = 0;
 5156|       |
 5157|     20|    if (slp == NULL) {
  ------------------
  |  Branch (5157:9): [True: 0, False: 20]
  ------------------
 5158|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5159|      0|    }
 5160|     20|    session = slp->session;
 5161|       |
 5162|     20|    isp = slp->internal;
 5163|     20|    transport = slp->transport;
 5164|     20|    if (!session || !isp || !transport) {
  ------------------
  |  Branch (5164:9): [True: 0, False: 20]
  |  Branch (5164:21): [True: 0, False: 20]
  |  Branch (5164:29): [True: 0, False: 20]
  ------------------
 5165|      0|        DEBUGMSGTL(("sess_async_send", "send fail: closing...\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]
  |  |  ------------------
  ------------------
 5166|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5167|      0|    }
 5168|       |
 5169|     20|    if (pdu == NULL) {
  ------------------
  |  Branch (5169:9): [True: 0, False: 20]
  ------------------
 5170|      0|        session->s_snmp_errno = SNMPERR_NULL_PDU;
  ------------------
  |  |  243|      0|#define SNMPERR_NULL_PDU		(-59)
  ------------------
 5171|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5172|      0|    }
 5173|       |
 5174|     20|    SNMP_FREE(isp->obuf); /* should already be NULL */
  ------------------
  |  |   62|     20|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 20]
  |  |  |  Branch (62:66): [Folded, False: 20]
  |  |  ------------------
  ------------------
 5175|       |
 5176|     20|    session->s_snmp_errno = 0;
 5177|     20|    session->s_errno = 0;
 5178|       |
 5179|       |    /*
 5180|       |     * Check/setup the version.  
 5181|       |     */
 5182|     20|    if (pdu->version == SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|     20|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (5182:9): [True: 0, False: 20]
  ------------------
 5183|      0|        if (session->version == SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|      0|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (5183:13): [True: 0, False: 0]
  ------------------
 5184|      0|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 5185|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5186|      0|        }
 5187|      0|        pdu->version = session->version;
 5188|     20|    } else if (session->version == SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|     20|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (5188:16): [True: 20, False: 0]
  ------------------
 5189|       |        /*
 5190|       |         * It's OK  
 5191|       |         */
 5192|     20|    } else if (pdu->version != session->version) {
  ------------------
  |  Branch (5192:16): [True: 0, False: 0]
  ------------------
 5193|       |        /*
 5194|       |         * ENHANCE: we should support multi-lingual sessions  
 5195|       |         */
 5196|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 5197|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5198|      0|    }
 5199|     20|    if (NETSNMP_RUNTIME_PROTOCOL_SKIP(pdu->version)) {
  ------------------
  |  |  246|     20|    (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||        \
  |  |  ------------------
  |  |  |  |  205|     40|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|     40|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  206|     40|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  207|      0|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|      0|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  247|     20|     NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) ||        \
  |  |  ------------------
  |  |  |  |  215|     40|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     40|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  216|     40|     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 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|     20|     NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver))
  |  |  ------------------
  |  |  |  |  229|     20|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|     20|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  230|     20|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|     20|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  231|     20|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|     20|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5200|      0|        DEBUGMSGTL(("sess_async_send", "version disabled at runtime\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]
  |  |  ------------------
  ------------------
 5201|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 5202|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5203|      0|    }
 5204|       |
 5205|       |    /*
 5206|       |     * do we expect a response?
 5207|       |     */
 5208|     20|    switch (pdu->command) {
 5209|       |
 5210|      0|        case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (5210:9): [True: 0, False: 20]
  ------------------
 5211|      0|        case SNMP_MSG_TRAP:
  ------------------
  |  |  135|      0|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (5211:9): [True: 0, False: 20]
  ------------------
 5212|      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 (5212:9): [True: 0, False: 20]
  ------------------
 5213|     20|        case SNMP_MSG_REPORT:
  ------------------
  |  |  147|     20|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (5213:9): [True: 20, False: 0]
  ------------------
 5214|     20|        case AGENTX_MSG_CLEANUPSET:
  ------------------
  |  |   45|     20|#define AGENTX_MSG_CLEANUPSET ((u_char)11)
  ------------------
  |  Branch (5214:9): [True: 0, False: 20]
  ------------------
 5215|     20|        case AGENTX_MSG_RESPONSE:
  ------------------
  |  |   52|     20|#define AGENTX_MSG_RESPONSE    ((u_char)18)
  ------------------
  |  Branch (5215:9): [True: 0, False: 20]
  ------------------
 5216|     20|            pdu->flags &= ~UCD_MSG_FLAG_EXPECT_RESPONSE;
  ------------------
  |  |  312|     20|#define UCD_MSG_FLAG_EXPECT_RESPONSE         0x200
  ------------------
 5217|     20|            break;
 5218|       |            
 5219|      0|        default:
  ------------------
  |  Branch (5219:9): [True: 0, False: 20]
  ------------------
 5220|      0|            pdu->flags |= UCD_MSG_FLAG_EXPECT_RESPONSE;
  ------------------
  |  |  312|      0|#define UCD_MSG_FLAG_EXPECT_RESPONSE         0x200
  ------------------
 5221|      0|            break;
 5222|     20|    }
 5223|       |
 5224|       |    /*
 5225|       |     * Check if we need to perform a v3 engineID probe. Call post probe hook to
 5226|       |     * create user from information in a session even if SNMP_FLAGS_DONT_PROBE
 5227|       |     * is set, as this may indicate that probe was already sent by other means
 5228|       |     * for example asynchronously.
 5229|       |     */
 5230|     20|    if ((pdu->version == SNMP_VERSION_3) &&
  ------------------
  |  |  113|     20|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (5230:9): [True: 20, False: 0]
  ------------------
 5231|     20|        (pdu->flags & UCD_MSG_FLAG_EXPECT_RESPONSE)) {
  ------------------
  |  |  312|     20|#define UCD_MSG_FLAG_EXPECT_RESPONSE         0x200
  ------------------
  |  Branch (5231:9): [True: 0, False: 20]
  ------------------
 5232|      0|        int rc;
 5233|      0|        DEBUGMSGTL(("snmpv3_build", "delayed probe for engineID\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]
  |  |  ------------------
  ------------------
 5234|      0|        rc = snmpv3_engineID_probe(slp, session);
 5235|      0|        if (rc == 0)
  ------------------
  |  Branch (5235:13): [True: 0, False: 0]
  ------------------
 5236|      0|            return 0; /* s_snmp_errno already set */
 5237|      0|    }
 5238|       |
 5239|       |    /*
 5240|       |     * determine max packet size
 5241|       |     */
 5242|     20|    if (pdu->msgMaxSize == 0) {
  ------------------
  |  Branch (5242:9): [True: 0, False: 20]
  ------------------
 5243|      0|        pdu->msgMaxSize = netsnmp_max_send_msg_size();
 5244|      0|        if (pdu->msgMaxSize > transport->msgMaxSize)
  ------------------
  |  Branch (5244:13): [True: 0, False: 0]
  ------------------
 5245|      0|            pdu->msgMaxSize = transport->msgMaxSize;
 5246|      0|        if (pdu->msgMaxSize > session->sndMsgMaxSize)
  ------------------
  |  Branch (5246:13): [True: 0, False: 0]
  ------------------
 5247|      0|            pdu->msgMaxSize = session->sndMsgMaxSize;
 5248|      0|        DEBUGMSGTL(("sess_async_send", "max PDU size: %ld\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]
  |  |  ------------------
  ------------------
 5249|      0|                    pdu->msgMaxSize));
 5250|      0|    }
 5251|     20|    netsnmp_assert(pdu->msgMaxSize > 0);
  ------------------
  |  |   47|     20|#      define netsnmp_assert(x)  do { \
  |  |   48|     20|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 20, False: 0]
  |  |  ------------------
  |  |   49|     20|                 ; \
  |  |   50|     20|              else \
  |  |   51|     20|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     20|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 20]
  |  |  ------------------
  ------------------
 5252|       |
 5253|       |    /*
 5254|       |     * allocate initial packet buffer. Buffer will be grown as needed
 5255|       |     * while building the packet.
 5256|       |     */
 5257|     20|    pktbuf_len = SNMP_MIN_MAX_LEN;
  ------------------
  |  |   48|     20|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
 5258|     20|    if ((pktbuf = (u_char *)malloc(pktbuf_len)) == NULL) {
  ------------------
  |  Branch (5258:9): [True: 0, False: 20]
  ------------------
 5259|      0|        DEBUGMSGTL(("sess_async_send",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5260|      0|                    "couldn't malloc initial packet buffer\n"));
 5261|      0|        session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 5262|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 5263|      0|    }
 5264|       |
 5265|       |#ifdef TEMPORARILY_DISABLED
 5266|       |    /*
 5267|       |     *  NULL variable are allowed in certain PDU types.
 5268|       |     *  In particular, SNMPv3 engineID probes are of this form.
 5269|       |     *  There is an internal PDU flag to indicate that this
 5270|       |     *    is acceptable, but until the construction of engineID
 5271|       |     *    probes can be amended to set this flag, we'll simply
 5272|       |     *    skip this test altogether.
 5273|       |     */
 5274|       |    if (pdu->variables == NULL) {
 5275|       |        switch (pdu->command) {
 5276|       |#ifndef NETSNMP_NO_WRITE_SUPPORT
 5277|       |        case SNMP_MSG_SET:
 5278|       |#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 5279|       |        case SNMP_MSG_GET:
 5280|       |        case SNMP_MSG_GETNEXT:
 5281|       |        case SNMP_MSG_GETBULK:
 5282|       |        case SNMP_MSG_RESPONSE:
 5283|       |        case SNMP_MSG_TRAP2:
 5284|       |        case SNMP_MSG_REPORT:
 5285|       |        case SNMP_MSG_INFORM:
 5286|       |            session->s_snmp_errno = snmp_errno = SNMPERR_NO_VARS;
 5287|       |            return SNMPERR_NO_VARS;
 5288|       |        case SNMP_MSG_TRAP:
 5289|       |            break;
 5290|       |        }
 5291|       |    }
 5292|       |#endif
 5293|       |
 5294|       |
 5295|       |    /*
 5296|       |     * Build the message to send. If a bulk response is too big, switch to
 5297|       |     * forward encoding and set a flag to drop varbinds to make it fit.
 5298|       |     */
 5299|     20|    do {
 5300|     20|        packet = NULL;
 5301|     20|        length = 0;
 5302|     20|        result = netsnmp_build_packet(isp, session, pdu, &pktbuf, &pktbuf_len,
 5303|     20|                                      &packet, &length);
 5304|     20|        if (0 != result)
  ------------------
  |  Branch (5304:13): [True: 0, False: 20]
  ------------------
 5305|      0|            break;
 5306|       |
 5307|     20|        if (orig_count) { /* 2nd pass, see how many varbinds remain */
  ------------------
  |  Branch (5307:13): [True: 0, False: 20]
  ------------------
 5308|      0|            curr_count = count_varbinds(pdu->variables);
 5309|      0|            DEBUGMSGTL(("sess_async_send", " vb count: %d -> %d\n", orig_count,
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5310|      0|                        curr_count));
 5311|      0|            DEBUGMSGTL(("sess_async_send", " pdu_len: %" NETSNMP_PRIz "d -> %" NETSNMP_PRIz "d (max %ld)\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]
  |  |  ------------------
  ------------------
 5312|      0|                        orig_length, length, pdu->msgMaxSize));
 5313|      0|        }
 5314|       |
 5315|       |        /** if length is less than max size, we're done (success). */
 5316|     20|        if (length <= pdu->msgMaxSize)
  ------------------
  |  Branch (5316:13): [True: 20, False: 0]
  ------------------
 5317|     20|            break;
 5318|       |
 5319|      0|        DEBUGMSGTL(("sess_async_send", "length %" NETSNMP_PRIz "d exceeds maximum %ld\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]
  |  |  ------------------
  ------------------
 5320|      0|                    length, pdu->msgMaxSize));
 5321|       |
 5322|       |        /** packet too big. if this is not a bulk request, we're done (err). */
 5323|      0|        if (!bulk) {
  ------------------
  |  Branch (5323:13): [True: 0, False: 0]
  ------------------
 5324|      0|           session->s_snmp_errno = SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 5325|      0|           break;
 5326|      0|        }
 5327|       |
 5328|       |        /** rebuild bulk response with truncation and fixed size */
 5329|      0|        pdu->flags |= UCD_MSG_FLAG_FORWARD_ENCODE | UCD_MSG_FLAG_BULK_TOOBIG;
  ------------------
  |  |  319|      0|#define UCD_MSG_FLAG_FORWARD_ENCODE         0x8000
  ------------------
                      pdu->flags |= UCD_MSG_FLAG_FORWARD_ENCODE | UCD_MSG_FLAG_BULK_TOOBIG;
  ------------------
  |  |  321|      0|#define UCD_MSG_FLAG_BULK_TOOBIG          0x010000
  ------------------
 5330|      0|        pktbuf_len = pdu->msgMaxSize;
 5331|       |
 5332|       |        /** save original number of varbinds & length */
 5333|      0|        if (0 == orig_count) {
  ------------------
  |  Branch (5333:13): [True: 0, False: 0]
  ------------------
 5334|      0|            curr_count = orig_count = count_varbinds(pdu->variables);
 5335|      0|            orig_length = length;
 5336|      0|        }
 5337|       |
 5338|      0|    } while(1);
  ------------------
  |  Branch (5338:13): [True: 0, Folded]
  ------------------
 5339|       |
 5340|     20|    DEBUGMSGTL(("sess_async_send",
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 5341|     20|                "final pktbuf_len after building packet %" NETSNMP_PRIz "u\n",
 5342|     20|                pktbuf_len));
 5343|     20|    if (curr_count != orig_count)
  ------------------
  |  Branch (5343:9): [True: 0, False: 20]
  ------------------
 5344|      0|        DEBUGMSGTL(("sess_async_send",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5345|     20|                    "sending %d of %d varbinds (-%d) from bulk response\n",
 5346|     20|                    curr_count, orig_count, orig_count - curr_count));
 5347|       |
 5348|     20|    if (length > pdu->msgMaxSize) {
  ------------------
  |  Branch (5348:9): [True: 0, False: 20]
  ------------------
 5349|      0|        DEBUGMSGTL(("sess_async_send",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5350|      0|                    "length of packet (%" NETSNMP_PRIz "u) exceeded pdu maximum (%lu)\n",
 5351|      0|                    length, pdu->msgMaxSize));
 5352|      0|        netsnmp_assert(SNMPERR_TOO_LONG == session->s_snmp_errno);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5353|      0|    }
 5354|       |
 5355|     20|    if ((SNMPERR_TOO_LONG == session->s_snmp_errno) || (result < 0)) {
  ------------------
  |  |  189|     20|#define SNMPERR_TOO_LONG		(-5)
  ------------------
  |  Branch (5355:9): [True: 0, False: 20]
  |  Branch (5355:56): [True: 0, False: 20]
  ------------------
 5356|      0|        DEBUGMSGTL(("sess_async_send", "encoding failure\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]
  |  |  ------------------
  ------------------
 5357|      0|        SNMP_FREE(pktbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 5358|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5359|      0|    }
 5360|       |
 5361|     20|    isp->obuf = pktbuf;
 5362|     20|    isp->obuf_size = pktbuf_len;
 5363|     20|    isp->opacket = packet;
 5364|     20|    isp->opacket_len = length;
 5365|       |
 5366|     20|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     20|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5367|     20|}
snmp_sess_send:
 5399|     20|{
 5400|     20|    return snmp_sess_async_send(slp, pdu, NULL, NULL);
 5401|     20|}
snmp_sess_async_send:
 5616|     20|{
 5617|       |
 5618|     20|    return snmp_sess_async_send_cp(slp, pdu, callback, cb_data, 0);
 5619|     20|}
snmp_sess_async_send_cp:
 5625|     20|{
 5626|     20|    int             rc;
 5627|       |
 5628|     20|    if (slp == NULL) {
  ------------------
  |  Branch (5628:9): [True: 0, False: 20]
  ------------------
 5629|      0|        snmp_errno = SNMPERR_BAD_SESSION;       /*MTCRITICAL_RESOURCE */
  ------------------
  |  |  188|      0|#define SNMPERR_BAD_SESSION		(-4)
  ------------------
 5630|      0|        return (0);
 5631|      0|    }
 5632|       |    /*
 5633|       |     * send pdu
 5634|       |     */
 5635|       |
 5636|     20|    rc = _sess_async_send(slp, pdu, callback, cb_data, cp_inc);
 5637|     20|    if (rc == 0)
  ------------------
  |  Branch (5637:9): [True: 0, False: 20]
  ------------------
 5638|      0|        SET_SNMP_ERROR(slp->session->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 5639|     20|    return rc;
 5640|     20|}
snmp_free_var_internals:
 5648|     20|{
 5649|     20|    if (!var)
  ------------------
  |  Branch (5649:9): [True: 0, False: 20]
  ------------------
 5650|      0|        return;
 5651|       |
 5652|     20|    if (var->name != var->name_loc)
  ------------------
  |  Branch (5652:9): [True: 0, False: 20]
  ------------------
 5653|      0|        SNMP_FREE(var->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]
  |  |  ------------------
  ------------------
 5654|     20|    if (var->val.string != var->buf)
  ------------------
  |  Branch (5654:9): [True: 0, False: 20]
  ------------------
 5655|      0|        SNMP_FREE(var->val.string);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 5656|     20|    if (var->data) {
  ------------------
  |  Branch (5656:9): [True: 0, False: 20]
  ------------------
 5657|      0|        if (var->dataFreeHook) {
  ------------------
  |  Branch (5657:13): [True: 0, False: 0]
  ------------------
 5658|      0|            var->dataFreeHook(var->data);
 5659|      0|            var->data = NULL;
 5660|      0|        } else {
 5661|       |            SNMP_FREE(var->data);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5662|      0|        }
 5663|      0|    }
 5664|     20|}
snmp_free_var:
 5668|     20|{
 5669|     20|    snmp_free_var_internals(var);
 5670|     20|    free(var);
 5671|     20|}
snmp_free_varbind:
 5675|    223|{
 5676|    223|    netsnmp_variable_list *ptr;
 5677|    243|    while (var) {
  ------------------
  |  Branch (5677:12): [True: 20, False: 223]
  ------------------
 5678|     20|        ptr = var->next_variable;
 5679|     20|        snmp_free_var(var);
 5680|     20|        var = ptr;
 5681|     20|    }
 5682|    223|}
snmp_free_pdu:
 5689|    203|{
 5690|    203|    struct snmp_secmod_def *sptr;
 5691|       |
 5692|    203|    if (!pdu)
  ------------------
  |  Branch (5692:9): [True: 0, False: 203]
  ------------------
 5693|      0|        return;
 5694|       |
 5695|    203|    free_securityStateRef(pdu);
 5696|       |
 5697|    203|    sptr = find_sec_mod(pdu->securityModel);
 5698|    203|    if (sptr && sptr->pdu_free)
  ------------------
  |  Branch (5698:9): [True: 42, False: 161]
  |  Branch (5698:17): [True: 0, False: 42]
  ------------------
 5699|      0|        (*sptr->pdu_free)(pdu);
 5700|       |
 5701|    203|    snmp_free_varbind(pdu->variables);
 5702|    203|    free(pdu->enterprise);
 5703|    203|    free(pdu->community);
 5704|    203|    free(pdu->contextEngineID);
 5705|    203|    free(pdu->securityEngineID);
 5706|    203|    free(pdu->contextName);
 5707|    203|    free(pdu->securityName);
 5708|    203|    free(pdu->transport_data);
 5709|    203|    free(pdu);
 5710|    203|}
snmp_create_sess_pdu:
 5715|    183|{
 5716|    183|    netsnmp_pdu *pdu = calloc(1, sizeof(netsnmp_pdu));
 5717|    183|    if (pdu == NULL) {
  ------------------
  |  Branch (5717:9): [True: 0, False: 183]
  ------------------
 5718|      0|        DEBUGMSGTL(("sess_process_packet", "can't malloc space for PDU\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5719|      0|        return NULL;
 5720|      0|    }
 5721|       |
 5722|       |    /*
 5723|       |     * Save the transport-level data specific to this reception (e.g. UDP
 5724|       |     * source address).  
 5725|       |     */
 5726|       |
 5727|    183|    pdu->transport_data = opaque;
 5728|    183|    pdu->transport_data_length = olength;
 5729|    183|    pdu->tDomain = transport->domain;
 5730|    183|    pdu->tDomainLen = transport->domain_length;
 5731|    183|    return pdu;
 5732|    183|}
snmp_read:
 6121|     46|{
 6122|     46|    netsnmp_large_fd_set lfdset;
 6123|       |
 6124|       |    netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
 6125|     46|    netsnmp_copy_fd_set_to_large_fd_set(&lfdset, fdset);
 6126|     46|    snmp_read2(&lfdset);
 6127|     46|    netsnmp_large_fd_set_cleanup(&lfdset);
 6128|     46|}
snmp_read2:
 6132|     46|{
 6133|     46|    struct session_list *slp, *next;
 6134|       |
 6135|     46|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     46|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 46]
  |  |  ------------------
  ------------------
 6136|     92|    for (slp = Sessions; slp; slp = next) {
  ------------------
  |  Branch (6136:26): [True: 46, False: 46]
  ------------------
 6137|     46|        next = slp->next;
 6138|     46|        snmp_sess_read2(slp, fdset);
 6139|     46|    }
 6140|     46|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     46|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 46]
  |  |  ------------------
  ------------------
 6141|     46|}
_sess_read:
 6621|     46|{
 6622|     46|    netsnmp_transport *transport;
 6623|       |
 6624|     46|    if (!slp || !fdset)
  ------------------
  |  Branch (6624:9): [True: 0, False: 46]
  |  Branch (6624:17): [True: 0, False: 46]
  ------------------
 6625|      0|        return 0;
 6626|       |
 6627|     46|    transport = slp->transport;
 6628|       |
 6629|     46|    if (!transport || !NETSNMP_LARGE_FD_ISSET(transport->sock, fdset)) {
  ------------------
  |  |   50|     46|                    netsnmp_large_fd_is_set(fd, fdset)
  ------------------
  |  Branch (6629:9): [True: 0, False: 46]
  |  Branch (6629:23): [True: 0, False: 46]
  ------------------
 6630|      0|        DEBUGMSGTL(("sess_read", "not reading transport socket\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6631|      0|        return 0;
 6632|      0|    }
 6633|       |
 6634|     46|    return __sess_read(slp);
 6635|     46|}
snmp_sess_read2:
 6657|     46|{
 6658|     46|    netsnmp_session *pss;
 6659|     46|    int             rc;
 6660|       |
 6661|     46|    rc = _sess_read(slp, fdset);
 6662|     46|    pss = slp->session;
 6663|     46|    if (rc && pss->s_snmp_errno) {
  ------------------
  |  Branch (6663:9): [True: 9, False: 37]
  |  Branch (6663:15): [True: 9, False: 0]
  ------------------
 6664|      9|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|      9|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6665|      9|    }
 6666|     46|    return rc;
 6667|     46|}
snmp_select_info:
 6718|     46|{
 6719|       |    return snmp_sess_select_info(NULL, numfds, fdset, timeout, block);
 6720|     46|}
snmp_sess_select_info:
 6738|     46|{
 6739|     46|    return snmp_sess_select_info_flags(slp, numfds, fdset, timeout, block,
 6740|     46|                                       NETSNMP_SELECT_NOFLAGS);
  ------------------
  |  |  195|     46|#define NETSNMP_SELECT_NOFLAGS  0x00
  ------------------
 6741|     46|}
snmp_sess_select_info_flags:
 6749|     46|{
 6750|     46|  int rc;
 6751|     46|  netsnmp_large_fd_set lfdset;
 6752|       |
 6753|     46|  netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
 6754|     46|  netsnmp_copy_fd_set_to_large_fd_set(&lfdset, fdset);
 6755|     46|  rc = snmp_sess_select_info2_flags(slp, numfds, &lfdset, timeout,
 6756|     46|                                    block, flags);
 6757|     46|  if (netsnmp_copy_large_fd_set_to_fd_set(fdset, &lfdset) < 0) {
  ------------------
  |  Branch (6757:7): [True: 0, False: 46]
  ------------------
 6758|       |      snmp_log(LOG_ERR,
 6759|      0|	     "Use snmp_sess_select_info2() for processing"
 6760|      0|	     " large file descriptors\n");
 6761|      0|  }
 6762|     46|  netsnmp_large_fd_set_cleanup(&lfdset);
 6763|     46|  return rc;
 6764|     46|}
snmp_sess_select_info2_flags:
 6808|     46|{
 6809|     46|    struct session_list *slp, *next = NULL;
 6810|     46|    netsnmp_request_list *rp;
 6811|     46|    struct timeval  now, earliest, alarm_tm;
 6812|     46|    int             active = 0, requests = 0;
 6813|     46|    int             next_alarm = 0;
 6814|       |
 6815|     46|    timerclear(&earliest);
 6816|       |
 6817|       |    /*
 6818|       |     * For each session examined, add its socket to the fdset,
 6819|       |     * and if it is the earliest timeout to expire, mark it as lowest.
 6820|       |     * If a single session is specified, do just for that session.
 6821|       |     */
 6822|       |
 6823|     46|    DEBUGMSGTL(("sess_select", "for %s session%s: ",
  ------------------
  |  |   66|     46|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     46|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#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: 46]
  |  |  ------------------
  ------------------
 6824|     46|                sessp ? "single" : "all", sessp ? "" : "s"));
 6825|       |
 6826|     92|    for (slp = sessp ? sessp : Sessions; slp; slp = next) {
  ------------------
  |  Branch (6826:16): [True: 0, False: 46]
  |  Branch (6826:42): [True: 46, False: 46]
  ------------------
 6827|     46|        next = slp->next;
 6828|       |
 6829|     46|        if (slp->transport == NULL) {
  ------------------
  |  Branch (6829:13): [True: 0, False: 46]
  ------------------
 6830|       |            /*
 6831|       |             * Close in progress -- skip this one.  
 6832|       |             */
 6833|      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]
  |  |  ------------------
  ------------------
 6834|      0|            continue;
 6835|      0|        }
 6836|       |
 6837|     46|        if (!NETSNMP_IS_VALID_SOCKET(slp->transport->sock)) {
  ------------------
  |  |   44|     46|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (6837:13): [True: 0, False: 46]
  ------------------
 6838|       |            /*
 6839|       |             * This session was marked for deletion.  
 6840|       |             */
 6841|      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]
  |  |  ------------------
  ------------------
 6842|      0|            if (sessp == NULL) {
  ------------------
  |  Branch (6842:17): [True: 0, False: 0]
  ------------------
 6843|      0|                snmp_close(slp->session);
 6844|      0|            } else {
 6845|      0|                snmp_sess_close(slp);
 6846|      0|            }
 6847|      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]
  |  |  ------------------
  ------------------
 6848|      0|                        sessp ? "single" : "all", sessp ? "" : "s"));
 6849|      0|            continue;
 6850|      0|        }
 6851|       |
 6852|     46|        DEBUGMSG(("sess_select", "%" NETSNMP_FMT_SKT " ",
  ------------------
  |  |   61|     46|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     46|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 46]
  |  |  ------------------
  ------------------
 6853|     46|                  slp->transport->sock));
 6854|     46|        if ((slp->transport->sock + 1) > *numfds) {
  ------------------
  |  Branch (6854:13): [True: 46, False: 0]
  ------------------
 6855|     46|            *numfds = (slp->transport->sock + 1);
 6856|     46|        }
 6857|       |
 6858|     46|        NETSNMP_LARGE_FD_SET(slp->transport->sock, fdset);
  ------------------
  |  |   35|     46|                    netsnmp_large_fd_setfd(fd, fdset)
  ------------------
 6859|     46|        if (slp->internal != NULL && slp->internal->requests) {
  ------------------
  |  Branch (6859:13): [True: 46, False: 0]
  |  Branch (6859:38): [True: 0, False: 46]
  ------------------
 6860|       |            /*
 6861|       |             * Found another session with outstanding requests.  
 6862|       |             */
 6863|      0|            requests++;
 6864|      0|            for (rp = slp->internal->requests; rp; rp = rp->next_request) {
  ------------------
  |  Branch (6864:48): [True: 0, False: 0]
  ------------------
 6865|      0|                if (!timerisset(&earliest)
  ------------------
  |  Branch (6865:21): [True: 0, False: 0]
  ------------------
 6866|      0|                    || (timerisset(&rp->expireM)
  ------------------
  |  Branch (6866:25): [True: 0, False: 0]
  ------------------
 6867|      0|                        && timercmp(&rp->expireM, &earliest, <))) {
  ------------------
  |  Branch (6867:28): [True: 0, False: 0]
  |  Branch (6867:28): [True: 0, False: 0]
  ------------------
 6868|      0|                    earliest = rp->expireM;
 6869|      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]
  |  |  ------------------
  ------------------
 6870|      0|                               (int)earliest.tv_sec, (int)earliest.tv_usec));
 6871|      0|                }
 6872|      0|            }
 6873|      0|        }
 6874|       |
 6875|     46|        active++;
 6876|     46|        if (sessp) {
  ------------------
  |  Branch (6876:13): [True: 0, False: 46]
  ------------------
 6877|       |            /*
 6878|       |             * Single session processing.  
 6879|       |             */
 6880|      0|            break;
 6881|      0|        }
 6882|     46|    }
 6883|     46|    DEBUGMSG(("sess_select", "\n"));
  ------------------
  |  |   61|     46|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     46|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 46]
  |  |  ------------------
  ------------------
 6884|       |
 6885|     46|    netsnmp_get_monotonic_clock(&now);
 6886|       |
 6887|     46|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     46|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6887:9): [True: 0, False: 46]
  ------------------
 6888|     46|                               NETSNMP_DS_LIB_ALARM_DONT_USE_SIG) &&
  ------------------
  |  |   71|     46|#define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG  11   /* don't use the alarm() signal */
  ------------------
 6889|      0|        !(flags & NETSNMP_SELECT_NOALARMS)) {
  ------------------
  |  |  196|      0|#define NETSNMP_SELECT_NOALARMS 0x01
  ------------------
  |  Branch (6889:9): [True: 0, False: 0]
  ------------------
 6890|      0|        next_alarm = netsnmp_get_next_alarm_time(&alarm_tm, &now);
 6891|      0|        if (next_alarm)
  ------------------
  |  Branch (6891:13): [True: 0, False: 0]
  ------------------
 6892|      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]
  |  |  ------------------
  ------------------
 6893|      0|                       (long)alarm_tm.tv_sec, (long)alarm_tm.tv_usec));
 6894|      0|    }
 6895|     46|    if (next_alarm == 0 && requests == 0) {
  ------------------
  |  Branch (6895:9): [True: 46, False: 0]
  |  Branch (6895:28): [True: 46, False: 0]
  ------------------
 6896|       |        /*
 6897|       |         * If none are active, skip arithmetic.  
 6898|       |         */
 6899|     46|        DEBUGMSGT(("sess_select","blocking:no session requests or alarms.\n"));
  ------------------
  |  |   62|     46|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     46|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 46]
  |  |  ------------------
  ------------------
 6900|     46|        *block = 1; /* can block - timeout value is undefined if no requests */
 6901|     46|        return active;
 6902|     46|    }
 6903|       |
 6904|      0|    if (next_alarm &&
  ------------------
  |  Branch (6904:9): [True: 0, False: 0]
  ------------------
 6905|      0|        (!timerisset(&earliest) || timercmp(&alarm_tm, &earliest, <)))
  ------------------
  |  Branch (6905:10): [True: 0, False: 0]
  |  Branch (6905:36): [True: 0, False: 0]
  |  Branch (6905:36): [True: 0, False: 0]
  ------------------
 6906|      0|        earliest = alarm_tm;
 6907|       |
 6908|      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]
  |  |  ------------------
  ------------------
 6909|      0|    if (earliest.tv_sec < 0) {
  ------------------
  |  Branch (6909:9): [True: 0, False: 0]
  ------------------
 6910|      0|        time_t overdue_ms = -(earliest.tv_sec * 1000 + earliest.tv_usec / 1000);
 6911|      0|        if (overdue_ms >= 10)
  ------------------
  |  Branch (6911:13): [True: 0, False: 0]
  ------------------
 6912|      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]
  |  |  ------------------
  ------------------
 6913|      0|                       (long) overdue_ms));
 6914|      0|        timerclear(&earliest);
 6915|      0|    } else {
 6916|      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]
  |  |  ------------------
  ------------------
 6917|      0|                   (int)earliest.tv_sec, (int)earliest.tv_usec));
 6918|      0|    }
 6919|       |
 6920|       |    /*
 6921|       |     * if it was blocking before or our delta time is less, reset timeout 
 6922|       |     */
 6923|      0|    if ((*block || (timercmp(&earliest, timeout, <)))) {
  ------------------
  |  Branch (6923:10): [True: 0, False: 0]
  |  Branch (6923:20): [True: 0, False: 0]
  |  Branch (6923:21): [True: 0, False: 0]
  ------------------
 6924|      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]
  |  |  ------------------
  ------------------
 6925|      0|                   "setting timer to %d.%06d sec, clear block (was %d)\n",
 6926|      0|                   (int)earliest.tv_sec, (int)earliest.tv_usec, *block));
 6927|      0|        *timeout = earliest;
 6928|      0|        *block = 0;
 6929|      0|    }
 6930|      0|    return active;
 6931|     46|}
snmp_oid_compare:
 7205|    366|{
 7206|    366|    register int    len;
 7207|    366|    register const oid *name1 = in_name1;
 7208|    366|    register const oid *name2 = in_name2;
 7209|       |
 7210|       |    /*
 7211|       |     * len = minimum of len1 and len2 
 7212|       |     */
 7213|    366|    if (len1 < len2)
  ------------------
  |  Branch (7213:9): [True: 0, False: 366]
  ------------------
 7214|      0|        len = len1;
 7215|    366|    else
 7216|    366|        len = len2;
 7217|       |    /*
 7218|       |     * find first non-matching OID 
 7219|       |     */
 7220|  3.78k|    while (len-- > 0) {
  ------------------
  |  Branch (7220:12): [True: 3.66k, False: 122]
  ------------------
 7221|       |        /*
 7222|       |         * these must be done in separate comparisons, since
 7223|       |         * subtracting them and using that result has problems with
 7224|       |         * subids > 2^31. 
 7225|       |         */
 7226|  3.66k|        if (*(name1) != *(name2)) {
  ------------------
  |  Branch (7226:13): [True: 244, False: 3.41k]
  ------------------
 7227|    244|            if (*(name1) < *(name2))
  ------------------
  |  Branch (7227:17): [True: 122, False: 122]
  ------------------
 7228|    122|                return -1;
 7229|    122|            return 1;
 7230|    244|        }
 7231|  3.41k|        name1++;
 7232|  3.41k|        name2++;
 7233|  3.41k|    }
 7234|       |    /*
 7235|       |     * both OIDs equal up to length of shorter OID 
 7236|       |     */
 7237|    122|    if (len1 < len2)
  ------------------
  |  Branch (7237:9): [True: 0, False: 122]
  ------------------
 7238|      0|        return -1;
 7239|    122|    if (len2 < len1)
  ------------------
  |  Branch (7239:9): [True: 0, False: 122]
  ------------------
 7240|      0|        return 1;
 7241|    122|    return 0;
 7242|    122|}
netsnmp_oid_equals:
 7342|  2.59k|{
 7343|  2.59k|    register const oid *name1 = in_name1;
 7344|  2.59k|    register const oid *name2 = in_name2;
 7345|  2.59k|    register int    len = len1;
 7346|       |
 7347|       |    /*
 7348|       |     * len = minimum of len1 and len2 
 7349|       |     */
 7350|  2.59k|    if (len1 != len2)
  ------------------
  |  Branch (7350:9): [True: 1.79k, False: 804]
  ------------------
 7351|  1.79k|        return 1;
 7352|       |    /*
 7353|       |     * Handle 'null' OIDs
 7354|       |     */
 7355|    804|    if (len1 == 0)
  ------------------
  |  Branch (7355:9): [True: 0, False: 804]
  ------------------
 7356|      0|        return 0;   /* Two null OIDs are (trivially) the same */
 7357|    804|    if (!name1 || !name2)
  ------------------
  |  Branch (7357:9): [True: 0, False: 804]
  |  Branch (7357:19): [True: 0, False: 804]
  ------------------
 7358|      0|        return 1;   /* Otherwise something's wrong, so report a non-match */
 7359|       |    /*
 7360|       |     * find first non-matching OID 
 7361|       |     */
 7362|  6.71k|    while (len-- > 0) {
  ------------------
  |  Branch (7362:12): [True: 6.71k, False: 0]
  ------------------
 7363|       |        /*
 7364|       |         * these must be done in separate comparisons, since
 7365|       |         * subtracting them and using that result has problems with
 7366|       |         * subids > 2^31. 
 7367|       |         */
 7368|  6.71k|        if (*(name1++) != *(name2++))
  ------------------
  |  Branch (7368:13): [True: 804, False: 5.91k]
  ------------------
 7369|    804|            return 1;
 7370|  6.71k|    }
 7371|      0|    return 0;
 7372|    804|}
snmp_pdu_add_variable:
 7482|     20|{
 7483|     20|    return snmp_varlist_add_variable(&pdu->variables, name, name_length,
 7484|     20|                                     type, value, len);
 7485|     20|}
snmp_varlist_add_variable:
 7496|     20|{
 7497|     20|    netsnmp_variable_list *vars, *vtmp;
 7498|     20|    int rc;
 7499|       |
 7500|     20|    if (varlist == NULL)
  ------------------
  |  Branch (7500:9): [True: 0, False: 20]
  ------------------
 7501|      0|        return NULL;
 7502|       |
 7503|     20|    vars = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|     20|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 7504|     20|    if (vars == NULL)
  ------------------
  |  Branch (7504:9): [True: 0, False: 20]
  ------------------
 7505|      0|        return NULL;
 7506|       |
 7507|     20|    vars->type = type;
 7508|       |
 7509|     20|    rc = snmp_set_var_value( vars, value, len );
 7510|     20|    if (( 0 != rc ) ||
  ------------------
  |  Branch (7510:9): [True: 0, False: 20]
  ------------------
 7511|     20|        (name != NULL && snmp_set_var_objid(vars, name, name_length))) {
  ------------------
  |  Branch (7511:10): [True: 20, False: 0]
  |  Branch (7511:26): [True: 0, False: 20]
  ------------------
 7512|      0|        snmp_free_var(vars);
 7513|      0|        return NULL;
 7514|      0|    }
 7515|       |
 7516|       |    /*
 7517|       |     * put only qualified variable onto varlist 
 7518|       |     */
 7519|     20|    if (*varlist == NULL) {
  ------------------
  |  Branch (7519:9): [True: 20, False: 0]
  ------------------
 7520|     20|        *varlist = vars;
 7521|     20|    } else {
 7522|      0|        for (vtmp = *varlist; vtmp->next_variable;
  ------------------
  |  Branch (7522:31): [True: 0, False: 0]
  ------------------
 7523|      0|             vtmp = vtmp->next_variable);
 7524|       |
 7525|      0|        vtmp->next_variable = vars;
 7526|      0|    }
 7527|       |
 7528|     20|    return vars;
 7529|     20|}
snmp_duplicate_objid:
 8168|    282|{
 8169|    282|    oid            *returnOid;
 8170|    282|    if (objToCopy != NULL && objToCopyLen != 0) {
  ------------------
  |  Branch (8170:9): [True: 282, False: 0]
  |  Branch (8170:30): [True: 282, False: 0]
  ------------------
 8171|    282|        returnOid = (oid *) malloc(objToCopyLen * sizeof(oid));
 8172|    282|        if (returnOid) {
  ------------------
  |  Branch (8172:13): [True: 282, False: 0]
  ------------------
 8173|    282|            memcpy(returnOid, objToCopy, objToCopyLen * sizeof(oid));
 8174|    282|        }
 8175|    282|    } else
 8176|      0|        returnOid = NULL;
 8177|    282|    return returnOid;
 8178|    282|}
snmp_increment_statistic:
 8188|    183|{
 8189|    183|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
  ------------------
  |  |  710|    183|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  706|    183|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  703|    183|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (8189:9): [True: 183, False: 0]
  |  Branch (8189:23): [True: 183, False: 0]
  ------------------
 8190|    183|        statistics[which]++;
 8191|    183|        return statistics[which];
 8192|    183|    }
 8193|      0|    return 0;
 8194|    183|}
snmp_get_statistic:
 8208|     20|{
 8209|     20|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS)
  ------------------
  |  |  710|     20|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  706|     20|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  703|     20|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (8209:9): [True: 20, False: 0]
  |  Branch (8209:23): [True: 20, False: 0]
  ------------------
 8210|     20|        return statistics[which];
 8211|      0|    return 0;
 8212|     20|}
snmp_init_statistics:
 8216|     47|{
 8217|     47|    memset(statistics, 0, sizeof(statistics));
 8218|     47|}
snmp_api.c:_init_snmp:
  719|    141|{
  720|       |
  721|    141|    struct timeval  tv;
  722|    141|    long            tmpReqid, tmpMsgid;
  723|       |
  724|    141|    if (_init_snmp_init_done)
  ------------------
  |  Branch (724:9): [True: 94, False: 47]
  ------------------
  725|     94|        return;
  726|     47|    _init_snmp_init_done = 1;
  727|     47|    Reqid = 1;
  728|       |
  729|     47|    snmp_res_init();            /* initialize the mt locking structures */
  ------------------
  |  |   78|     47|#define snmp_res_init() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (78:38): [Folded, False: 47]
  |  |  ------------------
  ------------------
  730|     47|#ifndef NETSNMP_DISABLE_MIB_LOADING
  731|     47|    netsnmp_init_mib_internals();
  732|     47|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  733|     47|    netsnmp_tdomain_init();
  734|       |
  735|     47|    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|     47|    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  744|     47|    tmpReqid = netsnmp_random();
  745|     47|    tmpMsgid = netsnmp_random();
  746|       |
  747|       |    /*
  748|       |     * don't allow zero value to repeat init 
  749|       |     */
  750|     47|    if (tmpReqid == 0)
  ------------------
  |  Branch (750:9): [True: 0, False: 47]
  ------------------
  751|      0|        tmpReqid = 1;
  752|     47|    if (tmpMsgid == 0)
  ------------------
  |  Branch (752:9): [True: 0, False: 47]
  ------------------
  753|      0|        tmpMsgid = 1;
  754|     47|    Reqid = tmpReqid;
  755|     47|    Msgid = tmpMsgid;
  756|       |
  757|     47|    netsnmp_register_default_domain("snmp", "udp udp6");
  758|     47|    netsnmp_register_default_domain("snmptrap", "udp udp6");
  759|       |
  760|     47|    netsnmp_register_default_target("snmp", "udp", ":161");
  761|     47|    netsnmp_register_default_target("snmp", "tcp", ":161");
  762|     47|    netsnmp_register_default_target("snmp", "udp6", ":161");
  763|     47|    netsnmp_register_default_target("snmp", "tcp6", ":161");
  764|     47|    netsnmp_register_default_target("snmp", "dtlsudp", ":10161");
  765|     47|    netsnmp_register_default_target("snmp", "tlstcp", ":10161");
  766|     47|    netsnmp_register_default_target("snmp", "ipx", "/36879");
  767|       |
  768|     47|    netsnmp_register_default_target("snmptrap", "udp", ":162");
  769|     47|    netsnmp_register_default_target("snmptrap", "tcp", ":162");
  770|     47|    netsnmp_register_default_target("snmptrap", "udp6", ":162");
  771|     47|    netsnmp_register_default_target("snmptrap", "tcp6", ":162");
  772|     47|    netsnmp_register_default_target("snmptrap", "dtlsudp", ":10162");
  773|     47|    netsnmp_register_default_target("snmptrap", "tlstcp", ":10162");
  774|     47|    netsnmp_register_default_target("snmptrap", "ipx", "/36880");
  775|       |
  776|     47|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  777|     47|                       NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH, 16);
  ------------------
  |  |  121|     47|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  778|     47|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |  131|     47|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  779|     47|                       DEFAULT_RETRIES);
  ------------------
  |  |  184|     47|#define DEFAULT_RETRIES	    5
  ------------------
  780|     47|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  781|     47|			   NETSNMP_DS_LIB_MIB_ERRORS, 1);
  ------------------
  |  |   59|     47|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  782|       |
  783|     47|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
  784|     47|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  785|     47|			   NETSNMP_DS_LIB_REVERSE_ENCODE,
  ------------------
  |  |   80|     47|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  786|     47|			   NETSNMP_DEFAULT_ASNENCODING_DIRECTION);
  ------------------
  |  | 1998|     47|#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
  ------------------
  787|     47|#endif
  788|     47|}
snmp_api.c:register_default_handlers:
  817|     47|{
  818|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dumpPacket",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  819|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|     47|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
  820|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "reverseEncodeBER",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  821|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   80|     47|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  822|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "defaultPort",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  823|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|     47|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  824|     47|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  825|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv3",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  826|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |  105|     47|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  ------------------
  827|     47|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  828|     47|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  829|     47|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  830|     47|#if !defined(NETSNMP_DISABLE_SNMPV1)
  831|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv1",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  832|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |  103|     47|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  ------------------
  833|     47|#endif
  834|     47|#if !defined(NETSNMP_DISABLE_SNMPV2C)
  835|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv2c",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  836|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |  104|     47|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  ------------------
  837|     47|#endif
  838|     47|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  839|     47|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defCommunity",
  ------------------
  |  |   78|     47|#define ASN_OCTET_STR	    0x04U
  ------------------
  840|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |  158|     47|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
  841|     47|#endif /* !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C) */
  842|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "noTokenWarnings",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  843|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   77|     47|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  844|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noRangeCheck",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  845|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|     47|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
  846|     47|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "persistentDir",
  ------------------
  |  |   78|     47|#define ASN_OCTET_STR	    0x04U
  ------------------
  847|     47|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |  159|     47|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
  848|     47|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tempFilePattern",
  ------------------
  |  |   78|     47|#define ASN_OCTET_STR	    0x04U
  ------------------
  849|     47|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |  166|     47|#define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15
  ------------------
  850|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noDisplayHint",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  851|     47|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|     47|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
  852|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "16bitIDs",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  853|     47|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   91|     47|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  854|     47|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
  ------------------
  |  |   78|     47|#define ASN_OCTET_STR	    0x04U
  ------------------
  855|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |  165|     47|#define NETSNMP_DS_LIB_CLIENT_ADDR       14
  ------------------
  856|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  857|     47|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |  102|     47|#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
  ------------------
  858|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  859|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |  122|     47|#define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
  ------------------
  860|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  861|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |  123|     47|#define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
  ------------------
  862|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientSendBuf",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  863|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |  124|     47|#define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
  ------------------
  864|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientRecvBuf",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  865|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |  125|     47|#define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
  ------------------
  866|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "sendMessageMaxSize",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  867|     47|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  868|     47|                               NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|     47|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  869|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentLoad",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  870|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   95|     47|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
  871|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentSave",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  872|     47|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   96|     47|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
  873|     47|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp",
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  874|     47|                               "noContextEngineIDDiscovery",
  875|     47|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  876|     47|                               NETSNMP_DS_LIB_NO_DISCOVERY);
  ------------------
  |  |   98|     47|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
  877|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "timeout",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  878|     47|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     47|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
  879|     47|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "retries",
  ------------------
  |  |   75|     47|#define ASN_INTEGER	    0x02U
  ------------------
  880|     47|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     47|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  881|     47|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "outputPrecision",
  ------------------
  |  |   78|     47|#define ASN_OCTET_STR	    0x04U
  ------------------
  882|     47|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |  186|     47|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  883|       |
  884|       |
  885|     47|    netsnmp_register_service_handlers();
  886|     47|}
snmp_api.c:snmp_sess_copy:
 1407|     47|{
 1408|     47|    struct session_list *psl;
 1409|     47|    psl = _sess_copy(pss);
 1410|     47|    if (!psl) {
  ------------------
  |  Branch (1410:9): [True: 0, False: 47]
  ------------------
 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|     47|    return psl;
 1417|     47|}
snmp_api.c:_sess_copy:
 1116|     47|{
 1117|     47|    struct session_list *slp;
 1118|     47|    struct snmp_internal_session *isp;
 1119|     47|    netsnmp_session *session;
 1120|     47|    struct snmp_secmod_def *sptr;
 1121|     47|    char           *cp;
 1122|     47|    u_char         *ucp;
 1123|       |
 1124|     47|    in_session->s_snmp_errno = 0;
 1125|     47|    in_session->s_errno = 0;
 1126|       |
 1127|       |    /*
 1128|       |     * Copy session structure and link into list 
 1129|       |     */
 1130|     47|    slp = calloc(1, sizeof(struct session_list));
 1131|     47|    if (slp == NULL) {
  ------------------
  |  Branch (1131:9): [True: 0, False: 47]
  ------------------
 1132|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1133|      0|        return (NULL);
 1134|      0|    }
 1135|       |
 1136|     47|    slp->transport = NULL;
 1137|       |
 1138|     47|    isp = calloc(1, sizeof(struct snmp_internal_session));
 1139|       |
 1140|     47|    if (isp == NULL) {
  ------------------
  |  Branch (1140:9): [True: 0, False: 47]
  ------------------
 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|     47|    slp->internal = isp;
 1147|     47|    slp->session = netsnmp_memdup(in_session, sizeof(netsnmp_session));
 1148|     47|    if (slp->session == NULL) {
  ------------------
  |  Branch (1148:9): [True: 0, False: 47]
  ------------------
 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|     47|    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|     47|    session->localname = NULL;
 1160|     47|    session->peername = NULL;
 1161|     47|    session->community = NULL;
 1162|     47|    session->contextEngineID = NULL;
 1163|     47|    session->contextName = NULL;
 1164|     47|    session->securityEngineID = NULL;
 1165|     47|    session->securityName = NULL;
 1166|     47|    session->securityAuthProto = NULL;
 1167|     47|    session->securityAuthLocalKey = NULL;
 1168|     47|    session->securityPrivProto = NULL;
 1169|     47|    session->securityPrivLocalKey = NULL;
 1170|     47|    session->sessUser = NULL;
 1171|     47|    session->paramName = NULL;
 1172|     47|#ifndef NETSNMP_NO_TRAP_STATS
 1173|     47|    session->trap_stats = NULL;
 1174|     47|#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|     47|    if (in_session->peername != NULL) {
  ------------------
  |  Branch (1181:9): [True: 0, False: 47]
  ------------------
 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|     47|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 1196|     47|    if (in_session->community_len != SNMP_DEFAULT_COMMUNITY_LEN) {
  ------------------
  |  |   78|     47|#define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
  ------------------
  |  Branch (1196:9): [True: 0, False: 47]
  ------------------
 1197|      0|        ucp = netsnmp_memdup(in_session->community, in_session->community_len);
 1198|     47|    } else {
 1199|     47|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1199:13): [True: 0, False: 47]
  ------------------
 1200|     47|					NETSNMP_DS_LIB_COMMUNITY)) != NULL) {
  ------------------
  |  |  158|     47|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
 1201|      0|            session->community_len = strlen(cp);
 1202|      0|            ucp = (u_char *) strdup(cp);
 1203|     47|        } 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|     47|            ucp = (u_char *) strdup("");
 1209|     47|#endif
 1210|     47|        }
 1211|     47|    }
 1212|       |
 1213|     47|    if (ucp == NULL) {
  ------------------
  |  Branch (1213:9): [True: 0, False: 47]
  ------------------
 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|     47|    session->community = ucp;   /* replace pointer with pointer to new data */
 1219|     47|#endif
 1220|       |
 1221|     47|    if (session->securityLevel <= 0) {
  ------------------
  |  Branch (1221:9): [True: 47, False: 0]
  ------------------
 1222|     47|        session->securityLevel =
 1223|     47|            netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |  115|     47|#define NETSNMP_DS_LIB_SECLEVEL             1
  ------------------
 1224|     47|    }
 1225|       |
 1226|     47|    if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 47]
  ------------------
 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|     47|    if (in_session->contextEngineIDLen > 0) {
  ------------------
  |  Branch (1238:9): [True: 0, False: 47]
  ------------------
 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|     47|    } else if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1248:16): [True: 0, False: 47]
  ------------------
 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|     47|    if (in_session->contextName) {
  ------------------
  |  Branch (1263:9): [True: 0, False: 47]
  ------------------
 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|     47|    } else {
 1271|     47|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1271:13): [True: 0, False: 47]
  ------------------
 1272|     47|                                        NETSNMP_DS_LIB_CONTEXT)) != NULL)
  ------------------
  |  |  152|     47|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1273|      0|            cp = strdup(cp);
 1274|     47|        else
 1275|     47|            cp = strdup(SNMP_DEFAULT_CONTEXT);
  ------------------
  |  |   92|     47|#define SNMP_DEFAULT_CONTEXT        ""
  ------------------
 1276|     47|        if (cp == NULL) {
  ------------------
  |  Branch (1276:13): [True: 0, False: 47]
  ------------------
 1277|      0|            snmp_sess_close(slp);
 1278|      0|            return (NULL);
 1279|      0|        }
 1280|     47|        session->contextName = cp;
 1281|     47|        session->contextNameLen = strlen(cp);
 1282|     47|    }
 1283|       |
 1284|     47|    if (in_session->securityName) {
  ------------------
  |  Branch (1284:9): [True: 0, False: 47]
  ------------------
 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|     47|    } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1290:16): [True: 0, False: 47]
  ------------------
 1291|     47|					   NETSNMP_DS_LIB_SECNAME)) != NULL) {
  ------------------
  |  |  151|     47|#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|     47|    if (in_session->securityAuthLocalKey) {
  ------------------
  |  Branch (1301:9): [True: 0, False: 47]
  ------------------
 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|     47|    if (in_session->securityPrivLocalKey) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 47]
  ------------------
 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|     47|    if (session->transport_configuration) {
  ------------------
  |  Branch (1317:9): [True: 0, False: 47]
  ------------------
 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|     47|    if (session->retries == SNMP_DEFAULT_RETRIES) {
  ------------------
  |  |   79|     47|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  |  Branch (1326:9): [True: 47, False: 0]
  ------------------
 1327|     47|        int retry = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1328|     47|                                       NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     47|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
 1329|     47|        if (retry < 0)
  ------------------
  |  Branch (1329:13): [True: 0, False: 47]
  ------------------
 1330|      0|            session->retries = DEFAULT_RETRIES;
  ------------------
  |  |  184|      0|#define DEFAULT_RETRIES	    5
  ------------------
 1331|     47|        else
 1332|     47|            session->retries = retry;
 1333|     47|    }
 1334|     47|    if (session->timeout == SNMP_DEFAULT_TIMEOUT) {
  ------------------
  |  |   80|     47|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  |  Branch (1334:9): [True: 47, False: 0]
  ------------------
 1335|     47|        int timeout = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1336|     47|                                         NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     47|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
 1337|     47|        if (timeout <= 0)
  ------------------
  |  Branch (1337:13): [True: 47, False: 0]
  ------------------
 1338|     47|            session->timeout = DEFAULT_TIMEOUT;
  ------------------
  |  |  185|     47|#define DEFAULT_TIMEOUT	    (1000L * 1000L)
  ------------------
 1339|      0|        else
 1340|      0|            session->timeout = timeout * 1000L * 1000L;
 1341|     47|    }
 1342|     47|    session->sessid = snmp_get_next_sessid();
 1343|       |
 1344|     47|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   29|     47|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
 1345|     47|                        session);
 1346|       |
 1347|     47|    if ((sptr = find_sec_mod(session->securityModel)) != NULL) {
  ------------------
  |  Branch (1347:9): [True: 47, False: 0]
  ------------------
 1348|       |        /*
 1349|       |         * security module specific copying 
 1350|       |         */
 1351|     47|        if (sptr->session_setup) {
  ------------------
  |  Branch (1351:13): [True: 47, False: 0]
  ------------------
 1352|     47|            int ret = (*sptr->session_setup) (in_session, session);
 1353|     47|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1353:17): [True: 0, False: 47]
  ------------------
 1354|      0|                snmp_sess_close(slp);
 1355|      0|                return NULL;
 1356|      0|            }
 1357|     47|        }
 1358|       |
 1359|       |        /*
 1360|       |         * security module specific opening
 1361|       |         */
 1362|     47|        if (sptr->session_open) {
  ------------------
  |  Branch (1362:13): [True: 0, False: 47]
  ------------------
 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|     47|    }
 1370|       |
 1371|     47|#ifndef NETSNMP_NO_WRITE_SUPPORT
 1372|     47|    if (in_session->sessUser) {
  ------------------
  |  Branch (1372:9): [True: 0, False: 47]
  ------------------
 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|     47|#endif /* NETSNMP_NO_WRITE_SUPPORT */
 1383|       |
 1384|     47|    if (in_session->paramName) {
  ------------------
  |  Branch (1384:9): [True: 0, False: 47]
  ------------------
 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|     47|#ifndef NETSNMP_NO_TRAP_STATS
 1392|     47|    if (in_session->trap_stats) {
  ------------------
  |  Branch (1392:9): [True: 0, False: 47]
  ------------------
 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|     47|#endif
 1401|       |
 1402|     47|    return (slp);
 1403|     47|}
snmp_api.c:netsnmp_free_transport_config:
 2044|     47|{
 2045|     47|    if (!tc)
  ------------------
  |  Branch (2045:9): [True: 47, False: 0]
  ------------------
 2046|     47|        return;
 2047|       |
 2048|      0|    CONTAINER_CLEAR(tc, netsnmp_free_one_tr_cfg, NULL);
 2049|      0|    CONTAINER_FREE(tc);
 2050|      0|}
snmp_api.c:snmp_free_session:
 2083|     47|{
 2084|     47|    if (!s)
  ------------------
  |  Branch (2084:9): [True: 0, False: 47]
  ------------------
 2085|      0|        return;
 2086|       |
 2087|     47|    netsnmp_cleanup_session(s);
 2088|       |
 2089|       |    /*
 2090|       |     * clear session from any callbacks
 2091|       |     */
 2092|     47|    netsnmp_callback_clear_client_arg(s, 0, 0);
 2093|       |
 2094|     47|    free(s);
 2095|     47|}
snmp_api.c:snmpv3_calc_msg_flags:
 2227|     20|{
 2228|     20|    *flags = 0;
 2229|     20|    if (sec_level == SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|     20|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (2229:9): [True: 0, False: 20]
  ------------------
 2230|      0|        *flags = SNMP_MSG_FLAG_AUTH_BIT;
  ------------------
  |  |  303|      0|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
 2231|     20|    else if (sec_level == SNMP_SEC_LEVEL_AUTHPRIV)
  ------------------
  |  |  301|     20|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (2231:14): [True: 0, False: 20]
  ------------------
 2232|      0|        *flags = SNMP_MSG_FLAG_AUTH_BIT | SNMP_MSG_FLAG_PRIV_BIT;
  ------------------
  |  |  303|      0|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
                      *flags = SNMP_MSG_FLAG_AUTH_BIT | SNMP_MSG_FLAG_PRIV_BIT;
  ------------------
  |  |  304|      0|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
 2233|       |
 2234|     20|    if (SNMP_CMD_CONFIRMED(msg_command))
  ------------------
  |  |  193|     20|#define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
  |  |  ------------------
  |  |  |  |  141|     40|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
  |  |  ------------------
  |  |  |  |  140|     40|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (193:32): [True: 0, False: 20]
  |  |  |  Branch (193:56): [True: 0, False: 20]
  |  |  ------------------
  |  |  194|     20|                               c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
  |  |  ------------------
  |  |  |  |  126|     40|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
  |  |  ------------------
  |  |  |  |  125|     40|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (194:32): [True: 0, False: 20]
  |  |  |  Branch (194:57): [True: 0, False: 20]
  |  |  ------------------
  |  |  195|     20|                               c == SNMP_MSG_SET )
  |  |  ------------------
  |  |  |  |  129|     40|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (195:32): [True: 0, False: 20]
  |  |  ------------------
  ------------------
 2235|      0|        *flags |= SNMP_MSG_FLAG_RPRT_BIT;
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 2236|       |
 2237|     20|    return;
 2238|     20|}
snmp_api.c:_snmp_build:
 2995|     20|{
 2996|     20|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 2997|     20|    u_char         *h0e = NULL;
 2998|     20|    size_t          start_offset = *offset;
 2999|     20|    long            version;
 3000|     20|    int             rc = 0;
 3001|     20|    size_t          length;
 3002|     20|#endif /* support for community based SNMP */
 3003|       |
 3004|     20|    u_char         *cp;
 3005|       |
 3006|     20|    if (NETSNMP_RUNTIME_PROTOCOL_SKIP(pdu->version)) {
  ------------------
  |  |  246|     20|    (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||        \
  |  |  ------------------
  |  |  |  |  205|     40|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|     40|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  206|     40|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  207|      0|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|      0|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  247|     20|     NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) ||        \
  |  |  ------------------
  |  |  |  |  215|     40|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     40|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  216|     40|     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 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|     20|     NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver))
  |  |  ------------------
  |  |  |  |  229|     20|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|     20|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  230|     20|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|     20|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  231|     20|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|     20|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3007|      0|        DEBUGMSGTL(("snmp_send", "build packet (version 0x%02x disabled)\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]
  |  |  ------------------
  ------------------
 3008|      0|                    (u_int)pdu->version));
 3009|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3010|      0|        return -1;
 3011|      0|    }
 3012|       |
 3013|     20|    session->s_snmp_errno = 0;
 3014|     20|    session->s_errno = 0;
 3015|       |
 3016|     20|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 3017|     20|    if ((pdu->flags & UCD_MSG_FLAG_BULK_TOOBIG) ||
  ------------------
  |  |  321|     20|#define UCD_MSG_FLAG_BULK_TOOBIG          0x010000
  ------------------
  |  Branch (3017:9): [True: 0, False: 20]
  ------------------
 3018|     20|        (0 == netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     20|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3018:9): [True: 0, False: 20]
  ------------------
 3019|     20|                                     NETSNMP_DS_LIB_REVERSE_ENCODE))) {
  ------------------
  |  |   80|     20|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
 3020|      0|        pdu->flags |= UCD_MSG_FLAG_FORWARD_ENCODE;
  ------------------
  |  |  319|      0|#define UCD_MSG_FLAG_FORWARD_ENCODE         0x8000
  ------------------
 3021|      0|    }
 3022|     20|#endif /* NETSNMP_USE_REVERSE_ASNENCODING */
 3023|       |
 3024|     20|    if (pdu->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|     20|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (3024:9): [True: 20, False: 0]
  ------------------
 3025|     20|        return snmpv3_build(pkt, pkt_len, offset, session, pdu);
 3026|     20|    }
 3027|       |
 3028|      0|    switch (pdu->command) {
 3029|      0|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (3029:5): [True: 0, False: 0]
  ------------------
 3030|      0|        netsnmp_assert(0 == (pdu->flags & UCD_MSG_FLAG_EXPECT_RESPONSE));
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3031|      0|#ifndef NETSNMP_NOTIFY_ONLY
 3032|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 3033|      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 (3033:5): [True: 0, False: 0]
  ------------------
 3034|      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 (3034:5): [True: 0, False: 0]
  ------------------
 3035|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 3036|      0|#endif /* ! NETSNMP_NOTIFY_ONLY */
 3037|      0|#ifndef NETSNMP_NO_WRITE_SUPPORT
 3038|      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 (3038:5): [True: 0, False: 0]
  ------------------
 3039|      0|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 3040|       |        /*
 3041|       |         * all versions support these PDU types 
 3042|       |         */
 3043|       |        /*
 3044|       |         * initialize defaulted PDU fields 
 3045|       |         */
 3046|       |
 3047|      0|        if (pdu->errstat == SNMP_DEFAULT_ERRSTAT)
  ------------------
  |  |   84|      0|#define SNMP_DEFAULT_ERRSTAT	    -1
  ------------------
  |  Branch (3047:13): [True: 0, False: 0]
  ------------------
 3048|      0|            pdu->errstat = 0;
 3049|      0|        if (pdu->errindex == SNMP_DEFAULT_ERRINDEX)
  ------------------
  |  |   85|      0|#define SNMP_DEFAULT_ERRINDEX	    -1
  ------------------
  |  Branch (3049:13): [True: 0, False: 0]
  ------------------
 3050|      0|            pdu->errindex = 0;
 3051|      0|        break;
 3052|       |
 3053|      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 (3053:5): [True: 0, False: 0]
  ------------------
 3054|      0|        netsnmp_assert(0 == (pdu->flags & UCD_MSG_FLAG_EXPECT_RESPONSE));
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3055|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 3056|      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 (3056:5): [True: 0, False: 0]
  ------------------
 3057|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3058|       |        /*
 3059|       |         * not supported in SNMPv1 and SNMPsec 
 3060|       |         */
 3061|      0|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3061:13): [True: 0, False: 0]
  ------------------
 3062|      0|            session->s_snmp_errno = SNMPERR_V2_IN_V1;
  ------------------
  |  |  191|      0|#define SNMPERR_V2_IN_V1		(-7)
  ------------------
 3063|      0|            return -1;
 3064|      0|        }
 3065|      0|#endif
 3066|      0|        if (pdu->errstat == SNMP_DEFAULT_ERRSTAT)
  ------------------
  |  |   84|      0|#define SNMP_DEFAULT_ERRSTAT	    -1
  ------------------
  |  Branch (3066:13): [True: 0, False: 0]
  ------------------
 3067|      0|            pdu->errstat = 0;
 3068|      0|        if (pdu->errindex == SNMP_DEFAULT_ERRINDEX)
  ------------------
  |  |   85|      0|#define SNMP_DEFAULT_ERRINDEX	    -1
  ------------------
  |  Branch (3068:13): [True: 0, False: 0]
  ------------------
 3069|      0|            pdu->errindex = 0;
 3070|      0|        break;
 3071|       |
 3072|      0|#ifndef NETSNMP_NOTIFY_ONLY
 3073|      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 (3073:5): [True: 0, False: 0]
  ------------------
 3074|       |        /*
 3075|       |         * not supported in SNMPv1 and SNMPsec 
 3076|       |         */
 3077|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3078|      0|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3078:13): [True: 0, False: 0]
  ------------------
 3079|      0|            session->s_snmp_errno = SNMPERR_V2_IN_V1;
  ------------------
  |  |  191|      0|#define SNMPERR_V2_IN_V1		(-7)
  ------------------
 3080|      0|            return -1;
 3081|      0|        }
 3082|      0|#endif
 3083|      0|        if (pdu->max_repetitions < 0) {
  ------------------
  |  |  161|      0|#define max_repetitions errindex
  ------------------
  |  Branch (3083:13): [True: 0, False: 0]
  ------------------
 3084|      0|            session->s_snmp_errno = SNMPERR_BAD_REPETITIONS;
  ------------------
  |  |  194|      0|#define SNMPERR_BAD_REPETITIONS		(-10)
  ------------------
 3085|      0|            return -1;
 3086|      0|        }
 3087|      0|        if (pdu->non_repeaters < 0) {
  ------------------
  |  |  160|      0|#define non_repeaters	errstat
  ------------------
  |  Branch (3087:13): [True: 0, False: 0]
  ------------------
 3088|      0|            session->s_snmp_errno = SNMPERR_BAD_REPEATERS;
  ------------------
  |  |  193|      0|#define SNMPERR_BAD_REPEATERS		(-9)
  ------------------
 3089|      0|            return -1;
 3090|      0|        }
 3091|      0|        break;
 3092|      0|#endif /* ! NETSNMP_NOTIFY_ONLY */
 3093|       |
 3094|      0|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|      0|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (3094:5): [True: 0, False: 0]
  ------------------
 3095|       |        /*
 3096|       |         * *only* supported in SNMPv1 and SNMPsec 
 3097|       |         */
 3098|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3099|      0|        if (pdu->version != SNMP_VERSION_1) {
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3099:13): [True: 0, False: 0]
  ------------------
 3100|      0|            session->s_snmp_errno = SNMPERR_V1_IN_V2;
  ------------------
  |  |  192|      0|#define SNMPERR_V1_IN_V2		(-8)
  ------------------
 3101|      0|            return -1;
 3102|      0|        }
 3103|      0|#endif
 3104|       |        /*
 3105|       |         * initialize defaulted Trap PDU fields 
 3106|       |         */
 3107|      0|        pdu->reqid = 1;         /* give a bogus non-error reqid for traps */
 3108|      0|        if (pdu->enterprise_length == SNMP_DEFAULT_ENTERPRISE_LENGTH) {
  ------------------
  |  |   88|      0|#define SNMP_DEFAULT_ENTERPRISE_LENGTH	0
  ------------------
  |  Branch (3108:13): [True: 0, False: 0]
  ------------------
 3109|      0|            pdu->enterprise = netsnmp_memdup(DEFAULT_ENTERPRISE,
  ------------------
  |  |  187|      0|#define DEFAULT_ENTERPRISE  default_enterprise
  ------------------
 3110|      0|                                             sizeof(DEFAULT_ENTERPRISE));
  ------------------
  |  |  187|      0|#define DEFAULT_ENTERPRISE  default_enterprise
  ------------------
 3111|      0|            if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (3111:17): [True: 0, False: 0]
  ------------------
 3112|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3113|      0|                return -1;
 3114|      0|            }
 3115|      0|            pdu->enterprise_length =
 3116|      0|                OID_LENGTH(DEFAULT_ENTERPRISE);
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 3117|      0|        }
 3118|      0|        if (pdu->time == SNMP_DEFAULT_TIME)
  ------------------
  |  |   89|      0|#define SNMP_DEFAULT_TIME	    0
  ------------------
  |  Branch (3118:13): [True: 0, False: 0]
  ------------------
 3119|      0|            pdu->time = DEFAULT_TIME;
  ------------------
  |  |  188|      0|#define DEFAULT_TIME	    0
  ------------------
 3120|       |        /*
 3121|       |         * don't expect a response 
 3122|       |         */
 3123|      0|        pdu->flags &= (~UCD_MSG_FLAG_EXPECT_RESPONSE);
  ------------------
  |  |  312|      0|#define UCD_MSG_FLAG_EXPECT_RESPONSE         0x200
  ------------------
 3124|      0|        break;
 3125|       |
 3126|      0|    case SNMP_MSG_REPORT:      /* SNMPv3 only */
  ------------------
  |  |  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 (3126:5): [True: 0, False: 0]
  ------------------
 3127|      0|    default:
  ------------------
  |  Branch (3127:5): [True: 0, False: 0]
  ------------------
 3128|      0|        session->s_snmp_errno = SNMPERR_UNKNOWN_PDU;
  ------------------
  |  |  207|      0|#define SNMPERR_UNKNOWN_PDU		(-23)
  ------------------
 3129|      0|        return -1;
 3130|      0|    }
 3131|       |
 3132|       |    /*
 3133|       |     * save length 
 3134|       |     */
 3135|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 3136|      0|    length = *pkt_len;
 3137|      0|#endif
 3138|       |
 3139|       |    /*
 3140|       |     * setup administrative fields based on version 
 3141|       |     */
 3142|       |    /*
 3143|       |     * build the message wrapper and all the administrative fields
 3144|       |     * upto the PDU sequence
 3145|       |     * (note that actual length of message will be inserted later) 
 3146|       |     */
 3147|      0|    switch (pdu->version) {
 3148|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3149|      0|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3149:5): [True: 0, False: 0]
  ------------------
 3150|      0|#endif
 3151|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
 3152|      0|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|      0|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (3152:5): [True: 0, False: 0]
  ------------------
 3153|      0|#endif
 3154|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 3155|       |#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY
 3156|       |        if (pdu->community_len == 0) {
 3157|       |            if (session->community_len == 0) {
 3158|       |                session->s_snmp_errno = SNMPERR_BAD_COMMUNITY;
 3159|       |                return -1;
 3160|       |            }
 3161|       |            pdu->community = netsnmp_memdup(session->community,
 3162|       |                                            session->community_len);
 3163|       |            if (pdu->community == NULL) {
 3164|       |                session->s_snmp_errno = SNMPERR_MALLOC;
 3165|       |                return -1;
 3166|       |            }
 3167|       |            pdu->community_len = session->community_len;
 3168|       |        }
 3169|       |#else                           /* !NETSNMP_NO_ZEROLENGTH_COMMUNITY */
 3170|      0|        if (pdu->community_len == 0 && pdu->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
  |  |  ------------------
  ------------------
  |  Branch (3170:13): [True: 0, False: 0]
  |  Branch (3170:40): [True: 0, False: 0]
  ------------------
 3171|       |            /*
 3172|       |             * copy session community exactly to pdu community 
 3173|       |             */
 3174|      0|            if (0 == session->community_len) {
  ------------------
  |  Branch (3174:17): [True: 0, False: 0]
  ------------------
 3175|      0|                SNMP_FREE(pdu->community);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3176|      0|            } else if (pdu->community_len == session->community_len) {
  ------------------
  |  Branch (3176:24): [True: 0, False: 0]
  ------------------
 3177|      0|                memmove(pdu->community,
 3178|      0|                        session->community, session->community_len);
 3179|      0|            } else {
 3180|      0|                SNMP_FREE(pdu->community);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3181|      0|                pdu->community = netsnmp_memdup(session->community,
 3182|      0|                                                session->community_len);
 3183|      0|                if (pdu->community == NULL) {
  ------------------
  |  Branch (3183:21): [True: 0, False: 0]
  ------------------
 3184|      0|                    session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3185|      0|                    return -1;
 3186|      0|                }
 3187|      0|            }
 3188|      0|            pdu->community_len = session->community_len;
 3189|      0|        }
 3190|      0|#endif                          /* !NETSNMP_NO_ZEROLENGTH_COMMUNITY */
 3191|       |
 3192|      0|        DEBUGMSGTL(("snmp_send", "Building SNMPv%ld message...\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]
  |  |  ------------------
  ------------------
 3193|      0|                    (1 + pdu->version)));
 3194|      0|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 3195|      0|        if (!(pdu->flags & UCD_MSG_FLAG_FORWARD_ENCODE)) {
  ------------------
  |  |  319|      0|#define UCD_MSG_FLAG_FORWARD_ENCODE         0x8000
  ------------------
  |  Branch (3195:13): [True: 0, False: 0]
  ------------------
 3196|      0|            DEBUGPRINTPDUTYPE("send", pdu->command);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3197|      0|            rc = snmp_pdu_realloc_rbuild(pkt, pkt_len, offset, pdu);
 3198|      0|            if (rc == 0) {
  ------------------
  |  Branch (3198:17): [True: 0, False: 0]
  ------------------
 3199|      0|                return -1;
 3200|      0|            }
 3201|       |
 3202|      0|            DEBUGDUMPHEADER("send", "Community String");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3203|      0|            rc = asn_realloc_rbuild_string(pkt, pkt_len, offset, 1,
 3204|      0|                                           (u_char) (ASN_UNIVERSAL |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
 3205|      0|                                                     ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3206|      0|                                                     ASN_OCTET_STR),
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 3207|      0|                                           pdu->community,
 3208|      0|                                           pdu->community_len);
 3209|      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]
  |  |  ------------------
  ------------------
 3210|      0|            if (rc == 0) {
  ------------------
  |  Branch (3210:17): [True: 0, False: 0]
  ------------------
 3211|      0|                return -1;
 3212|      0|            }
 3213|       |
 3214|       |
 3215|       |            /*
 3216|       |             * Store the version field.  
 3217|       |             */
 3218|      0|            DEBUGDUMPHEADER("send", "SNMP Version Number");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3219|       |
 3220|      0|            version = pdu->version;
 3221|      0|            rc = asn_realloc_rbuild_int(pkt, pkt_len, offset, 1,
 3222|      0|                                        (u_char) (ASN_UNIVERSAL |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
 3223|      0|                                                  ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3224|      0|                                                  ASN_INTEGER),
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
 3225|      0|                                        (long *) &version,
 3226|      0|                                        sizeof(version));
 3227|      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]
  |  |  ------------------
  ------------------
 3228|      0|            if (rc == 0) {
  ------------------
  |  Branch (3228:17): [True: 0, False: 0]
  ------------------
 3229|      0|                return -1;
 3230|      0|            }
 3231|       |
 3232|       |            /*
 3233|       |             * Build the final sequence.  
 3234|       |             */
 3235|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3236|      0|            if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3236:17): [True: 0, False: 0]
  ------------------
 3237|      0|                DEBUGDUMPSECTION("send", "SNMPv1 Message");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3238|      0|            } else {
 3239|      0|#endif
 3240|      0|                DEBUGDUMPSECTION("send", "SNMPv2c Message");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3241|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3242|      0|            }
 3243|      0|#endif
 3244|      0|            rc = asn_realloc_rbuild_sequence(pkt, pkt_len, offset, 1,
 3245|      0|                                             (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|      0|#define ASN_SEQUENCE	    0x10U
  ------------------
 3246|      0|                                                       ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3247|      0|                                             *offset - start_offset);
 3248|      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]
  |  |  ------------------
  ------------------
 3249|       |
 3250|      0|            if (rc == 0) {
  ------------------
  |  Branch (3250:17): [True: 0, False: 0]
  ------------------
 3251|      0|                return -1;
 3252|      0|            }
 3253|      0|            return 0;
 3254|      0|        } else {
 3255|       |
 3256|      0|#endif                          /* NETSNMP_USE_REVERSE_ASNENCODING */
 3257|       |            /*
 3258|       |             * Save current location and build SEQUENCE tag and length
 3259|       |             * placeholder for SNMP message sequence
 3260|       |             * (actual length will be inserted later) 
 3261|       |             */
 3262|      0|            cp = asn_build_sequence(*pkt, pkt_len,
 3263|      0|                                    (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|      0|#define ASN_SEQUENCE	    0x10U
  ------------------
 3264|      0|                                              ASN_CONSTRUCTOR), 0);
  ------------------
  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3265|      0|            if (cp == NULL) {
  ------------------
  |  Branch (3265:17): [True: 0, False: 0]
  ------------------
 3266|      0|                return -1;
 3267|      0|            }
 3268|      0|            h0e = cp;
 3269|       |
 3270|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3271|      0|            if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3271:17): [True: 0, False: 0]
  ------------------
 3272|      0|                DEBUGDUMPSECTION("send", "SNMPv1 Message");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3273|      0|            } else {
 3274|      0|#endif
 3275|      0|                DEBUGDUMPSECTION("send", "SNMPv2c Message");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3276|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3277|      0|            }
 3278|      0|#endif
 3279|       |
 3280|       |            /*
 3281|       |             * store the version field 
 3282|       |             */
 3283|      0|            DEBUGDUMPHEADER("send", "SNMP Version Number");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3284|       |
 3285|      0|            version = pdu->version;
 3286|      0|            cp = asn_build_int(cp, pkt_len,
 3287|      0|                               (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                             (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3288|      0|                                         ASN_INTEGER), (long *) &version,
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
 3289|      0|                               sizeof(version));
 3290|      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]
  |  |  ------------------
  ------------------
 3291|      0|            if (cp == NULL)
  ------------------
  |  Branch (3291:17): [True: 0, False: 0]
  ------------------
 3292|      0|                return -1;
 3293|       |
 3294|       |            /*
 3295|       |             * store the community string 
 3296|       |             */
 3297|      0|            DEBUGDUMPHEADER("send", "Community String");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3298|      0|            cp = asn_build_string(cp, pkt_len,
 3299|      0|                                  (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3300|      0|                                            ASN_OCTET_STR), pdu->community,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 3301|      0|                                  pdu->community_len);
 3302|      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]
  |  |  ------------------
  ------------------
 3303|      0|            if (cp == NULL)
  ------------------
  |  Branch (3303:17): [True: 0, False: 0]
  ------------------
 3304|      0|                return -1;
 3305|      0|            break;
 3306|       |
 3307|      0|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 3308|      0|        }
 3309|      0|#endif                          /* NETSNMP_USE_REVERSE_ASNENCODING */
 3310|      0|        break;
 3311|      0|#endif /* support for community based SNMP */
 3312|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (3312:5): [True: 0, False: 0]
  ------------------
 3313|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (3313:5): [True: 0, False: 0]
  ------------------
 3314|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (3314:5): [True: 0, False: 0]
  ------------------
 3315|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (3315:5): [True: 0, False: 0]
  ------------------
 3316|      0|    default:
  ------------------
  |  Branch (3316:5): [True: 0, False: 0]
  ------------------
 3317|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3318|      0|        return -1;
 3319|      0|    }
 3320|       |
 3321|      0|    DEBUGPRINTPDUTYPE("send", pdu->command);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3322|      0|    cp = snmp_pdu_build(pdu, cp, pkt_len);
 3323|      0|    DEBUGINDENTADD(-4);         /* return from entire v1/v2c message */
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3324|      0|    if (cp == NULL)
  ------------------
  |  Branch (3324:9): [True: 0, False: 0]
  ------------------
 3325|      0|        return -1;
 3326|       |
 3327|       |    /*
 3328|       |     * insert the actual length of the message sequence 
 3329|       |     */
 3330|      0|    switch (pdu->version) {
 3331|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 3332|      0|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (3332:5): [True: 0, False: 0]
  ------------------
 3333|      0|#endif
 3334|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
 3335|      0|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|      0|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (3335:5): [True: 0, False: 0]
  ------------------
 3336|      0|#endif
 3337|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 3338|      0|        asn_build_sequence(*pkt, &length,
 3339|      0|                           (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      0|#define ASN_SEQUENCE	    0x10U
  ------------------
                                         (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3340|      0|                           cp - h0e);
 3341|      0|        break;
 3342|      0|#endif /* support for community based SNMP */
 3343|       |
 3344|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (3344:5): [True: 0, False: 0]
  ------------------
 3345|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (3345:5): [True: 0, False: 0]
  ------------------
 3346|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (3346:5): [True: 0, False: 0]
  ------------------
 3347|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (3347:5): [True: 0, False: 0]
  ------------------
 3348|      0|    default:
  ------------------
  |  Branch (3348:5): [True: 0, False: 0]
  ------------------
 3349|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3350|      0|        return -1;
 3351|      0|    }
 3352|      0|    *pkt_len = cp - *pkt;
 3353|      0|    return 0;
 3354|      0|}
snmp_api.c:snmpv3_build:
 2303|     20|{
 2304|     20|    int             ret;
 2305|       |
 2306|     20|    session->s_snmp_errno = 0;
 2307|     20|    session->s_errno = 0;
 2308|       |
 2309|       |    /*
 2310|       |     * do validation for PDU types 
 2311|       |     */
 2312|     20|    switch (pdu->command) {
 2313|      0|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2313:5): [True: 0, False: 20]
  ------------------
 2314|      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 (2314:5): [True: 0, False: 20]
  ------------------
 2315|     20|    case SNMP_MSG_REPORT:
  ------------------
  |  |  147|     20|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2315:5): [True: 20, False: 0]
  ------------------
 2316|     20|        netsnmp_assert(0 == (pdu->flags & UCD_MSG_FLAG_EXPECT_RESPONSE));
  ------------------
  |  |   47|     20|#      define netsnmp_assert(x)  do { \
  |  |   48|     20|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 20, False: 0]
  |  |  ------------------
  |  |   49|     20|                 ; \
  |  |   50|     20|              else \
  |  |   51|     20|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     20|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2317|     20|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|     20|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 2318|     20|    case SNMP_MSG_INFORM:
  ------------------
  |  |  141|     20|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2318:5): [True: 0, False: 20]
  ------------------
 2319|     20|#ifndef NETSNMP_NOTIFY_ONLY
 2320|     20|    case SNMP_MSG_GET:
  ------------------
  |  |  125|     20|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2320:5): [True: 0, False: 20]
  ------------------
 2321|     20|    case SNMP_MSG_GETNEXT:
  ------------------
  |  |  126|     20|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2321:5): [True: 0, False: 20]
  ------------------
 2322|     20|#endif /* ! NETSNMP_NOTIFY_ONLY */
 2323|     20|#ifndef NETSNMP_NO_WRITE_SUPPORT
 2324|     20|    case SNMP_MSG_SET:
  ------------------
  |  |  129|     20|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2324:5): [True: 0, False: 20]
  ------------------
 2325|     20|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 2326|     20|        if (pdu->errstat == SNMP_DEFAULT_ERRSTAT)
  ------------------
  |  |   84|     20|#define SNMP_DEFAULT_ERRSTAT	    -1
  ------------------
  |  Branch (2326:13): [True: 0, False: 20]
  ------------------
 2327|      0|            pdu->errstat = 0;
 2328|     20|        if (pdu->errindex == SNMP_DEFAULT_ERRINDEX)
  ------------------
  |  |   85|     20|#define SNMP_DEFAULT_ERRINDEX	    -1
  ------------------
  |  Branch (2328:13): [True: 0, False: 20]
  ------------------
 2329|      0|            pdu->errindex = 0;
 2330|     20|        break;
 2331|       |
 2332|      0|#ifndef NETSNMP_NOTIFY_ONLY
 2333|      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 (2333:5): [True: 0, False: 20]
  ------------------
 2334|      0|        if (pdu->max_repetitions < 0) {
  ------------------
  |  |  161|      0|#define max_repetitions errindex
  ------------------
  |  Branch (2334:13): [True: 0, False: 0]
  ------------------
 2335|      0|            session->s_snmp_errno = SNMPERR_BAD_REPETITIONS;
  ------------------
  |  |  194|      0|#define SNMPERR_BAD_REPETITIONS		(-10)
  ------------------
 2336|      0|            return -1;
 2337|      0|        }
 2338|      0|        if (pdu->non_repeaters < 0) {
  ------------------
  |  |  160|      0|#define non_repeaters	errstat
  ------------------
  |  Branch (2338:13): [True: 0, False: 0]
  ------------------
 2339|      0|            session->s_snmp_errno = SNMPERR_BAD_REPEATERS;
  ------------------
  |  |  193|      0|#define SNMPERR_BAD_REPEATERS		(-9)
  ------------------
 2340|      0|            return -1;
 2341|      0|        }
 2342|      0|        break;
 2343|      0|#endif /* ! NETSNMP_NOTIFY_ONLY */
 2344|       |
 2345|      0|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|      0|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (2345:5): [True: 0, False: 20]
  ------------------
 2346|      0|        session->s_snmp_errno = SNMPERR_V1_IN_V2;
  ------------------
  |  |  192|      0|#define SNMPERR_V1_IN_V2		(-8)
  ------------------
 2347|      0|        return -1;
 2348|       |
 2349|      0|    default:
  ------------------
  |  Branch (2349:5): [True: 0, False: 20]
  ------------------
 2350|      0|        session->s_snmp_errno = SNMPERR_UNKNOWN_PDU;
  ------------------
  |  |  207|      0|#define SNMPERR_UNKNOWN_PDU		(-23)
  ------------------
 2351|      0|        return -1;
 2352|     20|    }
 2353|       |
 2354|       |    /* Do we need to set the session security engineid? */
 2355|     20|    if (pdu->securityEngineIDLen == 0) {
  ------------------
  |  Branch (2355:9): [True: 0, False: 20]
  ------------------
 2356|      0|        if (session->securityEngineIDLen) {
  ------------------
  |  Branch (2356:13): [True: 0, False: 0]
  ------------------
 2357|      0|            snmpv3_clone_engineID(&pdu->securityEngineID,
 2358|      0|                                  &pdu->securityEngineIDLen,
 2359|      0|                                  session->securityEngineID,
 2360|      0|                                  session->securityEngineIDLen);
 2361|      0|        }
 2362|      0|    }
 2363|       |    
 2364|       |    /* Do we need to set the session context engineid? */
 2365|     20|    if (pdu->contextEngineIDLen == 0) {
  ------------------
  |  Branch (2365:9): [True: 0, False: 20]
  ------------------
 2366|      0|        if (session->contextEngineIDLen) {
  ------------------
  |  Branch (2366:13): [True: 0, False: 0]
  ------------------
 2367|      0|            snmpv3_clone_engineID(&pdu->contextEngineID,
 2368|      0|                                  &pdu->contextEngineIDLen,
 2369|      0|                                  session->contextEngineID,
 2370|      0|                                  session->contextEngineIDLen);
 2371|      0|        } else if (pdu->securityEngineIDLen) {
  ------------------
  |  Branch (2371:20): [True: 0, False: 0]
  ------------------
 2372|      0|            snmpv3_clone_engineID(&pdu->contextEngineID,
 2373|      0|                                  &pdu->contextEngineIDLen,
 2374|      0|                                  pdu->securityEngineID,
 2375|      0|                                  pdu->securityEngineIDLen);
 2376|      0|        }
 2377|      0|    }
 2378|       |
 2379|     20|    if (pdu->contextName == NULL) {
  ------------------
  |  Branch (2379:9): [True: 0, False: 20]
  ------------------
 2380|      0|        if (!session->contextName) {
  ------------------
  |  Branch (2380:13): [True: 0, False: 0]
  ------------------
 2381|      0|            session->s_snmp_errno = SNMPERR_BAD_CONTEXT;
  ------------------
  |  |  201|      0|#define SNMPERR_BAD_CONTEXT		(-17)
  ------------------
 2382|      0|            return -1;
 2383|      0|        }
 2384|      0|        pdu->contextName = strdup(session->contextName);
 2385|      0|        if (pdu->contextName == NULL) {
  ------------------
  |  Branch (2385:13): [True: 0, False: 0]
  ------------------
 2386|      0|            session->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 2387|      0|            return -1;
 2388|      0|        }
 2389|      0|        pdu->contextNameLen = session->contextNameLen;
 2390|      0|    }
 2391|     20|    if (pdu->securityModel == SNMP_DEFAULT_SECMODEL) {
  ------------------
  |  |   91|     20|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  |  Branch (2391:9): [True: 0, False: 20]
  ------------------
 2392|      0|        pdu->securityModel = session->securityModel;
 2393|      0|        if (pdu->securityModel == SNMP_DEFAULT_SECMODEL) {
  ------------------
  |  |   91|      0|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  |  Branch (2393:13): [True: 0, False: 0]
  ------------------
 2394|      0|            pdu->securityModel = se_find_value_in_slist("snmp_secmods", netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL));
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          pdu->securityModel = se_find_value_in_slist("snmp_secmods", netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL));
  ------------------
  |  |  161|      0|#define NETSNMP_DS_LIB_SECMODEL          10
  ------------------
 2395|       |            
 2396|      0|            if (pdu->securityModel <= 0) {
  ------------------
  |  Branch (2396:17): [True: 0, False: 0]
  ------------------
 2397|      0|                pdu->securityModel = SNMP_SEC_MODEL_USM;
  ------------------
  |  |  295|      0|#define SNMP_SEC_MODEL_USM		3
  ------------------
 2398|      0|            }
 2399|      0|        }
 2400|      0|    }
 2401|     20|    if (pdu->securityNameLen == 0 && pdu->securityName == NULL) {
  ------------------
  |  Branch (2401:9): [True: 20, False: 0]
  |  Branch (2401:38): [True: 0, False: 20]
  ------------------
 2402|      0|        if (session->securityModel != SNMP_SEC_MODEL_TSM &&
  ------------------
  |  |  296|      0|#define SNMP_SEC_MODEL_TSM              4
  ------------------
  |  Branch (2402:13): [True: 0, False: 0]
  ------------------
 2403|      0|            session->securityNameLen == 0) {
  ------------------
  |  Branch (2403:13): [True: 0, False: 0]
  ------------------
 2404|      0|            session->s_snmp_errno = SNMPERR_BAD_SEC_NAME;
  ------------------
  |  |  211|      0|#define SNMPERR_BAD_SEC_NAME 		(-27)
  ------------------
 2405|      0|            return -1;
 2406|      0|        }
 2407|      0|        if (session->securityName) {
  ------------------
  |  Branch (2407:13): [True: 0, False: 0]
  ------------------
 2408|      0|            pdu->securityName = strdup(session->securityName);
 2409|      0|            if (pdu->securityName == NULL) {
  ------------------
  |  Branch (2409:17): [True: 0, False: 0]
  ------------------
 2410|      0|                session->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 2411|      0|                return -1;
 2412|      0|            }
 2413|      0|            pdu->securityNameLen = session->securityNameLen;
 2414|      0|        } else {
 2415|      0|            pdu->securityName = strdup("");
 2416|      0|            session->securityName = strdup("");
 2417|      0|        }
 2418|      0|    }
 2419|     20|    if (pdu->securityLevel == 0) {
  ------------------
  |  Branch (2419:9): [True: 0, False: 20]
  ------------------
 2420|      0|        if (session->securityLevel == 0) {
  ------------------
  |  Branch (2420:13): [True: 0, False: 0]
  ------------------
 2421|      0|            session->s_snmp_errno = SNMPERR_BAD_SEC_LEVEL;
  ------------------
  |  |  212|      0|#define SNMPERR_BAD_SEC_LEVEL 		(-28)
  ------------------
 2422|      0|            return -1;
 2423|      0|        }
 2424|      0|        pdu->securityLevel = session->securityLevel;
 2425|      0|    }
 2426|     20|    DEBUGMSGTL(("snmp_build",
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#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: 20]
  |  |  ------------------
  ------------------
 2427|     20|                "Building SNMPv3 message (secName:\"%s\", secLevel:%s)...\n",
 2428|     20|                ((session->securityName) ? (char *) session->securityName :
 2429|     20|                 ((pdu->securityName) ? (char *) pdu->securityName :
 2430|     20|                  "ERROR: undefined")), secLevelName[pdu->securityLevel]));
 2431|       |
 2432|     20|    DEBUGDUMPSECTION("send", "SNMPv3 Message");
  ------------------
  |  |   81|     20|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2433|     20|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 2434|     20|    if (!(pdu->flags & UCD_MSG_FLAG_FORWARD_ENCODE)) {
  ------------------
  |  |  319|     20|#define UCD_MSG_FLAG_FORWARD_ENCODE         0x8000
  ------------------
  |  Branch (2434:9): [True: 20, False: 0]
  ------------------
 2435|     20|        ret = snmpv3_packet_realloc_rbuild(pkt, pkt_len, offset,
 2436|     20|                                           session, pdu, NULL, 0);
 2437|     20|    } else {
 2438|      0|#endif
 2439|      0|        ret = snmpv3_packet_build(session, pdu, *pkt, pkt_len, NULL, 0);
 2440|      0|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 2441|      0|    }
 2442|     20|#endif
 2443|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2444|     20|    if (-1 != ret) {
  ------------------
  |  Branch (2444:9): [True: 20, False: 0]
  ------------------
 2445|     20|        session->s_snmp_errno = ret;
 2446|     20|    }
 2447|       |
 2448|     20|    return ret;
 2449|       |
 2450|     20|}                               /* end snmpv3_build() */
snmp_api.c:free_securityStateRef:
 4192|    256|{
 4193|    256|    struct snmp_secmod_def *sptr;
 4194|       |
 4195|    256|    if (!pdu->securityStateRef)
  ------------------
  |  Branch (4195:9): [True: 256, False: 0]
  ------------------
 4196|    256|        return;
 4197|       |
 4198|      0|    sptr = find_sec_mod(pdu->securityModel);
 4199|      0|    if (sptr) {
  ------------------
  |  Branch (4199:9): [True: 0, False: 0]
  ------------------
 4200|      0|        if (sptr->pdu_free_state_ref) {
  ------------------
  |  Branch (4200:13): [True: 0, False: 0]
  ------------------
 4201|      0|            (*sptr->pdu_free_state_ref) (pdu->securityStateRef);
 4202|      0|        } else {
 4203|      0|            snmp_log(LOG_ERR,
 4204|      0|                     "Security Model %d can't free state references\n",
 4205|      0|                     pdu->securityModel);
 4206|      0|	}
 4207|      0|    } else {
 4208|      0|	snmp_log(LOG_ERR,
 4209|      0|		 "Can't find security model to free ptr: %d\n",
 4210|      0|		 pdu->securityModel);
 4211|      0|    }
 4212|       |    pdu->securityStateRef = NULL;
 4213|      0|}
snmp_api.c:_snmp_parse:
 4418|    183|{
 4419|    183|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4420|    183|    u_char          community[COMMUNITY_MAX_LEN];
 4421|    183|    size_t          community_length = COMMUNITY_MAX_LEN;
  ------------------
  |  |   41|    183|#define COMMUNITY_MAX_LEN	256
  ------------------
 4422|    183|#endif
 4423|    183|    int             result = -1;
 4424|       |
 4425|    183|    static const oid snmpEngineIDoid[]   = { 1,3,6,1,6,3,10,2,1,1,0};
 4426|    183|    static size_t   snmpEngineIDoid_len = 11;
 4427|       |
 4428|    183|    static char     ourEngineID[SNMP_SEC_PARAM_BUF_SIZE];
 4429|    183|    static size_t   ourEngineID_len = sizeof(ourEngineID);
 4430|       |
 4431|    183|    netsnmp_pdu    *pdu2 = NULL;
 4432|       |
 4433|    183|    session->s_snmp_errno = 0;
 4434|    183|    session->s_errno = 0;
 4435|       |
 4436|       |    /*
 4437|       |     * Ensure all incoming PDUs have a unique means of identification 
 4438|       |     * (This is not restricted to AgentX handling,
 4439|       |     * though that is where the need becomes visible)   
 4440|       |     */
 4441|    183|    pdu->transid = snmp_get_next_transid();
 4442|       |
 4443|    183|    if (session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|    183|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4443:9): [True: 0, False: 183]
  ------------------
 4444|      0|        pdu->version = session->version;
 4445|    183|    } else {
 4446|    183|        pdu->version = snmp_parse_version(data, length);
 4447|    183|    }
 4448|       |
 4449|    183|    switch (pdu->version) {
 4450|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4451|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4452|      3|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      3|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4452:5): [True: 3, False: 180]
  ------------------
 4453|      3|#endif
 4454|      3|#ifndef NETSNMP_DISABLE_SNMPV2C
 4455|      3|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|      3|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (4455:5): [True: 0, False: 183]
  ------------------
 4456|      3|#endif
 4457|      3|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pdu->version,unsupported_version);
  ------------------
  |  |  220|      3|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do {    \
  |  |  221|      3|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||                \
  |  |  ------------------
  |  |  |  |  205|      6|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|      6|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  206|      6|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      3|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  207|      3|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|      3|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  222|      3|            NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  215|      3|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|      6|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  216|      3|     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|      3|    } while(0)
  |  |  ------------------
  |  |  |  Branch (226:13): [Folded, False: 3]
  |  |  ------------------
  ------------------
 4458|      3|        DEBUGMSGTL(("snmp_api", "Parsing SNMPv%ld message...\n",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4459|      3|                    (1 + pdu->version)));
 4460|       |
 4461|       |        /*
 4462|       |         * authenticates message and returns length if valid 
 4463|       |         */
 4464|      3|#ifndef NETSNMP_DISABLE_SNMPV1
 4465|      3|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      3|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4465:13): [True: 3, False: 0]
  ------------------
 4466|      3|            DEBUGDUMPSECTION("recv", "SNMPv1 message\n");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4467|      3|        } else {
 4468|      0|#endif
 4469|      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]
  |  |  ------------------
  ------------------
 4470|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4471|      0|        }
 4472|      3|#endif
 4473|      3|        data = snmp_comstr_parse(data, &length,
 4474|      3|                                 community, &community_length,
 4475|      3|                                 &pdu->version);
 4476|      3|        if (data == NULL)
  ------------------
  |  Branch (4476:13): [True: 1, False: 2]
  ------------------
 4477|      1|            return -1;
 4478|       |
 4479|      2|        if (pdu->version != session->version &&
  ------------------
  |  Branch (4479:13): [True: 2, False: 0]
  ------------------
 4480|      2|            session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|      2|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4480:13): [True: 0, False: 2]
  ------------------
 4481|      0|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4482|      0|            return -1;
 4483|      0|        }
 4484|       |
 4485|       |        /*
 4486|       |         * maybe get the community string. 
 4487|       |         */
 4488|      2|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|      2|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4489|      2|        pdu->securityModel = 
 4490|      2|#ifndef NETSNMP_DISABLE_SNMPV1
 4491|      2|            (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  107|      2|#define SNMP_VERSION_1	   0
  ------------------
                          (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  293|      2|#define SNMP_SEC_MODEL_SNMPv1		1
  ------------------
  |  Branch (4491:13): [True: 2, False: 0]
  ------------------
 4492|      2|#endif
 4493|      2|                                               SNMP_SEC_MODEL_SNMPv2c;
  ------------------
  |  |  294|      2|#define SNMP_SEC_MODEL_SNMPv2c		2
  ------------------
 4494|      2|        SNMP_FREE(pdu->community);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 2]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4495|      2|        pdu->community_len = 0;
 4496|      2|        pdu->community = (u_char *) 0;
 4497|      2|        if (community_length) {
  ------------------
  |  Branch (4497:13): [True: 0, False: 2]
  ------------------
 4498|      0|            pdu->community_len = community_length;
 4499|      0|            pdu->community = netsnmp_memdup(community, community_length);
 4500|      0|            if (pdu->community == NULL) {
  ------------------
  |  Branch (4500:17): [True: 0, False: 0]
  ------------------
 4501|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4502|      0|                return -1;
 4503|      0|            }
 4504|      0|        }
 4505|      2|        if (session->authenticator) {
  ------------------
  |  Branch (4505:13): [True: 0, False: 2]
  ------------------
 4506|      0|            data = session->authenticator(data, &length,
 4507|      0|                                          community, community_length);
 4508|      0|            if (data == NULL) {
  ------------------
  |  Branch (4508:17): [True: 0, False: 0]
  ------------------
 4509|      0|                session->s_snmp_errno = SNMPERR_AUTHENTICATION_FAILURE;
  ------------------
  |  |  219|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
 4510|      0|                return -1;
 4511|      0|            }
 4512|      0|        }
 4513|       |
 4514|      2|        DEBUGDUMPSECTION("recv", "PDU");
  ------------------
  |  |   81|      2|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4515|      2|        result = snmp_pdu_parse(pdu, data, &length);
 4516|      2|        if (result < 0) {
  ------------------
  |  Branch (4516:13): [True: 2, False: 0]
  ------------------
 4517|       |            /*
 4518|       |             * This indicates a parse error.  
 4519|       |             */
 4520|      2|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4521|      2|        }
 4522|      2|        DEBUGINDENTADD(-6);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4523|      2|        break;
 4524|      0|#endif /* support for community based SNMP */
 4525|       |
 4526|     33|    case SNMP_VERSION_3:
  ------------------
  |  |  113|     33|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (4526:5): [True: 33, False: 150]
  ------------------
 4527|     33|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(SNMP_VERSION_3,unsupported_version);
  ------------------
  |  |  233|     33|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do {      \
  |  |  234|     33|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  229|     33|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|     33|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [True: 33, Folded]
  |  |  |  |  ------------------
  |  |  |  |  230|     33|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|     33|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  231|     33|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|     33|#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|     33|    } while(0)
  |  |  ------------------
  |  |  |  Branch (238:13): [Folded, False: 33]
  |  |  ------------------
  ------------------
 4528|     33|        result = snmpv3_parse(pdu, data, &length, NULL, session);
 4529|     33|        DEBUGMSGTL(("snmp_parse",
  ------------------
  |  |   66|     33|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     33|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 33]
  |  |  ------------------
  ------------------
 4530|     33|                    "Parsed SNMPv3 message (secName:%s, secLevel:%s): %s\n",
 4531|     33|                    pdu->securityName, secLevelName[pdu->securityLevel],
 4532|     33|                    snmp_api_errstring(result)));
 4533|       |
 4534|     33|        if (result == SNMPERR_USM_UNKNOWNSECURITYNAME) {
  ------------------
  |  |  227|     33|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4534:13): [True: 0, False: 33]
  ------------------
 4535|      0|            snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
  ------------------
  |  |   19|      0|#define SNMP_CALLBACK_APPLICATION 1
  ------------------
 4536|      0|                                SNMPD_CALLBACK_AUTH_FAILURE, pdu);
  ------------------
  |  |   21|      0|#define SNMPD_CALLBACK_AUTH_FAILURE             17
  ------------------
 4537|      0|        }
 4538|       |        
 4539|     33|        if (result) {
  ------------------
  |  Branch (4539:13): [True: 33, False: 0]
  ------------------
 4540|     33|            struct snmp_secmod_def *secmod =
 4541|     33|                find_sec_mod(pdu->securityModel);
 4542|     33|            if (!slp) {
  ------------------
  |  Branch (4542:17): [True: 0, False: 33]
  ------------------
 4543|      0|                session->s_snmp_errno = result;
 4544|     33|            } else {
 4545|       |                /*
 4546|       |                 * Call the security model to special handle any errors
 4547|       |                 */
 4548|       |
 4549|     33|                if (secmod && secmod->handle_report) {
  ------------------
  |  Branch (4549:21): [True: 22, False: 11]
  |  Branch (4549:31): [True: 22, False: 0]
  ------------------
 4550|     22|                    (*secmod->handle_report)(slp, slp->transport, session,
 4551|     22|                                             result, pdu);
 4552|     22|                }
 4553|     33|            }
 4554|     33|            free_securityStateRef(pdu);
 4555|     33|        }
 4556|       |
 4557|       |        /* Implement RFC5343 here for two reasons:
 4558|       |           1) From a security perspective it handles this otherwise
 4559|       |              always approved request earlier.  It bypasses the need
 4560|       |              for authorization to the snmpEngineID scalar, which is
 4561|       |              what is what RFC3415 appendix A species as ok.  Note
 4562|       |              that we haven't bypassed authentication since if there
 4563|       |              was an authentication error it would have been handled
 4564|       |              above in the if(result) part at the latest.
 4565|       |           2) From an application point of view if we let this request
 4566|       |              get all the way to the application, it'd require that
 4567|       |              all application types supporting discovery also fire up
 4568|       |              a minimal agent in order to handle just this request
 4569|       |              which seems like overkill.  Though there is no other
 4570|       |              application types that currently need discovery (NRs
 4571|       |              accept notifications from contextEngineIDs that derive
 4572|       |              from the NO not the NR).  Also a lame excuse for doing
 4573|       |              it here.
 4574|       |           3) Less important technically, but the net-snmp agent
 4575|       |              doesn't currently handle registrations of different
 4576|       |              engineIDs either and it would have been a lot more work
 4577|       |              to implement there since we'd need to support that
 4578|       |              first. :-/ Supporting multiple context engineIDs should
 4579|       |              be done anyway, so it's not a valid excuse here.
 4580|       |           4) There is a lot less to do if we trump the agent at this
 4581|       |              point; IE, the agent does a lot more unnecessary
 4582|       |              processing when the only thing that should ever be in
 4583|       |              this context by definition is the single scalar.
 4584|       |        */
 4585|       |
 4586|       |        /* special RFC5343 engineID discovery engineID check */
 4587|     33|        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     33|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4587:13): [True: 33, False: 0]
  ------------------
 4588|     33|                                    NETSNMP_DS_LIB_NO_DISCOVERY) &&
  ------------------
  |  |   98|     33|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
 4589|     33|            SNMP_MSG_RESPONSE       != pdu->command &&
  ------------------
  |  |  127|     33|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     33|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     33|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4589:13): [True: 33, False: 0]
  ------------------
 4590|     33|            NULL                    != pdu->contextEngineID &&
  ------------------
  |  Branch (4590:13): [True: 22, False: 11]
  ------------------
 4591|     22|            pdu->contextEngineIDLen == 5 &&
  ------------------
  |  Branch (4591:13): [True: 0, False: 22]
  ------------------
 4592|      0|            pdu->contextEngineID[0] == 0x80 &&
  ------------------
  |  Branch (4592:13): [True: 0, False: 0]
  ------------------
 4593|      0|            pdu->contextEngineID[1] == 0x00 &&
  ------------------
  |  Branch (4593:13): [True: 0, False: 0]
  ------------------
 4594|      0|            pdu->contextEngineID[2] == 0x00 &&
  ------------------
  |  Branch (4594:13): [True: 0, False: 0]
  ------------------
 4595|      0|            pdu->contextEngineID[3] == 0x00 &&
  ------------------
  |  Branch (4595:13): [True: 0, False: 0]
  ------------------
 4596|      0|            pdu->contextEngineID[4] == 0x06) {
  ------------------
  |  Branch (4596:13): [True: 0, False: 0]
  ------------------
 4597|       |
 4598|       |            /* define a result so it doesn't get past us at this point
 4599|       |               and gets dropped by future parts of the stack */
 4600|      0|            result = SNMPERR_JUST_A_CONTEXT_PROBE;
  ------------------
  |  |  250|      0|#define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
  ------------------
 4601|       |
 4602|      0|            DEBUGMSGTL(("snmpv3_contextid", "starting context ID discovery\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4603|       |            /* ensure exactly one variable */
 4604|      0|            if (NULL != pdu->variables &&
  ------------------
  |  Branch (4604:17): [True: 0, False: 0]
  ------------------
 4605|      0|                NULL == pdu->variables->next_variable &&
  ------------------
  |  Branch (4605:17): [True: 0, False: 0]
  ------------------
 4606|       |
 4607|       |                /* if it's a GET, match it exactly */
 4608|      0|                ((SNMP_MSG_GET == pdu->command &&
  ------------------
  |  |  125|      0|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4608:19): [True: 0, False: 0]
  ------------------
 4609|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4609:19): [True: 0, False: 0]
  ------------------
 4610|      0|                                   snmpEngineIDoid_len,
 4611|      0|                                   pdu->variables->name,
 4612|      0|                                   pdu->variables->name_length) == 0)
 4613|       |                 /* if it's a GETNEXT ensure it's less than the engineID oid */
 4614|      0|                 ||
 4615|      0|                 (SNMP_MSG_GETNEXT == pdu->command &&
  ------------------
  |  |  126|      0|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4615:19): [True: 0, False: 0]
  ------------------
 4616|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4616:19): [True: 0, False: 0]
  ------------------
 4617|      0|                                   snmpEngineIDoid_len,
 4618|      0|                                   pdu->variables->name,
 4619|      0|                                   pdu->variables->name_length) > 0)
 4620|      0|                    )) {
 4621|       |
 4622|      0|                DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4623|      0|                            "  One correct variable found\n"));
 4624|       |
 4625|       |                /* Note: we're explicitly not handling a GETBULK.  Deal. */
 4626|       |
 4627|       |                /* set up the response */
 4628|      0|                pdu2 = snmp_clone_pdu(pdu);
 4629|       |
 4630|       |                /* free the current varbind */
 4631|      0|                snmp_free_varbind(pdu2->variables);
 4632|       |
 4633|       |                /* set the variables */
 4634|      0|                pdu2->variables = NULL;
 4635|      0|                pdu2->command = SNMP_MSG_RESPONSE;
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
 4636|      0|                pdu2->errstat = 0;
 4637|      0|                pdu2->errindex = 0;
 4638|       |
 4639|      0|                ourEngineID_len =
 4640|      0|                    snmpv3_get_engineID((u_char*)ourEngineID, ourEngineID_len);
 4641|      0|                if (0 != ourEngineID_len) {
  ------------------
  |  Branch (4641:21): [True: 0, False: 0]
  ------------------
 4642|       |
 4643|      0|                    DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4644|      0|                                "  responding with our engineID\n"));
 4645|       |
 4646|      0|                    snmp_pdu_add_variable(pdu2,
 4647|      0|                                          snmpEngineIDoid, snmpEngineIDoid_len,
 4648|      0|                                          ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 4649|      0|                                          ourEngineID, ourEngineID_len);
 4650|       |                    
 4651|       |                    /* send the response */
 4652|      0|                    if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (4652:25): [True: 0, False: 0]
  ------------------
 4653|       |
 4654|      0|                        DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4655|      0|                                    "  sent it off!\n"));
 4656|       |
 4657|      0|                        snmp_free_pdu(pdu2);
 4658|       |                        
 4659|      0|                        snmp_log(LOG_ERR, "sending a response to the context engineID probe failed\n");
 4660|      0|                    }
 4661|      0|                } else {
 4662|      0|                    snmp_log(LOG_ERR, "failed to get our own engineID!\n");
 4663|      0|                    snmp_free_pdu(pdu2);
 4664|      0|                }
 4665|      0|            } else {
 4666|      0|                snmp_log(LOG_WARNING,
 4667|      0|                         "received an odd context engineID probe\n");
 4668|      0|            }
 4669|      0|        }
 4670|       |
 4671|     33|        break;
 4672|    143|    case SNMPERR_BAD_VERSION:
  ------------------
  |  |  198|    143|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
  |  Branch (4672:5): [True: 143, False: 40]
  ------------------
 4673|    143|        ERROR_MSG("error parsing snmp message version");
  ------------------
  |  |  188|    143|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4674|    143|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    143|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4675|    143|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|    143|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4676|    143|        break;
 4677|       |
 4678|      0|        unsupported_version:  /* goto label */
 4679|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4679:5): [True: 0, False: 183]
  ------------------
 4680|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (4680:5): [True: 0, False: 183]
  ------------------
 4681|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4681:5): [True: 0, False: 183]
  ------------------
 4682|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (4682:5): [True: 0, False: 183]
  ------------------
 4683|      4|    default:
  ------------------
  |  Branch (4683:5): [True: 4, False: 179]
  ------------------
 4684|      4|        ERROR_MSG("unsupported snmp message version");
  ------------------
  |  |  188|      4|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4685|      4|        snmp_increment_statistic(STAT_SNMPINBADVERSIONS);
  ------------------
  |  |  634|      4|#define  STAT_SNMPINBADVERSIONS              11
  ------------------
 4686|       |
 4687|       |        /*
 4688|       |         * need better way to determine OS independent
 4689|       |         * INT32_MAX value, for now hardcode
 4690|       |         */
 4691|      4|        if (pdu->version < 0 || pdu->version > 2147483647) {
  ------------------
  |  Branch (4691:13): [True: 1, False: 3]
  |  Branch (4691:33): [True: 0, False: 3]
  ------------------
 4692|      1|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4693|      1|        }
 4694|      4|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      4|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4695|      4|        break;
 4696|    183|    }
 4697|       |
 4698|    182|    return result;
 4699|    183|}
snmp_api.c:snmp_parse_version:
 3828|    183|{
 3829|    183|    u_char          type;
 3830|    183|    long            version = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|    183|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3831|       |
 3832|    183|    data = asn_parse_sequence(data, &length, &type,
 3833|    183|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version");
  ------------------
  |  |   84|    183|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version");
  ------------------
  |  |   96|    183|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3834|    183|    if (data) {
  ------------------
  |  Branch (3834:9): [True: 183, False: 0]
  ------------------
 3835|    183|        DEBUGDUMPHEADER("recv", "SNMP Version");
  ------------------
  |  |   79|    183|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 183]
  |  |  ------------------
  ------------------
 3836|    183|        data =
 3837|    183|            asn_parse_int(data, &length, &type, &version, sizeof(version));
 3838|    183|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    183|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 183]
  |  |  ------------------
  ------------------
 3839|    183|        if (!data || type != ASN_INTEGER) {
  ------------------
  |  |   75|     40|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3839:13): [True: 143, False: 40]
  |  Branch (3839:22): [True: 0, False: 40]
  ------------------
 3840|    143|            return SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|    143|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3841|    143|        }
 3842|    183|    }
 3843|     40|    return version;
 3844|    183|}
snmp_api.c:netsnmp_build_packet:
 5114|     20|{
 5115|     20|    size_t offset = 0;
 5116|     20|    int    result;
 5117|       |
 5118|     20|    if (isp && isp->hook_realloc_build) {
  ------------------
  |  Branch (5118:9): [True: 20, False: 0]
  |  Branch (5118:16): [True: 0, False: 20]
  ------------------
 5119|      0|        result = isp->hook_realloc_build(sp, pdu, pktbuf_p, pktbuf_len_p,
 5120|      0|                                         &offset);
 5121|       |
 5122|      0|        *pkt_p = *pktbuf_p;
 5123|      0|        *len_p = offset;
 5124|     20|    } else if (isp && isp->hook_build) {
  ------------------
  |  Branch (5124:16): [True: 20, False: 0]
  |  Branch (5124:23): [True: 0, False: 20]
  ------------------
 5125|      0|        *pkt_p = *pktbuf_p;
 5126|      0|        *len_p = *pktbuf_len_p;
 5127|      0|        result = isp->hook_build(sp, pdu, *pktbuf_p, len_p);
 5128|     20|    } else {
 5129|     20|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 5130|     20|        if (!(pdu->flags & UCD_MSG_FLAG_FORWARD_ENCODE)) {
  ------------------
  |  |  319|     20|#define UCD_MSG_FLAG_FORWARD_ENCODE         0x8000
  ------------------
  |  Branch (5130:13): [True: 20, False: 0]
  ------------------
 5131|     20|            result = snmp_build(pktbuf_p, pktbuf_len_p, &offset, sp, pdu);
 5132|     20|            *pkt_p = *pktbuf_p + *pktbuf_len_p - offset;
 5133|     20|            *len_p = offset;
 5134|     20|        } else {
 5135|      0|#endif
 5136|      0|            *pkt_p = *pktbuf_p;
 5137|      0|            *len_p = *pktbuf_len_p;
 5138|      0|            result = snmp_build(pktbuf_p, len_p, &offset, sp, pdu);
 5139|      0|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
 5140|      0|        }
 5141|     20|#endif
 5142|     20|    }
 5143|       |
 5144|     20|    return result;
 5145|     20|}
snmp_api.c:_sess_async_send:
 5437|     20|{
 5438|     20|    netsnmp_session *session;
 5439|     20|    struct snmp_internal_session *isp;
 5440|     20|    netsnmp_transport *transport = NULL;
 5441|     20|    int             result;
 5442|     20|    long            reqid;
 5443|       |
 5444|     20|    if (slp == NULL || NULL == slp->session || NULL ==slp->internal ||
  ------------------
  |  Branch (5444:9): [True: 0, False: 20]
  |  Branch (5444:24): [True: 0, False: 20]
  |  Branch (5444:48): [True: 0, False: 20]
  ------------------
 5445|     20|                NULL == slp->transport) {
  ------------------
  |  Branch (5445:17): [True: 0, False: 20]
  ------------------
 5446|      0|        return 0;
 5447|      0|    }
 5448|       |
 5449|     20|    session = slp->session;
 5450|     20|    isp = slp->internal;
 5451|     20|    transport = slp->transport;
 5452|       |
 5453|     20|    if (NULL == isp->opacket) {
  ------------------
  |  Branch (5453:9): [True: 20, False: 0]
  ------------------
 5454|     20|        result = _build_initial_pdu_packet(slp, pdu, 0);
 5455|     20|        if ((SNMPERR_SUCCESS != result) || (NULL == isp->opacket)) {
  ------------------
  |  |  184|     20|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5455:13): [True: 0, False: 20]
  |  Branch (5455:44): [True: 0, False: 20]
  ------------------
 5456|      0|            if (callback) {
  ------------------
  |  Branch (5456:17): [True: 0, False: 0]
  ------------------
 5457|      0|                switch (session->s_snmp_errno) {
 5458|       |                    /*
 5459|       |                     * some of these probably don't make sense here, but
 5460|       |                     * it's a rough first cut.
 5461|       |                     */
 5462|      0|                    case SNMPERR_BAD_ENG_ID:
  ------------------
  |  |  210|      0|#define SNMPERR_BAD_ENG_ID 		(-26)
  ------------------
  |  Branch (5462:21): [True: 0, False: 0]
  ------------------
 5463|      0|                    case SNMPERR_BAD_SEC_LEVEL:
  ------------------
  |  |  212|      0|#define SNMPERR_BAD_SEC_LEVEL 		(-28)
  ------------------
  |  Branch (5463:21): [True: 0, False: 0]
  ------------------
 5464|      0|                    case SNMPERR_UNKNOWN_SEC_MODEL:
  ------------------
  |  |  214|      0|#define SNMPERR_UNKNOWN_SEC_MODEL 	(-30)
  ------------------
  |  Branch (5464:21): [True: 0, False: 0]
  ------------------
 5465|      0|                    case SNMPERR_UNKNOWN_ENG_ID:
  ------------------
  |  |  216|      0|#define SNMPERR_UNKNOWN_ENG_ID          (-32)
  ------------------
  |  Branch (5465:21): [True: 0, False: 0]
  ------------------
 5466|      0|                    case SNMPERR_UNKNOWN_USER_NAME:
  ------------------
  |  |  217|      0|#define SNMPERR_UNKNOWN_USER_NAME 	(-33)
  ------------------
  |  Branch (5466:21): [True: 0, False: 0]
  ------------------
 5467|      0|                    case SNMPERR_UNSUPPORTED_SEC_LEVEL:
  ------------------
  |  |  218|      0|#define SNMPERR_UNSUPPORTED_SEC_LEVEL 	(-34)
  ------------------
  |  Branch (5467:21): [True: 0, False: 0]
  ------------------
 5468|      0|                    case SNMPERR_AUTHENTICATION_FAILURE:
  ------------------
  |  |  219|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
  |  Branch (5468:21): [True: 0, False: 0]
  ------------------
 5469|      0|                    case SNMPERR_NOT_IN_TIME_WINDOW:
  ------------------
  |  |  220|      0|#define SNMPERR_NOT_IN_TIME_WINDOW 	(-36)
  ------------------
  |  Branch (5469:21): [True: 0, False: 0]
  ------------------
 5470|      0|                    case SNMPERR_USM_GENERICERROR:
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
  |  Branch (5470:21): [True: 0, False: 0]
  ------------------
 5471|      0|                    case SNMPERR_USM_UNKNOWNSECURITYNAME:
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (5471:21): [True: 0, False: 0]
  ------------------
 5472|      0|                    case SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL:
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
  |  Branch (5472:21): [True: 0, False: 0]
  ------------------
 5473|      0|                    case SNMPERR_USM_ENCRYPTIONERROR:
  ------------------
  |  |  229|      0|#define SNMPERR_USM_ENCRYPTIONERROR		(-45)
  ------------------
  |  Branch (5473:21): [True: 0, False: 0]
  ------------------
 5474|      0|                    case SNMPERR_USM_AUTHENTICATIONFAILURE:
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
  |  Branch (5474:21): [True: 0, False: 0]
  ------------------
 5475|      0|                    case SNMPERR_USM_PARSEERROR:
  ------------------
  |  |  231|      0|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
  |  Branch (5475:21): [True: 0, False: 0]
  ------------------
 5476|      0|                    case SNMPERR_USM_UNKNOWNENGINEID:
  ------------------
  |  |  232|      0|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
  |  Branch (5476:21): [True: 0, False: 0]
  ------------------
 5477|      0|                    case SNMPERR_USM_NOTINTIMEWINDOW:
  ------------------
  |  |  233|      0|#define SNMPERR_USM_NOTINTIMEWINDOW		(-49)
  ------------------
  |  Branch (5477:21): [True: 0, False: 0]
  ------------------
 5478|      0|                        callback(NETSNMP_CALLBACK_OP_SEC_ERROR, session,
  ------------------
  |  |  325|      0|#define NETSNMP_CALLBACK_OP_SEC_ERROR		7
  ------------------
 5479|      0|                                 pdu->reqid, pdu, cb_data);
 5480|      0|                        break;
 5481|      0|                    case SNMPERR_TIMEOUT: /* engineID probe timed out */
  ------------------
  |  |  208|      0|#define SNMPERR_TIMEOUT 		(-24)
  ------------------
  |  Branch (5481:21): [True: 0, False: 0]
  ------------------
 5482|      0|                        callback(NETSNMP_CALLBACK_OP_TIMED_OUT, session,
  ------------------
  |  |  320|      0|#define NETSNMP_CALLBACK_OP_TIMED_OUT		2
  ------------------
 5483|      0|                                 pdu->reqid, pdu, cb_data);
 5484|      0|                        break;
 5485|      0|                    default:
  ------------------
  |  Branch (5485:21): [True: 0, False: 0]
  ------------------
 5486|      0|                        callback(NETSNMP_CALLBACK_OP_SEND_FAILED, session,
  ------------------
  |  |  321|      0|#define NETSNMP_CALLBACK_OP_SEND_FAILED		3
  ------------------
 5487|      0|                                 pdu->reqid, pdu, cb_data);
 5488|      0|                        break;
 5489|      0|                }
 5490|      0|            }
 5491|       |            /** no packet to send?? */
 5492|      0|            return 0;
 5493|      0|        }
 5494|     20|    }
 5495|       |
 5496|       |    /*
 5497|       |     * Send the message.  
 5498|       |     */
 5499|       |
 5500|     20|    DEBUGMSGTL(("sess_process_packet", "sending message id#%ld reqid#%ld len %"
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 5501|     20|                NETSNMP_PRIz "u\n", pdu->msgid, pdu->reqid, isp->opacket_len));
 5502|     20|    result = netsnmp_transport_send(transport, isp->opacket, isp->opacket_len,
 5503|     20|                                    &(pdu->transport_data),
 5504|     20|                                    &(pdu->transport_data_length));
 5505|       |
 5506|     20|    SNMP_FREE(isp->obuf);
  ------------------
  |  |   62|     20|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 20, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 20]
  |  |  ------------------
  ------------------
 5507|     20|    isp->opacket = NULL; /* opacket was in obuf, so no free needed */
 5508|     20|    isp->opacket_len = 0;
 5509|       |
 5510|     20|    if (result < 0) {
  ------------------
  |  Branch (5510:9): [True: 0, False: 20]
  ------------------
 5511|      0|        session->s_snmp_errno = SNMPERR_BAD_SENDTO;
  ------------------
  |  |  196|      0|#define SNMPERR_BAD_SENDTO		(-12)
  ------------------
 5512|      0|        session->s_errno = errno;
 5513|      0|        if (callback)
  ------------------
  |  Branch (5513:13): [True: 0, False: 0]
  ------------------
 5514|      0|            callback(NETSNMP_CALLBACK_OP_SEND_FAILED, session,
  ------------------
  |  |  321|      0|#define NETSNMP_CALLBACK_OP_SEND_FAILED		3
  ------------------
 5515|      0|                     pdu->reqid, pdu, cb_data);
 5516|      0|        return 0;
 5517|      0|    }
 5518|       |
 5519|     20|    reqid = pdu->reqid;
 5520|       |
 5521|       |    /*
 5522|       |     * Bug 2387: 0 is a valid request id, so since reqid is used as a return
 5523|       |     * code with 0 meaning an error, set reqid to 1 if there is no error. This
 5524|       |     * does not affect the request id in the packet and fixes a memory leak
 5525|       |     * for incoming PDUs with a request id of 0. This could cause some
 5526|       |     * confusion if the caller is expecting the request id to match the
 5527|       |     * return code, as the documentation states it will. Most example code
 5528|       |     * just checks for non-zero, so hopefully this wont be an issue.
 5529|       |     */
 5530|     20|    if (0 == reqid && (SNMPERR_SUCCESS == session->s_snmp_errno))
  ------------------
  |  |  184|     20|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5530:9): [True: 20, False: 0]
  |  Branch (5530:23): [True: 20, False: 0]
  ------------------
 5531|     20|        ++reqid;
 5532|       |
 5533|       |    /*
 5534|       |     * Add to pending requests list if we expect a response.  
 5535|       |     */
 5536|     20|    if (pdu->flags & UCD_MSG_FLAG_EXPECT_RESPONSE) {
  ------------------
  |  |  312|     20|#define UCD_MSG_FLAG_EXPECT_RESPONSE         0x200
  ------------------
  |  Branch (5536:9): [True: 0, False: 20]
  ------------------
 5537|      0|        netsnmp_request_list *rp;
 5538|      0|        struct timeval  tv;
 5539|       |
 5540|      0|        rp = calloc(1, sizeof(netsnmp_request_list));
 5541|      0|        if (rp == NULL) {
  ------------------
  |  Branch (5541:13): [True: 0, False: 0]
  ------------------
 5542|      0|            session->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5543|      0|            return 0;
 5544|      0|        }
 5545|       |
 5546|      0|        netsnmp_get_monotonic_clock(&tv);
 5547|      0|        rp->pdu = pdu;
 5548|      0|        rp->request_id = pdu->reqid;
 5549|      0|        rp->message_id = pdu->msgid;
 5550|      0|        rp->callback = callback;
 5551|      0|        if (cp_inc && cb_data) {
  ------------------
  |  Branch (5551:13): [True: 0, False: 0]
  |  Branch (5551:23): [True: 0, False: 0]
  ------------------
 5552|      0|            netsnmp_refcnt_void *aux_cb_data = (netsnmp_refcnt_void*) cb_data;
 5553|      0|            aux_cb_data->refcnt++;
 5554|      0|            rp->cb_data_refcounted = 1;
 5555|      0|	}
 5556|      0|        rp->cb_data = cb_data;
 5557|      0|        rp->retries = 0;
 5558|      0|        if (pdu->flags & UCD_MSG_FLAG_PDU_TIMEOUT) {
  ------------------
  |  |  315|      0|#define UCD_MSG_FLAG_PDU_TIMEOUT            0x1000
  ------------------
  |  Branch (5558:13): [True: 0, False: 0]
  ------------------
 5559|      0|            rp->timeout = pdu->time * 1000000L;
 5560|      0|        } else {
 5561|      0|            rp->timeout = session->timeout;
 5562|      0|        }
 5563|      0|        rp->timeM = tv;
 5564|      0|        tv.tv_usec += rp->timeout;
 5565|      0|        tv.tv_sec += tv.tv_usec / 1000000L;
 5566|      0|        tv.tv_usec %= 1000000L;
 5567|      0|        rp->expireM = tv;
 5568|       |
 5569|       |        /*
 5570|       |         * XX lock should be per session ! 
 5571|       |         */
 5572|      0|        snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|      0|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5573|      0|        if (isp->requestsEnd) {
  ------------------
  |  Branch (5573:13): [True: 0, False: 0]
  ------------------
 5574|      0|            rp->next_request = isp->requestsEnd->next_request;
 5575|      0|            isp->requestsEnd->next_request = rp;
 5576|      0|            isp->requestsEnd = rp;
 5577|      0|        } else {
 5578|      0|            rp->next_request = isp->requests;
 5579|      0|            isp->requests = rp;
 5580|      0|            isp->requestsEnd = rp;
 5581|      0|        }
 5582|      0|        snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|      0|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5583|     20|    } else {
 5584|       |        /*
 5585|       |         * No response expected...  
 5586|       |         */
 5587|     20|        if (reqid) {
  ------------------
  |  Branch (5587:13): [True: 20, False: 0]
  ------------------
 5588|       |            /*
 5589|       |             * Free v1 or v2 TRAP PDU iff no error  
 5590|       |             */
 5591|     20|            snmp_free_pdu(pdu);
 5592|     20|        }
 5593|     20|    }
 5594|       |
 5595|     20|    return reqid;
 5596|     20|}
snmp_api.c:__sess_read:
 6290|     46|{
 6291|     46|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6291:27): [True: 46, False: 0]
  ------------------
 6292|     46|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6292:41): [True: 46, False: 0]
  ------------------
 6293|     46|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6293:36): [True: 46, False: 0]
  ------------------
 6294|     46|    size_t          pdulen = 0, rxbuf_len = SNMP_MAX_RCV_MSG_SIZE;
  ------------------
  |  |  108|     46|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6295|     46|    u_char         *rxbuf = NULL;
 6296|     46|    int             length = 0, olength = 0, rc = 0;
 6297|     46|    void           *opaque = NULL;
 6298|       |
 6299|     46|    if (NULL == slp || NULL == sp || NULL == isp || NULL == transport) {
  ------------------
  |  Branch (6299:9): [True: 0, False: 46]
  |  Branch (6299:24): [True: 0, False: 46]
  |  Branch (6299:38): [True: 0, False: 46]
  |  Branch (6299:53): [True: 0, False: 46]
  ------------------
 6300|      0|        snmp_log(LOG_ERR, "bad parameters to __sess_read\n");
 6301|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 6302|      0|    }
 6303|       |
 6304|       |    /* to avoid subagent crash */
 6305|     46|    if (!NETSNMP_IS_VALID_SOCKET(transport->sock)) {
  ------------------
  |  |   44|     46|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (6305:9): [True: 0, False: 46]
  ------------------
 6306|      0|        snmp_log(LOG_INFO, "transport->sock is invalid\n");
 6307|      0|        return 0; 
 6308|      0|    }
 6309|       |
 6310|     46|    sp->s_snmp_errno = 0;
 6311|     46|    sp->s_errno = 0;
 6312|       |
 6313|     46|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_LISTEN)
  ------------------
  |  |   52|     46|#define		NETSNMP_TRANSPORT_FLAG_LISTEN	 0x02
  ------------------
  |  Branch (6313:9): [True: 0, False: 46]
  ------------------
 6314|      0|        return _sess_read_accept(slp);
 6315|       |
 6316|     46|    if (!(transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)) {
  ------------------
  |  |   51|     46|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6316:9): [True: 46, False: 0]
  ------------------
 6317|     46|        snmp_rcv_packet rcvp;
 6318|     46|        u_char *pptr;
 6319|     46|        size_t len_remaining, pdulen;
 6320|     46|        void *ocopy = NULL;
 6321|       |
 6322|     46|        memset(&rcvp, 0x0, sizeof(rcvp));
 6323|       |
 6324|       |        /** read the packet */
 6325|     46|        rc = _sess_read_dgram_packet(slp, &rcvp);
 6326|     46|        if (-1 == rc) /* protocol error */
  ------------------
  |  Branch (6326:13): [True: 0, False: 46]
  ------------------
 6327|      0|            return -1;
 6328|     46|        else if (-2 == rc) /* no packet to process */
  ------------------
  |  Branch (6328:18): [True: 0, False: 46]
  ------------------
 6329|      0|            return 0;
 6330|       |
 6331|     46|        pptr = rcvp.packet;
 6332|     46|        len_remaining = rcvp.packet_len;
 6333|     46|        rc = 0;
 6334|       |
 6335|    229|        while (len_remaining > 0) {
  ------------------
  |  Branch (6335:16): [True: 227, False: 2]
  ------------------
 6336|    227|            if (isp->check_packet) {
  ------------------
  |  Branch (6336:17): [True: 0, False: 227]
  ------------------
 6337|      0|                pdulen = isp->check_packet(pptr, len_remaining);
 6338|    227|            } else {
 6339|    227|                pdulen = asn_check_packet(pptr, len_remaining);
 6340|    227|            }
 6341|    227|            if (pdulen == 0 || pdulen > len_remaining || pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|    183|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6341:17): [True: 13, False: 214]
  |  Branch (6341:32): [True: 31, False: 183]
  |  Branch (6341:58): [True: 0, False: 183]
  ------------------
 6342|       |                /* Not a valid packet or incomplete in datagram mode */
 6343|     44|                if (pptr == rcvp.packet) {
  ------------------
  |  Branch (6343:21): [True: 37, False: 7]
  ------------------
 6344|     37|                    SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|     37|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 37, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 37]
  |  |  ------------------
  ------------------
 6345|     37|                }
 6346|     44|                break;
 6347|     44|            }
 6348|    183|            if (pdulen < len_remaining) {
  ------------------
  |  Branch (6348:17): [True: 181, False: 2]
  ------------------
 6349|    181|                if (rcvp.olength > 0 && rcvp.opaque != NULL) {
  ------------------
  |  Branch (6349:21): [True: 181, False: 0]
  |  Branch (6349:41): [True: 181, False: 0]
  ------------------
 6350|    181|                    ocopy = malloc(rcvp.olength);
 6351|    181|                    if (ocopy != NULL) {
  ------------------
  |  Branch (6351:25): [True: 181, False: 0]
  ------------------
 6352|    181|                        memcpy(ocopy, rcvp.opaque, rcvp.olength);
 6353|    181|                    }
 6354|    181|                }
 6355|    181|            } else {
 6356|      2|                ocopy = rcvp.opaque;
 6357|      2|                rcvp.opaque = NULL;
 6358|      2|            }
 6359|    183|            rc = _sess_process_packet(slp, sp, isp, transport,
 6360|    183|                                      ocopy, ocopy ? rcvp.olength : 0,
  ------------------
  |  Branch (6360:46): [True: 183, False: 0]
  ------------------
 6361|    183|                                      pptr, pdulen);
 6362|    183|            ocopy = NULL;
 6363|    183|            pptr += pdulen;
 6364|    183|            len_remaining -= pdulen;
 6365|    183|        }
 6366|     46|        SNMP_FREE(rcvp.packet);
  ------------------
  |  |   62|     46|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 46, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 46]
  |  |  ------------------
  ------------------
 6367|     46|        SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|     46|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 7, False: 39]
  |  |  |  Branch (62:66): [Folded, False: 46]
  |  |  ------------------
  ------------------
 6368|     46|        return rc;
 6369|     46|    }
 6370|       |
 6371|       |    /** stream transport */
 6372|       |
 6373|      0|        if (isp->packet == NULL) {
  ------------------
  |  Branch (6373:13): [True: 0, False: 0]
  ------------------
 6374|       |            /*
 6375|       |             * We have no saved packet.  Allocate one.  
 6376|       |             */
 6377|      0|            if ((isp->packet = (u_char *) malloc(rxbuf_len)) == NULL) {
  ------------------
  |  Branch (6377:17): [True: 0, False: 0]
  ------------------
 6378|      0|                DEBUGMSGTL(("sess_read", "can't malloc %" NETSNMP_PRIz
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6379|      0|                            "u bytes for rxbuf\n", rxbuf_len));
 6380|      0|                return 0;
 6381|      0|            } else {
 6382|      0|                rxbuf = isp->packet;
 6383|      0|                isp->packet_size = rxbuf_len;
 6384|      0|                isp->packet_len = 0;
 6385|      0|            }
 6386|      0|        } else {
 6387|       |            /*
 6388|       |             * We have saved a partial packet from last time.  Extend that, if
 6389|       |             * necessary, and receive new data after the old data.  
 6390|       |             */
 6391|      0|            u_char         *newbuf;
 6392|       |
 6393|      0|            if (isp->packet_size < isp->packet_len + rxbuf_len) {
  ------------------
  |  Branch (6393:17): [True: 0, False: 0]
  ------------------
 6394|      0|                newbuf =
 6395|      0|                    (u_char *) realloc(isp->packet,
 6396|      0|                                       isp->packet_len + rxbuf_len);
 6397|      0|                if (newbuf == NULL) {
  ------------------
  |  Branch (6397:21): [True: 0, False: 0]
  ------------------
 6398|      0|                    DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6399|      0|                                "can't malloc %" NETSNMP_PRIz
 6400|      0|                                "u more for rxbuf (%" NETSNMP_PRIz "u tot)\n",
 6401|      0|                                rxbuf_len, isp->packet_len + rxbuf_len));
 6402|      0|                    return 0;
 6403|      0|                } else {
 6404|      0|                    isp->packet = newbuf;
 6405|      0|                    isp->packet_size = isp->packet_len + rxbuf_len;
 6406|      0|                    rxbuf = isp->packet + isp->packet_len;
 6407|      0|                }
 6408|      0|            } else {
 6409|      0|                rxbuf = isp->packet + isp->packet_len;
 6410|      0|                rxbuf_len = isp->packet_size - isp->packet_len;
 6411|      0|            }
 6412|      0|        }
 6413|       |
 6414|      0|    length = netsnmp_transport_recv(transport, rxbuf, rxbuf_len, &opaque,
 6415|      0|                                    &olength);
 6416|       |
 6417|      0|    if (0 == length && transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6417:9): [True: 0, False: 0]
  |  Branch (6417:24): [True: 0, False: 0]
  ------------------
 6418|       |        /* this allows for a transport that needs to return from
 6419|       |         * packet processing that doesn't necessarily have any
 6420|       |         * consumable data in it. */
 6421|       |
 6422|       |        /* reset the flag since it's a per-message flag */
 6423|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6424|       |
 6425|      0|        return 0;
 6426|      0|    }
 6427|       |
 6428|       |    /*
 6429|       |     * Remote end closed connection.  
 6430|       |     */
 6431|      0|    if (length <= 0) {
  ------------------
  |  Branch (6431:9): [True: 0, False: 0]
  ------------------
 6432|       |        /*
 6433|       |         * Alert the application if possible.  
 6434|       |         */
 6435|      0|        if (sp->callback != NULL) {
  ------------------
  |  Branch (6435:13): [True: 0, False: 0]
  ------------------
 6436|      0|            DEBUGMSGTL(("sess_read", "perform callback with op=DISCONNECT\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6437|      0|            (void) sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT, sp, 0,
  ------------------
  |  |  323|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6438|      0|                                NULL, sp->callback_magic);
 6439|      0|        }
 6440|       |        /*
 6441|       |         * Close socket and mark session for deletion.  
 6442|       |         */
 6443|      0|        DEBUGMSGTL(("sess_read", "fd %" NETSNMP_FMT_SKT " closed\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6444|      0|                    transport->sock));
 6445|      0|        transport->f_close(transport);
 6446|      0|        SNMP_FREE(isp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6447|      0|        SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6448|      0|        return -1;
 6449|      0|    }
 6450|       |
 6451|      0|    {
 6452|      0|        u_char *pptr = isp->packet;
 6453|      0|	void *ocopy = NULL;
 6454|       |
 6455|      0|        isp->packet_len += length;
 6456|       |
 6457|      0|        while (isp->packet_len > 0) {
  ------------------
  |  Branch (6457:16): [True: 0, False: 0]
  ------------------
 6458|       |
 6459|       |            /*
 6460|       |             * Get the total data length we're expecting (and need to wait
 6461|       |             * for).
 6462|       |             */
 6463|      0|            if (isp->check_packet) {
  ------------------
  |  Branch (6463:17): [True: 0, False: 0]
  ------------------
 6464|      0|                pdulen = isp->check_packet(pptr, isp->packet_len);
 6465|      0|            } else {
 6466|      0|                pdulen = asn_check_packet(pptr, isp->packet_len);
 6467|      0|            }
 6468|       |
 6469|      0|            DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6470|      0|                        "  loop packet_len %" NETSNMP_PRIz "u, PDU length %"
 6471|      0|                        NETSNMP_PRIz "u\n", isp->packet_len, pdulen));
 6472|       |
 6473|      0|            if (pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6473:17): [True: 0, False: 0]
  ------------------
 6474|       |                /*
 6475|       |                 * Illegal length, drop the connection.  
 6476|       |                 */
 6477|      0|                snmp_log(LOG_ERR, 
 6478|      0|			 "Received broken packet. Closing session.\n");
 6479|      0|		if (sp->callback != NULL) {
  ------------------
  |  Branch (6479:7): [True: 0, False: 0]
  ------------------
 6480|      0|		  DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6481|      0|			      "perform callback with op=DISCONNECT\n"));
 6482|      0|		  (void)sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT,
  ------------------
  |  |  323|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6483|      0|				     sp, 0, NULL, sp->callback_magic);
 6484|      0|		}
 6485|      0|		DEBUGMSGTL(("sess_read", "fd %" NETSNMP_FMT_SKT " closed\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6486|      0|                            transport->sock));
 6487|      0|                transport->f_close(transport);
 6488|      0|                SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6489|       |                /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6490|      0|                return -1;
 6491|      0|            }
 6492|       |
 6493|      0|            if (pdulen > isp->packet_len || pdulen == 0) {
  ------------------
  |  Branch (6493:17): [True: 0, False: 0]
  |  Branch (6493:45): [True: 0, False: 0]
  ------------------
 6494|       |                /*
 6495|       |                 * We don't have a complete packet yet.  If we've already
 6496|       |                 * processed a packet, break out so we'll shift this packet
 6497|       |                 * to the start of the buffer. If we're already at the
 6498|       |                 * start, simply return and wait for more data to arrive.
 6499|       |                 */
 6500|      0|                DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6501|      0|                            "pkt not complete (need %" NETSNMP_PRIz "u got %"
 6502|      0|                            NETSNMP_PRIz "u so far)\n", pdulen,
 6503|      0|                            isp->packet_len));
 6504|       |
 6505|      0|                if (pptr != isp->packet)
  ------------------
  |  Branch (6505:21): [True: 0, False: 0]
  ------------------
 6506|      0|                    break; /* opaque freed for us outside of loop. */
 6507|       |
 6508|      0|                SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6509|      0|                return 0;
 6510|      0|            }
 6511|       |
 6512|       |            /*  We have *at least* one complete packet in the buffer now.  If
 6513|       |		we have possibly more than one packet, we must copy the opaque
 6514|       |		pointer because we may need to reuse it for a later packet.  */
 6515|       |
 6516|      0|	    if (pdulen < isp->packet_len) {
  ------------------
  |  Branch (6516:10): [True: 0, False: 0]
  ------------------
 6517|      0|		if (olength > 0 && opaque != NULL) {
  ------------------
  |  Branch (6517:7): [True: 0, False: 0]
  |  Branch (6517:22): [True: 0, False: 0]
  ------------------
 6518|      0|		    ocopy = malloc(olength);
 6519|      0|		    if (ocopy != NULL) {
  ------------------
  |  Branch (6519:11): [True: 0, False: 0]
  ------------------
 6520|      0|			memcpy(ocopy, opaque, olength);
 6521|      0|		    }
 6522|      0|		}
 6523|      0|	    } else if (pdulen == isp->packet_len) {
  ------------------
  |  Branch (6523:17): [True: 0, False: 0]
  ------------------
 6524|       |		/*  Common case -- exactly one packet.  No need to copy the
 6525|       |		    opaque pointer.  */
 6526|      0|		ocopy = opaque;
 6527|      0|		opaque = NULL;
 6528|      0|	    }
 6529|       |
 6530|      0|            if ((rc = _sess_process_packet(slp, sp, isp, transport,
  ------------------
  |  Branch (6530:17): [True: 0, False: 0]
  ------------------
 6531|      0|                                           ocopy, ocopy?olength:0, pptr,
  ------------------
  |  Branch (6531:51): [True: 0, False: 0]
  ------------------
 6532|      0|                                           pdulen))) {
 6533|       |                /*
 6534|       |                 * Something went wrong while processing this packet -- set the
 6535|       |                 * errno.  
 6536|       |                 */
 6537|      0|                if (sp->s_snmp_errno != 0) {
  ------------------
  |  Branch (6537:21): [True: 0, False: 0]
  ------------------
 6538|      0|                    SET_SNMP_ERROR(sp->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6539|      0|                }
 6540|      0|            }
 6541|       |
 6542|       |	    /*  ocopy has been free()d by _sess_process_packet by this point,
 6543|       |		so set it to NULL.  */
 6544|       |
 6545|      0|	    ocopy = NULL;
 6546|       |
 6547|       |	    /*  Step past the packet we've just dealt with.  */
 6548|       |
 6549|      0|            pptr += pdulen;
 6550|      0|            isp->packet_len -= pdulen;
 6551|      0|        }
 6552|       |
 6553|       |	/*  If we had more than one packet, then we were working with copies
 6554|       |	    of the opaque pointer, so we still need to free() the opaque
 6555|       |	    pointer itself.  */
 6556|       |
 6557|      0|	SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6558|       |
 6559|      0|        if (isp->packet_len >= SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6559:13): [True: 0, False: 0]
  ------------------
 6560|       |            /*
 6561|       |             * Obviously this should never happen!  
 6562|       |             */
 6563|      0|            snmp_log(LOG_ERR,
 6564|      0|                     "too large packet_len = %" NETSNMP_PRIz
 6565|      0|                     "u, dropping connection %" NETSNMP_FMT_SKT "\n",
 6566|      0|                     isp->packet_len, transport->sock);
 6567|      0|            transport->f_close(transport);
 6568|       |            /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6569|      0|            return -1;
 6570|      0|        } else if (isp->packet_len == 0) {
  ------------------
  |  Branch (6570:20): [True: 0, False: 0]
  ------------------
 6571|       |            /*
 6572|       |             * This is good: it means the packet buffer contained an integral
 6573|       |             * number of PDUs, so we don't have to save any data for next
 6574|       |             * time.  We can free() the buffer now to keep the memory
 6575|       |             * footprint down.
 6576|       |             */
 6577|      0|            SNMP_FREE(isp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6578|      0|            isp->packet_size = 0;
 6579|      0|            isp->packet_len = 0;
 6580|      0|            return rc;
 6581|      0|        }
 6582|       |
 6583|       |        /*
 6584|       |         * If we get here, then there is a partial packet of length
 6585|       |         * isp->packet_len bytes starting at pptr left over.  Move that to the
 6586|       |         * start of the buffer, and then realloc() the buffer down to size to
 6587|       |         * reduce the memory footprint.  
 6588|       |         */
 6589|       |
 6590|      0|        memmove(isp->packet, pptr, isp->packet_len);
 6591|      0|        DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6592|      0|                    "end: memmove(%p, %p, %" NETSNMP_PRIz "u); realloc(%p, %"
 6593|      0|                    NETSNMP_PRIz "u)\n",
 6594|      0|                    isp->packet, pptr, isp->packet_len,
 6595|      0|		    isp->packet, isp->packet_len));
 6596|       |
 6597|      0|        if ((rxbuf = (u_char *)realloc(isp->packet, isp->packet_len)) == NULL) {
  ------------------
  |  Branch (6597:13): [True: 0, False: 0]
  ------------------
 6598|       |            /*
 6599|       |             * I don't see why this should ever fail, but it's not a big deal.
 6600|       |             */
 6601|      0|            DEBUGMSGTL(("sess_read", "realloc() failed\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6602|      0|        } else {
 6603|      0|            DEBUGMSGTL(("sess_read", "realloc() okay, old buffer %p, new %p\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6604|      0|                        isp->packet, rxbuf));
 6605|      0|            isp->packet = rxbuf;
 6606|      0|            isp->packet_size = isp->packet_len;
 6607|      0|        }
 6608|      0|    }
 6609|       |
 6610|      0|    return rc;
 6611|      0|}
snmp_api.c:_sess_read_dgram_packet:
 6232|     46|{
 6233|     46|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6233:27): [True: 46, False: 0]
  ------------------
 6234|     46|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6234:41): [True: 46, False: 0]
  ------------------
 6235|     46|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6235:36): [True: 46, False: 0]
  ------------------
 6236|       |
 6237|     46|    if (!sp || !isp || !transport || !rcvp ) {
  ------------------
  |  Branch (6237:9): [True: 0, False: 46]
  |  Branch (6237:16): [True: 0, False: 46]
  |  Branch (6237:24): [True: 0, False: 46]
  |  Branch (6237:38): [True: 0, False: 46]
  ------------------
 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|     46|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)
  ------------------
  |  |   51|     46|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6242:9): [True: 0, False: 46]
  ------------------
 6243|      0|        return -2;
 6244|       |
 6245|     46|    if (NULL != rcvp->packet) {
  ------------------
  |  Branch (6245:9): [True: 0, False: 46]
  ------------------
 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|     46|    if ((rcvp->packet = (u_char *) malloc(SNMP_MAX_RCV_MSG_SIZE)) == NULL) {
  ------------------
  |  |  108|     46|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
  |  Branch (6251:9): [True: 0, False: 46]
  ------------------
 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|     46|    rcvp->packet_len = netsnmp_transport_recv(transport, rcvp->packet,
 6258|     46|                                              SNMP_MAX_RCV_MSG_SIZE,
  ------------------
  |  |  108|     46|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6259|     46|                                              &rcvp->opaque, &rcvp->olength);
 6260|     46|    if (rcvp->packet_len == -1) {
  ------------------
  |  Branch (6260:9): [True: 0, False: 46]
  ------------------
 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|     46|    if (0 == rcvp->packet_len &&
  ------------------
  |  Branch (6269:9): [True: 0, False: 46]
  ------------------
 6270|      0|        transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6270:9): [True: 0, False: 0]
  ------------------
 6271|       |        /* this allows for a transport that needs to return from
 6272|       |         * packet processing that doesn't necessarily have any
 6273|       |         * consumable data in it. */
 6274|       |
 6275|       |        /* reset the flag since it's a per-message flag */
 6276|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6277|       |
 6278|       |        /** free packet */
 6279|      0|        SNMP_FREE(rcvp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6280|      0|        SNMP_FREE(rcvp->opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6281|       |
 6282|      0|        return -2;
 6283|      0|    }
 6284|       |
 6285|     46|    return 0;
 6286|     46|}
snmp_api.c:_sess_process_packet:
 6072|    183|{
 6073|    183|    netsnmp_pdu         *pdu;
 6074|    183|    int                  rc;
 6075|       |
 6076|    183|    pdu = _sess_process_packet_parse_pdu(slp, sp, isp, transport, opaque,
 6077|    183|                                         olength, packetptr, length);
 6078|    183|    if (NULL == pdu)
  ------------------
  |  Branch (6078:9): [True: 183, False: 0]
  ------------------
 6079|    183|        return -1;
 6080|       |
 6081|       |    /*
 6082|       |     * find session to process pdu. usually that will be the current session,
 6083|       |     * but with the introduction of shared transports, another session may
 6084|       |     * have the same socket.
 6085|       |     */
 6086|      0|    do {
 6087|      0|        rc = _sess_process_packet_handle_pdu(slp, sp, isp, transport, pdu);
 6088|      0|        if (-2 != rc || !(transport->flags & NETSNMP_TRANSPORT_FLAG_SHARED))
  ------------------
  |  |   58|      0|#define		NETSNMP_TRANSPORT_FLAG_SHARED	 0x40
  ------------------
  |  Branch (6088:13): [True: 0, False: 0]
  |  Branch (6088:25): [True: 0, False: 0]
  ------------------
 6089|      0|            break;
 6090|       |
 6091|       |        /** -2 means pdu not in request list. check other sessions */
 6092|      0|        do  {
 6093|      0|            slp = slp->next;
 6094|      0|        } while (slp && slp->transport->sock != transport->sock);
  ------------------
  |  Branch (6094:18): [True: 0, False: 0]
  |  Branch (6094:25): [True: 0, False: 0]
  ------------------
 6095|      0|        if (!slp)
  ------------------
  |  Branch (6095:13): [True: 0, False: 0]
  ------------------
 6096|      0|            break; /* no more sessions with same socket */
 6097|       |
 6098|      0|        sp = slp->session;
 6099|      0|        isp = slp->internal;
 6100|      0|        transport = slp->transport;
 6101|      0|    } while(slp);
  ------------------
  |  Branch (6101:13): [True: 0, False: 0]
  ------------------
 6102|       |
 6103|      0|    if (-2 == rc) { /* did not find session for pdu */
  ------------------
  |  Branch (6103:9): [True: 0, False: 0]
  ------------------
 6104|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNPDUHANDLERS);
  ------------------
  |  |  613|      0|#define   STAT_SNMPUNKNOWNPDUHANDLERS        2
  ------------------
 6105|      0|        DEBUGMSGTL(("sess_process_packet", "unhandled PDU\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6106|      0|        snmp_free_pdu(pdu);
 6107|      0|    }
 6108|       |
 6109|      0|  return rc;
 6110|    183|}
snmp_api.c:_sess_process_packet_parse_pdu:
 5744|    183|{
 5745|    183|  netsnmp_pdu    *pdu;
 5746|    183|  int             ret = 0;
 5747|    183|  int             dump = 0, filter = 0;
 5748|       |
 5749|    183|  debug_indent_reset();
 5750|       |
 5751|    183|  DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   66|    183|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 183]
  |  |  ------------------
  ------------------
 5752|    183|	      "session %p fd %" NETSNMP_FMT_SKT " pkt %p length %d\n", slp,
 5753|    183|	      transport->sock, packetptr, length));
 5754|       |
 5755|    183|  dump = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    183|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5756|    183|                                NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|    183|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
 5757|    183|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5758|    183|  filter = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    183|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5759|    183|                                  NETSNMP_DS_LIB_FILTER_TYPE);
  ------------------
  |  |  133|    183|#define NETSNMP_DS_LIB_FILTER_TYPE         17 /* 0=NONE, 1=whitelist, -1=blacklist */
  ------------------
 5760|    183|#endif
 5761|    183|  if (dump || filter) {
  ------------------
  |  Branch (5761:7): [True: 0, False: 183]
  |  Branch (5761:15): [True: 0, False: 183]
  ------------------
 5762|      0|      int filtered = 0;
 5763|      0|      char *addrtxt = netsnmp_transport_peer_string(transport, opaque, olength);
 5764|       |
 5765|      0|      if (!addrtxt) {
  ------------------
  |  Branch (5765:11): [True: 0, False: 0]
  ------------------
 5766|      0|          DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5767|      0|                      "Failed to resolve peer address\n"));
 5768|      0|          SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5769|      0|          return NULL;
 5770|      0|      }
 5771|       |
 5772|      0|      snmp_log(LOG_DEBUG, "\nReceived %d byte packet from %s\n",
 5773|      0|               length, addrtxt);
 5774|       |
 5775|      0|      if (dump)
  ------------------
  |  Branch (5775:11): [True: 0, False: 0]
  ------------------
 5776|      0|          xdump(packetptr, length, "");
 5777|       |
 5778|      0|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5779|      0|      if (filter) {
  ------------------
  |  Branch (5779:11): [True: 0, False: 0]
  ------------------
 5780|      0|          char *sourceaddr = NULL, *c = strchr(addrtxt, '[');
 5781|      0|          const char *dropstr = NULL;
 5782|      0|          if (c) {
  ------------------
  |  Branch (5782:15): [True: 0, False: 0]
  ------------------
 5783|      0|              sourceaddr = ++c;
 5784|      0|              c = strchr(sourceaddr, ']');
 5785|      0|              if (c)
  ------------------
  |  Branch (5785:19): [True: 0, False: 0]
  ------------------
 5786|      0|                  *c = 0;
 5787|      0|              filtered = netsnmp_transport_filter_check(sourceaddr);
 5788|      0|          }
 5789|      0|          else if (!strncmp(addrtxt, "callback", 8)) {
  ------------------
  |  Branch (5789:20): [True: 0, False: 0]
  ------------------
 5790|       |              /* do not filter internal request */
 5791|      0|              DEBUGMSGTL(("sess_process_packet:filter",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5792|      0|                          "bypass packet from %s \n",
 5793|      0|                          addrtxt));
 5794|      0|              filtered = 1;
 5795|      0|          }
 5796|      0|          if ((filter == -1) && filtered)
  ------------------
  |  Branch (5796:15): [True: 0, False: 0]
  |  Branch (5796:33): [True: 0, False: 0]
  ------------------
 5797|      0|              dropstr = "matched blacklist";
 5798|      0|          else if ((filter == 1) && !filtered)
  ------------------
  |  Branch (5798:20): [True: 0, False: 0]
  |  Branch (5798:37): [True: 0, False: 0]
  ------------------
 5799|      0|              dropstr = "didn't match whitelist";
 5800|      0|          if (dropstr) {
  ------------------
  |  Branch (5800:15): [True: 0, False: 0]
  ------------------
 5801|      0|              DEBUGMSGTL(("sess_process_packet:filter",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5802|      0|                          "packet from %s %s\n",
 5803|      0|                          sourceaddr ? sourceaddr : "UNKNOWN", dropstr));
 5804|      0|              SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5805|      0|              SNMP_FREE(addrtxt);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5806|      0|              return NULL;
 5807|      0|          }
 5808|      0|      }
 5809|      0|#endif
 5810|       |
 5811|      0|      SNMP_FREE(addrtxt);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5812|      0|  }
 5813|       |
 5814|       |  /*
 5815|       |   * Do transport-level filtering (e.g. IP-address based allow/deny).  
 5816|       |   */
 5817|       |
 5818|    183|  if (isp->hook_pre) {
  ------------------
  |  Branch (5818:7): [True: 0, False: 183]
  ------------------
 5819|      0|    if (isp->hook_pre(sp, transport, opaque, olength) == 0) {
  ------------------
  |  Branch (5819:9): [True: 0, False: 0]
  ------------------
 5820|      0|      DEBUGMSGTL(("sess_process_packet", "pre-parse fail\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5821|      0|      SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5822|      0|      return NULL;
 5823|      0|    }
 5824|      0|  }
 5825|       |
 5826|    183|  if (isp->hook_create_pdu) {
  ------------------
  |  Branch (5826:7): [True: 0, False: 183]
  ------------------
 5827|      0|    pdu = isp->hook_create_pdu(transport, opaque, olength);
 5828|    183|  } else {
 5829|    183|    pdu = snmp_create_sess_pdu(transport, opaque, olength);
 5830|    183|  }
 5831|       |
 5832|    183|  if (pdu == NULL) {
  ------------------
  |  Branch (5832:7): [True: 0, False: 183]
  ------------------
 5833|      0|    snmp_log(LOG_ERR, "pdu failed to be created\n");
 5834|      0|    SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5835|      0|    return NULL;
 5836|      0|  }
 5837|       |
 5838|       |  /* if the transport was a magic tunnel, mark the PDU as having come
 5839|       |     through one. */
 5840|    183|  if (transport->flags & NETSNMP_TRANSPORT_FLAG_TUNNELED) {
  ------------------
  |  |   53|    183|#define		NETSNMP_TRANSPORT_FLAG_TUNNELED	 0x04
  ------------------
  |  Branch (5840:7): [True: 0, False: 183]
  ------------------
 5841|      0|      pdu->flags |= UCD_MSG_FLAG_TUNNELED;
  ------------------
  |  |  317|      0|#define UCD_MSG_FLAG_TUNNELED               0x4000
  ------------------
 5842|      0|  }
 5843|       |
 5844|    183|  if (isp->hook_parse) {
  ------------------
  |  Branch (5844:7): [True: 0, False: 183]
  ------------------
 5845|      0|    ret = isp->hook_parse(sp, pdu, packetptr, length);
 5846|    183|  } else {
 5847|    183|    ret = snmp_parse(slp, sp, pdu, packetptr, length);
 5848|    183|  }
 5849|       |
 5850|    183|  DEBUGMSGTL(("sess_process_packet", "received message id#%ld reqid#%ld len "
  ------------------
  |  |   66|    183|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 183]
  |  |  ------------------
  ------------------
 5851|    183|              "%u\n", pdu->msgid, pdu->reqid, length));
 5852|       |
 5853|    183|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|    183|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5853:7): [True: 183, False: 0]
  ------------------
 5854|    183|    DEBUGMSGTL(("sess_process_packet", "parse fail\n"));
  ------------------
  |  |   66|    183|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 183]
  |  |  ------------------
  ------------------
 5855|    183|  }
 5856|       |
 5857|    183|  if (isp->hook_post) {
  ------------------
  |  Branch (5857:7): [True: 0, False: 183]
  ------------------
 5858|      0|    if (isp->hook_post(sp, pdu, ret) == 0) {
  ------------------
  |  Branch (5858:9): [True: 0, False: 0]
  ------------------
 5859|      0|      DEBUGMSGTL(("sess_process_packet", "post-parse fail\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5860|      0|      ret = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 5861|      0|    }
 5862|      0|  }
 5863|       |
 5864|    183|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|    183|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5864:7): [True: 183, False: 0]
  ------------------
 5865|    183|    snmp_free_pdu(pdu);
 5866|    183|    return NULL;
 5867|    183|  }
 5868|       |
 5869|      0|  return pdu;
 5870|    183|}

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

snmp_clone_mem:
  307|    140|{
  308|    140|    *dstPtr = NULL;
  309|    140|    if (srcPtr) {
  ------------------
  |  Branch (309:9): [True: 80, False: 60]
  ------------------
  310|     80|        *dstPtr = malloc(len + 1);
  311|     80|        if (!*dstPtr) {
  ------------------
  |  Branch (311:13): [True: 0, False: 80]
  ------------------
  312|      0|            return 1;
  313|      0|        }
  314|     80|        memmove(*dstPtr, srcPtr, len);
  315|       |        /*
  316|       |         * this is for those routines that expect 0-terminated strings!!!
  317|       |         * someone should rather have called strdup
  318|       |         */
  319|     80|        ((char *) *dstPtr)[len] = 0;
  320|     80|    }
  321|    140|    return 0;
  322|    140|}
snmp_clone_pdu:
  591|     20|{
  592|     20|    return _clone_pdu(pdu, 0);  /* copies all variables */
  593|     20|}
snmp_set_var_objid:
  689|     20|{
  690|     20|    size_t          len = sizeof(oid) * name_length;
  691|       |
  692|     20|    if (vp->name != vp->name_loc && vp->name != NULL) {
  ------------------
  |  Branch (692:9): [True: 20, False: 0]
  |  Branch (692:37): [True: 0, False: 20]
  ------------------
  693|       |        /*
  694|       |         * Probably previously-allocated "big storage".  Better free it
  695|       |         * else memory leaks possible.  
  696|       |         */
  697|      0|        free(vp->name);
  698|      0|    }
  699|       |
  700|       |    /*
  701|       |     * use built-in storage for smaller values 
  702|       |     */
  703|     20|    if (len <= sizeof(vp->name_loc)) {
  ------------------
  |  Branch (703:9): [True: 20, False: 0]
  ------------------
  704|     20|        vp->name = vp->name_loc;
  705|     20|    } else {
  706|      0|        vp->name = (oid *) malloc(len);
  707|      0|        if (!vp->name)
  ------------------
  |  Branch (707:13): [True: 0, False: 0]
  ------------------
  708|      0|            return 1;
  709|      0|    }
  710|     20|    if (objid)
  ------------------
  |  Branch (710:9): [True: 20, False: 0]
  ------------------
  711|     20|        memmove(vp->name, objid, len);
  712|     20|    vp->name_length = name_length;
  713|     20|    return 0;
  714|     20|}
snmp_set_var_value:
  805|     20|{
  806|     20|    int             largeval = 1;
  807|       |
  808|       |    /*
  809|       |     * xxx-rks: why the unconditional free? why not use existing
  810|       |     * memory, if len < vars->val_len ?
  811|       |     */
  812|     20|    if (vars->val.string && vars->val.string != vars->buf) {
  ------------------
  |  Branch (812:9): [True: 0, False: 20]
  |  Branch (812:29): [True: 0, False: 0]
  ------------------
  813|      0|        free(vars->val.string);
  814|      0|    }
  815|     20|    vars->val.string = NULL;
  816|     20|    vars->val_len = 0;
  817|       |
  818|     20|    if (value == NULL && len > 0) {
  ------------------
  |  Branch (818:9): [True: 0, False: 20]
  |  Branch (818:26): [True: 0, False: 0]
  ------------------
  819|      0|        snmp_log(LOG_ERR, "bad size for NULL value\n");
  820|      0|        return 1;
  821|      0|    }
  822|       |
  823|       |    /*
  824|       |     * use built-in storage for smaller values 
  825|       |     */
  826|     20|    if (len <= sizeof(vars->buf)) {
  ------------------
  |  Branch (826:9): [True: 20, False: 0]
  ------------------
  827|     20|        vars->val.string = (u_char *) vars->buf;
  828|     20|        largeval = 0;
  829|     20|    }
  830|       |
  831|     20|    if ((0 == len) || (NULL == value)) {
  ------------------
  |  Branch (831:9): [True: 0, False: 20]
  |  Branch (831:23): [True: 0, False: 20]
  ------------------
  832|      0|        vars->val.string[0] = 0;
  833|      0|        return 0;
  834|      0|    }
  835|       |
  836|     20|    vars->val_len = len;
  837|     20|    switch (vars->type) {
  838|      0|    case ASN_INTEGER:
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (838:5): [True: 0, False: 20]
  ------------------
  839|      0|    case ASN_UNSIGNED:
  ------------------
  |  |   91|      0|#define ASN_UNSIGNED    (ASN_APPLICATION | 2)   /* RFC 1902 - same as GAUGE */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (839:5): [True: 0, False: 20]
  ------------------
  840|      0|    case ASN_TIMETICKS:
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (840:5): [True: 0, False: 20]
  ------------------
  841|     20|    case ASN_COUNTER:
  ------------------
  |  |   89|     20|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (841:5): [True: 20, False: 0]
  ------------------
  842|     20|    case ASN_UINTEGER:
  ------------------
  |  |  100|     20|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (842:5): [True: 0, False: 20]
  ------------------
  843|     20|        if (vars->val_len == sizeof(int)) {
  ------------------
  |  Branch (843:13): [True: 0, False: 20]
  ------------------
  844|      0|            if (ASN_INTEGER == vars->type) {
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (844:17): [True: 0, False: 0]
  ------------------
  845|      0|                const int      *val_int 
  846|      0|                    = (const int *) value;
  847|      0|                *(vars->val.integer) = (long) *val_int;
  848|      0|            } else {
  849|      0|                const u_int    *val_uint
  850|      0|                    = (const u_int *) value;
  851|      0|                *(vars->val.integer) = (unsigned long) *val_uint;
  852|      0|            }
  853|      0|        }
  854|     20|        else if (vars->val_len == sizeof(long)){
  ------------------
  |  Branch (854:18): [True: 20, False: 0]
  ------------------
  855|     20|            const u_long   *val_ulong
  856|     20|                = (const u_long *) value;
  857|     20|            *(vars->val.integer) = *val_ulong;
  858|     20|            if (*(vars->val.integer) > 0xffffffff) {
  ------------------
  |  Branch (858:17): [True: 0, False: 20]
  ------------------
  859|      0|                NETSNMP_LOGONCE((LOG_INFO,
  ------------------
  |  |   37|      0|#define NETSNMP_LOGONCE(x) do { \
  |  |   38|      0|        static char logged = 0; \
  |  |   39|      0|        if (!logged) {          \
  |  |  ------------------
  |  |  |  Branch (39:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   40|      0|            logged = 1;         \
  |  |   41|      0|            snmp_log x ;        \
  |  |   42|      0|        }                       \
  |  |   43|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (43:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  860|      0|                                 "truncating integer value > 32 bits\n"));
  861|      0|                *(vars->val.integer) &= 0xffffffff;
  862|      0|            }
  863|     20|        }
  864|      0|        else if (vars->val_len == sizeof(long long)){
  ------------------
  |  Branch (864:18): [True: 0, False: 0]
  ------------------
  865|      0|            const unsigned long long   *val_ullong
  866|      0|                = (const unsigned long long *) value;
  867|      0|            *(vars->val.integer) = (long) *val_ullong;
  868|      0|            if (*(vars->val.integer) > 0xffffffff) {
  ------------------
  |  Branch (868:17): [True: 0, False: 0]
  ------------------
  869|      0|                NETSNMP_LOGONCE((LOG_INFO,
  ------------------
  |  |   37|      0|#define NETSNMP_LOGONCE(x) do { \
  |  |   38|      0|        static char logged = 0; \
  |  |   39|      0|        if (!logged) {          \
  |  |  ------------------
  |  |  |  Branch (39:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   40|      0|            logged = 1;         \
  |  |   41|      0|            snmp_log x ;        \
  |  |   42|      0|        }                       \
  |  |   43|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (43:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  870|      0|                                 "truncating integer value > 32 bits\n"));
  871|      0|                *(vars->val.integer) &= 0xffffffff;
  872|      0|            }
  873|      0|        }
  874|      0|        else if (vars->val_len == sizeof(intmax_t)){
  ------------------
  |  Branch (874:18): [True: 0, False: 0]
  ------------------
  875|      0|            const uintmax_t *val_uintmax_t
  876|      0|                = (const uintmax_t *) value;
  877|      0|            *(vars->val.integer) = (long) *val_uintmax_t;
  878|      0|            if (*(vars->val.integer) > 0xffffffff) {
  ------------------
  |  Branch (878:17): [True: 0, False: 0]
  ------------------
  879|      0|                NETSNMP_LOGONCE((LOG_INFO,
  ------------------
  |  |   37|      0|#define NETSNMP_LOGONCE(x) do { \
  |  |   38|      0|        static char logged = 0; \
  |  |   39|      0|        if (!logged) {          \
  |  |  ------------------
  |  |  |  Branch (39:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   40|      0|            logged = 1;         \
  |  |   41|      0|            snmp_log x ;        \
  |  |   42|      0|        }                       \
  |  |   43|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (43:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  880|      0|                                 "truncating integer value > 32 bits\n"));
  881|      0|                *(vars->val.integer) &= 0xffffffff;
  882|      0|            }
  883|      0|        }
  884|      0|        else if (vars->val_len == sizeof(short)) {
  ------------------
  |  Branch (884:18): [True: 0, False: 0]
  ------------------
  885|      0|            if (ASN_INTEGER == vars->type) {
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (885:17): [True: 0, False: 0]
  ------------------
  886|      0|                const short      *val_short 
  887|      0|                    = (const short *) value;
  888|      0|                *(vars->val.integer) = (long) *val_short;
  889|      0|            } else {
  890|      0|                const u_short    *val_ushort
  891|      0|                    = (const u_short *) value;
  892|      0|                *(vars->val.integer) = (unsigned long) *val_ushort;
  893|      0|            }
  894|      0|        }
  895|      0|        else if (vars->val_len == sizeof(char)) {
  ------------------
  |  Branch (895:18): [True: 0, False: 0]
  ------------------
  896|      0|            if (ASN_INTEGER == vars->type) {
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (896:17): [True: 0, False: 0]
  ------------------
  897|      0|                const signed char   *val_char
  898|      0|                    = (const signed char *) value;
  899|      0|                *(vars->val.integer) = (long) *val_char;
  900|      0|            } else {
  901|      0|                    const u_char    *val_uchar
  902|      0|                    = (const u_char *) value;
  903|      0|                *(vars->val.integer) = (unsigned long) *val_uchar;
  904|      0|            }
  905|      0|        }
  906|      0|        else {
  907|      0|            snmp_log(LOG_ERR,"bad size for integer-like type (%d)\n",
  908|      0|                     (int)vars->val_len);
  909|      0|            return (1);
  910|      0|        }
  911|     20|        vars->val_len = sizeof(long);
  912|     20|        break;
  913|       |
  914|      0|    case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (914:5): [True: 0, False: 20]
  ------------------
  915|      0|    case ASN_PRIV_IMPLIED_OBJECT_ID:
  ------------------
  |  |  205|      0|#define ASN_PRIV_IMPLIED_OBJECT_ID  (ASN_PRIVATE | ASN_OBJECT_ID)       /* 6 */
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  |  |               #define ASN_PRIV_IMPLIED_OBJECT_ID  (ASN_PRIVATE | ASN_OBJECT_ID)       /* 6 */
  |  |  ------------------
  |  |  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  |  |  ------------------
  ------------------
  |  Branch (915:5): [True: 0, False: 20]
  ------------------
  916|      0|    case ASN_PRIV_INCL_RANGE:
  ------------------
  |  |  201|      0|#define ASN_PRIV_INCL_RANGE (ASN_PRIVATE | 2)
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  ------------------
  |  Branch (916:5): [True: 0, False: 20]
  ------------------
  917|      0|    case ASN_PRIV_EXCL_RANGE:
  ------------------
  |  |  202|      0|#define ASN_PRIV_EXCL_RANGE (ASN_PRIVATE | 3)
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  ------------------
  |  Branch (917:5): [True: 0, False: 20]
  ------------------
  918|      0|        if (largeval) {
  ------------------
  |  Branch (918:13): [True: 0, False: 0]
  ------------------
  919|      0|            vars->val.objid = (oid *) malloc(vars->val_len);
  920|      0|        }
  921|      0|        if (vars->val.objid == NULL) {
  ------------------
  |  Branch (921:13): [True: 0, False: 0]
  ------------------
  922|      0|            snmp_log(LOG_ERR,"no storage for OID\n");
  923|      0|            return 1;
  924|      0|        }
  925|      0|        memmove(vars->val.objid, value, vars->val_len);
  926|      0|        break;
  927|       |
  928|      0|    case ASN_IPADDRESS: /* snmp_build_var_op treats IPADDR like a string */
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (928:5): [True: 0, False: 20]
  ------------------
  929|      0|        if (4 != vars->val_len) {
  ------------------
  |  Branch (929:13): [True: 0, False: 0]
  ------------------
  930|      0|            netsnmp_assert("ipaddress length == 4");
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  931|      0|        }
  932|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  933|      0|    case ASN_PRIV_IMPLIED_OCTET_STR:
  ------------------
  |  |  204|      0|#define ASN_PRIV_IMPLIED_OCTET_STR  (ASN_PRIVATE | ASN_OCTET_STR)       /* 4 */
  |  |  ------------------
  |  |  |  |   93|      0|#define ASN_PRIVATE	    0xC0U
  |  |  ------------------
  |  |               #define ASN_PRIV_IMPLIED_OCTET_STR  (ASN_PRIVATE | ASN_OCTET_STR)       /* 4 */
  |  |  ------------------
  |  |  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  |  |  ------------------
  ------------------
  |  Branch (933:5): [True: 0, False: 20]
  ------------------
  934|      0|    case ASN_OCTET_STR:
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (934:5): [True: 0, False: 20]
  ------------------
  935|      0|    case ASN_BIT_STR:
  ------------------
  |  |   77|      0|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (935:5): [True: 0, False: 20]
  ------------------
  936|      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 (936:5): [True: 0, False: 20]
  ------------------
  937|      0|    case ASN_NSAP:
  ------------------
  |  |   98|      0|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (937:5): [True: 0, False: 20]
  ------------------
  938|      0|        if (vars->val_len >= sizeof(vars->buf)) {
  ------------------
  |  Branch (938:13): [True: 0, False: 0]
  ------------------
  939|      0|            vars->val.string = (u_char *) malloc(vars->val_len + 1);
  940|      0|        }
  941|      0|        if (vars->val.string == NULL) {
  ------------------
  |  Branch (941:13): [True: 0, False: 0]
  ------------------
  942|      0|            snmp_log(LOG_ERR,"no storage for string\n");
  943|      0|            return 1;
  944|      0|        }
  945|      0|        memmove(vars->val.string, value, vars->val_len);
  946|       |        /*
  947|       |         * Make sure the string is zero-terminated; some bits of code make
  948|       |         * this assumption.  Easier to do this here than fix all these wrong
  949|       |         * assumptions.  
  950|       |         */
  951|      0|        vars->val.string[vars->val_len] = '\0';
  952|      0|        break;
  953|       |
  954|      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 (954:5): [True: 0, False: 20]
  ------------------
  955|      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 (955:5): [True: 0, False: 20]
  ------------------
  956|      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 (956:5): [True: 0, False: 20]
  ------------------
  957|      0|    case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (957:5): [True: 0, False: 20]
  ------------------
  958|      0|        vars->val_len = 0;
  959|      0|        vars->val.string = NULL;
  960|      0|        break;
  961|       |
  962|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
  963|      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 (963:5): [True: 0, False: 20]
  ------------------
  964|      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 (964:5): [True: 0, False: 20]
  ------------------
  965|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
  966|      0|    case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (966:5): [True: 0, False: 20]
  ------------------
  967|      0|        if (largeval || vars->val_len != sizeof(struct counter64)) {
  ------------------
  |  Branch (967:13): [True: 0, False: 0]
  |  Branch (967:25): [True: 0, False: 0]
  ------------------
  968|      0|            snmp_log(LOG_ERR,"bad size for counter 64 (%d)\n",
  969|      0|                     (int)vars->val_len);
  970|      0|            return (1);
  971|      0|        }
  972|      0|        vars->val_len = sizeof(struct counter64);
  973|      0|        memmove(vars->val.counter64, value, vars->val_len);
  974|      0|        break;
  975|       |
  976|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
  977|      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 (977:5): [True: 0, False: 20]
  ------------------
  978|      0|        if (largeval) {
  ------------------
  |  Branch (978:13): [True: 0, False: 0]
  ------------------
  979|      0|            snmp_log(LOG_ERR,"bad size for opaque float (%d)\n",
  980|      0|                     (int)vars->val_len);
  981|      0|            return (1);
  982|      0|        }
  983|      0|        vars->val_len = sizeof(float);
  984|      0|        memmove(vars->val.floatVal, value, vars->val_len);
  985|      0|        break;
  986|       |
  987|      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 (987:5): [True: 0, False: 20]
  ------------------
  988|      0|        if (largeval) {
  ------------------
  |  Branch (988:13): [True: 0, False: 0]
  ------------------
  989|      0|            snmp_log(LOG_ERR,"bad size for opaque double (%d)\n",
  990|      0|                     (int)vars->val_len);
  991|      0|            return (1);
  992|      0|        }
  993|      0|        vars->val_len = sizeof(double);
  994|      0|        memmove(vars->val.doubleVal, value, vars->val_len);
  995|      0|        break;
  996|       |
  997|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
  998|       |
  999|      0|    default:
  ------------------
  |  Branch (999:5): [True: 0, False: 20]
  ------------------
 1000|      0|        snmp_log(LOG_ERR,"Internal error in type switching\n");
 1001|      0|        snmp_set_detail("Internal error in type switching\n");
 1002|      0|        return (1);
 1003|     20|    }
 1004|       |
 1005|     20|    return 0;
 1006|     20|}
netsnmp_query_shutdown:
 1257|     47|netsnmp_query_shutdown(void) {
 1258|     47|    if (_def_query_session) {
  ------------------
  |  Branch (1258:9): [True: 0, False: 47]
  ------------------
 1259|      0|        snmp_close(_def_query_session);
 1260|       |        _def_query_session = NULL;
 1261|      0|    }
 1262|     47|}
snmp_client.c:_copy_varlist:
  426|     20|{                               /* !=0 number variables to copy */
  427|     20|    netsnmp_variable_list *newhead, *newvar, *oldvar;
  428|     20|    int             ii = 0;
  429|       |
  430|     20|    newhead = NULL;
  431|     20|    oldvar = NULL;
  432|       |
  433|     20|    while (var && (copy_count-- > 0)) {
  ------------------
  |  Branch (433:12): [True: 0, False: 20]
  |  Branch (433:19): [True: 0, False: 0]
  ------------------
  434|       |        /*
  435|       |         * Drop the specified variable (if applicable) 
  436|       |         * xxx hmm, is it intentional that dropping the errindex
  437|       |         *     counts towards copy_count?
  438|       |         */
  439|      0|        if (++ii == errindex) {
  ------------------
  |  Branch (439:13): [True: 0, False: 0]
  ------------------
  440|      0|            var = var->next_variable;
  441|      0|            continue;
  442|      0|        }
  443|       |
  444|       |        /*
  445|       |         * clone the next variable. Cleanup if alloc fails 
  446|       |         */
  447|      0|        newvar = (netsnmp_variable_list *)
  448|      0|            malloc(sizeof(netsnmp_variable_list));
  449|      0|        if (snmp_clone_var(var, newvar)) {
  ------------------
  |  Branch (449:13): [True: 0, False: 0]
  ------------------
  450|      0|            if (newvar)
  ------------------
  |  Branch (450:17): [True: 0, False: 0]
  ------------------
  451|      0|                free(newvar);
  452|      0|            snmp_free_varbind(newhead);
  453|      0|            return NULL;
  454|      0|        }
  455|       |
  456|       |        /*
  457|       |         * add cloned variable to new list  
  458|       |         */
  459|      0|        if (NULL == newhead)
  ------------------
  |  Branch (459:13): [True: 0, False: 0]
  ------------------
  460|      0|            newhead = newvar;
  461|      0|        if (oldvar)
  ------------------
  |  Branch (461:13): [True: 0, False: 0]
  ------------------
  462|      0|            oldvar->next_variable = newvar;
  463|      0|        oldvar = newvar;
  464|       |
  465|      0|        var = var->next_variable;
  466|      0|    }
  467|     20|    return newhead;
  468|     20|}
snmp_client.c:_clone_pdu:
  559|     20|{
  560|     20|    netsnmp_pdu    *newpdu;
  561|       |
  562|     20|    newpdu = _clone_pdu_header(pdu);
  563|     20|    if (!newpdu)
  ------------------
  |  Branch (563:9): [True: 0, False: 20]
  ------------------
  564|      0|        return newpdu;
  565|     20|    newpdu = _copy_pdu_vars(pdu, newpdu, drop_err, 0, 10000);   /* skip none, copy all */
  566|       |
  567|     20|    return newpdu;
  568|     20|}
snmp_client.c:_clone_pdu_header:
  361|     20|{
  362|     20|    netsnmp_pdu    *newpdu;
  363|     20|    struct snmp_secmod_def *sptr;
  364|     20|    int ret;
  365|       |
  366|     20|    if (!pdu)
  ------------------
  |  Branch (366:9): [True: 0, False: 20]
  ------------------
  367|      0|        return NULL;
  368|       |
  369|     20|    newpdu = netsnmp_memdup(pdu, sizeof(netsnmp_pdu));
  370|     20|    if (!newpdu)
  ------------------
  |  Branch (370:9): [True: 0, False: 20]
  ------------------
  371|      0|        return NULL;
  372|       |
  373|       |    /*
  374|       |     * reset copied pointers if copy fails 
  375|       |     */
  376|     20|    newpdu->variables = NULL;
  377|     20|    newpdu->enterprise = NULL;
  378|     20|    newpdu->community = NULL;
  379|     20|    newpdu->securityEngineID = NULL;
  380|     20|    newpdu->securityName = NULL;
  381|     20|    newpdu->contextEngineID = NULL;
  382|     20|    newpdu->contextName = NULL;
  383|     20|    newpdu->transport_data = NULL;
  384|     20|    newpdu->securityStateRef = NULL;
  385|       |
  386|       |    /*
  387|       |     * copy buffers individually. If any copy fails, all are freed. 
  388|       |     */
  389|     20|    if (snmp_clone_mem((void **) &newpdu->enterprise, pdu->enterprise,
  ------------------
  |  Branch (389:9): [True: 0, False: 20]
  ------------------
  390|     20|                       sizeof(oid) * pdu->enterprise_length) ||
  391|     20|        snmp_clone_mem((void **) &newpdu->community, pdu->community,
  ------------------
  |  Branch (391:9): [True: 0, False: 20]
  ------------------
  392|     20|                       pdu->community_len) ||
  393|     20|        snmp_clone_mem((void **) &newpdu->contextEngineID,
  ------------------
  |  Branch (393:9): [True: 0, False: 20]
  ------------------
  394|     20|                       pdu->contextEngineID, pdu->contextEngineIDLen)
  395|     20|        || snmp_clone_mem((void **) &newpdu->securityEngineID,
  ------------------
  |  Branch (395:12): [True: 0, False: 20]
  ------------------
  396|     20|                          pdu->securityEngineID, pdu->securityEngineIDLen)
  397|     20|        || snmp_clone_mem((void **) &newpdu->contextName, pdu->contextName,
  ------------------
  |  Branch (397:12): [True: 0, False: 20]
  ------------------
  398|     20|                          pdu->contextNameLen)
  399|     20|        || snmp_clone_mem((void **) &newpdu->securityName,
  ------------------
  |  Branch (399:12): [True: 0, False: 20]
  ------------------
  400|     20|                          pdu->securityName, pdu->securityNameLen)
  401|     20|        || snmp_clone_mem((void **) &newpdu->transport_data,
  ------------------
  |  Branch (401:12): [True: 0, False: 20]
  ------------------
  402|     20|                          pdu->transport_data,
  403|     20|                          pdu->transport_data_length)) {
  404|      0|        snmp_free_pdu(newpdu);
  405|      0|        return NULL;
  406|      0|    }
  407|       |
  408|     20|    sptr = find_sec_mod(newpdu->securityModel);
  409|     20|    if (sptr && sptr->pdu_clone) {
  ------------------
  |  Branch (409:9): [True: 20, False: 0]
  |  Branch (409:17): [True: 20, False: 0]
  ------------------
  410|       |        /* call security model if it needs to know about this */
  411|     20|        ret = sptr->pdu_clone(pdu, newpdu);
  412|     20|        if (ret) {
  ------------------
  |  Branch (412:13): [True: 0, False: 20]
  ------------------
  413|      0|            snmp_free_pdu(newpdu);
  414|      0|            return NULL;
  415|      0|        }
  416|     20|    }
  417|       |
  418|     20|    return newpdu;
  419|     20|}
snmp_client.c:_copy_pdu_vars:
  496|     20|{                               /* !=0 number of variables to copy */
  497|     20|    netsnmp_variable_list *var;
  498|       |#ifdef TEMPORARILY_DISABLED
  499|       |    int             copied;
  500|       |#endif
  501|     20|    int             drop_idx;
  502|       |
  503|     20|    if (!newpdu)
  ------------------
  |  Branch (503:9): [True: 0, False: 20]
  ------------------
  504|      0|        return NULL;            /* where is PDU to copy to ? */
  505|       |
  506|     20|    if (drop_err)
  ------------------
  |  Branch (506:9): [True: 0, False: 20]
  ------------------
  507|      0|        drop_idx = pdu->errindex - skip_count;
  508|     20|    else
  509|     20|        drop_idx = 0;
  510|       |
  511|     20|    var = pdu->variables;
  512|     20|    while (var && (skip_count-- > 0))   /* skip over pdu variables */
  ------------------
  |  Branch (512:12): [True: 0, False: 20]
  |  Branch (512:19): [True: 0, False: 0]
  ------------------
  513|      0|        var = var->next_variable;
  514|       |
  515|       |#ifdef TEMPORARILY_DISABLED
  516|       |    copied = 0;
  517|       |    if (pdu->flags & UCD_MSG_FLAG_FORCE_PDU_COPY)
  518|       |        copied = 1;             /* We're interested in 'empty' responses too */
  519|       |#endif
  520|       |
  521|     20|    newpdu->variables = _copy_varlist(var, drop_idx, copy_count);
  522|       |#ifdef TEMPORARILY_DISABLED
  523|       |    if (newpdu->variables)
  524|       |        copied = 1;
  525|       |#endif
  526|       |
  527|       |#ifdef ALSO_TEMPORARILY_DISABLED
  528|       |    /*
  529|       |     * Error if bad errindex or if target PDU has no variables copied 
  530|       |     */
  531|       |    if ((drop_err && (ii < pdu->errindex))
  532|       |#ifdef TEMPORARILY_DISABLED
  533|       |        /*
  534|       |         * SNMPv3 engineID probes are allowed to be empty.
  535|       |         * See the comment in snmp_api.c for further details 
  536|       |         */
  537|       |        || copied == 0
  538|       |#endif
  539|       |        ) {
  540|       |        snmp_free_pdu(newpdu);
  541|       |        return 0;
  542|       |    }
  543|       |#endif
  544|     20|    return newpdu;
  545|     20|}

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

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

init_snmp_logging:
  168|     47|{
  169|     47|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "logTimestamp", 
  ------------------
  |  |   72|     47|#define ASN_BOOLEAN	    0x01U
  ------------------
  170|     47|			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   64|     47|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  171|     47|    register_prenetsnmp_mib_handler("snmp", "logOption",
  172|     47|                                    parse_config_logOption, NULL, "string");
  173|       |
  174|     47|}
shutdown_snmp_logging:
  178|     47|{
  179|     47|   snmp_disable_log();
  180|     47|   while(NULL != logh_head)
  ------------------
  |  Branch (180:10): [True: 0, False: 47]
  ------------------
  181|      0|      netsnmp_remove_loghandler( logh_head );
  182|     47|}
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|     47|{
  691|     47|    netsnmp_log_handler *logh;
  692|       |
  693|     47|    for (logh = logh_head; logh; logh = logh->next) {
  ------------------
  |  Branch (693:28): [True: 0, False: 47]
  ------------------
  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|     47|}
log_handler_stdouterr:
 1101|  2.30k|{
 1102|  2.30k|    static int      newline = 1;	 /* MTCRITICAL_RESOURCE */
 1103|  2.30k|    const char     *newline_ptr;
 1104|  2.30k|    char            sbuf[40];
 1105|       |
 1106|  2.30k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  2.30k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1106:9): [True: 0, False: 2.30k]
  ------------------
 1107|  2.30k|                               NETSNMP_DS_LIB_LOG_TIMESTAMP) && newline) {
  ------------------
  |  |   64|  2.30k|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  |  Branch (1107:65): [True: 0, False: 0]
  ------------------
 1108|      0|        sprintf_stamp(NULL, sbuf);
 1109|  2.30k|    } else {
 1110|  2.30k|        strcpy(sbuf, "");
 1111|  2.30k|    }
 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.30k|    newline_ptr = strrchr(str, '\n');
 1117|  2.30k|    newline = newline_ptr && newline_ptr[1] == 0;
  ------------------
  |  Branch (1117:15): [True: 2.30k, False: 0]
  |  Branch (1117:30): [True: 2.30k, False: 0]
  ------------------
 1118|       |
 1119|  2.30k|    if (logh->imagic)
  ------------------
  |  Branch (1119:9): [True: 0, False: 2.30k]
  ------------------
 1120|      0|       printf(         "%s%s", sbuf, str);
 1121|  2.30k|    else
 1122|  2.30k|       fprintf(stderr, "%s%s", sbuf, str);
 1123|       |
 1124|  2.30k|    return 1;
 1125|  2.30k|}
snmp_log_string:
 1292|  2.30k|{
 1293|  2.30k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1294|  2.30k|    static int stderr_enabled = 0;
 1295|  2.30k|    static netsnmp_log_handler lh = { 1, 0, 0, 0, "stderr",
 1296|  2.30k|                                      log_handler_stdouterr, 0, NULL,  NULL,
 1297|  2.30k|                                      NULL };
 1298|  2.30k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1299|  2.30k|    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.30k|    if (0 == logh_enabled) {
  ------------------
  |  Branch (1305:9): [True: 2.30k, False: 0]
  ------------------
 1306|  2.30k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1307|  2.30k|        if (!stderr_enabled) {
  ------------------
  |  Branch (1307:13): [True: 1, False: 2.30k]
  ------------------
 1308|      1|            ++stderr_enabled;
 1309|      1|            netsnmp_set_line_buffering(stderr);
 1310|      1|        }
 1311|  2.30k|        log_handler_stdouterr( &lh, priority, str );
 1312|  2.30k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1313|       |
 1314|  2.30k|        return;
 1315|  2.30k|    }
 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.30k|{
 1380|  2.30k|    char           *buffer = NULL;
 1381|  2.30k|    int             length;
 1382|       |
 1383|  2.30k|    length = vasprintf(&buffer, format, ap);
 1384|  2.30k|    if (length < 0) {
  ------------------
  |  Branch (1384:9): [True: 0, False: 2.30k]
  ------------------
 1385|      0|        snmp_log_string(LOG_ERR, "Could not format log-string\n");
 1386|      0|        return -1;
 1387|      0|    }
 1388|       |
 1389|  2.30k|    snmp_log_string(priority, buffer);
 1390|  2.30k|    free(buffer);
 1391|  2.30k|    return 0;
 1392|  2.30k|}
snmp_log:
 1403|  2.30k|{
 1404|  2.30k|    va_list         ap;
 1405|  2.30k|    int             ret;
 1406|  2.30k|    va_start(ap, format);
 1407|  2.30k|    ret = snmp_vlog(priority, format, ap);
 1408|       |    va_end(ap);
 1409|  2.30k|    return (ret);
 1410|  2.30k|}

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

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

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

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

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

usm_get_user2:
  517|     20|{
  518|     20|    DEBUGMSGTL(("usm", "getting user %.*s\n", (int)nameLen,
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
  519|     20|                (const char *)name));
  520|     20|    return usm_get_user_from_list(engineID, engineIDLen, name, nameLen,
  521|     20|                                  userList, 1);
  522|     20|}
usm_free_user:
  749|    141|{
  750|    141|    if (user == NULL)
  ------------------
  |  Branch (750:9): [True: 94, False: 47]
  ------------------
  751|     94|        return NULL;
  752|       |
  753|     47|    SNMP_FREE(user->engineID);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 47]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  754|     47|    SNMP_FREE(user->name);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  755|     47|    SNMP_FREE(user->secName);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  756|     47|    SNMP_FREE(user->cloneFrom);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  757|     47|    SNMP_FREE(user->userPublicString);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 47]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  758|     47|    SNMP_FREE(user->authProtocol);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  759|     47|    SNMP_FREE(user->privProtocol);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  760|       |
  761|     47|    if (user->authKey != NULL) {
  ------------------
  |  Branch (761:9): [True: 0, False: 47]
  ------------------
  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|     47|    if (user->privKey != NULL) {
  ------------------
  |  Branch (766:9): [True: 0, False: 47]
  ------------------
  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|     47|    if (user->authKeyKu != NULL) {
  ------------------
  |  Branch (771:9): [True: 0, False: 47]
  ------------------
  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|     47|    if (user->privKeyKu != NULL) {
  ------------------
  |  Branch (776:9): [True: 0, False: 47]
  ------------------
  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|     47|#ifdef NETSNMP_USE_OPENSSL
  782|     47|    if (user->usmDHUserAuthKeyChange)
  ------------------
  |  Branch (782:9): [True: 0, False: 47]
  ------------------
  783|      0|    {
  784|      0|        DH_free(user->usmDHUserAuthKeyChange);
  785|      0|        user->usmDHUserAuthKeyChange = NULL;
  786|      0|    }
  787|       |
  788|     47|    if (user->usmDHUserPrivKeyChange)
  ------------------
  |  Branch (788:9): [True: 0, False: 47]
  ------------------
  789|      0|    {
  790|      0|        DH_free(user->usmDHUserPrivKeyChange);
  791|      0|        user->usmDHUserPrivKeyChange = NULL;
  792|      0|    }
  793|     47|#endif
  794|       |
  795|       |    /*
  796|       |     * FIX  Why not put this check *first?*
  797|       |     */
  798|     47|    if (user->prev != NULL && user->prev != (struct usmUser *)-1) {   /* ack, this shouldn't happen */
  ------------------
  |  Branch (798:9): [True: 0, False: 47]
  |  Branch (798:31): [True: 0, False: 0]
  ------------------
  799|      0|        user->prev->next = user->next;
  800|      0|    }
  801|     47|    if (user->next != NULL && user->next != (struct usmUser *)-1) {
  ------------------
  |  Branch (801:9): [True: 0, False: 47]
  |  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|     47|    SNMP_ZERO(user, sizeof(*user));
  ------------------
  |  |   77|     47|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 47, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 47]
  |  |  ------------------
  ------------------
  811|     47|    SNMP_FREE(user);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
  812|       |
  813|     47|    return NULL;                /* for convenience to returns from calling functions */
  814|       |
  815|    141|}                               /* end usm_free_user() */
usm_create_user:
 4097|     47|{
 4098|     47|    struct usmUser *newUser;
 4099|       |
 4100|       |    /*
 4101|       |     * create the new user 
 4102|       |     */
 4103|     47|    newUser = calloc(1, sizeof(struct usmUser));
 4104|     47|    if (newUser == NULL)
  ------------------
  |  Branch (4104:9): [True: 0, False: 47]
  ------------------
 4105|      0|        return NULL;
 4106|       |
 4107|       |    /*
 4108|       |     * fill the auth/priv protocols 
 4109|       |     */
 4110|     47|    if ((newUser->authProtocol =
  ------------------
  |  Branch (4110:9): [True: 0, False: 47]
  ------------------
 4111|     47|         snmp_duplicate_objid(usmNoAuthProtocol,
 4112|     47|                              OID_LENGTH(usmNoAuthProtocol))) ==
  ------------------
  |  |   64|     47|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     47|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4113|     47|        NULL)
 4114|      0|        return usm_free_user(newUser);
 4115|     47|    newUser->authProtocolLen = OID_LENGTH(usmNoAuthProtocol);
  ------------------
  |  |   64|     47|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     47|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4116|       |
 4117|     47|    if ((newUser->privProtocol =
  ------------------
  |  Branch (4117:9): [True: 0, False: 47]
  ------------------
 4118|     47|         snmp_duplicate_objid(usmNoPrivProtocol,
 4119|     47|                              OID_LENGTH(usmNoPrivProtocol))) ==
  ------------------
  |  |   64|     47|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     47|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4120|     47|        NULL)
 4121|      0|        return usm_free_user(newUser);
 4122|     47|    newUser->privProtocolLen = OID_LENGTH(usmNoPrivProtocol);
  ------------------
  |  |   64|     47|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     47|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4123|       |
 4124|       |    /*
 4125|       |     * set the storage type to nonvolatile, and the status to ACTIVE 
 4126|       |     */
 4127|     47|    newUser->userStorageType = ST_NONVOLATILE;
  ------------------
  |  |   52|     47|#define ST_NONVOLATILE	3
  ------------------
 4128|     47|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|     47|#define RS_ACTIVE	        1
  ------------------
 4129|     47|    return newUser;
 4130|       |
 4131|     47|}                               /* end usm_clone_user() */
get_default_authtype:
 5076|     94|{
 5077|     94|    if (defaultAuthType == NULL) {
  ------------------
  |  Branch (5077:9): [True: 1, False: 93]
  ------------------
 5078|      1|        defaultAuthType = SNMP_DEFAULT_AUTH_PROTO;
  ------------------
  |  |   94|      1|#define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
  ------------------
 5079|      1|        defaultAuthTypeLen = SNMP_DEFAULT_AUTH_PROTOLEN;
  ------------------
  |  |   98|      1|#define SNMP_DEFAULT_AUTH_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO)
  |  |  ------------------
  |  |  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5080|      1|    }
 5081|     94|    if (len)
  ------------------
  |  Branch (5081:9): [True: 47, False: 47]
  ------------------
 5082|     47|        *len = defaultAuthTypeLen;
 5083|     94|    return defaultAuthType;
 5084|     94|}
get_default_privtype:
 5098|     94|{
 5099|     94|    if (defaultPrivType == NULL) {
  ------------------
  |  Branch (5099:9): [True: 1, False: 93]
  ------------------
 5100|      1|        defaultPrivType = SNMP_DEFAULT_PRIV_PROTO;
  ------------------
  |  |  100|      1|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5101|      1|        defaultPrivTypeLen = SNMP_DEFAULT_PRIV_PROTOLEN;
  ------------------
  |  |  104|      1|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5102|      1|    }
 5103|     94|    if (len)
  ------------------
  |  Branch (5103:9): [True: 47, False: 47]
  ------------------
 5104|     47|        *len = defaultPrivTypeLen;
 5105|     94|    return defaultPrivType;
 5106|     94|}
init_usm:
 5198|     47|{
 5199|     47|    struct snmp_secmod_def *def;
 5200|     47|    char *type;
 5201|       |
 5202|     47|    DEBUGMSGTL(("init_usm", "unit_usm: %" NETSNMP_PRIo "u %" NETSNMP_PRIo "u\n",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 5203|     47|                usmNoPrivProtocol[0], usmNoPrivProtocol[1]));
 5204|       |
 5205|     47|    sc_init();                  /* initialize scapi code */
 5206|       |
 5207|       |    /*
 5208|       |     * register ourselves as a security service
 5209|       |     */
 5210|     47|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|     47|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
 5211|     47|    if (def == NULL)
  ------------------
  |  Branch (5211:9): [True: 0, False: 47]
  ------------------
 5212|      0|        return;
 5213|       |    /*
 5214|       |     * XXX: def->init_sess_secmod move stuff from snmp_api.c
 5215|       |     */
 5216|     47|    def->encode_reverse = usm_secmod_rgenerate_out_msg;
 5217|     47|    def->encode_forward = usm_secmod_generate_out_msg;
 5218|     47|    def->decode = usm_secmod_process_in_msg;
 5219|     47|    def->pdu_clone = usm_clone;
 5220|     47|    def->pdu_free_state_ref = usm_free_usmStateReference;
 5221|     47|    def->session_setup = usm_session_init;
 5222|     47|    def->handle_report = usm_handle_report;
 5223|     47|    def->probe_engineid = usm_discover_engineid;
 5224|     47|    def->post_probe_engineid = usm_create_user_from_session_hook;
 5225|     47|    if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |   40|     47|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  ------------------
  |  |  |  |  295|     47|#define SNMP_SEC_MODEL_USM		3
  |  |  ------------------
  ------------------
                  if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5225:9): [True: 0, False: 47]
  ------------------
 5226|      0|        SNMP_FREE(def);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5227|      0|        snmp_log(LOG_ERR, "could not register usm sec mod\n");
 5228|      0|        return;
 5229|      0|    }
 5230|       |
 5231|     47|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5232|     47|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|     47|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 5233|     47|                           init_usm_post_config, NULL);
 5234|       |
 5235|     47|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5236|     47|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|     47|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5237|     47|                           deinit_usm_post_config, NULL);
 5238|       |
 5239|     47|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5240|     47|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|     47|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5241|     47|                           free_engineID, NULL);
 5242|       |
 5243|     47|    register_config_handler("snmp", "defAuthType", snmpv3_authtype_conf,
 5244|     47|                            NULL, "MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224");
 5245|     47|    register_config_handler("snmp", "defPrivType", snmpv3_privtype_conf,
 5246|     47|                            NULL,
 5247|     47|                            "DES"
 5248|     47|#ifdef HAVE_AES
 5249|     47|                            "|AES|AES-128"
 5250|     47|#ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
 5251|     47|                            "|AES-192|AES-256"
 5252|     47|#endif /* NETSNMP_DRAFT_BLUMENTHAL_AES_04 */
 5253|       |#else
 5254|       |                            " (AES support not available)"
 5255|       |#endif
 5256|     47|                           );
 5257|       |
 5258|       |    /*
 5259|       |     * Free stuff at shutdown time
 5260|       |     */
 5261|     47|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     47|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5262|     47|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|     47|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5263|     47|                           free_enginetime_on_shutdown, NULL);
 5264|       |
 5265|       |
 5266|     47|    type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|     47|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
 5267|       |
 5268|     47|    register_config_handler(type, "userSetAuthPass", usm_set_password,
 5269|     47|                            NULL, NULL);
 5270|     47|    register_config_handler(type, "userSetPrivPass", usm_set_password,
 5271|     47|                            NULL, NULL);
 5272|     47|    register_config_handler(type, "userSetAuthKey", usm_set_password, NULL,
 5273|     47|                            NULL);
 5274|     47|    register_config_handler(type, "userSetPrivKey", usm_set_password, NULL,
 5275|     47|                            NULL);
 5276|     47|    register_config_handler(type, "userSetAuthLocalKey", usm_set_password,
 5277|     47|                            NULL, NULL);
 5278|     47|    register_config_handler(type, "userSetPrivLocalKey", usm_set_password,
 5279|     47|                            NULL, NULL);
 5280|     47|}
shutdown_usm:
 5284|     47|{
 5285|     47|    free_etimelist();
 5286|     47|    clear_user_list();
 5287|     47|}
snmpusm.c:usm_get_user_from_list:
  482|     20|{
  483|     20|    struct usmUser *ptr;
  484|       |
  485|     20|    for (ptr = puserList; ptr != NULL; ptr = ptr->next) {
  ------------------
  |  Branch (485:27): [True: 0, False: 20]
  ------------------
  486|      0|        if (ptr->name && strlen(ptr->name) == nameLen &&
  ------------------
  |  Branch (486:13): [True: 0, False: 0]
  |  Branch (486:26): [True: 0, False: 0]
  ------------------
  487|      0|            memcmp(ptr->name, name, nameLen) == 0) {
  ------------------
  |  Branch (487:13): [True: 0, False: 0]
  ------------------
  488|      0|          DEBUGMSGTL(("usm", "match on user %s\n", ptr->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]
  |  |  ------------------
  ------------------
  489|      0|          if (ptr->engineIDLen == engineIDLen &&
  ------------------
  |  Branch (489:15): [True: 0, False: 0]
  ------------------
  490|      0|            ((ptr->engineID == NULL && engineID == NULL) ||
  ------------------
  |  Branch (490:15): [True: 0, False: 0]
  |  Branch (490:40): [True: 0, False: 0]
  ------------------
  491|      0|             (ptr->engineID != NULL && engineID != NULL &&
  ------------------
  |  Branch (491:15): [True: 0, False: 0]
  |  Branch (491:40): [True: 0, False: 0]
  ------------------
  492|      0|              memcmp(ptr->engineID, engineID, engineIDLen) == 0)))
  ------------------
  |  Branch (492:15): [True: 0, False: 0]
  ------------------
  493|      0|            return ptr;
  494|      0|          DEBUGMSGTL(("usm", "no match on engineID ("));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %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|          if (engineID) {
  ------------------
  |  Branch (495:15): [True: 0, False: 0]
  ------------------
  496|      0|              DEBUGMSGHEX(("usm", engineID, engineIDLen));
  ------------------
  |  |   71|      0|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  497|      0|          } else {
  498|      0|              DEBUGMSGTL(("usm", "Empty EngineID"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  499|      0|          }
  500|      0|          DEBUGMSG(("usm", ")\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]
  |  |  ------------------
  ------------------
  501|      0|        }
  502|      0|    }
  503|       |
  504|       |    /*
  505|       |     * return "" user used to facilitate engineID discovery
  506|       |     */
  507|     20|    if (use_default && !strcmp(name, "")) {
  ------------------
  |  Branch (507:9): [True: 20, False: 0]
  |  Branch (507:24): [True: 20, False: 0]
  ------------------
  508|     20|        DEBUGMSGTL(("usm", "return noNameUser\n"));
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
  509|     20|        return noNameUser;
  510|     20|    }
  511|      0|    return NULL;
  512|     20|}
snmpusm.c:usm_secmod_rgenerate_out_msg:
 2431|     20|{
 2432|     20|    if (!parms)
  ------------------
  |  Branch (2432:9): [True: 0, False: 20]
  ------------------
 2433|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 2434|       |
 2435|     20|    return usm_rgenerate_out_msg(parms->msgProcModel,
 2436|     20|                                 parms->globalData, parms->globalDataLen,
 2437|     20|                                 parms->maxMsgSize, parms->secModel,
 2438|     20|                                 parms->secEngineID, parms->secEngineIDLen,
 2439|     20|                                 parms->secName, parms->secNameLen,
 2440|     20|                                 parms->secLevel,
 2441|     20|                                 parms->scopedPdu, parms->scopedPduLen,
 2442|     20|                                 parms->secStateRef,
 2443|     20|                                 parms->session->sessUser,
 2444|     20|                                 parms->wholeMsg, parms->wholeMsgLen,
 2445|     20|                                 parms->wholeMsgOffset);
 2446|     20|}
snmpusm.c:usm_rgenerate_out_msg:
 1977|     20|{
 1978|     20|    size_t          msgAuthParmLen = 0;
 1979|     20|    u_int           boots_uint;
 1980|     20|    u_int           time_uint;
 1981|     20|    long            boots_long;
 1982|     20|    long            time_long;
 1983|       |
 1984|       |    /*
 1985|       |     * Indirection because secStateRef values override parameters.
 1986|       |     * 
 1987|       |     * None of these are to be free'd - they are either pointing to
 1988|       |     * what's in the secStateRef or to something either in the
 1989|       |     * actual parameter list or the user list.
 1990|       |     */
 1991|       |
 1992|     20|    const char     *theName = NULL;
 1993|     20|    u_int           theNameLength = 0;
 1994|     20|    const u_char   *theEngineID = NULL;
 1995|     20|    u_int           theEngineIDLength = 0;
 1996|     20|    u_char         *theAuthKey = NULL;
 1997|     20|    u_int           theAuthKeyLength = 0;
 1998|     20|    const oid      *theAuthProtocol = NULL;
 1999|     20|    u_int           theAuthProtocolLength = 0;
 2000|     20|    u_char         *thePrivKey = NULL;
 2001|     20|    u_int           thePrivKeyLength = 0;
 2002|     20|    const oid      *thePrivProtocol = NULL;
 2003|     20|    u_int           thePrivProtocolLength = 0;
 2004|     20|    int             theSecLevel = 0;    /* No defined const for bad
 2005|       |                                         * value (other then err). */
 2006|     20|    size_t          salt_length = 0, save_salt_length = 0;
 2007|     20|    u_char          salt[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2008|     20|    u_char          authParams[USM_MAX_AUTHSIZE];
 2009|     20|    u_char          iv[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2010|     20|    size_t          sp_offset = 0, mac_offset = 0;
 2011|     20|    int             rc = 0;
 2012|       |
 2013|     20|    DEBUGMSGTL(("usm", "USM processing has begun (offset %d)\n", (int)*offset));
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2014|       |
 2015|     20|    if (secStateRef != NULL) {
  ------------------
  |  Branch (2015:9): [True: 0, False: 20]
  ------------------
 2016|       |        /*
 2017|       |         * To hush the compiler for now.  XXX 
 2018|       |         */
 2019|      0|        const struct usmStateReference *ref = secStateRef;
 2020|       |
 2021|      0|        theName = ref->usr_name;
 2022|      0|        theNameLength = ref->usr_name_length;
 2023|      0|        theEngineID = ref->usr_engine_id;
 2024|      0|        theEngineIDLength = ref->usr_engine_id_length;
 2025|       |
 2026|      0|        if (!theEngineIDLength) {
  ------------------
  |  Branch (2026:13): [True: 0, False: 0]
  ------------------
 2027|      0|            theEngineID = secEngineID;
 2028|      0|            theEngineIDLength = secEngineIDLen;
 2029|      0|        }
 2030|       |
 2031|      0|        theAuthProtocol = ref->usr_auth_protocol;
 2032|      0|        theAuthProtocolLength = ref->usr_auth_protocol_length;
 2033|      0|        theAuthKey = ref->usr_auth_key;
 2034|      0|        theAuthKeyLength = ref->usr_auth_key_length;
 2035|      0|        thePrivProtocol = ref->usr_priv_protocol;
 2036|      0|        thePrivProtocolLength = ref->usr_priv_protocol_length;
 2037|      0|        thePrivKey = ref->usr_priv_key;
 2038|      0|        thePrivKeyLength = ref->usr_priv_key_length;
 2039|      0|        theSecLevel = ref->usr_sec_level;
 2040|      0|    }
 2041|       |
 2042|       |    /*
 2043|       |     * * Identify the user record.
 2044|       |     */
 2045|     20|    else {
 2046|     20|        struct usmUser *user;
 2047|       |
 2048|       |        /*
 2049|       |         * we do allow an unknown user name for
 2050|       |         * unauthenticated requests. 
 2051|       |         */
 2052|     20|        if (sessUser)
  ------------------
  |  Branch (2052:13): [True: 0, False: 20]
  ------------------
 2053|      0|            user = sessUser;
 2054|     20|        else
 2055|     20|            user = usm_get_user2(secEngineID, secEngineIDLen, secName, secNameLen);
 2056|       |
 2057|     20|        if (user == NULL && secLevel != SNMP_SEC_LEVEL_NOAUTH) {
  ------------------
  |  |  299|      0|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
  |  Branch (2057:13): [True: 0, False: 20]
  |  Branch (2057:29): [True: 0, False: 0]
  ------------------
 2058|      0|            DEBUGMSGTL(("usm", "Unknown 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]
  |  |  ------------------
  ------------------
 2059|      0|            return SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 2060|      0|        }
 2061|       |
 2062|     20|        theName = secName;
 2063|     20|        theNameLength = secNameLen;
 2064|     20|        theEngineID = secEngineID;
 2065|     20|        theSecLevel = secLevel;
 2066|     20|        theEngineIDLength = secEngineIDLen;
 2067|     20|        if (user) {
  ------------------
  |  Branch (2067:13): [True: 20, False: 0]
  ------------------
 2068|     20|            theAuthProtocol = user->authProtocol;
 2069|     20|            theAuthProtocolLength = user->authProtocolLen;
 2070|     20|            theAuthKey = user->authKey;
 2071|     20|            theAuthKeyLength = user->authKeyLen;
 2072|     20|            thePrivProtocol = user->privProtocol;
 2073|     20|            thePrivProtocolLength = user->privProtocolLen;
 2074|     20|            thePrivKey = user->privKey;
 2075|     20|            thePrivKeyLength = user->privKeyLen;
 2076|     20|        } else {
 2077|       |            /*
 2078|       |             * unknown users can not do authentication (obviously) 
 2079|       |             */
 2080|      0|            theAuthProtocol = usmNoAuthProtocol;
 2081|      0|            theAuthProtocolLength =
 2082|      0|                OID_LENGTH(usmNoAuthProtocol);
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 2083|      0|            theAuthKey = NULL;
 2084|      0|            theAuthKeyLength = 0;
 2085|      0|            thePrivProtocol = usmNoPrivProtocol;
 2086|      0|            thePrivProtocolLength =
 2087|      0|                OID_LENGTH(usmNoPrivProtocol);
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 2088|      0|            thePrivKey = NULL;
 2089|      0|            thePrivKeyLength = 0;
 2090|      0|        }
 2091|     20|    }                           /* endif -- secStateRef==NULL */
 2092|       |
 2093|       |
 2094|       |    /*
 2095|       |     * From here to the end of the function, avoid reference to
 2096|       |     * secName, secEngineID, secLevel, and associated lengths.
 2097|       |     */
 2098|       |
 2099|       |
 2100|       |    /*
 2101|       |     * Check to see if the user can use the requested sec services.
 2102|       |     */
 2103|     20|    if (usm_check_secLevel_vs_protocols(theSecLevel,
  ------------------
  |  Branch (2103:9): [True: 0, False: 20]
  ------------------
 2104|     20|                                        theAuthProtocol,
 2105|     20|                                        theAuthProtocolLength,
 2106|     20|                                        thePrivProtocol,
 2107|     20|                                        thePrivProtocolLength) == 1) {
 2108|      0|        DEBUGMSGTL(("usm", "Unsupported Security Level or type (%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]
  |  |  ------------------
  ------------------
 2109|      0|                    theSecLevel));
 2110|       |
 2111|      0|        return SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
 2112|      0|    }
 2113|       |
 2114|       |
 2115|       |    /*
 2116|       |     * * Retrieve the engine information.
 2117|       |     * *
 2118|       |     * * XXX    No error is declared in the EoP when sending messages to
 2119|       |     * *        unknown engines, processing continues w/ boots/time == (0,0).
 2120|       |     */
 2121|     20|    if (get_enginetime(theEngineID, theEngineIDLength,
  ------------------
  |  Branch (2121:9): [True: 0, False: 20]
  ------------------
 2122|     20|                       &boots_uint, &time_uint, FALSE) == -1) {
  ------------------
  |  |  125|     20|#define FALSE 0
  ------------------
 2123|      0|        DEBUGMSGTL(("usm", "%s\n", "Failed to find engine data."));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2124|      0|    }
 2125|       |
 2126|     20|    boots_long = boots_uint;
 2127|     20|    time_long = time_uint;
 2128|       |
 2129|     20|    if (theSecLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|     20|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (2129:9): [True: 0, False: 20]
  ------------------
 2130|       |        /*
 2131|       |         * Initially assume that the ciphertext will end up the same size as
 2132|       |         * the plaintext plus some padding.  Really sc_encrypt ought to be able
 2133|       |         * to grow this for us, a la asn_realloc_rbuild_<type> functions, but
 2134|       |         * this will do for now.  
 2135|       |         */
 2136|      0|        u_char         *ciphertext = NULL;
 2137|      0|        size_t          ciphertextlen = scopedPduLen + 64;
 2138|      0|        int             priv_type = sc_get_privtype(thePrivProtocol,
 2139|      0|                                                    thePrivProtocolLength);
 2140|       |
 2141|      0|        if ((ciphertext = (u_char *) malloc(ciphertextlen)) == NULL) {
  ------------------
  |  Branch (2141:13): [True: 0, False: 0]
  ------------------
 2142|      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]
  |  |  ------------------
  ------------------
 2143|      0|                        "couldn't malloc %d bytes for encrypted PDU\n",
 2144|      0|                        (int)ciphertextlen));
 2145|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 2146|      0|        }
 2147|       |
 2148|       |        /*
 2149|       |         * XXX Hardwired to seek into a 1DES private key!  
 2150|       |         */
 2151|      0|#ifdef HAVE_AES
 2152|      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 (2152:13): [True: 0, False: 0]
  ------------------
 2153|      0|            salt_length = BYTESIZE(USM_AES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2154|      0|            save_salt_length = BYTESIZE(USM_AES_SALT_LENGTH)/2;
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2155|      0|            if (!thePrivKey ||
  ------------------
  |  Branch (2155:17): [True: 0, False: 0]
  ------------------
 2156|      0|                usm_set_aes_iv(salt, &salt_length,
  ------------------
  |  Branch (2156:17): [True: 0, False: 0]
  ------------------
 2157|      0|                               htonl(boots_uint), htonl(time_uint),
 2158|      0|                               iv) == -1) {
 2159|      0|                DEBUGMSGTL(("usm", "Can't set AES iv.\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]
  |  |  ------------------
  ------------------
 2160|      0|                SNMP_FREE(ciphertext);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2161|      0|                return SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 2162|      0|            }
 2163|      0|        } 
 2164|      0|#endif
 2165|      0|#ifndef NETSNMP_DISABLE_DES
 2166|      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 (2166:13): [True: 0, False: 0]
  ------------------
 2167|      0|            salt_length = BYTESIZE(USM_DES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2168|      0|            save_salt_length = BYTESIZE(USM_DES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2169|      0|            if (!thePrivKey || thePrivKeyLength < 16 ||
  ------------------
  |  Branch (2169:17): [True: 0, False: 0]
  |  Branch (2169:32): [True: 0, False: 0]
  ------------------
 2170|      0|                (usm_set_salt(salt, &salt_length,
  ------------------
  |  Branch (2170:17): [True: 0, False: 0]
  ------------------
 2171|      0|                              thePrivKey + 8,
 2172|      0|                              thePrivKeyLength - 8,
 2173|      0|                              iv) == -1)) {
 2174|      0|                DEBUGMSGTL(("usm", "Can't set DES-CBC 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]
  |  |  ------------------
  ------------------
 2175|      0|                SNMP_FREE(ciphertext);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2176|      0|                return SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 2177|      0|            }
 2178|      0|        }
 2179|      0|#endif
 2180|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 2181|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 2182|       |            dump_chunk("usm/dump", "This data was encrypted:",
 2183|       |                       scopedPdu, scopedPduLen);
 2184|       |        }
 2185|       |#endif
 2186|       |
 2187|      0|        if (sc_encrypt(thePrivProtocol, thePrivProtocolLength,
  ------------------
  |  Branch (2187:13): [True: 0, False: 0]
  ------------------
 2188|      0|                       thePrivKey, thePrivKeyLength,
 2189|      0|                       salt, salt_length,
 2190|      0|                       scopedPdu, scopedPduLen,
 2191|      0|                       ciphertext, &ciphertextlen) != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 2192|      0|            DEBUGMSGTL(("usm", "encryption error.\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]
  |  |  ------------------
  ------------------
 2193|      0|            SNMP_FREE(ciphertext);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2194|      0|            return SNMPERR_USM_ENCRYPTIONERROR;
  ------------------
  |  |  229|      0|#define SNMPERR_USM_ENCRYPTIONERROR		(-45)
  ------------------
 2195|      0|        }
 2196|       |
 2197|       |        /*
 2198|       |         * Write the encrypted scopedPdu back into the packet buffer.  
 2199|       |         */
 2200|       |
 2201|      0|        *offset = 0;
 2202|      0|        rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,
 2203|      0|                                       (u_char) (ASN_UNIVERSAL |
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
 2204|      0|                                                 ASN_PRIMITIVE |
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2205|      0|                                                 ASN_OCTET_STR),
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 2206|      0|                                       ciphertext, ciphertextlen);
 2207|      0|        if (rc == 0) {
  ------------------
  |  Branch (2207:13): [True: 0, False: 0]
  ------------------
 2208|      0|            DEBUGMSGTL(("usm", "Encryption 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]
  |  |  ------------------
  ------------------
 2209|      0|            SNMP_FREE(ciphertext);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2210|      0|            return SNMPERR_USM_ENCRYPTIONERROR;
  ------------------
  |  |  229|      0|#define SNMPERR_USM_ENCRYPTIONERROR		(-45)
  ------------------
 2211|      0|        }
 2212|       |
 2213|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 2214|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 2215|       |            dump_chunk("usm/dump", "salt + Encrypted form: ", salt,
 2216|       |                       salt_length);
 2217|       |            dump_chunk("usm/dump", "wholeMsg:",
 2218|       |                       (*wholeMsg + *wholeMsgLen - *offset), *offset);
 2219|       |        }
 2220|       |#endif
 2221|       |
 2222|      0|        DEBUGMSGTL(("usm", "Encryption successful.\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]
  |  |  ------------------
  ------------------
 2223|      0|        SNMP_FREE(ciphertext);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2224|     20|    } else {
 2225|       |        /*
 2226|       |         * theSecLevel != SNMP_SEC_LEVEL_AUTHPRIV  
 2227|       |         */
 2228|     20|    }
 2229|       |
 2230|       |    /*
 2231|       |     * Start encoding the msgSecurityParameters.  
 2232|       |     */
 2233|       |
 2234|     20|    sp_offset = *offset;
 2235|       |
 2236|     20|    DEBUGDUMPHEADER("send", "msgPrivacyParameters");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2237|       |    /*
 2238|       |     * msgPrivacyParameters (warning: assumes DES salt).  
 2239|       |     */
 2240|     20|    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,
 2241|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2242|     20|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2243|     20|                                   iv,
 2244|     20|                                   save_salt_length);
 2245|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2246|     20|    if (rc == 0) {
  ------------------
  |  Branch (2246:9): [True: 0, False: 20]
  ------------------
 2247|      0|        DEBUGMSGTL(("usm", "building privParams 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]
  |  |  ------------------
  ------------------
 2248|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2249|      0|    }
 2250|       |
 2251|     20|    DEBUGDUMPHEADER("send", "msgAuthenticationParameters");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2252|       |    /*
 2253|       |     * msgAuthenticationParameters.
 2254|       |     */
 2255|     20|    if (theSecLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|     40|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (2255:9): [True: 0, False: 20]
  ------------------
 2256|     20|        || theSecLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|     20|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (2256:12): [True: 0, False: 20]
  ------------------
 2257|      0|        memset(authParams, 0, sizeof(authParams));
 2258|      0|        msgAuthParmLen =
 2259|      0|            sc_get_auth_maclen(sc_get_authtype(theAuthProtocol,
 2260|      0|                                               theAuthProtocolLength));
 2261|      0|    }
 2262|       |
 2263|     20|    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,
 2264|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2265|     20|                                             | ASN_OCTET_STR), authParams,
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2266|     20|                                   msgAuthParmLen);
 2267|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2268|     20|    if (rc == 0) {
  ------------------
  |  Branch (2268:9): [True: 0, False: 20]
  ------------------
 2269|      0|        DEBUGMSGTL(("usm", "building authParams 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]
  |  |  ------------------
  ------------------
 2270|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2271|      0|    }
 2272|       |
 2273|       |    /*
 2274|       |     * Remember where to put the actual HMAC we calculate later on.  An
 2275|       |     * encoded OCTET STRING of length USM_MD5_AND_SHA_AUTH_LEN has an ASN.1
 2276|       |     * header of length 2, hence the fudge factor.  This works as long as
 2277|       |     * auth lengths stay < 127.
 2278|       |     */
 2279|     20|    mac_offset = *offset - 2;
 2280|       |
 2281|       |    /*
 2282|       |     * msgUserName.  
 2283|       |     */
 2284|     20|    DEBUGDUMPHEADER("send", "msgUserName");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2285|     20|    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,
 2286|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2287|     20|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2288|     20|                                   (const u_char *) theName, theNameLength);
 2289|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2290|     20|    if (rc == 0) {
  ------------------
  |  Branch (2290:9): [True: 0, False: 20]
  ------------------
 2291|      0|        DEBUGMSGTL(("usm", "building authParams 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]
  |  |  ------------------
  ------------------
 2292|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2293|      0|    }
 2294|       |
 2295|       |    /*
 2296|       |     * msgAuthoritativeEngineTime.  
 2297|       |     */
 2298|     20|    DEBUGDUMPHEADER("send", "msgAuthoritativeEngineTime");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2299|     20|    rc = asn_realloc_rbuild_int(wholeMsg, wholeMsgLen, offset, 1,
 2300|     20|                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                              (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2301|     20|                                          ASN_INTEGER), &time_long,
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 2302|     20|                                sizeof(long));
 2303|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2304|     20|    if (rc == 0) {
  ------------------
  |  Branch (2304:9): [True: 0, False: 20]
  ------------------
 2305|      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]
  |  |  ------------------
  ------------------
 2306|      0|                    "building msgAuthoritativeEngineTime failed.\n"));
 2307|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2308|      0|    }
 2309|       |
 2310|       |    /*
 2311|       |     * msgAuthoritativeEngineBoots.  
 2312|       |     */
 2313|     20|    DEBUGDUMPHEADER("send", "msgAuthoritativeEngineBoots");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2314|     20|    rc = asn_realloc_rbuild_int(wholeMsg, wholeMsgLen, offset, 1,
 2315|     20|                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                              (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2316|     20|                                          ASN_INTEGER), &boots_long,
  ------------------
  |  |   75|     20|#define ASN_INTEGER	    0x02U
  ------------------
 2317|     20|                                sizeof(long));
 2318|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2319|     20|    if (rc == 0) {
  ------------------
  |  Branch (2319:9): [True: 0, False: 20]
  ------------------
 2320|      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]
  |  |  ------------------
  ------------------
 2321|      0|                    "building msgAuthoritativeEngineBoots failed.\n"));
 2322|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2323|      0|    }
 2324|       |
 2325|     20|    DEBUGDUMPHEADER("send", "msgAuthoritativeEngineID");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2326|     20|    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,
 2327|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2328|     20|                                             | ASN_OCTET_STR), theEngineID,
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2329|     20|                                   theEngineIDLength);
 2330|     20|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     20|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2331|     20|    if (rc == 0) {
  ------------------
  |  Branch (2331:9): [True: 0, False: 20]
  ------------------
 2332|      0|        DEBUGMSGTL(("usm", "building msgAuthoritativeEngineID 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]
  |  |  ------------------
  ------------------
 2333|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2334|      0|    }
 2335|       |
 2336|       |    /*
 2337|       |     * USM msgSecurityParameters sequence header  
 2338|       |     */
 2339|     20|    rc = asn_realloc_rbuild_sequence(wholeMsg, wholeMsgLen, offset, 1,
 2340|     20|                                     (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|     20|#define ASN_SEQUENCE	    0x10U
  ------------------
 2341|     20|                                               ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2342|     20|                                     *offset - sp_offset);
 2343|     20|    if (rc == 0) {
  ------------------
  |  Branch (2343:9): [True: 0, False: 20]
  ------------------
 2344|      0|        DEBUGMSGTL(("usm", "building usm security parameters 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]
  |  |  ------------------
  ------------------
 2345|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2346|      0|    }
 2347|       |
 2348|       |    /*
 2349|       |     * msgSecurityParameters OCTET STRING wrapper.  
 2350|       |     */
 2351|     20|    rc = asn_realloc_rbuild_header(wholeMsg, wholeMsgLen, offset, 1,
 2352|     20|                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|     20|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                 (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|     20|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2353|     20|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|     20|#define ASN_OCTET_STR	    0x04U
  ------------------
 2354|     20|                                   *offset - sp_offset);
 2355|       |
 2356|     20|    if (rc == 0) {
  ------------------
  |  Branch (2356:9): [True: 0, False: 20]
  ------------------
 2357|      0|        DEBUGMSGTL(("usm", "building msgSecurityParameters 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]
  |  |  ------------------
  ------------------
 2358|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2359|      0|    }
 2360|       |
 2361|       |    /*
 2362|       |     * Copy in the msgGlobalData and msgVersion.  
 2363|       |     */
 2364|     20|    while ((*wholeMsgLen - *offset) < globalDataLen) {
  ------------------
  |  Branch (2364:12): [True: 0, False: 20]
  ------------------
 2365|      0|        if (!asn_realloc(wholeMsg, wholeMsgLen)) {
  ------------------
  |  Branch (2365:13): [True: 0, False: 0]
  ------------------
 2366|      0|            DEBUGMSGTL(("usm", "building global data 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]
  |  |  ------------------
  ------------------
 2367|      0|            return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2368|      0|        }
 2369|      0|    }
 2370|       |
 2371|     20|    *offset += globalDataLen;
 2372|     20|    memcpy(*wholeMsg + *wholeMsgLen - *offset, globalData, globalDataLen);
 2373|       |
 2374|       |    /*
 2375|       |     * Total packet sequence.  
 2376|       |     */
 2377|     20|    rc = asn_realloc_rbuild_sequence(wholeMsg, wholeMsgLen, offset, 1,
 2378|     20|                                     (u_char) (ASN_SEQUENCE |
  ------------------
  |  |   84|     20|#define ASN_SEQUENCE	    0x10U
  ------------------
 2379|     20|                                               ASN_CONSTRUCTOR), *offset);
  ------------------
  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2380|     20|    if (rc == 0) {
  ------------------
  |  Branch (2380:9): [True: 0, False: 20]
  ------------------
 2381|      0|        DEBUGMSGTL(("usm", "building master packet sequence 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]
  |  |  ------------------
  ------------------
 2382|      0|        return SNMPERR_TOO_LONG;
  ------------------
  |  |  189|      0|#define SNMPERR_TOO_LONG		(-5)
  ------------------
 2383|      0|    }
 2384|       |
 2385|       |    /*
 2386|       |     * Now consider / do authentication.  
 2387|       |     */
 2388|       |
 2389|     20|    if (theSecLevel == SNMP_SEC_LEVEL_AUTHNOPRIV ||
  ------------------
  |  |  300|     40|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (2389:9): [True: 0, False: 20]
  ------------------
 2390|     20|        theSecLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|     20|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (2390:9): [True: 0, False: 20]
  ------------------
 2391|      0|        size_t          temp_sig_len = msgAuthParmLen;
 2392|      0|        u_char         *temp_sig = (u_char *) malloc(temp_sig_len);
 2393|      0|        u_char         *proto_msg = *wholeMsg + *wholeMsgLen - *offset;
 2394|      0|        size_t          proto_msg_len = *offset;
 2395|       |
 2396|       |
 2397|      0|        if (temp_sig == NULL) {
  ------------------
  |  Branch (2397:13): [True: 0, False: 0]
  ------------------
 2398|      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]
  |  |  ------------------
  ------------------
 2399|      0|            return SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 2400|      0|        }
 2401|       |
 2402|      0|        if (sc_generate_keyed_hash(theAuthProtocol, theAuthProtocolLength,
  ------------------
  |  Branch (2402:13): [True: 0, False: 0]
  ------------------
 2403|      0|                                   theAuthKey, theAuthKeyLength,
 2404|      0|                                   proto_msg, proto_msg_len,
 2405|      0|                                   temp_sig, &temp_sig_len)
 2406|      0|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 2407|      0|            SNMP_FREE(temp_sig);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2408|      0|            DEBUGMSGTL(("usm", "Signing 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]
  |  |  ------------------
  ------------------
 2409|      0|            return SNMPERR_USM_AUTHENTICATIONFAILURE;
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
 2410|      0|        }
 2411|       |
 2412|      0|        if (temp_sig_len != msgAuthParmLen) {
  ------------------
  |  Branch (2412:13): [True: 0, False: 0]
  ------------------
 2413|      0|            SNMP_FREE(temp_sig);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2414|      0|            DEBUGMSGTL(("usm", "Signing lengths 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]
  |  |  ------------------
  ------------------
 2415|      0|            return SNMPERR_USM_AUTHENTICATIONFAILURE;
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
 2416|      0|        }
 2417|       |
 2418|      0|        memcpy(*wholeMsg + *wholeMsgLen - mac_offset, temp_sig,
 2419|      0|               msgAuthParmLen);
 2420|      0|        SNMP_FREE(temp_sig);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2421|      0|    }
 2422|       |    /*
 2423|       |     * endif -- create keyed hash 
 2424|       |     */
 2425|     20|    DEBUGMSGTL(("usm", "USM processing completed.\n"));
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 2426|     20|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     20|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 2427|     20|}                               /* end usm_rgenerate_out_msg() */
snmpusm.c:usm_check_secLevel_vs_protocols:
 1356|     20|{
 1357|       |
 1358|     20|    if (level == SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|     40|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (1358:9): [True: 0, False: 20]
  ------------------
 1359|      0|        &&
 1360|      0|        (netsnmp_oid_equals
  ------------------
  |  Branch (1360:9): [True: 0, False: 0]
  ------------------
 1361|      0|         (privProtocol, privProtocolLen, usmNoPrivProtocol,
 1362|      0|          OID_LENGTH(usmNoPrivProtocol)) == 0)) {
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 1363|      0|        DEBUGMSGTL(("usm", "Level: %d\n", 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]
  |  |  ------------------
  ------------------
 1364|      0|        DEBUGMSGTL(("usm", "Auth Protocol: "));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1365|      0|        DEBUGMSGOID(("usm", authProtocol, authProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1366|      0|        DEBUGMSG(("usm", ", Priv Protocol: "));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1367|      0|        DEBUGMSGOID(("usm", privProtocol, privProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1368|      0|        DEBUGMSG(("usm", "\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]
  |  |  ------------------
  ------------------
 1369|      0|        return 1;
 1370|      0|    }
 1371|     20|    if ((level == SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|     40|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (1371:10): [True: 0, False: 20]
  ------------------
 1372|     20|         || level == SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|     20|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (1372:13): [True: 0, False: 20]
  ------------------
 1373|      0|        &&
 1374|      0|        (netsnmp_oid_equals
  ------------------
  |  Branch (1374:9): [True: 0, False: 0]
  ------------------
 1375|      0|         (authProtocol, authProtocolLen, usmNoAuthProtocol,
 1376|      0|          OID_LENGTH(usmNoAuthProtocol)) == 0)) {
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 1377|      0|        DEBUGMSGTL(("usm", "Level: %d\n", 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]
  |  |  ------------------
  ------------------
 1378|      0|        DEBUGMSGTL(("usm", "Auth Protocol: "));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1379|      0|        DEBUGMSGOID(("usm", authProtocol, authProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1380|      0|        DEBUGMSG(("usm", ", Priv Protocol: "));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1381|      0|        DEBUGMSGOID(("usm", privProtocol, privProtocolLen));
  ------------------
  |  |   67|      0|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1382|      0|        DEBUGMSG(("usm", "\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]
  |  |  ------------------
  ------------------
 1383|      0|        return 1;
 1384|      0|    }
 1385|       |
 1386|     20|    return 0;
 1387|       |
 1388|     20|}                               /* end usm_check_secLevel_vs_protocols() */
snmpusm.c:usm_secmod_process_in_msg:
 3358|     22|{
 3359|     22|    if (!parms)
  ------------------
  |  Branch (3359:9): [True: 0, False: 22]
  ------------------
 3360|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3361|       |
 3362|     22|    return usm_process_in_msg(parms->msgProcModel,
 3363|     22|                              parms->maxMsgSize,
 3364|     22|                              parms->secParams,
 3365|     22|                              parms->secModel,
 3366|     22|                              parms->secLevel,
 3367|     22|                              parms->wholeMsg,
 3368|     22|                              parms->wholeMsgLen,
 3369|     22|                              parms->secEngineID,
 3370|     22|                              parms->secEngineIDLen,
 3371|     22|                              parms->secName,
 3372|     22|                              parms->secNameLen,
 3373|     22|                              parms->scopedPdu,
 3374|     22|                              parms->scopedPduLen,
 3375|     22|                              parms->maxSizeResponse,
 3376|     22|                              parms->secStateRef,
 3377|     22|                              parms->sess, parms->msg_flags);
 3378|     22|}
snmpusm.c:usm_process_in_msg:
 2957|     22|{                               /* IN     - v3 Message flags.              */
 2958|     22|    size_t          remaining = wholeMsgLen - (secParams - wholeMsg);
 2959|     22|    u_int           boots_uint;
 2960|     22|    u_int           time_uint;
 2961|     22|#ifdef HAVE_AES
 2962|     22|    u_int           net_boots, net_time;
 2963|     22|#endif
 2964|     22|#ifndef NETSNMP_DISABLE_DES
 2965|     22|    int             i;
 2966|     22|#endif
 2967|     22|    u_char          signature[USM_MAX_AUTHSIZE];
 2968|     22|    size_t          signature_length = USM_MAX_AUTHSIZE;
  ------------------
  |  |   38|     22|#define USM_MAX_AUTHSIZE                USM_HMAC384SHA512_AUTH_LEN
  |  |  ------------------
  |  |  |  |   37|     22|#define USM_HMAC384SHA512_AUTH_LEN      48      /* SHOULD */
  |  |  ------------------
  ------------------
 2969|     22|    u_char          salt[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2970|     22|    size_t          salt_length = BYTESIZE(USM_MAX_SALT_LENGTH);
  ------------------
  |  |   55|     22|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2971|     22|    u_char          iv[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2972|     22|    u_int           iv_length = BYTESIZE(USM_MAX_SALT_LENGTH);
  ------------------
  |  |   55|     22|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2973|     22|    u_char         *data_ptr;
 2974|     22|    u_char         *value_ptr;
 2975|     22|    u_char          type_value;
 2976|     22|    u_char         *end_of_overhead = NULL;
 2977|     22|    int             error;
 2978|     22|    int             rc = 0;
 2979|     22|    struct usmStateReference **secStateRef =
 2980|     22|        (struct usmStateReference **) secStateRf;
 2981|       |
 2982|     22|    struct usmUser *user;
 2983|       |
 2984|       |
 2985|     22|    DEBUGMSGTL(("usm", "USM processing begun...\n"));
  ------------------
  |  |   66|     22|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 22]
  |  |  ------------------
  ------------------
 2986|       |
 2987|     22|    netsnmp_assert(secStateRef);
  ------------------
  |  |   47|     22|#      define netsnmp_assert(x)  do { \
  |  |   48|     22|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 22, False: 0]
  |  |  ------------------
  |  |   49|     22|                 ; \
  |  |   50|     22|              else \
  |  |   51|     22|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     22|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 22]
  |  |  ------------------
  ------------------
 2988|       |
 2989|     22|    usm_free_usmStateReference(*secStateRef);
 2990|     22|    *secStateRef = usm_malloc_usmStateReference();
 2991|     22|    if (*secStateRef == NULL) {
  ------------------
  |  Branch (2991:9): [True: 0, False: 22]
  ------------------
 2992|      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]
  |  |  ------------------
  ------------------
 2993|      0|        return SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 2994|      0|    }
 2995|       |
 2996|       |    /*
 2997|       |     * Make sure the *secParms is an OCTET STRING.
 2998|       |     * Extract the user name, engine ID, and security level.
 2999|       |     */
 3000|     22|    if ((rc = usm_parse_security_parameters(secParams, remaining,
  ------------------
  |  Branch (3000:9): [True: 14, False: 8]
  ------------------
 3001|     22|                                            secEngineID, secEngineIDLen,
 3002|     22|                                            &boots_uint, &time_uint,
 3003|     22|                                            secName, secNameLen,
 3004|     22|                                            signature, &signature_length,
 3005|     22|                                            salt, &salt_length,
 3006|     22|                                            &data_ptr)) < 0) {
 3007|     14|        DEBUGMSGTL(("usm", "Parsing failed (rc %d).\n", rc));
  ------------------
  |  |   66|     14|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     14|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 14]
  |  |  ------------------
  ------------------
 3008|     14|        if (rc == -2) {
  ------------------
  |  Branch (3008:13): [True: 12, False: 2]
  ------------------
 3009|       |            /*
 3010|       |             * This indicates a decryptionError.  
 3011|       |             */
 3012|     12|            snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|     12|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3013|     12|            error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|     12|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3014|     12|        } else {
 3015|      2|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3016|      2|            error = SNMPERR_USM_PARSEERROR;
  ------------------
  |  |  231|      2|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
 3017|      2|        }
 3018|     14|        goto err;
 3019|     14|    }
 3020|       |
 3021|       |    /*
 3022|       |     * RFC 2574 section 8.3.2
 3023|       |     * 1)  If the privParameters field is not an 8-octet OCTET STRING,
 3024|       |     * then an error indication (decryptionError) is returned to the
 3025|       |     * calling module.
 3026|       |     */
 3027|      8|    if ((secLevel == SNMP_SEC_LEVEL_AUTHPRIV) && (salt_length != 8)) {
  ------------------
  |  |  301|      8|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3027:9): [True: 0, False: 8]
  |  Branch (3027:50): [True: 0, False: 0]
  ------------------
 3028|      0|        snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3029|      0|        error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3030|      0|        goto err;
 3031|      0|    }
 3032|       |
 3033|      8|    if (secLevel != SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      8|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3033:9): [True: 8, False: 0]
  ------------------
 3034|       |        /*
 3035|       |         * pull these out now so reports can use them 
 3036|       |         */
 3037|      8|        *scopedPdu = data_ptr;
 3038|      8|        *scopedPduLen = wholeMsgLen - (data_ptr - wholeMsg);
 3039|      8|        end_of_overhead = data_ptr;
 3040|      8|    }
 3041|       |
 3042|       |    /*
 3043|       |     * Cache the name, engine ID, and security level,
 3044|       |     * * per step 2 (section 3.2)
 3045|       |     */
 3046|      8|    if (usm_set_usmStateReference_name
  ------------------
  |  Branch (3046:9): [True: 0, False: 8]
  ------------------
 3047|      8|        (*secStateRef, secName, *secNameLen) == -1) {
 3048|      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]
  |  |  ------------------
  ------------------
 3049|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3050|      0|        goto err;
 3051|      0|    }
 3052|       |
 3053|      8|    if (usm_set_usmStateReference_engine_id
  ------------------
  |  Branch (3053:9): [True: 0, False: 8]
  ------------------
 3054|      8|        (*secStateRef, secEngineID, *secEngineIDLen) == -1) {
 3055|      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]
  |  |  ------------------
  ------------------
 3056|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3057|      0|        goto err;
 3058|      0|    }
 3059|       |
 3060|      8|    if (usm_set_usmStateReference_sec_level(*secStateRef, secLevel) ==
  ------------------
  |  Branch (3060:9): [True: 0, False: 8]
  ------------------
 3061|      8|        -1) {
 3062|      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]
  |  |  ------------------
  ------------------
 3063|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3064|      0|        goto err;
 3065|      0|    }
 3066|       |
 3067|       |    /*
 3068|       |     * Locate the engine ID record.
 3069|       |     * If it is unknown, then either create one or note this as an error.
 3070|       |     */
 3071|      8|    if ((sess && (sess->isAuthoritative == SNMP_SESS_AUTHORITATIVE ||
  ------------------
  |  |  125|     16|#define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
  ------------------
  |  Branch (3071:10): [True: 8, False: 0]
  |  Branch (3071:19): [True: 0, False: 8]
  ------------------
 3072|      8|                  (sess->isAuthoritative == SNMP_SESS_UNKNOWNAUTH &&
  ------------------
  |  |  126|     16|#define SNMP_SESS_UNKNOWNAUTH      2    /* sometimes (like NRs) */
  ------------------
  |  Branch (3072:20): [True: 8, False: 0]
  ------------------
 3073|      8|                   (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)))) ||
  ------------------
  |  |  305|      8|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3073:20): [True: 8, False: 0]
  ------------------
 3074|      8|        (!sess && (msg_flags & SNMP_MSG_FLAG_RPRT_BIT))) {
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3074:10): [True: 0, False: 0]
  |  Branch (3074:19): [True: 0, False: 0]
  ------------------
 3075|      8|        if (ISENGINEKNOWN(secEngineID, *secEngineIDLen) == FALSE) {
  ------------------
  |  |   82|      8|	( (get_enginetime(e, e_l,				\
  |  |  ------------------
  |  |  |  Branch (82:4): [True: 0, False: 8]
  |  |  ------------------
  |  |   83|      8|		&dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  128|      8|#define TRUE  1
  |  |  ------------------
  |  |               		&dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  184|      8|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |   84|      8|		? TRUE						\
  |  |  ------------------
  |  |  |  |  128|      0|#define TRUE  1
  |  |  ------------------
  |  |   85|      8|		: FALSE )
  |  |  ------------------
  |  |  |  |  125|      8|#define FALSE 0
  |  |  ------------------
  ------------------
                      if (ISENGINEKNOWN(secEngineID, *secEngineIDLen) == FALSE) {
  ------------------
  |  |  125|      8|#define FALSE 0
  ------------------
  |  Branch (3075:13): [True: 8, False: 0]
  ------------------
 3076|      8|            DEBUGMSGTL(("usm", "Unknown Engine ID.\n"));
  ------------------
  |  |   66|      8|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 8]
  |  |  ------------------
  ------------------
 3077|      8|            snmp_increment_statistic(STAT_USMSTATSUNKNOWNENGINEIDS);
  ------------------
  |  |  623|      8|#define   STAT_USMSTATSUNKNOWNENGINEIDS      6
  ------------------
 3078|      8|            error = SNMPERR_USM_UNKNOWNENGINEID;
  ------------------
  |  |  232|      8|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
 3079|      8|            goto err;
 3080|      8|        }
 3081|      8|    } else {
 3082|      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 (3082:13): [True: 0, False: 0]
  ------------------
 3083|      0|            != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3084|      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]
  |  |  ------------------
  ------------------
 3085|      0|            error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3086|      0|            goto err;
 3087|      0|        }
 3088|       |
 3089|      0|    }
 3090|       |
 3091|       |
 3092|       |    /*
 3093|       |     * Locate the User record.
 3094|       |     * If the user/engine ID is unknown, report this as an error.
 3095|       |     */
 3096|      0|    if (sess && sess->sessUser)
  ------------------
  |  Branch (3096:9): [True: 0, False: 0]
  |  Branch (3096:17): [True: 0, False: 0]
  ------------------
 3097|      0|        user = sess->sessUser;
 3098|      0|    else
 3099|      0|        user = usm_get_user_from_list(secEngineID, *secEngineIDLen,
 3100|      0|                                       secName, *secNameLen, userList,
 3101|      0|                                       (((sess && sess->isAuthoritative ==
  ------------------
  |  Branch (3101:43): [True: 0, False: 0]
  |  Branch (3101:51): [True: 0, False: 0]
  ------------------
 3102|      0|                                          SNMP_SESS_AUTHORITATIVE) ||
  ------------------
  |  |  125|      0|#define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
  ------------------
 3103|      0|                                         (!sess)) ? 0 : 1));
  ------------------
  |  Branch (3103:42): [True: 0, False: 0]
  ------------------
 3104|       |
 3105|      0|    if (user == NULL) {
  ------------------
  |  Branch (3105:9): [True: 0, False: 0]
  ------------------
 3106|      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]
  |  |  ------------------
  ------------------
 3107|      0|        snmp_increment_statistic(STAT_USMSTATSUNKNOWNUSERNAMES);
  ------------------
  |  |  622|      0|#define   STAT_USMSTATSUNKNOWNUSERNAMES      5
  ------------------
 3108|      0|        error = SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 3109|      0|        goto err;
 3110|      0|    }
 3111|       |
 3112|       |    /* ensure the user is active */
 3113|      0|    if (user->userStatus != RS_ACTIVE) {
  ------------------
  |  |   35|      0|#define RS_ACTIVE	        1
  ------------------
  |  Branch (3113:9): [True: 0, False: 0]
  ------------------
 3114|      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]
  |  |  ------------------
  ------------------
 3115|      0|        error = SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 3116|      0|        goto err;
 3117|      0|    }
 3118|       |
 3119|       |    /*
 3120|       |     * Make sure the security level is appropriate.
 3121|       |     */
 3122|       |
 3123|      0|    rc = usm_check_secLevel(secLevel, user);
 3124|      0|    if (1 == rc) {
  ------------------
  |  Branch (3124:9): [True: 0, False: 0]
  ------------------
 3125|      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]
  |  |  ------------------
  ------------------
 3126|      0|                    secLevel));
 3127|      0|        snmp_increment_statistic(STAT_USMSTATSUNSUPPORTEDSECLEVELS);
  ------------------
  |  |  620|      0|#define   STAT_USMSTATSUNSUPPORTEDSECLEVELS  3
  ------------------
 3128|      0|        error = SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
 3129|      0|        goto err;
 3130|      0|    } else if (rc != 0) {
  ------------------
  |  Branch (3130:16): [True: 0, False: 0]
  ------------------
 3131|      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]
  |  |  ------------------
  ------------------
 3132|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3133|      0|        goto err;
 3134|      0|    }
 3135|       |
 3136|       |    /*
 3137|       |     * Check the authentication credentials of the message.
 3138|       |     */
 3139|      0|    if (secLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|      0|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (3139:9): [True: 0, False: 0]
  ------------------
 3140|      0|        || secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3140:12): [True: 0, False: 0]
  ------------------
 3141|      0|        if (sc_check_keyed_hash(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3141:13): [True: 0, False: 0]
  ------------------
 3142|      0|                                user->authKey, user->authKeyLen,
 3143|      0|                                wholeMsg, wholeMsgLen,
 3144|      0|                                signature, signature_length)
 3145|      0|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 3146|      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]
  |  |  ------------------
  ------------------
 3147|      0|            snmp_increment_statistic(STAT_USMSTATSWRONGDIGESTS);
  ------------------
  |  |  624|      0|#define   STAT_USMSTATSWRONGDIGESTS          7
  ------------------
 3148|      0|	    snmp_log(LOG_WARNING, "Authentication failed for %s\n",
 3149|      0|				user->name);
 3150|      0|            error = SNMPERR_USM_AUTHENTICATIONFAILURE;
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
 3151|      0|            goto err;
 3152|      0|        }
 3153|       |
 3154|      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]
  |  |  ------------------
  ------------------
 3155|      0|    }
 3156|       |
 3157|       |
 3158|       |    /*
 3159|       |     * Steps 10-11  user is already set - relocated before timeliness 
 3160|       |     * check in case it fails - still save user data for response.
 3161|       |     *
 3162|       |     * Cache the keys and protocol oids, per step 11 (s3.2).
 3163|       |     */
 3164|      0|    if (usm_set_usmStateReference_auth_protocol(*secStateRef,
  ------------------
  |  Branch (3164:9): [True: 0, False: 0]
  ------------------
 3165|      0|                                                user->authProtocol,
 3166|      0|                                                user->
 3167|      0|                                                authProtocolLen) == -1) {
 3168|      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]
  |  |  ------------------
  ------------------
 3169|      0|                    "Couldn't cache authentication protocol."));
 3170|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3171|      0|        goto err;
 3172|      0|    }
 3173|       |
 3174|      0|    if (usm_set_usmStateReference_auth_key(*secStateRef,
  ------------------
  |  Branch (3174:9): [True: 0, False: 0]
  ------------------
 3175|      0|                                           user->authKey,
 3176|      0|                                           user->authKeyLen) == -1) {
 3177|      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]
  |  |  ------------------
  ------------------
 3178|      0|                    "Couldn't cache authentication key."));
 3179|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3180|      0|        goto err;
 3181|      0|    }
 3182|       |
 3183|      0|    if (usm_set_usmStateReference_priv_protocol(*secStateRef,
  ------------------
  |  Branch (3183:9): [True: 0, False: 0]
  ------------------
 3184|      0|                                                user->privProtocol,
 3185|      0|                                                user->
 3186|      0|                                                privProtocolLen) == -1) {
 3187|      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]
  |  |  ------------------
  ------------------
 3188|      0|                    "Couldn't cache privacy protocol."));
 3189|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3190|      0|        goto err;
 3191|      0|    }
 3192|       |
 3193|      0|    if (usm_set_usmStateReference_priv_key(*secStateRef,
  ------------------
  |  Branch (3193:9): [True: 0, False: 0]
  ------------------
 3194|      0|                                           user->privKey,
 3195|      0|                                           user->privKeyLen) == -1) {
 3196|      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]
  |  |  ------------------
  ------------------
 3197|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3198|      0|        goto err;
 3199|      0|    }
 3200|       |
 3201|       |
 3202|       |    /*
 3203|       |     * Perform the timeliness/time manager functions.
 3204|       |     */
 3205|      0|    if (secLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|      0|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (3205:9): [True: 0, False: 0]
  ------------------
 3206|      0|        || secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3206:12): [True: 0, False: 0]
  ------------------
 3207|      0|        if (usm_check_and_update_timeliness(secEngineID, *secEngineIDLen,
  ------------------
  |  Branch (3207:13): [True: 0, False: 0]
  ------------------
 3208|      0|                                            boots_uint, time_uint,
 3209|      0|                                            &error) == -1) {
 3210|      0|            goto err;
 3211|      0|        }
 3212|      0|    }
 3213|      0|#ifdef							LCD_TIME_SYNC_OPT
 3214|       |    /*
 3215|       |     * Cache the unauthenticated time to use in case we don't have
 3216|       |     * anything better - this guess will be no worse than (0,0)
 3217|       |     * that we normally use.
 3218|       |     */
 3219|      0|    else {
 3220|      0|        set_enginetime(secEngineID, *secEngineIDLen,
 3221|      0|                       boots_uint, time_uint, FALSE);
  ------------------
  |  |  125|      0|#define FALSE 0
  ------------------
 3222|      0|    }
 3223|      0|#endif                          /* LCD_TIME_SYNC_OPT */
 3224|       |
 3225|       |
 3226|       |    /*
 3227|       |     * If needed, decrypt the scoped PDU.
 3228|       |     */
 3229|      0|    if (secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3229:9): [True: 0, False: 0]
  ------------------
 3230|      0|        int priv_type = sc_get_privtype(user->privProtocol,
 3231|      0|                                        user->privProtocolLen);
 3232|      0|        remaining = wholeMsgLen - (data_ptr - wholeMsg);
 3233|       |
 3234|      0|        if ((value_ptr = asn_parse_sequence(data_ptr, &remaining,
  ------------------
  |  Branch (3234:13): [True: 0, False: 0]
  ------------------
 3235|      0|                                            &type_value,
 3236|      0|                                            (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                          (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3237|      0|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 3238|      0|                                            "encrypted sPDU")) == NULL) {
 3239|      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]
  |  |  ------------------
  ------------------
 3240|      0|                        "Failed while parsing encrypted sPDU."));
 3241|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3242|      0|            usm_free_usmStateReference(*secStateRef);
 3243|      0|            *secStateRef = NULL;
 3244|      0|            error = SNMPERR_USM_PARSEERROR;
  ------------------
  |  |  231|      0|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
 3245|      0|            goto err;
 3246|      0|        }
 3247|       |
 3248|      0|#ifndef NETSNMP_DISABLE_DES
 3249|      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 (3249:13): [True: 0, False: 0]
  ------------------
 3250|       |            /*
 3251|       |             * From RFC2574:
 3252|       |             * 
 3253|       |             * "Before decryption, the encrypted data length is verified.
 3254|       |             * If the length of the OCTET STRING to be decrypted is not
 3255|       |             * an integral multiple of 8 octets, the decryption process
 3256|       |             * is halted and an appropriate exception noted."  
 3257|       |             */
 3258|       |
 3259|      0|            if (remaining % 8 != 0) {
  ------------------
  |  Branch (3259:17): [True: 0, False: 0]
  ------------------
 3260|      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]
  |  |  ------------------
  ------------------
 3261|      0|                            "Ciphertext is %lu bytes, not an integer multiple of 8 (rem %lu)\n",
 3262|      0|                            (unsigned long)remaining, (unsigned long)remaining % 8));
 3263|      0|                snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3264|      0|                usm_free_usmStateReference(*secStateRef);
 3265|      0|                *secStateRef = NULL;
 3266|      0|                error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3267|      0|                goto err;
 3268|      0|            }
 3269|       |
 3270|      0|            end_of_overhead = value_ptr;
 3271|       |
 3272|      0|            if ( !user->privKey ) {
  ------------------
  |  Branch (3272:18): [True: 0, False: 0]
  ------------------
 3273|      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]
  |  |  ------------------
  ------------------
 3274|      0|                snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3275|      0|                usm_free_usmStateReference(*secStateRef);
 3276|      0|                *secStateRef = NULL;
 3277|      0|                error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3278|      0|                goto err;
 3279|      0|            }
 3280|       |
 3281|       |            /*
 3282|       |             * XOR the salt with the last (iv_length) bytes
 3283|       |             * of the priv_key to obtain the IV.
 3284|       |             */
 3285|      0|            iv_length = BYTESIZE(USM_DES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 3286|      0|            for (i = 0; i < (int) iv_length; i++)
  ------------------
  |  Branch (3286:25): [True: 0, False: 0]
  ------------------
 3287|      0|                iv[i] = salt[i] ^ user->privKey[iv_length + i];
 3288|      0|        }
 3289|      0|#endif
 3290|      0|#ifdef HAVE_AES
 3291|      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 (3291:13): [True: 0, False: 0]
  ------------------
 3292|      0|            iv_length = BYTESIZE(USM_AES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 3293|      0|            net_boots = ntohl(boots_uint);
 3294|      0|            net_time = ntohl(time_uint);
 3295|      0|            memcpy(iv, &net_boots, 4);
 3296|      0|            memcpy(iv+4, &net_time, 4);
 3297|      0|            memcpy(iv+8, salt, salt_length);
 3298|      0|        }
 3299|      0|#endif
 3300|       |
 3301|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 3302|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 3303|       |            dump_chunk("usm/dump", "Cypher Text", value_ptr, remaining);
 3304|       |            dump_chunk("usm/dump", "salt + Encrypted form:",
 3305|       |                       salt, salt_length);
 3306|       |            dump_chunk("usm/dump", "IV + Encrypted form:", iv, iv_length);
 3307|       |        }
 3308|       |#endif
 3309|      0|        if (sc_decrypt(user->privProtocol, user->privProtocolLen,
  ------------------
  |  Branch (3309:13): [True: 0, False: 0]
  ------------------
 3310|      0|                       user->privKey, user->privKeyLen,
 3311|      0|                       iv, iv_length,
 3312|      0|                       value_ptr, remaining, *scopedPdu, scopedPduLen)
 3313|      0|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 3314|      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]
  |  |  ------------------
  ------------------
 3315|      0|            snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3316|      0|            error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3317|      0|            goto err;
 3318|      0|        }
 3319|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 3320|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 3321|       |            dump_chunk("usm/dump", "Decrypted chunk:",
 3322|       |                       *scopedPdu, *scopedPduLen);
 3323|       |        }
 3324|       |#endif
 3325|      0|    }
 3326|       |    /*
 3327|       |     * sPDU is plaintext.
 3328|       |     */
 3329|      0|    else {
 3330|      0|        *scopedPdu = data_ptr;
 3331|      0|        *scopedPduLen = wholeMsgLen - (data_ptr - wholeMsg);
 3332|      0|        end_of_overhead = data_ptr;
 3333|       |
 3334|      0|    }                           /* endif -- PDU decryption */
 3335|       |
 3336|       |
 3337|       |    /*
 3338|       |     * Calculate the biggest sPDU for the response (i.e., whole - ovrhd).
 3339|       |     *
 3340|       |     * FIX  Correct? 
 3341|       |     */
 3342|      0|    *maxSizeResponse = maxMsgSize - (end_of_overhead - wholeMsg);
 3343|       |
 3344|       |
 3345|      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]
  |  |  ------------------
  ------------------
 3346|       |
 3347|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3348|       |
 3349|     22|err:
 3350|     22|    usm_free_usmStateReference(*secStateRef);
 3351|     22|    *secStateRef = NULL;
 3352|       |    netsnmp_assert(error != SNMPERR_SUCCESS);
  ------------------
  |  |   47|     22|#      define netsnmp_assert(x)  do { \
  |  |   48|     22|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 22, False: 0]
  |  |  ------------------
  |  |   49|     22|                 ; \
  |  |   50|     22|              else \
  |  |   51|     22|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     22|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 22]
  |  |  ------------------
  ------------------
 3353|     22|    return error;
 3354|      0|}                               /* end usm_process_in_msg() */
snmpusm.c:usm_malloc_usmStateReference:
  288|     22|{
  289|     22|    struct usmStateReference *retval;
  290|       |
  291|     22|    retval = calloc(1, sizeof(struct usmStateReference));
  292|     22|    if (retval)
  ------------------
  |  Branch (292:9): [True: 22, False: 0]
  ------------------
  293|     22|        retval->refcnt = 1;
  294|       |
  295|     22|    return retval;
  296|     22|}                               /* end usm_malloc_usmStateReference() */
snmpusm.c:usm_parse_security_parameters:
 2477|     22|{
 2478|     22|    u_char         *parse_ptr = secParams;
 2479|     22|    u_char         *value_ptr;
 2480|     22|    u_char         *next_ptr;
 2481|     22|    u_char          type_value;
 2482|       |
 2483|     22|    size_t          octet_string_length = remaining;
 2484|     22|    size_t          sequence_length;
 2485|     22|    size_t          remaining_bytes;
 2486|       |
 2487|     22|    long            boots_long;
 2488|     22|    long            time_long;
 2489|       |
 2490|     22|    u_int           origNameLen;
 2491|       |
 2492|       |
 2493|       |    /*
 2494|       |     * Eat the first octet header.
 2495|       |     */
 2496|     22|    if ((value_ptr = asn_parse_sequence(parse_ptr, &octet_string_length,
  ------------------
  |  Branch (2496:9): [True: 1, False: 21]
  ------------------
 2497|     22|                                        &type_value,
 2498|     22|                                        (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|     22|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|     22|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2499|     22|                                         ASN_OCTET_STR),
  ------------------
  |  |   78|     22|#define ASN_OCTET_STR	    0x04U
  ------------------
 2500|     22|                                        "usm first octet")) == NULL) {
 2501|       |        /*
 2502|       |         * RETURN parse error 
 2503|      1|         */ return -1;
 2504|      1|    }
 2505|       |
 2506|       |
 2507|       |    /*
 2508|       |     * Eat the sequence header.
 2509|       |     */
 2510|     21|    parse_ptr = value_ptr;
 2511|     21|    sequence_length = octet_string_length;
 2512|       |
 2513|     21|    if ((value_ptr = asn_parse_sequence(parse_ptr, &sequence_length,
  ------------------
  |  Branch (2513:9): [True: 0, False: 21]
  ------------------
 2514|     21|                                        &type_value,
 2515|     21|                                        (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|     21|#define ASN_SEQUENCE	    0x10U
  ------------------
                                                      (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     21|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2516|     21|                                        "usm sequence")) == NULL) {
 2517|       |        /*
 2518|       |         * RETURN parse error 
 2519|      0|         */ return -1;
 2520|      0|    }
 2521|       |
 2522|       |
 2523|       |    /*
 2524|       |     * Retrieve the engineID.
 2525|       |     */
 2526|     21|    parse_ptr = value_ptr;
 2527|     21|    remaining_bytes = sequence_length;
 2528|       |
 2529|     21|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineID");
  ------------------
  |  |   79|     21|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 21]
  |  |  ------------------
  ------------------
 2530|     21|    if ((next_ptr
  ------------------
  |  Branch (2530:9): [True: 0, False: 21]
  ------------------
 2531|     21|         = asn_parse_string(parse_ptr, &remaining_bytes, &type_value,
 2532|     21|                            secEngineID, secEngineIDLen)) == NULL) {
 2533|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2534|       |        /*
 2535|       |         * RETURN parse error 
 2536|      0|         */ return -1;
 2537|      0|    }
 2538|     21|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     21|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 21]
  |  |  ------------------
  ------------------
 2539|       |
 2540|     21|    if (type_value !=
  ------------------
  |  Branch (2540:9): [True: 0, False: 21]
  ------------------
 2541|     21|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|     21|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|     21|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|     21|#define ASN_OCTET_STR	    0x04U
  ------------------
 2542|       |        /*
 2543|       |         * RETURN parse error 
 2544|      0|         */ return -1;
 2545|      0|    }
 2546|       |
 2547|       |
 2548|       |    /*
 2549|       |     * Retrieve the engine boots, notice switch in the way next_ptr and
 2550|       |     * remaining_bytes are used (to accommodate the asn code).
 2551|       |     */
 2552|     21|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineBoots");
  ------------------
  |  |   79|     21|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 21]
  |  |  ------------------
  ------------------
 2553|     21|    if ((next_ptr = asn_parse_int(next_ptr, &remaining_bytes, &type_value,
  ------------------
  |  Branch (2553:9): [True: 0, False: 21]
  ------------------
 2554|     21|                                  &boots_long, sizeof(long))) == NULL) {
 2555|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2556|       |        /*
 2557|       |         * RETURN parse error 
 2558|      0|         */ return -1;
 2559|      0|    }
 2560|     21|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     21|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 21]
  |  |  ------------------
  ------------------
 2561|       |
 2562|     21|    if (type_value !=
  ------------------
  |  Branch (2562:9): [True: 0, False: 21]
  ------------------
 2563|     21|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   90|     21|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   95|     21|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   75|     21|#define ASN_INTEGER	    0x02U
  ------------------
 2564|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2565|       |        /*
 2566|       |         * RETURN parse error 
 2567|      0|         */ return -1;
 2568|      0|    }
 2569|       |
 2570|     21|    *boots_uint = (u_int) boots_long;
 2571|       |
 2572|       |
 2573|       |    /*
 2574|       |     * Retrieve the time value.
 2575|       |     */
 2576|     21|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineTime");
  ------------------
  |  |   79|     21|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 21]
  |  |  ------------------
  ------------------
 2577|     21|    if ((next_ptr = asn_parse_int(next_ptr, &remaining_bytes, &type_value,
  ------------------
  |  Branch (2577:9): [True: 0, False: 21]
  ------------------
 2578|     21|                                  &time_long, sizeof(long))) == NULL) {
 2579|       |        /*
 2580|       |         * RETURN parse error 
 2581|      0|         */ return -1;
 2582|      0|    }
 2583|     21|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     21|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 21]
  |  |  ------------------
  ------------------
 2584|       |
 2585|     21|    if (type_value !=
  ------------------
  |  Branch (2585:9): [True: 0, False: 21]
  ------------------
 2586|     21|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   90|     21|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   95|     21|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   75|     21|#define ASN_INTEGER	    0x02U
  ------------------
 2587|       |        /*
 2588|       |         * RETURN parse error 
 2589|      0|         */ return -1;
 2590|      0|    }
 2591|       |
 2592|     21|    *time_uint = (u_int) time_long;
 2593|       |
 2594|     21|    if (*boots_uint > ENGINEBOOT_MAX || *time_uint > ENGINETIME_MAX) {
  ------------------
  |  |  183|     42|#define ENGINEBOOT_MAX	2147483647      /* ((2^31)-1) */
  ------------------
                  if (*boots_uint > ENGINEBOOT_MAX || *time_uint > ENGINETIME_MAX) {
  ------------------
  |  |  182|     21|#define ENGINETIME_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (2594:9): [True: 0, False: 21]
  |  Branch (2594:41): [True: 0, False: 21]
  ------------------
 2595|      0|        return -1;
 2596|      0|    }
 2597|       |
 2598|       |    /*
 2599|       |     * Retrieve the secName.
 2600|       |     */
 2601|     21|    origNameLen = *secNameLen;
 2602|       |
 2603|       |
 2604|     21|    DEBUGDUMPHEADER("recv", "msgUserName");
  ------------------
  |  |   79|     21|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 21]
  |  |  ------------------
  ------------------
 2605|     21|    if ((next_ptr
  ------------------
  |  Branch (2605:9): [True: 0, False: 21]
  ------------------
 2606|     21|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2607|     21|                            (u_char *) secName, secNameLen)) == NULL) {
 2608|      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]
  |  |  ------------------
  ------------------
 2609|       |        /*
 2610|       |         * RETURN parse error 
 2611|      0|         */ return -1;
 2612|      0|    }
 2613|     21|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     21|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 21]
  |  |  ------------------
  ------------------
 2614|       |
 2615|       |    /*
 2616|       |     * FIX -- doesn't this also indicate a buffer overrun?
 2617|       |     */
 2618|     21|    if (origNameLen < *secNameLen + 1) {
  ------------------
  |  Branch (2618:9): [True: 0, False: 21]
  ------------------
 2619|       |        /*
 2620|       |         * RETURN parse error, but it's really a parameter error 
 2621|       |         */
 2622|      0|        return -1;
 2623|      0|    }
 2624|       |
 2625|     21|    if (*secNameLen > 32) {
  ------------------
  |  Branch (2625:9): [True: 0, False: 21]
  ------------------
 2626|       |        /*
 2627|       |         * This is a USM-specific limitation over and above the above
 2628|       |         * limitation (which will probably default to the length of an
 2629|       |         * SnmpAdminString, i.e. 255).  See RFC 2574, sec. 2.4.  
 2630|       |         */
 2631|      0|        return -1;
 2632|      0|    }
 2633|       |
 2634|     21|    secName[*secNameLen] = '\0';
 2635|       |
 2636|     21|    if (type_value !=
  ------------------
  |  Branch (2636:9): [True: 0, False: 21]
  ------------------
 2637|     21|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|     21|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|     21|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|     21|#define ASN_OCTET_STR	    0x04U
  ------------------
 2638|       |        /*
 2639|       |         * RETURN parse error 
 2640|      0|         */ return -1;
 2641|      0|    }
 2642|       |
 2643|       |
 2644|       |    /*
 2645|       |     * Retrieve the signature and blank it if there.
 2646|       |     */
 2647|     21|    DEBUGDUMPHEADER("recv", "msgAuthenticationParameters");
  ------------------
  |  |   79|     21|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 21]
  |  |  ------------------
  ------------------
 2648|     21|    if ((next_ptr
  ------------------
  |  Branch (2648:9): [True: 0, False: 21]
  ------------------
 2649|     21|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2650|     21|                            signature, signature_length)) == NULL) {
 2651|      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]
  |  |  ------------------
  ------------------
 2652|       |        /*
 2653|       |         * RETURN parse error 
 2654|      0|         */ return -1;
 2655|      0|    }
 2656|     21|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     21|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     21|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 21]
  |  |  ------------------
  ------------------
 2657|       |
 2658|     21|    if (type_value !=
  ------------------
  |  Branch (2658:9): [True: 1, False: 20]
  ------------------
 2659|     21|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|     21|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|     21|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|     21|#define ASN_OCTET_STR	    0x04U
  ------------------
 2660|       |        /*
 2661|       |         * RETURN parse error 
 2662|      1|         */ return -1;
 2663|      1|    }
 2664|       |
 2665|     20|    if (*signature_length != 0) {       /* Blanking for authentication step later */
  ------------------
  |  Branch (2665:9): [True: 20, False: 0]
  ------------------
 2666|     20|        memset(next_ptr - (u_long) * signature_length,
 2667|     20|               0, *signature_length);
 2668|     20|    }
 2669|       |
 2670|       |
 2671|       |    /*
 2672|       |     * Retrieve the salt.
 2673|       |     *
 2674|       |     * Note that the next ptr is where the data section starts.
 2675|       |     */
 2676|     20|    DEBUGDUMPHEADER("recv", "msgPrivacyParameters");
  ------------------
  |  |   79|     20|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 20]
  |  |  ------------------
  ------------------
 2677|     20|    if ((*data_ptr
  ------------------
  |  Branch (2677:9): [True: 12, False: 8]
  ------------------
 2678|     20|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2679|     20|                            salt, salt_length)) == NULL) {
 2680|     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]
  |  |  ------------------
  ------------------
 2681|       |        /*
 2682|       |         * RETURN parse error 
 2683|     12|         */ return -2;
 2684|     12|    }
 2685|      8|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      8|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 8]
  |  |  ------------------
  ------------------
 2686|       |
 2687|      8|    if (type_value !=
  ------------------
  |  Branch (2687:9): [True: 0, False: 8]
  ------------------
 2688|      8|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|      8|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|      8|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|      8|#define ASN_OCTET_STR	    0x04U
  ------------------
 2689|       |        /*
 2690|       |         * RETURN parse error 
 2691|      0|         */ return -2;
 2692|      0|    }
 2693|       |
 2694|      8|    return 0;
 2695|       |
 2696|      8|}                               /* end usm_parse_security_parameters() */
snmpusm.c:usm_set_usmStateReference_name:
  356|      8|{
  357|       |    MAKE_ENTRY(ref, char, name, name_len, usr_name, usr_name_length);
  ------------------
  |  |  248|      8|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|      8|do {                                                            \
  |  |  250|      8|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 8]
  |  |  ------------------
  |  |  251|      8|		return -1;                                      \
  |  |  252|      8|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 8]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|      8|	ref->field_len = 0;                                     \
  |  |  257|      8|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 8, False: 0]
  |  |  |  Branch (257:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  258|      8|		return 0;                                       \
  |  |  259|      8|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|      0|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  261|      0|		return -1;                                      \
  |  |  262|      0|                                                                \
  |  |  263|      0|	ref->field_len = len;                                   \
  |  |  264|      0|	return 0;                                               \
  |  |  265|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  358|      8|}
snmpusm.c:usm_set_usmStateReference_engine_id:
  364|      8|{
  365|       |    MAKE_ENTRY(ref, u_char, engine_id, engine_id_len,
  ------------------
  |  |  248|      8|#define MAKE_ENTRY(ref, type, item, len, field, field_len)      \
  |  |  249|      8|do {                                                            \
  |  |  250|      8|	if (ref == NULL)                                        \
  |  |  ------------------
  |  |  |  Branch (250:6): [True: 0, False: 8]
  |  |  ------------------
  |  |  251|      8|		return -1;                                      \
  |  |  252|      8|	if (ref->field != NULL)	{                               \
  |  |  ------------------
  |  |  |  Branch (252:6): [True: 0, False: 8]
  |  |  ------------------
  |  |  253|      0|		SNMP_ZERO(ref->field, ref->field_len);          \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  254|      0|		SNMP_FREE(ref->field);                          \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  255|      0|	}                                                       \
  |  |  256|      8|	ref->field_len = 0;                                     \
  |  |  257|      8|        if (len == 0 || item == NULL)                           \
  |  |  ------------------
  |  |  |  Branch (257:13): [True: 0, False: 8]
  |  |  |  Branch (257:25): [True: 0, False: 8]
  |  |  ------------------
  |  |  258|      8|		return 0;                                       \
  |  |  259|      8|	ref->field = netsnmp_memdup(item, len * sizeof(type));  \
  |  |  260|      8|        if (ref->field == NULL)                                 \
  |  |  ------------------
  |  |  |  Branch (260:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  261|      8|		return -1;                                      \
  |  |  262|      8|                                                                \
  |  |  263|      8|	ref->field_len = len;                                   \
  |  |  264|      8|	return 0;                                               \
  |  |  265|      8|} while (0)
  |  |  ------------------
  |  |  |  Branch (265:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  366|      8|               usr_engine_id, usr_engine_id_length);
  367|      8|}
snmpusm.c:usm_set_usmStateReference_sec_level:
  406|      8|{
  407|      8|    if (ref == NULL)
  ------------------
  |  Branch (407:9): [True: 0, False: 8]
  ------------------
  408|      0|        return -1;
  409|      8|    ref->usr_sec_level = sec_level;
  410|      8|    return 0;
  411|      8|}
snmpusm.c:usm_clone:
  300|     20|{
  301|     20|    struct usmStateReference *ref = pdu->securityStateRef;
  302|     20|    struct usmStateReference **new_ref =
  303|     20|        (struct usmStateReference **)&new_pdu->securityStateRef;
  304|     20|    int ret = 0;
  305|       |
  306|     20|    if (!ref)
  ------------------
  |  Branch (306:9): [True: 20, False: 0]
  ------------------
  307|     20|        return ret;
  308|       |
  309|      0|    if (pdu->command == 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 (309:9): [True: 0, False: 0]
  ------------------
  310|      0|        ret = usm_clone_usmStateReference(ref, new_ref);
  311|      0|    } else {
  312|      0|        *new_ref = ref;
  313|      0|        ref->refcnt++;
  314|      0|    }
  315|       |
  316|      0|    return ret;
  317|     20|}
snmpusm.c:usm_free_usmStateReference:
  321|     66|{
  322|     66|    struct usmStateReference *ref = old;
  323|       |
  324|     66|    if (!ref)
  ------------------
  |  Branch (324:9): [True: 44, False: 22]
  ------------------
  325|     44|        return;
  326|       |
  327|     22|    if (--ref->refcnt > 0)
  ------------------
  |  Branch (327:9): [True: 0, False: 22]
  ------------------
  328|      0|        return;
  329|       |
  330|     22|    SNMP_FREE(ref->usr_name);
  ------------------
  |  |   62|     22|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 22]
  |  |  |  Branch (62:66): [Folded, False: 22]
  |  |  ------------------
  ------------------
  331|     22|    SNMP_FREE(ref->usr_engine_id);
  ------------------
  |  |   62|     22|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 8, False: 14]
  |  |  |  Branch (62:66): [Folded, False: 22]
  |  |  ------------------
  ------------------
  332|     22|    SNMP_FREE(ref->usr_auth_protocol);
  ------------------
  |  |   62|     22|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 22]
  |  |  |  Branch (62:66): [Folded, False: 22]
  |  |  ------------------
  ------------------
  333|     22|    SNMP_FREE(ref->usr_priv_protocol);
  ------------------
  |  |   62|     22|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 22]
  |  |  |  Branch (62:66): [Folded, False: 22]
  |  |  ------------------
  ------------------
  334|       |
  335|     22|    if (ref->usr_auth_key_length && ref->usr_auth_key) {
  ------------------
  |  Branch (335:9): [True: 0, False: 22]
  |  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|     22|    if (ref->usr_priv_key_length && ref->usr_priv_key) {
  ------------------
  |  Branch (339:9): [True: 0, False: 22]
  |  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|     22|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 22, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 22]
  |  |  ------------------
  ------------------
  345|     22|}                               /* end usm_free_usmStateReference() */
snmpusm.c:usm_session_init:
 3461|     47|{
 3462|     47|    char *cp;
 3463|     47|    size_t i;
 3464|       |    
 3465|     47|    if (in_session->securityAuthProtoLen > 0) {
  ------------------
  |  Branch (3465:9): [True: 0, False: 47]
  ------------------
 3466|      0|        session->securityAuthProto =
 3467|      0|            snmp_duplicate_objid(in_session->securityAuthProto,
 3468|      0|                                 in_session->securityAuthProtoLen);
 3469|      0|        if (session->securityAuthProto == NULL) {
  ------------------
  |  Branch (3469:13): [True: 0, False: 0]
  ------------------
 3470|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3471|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3472|      0|        }
 3473|     47|    } else if (get_default_authtype(&i) != NULL) {
  ------------------
  |  Branch (3473:16): [True: 47, False: 0]
  ------------------
 3474|     47|        session->securityAuthProto =
 3475|     47|            snmp_duplicate_objid(get_default_authtype(NULL), i);
 3476|     47|        session->securityAuthProtoLen = i;
 3477|     47|    }
 3478|       |
 3479|     47|    if (in_session->securityPrivProtoLen > 0) {
  ------------------
  |  Branch (3479:9): [True: 0, False: 47]
  ------------------
 3480|      0|        session->securityPrivProto =
 3481|      0|            snmp_duplicate_objid(in_session->securityPrivProto,
 3482|      0|                                 in_session->securityPrivProtoLen);
 3483|      0|        if (session->securityPrivProto == NULL) {
  ------------------
  |  Branch (3483:13): [True: 0, False: 0]
  ------------------
 3484|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3485|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3486|      0|        }
 3487|     47|    } else if (get_default_privtype(&i) != NULL) {
  ------------------
  |  Branch (3487:16): [True: 47, False: 0]
  ------------------
 3488|     47|        session->securityPrivProto =
 3489|     47|            snmp_duplicate_objid(get_default_privtype(NULL), i);
 3490|     47|        session->securityPrivProtoLen = i;
 3491|     47|    }
 3492|       |
 3493|     47|    if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3493:9): [True: 47, False: 0]
  ------------------
 3494|     47|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3494:9): [True: 0, False: 47]
  ------------------
 3495|     47|				     NETSNMP_DS_LIB_AUTHMASTERKEY)))) {
  ------------------
  |  |  167|     47|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 3496|      0|        size_t buflen = sizeof(session->securityAuthKey);
 3497|      0|        u_char *tmpp = session->securityAuthKey;
 3498|      0|        session->securityAuthKeyLen = 0;
 3499|       |        /* it will be a hex string */
 3500|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3500:13): [True: 0, False: 0]
  ------------------
 3501|      0|                                &session->securityAuthKeyLen, 0, cp)) {
 3502|      0|            snmp_set_detail("error parsing authentication master key");
 3503|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3504|      0|        }
 3505|     47|    } else if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3505:16): [True: 47, False: 0]
  ------------------
 3506|     47|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3506:17): [True: 0, False: 47]
  ------------------
 3507|     47|                                            NETSNMP_DS_LIB_AUTHPASSPHRASE)) ||
  ------------------
  |  |  154|     47|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 3508|     47|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3508:17): [True: 0, False: 47]
  ------------------
 3509|     47|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|     47|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3510|      0|        session->securityAuthKeyLen = USM_AUTH_KU_LEN;
  ------------------
  |  |  271|      0|#define USM_AUTH_KU_LEN     64
  ------------------
 3511|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3511:13): [True: 0, False: 0]
  ------------------
 3512|      0|                        session->securityAuthProtoLen,
 3513|      0|                        (u_char *) cp, strlen(cp),
 3514|      0|                        session->securityAuthKey,
 3515|      0|                        &session->securityAuthKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3516|      0|            snmp_set_detail
 3517|      0|                ("Error generating a key (Ku) from the supplied authentication pass phrase.");
 3518|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3519|      0|        }
 3520|      0|    }
 3521|       |
 3522|       |    
 3523|     47|    if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3523:9): [True: 47, False: 0]
  ------------------
 3524|     47|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3524:9): [True: 0, False: 47]
  ------------------
 3525|     47|				     NETSNMP_DS_LIB_PRIVMASTERKEY)))) {
  ------------------
  |  |  168|     47|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 3526|      0|        size_t buflen = sizeof(session->securityPrivKey);
 3527|      0|        u_char *tmpp = session->securityPrivKey;
 3528|      0|        session->securityPrivKeyLen = 0;
 3529|       |        /* it will be a hex string */
 3530|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3530:13): [True: 0, False: 0]
  ------------------
 3531|      0|                                &session->securityPrivKeyLen, 0, cp)) {
 3532|      0|            snmp_set_detail("error parsing encryption master key");
 3533|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3534|      0|        }
 3535|     47|    } else if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3535:16): [True: 47, False: 0]
  ------------------
 3536|     47|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3536:17): [True: 0, False: 47]
  ------------------
 3537|     47|                                            NETSNMP_DS_LIB_PRIVPASSPHRASE)) ||
  ------------------
  |  |  155|     47|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 3538|     47|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3538:17): [True: 0, False: 47]
  ------------------
 3539|     47|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|     47|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3540|      0|        session->securityPrivKeyLen = USM_PRIV_KU_LEN;
  ------------------
  |  |  272|      0|#define USM_PRIV_KU_LEN     64
  ------------------
 3541|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3541:13): [True: 0, False: 0]
  ------------------
 3542|      0|                        session->securityAuthProtoLen,
 3543|      0|                        (u_char *) cp, strlen(cp),
 3544|      0|                        session->securityPrivKey,
 3545|      0|                        &session->securityPrivKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3546|      0|            snmp_set_detail
 3547|      0|                ("Error generating a key (Ku) from the supplied privacy pass phrase.");
 3548|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3549|      0|        }
 3550|      0|    }
 3551|       |
 3552|     47|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3553|     47|}
snmpusm.c:usm_handle_report:
 3384|     22|{
 3385|       |    /*
 3386|       |     * handle reportable errors 
 3387|       |     */
 3388|       |
 3389|       |    /* this will get in our way */
 3390|     22|    usm_free_usmStateReference(pdu->securityStateRef);
 3391|     22|    pdu->securityStateRef = NULL;
 3392|       |
 3393|     22|    switch (result) {
  ------------------
  |  Branch (3393:13): [True: 20, False: 2]
  ------------------
 3394|      0|    case SNMPERR_USM_AUTHENTICATIONFAILURE:
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
  |  Branch (3394:5): [True: 0, False: 22]
  ------------------
 3395|      0|    {
 3396|      0|        int res = session->s_snmp_errno;
 3397|      0|        session->s_snmp_errno = result;
 3398|      0|        if (session->callback) {
  ------------------
  |  Branch (3398:13): [True: 0, False: 0]
  ------------------
 3399|      0|            session->callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE,
  ------------------
  |  |  319|      0|#define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE	1
  ------------------
 3400|      0|                              session, pdu->reqid, pdu,
 3401|      0|                              session->callback_magic);
 3402|      0|        }
 3403|      0|        session->s_snmp_errno = res;
 3404|      0|    }  
 3405|      0|    NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 3406|      8|    case SNMPERR_USM_UNKNOWNENGINEID:
  ------------------
  |  |  232|      8|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
  |  Branch (3406:5): [True: 8, False: 14]
  ------------------
 3407|      8|    case SNMPERR_USM_UNKNOWNSECURITYNAME:
  ------------------
  |  |  227|      8|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (3407:5): [True: 0, False: 22]
  ------------------
 3408|      8|    case SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL:
  ------------------
  |  |  228|      8|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
  |  Branch (3408:5): [True: 0, False: 22]
  ------------------
 3409|      8|    case SNMPERR_USM_NOTINTIMEWINDOW:
  ------------------
  |  |  233|      8|#define SNMPERR_USM_NOTINTIMEWINDOW		(-49)
  ------------------
  |  Branch (3409:5): [True: 0, False: 22]
  ------------------
 3410|     20|    case SNMPERR_USM_DECRYPTIONERROR:
  ------------------
  |  |  234|     20|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
  |  Branch (3410:5): [True: 12, False: 10]
  ------------------
 3411|       |
 3412|     20|        if (SNMP_CMD_CONFIRMED(pdu->command) ||
  ------------------
  |  |  193|     40|#define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
  |  |  ------------------
  |  |  |  |  141|     40|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
  |  |  ------------------
  |  |  |  |  140|     40|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (193:32): [True: 0, False: 20]
  |  |  |  Branch (193:56): [True: 0, False: 20]
  |  |  ------------------
  |  |  194|     20|                               c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
  |  |  ------------------
  |  |  |  |  126|     40|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
  |  |  ------------------
  |  |  |  |  125|     40|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (194:32): [True: 0, False: 20]
  |  |  |  Branch (194:57): [True: 0, False: 20]
  |  |  ------------------
  |  |  195|     40|                               c == SNMP_MSG_SET )
  |  |  ------------------
  |  |  |  |  129|     40|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|     20|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|     20|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (195:32): [True: 0, False: 20]
  |  |  ------------------
  ------------------
 3413|     20|            (pdu->command == 0
  ------------------
  |  Branch (3413:14): [True: 20, False: 0]
  ------------------
 3414|     20|             && (pdu->flags & SNMP_MSG_FLAG_RPRT_BIT))) {
  ------------------
  |  |  305|     20|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3414:17): [True: 20, False: 0]
  ------------------
 3415|     20|            netsnmp_pdu    *pdu2;
 3416|     20|            int             flags = pdu->flags;
 3417|       |
 3418|     20|            pdu->flags |= UCD_MSG_FLAG_FORCE_PDU_COPY;
  ------------------
  |  |  313|     20|#define UCD_MSG_FLAG_FORCE_PDU_COPY          0x400
  ------------------
 3419|     20|            pdu2 = snmp_clone_pdu(pdu);
 3420|     20|            pdu->flags = pdu2->flags = flags;
 3421|     20|            snmpv3_make_report(pdu2, result);
 3422|     20|            if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (3422:17): [True: 0, False: 20]
  ------------------
 3423|      0|                snmp_free_pdu(pdu2);
 3424|       |                /*
 3425|       |                 * TODO: indicate error 
 3426|       |                 */
 3427|      0|            }
 3428|     20|        }
 3429|     20|        break;
 3430|     22|    }       
 3431|     22|}
snmpusm.c:init_usm_post_config:
 5134|     47|{
 5135|     47|    size_t          salt_integer_len = sizeof(salt_integer);
 5136|     47|    uint64_t        current_time;
 5137|       |
 5138|     47|    if (sc_random((u_char *) & salt_integer, &salt_integer_len) !=
  ------------------
  |  Branch (5138:9): [True: 0, False: 47]
  ------------------
 5139|     47|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5140|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5141|      0|        current_time = time(NULL);
 5142|      0|        salt_integer = current_time;
 5143|      0|    }
 5144|       |
 5145|     47|#ifdef HAVE_AES
 5146|     47|    salt_integer_len = sizeof (salt_integer64_1);
 5147|     47|    if (sc_random((u_char *) & salt_integer64_1, &salt_integer_len) !=
  ------------------
  |  Branch (5147:9): [True: 0, False: 47]
  ------------------
 5148|     47|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5149|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes1 salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5150|      0|        current_time = time(NULL);
 5151|      0|        salt_integer64_1 = current_time;
 5152|      0|    }
 5153|     47|    salt_integer_len = sizeof (salt_integer64_1);
 5154|     47|    if (sc_random((u_char *) & salt_integer64_2, &salt_integer_len) !=
  ------------------
  |  Branch (5154:9): [True: 0, False: 47]
  ------------------
 5155|     47|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5156|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes2 salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5157|      0|        current_time = time(NULL);
 5158|      0|        salt_integer64_2 = current_time;
 5159|      0|    }
 5160|     47|#endif
 5161|       |
 5162|       |    // Free noNameUser before it is assigned
 5163|     47|    usm_free_user(noNameUser);
 5164|       |
 5165|     47|#ifndef NETSNMP_DISABLE_MD5
 5166|     47|    noNameUser = usm_create_initial_user("", usmHMACMD5AuthProtocol,
 5167|     47|                                         OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|     47|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     47|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 5168|     47|                                         SNMP_DEFAULT_PRIV_PROTO,
  ------------------
  |  |  100|     47|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5169|     47|                                         SNMP_DEFAULT_PRIV_PROTOLEN);
  ------------------
  |  |  104|     47|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|     47|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|     47|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5170|       |#else
 5171|       |    noNameUser = usm_create_initial_user("", usmHMACSHA1AuthProtocol,
 5172|       |                                         OID_LENGTH(usmHMACSHA1AuthProtocol),
 5173|       |                                         SNMP_DEFAULT_PRIV_PROTO,
 5174|       |                                         SNMP_DEFAULT_PRIV_PROTOLEN);
 5175|       |#endif
 5176|       |
 5177|     47|    if ( noNameUser ) {
  ------------------
  |  Branch (5177:10): [True: 47, False: 0]
  ------------------
 5178|     47|        SNMP_FREE(noNameUser->engineID);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 5179|     47|        noNameUser->engineIDLen = 0;
 5180|     47|    }
 5181|       |
 5182|     47|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5183|     47|}                               /* end init_usm_post_config() */
snmpusm.c:usm_create_initial_user:
 4142|     47|{
 4143|     47|    struct usmUser *newUser = usm_create_user();
 4144|     47|    if (newUser == NULL)
  ------------------
  |  Branch (4144:9): [True: 0, False: 47]
  ------------------
 4145|      0|        return NULL;
 4146|       |
 4147|     47|    if ((newUser->name = strdup(name)) == NULL)
  ------------------
  |  Branch (4147:9): [True: 0, False: 47]
  ------------------
 4148|      0|        return usm_free_user(newUser);
 4149|       |
 4150|     47|    if ((newUser->secName = strdup(name)) == NULL)
  ------------------
  |  Branch (4150:9): [True: 0, False: 47]
  ------------------
 4151|      0|        return usm_free_user(newUser);
 4152|       |
 4153|     47|    if ((newUser->engineID =
  ------------------
  |  Branch (4153:9): [True: 0, False: 47]
  ------------------
 4154|     47|         snmpv3_generate_engineID(&newUser->engineIDLen)) == NULL)
 4155|      0|        return usm_free_user(newUser);
 4156|       |
 4157|     47|    if ((newUser->cloneFrom = (oid *) malloc(sizeof(oid) * 2)) == NULL)
  ------------------
  |  Branch (4157:9): [True: 0, False: 47]
  ------------------
 4158|      0|        return usm_free_user(newUser);
 4159|     47|    newUser->cloneFrom[0] = 0;
 4160|     47|    newUser->cloneFrom[1] = 0;
 4161|     47|    newUser->cloneFromLen = 2;
 4162|       |
 4163|     47|    SNMP_FREE(newUser->privProtocol);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 4164|     47|    if ((newUser->privProtocol = snmp_duplicate_objid(privProtocol,
  ------------------
  |  Branch (4164:9): [True: 0, False: 47]
  ------------------
 4165|     47|                                                      privProtocolLen)) ==
 4166|     47|        NULL) {
 4167|      0|        return usm_free_user(newUser);
 4168|      0|    }
 4169|     47|    newUser->privProtocolLen = privProtocolLen;
 4170|       |
 4171|     47|    SNMP_FREE(newUser->authProtocol);
  ------------------
  |  |   62|     47|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 47, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 47]
  |  |  ------------------
  ------------------
 4172|     47|    if ((newUser->authProtocol = snmp_duplicate_objid(authProtocol,
  ------------------
  |  Branch (4172:9): [True: 0, False: 47]
  ------------------
 4173|     47|                                                      authProtocolLen)) ==
 4174|     47|        NULL) {
 4175|      0|        return usm_free_user(newUser);
 4176|      0|    }
 4177|     47|    newUser->authProtocolLen = authProtocolLen;
 4178|       |
 4179|     47|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|     47|#define RS_ACTIVE	        1
  ------------------
 4180|     47|    newUser->userStorageType = ST_READONLY;
  ------------------
  |  |   54|     47|#define ST_READONLY	5
  ------------------
 4181|       |
 4182|     47|    return newUser;
 4183|     47|}
snmpusm.c:deinit_usm_post_config:
 5188|     47|{
 5189|     47|    usm_free_user(noNameUser);
 5190|     47|    noNameUser = NULL;
 5191|       |
 5192|     47|    DEBUGMSGTL(("deinit_usm_post_config", "initial user removed\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
 5193|     47|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     47|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5194|     47|}                               /* end deinit_usm_post_config() */
snmpusm.c:free_enginetime_on_shutdown:
  274|     47|{
  275|     47|    u_char engineID[SNMP_MAX_ENG_SIZE];
  276|     47|    size_t engineID_len = sizeof(engineID);
  277|       |
  278|     47|    DEBUGMSGTL(("snmpv3", "free enginetime callback called\n"));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  279|       |
  280|     47|    engineID_len = snmpv3_get_engineID(engineID, engineID_len);
  281|     47|    if (engineID_len > 0)
  ------------------
  |  Branch (281:9): [True: 0, False: 47]
  ------------------
  282|      0|	free_enginetime(engineID, engineID_len);
  283|     47|    return 0;
  284|     47|}
snmpusm.c:clear_user_list:
 3990|     47|{
 3991|     47|    struct usmUser *tmp = userList, *next = NULL;
 3992|       |
 3993|     47|    while (tmp != NULL) {
  ------------------
  |  Branch (3993:12): [True: 0, False: 47]
  ------------------
 3994|      0|	next = tmp->next;
 3995|      0|	usm_free_user(tmp);
 3996|      0|	tmp = next;
 3997|      0|    }
 3998|     47|    userList = NULL;
 3999|       |
 4000|     47|}

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

netsnmp_gethostbyname_v4:
  773|     47|{
  774|     47|#ifdef HAVE_GETADDRINFO
  775|     47|    struct addrinfo *addrs = NULL;
  776|     47|    struct addrinfo hint;
  777|     47|    int             err;
  778|       |
  779|     47|    memset(&hint, 0, sizeof hint);
  780|     47|    hint.ai_flags = 0;
  781|     47|    hint.ai_family = PF_INET;
  782|     47|    hint.ai_socktype = SOCK_DGRAM;
  783|     47|    hint.ai_protocol = 0;
  784|       |
  785|     47|    err = netsnmp_getaddrinfo(name, NULL, &hint, &addrs);
  786|     47|    if (err != 0) {
  ------------------
  |  Branch (786:9): [True: 0, False: 47]
  ------------------
  787|      0|        return -1;
  788|      0|    }
  789|       |
  790|     47|    if (addrs != NULL) {
  ------------------
  |  Branch (790:9): [True: 47, False: 0]
  ------------------
  791|     47|        memcpy(addr_out,
  792|     47|               &((struct sockaddr_in *) addrs->ai_addr)->sin_addr,
  793|     47|               sizeof(in_addr_t));
  794|     47|        freeaddrinfo(addrs);
  795|     47|    } 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|     47|    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|     47|}
netsnmp_getaddrinfo:
  843|     47|{
  844|     47|#ifdef HAVE_GETADDRINFO
  845|     47|    struct addrinfo *addrs = NULL;
  846|     47|    struct addrinfo hint;
  847|     47|    int             err;
  848|       |#ifdef DNSSEC_LOCAL_VALIDATION
  849|       |    val_status_t    val_status;
  850|       |#endif
  851|       |
  852|     47|    DEBUGMSGTL(("dns:getaddrinfo", "looking up "));
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  853|     47|    if (name)
  ------------------
  |  Branch (853:9): [True: 47, False: 0]
  ------------------
  854|     47|        DEBUGMSG(("dns:getaddrinfo", "\"%s\"", name));
  ------------------
  |  |   61|     47|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 47]
  |  |  ------------------
  ------------------
  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|     47|    if (service)
  ------------------
  |  Branch (858:9): [True: 0, False: 47]
  ------------------
  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|     47|    if (hints)
  ------------------
  |  Branch (861:9): [True: 47, False: 0]
  ------------------
  862|     47|	DEBUGMSG(("dns:getaddrinfo",
  ------------------
  |  |   61|     47|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  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: 47]
  |  |  ------------------
  ------------------
  863|     47|                  " with hints ({.ai_flags = %#x, .ai_family = %s})",
  864|     47|                  hints->ai_flags, hints->ai_family == 0 ? "0" :
  865|     47|                  hints->ai_family == AF_INET ? "AF_INET" :
  866|     47|                  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|     47|    DEBUGMSG(("dns:getaddrinfo", "\n"));
  ------------------
  |  |   61|     47|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 47]
  |  |  ------------------
  ------------------
  871|       |
  872|     47|    if (NULL == hints) {
  ------------------
  |  Branch (872:9): [True: 0, False: 47]
  ------------------
  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|     47|    } else {
  880|     47|        memcpy(&hint, hints, sizeof hint);
  881|     47|    }
  882|       |
  883|     47|#ifndef DNSSEC_LOCAL_VALIDATION
  884|     47|    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|     47|    *res = addrs;
  913|     47|    DEBUGIF("dns:getaddrinfo") {
  ------------------
  |  |  145|     47|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|     94|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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|     47|    return err;
  943|       |#else
  944|       |    NETSNMP_LOGONCE((LOG_ERR, "getaddrinfo not available"));
  945|       |    return EAI_FAIL;
  946|       |#endif /* getaddrinfo */
  947|     47|}
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|     47|{
 1385|     47|#ifdef HAVE_SYS_UTSNAME_H
 1386|     47|  static int printOSonce = 1;
 1387|     47|  struct utsname utsbuf;
 1388|     47|  if ( 0 > uname(&utsbuf))
  ------------------
  |  Branch (1388:8): [True: 0, False: 47]
  ------------------
 1389|      0|    return -1;
 1390|       |
 1391|     47|  if (printOSonce) {
  ------------------
  |  Branch (1391:7): [True: 1, False: 46]
  ------------------
 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|     47|  if (0 != strcasecmp(utsbuf.sysname, ospmname)) return -1;
  ------------------
  |  Branch (1397:7): [True: 0, False: 47]
  ------------------
 1398|       |
 1399|       |  /* Required to match only the leading characters */
 1400|     47|  return strncasecmp(utsbuf.release, ospmrelprefix, strlen(ospmrelprefix));
 1401|       |
 1402|       |#else
 1403|       |
 1404|       |  return -1;
 1405|       |
 1406|       |#endif /* HAVE_SYS_UTSNAME_H */
 1407|     47|}

netsnmp_memdup:
  279|    123|{
  280|    123|    void *to = NULL;
  281|       |
  282|    123|    if (from) {
  ------------------
  |  Branch (282:9): [True: 123, False: 0]
  ------------------
  283|    123|        to = malloc(size);
  284|    123|        if (to)
  ------------------
  |  Branch (284:13): [True: 123, False: 0]
  ------------------
  285|    123|            memcpy(to, from, size);
  286|    123|    }
  287|    123|    return to;
  288|    123|}                               /* end netsnmp_memdup() */
netsnmp_get_monotonic_clock:
  948|    254|{
  949|    254|#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
  950|    254|    struct timespec ts;
  951|    254|    int res;
  952|       |
  953|    254|    res = clock_gettime(CLOCK_MONOTONIC, &ts);
  954|    254|    if (res >= 0) {
  ------------------
  |  Branch (954:9): [True: 254, False: 0]
  ------------------
  955|    254|        tv->tv_sec = ts.tv_sec;
  956|    254|        tv->tv_usec = ts.tv_nsec / 1000;
  957|    254|    } 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|    254|}
netsnmp_getenv:
 1187|    237|{
 1188|    237|#if !defined (WIN32) && !defined (cygwin)
 1189|    237|  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|    237|}
netsnmp_gethomedir:
 1417|     48|const char *netsnmp_gethomedir(void) {
 1418|     48|    const char *homepath = netsnmp_getenv("HOME");
 1419|       |#ifdef _WIN32
 1420|       |    if (!homepath)
 1421|       |        homepath = netsnmp_getenv("USERPROFILE");
 1422|       |#endif
 1423|     48|    return homepath;
 1424|     48|}

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

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

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

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

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

netsnmp_sockaddr_in3:
   87|     47|{
   88|     47|    struct sockaddr_in *addr = &ep->a.sin;
   89|     47|    struct netsnmp_ep_str ep_str;
   90|     47|    int port, ret;
   91|       |
   92|     47|    if (!ep)
  ------------------
  |  Branch (92:9): [True: 0, False: 47]
  ------------------
   93|      0|        return 0;
   94|       |
   95|     47|    DEBUGMSGTL(("netsnmp_sockaddr_in",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#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: 47]
  |  |  ------------------
  ------------------
   96|     47|                "addr %p, inpeername \"%s\", default_target \"%s\"\n",
   97|     47|                ep, inpeername ? inpeername : "[NIL]",
   98|     47|                default_target ? default_target : "[NIL]"));
   99|       |
  100|     47|    memset(ep, 0, sizeof(*ep));
  101|     47|    addr->sin_addr.s_addr = htonl(INADDR_ANY);
  102|     47|    addr->sin_family = AF_INET;
  103|     47|    addr->sin_port = htons((u_short)SNMP_PORT);
  104|       |
  105|     47|    memset(&ep_str, 0, sizeof(ep_str));
  106|     47|    port = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     47|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  107|     47|                              NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|     47|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  108|     47|    if (port != 0)
  ------------------
  |  Branch (108:9): [True: 0, False: 47]
  ------------------
  109|      0|        snprintf(ep_str.port, sizeof(ep_str.port), "%d", port);
  110|     47|    else if (default_target &&
  ------------------
  |  Branch (110:14): [True: 0, False: 47]
  ------------------
  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|     47|    if (inpeername && *inpeername != '\0') {
  ------------------
  |  Branch (114:9): [True: 47, False: 0]
  |  Branch (114:23): [True: 47, False: 0]
  ------------------
  115|     47|	if (ep_str.addr) {
  ------------------
  |  Branch (115:6): [True: 0, False: 47]
  ------------------
  116|      0|	    free(ep_str.addr);  /* free default target */
  117|      0|	    ep_str.addr = NULL;
  118|      0|	}
  119|     47|	if (!netsnmp_parse_ep_str(&ep_str, inpeername))
  ------------------
  |  Branch (119:6): [True: 0, False: 47]
  ------------------
  120|      0|            return 0;
  121|     47|    }
  122|       |
  123|     47|    if (ep_str.port[0])
  ------------------
  |  Branch (123:9): [True: 47, False: 0]
  ------------------
  124|     47|        addr->sin_port = htons(atoi(ep_str.port));
  125|     47|    if (ep_str.iface[0])
  ------------------
  |  Branch (125:9): [True: 0, False: 47]
  ------------------
  126|      0|        strlcpy(ep->iface, ep_str.iface, sizeof(ep->iface));
  127|     47|    if (ep_str.addr && strcmp(ep_str.addr, "255.255.255.255") == 0) {
  ------------------
  |  Branch (127:9): [True: 47, False: 0]
  |  Branch (127:24): [True: 0, False: 47]
  ------------------
  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|     47|    } else if (ep_str.addr && strcmp(ep_str.addr, "") != 0) {
  ------------------
  |  Branch (133:16): [True: 47, False: 0]
  |  Branch (133:31): [True: 47, False: 0]
  ------------------
  134|     47|        ret = netsnmp_gethostbyname_v4(ep_str.addr, &addr->sin_addr.s_addr);
  135|     47|        if (ret < 0) {
  ------------------
  |  Branch (135:13): [True: 0, False: 47]
  ------------------
  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|     47|        DEBUGMSGTL(("netsnmp_sockaddr_in",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  142|     47|                    "hostname (resolved okay)\n"));
  143|     47|    }
  144|       |
  145|       |    /*
  146|       |     * Finished
  147|       |     */
  148|       |
  149|     47|    DEBUGMSGTL(("netsnmp_sockaddr_in", "return { AF_INET, %s:%hu }\n",
  ------------------
  |  |   66|     47|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     47|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 47]
  |  |  ------------------
  ------------------
  150|     47|                inet_ntoa(addr->sin_addr), ntohs(addr->sin_port)));
  151|     47|    free(ep_str.addr);
  152|     47|    return 1;
  153|     47|}

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

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

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

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

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

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

_netsnmp_udp_sockopt_set:
   69|     47|{
   70|     47|#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|     47|    if (0 == netsnmp_os_prematch("Linux","2.4"))
  ------------------
  |  Branch (76:9): [True: 0, False: 47]
  ------------------
   77|      0|    {
   78|      0|        int             one = 1;
   79|      0|        DEBUGMSGTL(("socket:option", "setting socket option SO_BSDCOMPAT\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
   80|      0|        setsockopt(sock, SOL_SOCKET, SO_BSDCOMPAT, (void *) &one, sizeof(one));
   81|      0|    }
   82|     47|#endif                          /*SO_BSDCOMPAT */
   83|       |    /*
   84|       |     * SO_REUSEADDR will allow multiple apps to open the same port at
   85|       |     * the same time. Only the last one to open the socket will get
   86|       |     * data. Obviously, for an agent, this is a bad thing. There should
   87|       |     * only be one listener.
   88|       |     */
   89|       |#ifdef ALLOW_PORT_HIJACKING
   90|       |#ifdef  SO_REUSEADDR
   91|       |    /*
   92|       |     * Allow the same port to be specified multiple times without failing.
   93|       |     *    (useful for a listener)
   94|       |     */
   95|       |    {
   96|       |        int             one = 1;
   97|       |        DEBUGMSGTL(("socket:option", "setting socket option SO_REUSEADDR\n"));
   98|       |        setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &one, sizeof(one));
   99|       |    }
  100|       |#endif                          /*SO_REUSEADDR */
  101|       |#endif
  102|       |
  103|       |    /*
  104|       |     * Try to set the send and receive buffers to a reasonably large value, so
  105|       |     * that we can send and receive big PDUs (defaults to 8192 bytes (!) on
  106|       |     * Solaris, for instance).  Don't worry too much about errors -- just
  107|       |     * plough on regardless.  
  108|       |     */
  109|     47|    netsnmp_sock_buffer_set(sock, SO_SNDBUF, local, 0);
  110|       |    netsnmp_sock_buffer_set(sock, SO_RCVBUF, local, 0);
  111|     47|}
netsnmp_udpbase_recvfrom:
  143|     46|{
  144|     46|    int r;
  145|     46|#if !defined(WIN32)
  146|     46|    struct iovec iov;
  147|     46|    char cmsg[CMSG_SPACE(cmsg_data_size)];
  148|     46|    struct cmsghdr *cm;
  149|     46|    struct msghdr msg;
  150|       |
  151|     46|    iov.iov_base = buf;
  152|     46|    iov.iov_len = len;
  153|       |
  154|     46|    memset(&msg, 0, sizeof msg);
  155|     46|    msg.msg_name = from;
  156|     46|    msg.msg_namelen = *fromlen;
  157|     46|    msg.msg_iov = &iov;
  158|     46|    msg.msg_iovlen = 1;
  159|     46|    msg.msg_control = &cmsg;
  160|     46|    msg.msg_controllen = sizeof(cmsg);
  161|       |
  162|     46|    r = recvmsg(sock, &msg, MSG_DONTWAIT);
  163|       |#else /* !defined(WIN32) */
  164|       |    WSABUF wsabuf;
  165|       |    char cmsg[WSA_CMSG_SPACE(sizeof(struct in_pktinfo))];
  166|       |    WSACMSGHDR *cm;
  167|       |    WSAMSG msg;
  168|       |    DWORD bytes_received;
  169|       |
  170|       |    wsabuf.buf = buf;
  171|       |    wsabuf.len = len;
  172|       |
  173|       |    msg.name = from;
  174|       |    msg.namelen = *fromlen;
  175|       |    msg.lpBuffers = &wsabuf;
  176|       |    msg.dwBufferCount = 1;
  177|       |    msg.Control.len = sizeof(cmsg);
  178|       |    msg.Control.buf = cmsg;
  179|       |    msg.dwFlags = 0;
  180|       |
  181|       |    if (pfWSARecvMsg) {
  182|       |        r = pfWSARecvMsg(sock, &msg, &bytes_received, NULL, NULL) == 0 ?
  183|       |            bytes_received : -1;
  184|       |        *fromlen = msg.namelen;
  185|       |    } else {
  186|       |        r = recvfrom(sock, buf, len, MSG_DONTWAIT, from, fromlen);
  187|       |    }
  188|       |#endif /* !defined(WIN32) */
  189|       |
  190|     46|    if (r == -1) {
  ------------------
  |  Branch (190:9): [True: 0, False: 46]
  ------------------
  191|      0|        return -1;
  192|      0|    }
  193|       |
  194|     46|    DEBUGMSGTL(("udpbase:recv", "got source addr: %s\n",
  ------------------
  |  |   66|     46|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     46|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 46]
  |  |  ------------------
  ------------------
  195|     46|                inet_ntoa(((struct sockaddr_in *)from)->sin_addr)));
  196|       |
  197|     46|    {
  198|       |        /* Get the local port number for use in diagnostic messages */
  199|     46|        int r2 = getsockname(sock, dstip, dstlen);
  200|     46|        netsnmp_assert(r2 == 0);
  ------------------
  |  |   47|     46|#      define netsnmp_assert(x)  do { \
  |  |   48|     46|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 46, False: 0]
  |  |  ------------------
  |  |   49|     46|                 ; \
  |  |   50|     46|              else \
  |  |   51|     46|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     46|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 46]
  |  |  ------------------
  ------------------
  201|     46|    }
  202|       |
  203|     46|#if !defined(WIN32)
  204|     92|    for (cm = CMSG_FIRSTHDR(&msg); cm != NULL; cm = CMSG_NXTHDR(&msg, cm)) {
  ------------------
  |  Branch (204:15): [True: 46, False: 0]
  |  Branch (204:36): [True: 46, False: 46]
  ------------------
  205|     46|#if defined(HAVE_IP_PKTINFO)
  206|     46|        if (cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_PKTINFO) {
  ------------------
  |  Branch (206:13): [True: 46, False: 0]
  |  Branch (206:41): [True: 46, False: 0]
  ------------------
  207|     46|            struct in_pktinfo* src = (struct in_pktinfo *)CMSG_DATA(cm);
  208|     46|            netsnmp_assert(dstip->sa_family == AF_INET);
  ------------------
  |  |   47|     46|#      define netsnmp_assert(x)  do { \
  |  |   48|     46|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 46, False: 0]
  |  |  ------------------
  |  |   49|     46|                 ; \
  |  |   50|     46|              else \
  |  |   51|     46|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     46|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 46]
  |  |  ------------------
  ------------------
  209|     46|            ((struct sockaddr_in*)dstip)->sin_addr = src->ipi_addr;
  210|     46|            *if_index = src->ipi_ifindex;
  211|     46|            DEBUGMSGTL(("udpbase:recv",
  ------------------
  |  |   66|     46|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     46|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 46]
  |  |  ------------------
  ------------------
  212|     46|                        "got destination (local) addr %s, iface %d\n",
  213|     46|                        inet_ntoa(src->ipi_addr), *if_index));
  214|     46|        }
  215|       |#elif defined(HAVE_IP_RECVDSTADDR)
  216|       |        if (cm->cmsg_level == IPPROTO_IP && cm->cmsg_type == IP_RECVDSTADDR) {
  217|       |            struct in_addr* src = (struct in_addr *)CMSG_DATA(cm);
  218|       |            ((struct sockaddr_in*)dstip)->sin_addr = *src;
  219|       |            DEBUGMSGTL(("netsnmp_udp", "got destination (local) addr %s\n",
  220|       |                        inet_ntoa(*src)));
  221|       |        }
  222|       |#endif
  223|     46|    }
  224|       |#else /* !defined(WIN32) */
  225|       |    for (cm = WSA_CMSG_FIRSTHDR(&msg); cm; cm = WSA_CMSG_NXTHDR(&msg, cm)) {
  226|       |        if (cm->cmsg_level == IPPROTO_IP && cm->cmsg_type == IP_PKTINFO) {
  227|       |            struct in_pktinfo* src = (struct in_pktinfo *)WSA_CMSG_DATA(cm);
  228|       |            netsnmp_assert(dstip->sa_family == AF_INET);
  229|       |            ((struct sockaddr_in*)dstip)->sin_addr = src->ipi_addr;
  230|       |            *if_index = src->ipi_ifindex;
  231|       |            DEBUGMSGTL(("udpbase:recv",
  232|       |                        "got destination (local) addr %s, iface %d\n",
  233|       |                        inet_ntoa(src->ipi_addr), *if_index));
  234|       |        }
  235|       |    }
  236|       |#endif /* !defined(WIN32) */
  237|     46|    return r;
  238|     46|}
netsnmp_udpbase_sendto_unix:
  245|     20|{
  246|     20|    struct iovec iov;
  247|     20|    struct msghdr m = { NULL };
  248|     20|    char          cmsg[CMSG_SPACE(cmsg_data_size)];
  249|     20|    int           rc;
  250|     20|    char          iface[IFNAMSIZ];
  251|     20|    socklen_t     ifacelen = IFNAMSIZ;
  252|       |
  253|     20|    iov.iov_base = NETSNMP_REMOVE_CONST(void *, data);
  ------------------
  |  |   91|     20|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  254|     20|    iov.iov_len  = len;
  255|       |
  256|     20|    {
  257|     20|        struct sockaddr_storage peer;
  258|     20|        socklen_t peer_len = sizeof(peer);
  259|       |
  260|     20|        if (getpeername(sock, (struct sockaddr *)&peer, &peer_len) == 0) {
  ------------------
  |  Branch (260:13): [True: 0, False: 20]
  ------------------
  261|      0|            m.msg_name = NULL;
  262|      0|            m.msg_namelen = 0;
  263|     20|        } else {
  264|     20|            m.msg_name = NETSNMP_REMOVE_CONST(void *, remote);
  ------------------
  |  |   91|     20|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  265|     20|            m.msg_namelen = sizeof(struct sockaddr_in);
  266|     20|            if (errno != ENOTCONN) {
  ------------------
  |  Branch (266:17): [True: 0, False: 20]
  ------------------
  267|      0|                snmp_log(LOG_ERR, "udpbase:sendto: fd %d getpeername failed: %d (%s)\n",
  268|      0|                         sock, errno, strerror(errno));
  269|      0|            }
  270|     20|        }
  271|     20|    }
  272|     20|    m.msg_iov		= &iov;
  273|     20|    m.msg_iovlen	= 1;
  274|     20|    m.msg_flags		= 0;
  275|       |
  276|     20|    if (srcip && srcip->s_addr != INADDR_ANY) {
  ------------------
  |  Branch (276:9): [True: 20, False: 0]
  |  Branch (276:18): [True: 20, False: 0]
  ------------------
  277|     20|        struct cmsghdr *cm;
  278|     20|        struct in_pktinfo ipi;
  279|     20|        int use_sendto = FALSE;
  ------------------
  |  |  125|     20|#define FALSE 0
  ------------------
  280|       |
  281|     20|        memset(cmsg, 0, sizeof(cmsg));
  282|       |
  283|     20|        m.msg_control    = &cmsg;
  284|     20|        m.msg_controllen = sizeof(cmsg);
  285|       |
  286|     20|        cm = CMSG_FIRSTHDR(&m);
  ------------------
  |  Branch (286:14): [True: 20, False: 0]
  ------------------
  287|     20|        cm->cmsg_len = CMSG_LEN(cmsg_data_size);
  288|       |
  289|     20|#if defined(HAVE_IP_PKTINFO)
  290|     20|        cm->cmsg_level = SOL_IP;
  291|     20|        cm->cmsg_type = IP_PKTINFO;
  292|       |
  293|     20|        memset(&ipi, 0, sizeof(ipi));
  294|     20|#ifdef HAVE_SO_BINDTODEVICE
  295|       |        /*
  296|       |         * For asymmetric multihomed users, we only set ifindex to 0 to
  297|       |         * let kernel handle return if there was no iface bound to the
  298|       |         * socket.
  299|       |         */
  300|     20|        if (getsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, iface,
  ------------------
  |  Branch (300:13): [True: 0, False: 20]
  ------------------
  301|     20|                       &ifacelen) != 0)  {
  302|      0|            DEBUGMSGTL(("udpbase:sendto",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  303|      0|                        "getsockopt SO_BINDTODEVICE failed: %s\n",
  304|      0|                        strerror(errno)));
  305|     20|        } else if (ifacelen == 0) {
  ------------------
  |  Branch (305:20): [True: 20, False: 0]
  ------------------
  306|     20|            DEBUGMSGTL(("udpbase:sendto",
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
  307|     20|                        "sendto: SO_BINDTODEVICE not set\n"));
  308|     20|        } else {
  309|      0|            DEBUGMSGTL(("udpbase:sendto",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %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|                        "sendto: SO_BINDTODEVICE dev=%s using ifindex=%d\n",
  311|      0|                        iface, if_index));
  312|      0|            use_sendto = TRUE;
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
  313|      0|        }
  314|     20|#endif /* HAVE_SO_BINDTODEVICE */
  315|       |
  316|     20|#ifdef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST
  317|     20|        DEBUGMSGTL(("udpbase:sendto", "sending from %s\n",
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
  318|     20|                    inet_ntoa(*srcip)));
  319|     20|        ipi.ipi_spec_dst.s_addr = srcip->s_addr;
  320|       |#else
  321|       |        DEBUGMSGTL(("udpbase:sendto", "ignoring from address %s\n",
  322|       |                    inet_ntoa(*srcip)));
  323|       |#endif
  324|     20|        memcpy(CMSG_DATA(cm), &ipi, sizeof(ipi));
  325|       |
  326|       |        /*
  327|       |         * For Linux and VRF, use sendto() instead of sendmsg(). Do not pass a
  328|       |         * cmsg with IP_PKTINFO set because that would override the bind to
  329|       |         * VRF which is set by 'vrf exec' command. That would break VRF.
  330|       |         */
  331|     20|        if (use_sendto)
  ------------------
  |  Branch (331:13): [True: 0, False: 20]
  ------------------
  332|      0|            rc = sendto(sock, data, len, MSG_DONTWAIT, remote,
  333|      0|                        sizeof(struct sockaddr));
  334|     20|        else
  335|     20|            rc = sendmsg(sock, &m, MSG_DONTWAIT);
  336|     20|        if (rc >= 0 || (errno != EINVAL && errno != ENETUNREACH))
  ------------------
  |  Branch (336:13): [True: 20, False: 0]
  |  Branch (336:25): [True: 0, False: 0]
  |  Branch (336:44): [True: 0, False: 0]
  ------------------
  337|     20|            return rc;
  338|       |
  339|       |        /*
  340|       |         * The error might be caused by broadcast srcip (i.e. we're responding
  341|       |         * to a broadcast request) - sendmsg does not like it. Try to resend it
  342|       |         * using the interface on which it was received
  343|       |         */
  344|       |
  345|      0|        DEBUGMSGTL(("udpbase:sendto", "re-sending on iface %d\n", if_index));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  346|       |
  347|      0|        {
  348|      0|            struct in_pktinfo ipi;
  349|       |
  350|      0|            memset(&ipi, 0, sizeof(ipi));
  351|      0|            ipi.ipi_ifindex = if_index;
  352|      0|#ifdef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST
  353|      0|            ipi.ipi_spec_dst.s_addr = INADDR_ANY;
  354|      0|#endif
  355|      0|            memcpy(CMSG_DATA(cm), &ipi, sizeof(ipi));
  356|      0|        }
  357|       |#elif defined(HAVE_IP_SENDSRCADDR)
  358|       |        cm->cmsg_level = IPPROTO_IP;
  359|       |        cm->cmsg_type = IP_SENDSRCADDR;
  360|       |        memcpy((struct in_addr *)CMSG_DATA(cm), srcip, sizeof(struct in_addr));
  361|       |#endif
  362|      0|        rc = sendmsg(sock, &m, MSG_DONTWAIT);
  363|      0|        if (rc >= 0 || errno != EINVAL)
  ------------------
  |  Branch (363:13): [True: 0, False: 0]
  |  Branch (363:24): [True: 0, False: 0]
  ------------------
  364|      0|            return rc;
  365|       |
  366|      0|        DEBUGMSGTL(("udpbase:sendto", "re-sending without source address\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]
  |  |  ------------------
  ------------------
  367|      0|        m.msg_control = NULL;
  368|      0|        m.msg_controllen = 0;
  369|      0|    }
  370|       |
  371|      0|    rc = sendmsg(sock, &m, MSG_DONTWAIT);
  372|      0|    if (rc < 0) {
  ------------------
  |  Branch (372:9): [True: 0, False: 0]
  ------------------
  373|      0|        snmp_log(LOG_ERR, "udpbase:sendto: sendmsg fd %d err %d (\"%s\") msg_name=%p\n",
  374|      0|                 sock, errno, strerror(errno), m.msg_name);
  375|      0|    }
  376|      0|    return rc;
  377|     20|}
netsnmp_udpbase_sendto:
  436|     20|{
  437|     20|#if !defined(WIN32)
  438|     20|    return netsnmp_udpbase_sendto_unix(sock, srcip, if_index, remote, data, len);
  439|       |#else /* !defined(WIN32) */
  440|       |    return netsnmp_udpbase_sendto_win32(sock, srcip, if_index, remote, data, len);
  441|       |#endif /* !defined(WIN32) */
  442|     20|}
netsnmp_udpbase_recv:
  454|     46|{
  455|     46|    int             rc = -1;
  456|     46|    socklen_t       fromlen = sizeof(netsnmp_sockaddr_storage);
  457|     46|    netsnmp_indexed_addr_pair *addr_pair = NULL;
  458|     46|    struct sockaddr *from;
  459|       |
  460|     46|    if (t && NETSNMP_IS_VALID_SOCKET(t->sock)) {
  ------------------
  |  |   44|     46|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  |  |  ------------------
  |  |  |  Branch (44:40): [True: 46, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (460:9): [True: 46, False: 0]
  ------------------
  461|     46|        addr_pair = SNMP_MALLOC_TYPEDEF(netsnmp_indexed_addr_pair);
  ------------------
  |  |   73|     46|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  462|     46|        if (addr_pair == NULL) {
  ------------------
  |  Branch (462:13): [True: 0, False: 46]
  ------------------
  463|      0|            *opaque = NULL;
  464|      0|            *olength = 0;
  465|      0|            return -1;
  466|      0|        } else
  467|     46|            from = &addr_pair->remote_addr.sa;
  468|       |
  469|     92|	while (rc < 0) {
  ------------------
  |  Branch (469:9): [True: 46, False: 46]
  ------------------
  470|     46|#ifdef netsnmp_udpbase_recvfrom_sendto_defined
  471|     46|            socklen_t local_addr_len = sizeof(addr_pair->local_addr);
  472|     46|            rc = netsnmp_udp_recvfrom(t->sock, buf, size, from, &fromlen,
  473|     46|                                      &addr_pair->local_addr.sa,
  474|     46|                                      &local_addr_len, &(addr_pair->if_index));
  475|       |#else
  476|       |            rc = recvfrom(t->sock, buf, size, MSG_DONTWAIT, from, &fromlen);
  477|       |#endif /* netsnmp_udpbase_recvfrom_sendto_defined */
  478|     46|	    if (rc < 0 && errno != EINTR) {
  ------------------
  |  Branch (478:10): [True: 0, False: 46]
  |  Branch (478:20): [True: 0, False: 0]
  ------------------
  479|      0|		break;
  480|      0|	    }
  481|     46|	}
  482|       |
  483|     46|        if (rc >= 0) {
  ------------------
  |  Branch (483:13): [True: 46, False: 0]
  ------------------
  484|     46|            DEBUGIF("netsnmp_udp") {
  ------------------
  |  |  145|     46|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|     92|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  485|      0|                char *str = netsnmp_udp_fmtaddr(
  486|      0|                    NULL, addr_pair, sizeof(netsnmp_indexed_addr_pair));
  487|      0|                DEBUGMSGTL(("netsnmp_udp",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  488|      0|                            "recvfrom fd %" NETSNMP_FMT_SKT " got %d bytes (from %s)\n",
  489|      0|                            t->sock, rc, str));
  490|      0|                free(str);
  491|      0|            }
  492|     46|        } else {
  493|      0|            DEBUGMSGTL(("netsnmp_udp", "recvfrom fd %" NETSNMP_FMT_SKT " err %d (\"%s\")\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  494|      0|                        t->sock, errno, strerror(errno)));
  495|      0|        }
  496|     46|        *opaque = (void *)addr_pair;
  497|     46|        *olength = sizeof(netsnmp_indexed_addr_pair);
  498|     46|    }
  499|     46|    return rc;
  500|     46|}
netsnmp_udpbase_send:
  507|     20|{
  508|     20|    int rc = -1;
  509|     20|    const netsnmp_indexed_addr_pair *addr_pair = NULL;
  510|     20|    const struct sockaddr *to = NULL;
  511|       |
  512|     20|    if (opaque && *opaque && olength) {
  ------------------
  |  Branch (512:9): [True: 20, False: 0]
  |  Branch (512:19): [True: 20, False: 0]
  |  Branch (512:30): [True: 20, False: 0]
  ------------------
  513|     20|        if (*olength == sizeof(netsnmp_indexed_addr_pair)) {
  ------------------
  |  Branch (513:13): [True: 20, False: 0]
  ------------------
  514|     20|            addr_pair = *opaque;
  515|     20|            to = &addr_pair->remote_addr.sa;
  516|     20|        } else if (*olength == sizeof(struct sockaddr_in)) {
  ------------------
  |  Branch (516:20): [True: 0, False: 0]
  ------------------
  517|      0|            to = *opaque;
  518|      0|        } else {
  519|      0|            snmp_log(LOG_ERR, "unknown addr type of size %d\n", *olength);
  520|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  521|      0|        }
  522|     20|    } else if (t && t->data &&
  ------------------
  |  Branch (522:16): [True: 0, False: 0]
  |  Branch (522:21): [True: 0, False: 0]
  ------------------
  523|      0|               t->data_length == sizeof(netsnmp_indexed_addr_pair)) {
  ------------------
  |  Branch (523:16): [True: 0, False: 0]
  ------------------
  524|      0|        addr_pair = t->data;
  525|      0|        to = &addr_pair->remote_addr.sa;
  526|      0|    } else {
  527|      0|        int len = -1;
  528|       |
  529|      0|        if (t != NULL && t->data != NULL)
  ------------------
  |  Branch (529:13): [True: 0, False: 0]
  |  Branch (529:26): [True: 0, False: 0]
  ------------------
  530|      0|            len = t->data_length;
  531|      0|        snmp_log(LOG_ERR, "unknown addr type of size %d\n", len);
  532|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  533|      0|    }
  534|       |
  535|     20|    if (to && t && NETSNMP_IS_VALID_SOCKET(t->sock)) {
  ------------------
  |  |   44|     20|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  |  |  ------------------
  |  |  |  Branch (44:40): [True: 20, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (535:9): [True: 20, False: 0]
  |  Branch (535:15): [True: 20, False: 0]
  ------------------
  536|     20|        DEBUGIF("netsnmp_udp") {
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  537|      0|            char *str = netsnmp_udp_fmtaddr(NULL,
  538|      0|                                            addr_pair ? (const void *)addr_pair : (const void *)to,
  ------------------
  |  Branch (538:45): [True: 0, False: 0]
  ------------------
  539|      0|                                            addr_pair ? sizeof(netsnmp_indexed_addr_pair) : sizeof(struct sockaddr_in));
  ------------------
  |  Branch (539:45): [True: 0, False: 0]
  ------------------
  540|      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]
  |  |  ------------------
  ------------------
  541|      0|                        "send %d bytes to %s on fd %" NETSNMP_FMT_SKT "\n",
  542|      0|                        size, str, t->sock));
  543|      0|            free(str);
  544|      0|        }
  545|     40|	while (rc < 0) {
  ------------------
  |  Branch (545:9): [True: 20, False: 20]
  ------------------
  546|     20|#ifdef netsnmp_udpbase_recvfrom_sendto_defined
  547|     20|            rc = netsnmp_udp_sendto(t->sock,
  548|     20|                    addr_pair ? &(addr_pair->local_addr.sin.sin_addr) : NULL,
  ------------------
  |  Branch (548:21): [True: 20, False: 0]
  ------------------
  549|     20|                    addr_pair ? addr_pair->if_index : 0, to, buf, size);
  ------------------
  |  Branch (549:21): [True: 20, False: 0]
  ------------------
  550|       |#else
  551|       |            {
  552|       |                struct sockaddr_storage peer;
  553|       |                socklen_t peer_len = sizeof(peer);
  554|       |
  555|       |                if (getpeername(t->sock, (struct sockaddr *)&peer, &peer_len) == 0) {
  556|       |                    rc = sendto(t->sock, buf, size, 0, NULL, 0);
  557|       |                } else {
  558|       |                    rc = sendto(t->sock, buf, size, 0, to, sizeof(struct sockaddr));
  559|       |                }
  560|       |            }
  561|       |#endif /* netsnmp_udpbase_recvfrom_sendto_defined */
  562|     20|	    if (rc < 0 && errno != EINTR) {
  ------------------
  |  Branch (562:10): [True: 0, False: 20]
  |  Branch (562:20): [True: 0, False: 0]
  ------------------
  563|      0|                snmp_log(LOG_ERR, "udpbase:send: sendto fd %" NETSNMP_FMT_SKT " err %d (\"%s\")\n",
  564|      0|                         t->sock, errno, strerror(errno));
  565|      0|                DEBUGMSGTL(("netsnmp_udp", "sendto error, rc %d (errno %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]
  |  |  ------------------
  ------------------
  566|      0|                            rc, errno));
  567|      0|		break;
  568|      0|	    }
  569|     20|	}
  570|     20|    }
  571|     20|    return rc;
  572|     20|}

netsnmp_udp_recvfrom:
  159|     46|{
  160|       |    /** udpipv4 just calls udpbase. should we skip directly to there? */
  161|     46|    return netsnmp_udpipv4_recvfrom(sock, buf, len, from, fromlen, dstip, dstlen,
  162|     46|                                    if_index);
  163|     46|}
netsnmp_udp_sendto:
  168|     20|{
  169|       |    /** udpipv4 just calls udpbase. should we skip directly to there? */
  170|     20|    return netsnmp_udpipv4_sendto(sock, srcip, if_index, remote, data, len);
  171|     20|}
netsnmp_udp_create_tspec:
  687|     47|{
  688|     47|    netsnmp_transport *t = netsnmp_udpipv4base_tspec_transport(tspec);
  689|     47|    if (NULL != t) {
  ------------------
  |  Branch (689:9): [True: 47, False: 0]
  ------------------
  690|     47|        netsnmp_udp_transport_base(t);
  691|     47|    }
  692|     47|    return t;
  693|       |
  694|     47|}
netsnmp_udp_ctor:
  710|     47|{
  711|     47|    udpDomain.name = netsnmpUDPDomain;
  712|     47|    udpDomain.name_length = netsnmpUDPDomain_len;
  713|     47|    udpDomain.prefix = calloc(2, sizeof(char *));
  714|     47|    if (!udpDomain.prefix) {
  ------------------
  |  Branch (714:9): [True: 0, False: 47]
  ------------------
  715|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  716|      0|        return;
  717|      0|    }
  718|     47|    udpDomain.prefix[0] = "udp";
  719|       |
  720|     47|    udpDomain.f_create_from_tstring_new = netsnmp_udp_create_tstring;
  721|     47|    udpDomain.f_create_from_tspec       = netsnmp_udp_create_tspec;
  722|     47|    udpDomain.f_create_from_ostring     = netsnmp_udp_create_ostring;
  723|       |
  724|     47|    netsnmp_tdomain_register(&udpDomain);
  725|     47|}
snmpUDPDomain.c:netsnmp_udp_transport_base:
  180|     47|{
  181|     47|    if (NULL == t) {
  ------------------
  |  Branch (181:9): [True: 0, False: 47]
  ------------------
  182|      0|        return NULL;
  183|      0|    }
  184|       |
  185|       |    /*
  186|       |     * Set Domain
  187|       |     */
  188|       |
  189|     47|    t->domain = netsnmpUDPDomain;
  190|     47|    t->domain_length = netsnmpUDPDomain_len;
  191|       |
  192|       |    /*
  193|       |     * 16-bit length field, 8 byte UDP header, 20 byte IPv4 header  
  194|       |     */
  195|       |
  196|     47|    t->msgMaxSize = 0xffff - 8 - 20;
  197|     47|    t->f_recv     = netsnmp_udpbase_recv;
  198|     47|    t->f_send     = netsnmp_udpbase_send;
  199|     47|    t->f_close    = netsnmp_socketbase_close;
  200|     47|    t->f_accept   = NULL;
  201|     47|    t->f_setup_session = netsnmp_ipbase_session_init;
  202|     47|    t->f_fmtaddr  = netsnmp_udp_fmtaddr;
  203|     47|    t->f_get_taddr = netsnmp_ipv4_get_taddr;
  204|       |
  205|     47|    return t;
  206|     47|}

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

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

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

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

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

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

