Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to use SIOCGIFCOUNT

Reply
Thread Tools Display Modes

How to use SIOCGIFCOUNT

 
 
Datha
Guest
Posts: n/a

 
      12-21-2005, 12:20 PM
Hi Everyone,
How to use SIOCGIFCOUNT. I have tried using following code. I get error
saying that
SIOCGIFCOUNT(AF_INET): Invalid argument. I am interested to know when I
use SIOCGIFCOUNT, what parameters I nhave to pass.

#include <sys/socket.h>
#include <net/if.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <linux/sockios.h>
#include <netinet/in.h>

int main(void)
{
int s;
struct ifconf ifc;
struct ifreq ifr;

memset(&ifc, 0, sizeof(ifc));
memset(&ifr, 0, sizeof(ifr));
ifc.ifc_len = 0;
ifc.ifc_buf = NULL;

if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror("socket(AF_INET)");
exit(-1);
}

if(ioctl(s, SIOCGIFCOUNT, &ifr) < 0)
{
perror("SIOCGIFCOUNT:");
exit(-1);
}

printf("Number of interfaces = %d\n",ifc.ifc_len/sizeof(struct
ifreq));
close(s);
}
Thank Yu,
Datha

 
Reply With Quote
 
 
 
 
Robert Harris
Guest
Posts: n/a

 
      12-21-2005, 02:35 PM
Datha wrote:
> Hi Everyone,
> How to use SIOCGIFCOUNT. I have tried using following code. I get error
> saying that
> SIOCGIFCOUNT(AF_INET): Invalid argument. I am interested to know when I
> use SIOCGIFCOUNT, what parameters I nhave to pass.
>
> [snip]
>

Looking at the kernel code, it seems to be defined only for Appletalk.
What do you really want to find out with it?

Robert
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




1 2 3 4 5 6 7 8 9 10 11