summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
diff options
context:
space:
mode:
authorsyrinx <syrinx@FreeBSD.org>2012-01-10 15:29:03 +0000
committersyrinx <syrinx@FreeBSD.org>2012-01-10 15:29:03 +0000
commitd4a4d0726568facb84d6fd9be8da8d94aaf01799 (patch)
tree7139b337e38d7cc392ee06748d7bab1c6d86647c /usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
parent0730e7f5bed7d8a8c749f0b81c900c9dc3f0b5c9 (diff)
downloadFreeBSD-src-d4a4d0726568facb84d6fd9be8da8d94aaf01799.zip
FreeBSD-src-d4a4d0726568facb84d6fd9be8da8d94aaf01799.tar.gz
Implement an option to execute SNMP walks using GETBULK requests in bsnmpwalk(1)
retrieving multiple values with a Single PDU. Reviewed by: philip@ Tested by: tsanand129 (at) gmail (dot) com
Diffstat (limited to 'usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c')
-rwxr-xr-xusr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
index 53deff7..52aa1a9 100755
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
@@ -132,6 +132,7 @@ snmptool_init(struct snmp_toolinfo *snmptoolctx)
snmptoolctx->flags = SNMP_PDU_GET; /* XXX */
SLIST_INIT(&snmptoolctx->filelist);
snmp_client_init(&snmp_client);
+ SET_MAXREP(snmptoolctx, SNMP_MAX_REPETITIONS);
if (add_filename(snmptoolctx, bsnmpd_defs, &IsoOrgDod_OID, 0) < 0)
warnx("Error adding file %s to list", bsnmpd_defs);
@@ -2039,14 +2040,20 @@ snmp_output_err_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu)
}
int32_t
-snmp_output_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu)
+snmp_output_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu,
+ struct asn_oid *root)
{
int32_t error;
char p[ASN_OIDSTRLEN];
uint32_t i;
struct snmp_object object;
- for (i = 0, error = 0; i < pdu->nbindings; i++) {
+ i = error = 0;
+ while (i < pdu->nbindings) {
+ if (root != NULL && !(asn_is_suboid(root,
+ &(pdu->bindings[i].var))))
+ break;
+
if (GET_OUTPUT(snmptoolctx) != OUTPUT_QUIET) {
if (!ISSET_NUMERIC(snmptoolctx) &&
(snmp_fill_object(snmptoolctx, &object,
@@ -2058,9 +2065,13 @@ snmp_output_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu)
}
}
error |= snmp_output_numval(snmptoolctx, &(pdu->bindings[i]), object.info);
+ i++;
}
- return (error);
+ if (error)
+ return (-1);
+
+ return (i);
}
void
OpenPOWER on IntegriCloud