提交 05120a04 编写于 作者: C chegar

6972374: NetworkInterface.getNetworkInterfaces throws "java.net.SocketException" on Solaris zone

Reviewed-by: alanb, dsamersoff
上级 7408cbaa
...@@ -131,7 +131,7 @@ static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *name, s ...@@ -131,7 +131,7 @@ static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *name, s
static short getSubnet(JNIEnv *env, int sock, const char *ifname); static short getSubnet(JNIEnv *env, int sock, const char *ifname);
static int getIndex(int sock, const char *ifname); static int getIndex(int sock, const char *ifname);
static int getFlags(JNIEnv *env, int sock, const char *ifname); static int getFlags(int sock, const char *ifname);
static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf); static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf);
static int getMTU(JNIEnv *env, int sock, const char *ifname); static int getMTU(JNIEnv *env, int sock, const char *ifname);
...@@ -550,7 +550,7 @@ static int getFlags0(JNIEnv *env, jstring name) { ...@@ -550,7 +550,7 @@ static int getFlags0(JNIEnv *env, jstring name) {
name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
ret = getFlags(env, sock, name_utf); ret = getFlags(sock, name_utf);
close(sock); close(sock);
(*env)->ReleaseStringUTFChars(env, name, name_utf); (*env)->ReleaseStringUTFChars(env, name, name_utf);
...@@ -885,7 +885,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc ...@@ -885,7 +885,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc
* the 'parent' interface with the new records. * the 'parent' interface with the new records.
*/ */
*name_colonP = 0; *name_colonP = 0;
if (getFlags(env,sock,name) < 0) { if (getFlags(sock, name) < 0) {
// failed to access parent interface do not create parent. // failed to access parent interface do not create parent.
// We are a virtual interface with no parent. // We are a virtual interface with no parent.
isVirtual = 1; isVirtual = 1;
...@@ -1257,7 +1257,7 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) { ...@@ -1257,7 +1257,7 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
return if2.ifr_mtu; return if2.ifr_mtu;
} }
static int getFlags(JNIEnv *env, int sock, const char *ifname) { static int getFlags(int sock, const char *ifname) {
struct ifreq if2; struct ifreq if2;
int ret = -1; int ret = -1;
...@@ -1633,13 +1633,12 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) { ...@@ -1633,13 +1633,12 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
} }
static int getFlags(JNIEnv *env, int sock, const char *ifname) { static int getFlags(int sock, const char *ifname) {
struct lifreq lifr; struct lifreq lifr;
memset((caddr_t)&lifr, 0, sizeof(lifr)); memset((caddr_t)&lifr, 0, sizeof(lifr));
strcpy((caddr_t)&(lifr.lifr_name), ifname); strcpy((caddr_t)&(lifr.lifr_name), ifname);
if (ioctl(sock, SIOCGLIFFLAGS, (char *)&lifr) < 0) { if (ioctl(sock, SIOCGLIFFLAGS, (char *)&lifr) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL SIOCGLIFFLAGS failed");
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册