Subject: Re: pkgsrc/wakeup with multiple interfaces
To: None <current-users@netbsd.org>
From: John F <from_netbsd5@frear.com>
List: current-users
Date: 12/13/2005 00:35:46
> On Mon, Dec 12, 2005, David Young wrote:
> 
> John,
> 
> Reading your patch, it looks like it gets the interface-specific source 
> using select_if, and then overwrites it with INADDR_ANY before calling 
> bind(2).  Maybe you are on the right track, you just have a bug?

I was getting embarrassed for a second there, but no, I believe it is not 
a bug.  There are two sockaddr_in structs, named client and server. 
select_if is called on server and then s_addr = INADDR_ANY is declared on 
client, or vice versa for try #2.

It may be a bit confusing to read the second patch I sent, since it was 
based off the first patch.  I was aiming for a smaller patch - I wanted to 
avoid resending the entire select_if function a second time.

> For a multicast UDP socket, I specify the outbound interface by its 
> ifindex, like this:

Very cool..

It looks like the fourth argument, &addr, is the key here.

Its a very interesting bit of code.  The man page just talks about the 
SOL_SOCKET level and you're working at the IP level instead of the higher 
level socket level.  I see that this is documented in the 'ip' man page - 
which I haven't looked at carefully yet. (There is so much documentation 
to read..)  getsockopt says it uses &addr to access an option value, and 
you've run htonl on that.  So, ifindex has got to be a real IP address.. 
Well, I'll play with it and see what it does for me.

All of the above said...

Daniel..

net/wol...  Excellent!!  And, I wasn't aware that magic packets had a 
security feature?!  I don't believe my Mac OS X client computer implements 
that..  (I haven't checked, could be wrong, but iirc the gui simply 
provides a checkbox for en/disabling wake on lan.)

I think I'll continue to hack on the wakeup program a bit further, as at 
this point its a good/simple way for me to tool around with socket 
programming in C, but had I known about 'wol' earlier I would have never 
begun toying with 'wakeup'.  And, if I can't figure out how to do what I 
set out to do with 'wakeup' and just want to be done with it, or I just 
want to see a completely different approach to solving the problem, I will 
be using wol.  What a terrific suggestion!

Thank you David and thank you Daniel.

- John