Find Interface name

C

chellappa

hi all,
i trying to find the intferface name using this coding ,but that is
not working ,,,if anybody this pervious..please help to find the
interface name using Linux C.

//CODE
ioctl(sd, SIOCGIFNAME, &ifr);
strncpy(ifname,ifr.ifr_name,IFNAMSIZ);
printf("Interface name :%s\n",ifname);

//
thanks all
 
E

Eric Sosman

chellappa said:
hi all,
i trying to find the intferface name using this coding ,but that is
not working ,,,if anybody this pervious..please help to find the
interface name using Linux C.

//CODE
ioctl(sd, SIOCGIFNAME, &ifr);
strncpy(ifname,ifr.ifr_name,IFNAMSIZ);
printf("Interface name :%s\n",ifname);

In Standard C, an `int' is guaranteed to be able
to count as high as 32767. Some implementations use
a wider `int', but 32767 is the maximum you can be
absolutely sure of.

If one were to write a program to count the number
of times Chellappa has been told that Standard C has
no networking facilities, the number of times he has
been told to take his networking questions to newsgroups
where networking experts hang out, the number of times
he has been given the names of those newsgroups, and the
number of times he has utterly failed to get the message,
would it be wise to use a mere `int' for the counter?
 
J

Joe Estock

Eric said:
In Standard C, an `int' is guaranteed to be able
to count as high as 32767. Some implementations use
a wider `int', but 32767 is the maximum you can be
absolutely sure of.

If one were to write a program to count the number
of times Chellappa has been told that Standard C has
no networking facilities, the number of times he has
been told to take his networking questions to newsgroups
where networking experts hang out, the number of times
he has been given the names of those newsgroups, and the
number of times he has utterly failed to get the message,
would it be wise to use a mere `int' for the counter?

I'd put bets on at least an unsigned long, preferably an unsigned long
long if the implementation supports it.

Joe
 
W

wcang79

Hi,

I don't know about SIOCGIFNAME, but I assume that what you want is
to call ioctl(sd, SIOCGIFCONF, &ifconf) to obtain all the network
interfaces on your system.

Regards,
Ang Way Chuang
 
W

wcang79

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,171
Messages
2,570,935
Members
47,472
Latest member
KarissaBor

Latest Threads

Top