Provided by: manpages-zh_1.5.2-1_all bug

NAME

       netdevice -  Linux .

 (SYNOPSIS)
       #include <sys/ioctl.h>
       #include <net/if.h>

 (DESCRIPTION)
             (socket) .

       Linux       ioctl.     ,       .  ifreq :

       struct ifreq
       {
           char            ifr_name[IFNAMSIZ];   /* Interface name */
           union {
                           struct sockaddr       ifr_addr;
                           struct sockaddr       ifr_dstaddr;
                           struct sockaddr       ifr_broadaddr;
                           struct sockaddr       ifr_netmask;
                           struct sockaddr       ifr_hwaddr;
                           short                 ifr_flags;
                           int                   ifr_ifindex;
                           int                   ifr_metric;
                           int                   ifr_mtu;
                           struct ifmap          ifr_map;
                           char                  ifr_slave[IFNAMSIZ];
                           char                  ifr_newname[IFNAMSIZ];
                           char *                ifr_data;
           };
       }

       struct ifconf
       {
           int ifc_len;                          /* size of buffer */
           union {
                           char *                ifc_buf; /* buffer address */
                           struct ifreq *ifc_req; /* array of structures */
           };
       };

       , ioctl ifr_name          .     .

IOCTLS

         ioctl  ,    uid  0, CAP_NET_ADMIN .  EPERM .

       SIOCGIFNAME
               ifr_ifindex, ifr_name   .  ifr_name   ioctl.

       SIOCGIFINDEX
               ifr_ifindex.

       SIOCGIFFLAGS, SIOCSIFFLAGS
                  .  ifr_flags    :

              IFF_UP             .
              IFF_BROADCAST      .
              IFF_DEBUG          .
              IFF_LOOPBACK       .
              IFF_POINTOPOINT    .
              IFF_RUNNING        .
              IFF_NOARP          arp, .
              IFF_PROMISC        (promiscuous).
              IFF_NOTRAILERS     trailer .
              IFF_ALLMULTI       (multicast).
              IFF_MASTER         (bundle).
              IFF_SLAVE          (bundle).
              IFF_MULTICAST      (multicast).
              IFF_PORTSEL        ifmap(media).
              IFF_AUTOMEDIA      .
              IFF_DYNAMIC        .

                 ,     .

       SIOCGIFMETRIC, SIOCSIFMETRIC
               ifr_metric     metric .    .  ifr_metric  0, EOPNOTSUPP.

       SIOCGIFMTU, SIOCSIFMTU
               ifr_mtu     MTU().   MTU  .  MTU    .

       SIOCGIFHWADDR, SIOCSIFHWADDR
               ifr_hwaddr     .    .

       SIOCSIFHWBROADCAST
               ifr_hwaddr     .  .

       SIOCGIFMAP, SIOCSIFMAP
               ifr_map     .    .

              struct ifmap
              {
                  unsigned long   mem_start;
                  unsigned long   mem_end;
                  unsigned short  base_addr;
                  unsigned char   irq;
                  unsigned char   dma;
                  unsigned char   port;
              };

               ifmap       .

       SIOCADDMULTI, SIOCDELMULTI
               ifr_hwaddr     (multicase filter)     .   .  packet(7).

       SIOCGIFTXQLEN, SIOCSIFTXQLEN
               ifr_qlen     .     .

       SIOCSIFNAME
               ifr_ifindex ifr_newname.   .

       SIOCGIFCONF
               () .  ,   AF_INET .  ifconf   ioctl  .  ifc_req ifreq , ifc_len
              .     L3(?)   ifreqs,     :  ifr_name    (eth0:1),  ifr_addr   .
              ifc_len   ;    ,  ,       .     ioctl  0,   -1,   .

           ioctl     .    .  IP ip(7).

       ,     ioctl,   .

 (NOTE)
        SIOCGIFCONF    IP , ip(7).

 (NOTE)
        /proc/net/dev IFF_RUNNING   .

 (SEE ALSO)
       ip(7), proc(7)

[]

        <xuming@iname.com>

[]

       2000/10/15
       2001/11/24

linuxman:

       http://cmpp.linuxforum.net