I am using netsnmp-5.1.1. I was able to find the problem and fix it for
my environment.
The problem only exists when you add a MIB entry from an external SNMP
Manager (vs. the snmpd.conf file).
Both the write_snmpNotifyTag() and the write_snmpNotifyRowStatus()
functions needed changes. The fundamental
problem is when the memdup() library call is being used, the caller
needs to make sure that there is a NULL terminating
Character added at the end the char* being duplicated. The interesting
thing is that when you do a MIB walk everything looks
fine because the agent uses the Tag length to find the end of the char.
Unfortunately, this is misleading because the internal
structure used to send out the trap does not use the length and
therefore gets garbage data appended to end of Tag string.
Long story short the fix consists of the following:
FUNCTION write_snmpNotifyTag()
OLD CODE:
case ACTION:
tmpvar = StorageTmp->snmpNotifyTag;
tmplen = StorageTmp->snmpNotifyTagLen;
memdup((u_char **) & StorageTmp->snmpNotifyTag, var_val,
var_val_len);
StorageTmp->snmpNotifyTagLen = var_val_len;
break;
NEW CODE:
case ACTION:
tmpvar = StorageTmp->snmpNotifyTag;
tmplen = StorageTmp->snmpNotifyTagLen;
memdup((u_char **) & StorageTmp->snmpNotifyTag, var_val,
var_val_len + 1);
StorageTmp->snmpNotifyTag[var_val_len] = '\0';
StorageTmp->snmpNotifyTagLen = var_val_len;
break;
FUNCTION snmpNotifyRowStatus()
OLD CODE:
memdup((u_char **) & (StorageNew->snmpNotifyName),
vp->val.string, vp->val_len);
if (StorageNew->snmpNotifyName == NULL) {
return SNMP_ERR_RESOURCEUNAVAILABLE;
}
StorageNew->snmpNotifyNameLen = vp->val_len;
NEW CODE:
memdup((u_char **) & (StorageNew->snmpNotifyName),
vp->val.string, vp->val_len + 1);
StorageNew->snmpNotifyName[vp->val_len] = '\0';
if (StorageNew->snmpNotifyName == NULL) {
return SNMP_ERR_RESOURCEUNAVAILABLE;
}
StorageNew->snmpNotifyNameLen = vp->val_len;
Can someone add these changes or better fix to CVS?
Thanks,
George
-----Original Message-----
From: Robert Story (Coders) [mailto:[EMAIL PROTECTED]
Sent: Monday, September 20, 2004 5:19 AM
To: George Azzi
Cc: [EMAIL PROTECTED]
Subject: Re: Adding Trap destination via MIB does not work
On Tue, 31 Aug 2004 15:41:46 -0700 George wrote:
GA> I have added some Trap destination entries in the
GA> SnmpTargetAddrTable, SnmpTargetParamsTable and SnmpNotifyTable via
GA> an external SNMP manager but I don't receive any traps.
GA>
GA> There doesn't seem to be any association between the MIBs to the
GA> "trapsink" mechanism. Traps seem to be only sent to TrapSink
GA> destinations (sink to MIB path works fine).
What release are you using? In the latest release, the trapsink
mechanism creates entries in those tables, which are used for sending
traps. What do the rows that you created look like?
--
Robert Story; NET-SNMP Junkie <http://www.net-snmp.org/>
<irc://irc.freenode.net/#net-snmp>
Archive:
<http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-coders>
You are lost in a twisty maze of little standards, all different.
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders