tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: tap interface address
On Mon, 11 Aug 2008, Quentin Garnier wrote:
> On Mon, Aug 11, 2008 at 02:23:50PM +0100, Iain Hibbert wrote:
> > Hi,
> >
> > Am trying to open a tap(4) device and get the interface address, but
> > SIOCGIFADDR does not work (though it seems that it should, looking at the
> > if_tap.c code and ether_ioctl()) No error is produced but nothing is
>
> I... doubt that. tap_dev_ioctl() returns ENOTTY (as it should). I'll
> try though, there might be a bug.
Mm, maybe you are right, but the program shows no error (is ENOTTY
rewritten to something else in the dev code?)
> > and I worked out how to change the physical address using SIOCSIFPHYADDR
>
> That won't work either if you do it on the fd returned by /dev/tap.
Sorry - yes, was using a socket (BTPROTO_L2CAP) for that.
If I try the SIOCGIFADDR through that socket I do get ENOTTY.
Interestingly, using socket(PF_INET, SOCK_STREAM, 0) gives EADDRNOTAVAIL
as does (PF_INET, SOCK_DGRAM, 0) but (PF_INET, SOCK_SEQPACKET, 0) is
EOPNOTSUPP.
I thought that the 'i' ioctls were diverted to the network stack?
I wonder if I need to prepare the sockaddr somehow?
> Iain, the way one is supposed to manipulate an interface is through a
> socket. So you have to open a socket first (AF_INET is fine to do the
> SIOCSIFPHYADDR call, and you can use it later to set an ipv4 address on
> the interface and so on), and then do the ioctl calls on it.
dhclient will handle all that stuff. I just want to get the address
> I don't think I should blindly let ioctls go to tap_ioctl from the
> character device, but I guess I could at least allow my kludgy
> SIOCSIFPHYADDR. Though usually if you're playing with a tap interface
> you'll need a socket at some point.
Well, you need the fd for the IO in any case..
iain
Home |
Main Index |
Thread Index |
Old Index