01-20-06 07:50 AM
"manish" <manishmodgil@gmail.com> writes:
> what if i write
>
> printf(" %d", ioctl(1,SIOCGIFBRDADDR,0));
>
> how could i display the broadcast address on the stdout.
You have stdout redirected to an inet socket?
Anyways, read man ioctl
and understand what it returns (hint: check the RETURN VALUE section).
Then read man ioctl_list (or the equivalent on your OS, I'm a little
Linux-centric) and understand what the SIOCGIFBRDADDR row means:
For each ioctl, I list its numerical value, its name, and its
argument type.
An argument type of 'const struct foo *' means the argument is
input to the kernel. 'struct foo *' means the kernel outputs the
argument. If the kernel uses the argument for both input and
output, this is marked with // I-O.
..
0x00008919 SIOCGIFBRDADDR struct ifreq * // I-O
..
Something like:
struct ifreq request;
int res=ioctl(socket,SIOCGIFBRDADDR,&request);
if(res<0){ perror("ioctl SIOCGIFBRDADDR"); exit(1); }
do_something_with(request);
--
__Pascal Bourguignon__ http://www.informatimago.com/
"You cannot really appreciate Dilbert unless you read it in the
original Klingon"
[ Post a follow-up to this message ]
|