提交 ac3a2185 编写于 作者: K khazra

7144274: [macosx] Default IPv6 multicast interface is not being set when...

7144274: [macosx] Default IPv6 multicast interface is not being set when calling MulticastSocket.joinGroup()
Summary: Get default interface for Mac OS X when interface is not set
Reviewed-by: chegar
上级 9342f2b4
......@@ -84,6 +84,7 @@ static jfieldID pdsi_ttlID;
#endif
extern void setDefaultScopeID(JNIEnv *env, struct sockaddr *him);
extern int getDefaultScopeID(JNIEnv *env);
/*
* Returns a java.lang.Integer based on 'i'
......@@ -2418,7 +2419,11 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
}
}
#endif
#ifdef MACOSX
if (family == AF_INET6 && index == 0) {
index = getDefaultScopeID(env);
}
#endif
mname6.ipv6mr_interface = index;
} else {
jint idx = (*env)->GetIntField(env, niObj, ni_indexID);
......
......@@ -109,6 +109,24 @@ void setDefaultScopeID(JNIEnv *env, struct sockaddr *him)
#endif
}
int getDefaultScopeID(JNIEnv *env) {
static jclass ni_class = NULL;
static jfieldID ni_defaultIndexID;
if (ni_class == NULL) {
jclass c = (*env)->FindClass(env, "java/net/NetworkInterface");
CHECK_NULL(c);
c = (*env)->NewGlobalRef(env, c);
CHECK_NULL(c);
ni_defaultIndexID = (*env)->GetStaticFieldID(env, c,
"defaultIndex", "I");
ni_class = c;
}
int defaultIndex = 0;
defaultIndex = (*env)->GetStaticIntField(env, ni_class,
ni_defaultIndexID);
return defaultIndex;
}
#ifdef __solaris__
static int init_tcp_max_buf, init_udp_max_buf;
static int tcp_max_buf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册