ATM/X.25 interfaces

ATM/X.25 interfaces

Post by Shailesh Dargud » Thu, 13 Mar 2003 15:54:45

I have a requirement which needs to find all the network interfaces and
assigned IP for them ,
So I have written a small code which uses  SIOCGIFCONF ioctl request .
Also the code works fine. I just wanted to make sure that using
SIOCGIFCONF,will I be able to
get the names of ATM and x.25 interfaces also. I hope it should, but I
don't  have these interfaces to test.
Has anybody tried this on these types  interfaces . Are there any other
network interfaces which this  code
will fail to detect.Please correct me if I am doing anything wrong.

I am doing this on HP UX.


Sample Code is as below,

#include <stdio.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <stdlib.h>

int if_name(struct ifconf *ifc)
    static char buf[BUFSIZ];
    int sfd = 0;
    sfd = socket(AF_INET, SOCK_STREAM, 0);
    memset(ifc, 0, sizeof(struct ifconf));

    ifc->ifc_len = sizeof(buf);
    ifc->ifc_buf = buf;

    if (ioctl(sfd, SIOCGIFCONF, ifc) < 0)
        perror(" ioctl error :");

  printf("found %d interfaces.\n",
           ifc->ifc_len / (sizeof(struct ifreq)));
    return (ifc->ifc_len / (sizeof(struct ifreq)));


int main(int argc, char *argv[])
    int i, no;
    struct ifconf ifcg;
    no = if_name(&ifcg);
    for (i = 0; i < no; i++) {
        printf("%s \n", ifcg.ifc_req[i].ifr_name);
    return 0;