Okay, I've figured out something that works. I'll describe what I did:
First, In TSNMPRec.EncodeBuf in snmpsend.pas, I replaced the
StrToIntDef in the call to ASNEncUInt with a StrToCardDef function.
This eliminated the problem of StrToIntDef returning the default value
if the value given it is > HIGH(Integer).
At that point, ASNEncUInt in asn1util.pas was called, and, of course,
the variable showed up as being a large negative integer (since the
parameter is an integer and not a cardinal, so it wrapped around).
However, despite ASNEncUInt attempts to handle the negative, the value
generated was not correct (according to wireshark, at least).
So, I added another function to asn1util.pas:
function ASNEncCard(Value: cardinal): AnsiString;
var
x, y: Cardinal;
begin
x := Value;
Result := '';
repeat
y := x mod 256;
x := x div 256;
Result := AnsiChar(y) + Result;
until x = 0;
end;
Then changed the code in snmpsend.pas to this:
...
ASN1_COUNTER, ASN1_GAUGE, ASN1_TIMETICKS:
s := ASNObject(MibToID(SNMPMib.OID), ASN1_OBJID) +
ASNObject(ASNEncCard(StrToCardDef(SNMPMib.Value, 0)),
SNMPMib.ValueType);
...
After doing this, my large Unsigned32 snmp values are correct,
according to wireshark.
I'm actually pretty suprised nobody else using synapse has run into
this problem. Has anybody else with experience with TSNMPRec found
another way to use the ASN1_GAUGE value type to send variables greater
than $7FFFFFFF? As far as I can see it, the code as it was wouldn't
work.
-SG
--
Good news, everyone!
Seth Grover
sethdgrover[at]gmail[dot]com
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public