williamr@2: /*- williamr@2: * Copyright (c) 1982, 1986, 1989, 1993 williamr@2: * The Regents of the University of California. All rights reserved. williamr@2: * williamr@2: * Redistribution and use in source and binary forms, with or without williamr@2: * modification, are permitted provided that the following conditions williamr@2: * are met: williamr@2: * 1. Redistributions of source code must retain the above copyright williamr@2: * notice, this list of conditions and the following disclaimer. williamr@2: * 2. Redistributions in binary form must reproduce the above copyright williamr@2: * notice, this list of conditions and the following disclaimer in the williamr@2: * documentation and/or other materials provided with the distribution. williamr@2: * 4. Neither the name of the University nor the names of its contributors williamr@2: * may be used to endorse or promote products derived from this software williamr@2: * without specific prior written permission. williamr@2: * williamr@2: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND williamr@2: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE williamr@2: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE williamr@2: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE williamr@2: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL williamr@2: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS williamr@2: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) williamr@2: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT williamr@2: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY williamr@2: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF williamr@2: * SUCH DAMAGE. williamr@2: * williamr@4: * Portions Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. williamr@2: * @(#)if.h 8.1 (Berkeley) 6/10/93 williamr@2: * $FreeBSD: src/sys/net/if.h,v 1.96.2.3 2005/10/07 14:00:05 glebius Exp $ williamr@2: */ williamr@2: williamr@2: #ifndef _NET_IF_H_ williamr@2: #define _NET_IF_H_ williamr@2: williamr@2: #ifdef __SYMBIAN32__ williamr@2: #ifdef __cplusplus williamr@2: extern "C" { williamr@2: #endif williamr@2: #endif williamr@2: williamr@2: #include williamr@2: williamr@2: #ifdef _KERNEL williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if __BSD_VISIBLE williamr@2: /* williamr@2: * does not depend on on most other systems. This williamr@2: * helps userland compatibility. (struct timeval ifi_lastchange) williamr@2: */ williamr@2: #ifndef _KERNEL williamr@2: #include williamr@2: #endif williamr@2: williamr@2: struct ifnet; williamr@2: #endif williamr@2: williamr@2: /* williamr@2: * Length of interface external name, including terminating '\0'. williamr@2: * Note: this is the same size as a generic device's external name. williamr@2: */ williamr@2: #ifdef __SYMBIAN32__ williamr@2: // KCommsDbSvrMaxColumnNameLength = 50 williamr@2: #define IF_NAMESIZE 50 williamr@2: #else williamr@2: #define IF_NAMESIZE 16 williamr@2: #endif williamr@2: #if __BSD_VISIBLE williamr@2: #define IFNAMSIZ IF_NAMESIZE williamr@2: #define IF_MAXUNIT 0x7fff /* historical value */ williamr@2: #endif williamr@2: #if __BSD_VISIBLE williamr@2: williamr@2: /* williamr@2: * Structure used to query names of interface cloners. williamr@2: */ williamr@2: williamr@2: struct if_clonereq { williamr@2: int ifcr_total; /* total cloners (out) */ williamr@2: int ifcr_count; /* room for this many in user buffer */ williamr@2: char *ifcr_buffer; /* buffer for cloner names */ williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Structure describing information about an interface williamr@2: * which may be of interest to management entities. williamr@2: */ williamr@2: struct if_data { williamr@2: /* generic interface information */ williamr@2: u_char ifi_type; /* ethernet, tokenring, etc */ williamr@2: u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ williamr@2: u_char ifi_addrlen; /* media address length */ williamr@2: u_char ifi_hdrlen; /* media header length */ williamr@2: u_char ifi_link_state; /* current link state */ williamr@2: u_char ifi_recvquota; /* polling quota for receive intrs */ williamr@2: u_char ifi_xmitquota; /* polling quota for xmit intrs */ williamr@2: u_char ifi_datalen; /* length of this data struct */ williamr@2: u_long ifi_mtu; /* maximum transmission unit */ williamr@2: u_long ifi_metric; /* routing metric (external only) */ williamr@2: u_long ifi_baudrate; /* linespeed */ williamr@2: /* volatile statistics */ williamr@2: u_long ifi_ipackets; /* packets received on interface */ williamr@2: u_long ifi_ierrors; /* input errors on interface */ williamr@2: u_long ifi_opackets; /* packets sent on interface */ williamr@2: u_long ifi_oerrors; /* output errors on interface */ williamr@2: u_long ifi_collisions; /* collisions on csma interfaces */ williamr@2: u_long ifi_ibytes; /* total number of octets received */ williamr@2: u_long ifi_obytes; /* total number of octets sent */ williamr@2: u_long ifi_imcasts; /* packets received via multicast */ williamr@2: u_long ifi_omcasts; /* packets sent via multicast */ williamr@2: u_long ifi_iqdrops; /* dropped on input, this interface */ williamr@2: u_long ifi_noproto; /* destined for unsupported protocol */ williamr@2: u_long ifi_hwassist; /* HW offload capabilities */ williamr@2: time_t ifi_epoch; /* uptime at attach or stat reset */ williamr@2: #ifdef __alpha__ williamr@2: u_int ifi_timepad; /* time_t is int, not long on alpha */ williamr@2: #endif williamr@2: struct timeval ifi_lastchange; /* time of last administrative change */ williamr@2: }; williamr@2: williamr@2: /*- williamr@2: * Interface flags are of two types: network stack owned flags, and driver williamr@2: * owned flags. Historically, these values were stored in the same ifnet williamr@2: * flags field, but with the advent of fine-grained locking, they have been williamr@2: * broken out such that the network stack is responsible for synchronizing williamr@2: * the stack-owned fields, and the device driver the device-owned fields. williamr@2: * Both halves can perform lockless reads of the other half's field, subject williamr@2: * to accepting the involved races. williamr@2: * williamr@2: * Both sets of flags come from the same number space, and should not be williamr@2: * permitted to conflict, as they are exposed to user space via a single williamr@2: * field. williamr@2: * williamr@2: * The following symbols identify read and write requirements for fields: williamr@2: * williamr@2: * (i) if_flags field set by device driver before attach, read-only there williamr@2: * after. williamr@2: * (n) if_flags field written only by the network stack, read by either the williamr@2: * stack or driver. williamr@2: * (d) if_drv_flags field written only by the device driver, read by either williamr@2: * the stack or driver. williamr@2: */ williamr@2: #define IFF_UP 0x1 /* (n) interface is up */ williamr@2: #define IFF_BROADCAST 0x2 /* (i) broadcast address valid */ williamr@2: #define IFF_DEBUG 0x4 /* (n) turn on debugging */ williamr@2: #define IFF_LOOPBACK 0x8 /* (i) is a loopback net */ williamr@2: #define IFF_POINTOPOINT 0x10 /* (i) is a point-to-point link */ williamr@2: #define IFF_SMART 0x20 /* (i) interface manages own routes */ williamr@2: #define IFF_DRV_RUNNING 0x40 /* (d) resources allocated */ williamr@2: #define IFF_NOARP 0x80 /* (n) no address resolution protocol */ williamr@2: #define IFF_PROMISC 0x100 /* (n) receive all packets */ williamr@2: #define IFF_ALLMULTI 0x200 /* (n) receive all multicast packets */ williamr@2: #define IFF_DRV_OACTIVE 0x400 /* (d) tx hardware queue is full */ williamr@2: #define IFF_SIMPLEX 0x800 /* (i) can't hear own transmissions */ williamr@2: #define IFF_LINK0 0x1000 /* per link layer defined bit */ williamr@2: #define IFF_LINK1 0x2000 /* per link layer defined bit */ williamr@2: #define IFF_LINK2 0x4000 /* per link layer defined bit */ williamr@2: #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ williamr@2: #define IFF_MULTICAST 0x8000 /* (i) supports multicast */ williamr@2: /* 0x10000 */ williamr@2: #define IFF_PPROMISC 0x20000 /* (n) user-requested promisc mode */ williamr@2: #define IFF_MONITOR 0x40000 /* (n) user-requested monitor mode */ williamr@2: #define IFF_STATICARP 0x80000 /* (n) static ARP */ williamr@2: #define IFF_NEEDSGIANT 0x100000 /* (i) hold Giant over if_start calls */ williamr@2: williamr@2: /* williamr@2: * Old names for driver flags so that user space tools can continue to use williamr@2: * the old (portable) names. williamr@2: */ williamr@2: #ifndef _KERNEL williamr@2: #define IFF_RUNNING IFF_DRV_RUNNING williamr@2: #define IFF_OACTIVE IFF_DRV_OACTIVE williamr@2: #endif williamr@2: williamr@2: /* flags set internally only: */ williamr@2: #define IFF_CANTCHANGE \ williamr@2: (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\ williamr@2: IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC) williamr@2: williamr@2: /* williamr@2: * Values for if_link_state. williamr@2: */ williamr@2: #define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */ williamr@2: #define LINK_STATE_DOWN 1 /* link is down */ williamr@2: #define LINK_STATE_UP 2 /* link is up */ williamr@2: williamr@2: /* williamr@2: * Some convenience macros used for setting ifi_baudrate. williamr@2: * XXX 1000 vs. 1024? --thorpej@netbsd.org williamr@2: */ williamr@2: #define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */ williamr@2: #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */ williamr@2: #define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */ williamr@2: williamr@2: /* Capabilities that interfaces can advertise. */ williamr@2: #define IFCAP_RXCSUM 0x0001 /* can offload checksum on RX */ williamr@2: #define IFCAP_TXCSUM 0x0002 /* can offload checksum on TX */ williamr@2: #define IFCAP_NETCONS 0x0004 /* can be a network console */ williamr@2: #define IFCAP_VLAN_MTU 0x0008 /* VLAN-compatible MTU */ williamr@2: #define IFCAP_VLAN_HWTAGGING 0x0010 /* hardware VLAN tag support */ williamr@2: #define IFCAP_JUMBO_MTU 0x0020 /* 9000 byte MTU supported */ williamr@2: #define IFCAP_POLLING 0x0040 /* driver supports polling */ williamr@2: williamr@2: #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) williamr@2: williamr@2: #define IFQ_MAXLEN 50 williamr@2: #define IFNET_SLOWHZ 1 /* granularity is 1 second */ williamr@2: williamr@2: /* williamr@2: * Message format for use in obtaining information about interfaces williamr@2: * from getkerninfo and the routing socket williamr@2: */ williamr@2: struct if_msghdr { williamr@2: u_short ifm_msglen; /* to skip over non-understood messages */ williamr@2: u_char ifm_version; /* future binary compatibility */ williamr@2: u_char ifm_type; /* message type */ williamr@2: int ifm_addrs; /* like rtm_addrs */ williamr@2: int ifm_flags; /* value of if_flags */ williamr@2: u_short ifm_index; /* index for associated ifp */ williamr@2: struct if_data ifm_data;/* statistics and other data about if */ williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Message format for use in obtaining information about interface addresses williamr@2: * from getkerninfo and the routing socket williamr@2: */ williamr@2: struct ifa_msghdr { williamr@2: u_short ifam_msglen; /* to skip over non-understood messages */ williamr@2: u_char ifam_version; /* future binary compatibility */ williamr@2: u_char ifam_type; /* message type */ williamr@2: int ifam_addrs; /* like rtm_addrs */ williamr@2: int ifam_flags; /* value of ifa_flags */ williamr@2: u_short ifam_index; /* index for associated ifp */ williamr@2: int ifam_metric; /* value of ifa_metric */ williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Message format for use in obtaining information about multicast addresses williamr@2: * from the routing socket williamr@2: */ williamr@2: struct ifma_msghdr { williamr@2: u_short ifmam_msglen; /* to skip over non-understood messages */ williamr@2: u_char ifmam_version; /* future binary compatibility */ williamr@2: u_char ifmam_type; /* message type */ williamr@2: int ifmam_addrs; /* like rtm_addrs */ williamr@2: int ifmam_flags; /* value of ifa_flags */ williamr@2: u_short ifmam_index; /* index for associated ifp */ williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Message format announcing the arrival or departure of a network interface. williamr@2: */ williamr@2: struct if_announcemsghdr { williamr@2: u_short ifan_msglen; /* to skip over non-understood messages */ williamr@2: u_char ifan_version; /* future binary compatibility */ williamr@2: u_char ifan_type; /* message type */ williamr@2: u_short ifan_index; /* index for associated ifp */ williamr@2: char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ williamr@2: u_short ifan_what; /* what type of announcement */ williamr@2: }; williamr@2: williamr@2: #define IFAN_ARRIVAL 0 /* interface arrival */ williamr@2: #define IFAN_DEPARTURE 1 /* interface departure */ williamr@2: williamr@2: /* williamr@2: * Interface request structure used for socket williamr@2: * ioctl's. All interface ioctl's must have parameter williamr@2: * definitions which begin with ifr_name. The williamr@2: * remainder may be interface specific. williamr@2: */ williamr@2: struct ifreq { williamr@2: char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ williamr@2: union { williamr@2: struct sockaddr ifru_addr; williamr@2: struct sockaddr ifru_dstaddr; williamr@2: struct sockaddr ifru_broadaddr; williamr@2: struct sockaddr ifru_hwaddr; williamr@2: short ifru_flags[2]; williamr@2: short ifru_index; williamr@2: int ifru_metric; williamr@2: int ifru_mtu; williamr@2: int ifru_phys; williamr@2: int ifru_media; williamr@2: caddr_t ifru_data; williamr@2: int ifru_cap[2]; williamr@2: unsigned int snap_id; williamr@2: } ifr_ifru; williamr@2: #ifdef __SYMBIAN32__ williamr@2: #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ williamr@2: #endif williamr@2: #define ifr_addr ifr_ifru.ifru_addr /* address */ williamr@2: #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ williamr@2: #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ williamr@2: #define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */ williamr@2: #define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */ williamr@2: #define ifr_metric ifr_ifru.ifru_metric /* metric */ williamr@2: #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ williamr@2: #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ williamr@2: #define ifr_media ifr_ifru.ifru_media /* physical media */ williamr@2: #define ifr_data ifr_ifru.ifru_data /* for use by interface */ williamr@2: #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ williamr@2: #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ williamr@2: #define ifr_index ifr_ifru.ifru_index /* interface index */ williamr@2: }; williamr@2: williamr@2: #define _SIZEOF_ADDR_IFREQ(ifr) \ williamr@2: ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ williamr@2: (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ williamr@2: (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) williamr@2: williamr@2: struct ifaliasreq { williamr@2: char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ williamr@2: struct sockaddr ifra_addr; williamr@2: struct sockaddr ifra_broadaddr; williamr@2: struct sockaddr ifra_mask; williamr@2: }; williamr@2: williamr@2: struct ifmediareq { williamr@2: char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ williamr@2: int ifm_current; /* current media options */ williamr@2: int ifm_mask; /* don't care mask */ williamr@2: int ifm_status; /* media status */ williamr@2: int ifm_active; /* active options */ williamr@2: int ifm_count; /* # entries in ifm_ulist array */ williamr@2: int *ifm_ulist; /* media words */ williamr@2: }; williamr@2: williamr@2: struct ifdrv { williamr@2: char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ williamr@2: unsigned long ifd_cmd; williamr@2: size_t ifd_len; williamr@2: void *ifd_data; williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Structure used to retrieve aux status data from interfaces. williamr@2: * Kernel suppliers to this interface should respect the formatting williamr@2: * needed by ifconfig(8): each line starts with a TAB and ends with williamr@2: * a newline. The canonical example to copy and paste is in if_tun.c. williamr@2: */ williamr@2: williamr@2: #define IFSTATMAX 800 /* 10 lines of text */ williamr@2: struct ifstat { williamr@2: char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ williamr@2: char ascii[IFSTATMAX + 1]; williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Structure used in SIOCGIFCONF request. williamr@2: * Used to retrieve interface configuration williamr@2: * for machine (useful for programs which williamr@2: * must know all networks accessible). williamr@2: */ williamr@2: struct ifconf { williamr@2: int ifc_len; /* size of associated buffer */ williamr@2: union { williamr@2: caddr_t ifcu_buf; williamr@2: struct ifreq *ifcu_req; williamr@2: } ifc_ifcu; williamr@2: #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ williamr@2: #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ williamr@2: }; williamr@2: williamr@2: williamr@2: /* williamr@2: * Structure for SIOC[AGD]LIFADDR williamr@2: */ williamr@2: struct if_laddrreq { williamr@2: char iflr_name[IFNAMSIZ]; williamr@2: u_int flags; williamr@2: #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ williamr@2: u_int prefixlen; /* in/out */ williamr@2: struct sockaddr_storage addr; /* in/out */ williamr@2: struct sockaddr_storage dstaddr; /* out */ williamr@2: }; williamr@2: williamr@2: #endif /* __BSD_VISIBLE */ williamr@2: williamr@2: #ifndef _KERNEL williamr@2: struct if_nameindex { williamr@2: unsigned int if_index; /* 1, 2, ... */ williamr@2: char *if_name; /* null terminated name: "le0", ... */ williamr@2: }; williamr@2: williamr@2: __BEGIN_DECLS williamr@2: IMPORT_C void if_freenameindex(struct if_nameindex *); williamr@2: IMPORT_C char *if_indextoname(unsigned int, char *); williamr@2: IMPORT_C struct if_nameindex *if_nameindex(void); williamr@2: IMPORT_C unsigned int if_nametoindex(const char *); williamr@2: __END_DECLS williamr@2: #endif williamr@2: williamr@2: #ifdef _KERNEL williamr@2: struct thread; williamr@2: williamr@2: /* XXX - this should go away soon. */ williamr@4: #include williamr@2: #endif williamr@2: williamr@2: /* williamr@2: * Symbian specific APIs williamr@2: */ williamr@2: #ifdef __SYMBIAN32__ williamr@2: IMPORT_C int setdefaultif( const struct ifreq* ); williamr@2: #endif williamr@2: williamr@2: #ifdef __SYMBIAN32__ williamr@2: #ifdef __cplusplus williamr@2: } williamr@2: #endif williamr@2: #endif williamr@2: williamr@2: #endif /* !_NET_IF_H_ */