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