299 300 /* 301 * Class: sun_nio_ch_sctp_SctpNet 302 * Method: preClose0 303 * Signature: (I)V 304 */ 305 JNIEXPORT void JNICALL 306 Java_sun_nio_ch_sctp_SctpNet_preClose0 307 (JNIEnv *env, jclass clazz, jint fd) { 308 if (preCloseFD >= 0) { 309 if (dup2(preCloseFD, fd) < 0) 310 JNU_ThrowIOExceptionWithLastError(env, "dup2 failed"); 311 } 312 } 313 314 void initializeISA 315 (JNIEnv* env) { 316 if (isaCls == 0) { 317 jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress"); 318 CHECK_NULL(c); 319 isaCls = (*env)->NewGlobalRef(env, c); 320 CHECK_NULL(isaCls); 321 (*env)->DeleteLocalRef(env, c); 322 isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>", 323 "(Ljava/net/InetAddress;I)V"); 324 } 325 } 326 327 jobject SockAddrToInetSocketAddress 328 (JNIEnv *env, struct sockaddr* sap) { 329 int port = 0; 330 331 jobject ia = NET_SockaddrToInetAddress(env, sap, &port); 332 if (ia == NULL) 333 return NULL; 334 335 if (isaCls == 0) { 336 initializeISA(env); 337 CHECK_NULL_RETURN(isaCls, NULL); 338 } 339 340 return (*env)->NewObject(env, isaCls, isaCtrID, ia, port); 341 } 342 343 /* | 299 300 /* 301 * Class: sun_nio_ch_sctp_SctpNet 302 * Method: preClose0 303 * Signature: (I)V 304 */ 305 JNIEXPORT void JNICALL 306 Java_sun_nio_ch_sctp_SctpNet_preClose0 307 (JNIEnv *env, jclass clazz, jint fd) { 308 if (preCloseFD >= 0) { 309 if (dup2(preCloseFD, fd) < 0) 310 JNU_ThrowIOExceptionWithLastError(env, "dup2 failed"); 311 } 312 } 313 314 void initializeISA 315 (JNIEnv* env) { 316 if (isaCls == 0) { 317 jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress"); 318 CHECK_NULL(c); 319 isaCtrID = (*env)->GetMethodID(env, c, "<init>", 320 "(Ljava/net/InetAddress;I)V"); 321 CHECK_NULL(isaCtrID); 322 isaCls = (*env)->NewGlobalRef(env, c); 323 CHECK_NULL(isaCls); 324 (*env)->DeleteLocalRef(env, c); 325 } 326 } 327 328 jobject SockAddrToInetSocketAddress 329 (JNIEnv *env, struct sockaddr* sap) { 330 int port = 0; 331 332 jobject ia = NET_SockaddrToInetAddress(env, sap, &port); 333 if (ia == NULL) 334 return NULL; 335 336 if (isaCls == 0) { 337 initializeISA(env); 338 CHECK_NULL_RETURN(isaCls, NULL); 339 } 340 341 return (*env)->NewObject(env, isaCls, isaCtrID, ia, port); 342 } 343 344 /* |