提交 72c3a98c 编写于 作者: M michaelm

7079012: test/java/net/NetworkInterface/NetParamsTest.java fails with...

7079012: test/java/net/NetworkInterface/NetParamsTest.java fails with SocketException getting mac address
Reviewed-by: chegar, alanb
上级 cf002e83
......@@ -139,8 +139,12 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname);
#ifdef __solaris__
static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family);
static int getMacFromDevice(JNIEnv *env, const char* ifname, unsigned char* retbuf);
#ifndef SIOCGLIFHWADDR
#define SIOCGLIFHWADDR _IOWR('i', 192, struct lifreq)
#endif
#endif
/******************* Java entry points *****************************/
......@@ -1567,6 +1571,20 @@ static int getMacAddress(JNIEnv *env, int sock, const char *ifname, const struc
struct sockaddr_in* sin;
struct sockaddr_in ipAddr;
int len, i;
struct lifreq lif;
/* First, try the new (S11) SIOCGLIFHWADDR ioctl(). If that fails
* try the old way.
*/
memset(&lif, 0, sizeof(lif));
strlcpy(lif.lifr_name, ifname, sizeof(lif.lifr_name));
if (ioctl(sock, SIOCGLIFHWADDR, &lif) != -1) {
struct sockaddr_dl *sp;
sp = (struct sockaddr_dl *)&lif.lifr_addr;
memcpy(buf, &sp->sdl_data[0], sp->sdl_alen);
return sp->sdl_alen;
}
/**
* On Solaris we have to use DLPI, but it will only work if we have
......@@ -1594,13 +1612,8 @@ static int getMacAddress(JNIEnv *env, int sock, const char *ifname, const struc
arpreq.arp_flags= ATF_PUBL;
if (ioctl(sock, SIOCGARP, &arpreq) < 0) {
if (errno != ENXIO) {
// "No such device or address" means no hardware address, so it's
// normal don't throw an exception
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL failed");
return -1;
}
}
memcpy(buf, &arpreq.arp_ha.sa_data[0], len );
}
......
......@@ -374,9 +374,6 @@ com/sun/net/httpserver/Test9a.java generic-all
# 7079145 java/net/ipv6tests/UdpTest.java hang at IPv6 only data exchange
java/net/ipv6tests/UdpTest.java linux-all
# 7079012
java/net/NetworkInterface/NetParamsTest.java solaris-all
# 7081476
java/net/InetSocketAddress/B6469803.java generic-all
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册