On fre, 2006-12-15 at 10:45 -0500, G. S. Marzot wrote:
> sadly this is the first time I tried sending/receiving traps in a long
> time...so
> the access control feature was new to me...
>
> one question:
>
> Is there a philosophical reason that no snmptrapd.conf file is installed or
> available with sample lines for the basic user (commented out where approp.)?
>
> also found some oddness (read bugs) when trying to send traps:
>
> [EMAIL PROTECTED] ~]$ snmptrap -d -v 1 -c public localhost "" "" 0 0 ""
>
> Sending 44 bytes to UDP: [127.0.0.1]:161
> 0000: 30 2A 02 01 00 04 06 70 75 62 6C 69 63 A4 1D 06 0*.....public...
> 0016: 08 2B 06 01 04 01 03 01 01 40 04 C0 A8 01 03 02 [EMAIL PROTECTED]
> 0032: 01 00 02 01 00 43 03 07 D3 19 30 00 .....C....0.
>
> read_config_store open failure on /var/net-snmp/snmpapp.conf
> read_config_store open failure on /var/net-snmp/snmpapp.conf
> read_config_store open failure on /var/net-snmp/snmpapp.conf
>
>
> note the default sending to port 161...
Ahrg! Does the attached patch correct the problem for you?
The problem is that snmp_open() calls
netsnmp_tdomain_transport_full("snmp", ...) and this tells the library
that when it looks for default values to use then it should use the
"snmp" domain, and there port 161 is reasonable. In this case we should
have told it to use the "snmptrap" domain. That is all the patch does.
Another thing is that maybe NETSNMP_DS_LIB_DEFAULT_PORT should have
higher precedence than the value from the domain transport lookup?
In any case the attached patch or something along those line should be
used as it is more correct than the current code.
/MF
Index: apps/snmptrap.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/apps/snmptrap.c,v
retrieving revision 5.4
diff -u -r5.4 snmptrap.c
--- apps/snmptrap.c 15 Sep 2006 00:48:43 -0000 5.4
+++ apps/snmptrap.c 16 Dec 2006 09:24:13 -0000
@@ -148,6 +148,7 @@
main(int argc, char *argv[])
{
netsnmp_session session, *ss;
+ netsnmp_transport *trans;
netsnmp_pdu *pdu, *response;
oid name[MAX_OID_LEN];
size_t name_length;
@@ -185,8 +186,6 @@
session.callback = snmp_input;
session.callback_magic = NULL;
- netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT,
- SNMP_TRAP_PORT);
if (session.version == SNMP_VERSION_3 && !inform) {
/*
@@ -239,10 +238,21 @@
session.engineTime = get_uptime(); /* but it'll work. Sort of. */
}
- ss = snmp_open(&session);
+ trans = netsnmp_transport_open_client("snmptrap", session.peername);
+ if (trans == NULL) {
+ /*
+ * diagnose snmp_transport_open_client errors with the input
+ * netsnmp_session pointer
+ */
+ snmp_sess_perror("snmptrap", &session);
+ SOCK_CLEANUP;
+ exit(1);
+ }
+
+ ss = snmp_add(&session, trans, NULL, NULL);
if (ss == NULL) {
/*
- * diagnose snmp_open errors with the input netsnmp_session pointer
+ * diagnose snmp_add errors with the input netsnmp_session pointer
*/
snmp_sess_perror("snmptrap", &session);
SOCK_CLEANUP;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders