root/include/uapi/linux/if.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
   2 /*
   3  * INET         An implementation of the TCP/IP protocol suite for the LINUX
   4  *              operating system.  INET is implemented using the  BSD Socket
   5  *              interface as the means of communication with the user level.
   6  *
   7  *              Global definitions for the INET interface module.
   8  *
   9  * Version:     @(#)if.h        1.0.2   04/18/93
  10  *
  11  * Authors:     Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
  12  *              Ross Biro
  13  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  14  *
  15  *              This program is free software; you can redistribute it and/or
  16  *              modify it under the terms of the GNU General Public License
  17  *              as published by the Free Software Foundation; either version
  18  *              2 of the License, or (at your option) any later version.
  19  */
  20 #ifndef _LINUX_IF_H
  21 #define _LINUX_IF_H
  22 
  23 #include <linux/libc-compat.h>          /* for compatibility with glibc */
  24 #include <linux/types.h>                /* for "__kernel_caddr_t" et al */
  25 #include <linux/socket.h>               /* for "struct sockaddr" et al  */
  26 #include <linux/compiler.h>             /* for "__user" et al           */
  27 
  28 #ifndef __KERNEL__
  29 #include <sys/socket.h>                 /* for struct sockaddr.         */
  30 #endif
  31 
  32 #if __UAPI_DEF_IF_IFNAMSIZ
  33 #define IFNAMSIZ        16
  34 #endif /* __UAPI_DEF_IF_IFNAMSIZ */
  35 #define IFALIASZ        256
  36 #include <linux/hdlc/ioctl.h>
  37 
  38 /* For glibc compatibility. An empty enum does not compile. */
  39 #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || \
  40     __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
  41 /**
  42  * enum net_device_flags - &struct net_device flags
  43  *
  44  * These are the &struct net_device flags, they can be set by drivers, the
  45  * kernel and some can be triggered by userspace. Userspace can query and
  46  * set these flags using userspace utilities but there is also a sysfs
  47  * entry available for all dev flags which can be queried and set. These flags
  48  * are shared for all types of net_devices. The sysfs entries are available
  49  * via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
  50  * are annotated below, note that only a few flags can be toggled and some
  51  * other flags are always preserved from the original net_device flags
  52  * even if you try to set them via sysfs. Flags which are always preserved
  53  * are kept under the flag grouping @IFF_VOLATILE. Flags which are volatile
  54  * are annotated below as such.
  55  *
  56  * You should have a pretty good reason to be extending these flags.
  57  *
  58  * @IFF_UP: interface is up. Can be toggled through sysfs.
  59  * @IFF_BROADCAST: broadcast address valid. Volatile.
  60  * @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
  61  * @IFF_LOOPBACK: is a loopback net. Volatile.
  62  * @IFF_POINTOPOINT: interface is has p-p link. Volatile.
  63  * @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
  64  *      Volatile.
  65  * @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
  66  * @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
  67  * @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
  68  * @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
  69  *      sysfs.
  70  * @IFF_MASTER: master of a load balancer. Volatile.
  71  * @IFF_SLAVE: slave of a load balancer. Volatile.
  72  * @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
  73  * @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
  74  * @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
  75  * @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
  76  *      through sysfs.
  77  * @IFF_LOWER_UP: driver signals L1 up. Volatile.
  78  * @IFF_DORMANT: driver signals dormant. Volatile.
  79  * @IFF_ECHO: echo sent packets. Volatile.
  80  */
  81 enum net_device_flags {
  82 /* for compatibility with glibc net/if.h */
  83 #if __UAPI_DEF_IF_NET_DEVICE_FLAGS
  84         IFF_UP                          = 1<<0,  /* sysfs */
  85         IFF_BROADCAST                   = 1<<1,  /* volatile */
  86         IFF_DEBUG                       = 1<<2,  /* sysfs */
  87         IFF_LOOPBACK                    = 1<<3,  /* volatile */
  88         IFF_POINTOPOINT                 = 1<<4,  /* volatile */
  89         IFF_NOTRAILERS                  = 1<<5,  /* sysfs */
  90         IFF_RUNNING                     = 1<<6,  /* volatile */
  91         IFF_NOARP                       = 1<<7,  /* sysfs */
  92         IFF_PROMISC                     = 1<<8,  /* sysfs */
  93         IFF_ALLMULTI                    = 1<<9,  /* sysfs */
  94         IFF_MASTER                      = 1<<10, /* volatile */
  95         IFF_SLAVE                       = 1<<11, /* volatile */
  96         IFF_MULTICAST                   = 1<<12, /* sysfs */
  97         IFF_PORTSEL                     = 1<<13, /* sysfs */
  98         IFF_AUTOMEDIA                   = 1<<14, /* sysfs */
  99         IFF_DYNAMIC                     = 1<<15, /* sysfs */
 100 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
 101 #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
 102         IFF_LOWER_UP                    = 1<<16, /* volatile */
 103         IFF_DORMANT                     = 1<<17, /* volatile */
 104         IFF_ECHO                        = 1<<18, /* volatile */
 105 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
 106 };
 107 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */
 108 
 109 /* for compatibility with glibc net/if.h */
 110 #if __UAPI_DEF_IF_NET_DEVICE_FLAGS
 111 #define IFF_UP                          IFF_UP
 112 #define IFF_BROADCAST                   IFF_BROADCAST
 113 #define IFF_DEBUG                       IFF_DEBUG
 114 #define IFF_LOOPBACK                    IFF_LOOPBACK
 115 #define IFF_POINTOPOINT                 IFF_POINTOPOINT
 116 #define IFF_NOTRAILERS                  IFF_NOTRAILERS
 117 #define IFF_RUNNING                     IFF_RUNNING
 118 #define IFF_NOARP                       IFF_NOARP
 119 #define IFF_PROMISC                     IFF_PROMISC
 120 #define IFF_ALLMULTI                    IFF_ALLMULTI
 121 #define IFF_MASTER                      IFF_MASTER
 122 #define IFF_SLAVE                       IFF_SLAVE
 123 #define IFF_MULTICAST                   IFF_MULTICAST
 124 #define IFF_PORTSEL                     IFF_PORTSEL
 125 #define IFF_AUTOMEDIA                   IFF_AUTOMEDIA
 126 #define IFF_DYNAMIC                     IFF_DYNAMIC
 127 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
 128 
 129 #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
 130 #define IFF_LOWER_UP                    IFF_LOWER_UP
 131 #define IFF_DORMANT                     IFF_DORMANT
 132 #define IFF_ECHO                        IFF_ECHO
 133 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
 134 
 135 #define IFF_VOLATILE    (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
 136                 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
 137 
 138 #define IF_GET_IFACE    0x0001          /* for querying only */
 139 #define IF_GET_PROTO    0x0002
 140 
 141 /* For definitions see hdlc.h */
 142 #define IF_IFACE_V35    0x1000          /* V.35 serial interface        */
 143 #define IF_IFACE_V24    0x1001          /* V.24 serial interface        */
 144 #define IF_IFACE_X21    0x1002          /* X.21 serial interface        */
 145 #define IF_IFACE_T1     0x1003          /* T1 telco serial interface    */
 146 #define IF_IFACE_E1     0x1004          /* E1 telco serial interface    */
 147 #define IF_IFACE_SYNC_SERIAL 0x1005     /* can't be set by software     */
 148 #define IF_IFACE_X21D   0x1006          /* X.21 Dual Clocking (FarSite) */
 149 
 150 /* For definitions see hdlc.h */
 151 #define IF_PROTO_HDLC   0x2000          /* raw HDLC protocol            */
 152 #define IF_PROTO_PPP    0x2001          /* PPP protocol                 */
 153 #define IF_PROTO_CISCO  0x2002          /* Cisco HDLC protocol          */
 154 #define IF_PROTO_FR     0x2003          /* Frame Relay protocol         */
 155 #define IF_PROTO_FR_ADD_PVC 0x2004      /*    Create FR PVC             */
 156 #define IF_PROTO_FR_DEL_PVC 0x2005      /*    Delete FR PVC             */
 157 #define IF_PROTO_X25    0x2006          /* X.25                         */
 158 #define IF_PROTO_HDLC_ETH 0x2007        /* raw HDLC, Ethernet emulation */
 159 #define IF_PROTO_FR_ADD_ETH_PVC 0x2008  /*  Create FR Ethernet-bridged PVC */
 160 #define IF_PROTO_FR_DEL_ETH_PVC 0x2009  /*  Delete FR Ethernet-bridged PVC */
 161 #define IF_PROTO_FR_PVC 0x200A          /* for reading PVC status       */
 162 #define IF_PROTO_FR_ETH_PVC 0x200B
 163 #define IF_PROTO_RAW    0x200C          /* RAW Socket                   */
 164 
 165 /* RFC 2863 operational status */
 166 enum {
 167         IF_OPER_UNKNOWN,
 168         IF_OPER_NOTPRESENT,
 169         IF_OPER_DOWN,
 170         IF_OPER_LOWERLAYERDOWN,
 171         IF_OPER_TESTING,
 172         IF_OPER_DORMANT,
 173         IF_OPER_UP,
 174 };
 175 
 176 /* link modes */
 177 enum {
 178         IF_LINK_MODE_DEFAULT,
 179         IF_LINK_MODE_DORMANT,   /* limit upward transition to dormant */
 180 };
 181 
 182 /*
 183  *      Device mapping structure. I'd just gone off and designed a 
 184  *      beautiful scheme using only loadable modules with arguments
 185  *      for driver options and along come the PCMCIA people 8)
 186  *
 187  *      Ah well. The get() side of this is good for WDSETUP, and it'll
 188  *      be handy for debugging things. The set side is fine for now and
 189  *      being very small might be worth keeping for clean configuration.
 190  */
 191 
 192 /* for compatibility with glibc net/if.h */
 193 #if __UAPI_DEF_IF_IFMAP
 194 struct ifmap {
 195         unsigned long mem_start;
 196         unsigned long mem_end;
 197         unsigned short base_addr; 
 198         unsigned char irq;
 199         unsigned char dma;
 200         unsigned char port;
 201         /* 3 bytes spare */
 202 };
 203 #endif /* __UAPI_DEF_IF_IFMAP */
 204 
 205 struct if_settings {
 206         unsigned int type;      /* Type of physical device or protocol */
 207         unsigned int size;      /* Size of the data allocated by the caller */
 208         union {
 209                 /* {atm/eth/dsl}_settings anyone ? */
 210                 raw_hdlc_proto          __user *raw_hdlc;
 211                 cisco_proto             __user *cisco;
 212                 fr_proto                __user *fr;
 213                 fr_proto_pvc            __user *fr_pvc;
 214                 fr_proto_pvc_info       __user *fr_pvc_info;
 215 
 216                 /* interface settings */
 217                 sync_serial_settings    __user *sync;
 218                 te1_settings            __user *te1;
 219         } ifs_ifsu;
 220 };
 221 
 222 /*
 223  * Interface request structure used for socket
 224  * ioctl's.  All interface ioctl's must have parameter
 225  * definitions which begin with ifr_name.  The
 226  * remainder may be interface specific.
 227  */
 228 
 229 /* for compatibility with glibc net/if.h */
 230 #if __UAPI_DEF_IF_IFREQ
 231 struct ifreq {
 232 #define IFHWADDRLEN     6
 233         union
 234         {
 235                 char    ifrn_name[IFNAMSIZ];            /* if name, e.g. "en0" */
 236         } ifr_ifrn;
 237         
 238         union {
 239                 struct  sockaddr ifru_addr;
 240                 struct  sockaddr ifru_dstaddr;
 241                 struct  sockaddr ifru_broadaddr;
 242                 struct  sockaddr ifru_netmask;
 243                 struct  sockaddr ifru_hwaddr;
 244                 short   ifru_flags;
 245                 int     ifru_ivalue;
 246                 int     ifru_mtu;
 247                 struct  ifmap ifru_map;
 248                 char    ifru_slave[IFNAMSIZ];   /* Just fits the size */
 249                 char    ifru_newname[IFNAMSIZ];
 250                 void __user *   ifru_data;
 251                 struct  if_settings ifru_settings;
 252         } ifr_ifru;
 253 };
 254 #endif /* __UAPI_DEF_IF_IFREQ */
 255 
 256 #define ifr_name        ifr_ifrn.ifrn_name      /* interface name       */
 257 #define ifr_hwaddr      ifr_ifru.ifru_hwaddr    /* MAC address          */
 258 #define ifr_addr        ifr_ifru.ifru_addr      /* address              */
 259 #define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-p lnk */
 260 #define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address    */
 261 #define ifr_netmask     ifr_ifru.ifru_netmask   /* interface net mask   */
 262 #define ifr_flags       ifr_ifru.ifru_flags     /* flags                */
 263 #define ifr_metric      ifr_ifru.ifru_ivalue    /* metric               */
 264 #define ifr_mtu         ifr_ifru.ifru_mtu       /* mtu                  */
 265 #define ifr_map         ifr_ifru.ifru_map       /* device map           */
 266 #define ifr_slave       ifr_ifru.ifru_slave     /* slave device         */
 267 #define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
 268 #define ifr_ifindex     ifr_ifru.ifru_ivalue    /* interface index      */
 269 #define ifr_bandwidth   ifr_ifru.ifru_ivalue    /* link bandwidth       */
 270 #define ifr_qlen        ifr_ifru.ifru_ivalue    /* Queue length         */
 271 #define ifr_newname     ifr_ifru.ifru_newname   /* New name             */
 272 #define ifr_settings    ifr_ifru.ifru_settings  /* Device/proto settings*/
 273 
 274 /*
 275  * Structure used in SIOCGIFCONF request.
 276  * Used to retrieve interface configuration
 277  * for machine (useful for programs which
 278  * must know all networks accessible).
 279  */
 280 
 281 /* for compatibility with glibc net/if.h */
 282 #if __UAPI_DEF_IF_IFCONF
 283 struct ifconf  {
 284         int     ifc_len;                        /* size of buffer       */
 285         union {
 286                 char __user *ifcu_buf;
 287                 struct ifreq __user *ifcu_req;
 288         } ifc_ifcu;
 289 };
 290 #endif /* __UAPI_DEF_IF_IFCONF */
 291 
 292 #define ifc_buf ifc_ifcu.ifcu_buf               /* buffer address       */
 293 #define ifc_req ifc_ifcu.ifcu_req               /* array of structures  */
 294 
 295 #endif /* _LINUX_IF_H */

/* [<][>][^][v][top][bottom][index][help] */