On Mon, 2005-10-31 at 22:17 -0800, mahua dutta wrote:

> I like to know whether Inetaddress be considered
> as OCTET sting while implementing the mib.

Yes.
It *must* be considered as an OCTET STRING.

> If So, for Ipv6 or Ipv4, the pseudo code can be as
> snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char
> *)"127.0.0.1", strlen("127.0.0.1")).
> 
> Is it correct to do that ?

No.
An IPv4 address is a fixed-length *binary* string,
not a (variable-length) printable string.
See RFC 2578, section 7.1.5

So this code would actually be more like:

   char  localhost[4];
   localhost[0] = 127;
   localhost[1] = 0;
   localhost[2] = 0;
   localhost[3] = 1;

   snmp_set_var_typed_value( var, ASN_OCTET_STR,
                                  localhost, 4);

IPv6 addresses would be handled in a similar way.


> There is an similar question in the following link
> http://sourceforge.net/mailarchive/message.php?msg_id=11149756

Not really - this questioner *was* using a fixed
length binary string, and was asking about the
difference between ASN_OCTET_STR and ASN_IPADDRESS

The two types work in basically the same way - they
both use *binary* string values, not printable ones.

Dave


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to