Commit Graph

29 Commits

Author SHA1 Message Date
Tom Jones
81e0e7b9e3 bsnmp: Use mkstemp when creating clients local socket
Reviewed by:	harti, rew
Sponsored by:   NetApp, Inc.
Sponsored by:   Klara, Inc.
X-NetApp-PR:    #72
Differential Revision:	https://reviews.freebsd.org/D34550
2022-03-15 08:20:13 +00:00
Gordon Bergling
4731124cac bsnmp: Fix two typos in error messages
- s/responce/response/

MFC after:	1 week
2022-01-26 20:25:40 +01:00
Edward Tomasz Napierala
f53120073b Revert "bsnmpclient(3): make it thread-safe"
This reverts commit 89e3d5671b.

As pointed out, there are several problems with that commit:

1. The new semantics, while useful for clients where multiple
   threads use separate contexts, breaks clients which correctly
   share a single one
2. Change in semantics would require a library version bump
3. It doesn't build with GCC
2020-12-29 19:55:05 +00:00
Edward Tomasz Napierala
89e3d5671b bsnmpclient(3): make it thread-safe
Reviewed By:	harti
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27336
2020-12-29 14:59:37 +00:00
Hartmut Brandt
0bf56da32d Merge release 1.14 of bsnmp. 2020-04-01 15:25:16 +00:00
Justin Hibbits
38effe887e bsnmp: Fix operator precedence in error check in table_check_response
Summary:
The ?: operator has a lower precedence than == and &&, so the result will always
be recorded as true.  Found by gcc8.

Reviewed by:	ngie, ae
Differential Revision: https://reviews.freebsd.org/D22427
2019-11-18 23:23:38 +00:00
Andrey V. Elsukov
48e091f99d Follow the declared behaviour that specifies server string format in
bsnmpclient(3).

snmp_parse_server() function accepts string where some fields can be
omitted: [trans::][community@][server][:port]

"trans" field can be "udp", "udp6", "dgram" and "stream".
"community" can be empty string, if it is omitted, the default value
will be used. For read_community it is "public", for write_comminity
it is "private". "server" field can be hostname, IPv4 address or IPv6
address. IPv6 address should be specified in brackets "[]".
If port is omitted, the default value "snmp" will be used for "udp"
and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is
not required to specify all fields in argument of '-s' option. E.g.

  # bsnmpget -s 127.1 sysName.0
  # bsnmpget -s "udp::127.1" sysName.0
  # bsnmpget -s "udp::public@127.1" sysName.0
  # bsnmpget -s "udp::public@127.1:161" sysName.0
  # bsnmpget -s "udp::[::1]" sysName.0
  # bsnmpget -s "udp6::[::1]" sysName.0
  # bsnmpget -s "[fe80::1%lo0]" sysName.0

PR:		236664
Reported by:	olivier
MFC after:	1 month
2019-04-03 12:47:49 +00:00
Andrey V. Elsukov
04d1781439 Add IPv6 transport for bsnmp.
This patch adds a new table begemotSnmpdTransInetTable that uses the
InetAddressType textual convention and can be used to create listening
ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
future extension beyond UDP by adding a protocol identifier to the table
index. In order to support this gensnmptree had to be modified.

Submitted by:   harti
MFC after:      1 month
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D16654
2019-04-02 12:50:01 +00:00
Enji Cooper
295685c5c1 bsnmp: explicitly test the return value for open_client_{local,udp} in snmp_open(..)
open_client_* returns -1 on failure; 0 on success. Ensure that the return value is
0 -- otherwise exit snmp_open(..).

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-20 17:26:13 +00:00
Enji Cooper
7583dc2785 bsnmp: don't leak snmp_client.fd in open_client_udp(..) on connect(2) failure
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-20 17:17:54 +00:00
Enji Cooper
3daec7ae72 snmp_table_fetch_async: don't leak work if snmp_pdu_send(..) fails
MFC after:	1 week
Reported by:	Coverity
CID:		1017276
2017-01-05 08:49:06 +00:00
Enji Cooper
2e590d595e Use calloc instead of malloc with buffers in snmp_{recv,send}_packet
This doesn't fix the issue noted in the PR, but at the very least it
cleans up the error so it looks a bit more sane, and in the event
that bsnmp did wander off into the weeds, the likelihood of it
crashing with more sensible output is greater, in my opinion

MFC counter set high so I have enough time to resolve the real
underlying bug in bsnmpwalk

MFC after:	1 month
PR:		215721
2017-01-04 07:53:01 +00:00
Enji Cooper
1cc49661ec snmp_discover_engine: fix up req/resp (PDU object) handling a bit
- Call snmp_pdu_free on req and resp when done with the objects
- Call snmp_pdu_free on req before calling snmp_pdu_create on it
  again

MFC after:	1 week
2016-12-31 23:20:57 +00:00
Enji Cooper
1e5211d238 Unbreak the build by passing the string to strdup, not its length
MFC after:	1 week
X-MFC with:	r310931
Pointyhat to:	ngie
2016-12-31 11:24:12 +00:00
Enji Cooper
bfb81e6524 Use strdup in snmp_parse_server(..) when possible instead of malloc+strcpy
This simplifies the code and mutes a Coverity warning about sc->cport being
improperly allocated

Reported by:	Coverity
CID:		1018247
MFC after:	1 week
2016-12-31 11:13:00 +00:00
Enji Cooper
700d391fb8 style(9): snmp_send_packet(..): fix whitespace
MFC after:	3 days
2016-12-28 04:56:15 +00:00
Enji Cooper
e1d581b289 style(9): clean up trailing whitespace
MFC after:	3 weeks
2016-12-27 23:32:54 +00:00
Enji Cooper
3b9712fa95 Minor style(9) fixes
- Trailing whitespace cleanup
- Sort variables in snmp_dialog(..) by alignment

No functional change

MFC after:	1 week
2016-12-24 11:30:24 +00:00
Enji Cooper
7c25494706 Clean up trailing and leading whitespace
Fix variable type alignment in snmp_dialog(..)

MFC after:	1 week
2016-12-18 05:31:54 +00:00
Shteryana Shopova
72cd7a520d Bring in a SNMP module that allows configuration of SNMPv3 Notification targets.
Sponsored by:	The FreeBSD Foundation
Reviewed by:	philip
Approved by:	philip
2010-12-20 17:13:14 +00:00
Shteryana Shopova
135f7de5dd In bsnmpd(1) add support for SNMPv3 message processing model, including message authentication, packet encryption & view-based access control (RFC 3412, 3414, 3415).
Sponsored by:	The FreeBSD Foundation
Reviewed by:	philip@ (mostly)
Approved by:	philip@
2010-12-08 13:51:38 +00:00
Hartmut Brandt
ed0e376bca Flatten bsnmp vendor area. 2008-12-20 16:44:43 +00:00
Hartmut Brandt
748b5b1ebd Virgin import of bsnmpd 1.12 2006-02-27 16:16:18 +00:00
Hartmut Brandt
4c0a7af955 Vendor fix for the build problem of snmp_pf. Move the fallback definitions
for U?INT32_{MAX,MIN} from asn1.h into the .c files that actually require
them (the .h file doesn't refer to these macros).
2005-10-05 15:19:56 +00:00
Hartmut Brandt
165c5d31cb Virgin import of bsnmpd 1.11 2005-10-04 14:41:06 +00:00
Hartmut Brandt
69292ced51 Virgin import of bsnmpd 1.10 2005-05-23 11:19:11 +00:00
Hartmut Brandt
896052c10f Virgin import of bsnmpd 1.7 2004-08-06 13:38:30 +00:00
Hartmut Brandt
70af00a124 Virgin import of bsnmpd 1.5a 2004-01-23 10:44:47 +00:00
Hartmut Brandt
f06ca4af18 Virgin import of bsnmp 1.4 2003-11-10 08:53:38 +00:00