On Thu, Mar 05, 2009 at 10:03:25AM +0300, Eugene Berdnikov wrote:
>  Linux? It works for me:
> 
>       s0 = socket(PF_INET,SOCK_DGRAM,0);
>       if (s0<0)
>               perror ("socket");
> 
>       ret = ioctl(s0, SIOCSIFFLAGS, &ifr);
>       if (ret < 0)
>               perror("set flags");
> 
>  I think that if SIOCGIFFLAGS succeeds on some fd, then SIOCSIFFLAGS
>  should also succeed or return an error. So this is a kernel bug.

 Some digging shows that ioctl's to fd, such as SIOCGIFFLAGS, return
 things different from visible network device state. Probably you
 can only do those ioctl's that are listed in linux/if_tun.h, and
 the mistery is why kernel doesn't return EINVAL if ioctl is called
 with wrong function number.

 I looked through kernel tun.c code -- it seems correct to me.
 However, the bug may be somewhere else.

 So, you should create socket, fill interface name field in ifr,
 get flags via ioctl with this socket, and work with derived data.
 That's what ifconfig does.
-- 
 Eugene Berdnikov

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
VTun-devel mailing list
VTun-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vtun-devel

Reply via email to