How to obtain the IP address from a broadcast response?
Reinhold Kainhofer <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Organization | Vienna University of Technology |
| Message-ID | <[email protected]> |
I'm working on SNMP-autodetection of a scanner (for a SANE scanner driver,
written in C). The detection works by sending a UDP broadcast SNMP request and
checking all responses whether they belong to a supported scanner. Now,
sending the broadcast and receiving responses works fine.
Unfortunately, I can't find a way to get the IP address of the answering
device. In the tutorial, the print_result function uses sp->peername, which of
course in my case still points to the broadcast address "255.255.255.255"...
I looked through all the documentation on the website, but could not find
anything about how to get the IP address of the responder...
The only thing that works somehow is (
char *addr_string = transport->f_fmtaddr(transport,
pdu->transport_data, pdu-> transport_data_length);
which prints
"UDP: [10.0.0.5]:161->[0.0.0.0]:36078"
So, apparently, the IP address is there, but the f_fmtaddr function is buried
so deep in the snmplib/transports/ and so dependent on internal data
structures (in particular, netsnmp_udp_addr_pair etc.), that the code there is
basically unusable for copying to my driver and modifying it there.
Is there any high-level method to get only the IP address (IP4 and/or IP6) of
the responder?
Thanks,
Reinhold
--
------------------------------------------------------------------
Reinhold Kainhofer, [email protected], http://reinhold.kainhofer.com/
* Financial & Actuarial Math., Vienna Univ. of Technology, Austria
* http://www.fam.tuwien.ac.at/, DVR: 0005886
* LilyPond, Music typesetting, http://www.lilypond.org
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
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