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