diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 70afe9b71..6163e9120 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2007-01-16 Corinna Vinschen + + * fhandler_socket.cc (fhandler_socket::ioctl): Handle SIOCGIFINDEX. + * net.cc (get_2k_ifconf): Ditto. + (get_nt_ifconf): Fake SIOCGIFINDEX. + (get_95_ifconf): Ditto. + (get_ifconf): Handle SIOCGIFINDEX. Fake it for loopback on systems + not supporting IP Helper Lib. + * include/asm/socket.h (SIOCGIFINDEX): Define. + * include/cygwin/if.h (struct ifreq): Add member for interface index. + (ifr_ifindex): Define. + 2007-01-16 Corinna Vinschen * include/cygwin/in6.h (struct ipv6_mreq): Change type of interface diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 3f7799eec..0ef0f593d 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1419,6 +1419,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) case SIOCGIFHWADDR: case SIOCGIFMETRIC: case SIOCGIFMTU: + case SIOCGIFINDEX: { ifc.ifc_len = 2048; ifc.ifc_buf = (char *) alloca (2048); @@ -1469,6 +1470,9 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) case SIOCGIFMTU: ifr->ifr_mtu = ifrp->ifr_mtu; break; + case SIOCGIFINDEX: + ifr->ifr_ifindex = ifrp->ifr_ifindex; + break; } break; } diff --git a/winsup/cygwin/include/asm/socket.h b/winsup/cygwin/include/asm/socket.h index ed062190c..637cec294 100644 --- a/winsup/cygwin/include/asm/socket.h +++ b/winsup/cygwin/include/asm/socket.h @@ -1,6 +1,6 @@ /* asm/socket.h - Copyright 1996, 1997, 1998, 2001 Red Hat, Inc. + Copyright 1996, 1997, 1998, 2001, 2005, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -41,6 +41,7 @@ details. */ #define SIOCGIFHWADDR _IOW('s', 105, struct ifreq) /* Get hw addr */ #define SIOCGIFMETRIC _IOW('s', 106, struct ifreq) /* get metric */ #define SIOCGIFMTU _IOW('s', 107, struct ifreq) /* get MTU size */ +#define SIOCGIFINDEX _IOW('s', 108, struct ifreq) /* get if index */ #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 b0953de36..fe36afcf2 100644 --- a/winsup/cygwin/include/cygwin/if.h +++ b/winsup/cygwin/include/cygwin/if.h @@ -1,6 +1,6 @@ /* cygwin/if.h - Copyright 1996, 2001 Red Hat, Inc. + Copyright 1996, 2001, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -51,6 +51,7 @@ struct ifreq short ifru_flags; int ifru_metric; int ifru_mtu; + int ifru_ifindex; } ifr_ifru; }; @@ -62,7 +63,7 @@ struct ifreq #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ #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 */ /* * Structure used in SIOCGIFCONF request. diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index f70618d22..13a1ee9df 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1299,6 +1299,9 @@ get_2k_ifconf (struct ifconf *ifc, int what) case SIOCGIFMTU: ifr->ifr_mtu = ifrow->dwMtu; break; + case SIOCGIFINDEX: + ifr->ifr_ifindex = ifrow->dwIndex; + break; } ++cnt; if ((caddr_t)++ ifr > @@ -1461,6 +1464,9 @@ get_nt_ifconf (struct ifconf *ifc, int what) case SIOCGIFMTU: ifr->ifr_mtu = 1500; break; + case SIOCGIFINDEX: + ifr->ifr_ifindex = -1; + break; } } else @@ -1503,6 +1509,9 @@ get_nt_ifconf (struct ifconf *ifc, int what) case SIOCGIFMTU: ifr->ifr_mtu = 1500; break; + case SIOCGIFINDEX: + ifr->ifr_ifindex = -1; + break; } } ++cnt; @@ -1638,6 +1647,9 @@ get_95_ifconf (struct ifconf *ifc, int what) case SIOCGIFMTU: ifr->ifr_mtu = 1500; break; + case SIOCGIFINDEX: + ifr->ifr_ifindex = -1; + break; } } @@ -1747,6 +1759,9 @@ get_ifconf (struct ifconf *ifc, int what) /* Default value for MS TCP Loopback interface. */ ifr->ifr_mtu = 1520; break; + case SIOCGIFINDEX: + ifr->ifr_ifindex = -1; + break; default: set_errno (EINVAL); return -1;