RE: getting ifname from index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For Linux, you could look into man page of netdevice(7) for the information

FYI, the code goes like this

{
  struct ifreq ifr;
  int sd;

  /* packet socket */
  sd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));

    ifr.ifr_ifindex=3;

    ioctl(sd, SIOCGIFNAME, &ifr);

    printf("%s\t\tIndex: %d\n", ifr.ifr_name, ifr.ifr_ifindex);
}

Hope this helps.

Cheers
Chakri


-----Original Message-----
From: linux-net-owner@vger.kernel.org
[mailto:linux-net-owner@vger.kernel.org]On Behalf Of Madhavi Suram
Sent: Friday, November 02, 2001 8:01 PM
To: linux-net@vger.kernel.org
Subject: getting ifname from index



Hi

I want to get the interface name using interface index in userland. Is
there a way of doing this in linux? Do sysctl/ioctl provide this
information in any way? Could you please give me some pointers for this.

thanks & regards
Madhavi.

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux