1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * INET An implementation of the TCP/IP protocol suite for the LINUX 4607ca46eSDavid Howells * operating system. INET is implemented using the BSD Socket 5607ca46eSDavid Howells * interface as the means of communication with the user level. 6607ca46eSDavid Howells * 7607ca46eSDavid Howells * Global definitions for the INET interface module. 8607ca46eSDavid Howells * 9607ca46eSDavid Howells * Version: @(#)if.h 1.0.2 04/18/93 10607ca46eSDavid Howells * 11607ca46eSDavid Howells * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988 12607ca46eSDavid Howells * Ross Biro 13607ca46eSDavid Howells * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 14607ca46eSDavid Howells * 15607ca46eSDavid Howells * This program is free software; you can redistribute it and/or 16607ca46eSDavid Howells * modify it under the terms of the GNU General Public License 17607ca46eSDavid Howells * as published by the Free Software Foundation; either version 18607ca46eSDavid Howells * 2 of the License, or (at your option) any later version. 19607ca46eSDavid Howells */ 20607ca46eSDavid Howells #ifndef _LINUX_IF_H 21607ca46eSDavid Howells #define _LINUX_IF_H 22607ca46eSDavid Howells 234a91cb61SMikko Rapeli #include <linux/libc-compat.h> /* for compatibility with glibc */ 24607ca46eSDavid Howells #include <linux/types.h> /* for "__kernel_caddr_t" et al */ 25607ca46eSDavid Howells #include <linux/socket.h> /* for "struct sockaddr" et al */ 26607ca46eSDavid Howells #include <linux/compiler.h> /* for "__user" et al */ 27607ca46eSDavid Howells 282618be7dSDmitry V. Levin #ifndef __KERNEL__ 292618be7dSDmitry V. Levin #include <sys/socket.h> /* for struct sockaddr. */ 302618be7dSDmitry V. Levin #endif 312618be7dSDmitry V. Levin 324a91cb61SMikko Rapeli #if __UAPI_DEF_IF_IFNAMSIZ 33607ca46eSDavid Howells #define IFNAMSIZ 16 344a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_IFNAMSIZ */ 35607ca46eSDavid Howells #define IFALIASZ 256 3636fbf1e5SJiri Pirko #define ALTIFNAMSIZ 128 37607ca46eSDavid Howells #include <linux/hdlc/ioctl.h> 38607ca46eSDavid Howells 394a91cb61SMikko Rapeli /* For glibc compatibility. An empty enum does not compile. */ 40efc45154SJonas Gorski #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || \ 414a91cb61SMikko Rapeli __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 42589f5816SLuis R. Rodriguez /** 43589f5816SLuis R. Rodriguez * enum net_device_flags - &struct net_device flags 44589f5816SLuis R. Rodriguez * 45589f5816SLuis R. Rodriguez * These are the &struct net_device flags, they can be set by drivers, the 46589f5816SLuis R. Rodriguez * kernel and some can be triggered by userspace. Userspace can query and 47589f5816SLuis R. Rodriguez * set these flags using userspace utilities but there is also a sysfs 48589f5816SLuis R. Rodriguez * entry available for all dev flags which can be queried and set. These flags 49589f5816SLuis R. Rodriguez * are shared for all types of net_devices. The sysfs entries are available 50589f5816SLuis R. Rodriguez * via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs 51589f5816SLuis R. Rodriguez * are annotated below, note that only a few flags can be toggled and some 5293e68cd6SZhang Shengju * other flags are always preserved from the original net_device flags 53589f5816SLuis R. Rodriguez * even if you try to set them via sysfs. Flags which are always preserved 54589f5816SLuis R. Rodriguez * are kept under the flag grouping @IFF_VOLATILE. Flags which are volatile 55589f5816SLuis R. Rodriguez * are annotated below as such. 56589f5816SLuis R. Rodriguez * 57589f5816SLuis R. Rodriguez * You should have a pretty good reason to be extending these flags. 58589f5816SLuis R. Rodriguez * 59589f5816SLuis R. Rodriguez * @IFF_UP: interface is up. Can be toggled through sysfs. 60589f5816SLuis R. Rodriguez * @IFF_BROADCAST: broadcast address valid. Volatile. 61589f5816SLuis R. Rodriguez * @IFF_DEBUG: turn on debugging. Can be toggled through sysfs. 62589f5816SLuis R. Rodriguez * @IFF_LOOPBACK: is a loopback net. Volatile. 63589f5816SLuis R. Rodriguez * @IFF_POINTOPOINT: interface is has p-p link. Volatile. 64589f5816SLuis R. Rodriguez * @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs. 65589f5816SLuis R. Rodriguez * Volatile. 66589f5816SLuis R. Rodriguez * @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile. 67589f5816SLuis R. Rodriguez * @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile. 68589f5816SLuis R. Rodriguez * @IFF_PROMISC: receive all packets. Can be toggled through sysfs. 69589f5816SLuis R. Rodriguez * @IFF_ALLMULTI: receive all multicast packets. Can be toggled through 70589f5816SLuis R. Rodriguez * sysfs. 71589f5816SLuis R. Rodriguez * @IFF_MASTER: master of a load balancer. Volatile. 72589f5816SLuis R. Rodriguez * @IFF_SLAVE: slave of a load balancer. Volatile. 73589f5816SLuis R. Rodriguez * @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs. 74589f5816SLuis R. Rodriguez * @IFF_PORTSEL: can set media type. Can be toggled through sysfs. 75589f5816SLuis R. Rodriguez * @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs. 76589f5816SLuis R. Rodriguez * @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled 77589f5816SLuis R. Rodriguez * through sysfs. 78589f5816SLuis R. Rodriguez * @IFF_LOWER_UP: driver signals L1 up. Volatile. 79589f5816SLuis R. Rodriguez * @IFF_DORMANT: driver signals dormant. Volatile. 80589f5816SLuis R. Rodriguez * @IFF_ECHO: echo sent packets. Volatile. 81589f5816SLuis R. Rodriguez */ 82589f5816SLuis R. Rodriguez enum net_device_flags { 834a91cb61SMikko Rapeli /* for compatibility with glibc net/if.h */ 844a91cb61SMikko Rapeli #if __UAPI_DEF_IF_NET_DEVICE_FLAGS 85589f5816SLuis R. Rodriguez IFF_UP = 1<<0, /* sysfs */ 86589f5816SLuis R. Rodriguez IFF_BROADCAST = 1<<1, /* volatile */ 87589f5816SLuis R. Rodriguez IFF_DEBUG = 1<<2, /* sysfs */ 88589f5816SLuis R. Rodriguez IFF_LOOPBACK = 1<<3, /* volatile */ 89589f5816SLuis R. Rodriguez IFF_POINTOPOINT = 1<<4, /* volatile */ 90589f5816SLuis R. Rodriguez IFF_NOTRAILERS = 1<<5, /* sysfs */ 91589f5816SLuis R. Rodriguez IFF_RUNNING = 1<<6, /* volatile */ 92589f5816SLuis R. Rodriguez IFF_NOARP = 1<<7, /* sysfs */ 93589f5816SLuis R. Rodriguez IFF_PROMISC = 1<<8, /* sysfs */ 94589f5816SLuis R. Rodriguez IFF_ALLMULTI = 1<<9, /* sysfs */ 95589f5816SLuis R. Rodriguez IFF_MASTER = 1<<10, /* volatile */ 96589f5816SLuis R. Rodriguez IFF_SLAVE = 1<<11, /* volatile */ 97589f5816SLuis R. Rodriguez IFF_MULTICAST = 1<<12, /* sysfs */ 98589f5816SLuis R. Rodriguez IFF_PORTSEL = 1<<13, /* sysfs */ 99589f5816SLuis R. Rodriguez IFF_AUTOMEDIA = 1<<14, /* sysfs */ 100589f5816SLuis R. Rodriguez IFF_DYNAMIC = 1<<15, /* sysfs */ 1014a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */ 1024a91cb61SMikko Rapeli #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 103589f5816SLuis R. Rodriguez IFF_LOWER_UP = 1<<16, /* volatile */ 104589f5816SLuis R. Rodriguez IFF_DORMANT = 1<<17, /* volatile */ 105589f5816SLuis R. Rodriguez IFF_ECHO = 1<<18, /* volatile */ 1064a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ 107589f5816SLuis R. Rodriguez }; 108efc45154SJonas Gorski #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */ 109607ca46eSDavid Howells 1104a91cb61SMikko Rapeli /* for compatibility with glibc net/if.h */ 1114a91cb61SMikko Rapeli #if __UAPI_DEF_IF_NET_DEVICE_FLAGS 112589f5816SLuis R. Rodriguez #define IFF_UP IFF_UP 113589f5816SLuis R. Rodriguez #define IFF_BROADCAST IFF_BROADCAST 114589f5816SLuis R. Rodriguez #define IFF_DEBUG IFF_DEBUG 115589f5816SLuis R. Rodriguez #define IFF_LOOPBACK IFF_LOOPBACK 116589f5816SLuis R. Rodriguez #define IFF_POINTOPOINT IFF_POINTOPOINT 117589f5816SLuis R. Rodriguez #define IFF_NOTRAILERS IFF_NOTRAILERS 118589f5816SLuis R. Rodriguez #define IFF_RUNNING IFF_RUNNING 119589f5816SLuis R. Rodriguez #define IFF_NOARP IFF_NOARP 120589f5816SLuis R. Rodriguez #define IFF_PROMISC IFF_PROMISC 121589f5816SLuis R. Rodriguez #define IFF_ALLMULTI IFF_ALLMULTI 122589f5816SLuis R. Rodriguez #define IFF_MASTER IFF_MASTER 123589f5816SLuis R. Rodriguez #define IFF_SLAVE IFF_SLAVE 124589f5816SLuis R. Rodriguez #define IFF_MULTICAST IFF_MULTICAST 125589f5816SLuis R. Rodriguez #define IFF_PORTSEL IFF_PORTSEL 126589f5816SLuis R. Rodriguez #define IFF_AUTOMEDIA IFF_AUTOMEDIA 127589f5816SLuis R. Rodriguez #define IFF_DYNAMIC IFF_DYNAMIC 1284a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */ 1294a91cb61SMikko Rapeli 1304a91cb61SMikko Rapeli #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 131589f5816SLuis R. Rodriguez #define IFF_LOWER_UP IFF_LOWER_UP 132589f5816SLuis R. Rodriguez #define IFF_DORMANT IFF_DORMANT 133589f5816SLuis R. Rodriguez #define IFF_ECHO IFF_ECHO 1344a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ 135607ca46eSDavid Howells 136607ca46eSDavid Howells #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\ 137607ca46eSDavid Howells IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) 138607ca46eSDavid Howells 139607ca46eSDavid Howells #define IF_GET_IFACE 0x0001 /* for querying only */ 140607ca46eSDavid Howells #define IF_GET_PROTO 0x0002 141607ca46eSDavid Howells 142607ca46eSDavid Howells /* For definitions see hdlc.h */ 143607ca46eSDavid Howells #define IF_IFACE_V35 0x1000 /* V.35 serial interface */ 144607ca46eSDavid Howells #define IF_IFACE_V24 0x1001 /* V.24 serial interface */ 145607ca46eSDavid Howells #define IF_IFACE_X21 0x1002 /* X.21 serial interface */ 146607ca46eSDavid Howells #define IF_IFACE_T1 0x1003 /* T1 telco serial interface */ 147607ca46eSDavid Howells #define IF_IFACE_E1 0x1004 /* E1 telco serial interface */ 148607ca46eSDavid Howells #define IF_IFACE_SYNC_SERIAL 0x1005 /* can't be set by software */ 149607ca46eSDavid Howells #define IF_IFACE_X21D 0x1006 /* X.21 Dual Clocking (FarSite) */ 150607ca46eSDavid Howells 151607ca46eSDavid Howells /* For definitions see hdlc.h */ 152607ca46eSDavid Howells #define IF_PROTO_HDLC 0x2000 /* raw HDLC protocol */ 153607ca46eSDavid Howells #define IF_PROTO_PPP 0x2001 /* PPP protocol */ 154607ca46eSDavid Howells #define IF_PROTO_CISCO 0x2002 /* Cisco HDLC protocol */ 155607ca46eSDavid Howells #define IF_PROTO_FR 0x2003 /* Frame Relay protocol */ 156607ca46eSDavid Howells #define IF_PROTO_FR_ADD_PVC 0x2004 /* Create FR PVC */ 157607ca46eSDavid Howells #define IF_PROTO_FR_DEL_PVC 0x2005 /* Delete FR PVC */ 158607ca46eSDavid Howells #define IF_PROTO_X25 0x2006 /* X.25 */ 159607ca46eSDavid Howells #define IF_PROTO_HDLC_ETH 0x2007 /* raw HDLC, Ethernet emulation */ 160607ca46eSDavid Howells #define IF_PROTO_FR_ADD_ETH_PVC 0x2008 /* Create FR Ethernet-bridged PVC */ 161607ca46eSDavid Howells #define IF_PROTO_FR_DEL_ETH_PVC 0x2009 /* Delete FR Ethernet-bridged PVC */ 162607ca46eSDavid Howells #define IF_PROTO_FR_PVC 0x200A /* for reading PVC status */ 163607ca46eSDavid Howells #define IF_PROTO_FR_ETH_PVC 0x200B 164607ca46eSDavid Howells #define IF_PROTO_RAW 0x200C /* RAW Socket */ 165607ca46eSDavid Howells 166607ca46eSDavid Howells /* RFC 2863 operational status */ 167607ca46eSDavid Howells enum { 168607ca46eSDavid Howells IF_OPER_UNKNOWN, 169607ca46eSDavid Howells IF_OPER_NOTPRESENT, 170607ca46eSDavid Howells IF_OPER_DOWN, 171607ca46eSDavid Howells IF_OPER_LOWERLAYERDOWN, 172607ca46eSDavid Howells IF_OPER_TESTING, 173607ca46eSDavid Howells IF_OPER_DORMANT, 174607ca46eSDavid Howells IF_OPER_UP, 175607ca46eSDavid Howells }; 176607ca46eSDavid Howells 177607ca46eSDavid Howells /* link modes */ 178607ca46eSDavid Howells enum { 179607ca46eSDavid Howells IF_LINK_MODE_DEFAULT, 180607ca46eSDavid Howells IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */ 181*eec517cdSAndrew Lunn IF_LINK_MODE_TESTING, /* limit upward transition to testing */ 182607ca46eSDavid Howells }; 183607ca46eSDavid Howells 184607ca46eSDavid Howells /* 185607ca46eSDavid Howells * Device mapping structure. I'd just gone off and designed a 186607ca46eSDavid Howells * beautiful scheme using only loadable modules with arguments 187607ca46eSDavid Howells * for driver options and along come the PCMCIA people 8) 188607ca46eSDavid Howells * 189607ca46eSDavid Howells * Ah well. The get() side of this is good for WDSETUP, and it'll 190607ca46eSDavid Howells * be handy for debugging things. The set side is fine for now and 191607ca46eSDavid Howells * being very small might be worth keeping for clean configuration. 192607ca46eSDavid Howells */ 193607ca46eSDavid Howells 1944a91cb61SMikko Rapeli /* for compatibility with glibc net/if.h */ 1954a91cb61SMikko Rapeli #if __UAPI_DEF_IF_IFMAP 196607ca46eSDavid Howells struct ifmap { 197607ca46eSDavid Howells unsigned long mem_start; 198607ca46eSDavid Howells unsigned long mem_end; 199607ca46eSDavid Howells unsigned short base_addr; 200607ca46eSDavid Howells unsigned char irq; 201607ca46eSDavid Howells unsigned char dma; 202607ca46eSDavid Howells unsigned char port; 203607ca46eSDavid Howells /* 3 bytes spare */ 204607ca46eSDavid Howells }; 2054a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_IFMAP */ 206607ca46eSDavid Howells 207607ca46eSDavid Howells struct if_settings { 208607ca46eSDavid Howells unsigned int type; /* Type of physical device or protocol */ 209607ca46eSDavid Howells unsigned int size; /* Size of the data allocated by the caller */ 210607ca46eSDavid Howells union { 211607ca46eSDavid Howells /* {atm/eth/dsl}_settings anyone ? */ 212607ca46eSDavid Howells raw_hdlc_proto __user *raw_hdlc; 213607ca46eSDavid Howells cisco_proto __user *cisco; 214607ca46eSDavid Howells fr_proto __user *fr; 215607ca46eSDavid Howells fr_proto_pvc __user *fr_pvc; 216607ca46eSDavid Howells fr_proto_pvc_info __user *fr_pvc_info; 217f362e5feSMartin Schiller x25_hdlc_proto __user *x25; 218607ca46eSDavid Howells 219607ca46eSDavid Howells /* interface settings */ 220607ca46eSDavid Howells sync_serial_settings __user *sync; 221607ca46eSDavid Howells te1_settings __user *te1; 222607ca46eSDavid Howells } ifs_ifsu; 223607ca46eSDavid Howells }; 224607ca46eSDavid Howells 225607ca46eSDavid Howells /* 226607ca46eSDavid Howells * Interface request structure used for socket 227607ca46eSDavid Howells * ioctl's. All interface ioctl's must have parameter 228607ca46eSDavid Howells * definitions which begin with ifr_name. The 229607ca46eSDavid Howells * remainder may be interface specific. 230607ca46eSDavid Howells */ 231607ca46eSDavid Howells 2324a91cb61SMikko Rapeli /* for compatibility with glibc net/if.h */ 2334a91cb61SMikko Rapeli #if __UAPI_DEF_IF_IFREQ 234607ca46eSDavid Howells struct ifreq { 235607ca46eSDavid Howells #define IFHWADDRLEN 6 236607ca46eSDavid Howells union 237607ca46eSDavid Howells { 238607ca46eSDavid Howells char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 239607ca46eSDavid Howells } ifr_ifrn; 240607ca46eSDavid Howells 241607ca46eSDavid Howells union { 242607ca46eSDavid Howells struct sockaddr ifru_addr; 243607ca46eSDavid Howells struct sockaddr ifru_dstaddr; 244607ca46eSDavid Howells struct sockaddr ifru_broadaddr; 245607ca46eSDavid Howells struct sockaddr ifru_netmask; 246607ca46eSDavid Howells struct sockaddr ifru_hwaddr; 247607ca46eSDavid Howells short ifru_flags; 248607ca46eSDavid Howells int ifru_ivalue; 249607ca46eSDavid Howells int ifru_mtu; 250607ca46eSDavid Howells struct ifmap ifru_map; 251607ca46eSDavid Howells char ifru_slave[IFNAMSIZ]; /* Just fits the size */ 252607ca46eSDavid Howells char ifru_newname[IFNAMSIZ]; 253607ca46eSDavid Howells void __user * ifru_data; 254607ca46eSDavid Howells struct if_settings ifru_settings; 255607ca46eSDavid Howells } ifr_ifru; 256607ca46eSDavid Howells }; 2574a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_IFREQ */ 258607ca46eSDavid Howells 259607ca46eSDavid Howells #define ifr_name ifr_ifrn.ifrn_name /* interface name */ 260607ca46eSDavid Howells #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 261607ca46eSDavid Howells #define ifr_addr ifr_ifru.ifru_addr /* address */ 262607ca46eSDavid Howells #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ 263607ca46eSDavid Howells #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ 264607ca46eSDavid Howells #define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ 265607ca46eSDavid Howells #define ifr_flags ifr_ifru.ifru_flags /* flags */ 266607ca46eSDavid Howells #define ifr_metric ifr_ifru.ifru_ivalue /* metric */ 267607ca46eSDavid Howells #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ 268607ca46eSDavid Howells #define ifr_map ifr_ifru.ifru_map /* device map */ 269607ca46eSDavid Howells #define ifr_slave ifr_ifru.ifru_slave /* slave device */ 270607ca46eSDavid Howells #define ifr_data ifr_ifru.ifru_data /* for use by interface */ 271607ca46eSDavid Howells #define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ 272607ca46eSDavid Howells #define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ 273607ca46eSDavid Howells #define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */ 274607ca46eSDavid Howells #define ifr_newname ifr_ifru.ifru_newname /* New name */ 275607ca46eSDavid Howells #define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/ 276607ca46eSDavid Howells 277607ca46eSDavid Howells /* 278607ca46eSDavid Howells * Structure used in SIOCGIFCONF request. 279607ca46eSDavid Howells * Used to retrieve interface configuration 280607ca46eSDavid Howells * for machine (useful for programs which 281607ca46eSDavid Howells * must know all networks accessible). 282607ca46eSDavid Howells */ 283607ca46eSDavid Howells 2844a91cb61SMikko Rapeli /* for compatibility with glibc net/if.h */ 2854a91cb61SMikko Rapeli #if __UAPI_DEF_IF_IFCONF 286607ca46eSDavid Howells struct ifconf { 287607ca46eSDavid Howells int ifc_len; /* size of buffer */ 288607ca46eSDavid Howells union { 289607ca46eSDavid Howells char __user *ifcu_buf; 290607ca46eSDavid Howells struct ifreq __user *ifcu_req; 291607ca46eSDavid Howells } ifc_ifcu; 292607ca46eSDavid Howells }; 2934a91cb61SMikko Rapeli #endif /* __UAPI_DEF_IF_IFCONF */ 2944a91cb61SMikko Rapeli 295607ca46eSDavid Howells #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ 296607ca46eSDavid Howells #define ifc_req ifc_ifcu.ifcu_req /* array of structures */ 297607ca46eSDavid Howells 298607ca46eSDavid Howells #endif /* _LINUX_IF_H */ 299