X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8ad349bb6ed4a0be06e34c92be0d98b92e078db4..6d2010ae8f7a6078e10b361c6962983bab233e0f:/bsd/net/if.h diff --git a/bsd/net/if.h b/bsd/net/if.h index 630058a50..a7974460c 100644 --- a/bsd/net/if.h +++ b/bsd/net/if.h @@ -1,31 +1,29 @@ /* - * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2011 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the - * License may not be used to create, or enable the creation or - * redistribution of, unlawful or unlicensed copies of an Apple operating - * system, or to circumvent, violate, or enable the circumvention or - * violation of, any terms of an Apple operating system software license - * agreement. - * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and * limitations under the License. - * - * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -66,9 +64,11 @@ #ifndef _NET_IF_H_ #define _NET_IF_H_ +#include + #define IF_NAMESIZE 16 -#ifndef _POSIX_C_SOURCE +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #include #ifdef __APPLE__ /* @@ -94,31 +94,35 @@ #define KEV_DL_PROTO_ATTACHED 14 #define KEV_DL_PROTO_DETACHED 15 #define KEV_DL_LINK_ADDRESS_CHANGED 16 +#define KEV_DL_WAKEFLAGS_CHANGED 17 +#define KEV_DL_IF_IDLE_ROUTE_REFCNT 18 +#define KEV_DL_IFCAP_CHANGED 19 #include #include #endif #ifdef KERNEL_PRIVATE +#define IF_MAXUNIT 0x7fff /* historical value */ + struct if_clonereq { int ifcr_total; /* total cloners (out) */ int ifcr_count; /* room for this many in user buffer */ char *ifcr_buffer; /* buffer for cloner names */ }; -/* in-kernel, LP64-aware version of if_clonereq. all pointers - * grow when we're dealing with a 64-bit process. - * WARNING - keep in sync with if_clonereq - */ struct if_clonereq64 { int ifcr_total; /* total cloners (out) */ int ifcr_count; /* room for this many in user buffer */ - union { - u_int64_t ifcru_buffer64; - char * ifcru_buffer32; - } ifcr_ifcru; + user64_addr_t ifcru_buffer __attribute__((aligned(8))); +}; + +struct if_clonereq32 { + int ifcr_total; /* total cloners (out) */ + int ifcr_count; /* room for this many in user buffer */ + user32_addr_t ifcru_buffer; }; -#endif KERNEL_PRIVATE +#endif /* KERNEL_PRIVATE */ #define IFF_UP 0x1 /* interface is up */ #define IFF_BROADCAST 0x2 /* broadcast address valid */ @@ -143,15 +147,31 @@ struct if_clonereq64 { #define IFEF_AUTOCONFIGURING 0x1 #define IFEF_DVR_REENTRY_OK 0x20 /* When set, driver may be reentered from its own thread */ #define IFEF_ACCEPT_RTADVD 0x40 /* set to accept IPv6 router advertisement on the interface */ -#define IFEF_DETACHING 0x80 /* Set when interface is detaching */ -#define IFEF_USEKPI 0x100 /* Set when interface is created through the KPIs */ +#define _IFEF_DETACHING 0x80 /* deprecated */ +#define IFEF_USEKPI 0x100 /* Set when interface is created through the KPIs */ #define IFEF_VLAN 0x200 /* interface has one or more vlans */ #define IFEF_BOND 0x400 /* interface is part of bond */ #define IFEF_ARPLL 0x800 /* ARP for IPv4LL addresses on this port */ -#define IFEF_REUSE 0x20000000 /* DLIL ifnet recycler, ifnet is not new */ -#define IFEF_INUSE 0x40000000 /* DLIL ifnet recycler, ifnet in use */ +#define IFEF_NOWINDOWSCALE 0x1000 /* Don't scale TCP window on iface */ +#define IFEF_NOAUTOIPV6LL 0x2000 /* Interface IPv6 LinkLocal address not provided by kernel */ +#define IFEF_SERVICE_TRIGGERED 0x20000 /* interface is on-demand dynamically created/destroyed */ +#define IFEF_SENDLIST 0x10000000 /* Interface supports sending a list of packets */ +#define _IFEF_REUSE 0x20000000 /* deprecated */ +#define _IFEF_INUSE 0x40000000 /* deprecated */ #define IFEF_UPDOWNCHANGE 0x80000000 /* Interface's up/down state is changing */ +/* + * !!! NOTE !!! + * + * if_idle_flags definitions: (all bits are reserved for internal/future + * use). Setting these flags MUST be done via the ifnet_set_idle_flags() + * KPI due to the associated reference counting. Clearing them may be done by + * calling the KPI, otherwise implicitly at interface detach time. Setting + * the if_idle_flags field to a non-zero value will cause the networking + * stack to aggressively purge expired objects (routes, etc.) + */ +#define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */ + /* flags set internally only: */ #define IFF_CANTCHANGE \ (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ @@ -159,6 +179,40 @@ struct if_clonereq64 { #endif /* KERNEL_PRIVATE */ +/* + * Capabilities that interfaces can advertise. + * + * struct ifnet.if_capabilities + * contains the optional features & capabilities a particular interface + * supports (not only the driver but also the detected hw revision). + * Capabilities are defined by IFCAP_* below. + * struct ifnet.if_capenable + * contains the enabled (either by default or through ifconfig) optional + * features & capabilities on this interface. + * Capabilities are defined by IFCAP_* below. + * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h, + * contains the enabled optional features & capabilites that can be used + * individually per packet and are specified in the mbuf pkthdr.csum_flags + * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be + * more detailed or differenciated than IFCAP_*. + * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h + */ +#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ +#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ +#define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */ +#define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */ +#define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */ +#define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */ +#define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */ +#define IFCAP_LRO 0x00080 /* can do Large Receive Offload */ +#define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */ + +#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) +#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) + +#define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \ + IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV) + #define IFQ_MAXLEN 50 #define IFNET_SLOWHZ 1 /* granularity is 1 second */ @@ -246,6 +300,54 @@ struct ifdevmtu { int ifdm_max; }; +#pragma pack(4) + +/* + ifkpi: interface kpi ioctl + Used with SIOCSIFKPI and SIOCGIFKPI. + + ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From + user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket. + ifk_type - The type. Types are specific to each module id. + ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes. + + Copying data between user space and kernel space is done using copyin + and copyout. A process may be running in 64bit mode. In such a case, + the pointer will be a 64bit pointer, not a 32bit pointer. The following + sample is a safe way to copy the data in to the kernel from either a + 32bit or 64bit process: + + user_addr_t tmp_ptr; + if (IS_64BIT_PROCESS(current_proc())) { + tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64); + } + else { + tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr); + } + error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer); + */ + +struct ifkpi { + unsigned int ifk_module_id; + unsigned int ifk_type; + union { + void *ifk_ptr; + int ifk_value; +#ifdef KERNEL + u_int64_t ifk_ptr64; +#endif /* KERNEL */ + } ifk_data; +}; + +/* Wake capabilities of a interface */ +#define IF_WAKE_ON_MAGIC_PACKET 0x01 +#ifdef KERNEL_PRIVATE +#define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET +#endif /* KERNEL_PRIVATE */ + + +#pragma pack() + /* * Interface request structure used for socket * ioctl's. All interface ioctl's must have parameter @@ -270,8 +372,12 @@ struct ifreq { caddr_t ifru_data; #ifdef KERNEL_PRIVATE u_int64_t ifru_data64; /* 64-bit ifru_data */ -#endif KERNEL_PRIVATE +#endif /* KERNEL_PRIVATE */ struct ifdevmtu ifru_devmtu; + struct ifkpi ifru_kpi; + u_int32_t ifru_wake_flags; + u_int32_t ifru_route_refcnt; + int ifru_cap[2]; } ifr_ifru; #define ifr_addr ifr_ifru.ifru_addr /* address */ #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ @@ -291,7 +397,12 @@ struct ifreq { #define ifr_intval ifr_ifru.ifru_intval /* integer value */ #ifdef KERNEL_PRIVATE #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */ -#endif KERNEL_PRIVATE +#endif /* KERNEL_PRIVATE */ +#define ifr_kpi ifr_ifru.ifru_kpi +#define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities of devive */ +#define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references on interface */ +#define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ +#define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ }; #define _SIZEOF_ADDR_IFREQ(ifr) \ @@ -311,6 +422,9 @@ struct rslvmulti_req { struct sockaddr **llsa; }; +#if !defined(KERNEL) || defined(KERNEL_PRIVATE) +#pragma pack(4) + struct ifmediareq { char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ int ifm_current; /* current media options */ @@ -321,11 +435,11 @@ struct ifmediareq { int *ifm_ulist; /* media words */ }; +#pragma pack() +#endif /* !KERNEL || KERNEL_PRIVATE */ + #ifdef KERNEL_PRIVATE -/* LP64 version of ifmediareq. all pointers - * grow when we're dealing with a 64-bit process. - * WARNING - keep in sync with ifmediareq - */ +#pragma pack(4) struct ifmediareq64 { char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ int ifm_current; /* current media options */ @@ -333,12 +447,48 @@ struct ifmediareq64 { int ifm_status; /* media status */ int ifm_active; /* active options */ int ifm_count; /* # entries in ifm_ulist array */ - union { /* media words */ - int * ifmu_ulist32; /* 32-bit pointer */ - u_int64_t ifmu_ulist64; /* 64-bit pointer */ - } ifm_ifmu; + user64_addr_t ifmu_ulist __attribute__((aligned(8))); }; -#endif // KERNEL_PRIVATE + +struct ifmediareq32 { + char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + int ifm_current; /* current media options */ + int ifm_mask; /* don't care mask */ + int ifm_status; /* media status */ + int ifm_active; /* active options */ + int ifm_count; /* # entries in ifm_ulist array */ + user32_addr_t ifmu_ulist; /* 32-bit pointer */ +}; +#pragma pack() +#endif /* KERNEL_PRIVATE */ + + +#pragma pack(4) +struct ifdrv { + char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + unsigned long ifd_cmd; + size_t ifd_len; + void *ifd_data; +}; +#pragma pack() + +#ifdef KERNEL_PRIVATE +#pragma pack(4) +struct ifdrv32 { + char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_int32_t ifd_cmd; + u_int32_t ifd_len; + user32_addr_t ifd_data; +}; + +struct ifdrv64 { + char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_int64_t ifd_cmd; + u_int64_t ifd_len; + user64_addr_t ifd_data; +}; +#pragma pack() +#endif /* KERNEL_PRIVATE */ /* * Structure used to retrieve aux status data from interfaces. @@ -353,44 +503,51 @@ struct ifstat { char ascii[IFSTATMAX + 1]; }; +#if !defined(KERNEL) || defined(KERNEL_PRIVATE) /* * Structure used in SIOCGIFCONF request. * Used to retrieve interface configuration * for machine (useful for programs which * must know all networks accessible). */ +#pragma pack(4) struct ifconf { int ifc_len; /* size of associated buffer */ union { caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; +}; +#pragma pack() #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ +#endif /* !KERNEL || KERNEL_PRIVATE */ + +#if defined(KERNEL_PRIVATE) +#pragma pack(4) +struct ifconf32 { + int ifc_len; /* size of associated buffer */ + struct { + user32_addr_t ifcu_req; + } ifc_ifcu; }; -#ifdef KERNEL_PRIVATE -/* LP64 version of ifconf. all pointers - * grow when we're dealing with a 64-bit process. - * WARNING - keep in sync with ifconf - */ struct ifconf64 { int ifc_len; /* size of associated buffer */ - union { - struct ifreq * ifcu_req; - u_int64_t ifcu_req64; + struct { + user64_addr_t ifcu_req __attribute__((aligned(8))); } ifc_ifcu; }; -#define ifc_req64 ifc_ifcu.ifcu_req64 -#endif // KERNEL_PRIVATE +#pragma pack() +#endif /* KERNEL_PRIVATE */ /* * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure */ struct kev_dl_proto_data { struct net_event_data link_data; - unsigned long proto_family; - unsigned long proto_remaining_count; + u_int32_t proto_family; + u_int32_t proto_remaining_count; }; /* @@ -411,7 +568,7 @@ MALLOC_DECLARE(M_IFADDR); MALLOC_DECLARE(M_IFMADDR); #endif #endif -#endif /* _POSIX_C_SOURCE */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ #ifndef KERNEL struct if_nameindex {