diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2007-01-21 22:54:05 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2007-01-21 22:54:05 +0000 |
commit | bff438913761968193960dc32b1db372ebe509ee (patch) | |
tree | ea2cb2770237834082201c46df2fdd9108b0562b /winsup/cygwin/include | |
parent | f89533c1ffb2ff780ad8e678a1cd9c7e6035725f (diff) | |
download | cygnal-bff438913761968193960dc32b1db372ebe509ee.tar.gz cygnal-bff438913761968193960dc32b1db372ebe509ee.tar.bz2 cygnal-bff438913761968193960dc32b1db372ebe509ee.zip |
* autoload.cc (WSAIoctl): Define.
(SendARP): Define.
* cygwin.din: Export if_freenameindex, if_indextoname, if_nameindex and
if_nametoindex.
* fhandler_procnet.cc: Drop including wchar.h. Drop definitions of
GAA_FLAG_INCLUDE_ALL_INTERFACES, IP_ADAPTER_UNICAST_ADDRESS_VISTA.
(fhandler_procnet::exists): Check for has_gaa_prefixes. Call
get_adapters_addresses here.
(fhandler_procnet::readdir): Ditto.
(prefix): Move to net.cc.
(fhandler_procnet::fill_filebuf): Call get_adapters_addresses here.
Simplify allocation. Use AdapterName rather than FriendlyName as
interface name. Use IfIndex if available, Ipv6IfIndex otherwise.
(in6_are_prefix_equal): Move to net.cc.
* fhandler_socket.cc: Define old SIOCGxxx values.
(CONV_OLD_TO_NEW_SIO): Convert old SIOCGxxx value to new one.
(struct __old_ifreq): Define old struct ifreq.
(fhandler_socket::ioctl): Handle old SIOCGxxx values. Handle new
SIOCGIFFRNDLYNAM command. Simplify copying ifreq data to user space.
Call get_ifconf with additional SOCKET parameter.
* net.cc (IP_ADAPTER_UNICAST_ADDRESS_LH): Define.
(IP_ADAPTER_ADDRESSES_LH): Define.
(SIO_GET_INTERFACE_LIST): Define.
(sockaddr_in6_old): Define.
(sockaddr_gen): Define.
(INTERFACE_INFO): Define.
(IN_LOOPBACK): Define.
(in_are_prefix_equal): New static function.
(ip_addr_prefix): New function, replaces prefix function, add AF_INET
handling.
(GAA_FLAG_INCLUDE_ALL_INTERFACES): Define.
(get_adapters_addresses): New function.
(WS_IFF_xxx): Define Winsock interface flag values.
(convert_ifr_flags): New function to convert Winsock interface flag
values to Cygwin interface flag values.
(get_xp_ifconf): New get_ifconf implementation for XP SP1 and above.
(get_2k_ifconf): Fix interface index. Fix formatting.
(get_nt_ifconf): Fix formatting.
(get_95_ifconf): Ditto.
(get_ifconf): Take additional SOCKET parameter. Call get_xp_ifconf
on XP SP1 and above.
(if_nametoindex): New function.
(if_indextoname): New function.
(if_nameindex): New function.
(if_freenameindex): New function.
(in6_are_prefix_equal): Moved here from fhandler_procnet.cc.
* wincap.cc (wincap_xp): Define has_gaa_prefixes as true by default.
(wincapc::init): Assume has_osversioninfoex by default. Call
GetVersionEx with OSVERSIONINFOEX first. Call with OSVERSIONINFO only
if that fails. Simplify NT4 case and try to avoid strcmp. Check XP
Service Pack using version.wServicePackMajor to avoid strcmp.
* include/asm/socket.h (SIOCGIFFRNDLYNAM): Define.
* include/cygwin/if.h: Fix formatting.
(IFF_POINTTOPOINT): Define.
(IFF_NOARP): Define.
(IFF_LOWER_UP): Define.
(IFF_DORMANT): Define.
(struct if_nameindex): Define.
(IFRF_FRIENDLYNAMESIZ): Define.
(struct ifreq_frndlyname): Define.
(IFNAMSIZ): Redefine as 44.
(IF_NAMESIZE): Define.
(struct ifreq): Redefine ifru_flags as int. Define ifru_data. Pad size
to sizeof sockaddr_in6 for further extensions.
(ifr_data): Define.
(ifr_frndlyname): Define.
(if_nametoindex): Declare.
(if_indextoname): Declare.
(if_nameindex): Declare.
(if_freenameindex): Declare.
* include/cygwin/version.h: Bump API minor number.
(CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ): Define check for old vs. new
ifreq structure.
Diffstat (limited to 'winsup/cygwin/include')
-rw-r--r-- | winsup/cygwin/include/asm/socket.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/if.h | 94 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/version.h | 7 |
3 files changed, 69 insertions, 33 deletions
diff --git a/winsup/cygwin/include/asm/socket.h b/winsup/cygwin/include/asm/socket.h index 4541bc850..f8e93cc81 100644 --- a/winsup/cygwin/include/asm/socket.h +++ b/winsup/cygwin/include/asm/socket.h @@ -43,6 +43,7 @@ details. */ #define SIOCGIFMTU _IOW('s', 107, struct ifreq) /* get MTU size */ #define SIOCGIFINDEX _IOW('s', 108, struct ifreq) /* get if index */ #define SIOGIFINDEX SIOCGIFINDEX /* backward compatibility w/ Linux typo. */ +#define SIOCGIFFRNDLYNAM _IOW('s', 109, struct ifreq) /* get friendly if name */ #define SOL_SOCKET 0xffff /* options for socket level */ diff --git a/winsup/cygwin/include/cygwin/if.h b/winsup/cygwin/include/cygwin/if.h index fe36afcf2..c61e2ada2 100644 --- a/winsup/cygwin/include/cygwin/if.h +++ b/winsup/cygwin/include/cygwin/if.h @@ -19,13 +19,32 @@ extern "C" { #include <sys/socket.h> /* Standard interface flags. */ -#define IFF_UP 0x1 /* interface is up */ -#define IFF_BROADCAST 0x2 /* broadcast address valid */ -#define IFF_LOOPBACK 0x8 /* is a loopback net */ -#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ -#define IFF_RUNNING 0x40 /* resources allocated */ -#define IFF_PROMISC 0x100 /* receive all packets */ -#define IFF_MULTICAST 0x1000 /* Supports multicast */ +#define IFF_UP 0x1 /* interface is up */ +#define IFF_BROADCAST 0x2 /* broadcast address valid */ +#define IFF_LOOPBACK 0x8 /* is a loopback net */ +#define IFF_POINTTOPOINT 0x10 /* is a point-to-point interface */ +#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ +#define IFF_RUNNING 0x40 /* resources allocated */ +#define IFF_NOARP 0x80 /* no ARP protocol */ +#define IFF_PROMISC 0x100 /* receive all packets */ +#define IFF_MULTICAST 0x1000 /* Supports multicast */ +#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ +#define IFF_DORMANT 0x20000 /* driver signals dormant */ + +struct if_nameindex { + unsigned if_index; + char *if_name; +}; + +/* This is the structure expected by ioctl when the application requests + the friendly adapter name (>= XP SP1). ifru_data should point to such + a structure when ioctl is called with SIOCGIFFRNDLYNAM. */ +#define IFRF_FRIENDLYNAMESIZ 260 + +struct ifreq_frndlyname { + int ifrf_len; + char ifrf_friendlyname[IFRF_FRIENDLYNAMESIZ]; +}; /* * Interface request structure used for socket @@ -33,26 +52,29 @@ extern "C" { * definitions which begin with ifr_name. The * remainder may be interface specific. */ - -struct ifreq -{ -#define IFNAMSIZ 16 +#define IFNAMSIZ 44 +#define IF_NAMESIZE IFNAMSIZ #define IFHWADDRLEN 6 - union - { - char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - } ifr_ifrn; - - union { - struct sockaddr ifru_addr; - struct sockaddr ifru_broadaddr; - struct sockaddr ifru_netmask; - struct sockaddr ifru_hwaddr; - short ifru_flags; - int ifru_metric; - int ifru_mtu; - int ifru_ifindex; - } ifr_ifru; + +struct ifreq { + union { + char ifrn_name[IFNAMSIZ]; /* Unique Windows Adapter name (A GUID) */ + } ifr_ifrn; + + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + int ifru_flags; + int ifru_metric; + int ifru_mtu; + int ifru_ifindex; + /* The space must be preallocated by the application. */ + void *ifru_data; + /* Pad to sizeof sockaddr_in6 for further extensions. */ + char __ifru_pad[28]; + } ifr_ifru; }; #define ifr_name ifr_ifrn.ifrn_name /* interface name */ @@ -64,6 +86,8 @@ struct ifreq #define ifr_metric ifr_ifru.ifru_metric /* metric */ #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ #define ifr_ifindex ifr_ifru.ifru_ifindex /* interface index */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#define ifr_frndlyname ifr_ifru.ifru_data /* Windows friendly if name */ /* * Structure used in SIOCGIFCONF request. @@ -74,16 +98,22 @@ struct ifreq struct ifconf { - int ifc_len; /* size of buffer */ - union - { - caddr_t ifcu_buf; - struct ifreq *ifcu_req; - } ifc_ifcu; + int ifc_len; /* size of buffer */ + union + { + caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; }; + #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ #define ifc_req ifc_ifcu.ifcu_req /* array of structures */ +extern unsigned if_nametoindex (const char *); +extern char *if_indextoname (unsigned, char *); +extern struct if_nameindex *if_nameindex (void); +extern void if_freenameindex (struct if_nameindex *); + #ifdef __cplusplus }; #endif /* __cplusplus */ diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index dd448aef2..44c7229c3 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -94,6 +94,9 @@ details. */ #define CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES \ (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 138) +#define CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ \ + (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 161) + /* API_MAJOR 0.0: Initial version. API_MINOR changes: 1: Export cygwin32_ calls as cygwin_ as well. 2: Export j1, jn, y1, yn. @@ -296,12 +299,14 @@ details. */ 159: Export posix_openpt. 160: Export posix_fadvice, posix_fallocate. 161: Export resolver functions. + 162: New struct ifreq. Export if_nametoindex, if_indextoname, + if_nameindex, if_freenameindex. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 161 +#define CYGWIN_VERSION_API_MINOR 162 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible |