How to know if the network supports broadcasting ?
M.D. Srinivas Murthy
murthy at la.excelan.com
Tue Jul 31 04:25:27 AEST 1990
In article <2588 at sequent.cs.qmw.ac.uk> kinawi at cs.qmw.ac.uk (Husam Kinawi) writes:
>Hello,
>SIOCGIFFLAGS, the parameter to be of type "ifreq", and the file descriptor to
>
>My Questions are:
>i) Is this the right way to detect ifa network supports broadcast, and if yes,
> what makes my ioctl fail to work ?
>ii)If I am not on the right way, then is there a possible way to detect
> whether the network used supports broadcast ?
>
> if(ioctl(SocketId, SIOCGIFADDR, p) == -1){
> perror("Ioctl");
> printf("Errno = %d\n", errno);
> }
The approach is right. But -
1. The ioctl code should be SIOCGIFFLAGS.
2. The third parameter has to be a pointer to ifreq structure.
3. You have to specify the interface name (p.ifr_name) for which you want
the flags.
here is the part of the code which worked on a SUN system.
strcpy(p.ifr_name,"ie0");
if(ioctl(SocketId, SIOCGIFFLAGS, &p) == -1){
perror("Ioctl");
printf("Errno = %d\n", errno);
}
I hardcoded the interface name in the example. But you can get the interface
name of all the interfaces using the SIOCGIFCONF ioctl.
SIOCGIFCONF take an array of ifreq structures and fills them with interface
name and interface address.
murthy
More information about the Comp.unix.questions
mailing list