On Wed, Jul 13, 2011 at 2:38 PM, Zack Little <[email protected]> wrote:
>
>
>> > how would I use the InetAddress object binary string to return
>> > an IPv6 address in my custom MIB? None of those types seem related to a
>> > binary string.
>>
>> I haven't checked the code, but it should be possible to use the 'string'
>> type to return a binary string value, as well as regular ASCII strings.
>>
>> Try it.
>>
> I looked at the pass_persist.c code and if "string" is passed in it sets the
> 'type' in the structure to ASN_OCTET_STR. So I think that means I could
> pass in the binary representation of the IPv6 address. After reading
> INET-ADDRESS-MIB I'm still unclear as to how to convert and IPv6 address
> into the binary format the net-snmp code expects. There is not an existing
> conversion function I could call?
>
>> > The situation with snmptrap seems better
>> > because it can accept arguments with a type of "HEX STRING" or "DECIMAL
>> > STRING". I don't know how to convert an IPv6 address into that format
>> > though.
>>
>> Try querying the agent for an existing table object that shows such
>> an IPv6 address, and use the '-d' flag to dump the raw packets.
>> That will show how IPv6 addresses are represented.
>>
>> Or see the description in the INET-ADDRESS-MIB
>>
>> Dave
> I'm still struggling to understand why the implementation is how it
> currently is. I enabled IPv6 support when I compiled the net-snmp tool.
> Therefore it's very easy to specify an IPv6 address to snmptrap as the
> destination of where the trap should be sent. If you're able to easily
> specify an IPv6 destination then it stands to reason that in your trap you
> would want to include some IPv6 IP address information. So in this example
> below the trap's destination of ::1 (the first one) is happily accepted by
> the code but the trap argument of ::1 (the second one) is not.
>
> /bin/snmptrap -v 3 -u userid -a MD5 -A authpasswd -x DES -X encryptpasswd -l
> authPriv ::1 449800 IpInfo TheIp a ::1
Not totally unrelated, but.. I spy with my little eye something v4
(apps/snmptrap.c):
agent = argv[arg];
if (agent != NULL && strlen(agent) != 0) {
int ret = netsnmp_gethostbyname_v4(agent, pdu_in_addr_t);
if (ret < 0) {
fprintf(stderr, "unknown host: %s\n", agent);
exit(1);
}
} else {
*pdu_in_addr_t = get_myaddr();
}
As for your issue, what I did was reproduced it following the example
in the tutorial (
http://www.net-snmp.org/tutorial/tutorial-5/commands/snmptrap.html ),
and with the following command line:
$ cat > NOTIFICATION-TEST-MIB.txt <<EOF
NOTIFICATION-TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS ucdavis FROM UCD-SNMP-MIB;
demonotifs OBJECT IDENTIFIER ::= { ucdavis 991 }
demo-notif NOTIFICATION-TYPE
STATUS current
OBJECTS { sysLocation }
DESCRIPTION "Just a test notification"
::= { demonotifs 17 }
END
EOF
$ snmptrap -M +$PWD -m all -v2c -c public fallout ''
NOTIFICATION-TEST-MIB::demo-notif IF-MIB::linkUp a ::1
IF-MIB::linkUp: Bad value notation (::1)
Looking through gdb and the source code, it's pretty obvious why
this doesn't work (from snmp_add_var in snmplib/snmp_api.c):
case 'a':
#ifndef NETSNMP_DISABLE_MIB_LOADING
if (check && tp->type != TYPE_IPADDR) {
value = "IpAddress";
result = SNMPERR_VALUE;
goto type_error;
}
#endif /* NETSNMP_DISABLE_MIB_LOADING */
atmp = inet_addr(value);
if (atmp != (in_addr_t) -1 || !strcmp(value, "255.255.255.255"))
inet_aton only groks IPv4 addresses :). Additional logic needs to
be added to parse out the address via inet_addr -- I would introduce
another argument (say 'A' instead of 'a'?) for IPv6 addresses so that
way there's a clean method for dealing with IPv4 vs IPv6 (some
revamping will need to occur because IPv6 addresses must be
IPV6-TC::Ipv6Address types, for instance, from what I can see etc).
I'll see if I can whip up a patch later on tonight because I know
this is going to be a snag for my group in a couple of months :/..
Thanks,
-Garrett
------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric
Ries, the creator of the Lean Startup Methodology on "Lean Startup
Secrets Revealed." This video shows you how to validate your ideas,
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users