On Tue, 2007-09-04 at 23:11 +0600, Aaron Kaplan wrote:
> hi!
> 
> aehmm... maybe I am making a fool out of myself but because I don't  
> understand your question, but... did you look at the gethostbyname 
> () , inet_aton(), ... collection of manpages?
> 
> 
> On Sep 4, 2007, at 10:21 PM, Joao wrote:
> 
> > Hi all!
> > Is there any function to send a message to a known node by its ip  
> > adress?

Within OLSRD or in general?

> > The only function i could find that does a similar job is olsr_sendto

And that is basically just a wrapper (to fix for OS-specific subtleties IIRC)
around sendto(2) - which is one of the functions to use.

> > but for that is needed a sockaddr struct...
> > Is there any other way to make this happen?

Yes. In general you have to - as Aaron wrote - make a (binary) struct in_addr
out of it, create socket, and send it with sendto(2) (or others mentioned on
the manual page of sendto(2)).

The motivation/reason is (IMHO) that you practically never[0] sent out only one
packet to one target but *lots of*. Sou usually you create socket just once and
use it often. Otherwise you waste lots of CPU power with the usual "convert,
create socket, sent, close socket" thing (and do not forget error the checking
part on it. And if you error check everything before, you could create the socket
before too). The requires (on Unixens) ATM at least 3 system calls (i.e. socket(2),
sendto(2), close(2)) and that is *quite* expensive in relation to pure library
calls.

	Bernd

[0]: Apart from DDoS attacks with faked soruce addresss, only "ping" comes into
     my mind. And even with "ping" you usually sent out more than one packet.
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




