[Midnightbsd-cvs] src [10991] trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c: update

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Jun 15 16:40:35 EDT 2018


Revision: 10991
          http://svnweb.midnightbsd.org/src/?rev=10991
Author:   laffer1
Date:     2018-06-15 16:40:34 -0400 (Fri, 15 Jun 2018)
Log Message:
-----------
update

Modified Paths:
--------------
    trunk/usr.sbin/bsnmpd/tools/bsnmptools/Makefile
    trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
    trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c

Property Changed:
----------------
    trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1

Modified: trunk/usr.sbin/bsnmpd/tools/bsnmptools/Makefile
===================================================================
--- trunk/usr.sbin/bsnmpd/tools/bsnmptools/Makefile	2018-06-15 20:40:12 UTC (rev 10990)
+++ trunk/usr.sbin/bsnmpd/tools/bsnmptools/Makefile	2018-06-15 20:40:34 UTC (rev 10991)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/bsnmpd/tools/bsnmptools/Makefile 216323 2010-12-09 12:25:45Z syrinx $
 # Author: Shteryana Shopova <syrinx at FreeBSD.org>
 
 .include <bsd.own.mk>

Modified: trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
===================================================================
--- trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1	2018-06-15 20:40:12 UTC (rev 10990)
+++ trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1	2018-06-15 20:40:34 UTC (rev 10991)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"
 .\" Copyright (c) 2010 The FreeBSD Foundation
 .\" All rights reserved.
@@ -31,7 +32,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1 262783 2014-03-05 13:25:01Z brueffer $
 .\"
 .Dd January 10, 2012
 .Dt BSNMPGET 1
@@ -106,18 +107,18 @@
 .Pp
 Depending on the options
 .Nm bsnmpget
-constructs either a SMNP GetRequest, GetNextRequest
+constructs either a SNMP GetRequest, GetNextRequest
 or a GetBulkRequest packet, fills in the object identifiers (OIDs) of the
-objects whose values will be retrived, waits for a response and prints it if
+objects whose values will be retrieved, waits for a response and prints it if
 received successfully.
 .Pp
 .Nm Bsnmpwalk
-queries an agent with ether SMNP GetNextRequest or GetBulkRequest packets,
+queries an agent with ether SNMP GetNextRequest or GetBulkRequest packets,
 asking for values of OID instances that are a part of the object subtree
 rooted at the provided OIDs.
 .Pp
 .Nm Bsnmpset
-constructs a SMNP SetRequest packet, fills in the OIDs (object identifiers),
+constructs a SNMP SetRequest packet, fills in the OIDs (object identifiers),
 syntaxes and values of the objects whose values are to be set and waits for a
 response from server.
 .Sh OPTIONS
@@ -151,7 +152,8 @@
 The context name. Default is "" (empty).
 .It Cm context-engine=engine-id
 The SNMP Engine ID of the context to query with SNMPv3 PDUs, represented as
-binary octet string. By default, this is set to the Engine ID of the SNMP agent.
+binary octet string.
+By default, this is set to the Engine ID of the SNMP agent.
 .El
 .It Fl D
 Perform SNMP USM Engine Discovery, rather than sending a request for the value
@@ -177,7 +179,8 @@
 .Xr gensnmpdef 1
 when producing the MIB description file.
 The default value is .iso(1).org(3).dod(6) which is what should have been
-used for all the files installed under /usr/share/snmp/defs.
+used for all the files installed under
+.Pa /usr/share/snmp/defs .
 Use this only if you generated your own files, providing a
 .Fl c
 option to
@@ -198,7 +201,8 @@
 example using quotes.
 .It Fl i Ar filelist
 List of MIB description files produced by
-.Xr gensnmpdef 1 which
+.Xr gensnmpdef 1
+which
 .Nm bsnmpget ,
 .Nm bsnmpwalk
 or
@@ -207,12 +211,13 @@
 Multiple files can be provided either giving this option multiple times
 or a comma separated list of file names.
 If a filename begins with a letter the default directory,
-/usr/share/snmp/defs,
+.Pa /usr/share/snmp/defs ,
 will be searched.
 .It Fl K
 Calculate and display the localized authentication and privacy keys
-corresponding to a plain text password. The password is obtain via the
-environment. Additionally, if one or more OIDs are specified, the calculated
+corresponding to a plain text password.
+The password is obtained via the environment.
+Additionally, if one or more OIDs are specified, the calculated
 keys are used when processing the SNMPv3 requests.
 .It Fl l Ar filename
 The path of the posix local (unix domain) socket if local
@@ -242,9 +247,9 @@
 Privacy options to use with SNMPv3 PDUs
 .Bl -tag -width \&
 .It Cm proto=[aes|des]
-The protocol to use when encypting/decrypting SNMPv3 PDU data.
+The protocol to use when encrypting/decrypting SNMPv3 PDU data.
 .It Cm key=privkey
-A binary localized privacy key to use when encypting/decrypting SNMPv3 PDU data.
+A binary localized privacy key to use when encrypting/decrypting SNMPv3 PDU data.
 .El
 .Pp
 By default plain text SNMPv3 PDUs are sent.
@@ -259,7 +264,7 @@
 and getnext for
 .Nm bsnmpwalk .
 Getbulk allows executing the so called SNMP "bulkwalks" allowing the values of
-multiple columns to be retrived in a single PDU by
+multiple columns to be retrieved in a single PDU by
 .Nm bsnmpwalk .
 .It Fl r Ar retries
 Number of resends of request packets before giving up if the agent does
@@ -267,7 +272,7 @@
 Default is 3.
 .It Fl s Ar [trans::] Ns Ar [community@] Ns Ar [server] Ns Ar [:port]
 Each of the server specification components is optional but at least one
-has to be provided if
+has to be provided if the
 .Ar s
 option is used.
 The server specification is constructed in the following manner:
@@ -274,7 +279,7 @@
 .Bl -tag -width \&
 .It Cm trans::
 Transport type may be one of udp, stream or dgram.
-If this option is not provided an udp inet/inet6 socket will be used, which
+If this option is not provided an UDP inet/inet6 socket will be used, which
 is the most common.
 Stream stands for a posix local stream socket and a posix local datagram
 socket will be used if dgram is specified.
@@ -317,11 +322,13 @@
 If any of the above is not specified, SNMP USM Engine Discovery is attempted.
 This is also the default behavior.
 .It Cm name=username
-The USM user name to include in the SNMPv3 PDUs. By default, the user name is
-obtain via the environment
+The USM user name to include in the SNMPv3 PDUs.
+By default, the user name is
+obtained via the environment.
 .El
 .It Fl v Ar version
-The SNMP protocol version to use when sending requests. SNMP versions 1, 2 and
+The SNMP protocol version to use when sending requests.
+SNMP versions 1, 2 and
 3 are supported.
 If no version option is provided
 .Nm bsnmpget ,
@@ -330,9 +337,9 @@
 .Nm bsnmpset
 will use version 2.
 Note that GetBulkRequest-PDUs were introduced in SNMPv2 thus setting the
-version to 1 is incompatiable with sending a GetBulk PDU.
+version to 1 is incompatible with sending a GetBulk PDU.
 .It OID
-The object identifier whose value to retrive.
+The object identifier whose value to retrieve.
 At least one OID should be provided for
 .Nm bsnmpget
 to be able to send a request.
@@ -340,7 +347,7 @@
 For
 .Nm bsnmpwalk
 this is the root object identifier of the subtree whose values are to be
-retrived.
+retrieved.
 If no OID is provided
 .Nm bsnmpwalk
 will walk the mib2 subtree rooted
@@ -355,7 +362,7 @@
 .It ifRcvAddressStatus.2.6.255.255.255.255.255.255
 .It ifRcvAddressType[2,ff:ff:ff:ff:ff:ff]
 .It ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]
-(requires
+(requires the
 .Fl o Ar verbose
 option)
 .El
@@ -373,14 +380,14 @@
 .It Cm OID
 OID may be input as a string, a string followed by a random number of integers
 (suboids) separated by dots, a sequence of integers separated by dots - that is
-if
+if the
 .Ar n
-options is used - and in such case a syntax is required for every value,
+option is used - and in such case a syntax is required for every value,
 or a string followed by square brackets (used to denote an entry's indexes) and
 corresponding indexes.
-Any of formats used to print a single variable by
-.Nm bsnmpset is
-valid for inpit OID as well:
+Any of the formats used to print a single variable by
+.Nm bsnmpset
+is valid as input OID as well:
 .Bl -tag -width \&
 .It 1.3.6.1.2.1.25.1.1.0=TimeTicks:537615486
 .It sysLocation=OctetString:"@ Home" (with Fl o Ar verbose No option)
@@ -389,17 +396,17 @@
 .It ifPhysAddress.1="00:02:b3:1d:1c:a3"
 .It ifRcvAddressStatus.1.6.255.255.255.255.255.255=1
 .It "ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]=Integer:1"
-(with
+(with the
 .Fl o Ar verbose
 option)
 .El
 .It Cm syntax
-where syntax string is one of:
+where the syntax string is one of:
 Integer, OctetString, OID, IpAddress, Counter32, Gauge, TimeTicks, Counter64.
 .It Cm value
 The value to be set - IP address in form of u.u.u.u - for example
 1.3.1.6.1.2.0=IpAddress:192.168.0.1, strings require inverted-commas if they
-contain any special characters or spaces, all other numeric types don't.
+contain any special characters or spaces, all other numeric types do not.
 .El
 .El
 .Sh ENVIRONMENT
@@ -417,8 +424,9 @@
 Specifies a default SNMP USM user name.
 .It Ev SNMPPASSWD
 Specifies the SNMP USM plain text password to use when calculating localized
-authentication and privacy keys. If this variable exists in the environment,
-SMNPv3 is the default version to use for outgoing requests.
+authentication and privacy keys.
+If this variable exists in the environment,
+SNMPv3 is the default version to use for outgoing requests.
 .El
 .Sh SEE ALSO
 .Xr gensnmpdef 1


Property changes on: trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
===================================================================
--- trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c	2018-06-15 20:40:12 UTC (rev 10990)
+++ trunk/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c	2018-06-15 20:40:34 UTC (rev 10991)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2006 The FreeBSD Project
  * All rights reserved.
@@ -29,7 +30,7 @@
  * Bsnmpget and bsnmpwalk are simple tools for querying SNMP agents,
  * bsnmpset can be used to set MIB objects in an agent.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c 312050 2017-01-13 08:59:22Z ngie $
  */
 
 #include <sys/queue.h>
@@ -76,8 +77,9 @@
 	    (program == BSNMPWALK) ? "[-dhnK]" :
 	    (program == BSNMPSET) ? "[-adehnK]" :
 	    "",
-	(program == BSNMPGET) ? " [-M max-repetitions] [-N non-repeaters]" : "",
-	(program == BSNMPGET) ? "[-p pdu] " : "",
+	(program == BSNMPGET || program == BSNMPWALK) ?
+	" [-M max-repetitions] [-N non-repeaters]" : "",
+	(program == BSNMPGET || program == BSNMPWALK) ? "[-p pdu] " : "",
 	(program == BSNMPGET) ? " OID [OID ...]" :
 	    (program == BSNMPWALK || program == BSNMPSET) ? " [OID ...]" :
 	    ""
@@ -150,7 +152,7 @@
 
 	switch (program) {
 		case BSNMPWALK:
-			opts = "dhnKA:b:C:I:i:l:o:P:r:s:t:U:v:";
+			opts = "dhnKA:b:C:I:i:l:M:N:o:P:p:r:s:t:U:v:";
 			break;
 		case BSNMPGET:
 			opts = "aDdehnKA:b:C:I:i:l:M:N:o:P:p:r:s:t:U:v:";
@@ -248,9 +250,9 @@
 
 /*
  * Read user input OID - one of following formats:
- * 1) 1.2.1.1.2.1.0 - that is if option numeric was giveni;
+ * 1) 1.2.1.1.2.1.0 - that is if option numeric was given;
  * 2) string - in such case append .0 to the asn_oid subs;
- * 3) string.1 - no additional proccessing required in such case.
+ * 3) string.1 - no additional processing required in such case.
  */
 static char *
 snmptools_parse_stroid(struct snmp_toolinfo *snmptoolctx,
@@ -393,19 +395,22 @@
 			    GET_NONREP(snmptoolctx));
 
 		if (snmp_dialog(&req, &resp) == -1) {
-			warnx("Snmp dialog - %s", strerror(errno));
+			warn("Snmp dialog");
 			break;
 		}
 
 		if (snmp_parse_resp(&resp, &req) >= 0) {
-			snmp_output_resp(snmptoolctx, &resp);
+			snmp_output_resp(snmptoolctx, &resp, NULL);
+			snmp_pdu_free(&resp);
 			break;
 		}
 
 		snmp_output_err_resp(snmptoolctx, &resp);
 		if (GET_PDUTYPE(snmptoolctx) == SNMP_PDU_GETBULK ||
-		    !ISSET_RETRY(snmptoolctx))
+		    !ISSET_RETRY(snmptoolctx)) {
+			snmp_pdu_free(&resp);
 			break;
+		}
 
 		/*
 		 * Loop through the object list and set object->error to the
@@ -413,8 +418,10 @@
 		 */
 		if (snmp_object_seterror(snmptoolctx,
 		    &(resp.bindings[resp.error_index - 1]),
-		    resp.error_status) <= 0)
+		    resp.error_status) <= 0) {
+			snmp_pdu_free(&resp);
 			break;
+		}
 
 		fprintf(stderr, "Retrying...\n");
 		snmp_pdu_free(&resp);
@@ -421,7 +428,7 @@
 		snmp_pdu_create(&req, GET_PDUTYPE(snmptoolctx));
 	}
 
-	snmp_pdu_free(&resp);
+	snmp_pdu_free(&req);
 
 	return (0);
 }
@@ -458,11 +465,17 @@
 snmptool_walk(struct snmp_toolinfo *snmptoolctx)
 {
 	struct snmp_pdu req, resp;
-	struct asn_oid root;	/* Keep the inital oid. */
+	struct asn_oid root;	/* Keep the initial oid. */
 	int32_t outputs, rc;
+	uint32_t op;
 
-	snmp_pdu_create(&req, SNMP_PDU_GETNEXT);
+	if (GET_PDUTYPE(snmptoolctx) == SNMP_PDU_GETBULK)
+		op = SNMP_PDU_GETBULK;
+	else
+		op = SNMP_PDU_GETNEXT;
 
+	snmp_pdu_create(&req, op);
+
 	while ((rc = snmp_pdu_add_bindings(snmptoolctx, NULL,
 	    snmptool_add_vbind, &req, 1)) > 0) {
 
@@ -470,6 +483,10 @@
 		memset(&root, 0, sizeof(struct asn_oid));
 		asn_append_oid(&root, &(req.bindings[0].var));
 
+		if (op == SNMP_PDU_GETBULK)
+			snmpget_fix_getbulk(&req, GET_MAXREP(snmptoolctx),
+			    GET_NONREP(snmptoolctx));
+
 		outputs = 0;
 		while (snmp_dialog(&req, &resp) >= 0) {
 			if ((snmp_parse_resp(&resp, &req)) < 0) {
@@ -479,21 +496,26 @@
 				break;
 			}
 
-			if (!(asn_is_suboid(&root, &(resp.bindings[0].var)))) {
+			rc = snmp_output_resp(snmptoolctx, &resp, &root);
+			if (rc < 0) {
 				snmp_pdu_free(&resp);
+				outputs = -1;
 				break;
 			}
 
-			if (snmp_output_resp(snmptoolctx, &resp)!= 0) {
+			outputs += rc;
+
+			if ((u_int)rc < resp.nbindings) {
 				snmp_pdu_free(&resp);
-				outputs = -1;
 				break;
 			}
-			outputs++;
+
+			snmpwalk_nextpdu_create(op,
+			    &(resp.bindings[resp.nbindings - 1].var), &req);
+			if (op == SNMP_PDU_GETBULK)
+				snmpget_fix_getbulk(&req, GET_MAXREP(snmptoolctx),
+				    GET_NONREP(snmptoolctx));
 			snmp_pdu_free(&resp);
-
-			snmpwalk_nextpdu_create(SNMP_PDU_GETNEXT,
-			    &(resp.bindings[0].var), &req);
 		}
 
 		/* Just in case our root was a leaf. */
@@ -500,14 +522,14 @@
 		if (outputs == 0) {
 			snmpwalk_nextpdu_create(SNMP_PDU_GET, &root, &req);
 			if (snmp_dialog(&req, &resp) == SNMP_CODE_OK) {
-				if (snmp_parse_resp(&resp,&req) < 0)
+				if (snmp_parse_resp(&resp, &req) < 0)
 					snmp_output_err_resp(snmptoolctx, &resp);
 				else
-					snmp_output_resp(snmptoolctx, &(resp));
-
+					snmp_output_resp(snmptoolctx, &resp,
+					    NULL);
 				snmp_pdu_free(&resp);
 			} else
-				warnx("Snmp dialog - %s", strerror(errno));
+				warn("Snmp dialog");
 		}
 
 		if (snmp_object_remove(snmptoolctx, &root) < 0) {
@@ -515,9 +537,12 @@
 			break;
 		}
 
-		snmp_pdu_create(&req, SNMP_PDU_GETNEXT);
+		snmp_pdu_free(&req);
+		snmp_pdu_create(&req, op);
 	}
 
+	snmp_pdu_free(&req);
+
 	if (rc == 0)
 		return (0);
 	else
@@ -540,8 +565,7 @@
 		errno = 0;
 		suboid = strtoul(val, &endptr, 10);
 		if (errno != 0) {
-			warnx("Value %s not supported - %s", val,
-			    strerror(errno));
+			warn("Value %s not supported", val);
 			errno = saved_errno;
 			return (-1);
 		}
@@ -589,9 +613,9 @@
 static int32_t
 parse_ip(struct snmp_value * value, char * val)
 {
+	char *endptr, *str;
+	int32_t i;
 	uint32_t v;
-	int32_t i;
-	char *endptr, *str;
 
 	str = val;
 	for (i = 0; i < 4; i++) {
@@ -603,8 +627,8 @@
 		str = endptr + 1;
 		value->v.ipaddress[i] = (uint8_t) v;
 	}
+	value->syntax = SNMP_SYNTAX_IPADDRESS;
 
-	value->syntax = SNMP_SYNTAX_IPADDRESS;
 	return (0);
 }
 
@@ -620,7 +644,7 @@
 	v = strtol(val, &endptr, 10);
 
 	if (errno != 0) {
-		warnx("Value %s not supported - %s", val, strerror(errno));
+		warn("Value %s not supported", val);
 		errno = saved_errno;
 		return (-1);
 	}
@@ -668,7 +692,7 @@
 	v = strtoul(val, &endptr, 10);
 
 	if (errno != 0) {
-		warnx("Value %s not supported - %s", val, strerror(errno));
+		warn("Value %s not supported", val);
 		errno = saved_errno;
 		return (-1);
 	}
@@ -722,7 +746,7 @@
 	v = strtoull(val, &endptr, 10);
 
 	if (errno != 0) {
-		warnx("Value %s not supported - %s", val, strerror(errno));
+		warnx("Value %s not supported", val);
 		errno = saved_errno;
 		return (-1);
 	}
@@ -763,7 +787,7 @@
 }
 
 /*
- * Parse a command line argument of type OID=syntax:value and fill in whatever 
+ * Parse a command line argument of type OID=syntax:value and fill in whatever
  * fields can be derived from the input into snmp_value structure. Reads numeric
  * OIDs.
  */
@@ -807,7 +831,7 @@
 			break;
 
 	if (ptr[cnt] != '\0') {
-		warnx("Value string too long - %s",ptr);
+		warnx("Value string too long - %s", ptr);
 		return (-1);
 	}
 
@@ -816,7 +840,7 @@
 	 * to know syntax to check value boundaries.
 	 */
 	if (snmp_parse_numoid(oid_str, &(snmp_val->var)) < 0) {
-		warnx("Error parsing OID %s",oid_str);
+		warnx("Error parsing OID %s", oid_str);
 		return (-1);
 	}
 
@@ -826,10 +850,9 @@
 	return (1);
 }
 
-/* XXX-BZ aruments should be swapped. */
 static int32_t
-parse_syntax_strval(struct snmp_toolinfo *snmptoolctx, char *str,
-    struct snmp_object *object)
+parse_syntax_strval(struct snmp_toolinfo *snmptoolctx,
+    struct snmp_object *object, char *str)
 {
 	uint32_t len;
 	enum snmp_syntax syn;
@@ -895,13 +918,13 @@
 
 	if ((ptr = snmptools_parse_stroid(snmptoolctx, obj, argv)) == NULL)
 		return (-1);
- 
+
 	if (*ptr != '=') {
 		warnx("Value to set expected after OID");
 		return (-1);
 	}
 
-	if (parse_syntax_strval(snmptoolctx, ptr + 1, obj) < 0)
+	if (parse_syntax_strval(snmptoolctx, obj, ptr + 1) < 0)
 		return (-1);
 
 	return (1);
@@ -942,7 +965,7 @@
 add_octstring_syntax(struct snmp_value *dst, struct snmp_value *src)
 {
 	if (src->v.octetstring.len > ASN_MAXOCTETSTRING) {
-		warnx("OctetString len too big - %u",src->v.octetstring.len);
+		warnx("OctetString len too big - %u", src->v.octetstring.len);
 		return (-1);
 	}
 
@@ -1070,32 +1093,36 @@
 	while ((snmp_pdu_add_bindings(snmptoolctx, snmpset_verify_vbind,
 	    snmpset_add_vbind, &req, SNMP_MAX_BINDINGS)) > 0) {
 		if (snmp_dialog(&req, &resp)) {
-			warnx("Snmp dialog - %s", strerror(errno));
+			warn("Snmp dialog");
 			break;
 		}
 
 		if (snmp_pdu_check(&req, &resp) > 0) {
 			if (GET_OUTPUT(snmptoolctx) != OUTPUT_QUIET)
-				snmp_output_resp(snmptoolctx, &resp);
+				snmp_output_resp(snmptoolctx, &resp, NULL);
+			snmp_pdu_free(&resp);
 			break;
 		}
 
 		snmp_output_err_resp(snmptoolctx, &resp);
-		if (!ISSET_RETRY(snmptoolctx))
+		if (!ISSET_RETRY(snmptoolctx)) {
+			snmp_pdu_free(&resp);
 			break;
+		}
 
 		if (snmp_object_seterror(snmptoolctx,
 		    &(resp.bindings[resp.error_index - 1]),
-		    resp.error_status) <= 0)
+		    resp.error_status) <= 0) {
+			snmp_pdu_free(&resp);
 			break;
+		}
 
 		fprintf(stderr, "Retrying...\n");
 		snmp_pdu_free(&req);
-		snmp_pdu_free(&resp);
 		snmp_pdu_create(&req, SNMP_PDU_SET);
 	}
 
-	snmp_pdu_free(&resp);
+	snmp_pdu_free(&req);
 
 	return (0);
 }
@@ -1105,13 +1132,13 @@
  */
 /*
  * According to command line options prepare SNMP Get | GetNext | GetBulk PDU.
- * Wait for a responce and print it.
+ * Wait for a response and print it.
  */
 /*
  * Do a 'snmp walk' - according to command line options request for values
  * lexicographically subsequent and subrooted at a common node. Send a GetNext
- * PDU requesting the value for each next variable and print the responce. Stop
- * when a Responce PDU is received that contains the value of a variable not
+ * PDU requesting the value for each next variable and print the response. Stop
+ * when a Response PDU is received that contains the value of a variable not
  * subrooted at the variable the walk started.
  */
 int
@@ -1215,7 +1242,7 @@
 	}
 
 	if (snmp_open(NULL, NULL, NULL, NULL)) {
-		warnx("Failed to open snmp session: %s.", strerror(errno));
+		warn("Failed to open snmp session");
 		snmp_tool_freeall(&snmptoolctx);
 		exit(1);
 	}
@@ -1225,7 +1252,7 @@
 
 	if (ISSET_EDISCOVER(&snmptoolctx) &&
 	    snmp_discover_engine(snmptoolctx.passwd) < 0) {
-		warnx("Unknown SNMP Engine ID: %s.", strerror(errno));
+		warn("Unknown SNMP Engine ID");
 		rc = 1;
 		goto cleanup;
 	}
@@ -1241,7 +1268,7 @@
 		    snmp_get_local_keys(&snmp_client.user,
 		    snmp_client.engine.engine_id,
 		    snmp_client.engine.engine_len) != SNMP_CODE_OK) {
-		    	warnx("Failed to get keys: %s.", strerror(errno));
+		    	warn("Failed to get keys");
 			rc = 1;
 			goto cleanup;
 		}



More information about the Midnightbsd-cvs mailing list