Re: [newbie] ASN1 types mapping to c

Dave Shield <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
2009/11/8 LiWei Sun <[email protected]>:
> I don't know how to pass an ip address value to "snmp_set_var_typed_value"  function.
> I got a string value like "192.168.1.1", is it right to simply cast it to u_char* type

No - you need to pass it a *binary* string - of length 4.
Something like:

   char addr[4];
   addr[0] = 192;
   addr[1] = 168;
   addr[2] = 1;
   addr[3] = 1;

snmp_set_var_typed_value(var, ASN_IPADDRESS, addr, sizeof(addr));


You may need to experiment to check the byte ordering.

Dave

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.