116 static jclass ni_ia6cls; |
116 static jclass ni_ia6cls; |
117 static jclass ni_ibcls; |
117 static jclass ni_ibcls; |
118 static jmethodID ni_ia4ctrID; |
118 static jmethodID ni_ia4ctrID; |
119 static jmethodID ni_ia6ctrID; |
119 static jmethodID ni_ia6ctrID; |
120 static jmethodID ni_ibctrID; |
120 static jmethodID ni_ibctrID; |
121 static jfieldID ni_iaaddressID; |
|
122 static jfieldID ni_iafamilyID; |
|
123 static jfieldID ni_ia6ipaddressID; |
121 static jfieldID ni_ia6ipaddressID; |
124 static jfieldID ni_ibaddressID; |
122 static jfieldID ni_ibaddressID; |
125 static jfieldID ni_ib4broadcastID; |
123 static jfieldID ni_ib4broadcastID; |
126 static jfieldID ni_ib4maskID; |
124 static jfieldID ni_ib4maskID; |
127 |
125 |
193 ni_ibcls = (*env)->FindClass(env, "java/net/InterfaceAddress"); |
191 ni_ibcls = (*env)->FindClass(env, "java/net/InterfaceAddress"); |
194 ni_ibcls = (*env)->NewGlobalRef(env, ni_ibcls); |
192 ni_ibcls = (*env)->NewGlobalRef(env, ni_ibcls); |
195 ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V"); |
193 ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V"); |
196 ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V"); |
194 ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V"); |
197 ni_ibctrID = (*env)->GetMethodID(env, ni_ibcls, "<init>", "()V"); |
195 ni_ibctrID = (*env)->GetMethodID(env, ni_ibcls, "<init>", "()V"); |
198 ni_iaaddressID = (*env)->GetFieldID(env, ni_iacls, "address", "I"); |
|
199 ni_iafamilyID = (*env)->GetFieldID(env, ni_iacls, "family", "I"); |
|
200 ni_ia6ipaddressID = (*env)->GetFieldID(env, ni_ia6cls, "ipaddress", "[B"); |
196 ni_ia6ipaddressID = (*env)->GetFieldID(env, ni_ia6cls, "ipaddress", "[B"); |
201 ni_ibaddressID = (*env)->GetFieldID(env, ni_ibcls, "address", "Ljava/net/InetAddress;"); |
197 ni_ibaddressID = (*env)->GetFieldID(env, ni_ibcls, "address", "Ljava/net/InetAddress;"); |
202 ni_ib4broadcastID = (*env)->GetFieldID(env, ni_ibcls, "broadcast", "Ljava/net/Inet4Address;"); |
198 ni_ib4broadcastID = (*env)->GetFieldID(env, ni_ibcls, "broadcast", "Ljava/net/Inet4Address;"); |
203 ni_ib4maskID = (*env)->GetFieldID(env, ni_ibcls, "maskLength", "S"); |
199 ni_ib4maskID = (*env)->GetFieldID(env, ni_ibcls, "maskLength", "S"); |
204 ni_defaultIndexID = (*env)->GetStaticFieldID(env, ni_class, "defaultIndex", "I"); |
200 ni_defaultIndexID = (*env)->GetStaticFieldID(env, ni_class, "defaultIndex", "I"); |
323 while (addrP != NULL) { |
319 while (addrP != NULL) { |
324 |
320 |
325 if (family == addrP->family) { |
321 if (family == addrP->family) { |
326 if (family == AF_INET) { |
322 if (family == AF_INET) { |
327 int address1 = htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr); |
323 int address1 = htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr); |
328 int address2 = (*env)->GetIntField(env, iaObj, ni_iaaddressID); |
324 int address2 = getInetAddress_addr(env, iaObj); |
329 |
325 |
330 if (address1 == address2) { |
326 if (address1 == address2) { |
331 match = JNI_TRUE; |
327 match = JNI_TRUE; |
332 break; |
328 break; |
333 } |
329 } |
649 jobject ibObj = NULL; |
645 jobject ibObj = NULL; |
650 |
646 |
651 if (addrP->family == AF_INET) { |
647 if (addrP->family == AF_INET) { |
652 iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); |
648 iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); |
653 if (iaObj) { |
649 if (iaObj) { |
654 (*env)->SetIntField(env, iaObj, ni_iaaddressID, htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); |
650 setInetAddress_addr(env, iaObj, htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); |
655 } |
651 } |
656 ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID); |
652 ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID); |
657 if (ibObj) { |
653 if (ibObj) { |
658 (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); |
654 (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); |
659 if (addrP->brdcast) { |
655 if (addrP->brdcast) { |
660 jobject ia2Obj = NULL; |
656 jobject ia2Obj = NULL; |
661 ia2Obj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); |
657 ia2Obj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); |
662 if (ia2Obj) { |
658 if (ia2Obj) { |
663 (*env)->SetIntField(env, ia2Obj, ni_iaaddressID, |
659 setInetAddress_addr(env, ia2Obj, htonl(((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); |
664 htonl(((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); |
|
665 (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); |
660 (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); |
666 (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); |
661 (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); |
667 } |
662 } |
668 } |
663 } |
669 (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); |
664 (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); |