Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/OSNetworkSystem.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/OSNetworkSystem.h?rev=375250&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/OSNetworkSystem.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/OSNetworkSystem.h Mon Feb 6 03:19:15 2006
@@ -0,0 +1,365 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <jni.h>
+/* Header for class com_ibm_platform_OSNetworkSystem */
+#define SOCKET_CONNECT_STEP_START 0
+#define SOCKET_CONNECT_STEP_CHECK 1
+#define SOCKET_OP_NONE 0
+#define SOCKET_OP_READ 1
+#define SOCKET_OP_WRITE 2
+#define SOCKET_READ_WRITE 3
+
+
+#ifndef _Included_com_ibm_platform_OSNetworkSystem
+#define _Included_com_ibm_platform_OSNetworkSystem
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: oneTimeInitializationDatagram
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_oneTimeInitializationDatagram
+ (JNIEnv *, jclass, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: oneTimeInitializationSocket
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_oneTimeInitializationSocket
+ (JNIEnv *, jclass, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createDatagramSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createDatagramSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: readSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_readSocketImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: writeSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_writeSocketImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: setNonBlockingImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_setNonBlockingImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;ILjava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_connectSocketImpl
+ (JNIEnv *, jclass, jobject, jint, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectWithTimeoutSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;IILjava/net/InetAddress;IILjava/lang/Long;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_connectWithTimeoutSocketImpl
+ (JNIEnv *, jclass, jobject, jint, jint, jobject, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectStreamWithTimeoutSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;IIILjava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_connectStreamWithTimeoutSocketImpl
+ (JNIEnv *, jclass, jobject, jint, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: socketBindImpl
+ * Signature: (Ljava/io/FileDescriptor;ILjava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_socketBindImpl
+ (JNIEnv *, jclass, jobject, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: listenStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;I)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_listenStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: availableStreamImpl
+ * Signature: (Ljava/io/FileDescriptor;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_availableStreamImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: acceptSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/SocketImpl;Ljava/io/FileDescriptor;I)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_acceptSocketImpl
+ (JNIEnv *, jclass, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: supportsUrgentDataImpl
+ * Signature: (Ljava/io/FileDescriptor;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_ibm_platform_OSNetworkSystem_supportsUrgentDataImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendUrgentDataImpl
+ * Signature: (Ljava/io/FileDescriptor;B)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_sendUrgentDataImpl
+ (JNIEnv *, jclass, jobject, jbyte);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectDatagramImpl2
+ * Signature: (Ljava/io/FileDescriptor;IILjava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_connectDatagramImpl2
+ (JNIEnv *, jclass, jobject, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: disconnectDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_disconnectDatagramImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: socketBindImpl2
+ * Signature: (Ljava/io/FileDescriptor;IZLjava/net/InetAddress;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_ibm_platform_OSNetworkSystem_socketBindImpl2
+ (JNIEnv *, jclass, jobject, jint, jboolean, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: peekDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_peekDatagramImpl
+ (JNIEnv *, jclass, jobject, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: receiveDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/DatagramPacket;[BIIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_receiveDatagramImpl
+ (JNIEnv *, jclass, jobject, jobject, jbyteArray, jint, jint, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: recvConnectedDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/DatagramPacket;[BIIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_recvConnectedDatagramImpl
+ (JNIEnv *, jclass, jobject, jobject, jbyteArray, jint, jint, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIIIZILjava/net/InetAddress;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendDatagramImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint, jboolean, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendConnectedDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendConnectedDatagramImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createServerStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createServerStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createMulticastSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createMulticastSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: receiveStreamImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_receiveStreamImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendStreamImpl
+ * Signature: (Ljava/io/FileDescriptor;[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendStreamImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: shutdownInputImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_shutdownInputImpl
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: shutdownOutputImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_shutdownOutputImpl
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: acceptStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/SocketImpl;Ljava/io/FileDescriptor;I)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_acceptStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendDatagramImpl2
+ * Signature: (Ljava/io/FileDescriptor;[BIIILjava/net/InetAddress;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendDatagramImpl2
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: selectImpl
+ * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_selectImpl
+ (JNIEnv *, jclass, jobjectArray, jobjectArray, jint, jint, jintArray, jlong);
+
+ /*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketLocalAddressImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)Ljava/net/InetAddress;
+ */
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketLocalAddressImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketLocalPortImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketLocalPortImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketOptionImpl
+ * Signature: (Ljava/io/FileDescriptor;I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketOptionImpl
+ (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: setSocketOptionImpl
+ * Signature: (Ljava/io/FileDescriptor;ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_setSocketOptionImpl
+ (JNIEnv *, jclass, jobject, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketFlags
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketFlagsImpl
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: socketCloseImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_socketCloseImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getHostByAddrImpl
+ * Signature: ([B)Ljava/net/InetAddress;
+ */
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getHostByAddrImpl
+ (JNIEnv *, jclass, jbyteArray);
+
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getHostByNameImpl
+ (JNIEnv *, jclass,jstring,jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.c?rev=375250&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.c Mon Feb 6 03:19:15 2006
@@ -0,0 +1,211 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <utime.h>
+
+#include <string.h>
+#include <time.h>
+#include <locale.h>
+
+#include <langinfo.h>
+
+#include <dirent.h>
+
+#include "helpers.h"
+#include "jclprots.h"
+#include "jclglob.h"
+
+int portCmp (const void **a, const void **b);
+
+/**
+ * It is the responsibility of #getPlatformRoots to return a char array
+ * with volume names separated by null with a trailing extra null, so for
+ * Unix it should be '\<null><null>' .
+ */
+I_32
+getPlatformRoots (char *rootStrings)
+{
+ rootStrings[0] = (char) '/';
+ rootStrings[1] = (char) NULL;
+ rootStrings[2] = (char) NULL;
+ return 1;
+}
+
+/**
+ * Answer 1 if the path is hidden, 0 otherwise even in fail cases.
+ */
+I_32
+getPlatformIsHidden (JNIEnv * env, char *path)
+{
+ PORT_ACCESS_FROM_ENV (env);
+
+ /* Answer true if the file exists and starts with a period */
+ I_32 length = strlen (path), index, existsResult;
+ existsResult = hyfile_attr (path);
+ if (existsResult < 0)
+ return 0;
+
+ if (length == 0)
+ return 0;
+ for (index = length; index >= 0; index--)
+ {
+ if (path[index] == '.' && (index > 0 && path[index - 1] == '/'))
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * Answer 1 if the file time was updated, 0 otherwise even in fail cases.
+ */
+I_32
+setPlatformLastModified (JNIEnv * env, char *path, I_64 time)
+{
+
+ PORT_ACCESS_FROM_ENV (env);
+ struct stat statbuf;
+ struct utimbuf timebuf;
+ if (stat (path, &statbuf))
+ return FALSE;
+ timebuf.actime = statbuf.st_atime;
+ timebuf.modtime = (time_t) (time / 1000);
+ return utime (path, &timebuf) == 0;
+
+}
+
+/**
+ * Answer 1 if the path is now readOnly, 0 otherwise even in fail cases.
+ */
+I_32
+setPlatformReadOnly (JNIEnv * env, char *path)
+{
+ struct stat buffer;
+ mode_t mode;
+ if (stat (path, &buffer))
+ {
+ return 0;
+ }
+ mode = buffer.st_mode;
+ mode = mode & 07555;
+ return chmod (path, mode) == 0;
+
+}
+
+/**
+ * Answer 1 if the file length was set, 0 otherwise even in fail cases.
+ */
+I_32
+setPlatformFileLength (JNIEnv * env, IDATA descriptor, jlong newLength)
+{
+
+ return (ftruncate ((int) descriptor, newLength) == 0);
+
+}
+
+jbyteArray
+getPlatformPath (JNIEnv * env, jbyteArray path)
+{
+ return NULL;
+}
+
+void
+setPlatformBindOptions (JNIEnv * env, hysocket_t socketP)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ BOOLEAN value = TRUE;
+
+ hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);
+}
+
+/**
+ * Answer 1 if the path is read-only, 0 otherwise even in fail cases.
+ */
+I_32
+getPlatformIsReadOnly (JNIEnv * env, char *path)
+{
+ I_32 result;
+ struct stat buffer;
+
+ result = stat (path, &buffer);
+ if (result == -1)
+ return 0;
+
+ if (buffer.st_uid == geteuid ())
+ return (buffer.st_mode & S_IWUSR) == 0;
+ else if (buffer.st_gid == getegid ())
+ return (buffer.st_mode & S_IWGRP) == 0;
+
+ return (buffer.st_mode & S_IWOTH) == 0;
+
+}
+
+/**
+ * Answer 1 if the path is write-only, 0 otherwise even in fail cases.
+ */
+I_32
+getPlatformIsWriteOnly (JNIEnv * env, char *path)
+{
+ I_32 result;
+ struct stat buffer;
+
+ result = stat (path, &buffer);
+ if (result == -1)
+ return 0;
+
+ if (buffer.st_uid == geteuid ())
+ return (buffer.st_mode & S_IRUSR) == 0;
+ else if (buffer.st_gid == getegid ())
+ return (buffer.st_mode & S_IRGRP) == 0;
+
+ return (buffer.st_mode & S_IROTH) == 0;
+
+}
+
+/* Resolve link if it is a symbolic link and put the result in link. */
+int
+platformReadLink (char *link)
+{
+
+ int size = readlink (link, link, HyMaxPath);
+ if (size <= 0)
+ return FALSE;
+ if (size >= HyMaxPath)
+ link[HyMaxPath - 1] = 0;
+ else
+ link[size] = 0;
+ return TRUE;
+
+}
+
+jstring
+getCustomTimeZoneInfo (JNIEnv * env, jintArray tzinfo,
+ jbooleanArray isCustomTimeZone)
+{
+ return NULL;
+}
+
+void
+setDefaultServerSocketOptions (JNIEnv * env, hysocket_t socketP)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ BOOLEAN value = TRUE;
+
+ hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);
+}
Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.h?rev=375250&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/helpers.h Mon Feb 6 03:19:15 2006
@@ -0,0 +1,36 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(helpers_h)
+#define helpers_h
+#include "jcl.h"
+int platformReadLink (char *link);
+jbyteArray getPlatformPath (JNIEnv * env, jbyteArray path);
+void setDefaultServerSocketOptions (JNIEnv * env, hysocket_t socketP);
+I_32 getPlatformRoots (char *rootStrings);
+char *getCommports (JNIEnv * env);
+jint getPlatformDatagramNominalSize (JNIEnv * env, hysocket_t socketP);
+I_32 getPlatformIsHidden (JNIEnv * env, char *path);
+jstring getCustomTimeZoneInfo (JNIEnv * env, jintArray tzinfo,
+ jbooleanArray isCustomTimeZone);
+jint getPlatformDatagramMaxSize (JNIEnv * env, hysocket_t socketP);
+I_32 getPlatformIsWriteOnly (JNIEnv * env, char *path);
+I_32 setPlatformFileLength (JNIEnv * env, IDATA descriptor, jlong newLength);
+I_32 getPlatformIsReadOnly (JNIEnv * env, char *path);
+void setPlatformBindOptions (JNIEnv * env, hysocket_t socketP);
+I_32 setPlatformLastModified (JNIEnv * env, char *path, I_64 time);
+I_32 setPlatformReadOnly (JNIEnv * env, char *path);
+int portCmp (const void **a, const void **b);
+#endif /* helpers_h */
Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/hynio.exp
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/hynio.exp?rev=375250&r1=375249&r2=375250&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/hynio.exp (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/hynio.exp Mon Feb 6 03:19:15 2006
@@ -31,5 +31,46 @@
Java_com_ibm_platform_OSMemory_setFloat;
Java_com_ibm_platform_OSMemory_getDouble;
Java_com_ibm_platform_OSMemory_setDouble;
+ Java_com_ibm_platform_OSNetworkSystem_createSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_createDatagramSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_readSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_writeSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_setNonBlockingImpl;
+ Java_com_ibm_platform_OSNetworkSystem_connectSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_connectWithTimeoutSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_connectStreamWithTimeoutSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_socketBindImpl;
+ Java_com_ibm_platform_OSNetworkSystem_listenStreamSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_availableStreamImpl;
+ Java_com_ibm_platform_OSNetworkSystem_acceptSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_supportsUrgentDataImpl;
+ Java_com_ibm_platform_OSNetworkSystem_sendUrgentDataImpl;
+ Java_com_ibm_platform_OSNetworkSystem_connectDatagramImpl2;
+ Java_com_ibm_platform_OSNetworkSystem_disconnectDatagramImpl;
+ Java_com_ibm_platform_OSNetworkSystem_socketBindImpl2;
+ Java_com_ibm_platform_OSNetworkSystem_peekDatagramImpl;
+ Java_com_ibm_platform_OSNetworkSystem_receiveDatagramImpl;
+ Java_com_ibm_platform_OSNetworkSystem_recvConnectedDatagramImpl;
+ Java_com_ibm_platform_OSNetworkSystem_sendDatagramImpl;
+ Java_com_ibm_platform_OSNetworkSystem_sendConnectedDatagramImpl;
+ Java_com_ibm_platform_OSNetworkSystem_createServerStreamSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_createMulticastSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_receiveStreamImpl;
+ Java_com_ibm_platform_OSNetworkSystem_sendStreamImpl;
+ Java_com_ibm_platform_OSNetworkSystem_shutdownInputImpl;
+ Java_com_ibm_platform_OSNetworkSystem_shutdownOutputImpl;
+ Java_com_ibm_platform_OSNetworkSystem_acceptStreamSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_createStreamSocketImpl;
+ Java_com_ibm_platform_OSNetworkSystem_sendDatagramImpl2;
+ Java_com_ibm_platform_OSNetworkSystem_selectImpl;
+ Java_com_ibm_platform_OSNetworkSystem_getSocketLocalAddressImpl;
+ Java_com_ibm_platform_OSNetworkSystem_getSocketLocalPortImpl;
+ Java_com_ibm_platform_OSNetworkSystem_getSocketOptionImpl;
+ Java_com_ibm_platform_OSNetworkSystem_setSocketOptionImpl;
+ Java_com_ibm_platform_OSNetworkSystem_getSocketFlagsImpl;
+ Java_com_ibm_platform_OSNetworkSystem_socketCloseImpl;
+ Java_com_ibm_platform_OSNetworkSystem_getHostByAddrImpl;
+ Java_com_ibm_platform_OSNetworkSystem_getHostByNameImpl;
+ Java_com_ibm_platform_OSNetworkSystem_setInetAddressImpl;
local : *;
};
Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/makefile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/makefile?rev=375250&r1=375249&r2=375250&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/makefile (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/makefile Mon Feb 6 03:19:15 2006
@@ -26,11 +26,11 @@
LIBPATH=../lib/# declaration
-CFLAGS=-fpic -O1 -march=pentium3 -DLINUX -D_REENTRANT -DIPv6_FUNCTION_SUPPORT -DHYX86 -I../include -I../zlib -I../zip -I../fdlibm -I../nio $(VMDEBUG)
+CFLAGS=-fpic -O1 -march=pentium3 -DLINUX -D_REENTRANT -DIPv6_FUNCTION_SUPPORT -DHYX86 -I../include -I../common -I../zlib -I../zip -I../fdlibm -I../nio $(VMDEBUG)
.SUFFIXES:.cpp
.cpp.o:
- $(CXX) -fpic -O1 -march=pentium3 -fno-exceptions -fno-rtti -DLINUX -D_REENTRANT -DIPv6_FUNCTION_SUPPORT -DHYX86 -I../include -I../zlib -I../zip -I../fdlibm -I../nio $(VMDEBUG) -c $<
+ $(CXX) -fpic -O1 -march=pentium3 -fno-exceptions -fno-rtti -DLINUX -D_REENTRANT -DIPv6_FUNCTION_SUPPORT -DHYX86 -I../include -I../common -I../zlib -I../zip -I../fdlibm -I../nio $(VMDEBUG) -c $<
ASFLAGS= -o $@
@@ -40,9 +40,9 @@
$(AS) $(ASFLAGS) -o $*.o $*.s
-rm $*.s
-BUILDFILES1 = nio_copyright.o
-BUILDFILES2 = OSFileSystem.o OSFileSystemLinux32.o OSMemory.o OSMemoryLinux32.o
-
+BUILDFILES1 = nio_copyright.o helpers.o
+BUILDFILES2 = OSFileSystem.o OSFileSystemLinux32.o OSMemory.o OSMemoryLinux32.o nethelp.o OSNetworkSystem.o socket.o
+
MDLLIBFILES1 = ../libhysig.so ../lib/libhyzip.a ../libhyzlib.so ../lib/libhycommon.a ../lib/libhypool.a
MDLLIBFILES2 = ../lib/libhyfdlibm.a ../libhythr.so ../libvmi.so
Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.c?rev=375250&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.c Mon Feb 6 03:19:15 2006
@@ -0,0 +1,1681 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "nethelp.h"
+//#include "jclglob.h"
+#include "portsock.h"
+#include "hyport.h"
+
+void throwJavaNetBindException (JNIEnv * env, I_32 errorNumber);
+jobject newJavaNetInetAddressGenericBS (JNIEnv * env, jbyte * address,
+ U_32 length, char *hostName,
+ U_32 scope_id);
+void throwJavaNetUnknownHostException (JNIEnv * env, I_32 errorNumber);
+jobject newJavaNetInetAddressGenericB (JNIEnv * env, jbyte * address,
+ U_32 length, U_32 scope_id);
+jobject newJavaLangByte (JNIEnv * env, U_8 aByte);
+U_8 byteValue (JNIEnv * env, jobject aByte);
+I_32 intValue (JNIEnv * env, jobject anInteger);
+void throwJavaNetPortUnreachableException (JNIEnv * env, I_32 errorNumber);
+jobject newJavaByteArray (JNIEnv * env, jbyte * bytes, jint length);
+jobjectArray createAliasArrayFromAddrinfo (JNIEnv * env,
+ hyaddrinfo_t addresses,
+ char *hName);
+BOOLEAN booleanValue (JNIEnv * env, jobject aBoolean);
+BOOLEAN jcl_supports_ipv6 (JNIEnv * env);
+jobject newJavaLangInteger (JNIEnv * env, I_32 anInt);
+BOOLEAN preferIPv4Stack (JNIEnv * env);
+char *netLookupErrorString (JNIEnv * env, I_32 anErrorNum);
+void netInitializeIDCaches (JNIEnv * env, jboolean ipv6_support);
+jobject newJavaLangBoolean (JNIEnv * env, BOOLEAN aBool);
+void throwJavaLangIllegalArgumentException (JNIEnv * env, I_32 errorNumber);
+void netGetJavaNetInetAddressValue (JNIEnv * env, jobject anInetAddress,
+ U_8 * buffer, U_32 * length);
+void throwJavaIoInterruptedIOException (JNIEnv * env, I_32 errorNumber);
+void throwJavaNetSocketTimeoutException (JNIEnv * env, I_32 errorNumber);
+void callThreadYield (JNIEnv * env);
+void throwJavaNetConnectException (JNIEnv * env, I_32 errorNumber);
+void netGetJavaNetInetAddressScopeId (JNIEnv * env, jobject anInetAddress,
+ U_32 * scope_id);
+BOOLEAN preferIPv6Addresses (JNIEnv * env);
+jobjectArray createAliasArray (JNIEnv * env, jbyte ** addresses,
+ I_32 * family, U_32 count, char *hName,
+ U_32 * scope_id_array);
+void throwJavaNetSocketException (JNIEnv * env, I_32 errorNumber);
+I_32 netGetSockAddr (JNIEnv * env, jobject fileDescriptor,
+ hysockaddr_t sockaddrP, jboolean preferIPv6Addresses);
+
+//--------------------------------------
+//reflect function
+//--------------------------------------
+jclass
+getJavaLangBooleanClass(JNIEnv * env);
+
+jmethodID
+getJavaLangBooleanInit(JNIEnv * env);
+
+jfieldID
+getJavaLangBooleanValue(JNIEnv * env);
+
+jclass
+getJavaLangByteClass(JNIEnv * env);
+
+jmethodID
+getJavaLangByteInit(JNIEnv * env);
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env);
+
+jclass
+getJavaLangIntegerClass(JNIEnv * env);
+
+jmethodID
+getJavaLangIntegerInit(JNIEnv * env);
+
+jfieldID
+getJavaLangIntegerValue(JNIEnv * env);
+
+jclass
+getJavaNetInetAddressClass(JNIEnv * env);
+
+jfieldID
+getJavaNetInetAddressIpaddress(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressPreferIPv6Addresses(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressStringByte(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressByteArray(JNIEnv * env);
+jmethodID
+getJavaNetInetAddressInitByteArray(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressInitByteString(JNIEnv * env);
+
+jclass
+getJavaNetSocketClass(JNIEnv * env);
+
+jmethodID
+getJavaNetSocketPreferIPv4Stack(JNIEnv * env);
+
+jclass
+getJavaLangThreadClass(JNIEnv * env);
+
+jmethodID
+getJavaLangThreadYield(JNIEnv * env);
+
+jclass
+getJavaNetDatagramPacketClass(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketLength(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketPort(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplPort(JNIEnv * env);
+
+
+
+/**
+ * Set the exception state of the VM with a new java.lang.IllegalArgumentException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaLangIllegalArgumentException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/lang/IllegalArgumentException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+
+}
+
+/**
+ * Set the exception state of the VM with a new java.net.BindException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaNetBindException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/net/BindException");
+ if (0 == aClass)
+ {
+ (*env)->ExceptionClear (env);
+ aClass = (*env)->FindClass (env, "java/net/SocketException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+}
+
+/**
+ * Set the exception state of the VM with a new java.net.ConnectException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaNetConnectException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/net/ConnectException");
+ if (0 == aClass)
+ {
+ (*env)->ExceptionClear (env);
+ aClass = (*env)->FindClass (env, "java/net/SocketException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+}
+
+/**
+ * Set the exception state of the VM with a new java.net.SocketException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaNetSocketException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/net/SocketException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+
+}
+
+/**
+ * Set the exception state of the VM with a new java.net.UnknownHostException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaNetUnknownHostException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ char *errorMessage;
+ if (errorNumber == HYPORT_ERROR_SOCKET_SYSTEMFULL)
+ {
+ throwNewOutOfMemoryError (env, "");
+ return;
+ }
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/net/UnknownHostException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+
+}
+
+/**
+ * Set the exception state of the VM with a new java.io.InterruptedIOException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaIoInterruptedIOException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/io/InterruptedIOException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+
+}
+
+/**
+ * Answer a new java.lang.Boolean object.
+ *
+ * @param env pointer to the JNI library
+ * @param aBool the Boolean constructor argument
+ *
+ * @return the new Boolean
+ */
+
+jobject
+newJavaLangBoolean (JNIEnv * env, BOOLEAN aBool)
+{
+ jclass tempClass;
+ jmethodID tempMethod;
+
+ //tempClass = JCL_CACHE_GET (env, CLS_java_lang_Boolean);
+ tempClass = getJavaLangBooleanClass(env);
+ //tempMethod = JCL_CACHE_GET (env, MID_java_lang_Boolean_init);
+ tempMethod = getJavaLangBooleanInit(env);
+ return (*env)->NewObject (env, tempClass, tempMethod, (jboolean) aBool);
+}
+
+/**
+ * Answer a new java.lang.Byte object.
+ *
+ * @param env pointer to the JNI library
+ * @param aByte the Byte constructor argument
+ *
+ * @return the new Byte
+ */
+
+jobject
+newJavaLangByte (JNIEnv * env, U_8 aByte)
+{
+ jclass tempClass;
+ jmethodID tempMethod;
+
+ //tempClass = JCL_CACHE_GET (env, CLS_java_lang_Byte);
+ tempClass = getJavaLangByteClass(env);
+ tempMethod = getJavaLangByteInit(env);
+ //tempMethod = JCL_CACHE_GET (env, MID_java_lang_Byte_init);
+ return (*env)->NewObject (env, tempClass, tempMethod, (jbyte) aByte);
+}
+
+/**
+ * Answer a new java.lang.Integer object.
+ *
+ * @param env pointer to the JNI library
+ * @param anInt the Integer constructor argument
+ *
+ * @return the new Integer
+ */
+
+jobject
+newJavaLangInteger (JNIEnv * env, I_32 anInt)
+{
+ jclass tempClass;
+ jmethodID tempMethod;
+
+ //tempClass = JCL_CACHE_GET (env, CLS_java_lang_Integer);
+ //tempMethod = JCL_CACHE_GET (env, MID_java_lang_Integer_init);
+ tempClass = getJavaLangIntegerClass(env);
+ tempMethod = getJavaLangIntegerInit(env);
+ return (*env)->NewObject (env, tempClass, tempMethod, (jint) anInt);
+}
+
+/**
+ * Answer the network address structure for this socket. A helper method, used
+ * to later query a socket bound to the default address/port. See the
+ * Java_java_net_Socket_netGetSocketLocalAddress/Port functions.
+ *
+ * @param env pointer to the JNI library
+ * @param fileDescriptor pointer to the socket file descriptor
+ * @param sockAddrResult pointer pointer to the sockaddr struct to return the address in
+ * @param preferIPv6Addresses on V4/V6 nodes, a preference as to which address to return for the node
+ *
+ * @return 0, if no errors occurred, otherwise the (negative) error code
+ */
+
+I_32
+netGetSockAddr (JNIEnv * env, jobject fileDescriptor, hysockaddr_t sockaddrP,
+ jboolean preferIPv6Addresses)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ I_32 result = 0;
+ hysocket_t socketP;
+ U_8 ipAddr[HYSOCK_INADDR6_LEN];
+ memset (ipAddr, 0, HYSOCK_INADDR6_LEN);
+
+ socketP = getJavaIoFileDescriptorContentsAsAPointer (env, fileDescriptor);
+ if (!hysock_socketIsValid (socketP))
+ {
+ return HYPORT_ERROR_SOCKET_UNKNOWNSOCKET;
+ }
+ else
+ {
+ if (preferIPv6Addresses)
+ {
+ hysock_sockaddr_init6 (sockaddrP, ipAddr, HYSOCK_INADDR6_LEN,
+ HYADDR_FAMILY_UNSPEC, 0, 0, 0, socketP);
+ result = hysock_getsockname (socketP, sockaddrP);
+ }
+ else
+ {
+ hysock_sockaddr_init6 (sockaddrP, ipAddr, HYSOCK_INADDR_LEN,
+ HYADDR_FAMILY_AFINET4, 0, 0, 0, socketP);
+ result = hysock_getsockname (socketP, sockaddrP);
+ }
+ return result;
+ }
+}
+
+/**
+ * Answer the 'value' field value from a java.lang.Boolean
+ *
+ * @param env pointer to the JNI library
+ * @param aBoolean the object to access the 'value' field of
+ *
+ * @return the 'value' field boolean value (completion status is not returned)
+ */
+
+BOOLEAN
+booleanValue (JNIEnv * env, jobject aBoolean)
+{
+ //return (BOOLEAN) ((*env)->
+ // GetBooleanField (env, aBoolean,
+ // JCL_CACHE_GET (env,
+ // FID_java_lang_Boolean_value)));
+ return (BOOLEAN) ((*env)->
+ GetBooleanField (env, aBoolean,
+ getJavaLangBooleanValue(env)));
+}
+
+/**
+ * Answer the 'value' field value from a java.lang.Byte
+ *
+ * @param env pointer to the JNI library
+ * @param aByte the object to access the 'value' field of
+ *
+ * @return the 'value' field byte value (completion status is not returned)
+ */
+
+U_8
+byteValue (JNIEnv * env, jobject aByte)
+{
+ //return (U_8) ((*env)->
+ // GetByteField (env, aByte,
+ // JCL_CACHE_GET (env, FID_java_lang_Byte_value)));
+ return (U_8) ((*env)->
+ GetByteField (env, aByte,
+ getJavaLangByteValue(env)));
+}
+
+/**
+ * Answer the 'value' field value from a java.lang.Integer
+ *
+ * @param env pointer to the JNI library
+ * @param anInteger the object to access the 'value' field of
+ *
+ * @return the 'value' field integer value (completion status is not returned)
+ */
+
+I_32
+intValue (JNIEnv * env, jobject anInteger)
+{
+ //return (I_32) ((*env)->
+ // GetIntField (env, anInteger,
+ // JCL_CACHE_GET (env,
+ // FID_java_lang_Integer_value)));
+ return (I_32) ((*env)->
+ GetIntField (env, anInteger,
+ getJavaLangIntegerValue(env)));
+}
+
+/**
+ * Answer the errorString corresponding to the errorNumber, if available.
+ * This function will answer a default error string, if the errorNumber is not
+ * recognized.
+ *
+ * This function will have to be reworked to handle internationalization properly, removing
+ * the explicit strings.
+ *
+ * @param anErrorNum the error code to resolve to a human readable string
+ *
+ * @return a human readable error string
+ */
+
+char *
+netLookupErrorString (JNIEnv * env, I_32 anErrorNum)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ switch (anErrorNum)
+ {
+ case HYPORT_ERROR_SOCKET_BADSOCKET:
+ return "Bad socket";
+ case HYPORT_ERROR_SOCKET_NOTINITIALIZED:
+ return "Socket library uninitialized";
+ case HYPORT_ERROR_SOCKET_BADAF:
+ return "Bad address family";
+ case HYPORT_ERROR_SOCKET_BADPROTO:
+ return "Bad protocol";
+ case HYPORT_ERROR_SOCKET_BADTYPE:
+ return "Bad type";
+ case HYPORT_ERROR_SOCKET_SYSTEMBUSY:
+ return "System busy handling requests";
+ case HYPORT_ERROR_SOCKET_SYSTEMFULL:
+ return "Too many sockets allocated";
+ case HYPORT_ERROR_SOCKET_NOTCONNECTED:
+ return "Socket is not connected";
+ case HYPORT_ERROR_SOCKET_INTERRUPTED:
+ return "The call was cancelled";
+ case HYPORT_ERROR_SOCKET_TIMEOUT:
+ return "The operation timed out";
+ case HYPORT_ERROR_SOCKET_CONNRESET:
+ return "The connection was reset";
+ case HYPORT_ERROR_SOCKET_WOULDBLOCK:
+ return "The socket is marked as nonblocking operation would block";
+ case HYPORT_ERROR_SOCKET_ADDRNOTAVAIL:
+ return "The address is not available";
+ case HYPORT_ERROR_SOCKET_ADDRINUSE:
+ return "The address is already in use";
+ case HYPORT_ERROR_SOCKET_NOTBOUND:
+ return "The socket is not bound";
+ case HYPORT_ERROR_SOCKET_UNKNOWNSOCKET:
+ return "Resolution of the FileDescriptor to socket failed";
+ case HYPORT_ERROR_SOCKET_INVALIDTIMEOUT:
+ return "The specified timeout is invalid";
+ case HYPORT_ERROR_SOCKET_FDSETFULL:
+ return "Unable to create an FDSET";
+ case HYPORT_ERROR_SOCKET_TIMEVALFULL:
+ return "Unable to create a TIMEVAL";
+ case HYPORT_ERROR_SOCKET_REMSOCKSHUTDOWN:
+ return "The remote socket has shutdown gracefully";
+ case HYPORT_ERROR_SOCKET_NOTLISTENING:
+ return "Listen() was not invoked prior to accept()";
+ case HYPORT_ERROR_SOCKET_NOTSTREAMSOCK:
+ return "The socket does not support connection-oriented service";
+ case HYPORT_ERROR_SOCKET_ALREADYBOUND:
+ return "The socket is already bound to an address";
+ case HYPORT_ERROR_SOCKET_NBWITHLINGER:
+ return "The socket is marked non-blocking & SO_LINGER is non-zero";
+ case HYPORT_ERROR_SOCKET_ISCONNECTED:
+ return "The socket is already connected";
+ case HYPORT_ERROR_SOCKET_NOBUFFERS:
+ return "No buffer space is available";
+ case HYPORT_ERROR_SOCKET_HOSTNOTFOUND:
+ return "Authoritative Answer Host not found";
+ case HYPORT_ERROR_SOCKET_NODATA:
+ return "Valid name, no data record of requested type";
+ case HYPORT_ERROR_SOCKET_BOUNDORCONN:
+ return "The socket has not been bound or is already connected";
+ case HYPORT_ERROR_SOCKET_OPNOTSUPP:
+ return "The socket does not support the operation";
+ case HYPORT_ERROR_SOCKET_OPTUNSUPP:
+ return "The socket option is not supported";
+ case HYPORT_ERROR_SOCKET_OPTARGSINVALID:
+ return "The socket option arguments are invalid";
+ case HYPORT_ERROR_SOCKET_SOCKLEVELINVALID:
+ return "The socket level is invalid";
+ case HYPORT_ERROR_SOCKET_TIMEOUTFAILURE:
+ return "The timeout operation failed";
+ case HYPORT_ERROR_SOCKET_SOCKADDRALLOCFAIL:
+ return "Failed to allocate address structure";
+ case HYPORT_ERROR_SOCKET_FDSET_SIZEBAD:
+ return "The calculated maximum size of the file descriptor set is bad";
+ case HYPORT_ERROR_SOCKET_UNKNOWNFLAG:
+ return "The flag is unknown";
+ case HYPORT_ERROR_SOCKET_MSGSIZE:
+ return
+ "The datagram was too big to fit the specified buffer, so truncated";
+ case HYPORT_ERROR_SOCKET_NORECOVERY:
+ return "The operation failed with no recovery possible";
+ case HYPORT_ERROR_SOCKET_ARGSINVALID:
+ return "The arguments are invalid";
+ case HYPORT_ERROR_SOCKET_BADDESC:
+ return "The socket argument is not a valid file descriptor";
+ case HYPORT_ERROR_SOCKET_NOTSOCK:
+ return "The socket argument is not a socket";
+ case HYPORT_ERROR_SOCKET_HOSTENTALLOCFAIL:
+ return "Unable to allocate the hostent structure";
+ case HYPORT_ERROR_SOCKET_TIMEVALALLOCFAIL:
+ return "Unable to allocate the timeval structure";
+ case HYPORT_ERROR_SOCKET_LINGERALLOCFAIL:
+ return "Unable to allocate the linger structure";
+ case HYPORT_ERROR_SOCKET_IPMREQALLOCFAIL:
+ return "Unable to allocate the ipmreq structure";
+ case HYPORT_ERROR_SOCKET_FDSETALLOCFAIL:
+ return "Unable to allocate the fdset structure";
+ case HYPORT_ERROR_SOCKET_CONNECTION_REFUSED:
+ return "Connection refused";
+
+ default:
+ return (char *) hysock_error_message ();
+ }
+}
+
+
+/**
+ * Answer the 'address' field value from a java.net.InetAddress
+ *
+ * @param env pointer to the JNI library
+ * @param anInetAddress the object to access the 'value' field of
+ *
+ * @return the 'address' field integer value (completion status is not returned)
+ */
+
+void
+netGetJavaNetInetAddressValue (JNIEnv * env, jobject anInetAddress,
+ U_8 * buffer, U_32 * length)
+{
+ //jbyteArray byte_array =
+ // (jbyteArray) ((*env)->GetObjectField (env, anInetAddress,
+ // JCL_CACHE_GET (env,
+ // FID_java_net_InetAddress_address)));
+ jbyteArray byte_array =
+ (jbyteArray) ((*env)->GetObjectField (env, anInetAddress,
+ getJavaNetInetAddressIpaddress(env)));
+ *length = (*env)->GetArrayLength (env, byte_array);
+ (*env)->GetByteArrayRegion (env, byte_array, 0, *length, buffer);
+}
+
+/**
+ * Call the java.lang.Thread.yield() method.
+ *
+ * @param env pointer to the JNI library
+ *
+ */
+
+void
+callThreadYield (JNIEnv * env)
+{
+ jmethodID tempMethod;
+ jclass tempClass;
+ jobject globalRef;
+
+ //tempClass = JCL_CACHE_GET (env, CLS_java_lang_Thread);
+ //tempMethod = JCL_CACHE_GET (env, MID_java_lang_Thread_yield);
+ tempClass = getJavaLangThreadClass(env);
+ tempMethod = getJavaLangThreadYield(env);
+ if (tempClass == 0)
+ {
+ tempClass = (*env)->FindClass (env, "java/lang/Thread");
+ if (!tempClass)
+ return;
+ globalRef = (*env)->NewWeakGlobalRef (env, tempClass);
+ if (!globalRef)
+ return;
+ tempMethod = (*env)->GetStaticMethodID (env, tempClass, "yield", "()V");
+ if (!tempMethod)
+ return;
+ //JCL_CACHE_SET (env, CLS_java_lang_Thread, globalRef);
+ //JCL_CACHE_SET (env, MID_java_lang_Thread_yield, tempMethod);
+ }
+ (*env)->CallStaticVoidMethod (env, tempClass, tempMethod);
+}
+
+/**
+ * A helper method, to construct an array of InetAddress's, based upon the nominated host name
+ * and array of alternate addresses. Used by the netGetAliasesByAddr/Name functions. If the host
+ * does not have aliases (only multi-homed hosts do), answer an array with a single InetAddress
+ * constructed from the host name & address.
+ *
+ * @param env pointer to the JNI library
+ * @param addresses an array of host addresses
+ * @param family an array of families matching host addresses
+ * @param count the number of addresses
+ * @param hName the host name
+ * @param h_aliases pointer to the array of alternate addresses
+ * @param scope_id_array scope ids for the addresses
+ *
+ * @return an array of InetAddress's
+ */
+
+jobjectArray
+createAliasArray (JNIEnv * env, jbyte ** addresses, I_32 * family, U_32 count,
+ char *hName, U_32 * scope_id_array)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ U_32 i, length;
+ jobjectArray aliases;
+ jobject element;
+ jclass tempClass = (*env)->FindClass (env, "java/net/InetAddress");
+
+ /* Number of structures */
+ for (i = 0; i < count; i++)
+ {
+
+ /* Create the byte array for the appropriate family and fill it in */
+ if (family[i] == HYADDR_FAMILY_AFINET4)
+ {
+ length = HYSOCK_INADDR_LEN;
+ }
+ else
+ {
+ length = HYSOCK_INADDR6_LEN;
+ }
+
+ element =
+ newJavaNetInetAddressGenericBS (env, addresses[i], length, hName,
+ scope_id_array[i]);
+
+ if (i == 0)
+ {
+ aliases = (*env)->NewObjectArray (env, count, tempClass, element);
+ }
+ else
+ {
+ (*env)->SetObjectArrayElement (env, aliases, i, element);
+ }
+ }
+ return aliases;
+}
+
+/**
+ * A helper method, to construct an array of InetAddress's, based upon the nominated host name
+ * and array of alternate addresses. Used by the netGetAliasesByAddr/Name functions. If the host
+ * does not have aliases (only multi-homed hosts do), answer an array with a single InetAddress
+ * constructed from the host name & address.
+ *
+ * @param env pointer to the JNI library
+ * @param addresses addrinfos to take the ip addresses from
+ * @param hName the host name
+ * @param h_aliases pointer to the array of alternate addresses
+ *
+ * @return an array of InetAddress's
+ */
+
+jobjectArray
+createAliasArrayFromAddrinfo (JNIEnv * env, hyaddrinfo_t addresses,
+ char *hName)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ U_32 count = 0;
+ U_32 i, j;
+ I_32 length = 0;
+ jbyte **aliasList;
+ I_32 *family;
+ U_32 *scope_id_array;
+ U_32 mem_size;
+ BOOLEAN contains;
+ jbyte temp_address[HYSOCK_INADDR6_LEN];
+ jobjectArray inetAddressArray;
+ U_32 scope_id = 0;
+
+ hysock_getaddrinfo_length (addresses, &length);
+
+ /* The array needs to be big enough to hold an aliases and an address for each entry */
+ mem_size = length * sizeof (jbyte *);
+ aliasList = hymem_allocate_memory (mem_size);
+ family = hymem_allocate_memory (length * sizeof (I_32));
+ scope_id_array = hymem_allocate_memory (length * sizeof (U_32));
+ memset (aliasList, 0, mem_size);
+
+ for (i = 0; i < (U_32) length; i++)
+ {
+ memset (temp_address, 0, HYSOCK_INADDR6_LEN);
+ hysock_getaddrinfo_address (addresses, temp_address, i, &scope_id);
+
+ /* On some platforms we get duplicate addresses back for each protocol type,
+ we only want 1 per list, so we're filtering duplicates */
+ contains = FALSE;
+ for (j = 0; j < count; j++)
+ {
+ if (!memcmp (temp_address, aliasList[j], HYSOCK_INADDR6_LEN))
+ {
+ contains = TRUE;
+ }
+ }
+ if (!contains)
+ {
+ aliasList[count] =
+ (U_8 *) hymem_allocate_memory (HYSOCK_INADDR6_LEN);
+ hysock_getaddrinfo_family (addresses, &family[count], i);
+ scope_id_array[count] = scope_id;
+ memcpy (aliasList[count++], temp_address, HYSOCK_INADDR6_LEN);
+ }
+ }
+ inetAddressArray =
+ createAliasArray (env, aliasList, family, count, hName, scope_id_array);
+
+ for (i = 0; i < count; i++)
+ {
+ hymem_free_memory ( aliasList[i]);
+ }
+ hymem_free_memory (family);
+ hymem_free_memory (scope_id_array);
+ hymem_free_memory (aliasList);
+
+ return inetAddressArray;
+}
+
+/**
+ * Answers whether or not the jcl supports IPv6.
+ *
+ * @param env pointer to the JNI library
+ * @return a boolean
+ */
+
+BOOLEAN
+jcl_supports_ipv6 (JNIEnv * env)
+{
+ //return (BOOLEAN) JCL_CACHE_GET (env, jcl_supports_ipv6);
+ //TODO check support
+ return (BOOLEAN) 1;
+}
+
+/**
+ * Answer a new byte[] object.
+ *
+ * @param env pointer to the JNI library
+ * @param bytes bytes to write to the new ByteArray
+ *
+ * @return the new InetAddress
+ */
+
+jobject
+newJavaByteArray (JNIEnv * env, jbyte * bytes, jint length)
+{
+ jbyteArray byte_array = (*env)->NewByteArray (env, length);
+ if (byte_array == NULL)
+ {
+ return NULL;
+ }
+ (*env)->SetByteArrayRegion (env, byte_array, 0, length, bytes);
+
+ return byte_array;
+}
+
+/**
+ * Answer a new java.net.InetAddress object.
+ *
+ * @param env pointer to the JNI library
+ * @param address the ip address as a byte array, in network order
+ * @param length the number of bytes in the address
+ * @param scope_id the scope id for the address if applicable. Otherwise should be 0
+ *
+ * Determines whether to return a InetAddress in the case of IPv4, or Inet4Address/Inet6Address in the case of IPv6
+ * @return the new InetAddress
+ */
+
+jobject
+newJavaNetInetAddressGenericB (JNIEnv * env, jbyte * address, U_32 length,
+ U_32 scope_id)
+{
+ jclass tempClass;
+ jmethodID tempMethod;
+ jmethodID tempMethodWithScope = NULL;
+ jbyteArray byte_array;
+ BOOLEAN isAnyAddress = 1;
+ static jbyte IPv4ANY[4] = { 0, 0, 0, 0 };
+ static jbyte IPv6ANY[16] =
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ U_32 i = 0;
+
+ /* check if the address being returned is the any address. If so we need to check the prefer flags to see how it should be returned
+ (either as IPv4 Any or IPv6 ANY) */
+
+ if (jcl_supports_ipv6 (env))
+ {
+ /* Figure out if it is the any address */
+ for (i = 0; i < length; i++)
+ {
+ if (address[i] != 0)
+ {
+ isAnyAddress = 0;
+ break;
+ }
+ }
+ }
+ else
+ {
+ /* just do what we used to do without checking */
+ isAnyAddress = 0;
+ }
+
+ /* If it is the any address then set up to return appropriately based on the flags */
+ if (isAnyAddress)
+ {
+ if ((!preferIPv4Stack (env)) && (preferIPv6Addresses (env)))
+ {
+ if ((byte_array =
+ newJavaByteArray (env, IPv6ANY, sizeof (IPv6ANY))) == NULL)
+ {
+ return NULL;
+ }
+ }
+ else
+ {
+ if ((byte_array =
+ newJavaByteArray (env, IPv4ANY, sizeof (IPv4ANY))) == NULL)
+ {
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ /* not any so just set up to return the address normally */
+ if ((byte_array = newJavaByteArray (env, address, length)) == NULL)
+ {
+ return NULL;
+ }
+ }
+
+ if (jcl_supports_ipv6 (env))
+ {
+ tempMethodWithScope = NULL;
+ if (scope_id != 0)
+ {
+ //tempMethodWithScope =
+ // (*env)->GetStaticMethodID (env,
+ // JCL_CACHE_GET (env,
+ // CLS_java_net_InetAddress),
+ // "getByAddress",
+ // "([BI)Ljava/net/InetAddress;");
+ tempMethodWithScope =
+ (*env)->GetStaticMethodID (env,
+ getJavaNetInetAddressClass(env),
+ "getByAddress",
+ "([BI)Ljava/net/InetAddress;");
+ if ((*env)->ExceptionCheck (env))
+ {
+ (*env)->ExceptionClear (env);
+ tempMethodWithScope = NULL;
+ }
+ }
+
+ if (tempMethodWithScope != NULL)
+ {
+ /* create using the scope id */
+ //tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+ tempClass = getJavaNetInetAddressClass(env);
+ return (*env)->CallStaticObjectMethod (env, tempClass,
+ tempMethodWithScope,
+ byte_array, scope_id);
+ }
+ else
+ {
+ //tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+ tempClass = getJavaNetInetAddressClass(env);
+ //tempMethod =
+ // JCL_CACHE_GET (env,
+ // MID_java_net_InetAddress_getByAddress_byteArray);
+ tempMethod = getJavaNetInetAddressGetByAddressByteArray(env);
+ return (*env)->CallStaticObjectMethod (env, tempClass, tempMethod,
+ byte_array);
+ }
+ }
+ else
+ {
+ //tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+ //tempMethod =
+ // JCL_CACHE_GET (env, MID_java_net_InetAddress_init_byteArray);
+ tempClass = getJavaNetInetAddressClass(env);
+ tempMethod = getJavaNetInetAddressInitByteArray(env);
+ return (*env)->NewObject (env, tempClass, tempMethod, byte_array);
+ }
+}
+
+/**
+ * Answer a new java.net.InetAddress object.
+ *
+ * @param env pointer to the JNI library
+ * @param address the ip address as a byte array, in network order
+ * @param length the number of bytes in the address
+ * @param hostName the host name
+ * @param scope_id the scope id for the address if applicable. Otherwise should be 0
+ *
+ * Determines whether to return a InetAddress in the case of IPv4, or Inet4Address/Inet6Address in the case of IPv6
+ * @return the new InetAddress
+ */
+
+jobject
+newJavaNetInetAddressGenericBS (JNIEnv * env, jbyte * address, U_32 length,
+ char *hostName, U_32 scope_id)
+{
+ jclass tempClass;
+ jmethodID tempMethod;
+ jmethodID tempMethodWithScope = NULL;
+ jbyteArray byte_array;
+ jstring aString;
+ BOOLEAN isAnyAddress = 1;
+ static jbyte IPv4ANY[4] = { 0, 0, 0, 0 };
+ static jbyte IPv6ANY[16] =
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ U_32 i = 0;
+
+ aString = (*env)->NewStringUTF (env, hostName);
+
+ /* check if the address being returned is the any address. If so we need to check the prefer flags to see how it should be returned
+ (either as IPv4 Any or IPv6 ANY) */
+
+ if (jcl_supports_ipv6 (env))
+ {
+ /* Figure out if it is the any address */
+ for (i = 0; i < length; i++)
+ {
+ if (address[i] != 0)
+ {
+ isAnyAddress = 0;
+ break;
+ }
+ }
+ }
+ else
+ {
+ /* just do what we used to do without checking */
+ isAnyAddress = 0;
+ }
+
+ /* If it is the any address then set up to return appropriately based on the flags */
+ if (isAnyAddress)
+ {
+ if ((!preferIPv4Stack (env)) && (preferIPv6Addresses (env)))
+ {
+ if ((byte_array =
+ newJavaByteArray (env, IPv6ANY, sizeof (IPv6ANY))) == NULL)
+ {
+ return NULL;
+ }
+ }
+ else
+ {
+ if ((byte_array =
+ newJavaByteArray (env, IPv4ANY, sizeof (IPv4ANY))) == NULL)
+ {
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ /* not any so just set up to return the address normally */
+ if ((byte_array = newJavaByteArray (env, address, length)) == NULL)
+ {
+ return NULL;
+ }
+ }
+
+ if (jcl_supports_ipv6 (env))
+ {
+ tempMethodWithScope = NULL;
+ if (scope_id != 0)
+ {
+ /* tempMethodWithScope =
+ (*env)->GetStaticMethodID (env,
+ JCL_CACHE_GET (env,
+ CLS_java_net_InetAddress),
+ "getByAddress",
+ "(Ljava/lang/String;[BI)Ljava/net/InetAddress;");
+ */
+ tempMethodWithScope =
+ (*env)->GetStaticMethodID (env,
+ getJavaNetInetAddressClass(env),
+ "getByAddress",
+ "(Ljava/lang/String;[BI)Ljava/net/InetAddress;");
+ if ((*env)->ExceptionCheck (env))
+ {
+ (*env)->ExceptionClear (env);
+ tempMethodWithScope = NULL;
+ }
+ }
+
+ if (tempMethodWithScope != NULL)
+ {
+ /* create using the scope id */
+ //tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+ tempClass = getJavaNetInetAddressClass(env);
+ return (*env)->CallStaticObjectMethod (env, tempClass,
+ tempMethodWithScope, aString,
+ byte_array, scope_id);
+ }
+ else
+ {
+ /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+ tempMethod =
+ JCL_CACHE_GET (env,
+ MID_java_net_InetAddress_getByAddress_Ljava_lang_String_byteArray);
+ */
+ tempClass = getJavaNetInetAddressClass(env);
+ tempMethod = getJavaNetInetAddressGetByAddressStringByte(env);
+ return (*env)->CallStaticObjectMethod (env, tempClass, tempMethod,
+ aString, byte_array);
+ }
+ }
+ else
+ {
+ /*tempClass = JCL_CACHE_GET (env, CLS_java_net_InetAddress);
+ tempMethod =
+ JCL_CACHE_GET (env,
+ MID_java_net_InetAddress_init_byteArrayLjava_lang_String);
+ */
+ tempClass = getJavaNetInetAddressClass(env);
+ tempMethod = getJavaNetInetAddressInitByteString(env);
+ return (*env)->NewObject (env, tempClass, tempMethod, byte_array,
+ aString);
+ }
+}
+
+/**
+ * Set the exception state of the VM with a new java.net.PortUnreachableException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaNetPortUnreachableException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/net/PortUnreachableException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+
+}
+
+/**
+ * Set the exception state of the VM with a new java.net.SocketTimeoutException.
+ *
+ * @param env pointer to the JNI library
+ * @param errorNumber the error code which lead to the exception
+ *
+ */
+
+void
+throwJavaNetSocketTimeoutException (JNIEnv * env, I_32 errorNumber)
+{
+ jclass aClass;
+ /* the error message lookup should be done before the FindClass call, because the FindClass call
+ * may reset the error number that is used in hysock_error_message */
+ char *errorMessage = netLookupErrorString (env, errorNumber);
+ aClass = (*env)->FindClass (env, "java/net/SocketTimeoutException");
+ if (0 == aClass)
+ {
+ return;
+ }
+ (*env)->ThrowNew (env, aClass, errorMessage);
+
+}
+
+/**
+ * Answers whether or not we should prefer the IPv4 stack
+ *
+ * @param env pointer to the JNI library
+ * @return a boolean
+ */
+
+BOOLEAN
+preferIPv4Stack (JNIEnv * env)
+{
+ BOOLEAN result = FALSE;
+
+ /* if the jcl does not support IPV6 then just use the IPV4 stack without checking
+ the values of the flags */
+ if (!jcl_supports_ipv6 (env))
+ {
+ return TRUE;
+ }
+
+ /*result =
+ (*env)->CallStaticBooleanMethod (env,
+ JCL_CACHE_GET (env, CLS_java_net_Socket),
+ JCL_CACHE_GET (env,
+ MID_java_net_Socket_preferIPv4Stack));
+ */
+ result =
+ (*env)->CallStaticBooleanMethod (env,
+ getJavaNetSocketClass(env),
+ getJavaNetSocketPreferIPv4Stack(env));
+ if ((*env)->ExceptionCheck (env))
+ {
+ /* older JCLs do not have the right code for security checks so this may fail with an exception
+ just clear the exception and set the value to false which is the default */
+ (*env)->ExceptionClear (env);
+ return FALSE;
+ }
+ else
+ {
+ return result;
+ }
+}
+
+/**
+ * Answers whether or not we should prefer the IPv4 stack
+ *
+ * @param env pointer to the JNI library
+ * @return a boolean
+ */
+
+BOOLEAN
+preferIPv6Addresses (JNIEnv * env)
+{
+ BOOLEAN result = FALSE;
+
+ /* if the jcl does not support IPV6 then we don't prefer IPv6 addresses for any case so just return false
+ without checking the values of the flags */
+ if (!jcl_supports_ipv6 (env))
+ {
+ return FALSE;
+ }
+
+ /*result =
+ (*env)->CallStaticBooleanMethod (env,
+ JCL_CACHE_GET (env,
+ CLS_java_net_InetAddress),
+ JCL_CACHE_GET (env,
+ MID_java_net_InetAddress_preferIPv6Addresses));
+ */
+ result =
+ (*env)->CallStaticBooleanMethod (env,
+ getJavaNetInetAddressClass(env),
+ getJavaNetInetAddressPreferIPv6Addresses(env));
+ if ((*env)->ExceptionCheck (env))
+ {
+ /* older JCLs do not have the right code for security checks so this may fail with an exception
+ just clear the exception and set the value to false which is the default */
+ (*env)->ExceptionClear (env);
+ return FALSE;
+ }
+ else
+ {
+ return result;
+ }
+}
+
+/**
+ * Answer the 'scope_id' field value from a java.net.InetAddress
+ *
+ * @param env pointer to the JNI library
+ * @param anInetAddress the object to access the 'value' field
+ * @param scope_id pointer to the integer in which the scope_id value should be returned
+ *
+ */
+void
+netGetJavaNetInetAddressScopeId (JNIEnv * env, jobject anInetAddress,
+ U_32 * scope_id)
+{
+ jfieldID scopeFid;
+ jclass inet6AddressClass = (*env)->FindClass (env, "java/net/Inet6Address");
+
+ /* only inet6 addresses have the scope id so only get the value for this type of InetAddress */
+ if ((!((*env)->ExceptionCheck (env)))
+ && (*env)->IsInstanceOf (env, anInetAddress, inet6AddressClass))
+ {
+ scopeFid = (*env)->GetFieldID (env, inet6AddressClass, "scope_id", "I");
+ /* this is to support older jcls that did not have the scope id */
+ if (!((*env)->ExceptionCheck (env)))
+ {
+ *scope_id = (*env)->GetIntField (env, anInetAddress, scopeFid);
+ }
+ else
+ {
+ *scope_id = 0;
+ }
+ }
+ else
+ {
+ *scope_id = 0;
+ }
+
+ /* clear any exception that might have occured */
+ (*env)->ExceptionClear (env);
+
+}
+
+jclass
+getJavaLangBooleanClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jmethodID
+getJavaLangBooleanInit(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(Z)V");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jfieldID
+getJavaLangBooleanValue(JNIEnv * env){
+ jmethodID mid;
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Boolean");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(Z)V");
+ if (!mid)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "value", "Z");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jclass
+getJavaLangByteClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jmethodID
+getJavaLangByteInit(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(B)V");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env){
+ jmethodID mid;
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Byte");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(B)V");
+ if (!mid)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "value", "B");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jclass
+getJavaLangIntegerClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jmethodID
+getJavaLangIntegerInit(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+ return mid;
+}
+
+jfieldID
+getJavaLangIntegerValue(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+ if (!lookupClass)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "value", "I");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+/* already impl
+jmethodID
+getJavaLangByteInit(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env){
+ jmethodID mid;
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Integer");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "(I)V");
+ if (!mid)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "value", "I");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+*/
+
+jclass
+getJavaNetInetAddressClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jfieldID
+getJavaNetInetAddressIpaddress(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "ipaddress", "[B");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jmethodID
+getJavaNetInetAddressPreferIPv6Addresses(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetStaticMethodID (env, lookupClass, "preferIPv6Addresses",
+ "()Z");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jmethodID
+getJavaNetInetAddressGetByAddressStringByte(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ mid =
+ (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
+ "(Ljava/lang/String;[B)Ljava/net/InetAddress;");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jmethodID
+getJavaNetInetAddressGetByAddressByteArray(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ mid =
+ (*env)->GetStaticMethodID (env, lookupClass, "getByAddress",
+ "([B)Ljava/net/InetAddress;");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+jmethodID
+getJavaNetInetAddressInitByteArray(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>", "([B)V");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jmethodID
+getJavaNetInetAddressInitByteString(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/InetAddress");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetMethodID (env, lookupClass, "<init>",
+ "([BLjava/lang/String;)V");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jclass
+getJavaNetSocketClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/net/Socket");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jmethodID
+getJavaNetSocketPreferIPv4Stack(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/Socket");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetStaticMethodID (env, lookupClass, "preferIPv4Stack", "()Z");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jclass
+getJavaLangThreadClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Thread");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jmethodID
+getJavaLangThreadYield(JNIEnv * env){
+ jmethodID mid;
+ jclass lookupClass = (*env)->FindClass (env, "java/lang/Thread");
+ if (!lookupClass)
+ return NULL;
+ mid = (*env)->GetStaticMethodID (env, lookupClass, "yield", "()V");
+ if (!mid)
+ return NULL;
+ return mid;
+}
+
+jclass
+getJavaNetDatagramPacketClass(JNIEnv * env){
+ jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+ if (!lookupClass)
+ return NULL;
+ return lookupClass;
+}
+
+jfieldID
+getJavaNetDatagramPacketAddress(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+ if (!lookupClass)
+ return NULL;
+ fid =
+ (*env)->GetFieldID (env, lookupClass, "address",
+ "Ljava/net/InetAddress;");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jfieldID
+getJavaNetDatagramPacketLength(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+ if (!lookupClass)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "length", "I");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jfieldID
+getJavaNetDatagramPacketPort(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/DatagramPacket");
+ if (!lookupClass)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "port", "I");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jfieldID
+getJavaNetSocketImplAddress(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/SocketImpl");
+ if (!lookupClass)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "address", "Ljava/net/InetAddress;");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+jfieldID
+getJavaNetSocketImplPort(JNIEnv * env){
+ jfieldID fid;
+ jclass lookupClass = (*env)->FindClass (env, "java/net/SocketImpl");
+ if (!lookupClass)
+ return NULL;
+ fid = (*env)->GetFieldID (env, lookupClass, "port", "I");
+ if (!fid)
+ return NULL;
+ return fid;
+}
+
+jfieldID
+getJavaIoFileDescriptorDescriptor (JNIEnv * env)
+{
+ jclass descriptorCLS;
+ jfieldID descriptorFID;
+
+ descriptorCLS = (*env)->FindClass (env, "java/io/FileDescriptor");
+ if (NULL == descriptorCLS)
+ {
+ return NULL;
+ }
+
+ descriptorFID = (*env)->GetFieldID (env, descriptorCLS, "descriptor", "J");
+ if (NULL == descriptorFID)
+ {
+ return NULL;
+ }
+
+ return descriptorFID;
+}
+
+void
+setJavaIoFileDescriptorContents (JNIEnv * env, jobject fd,
+ void *value)
+{
+ jfieldID fid = getJavaIoFileDescriptorDescriptor (env);
+ if (NULL != fid)
+ {
+ (*env)->SetLongField (env, fd, fid, (jlong) value);
+ }
+}
+
+void *
+getJavaIoFileDescriptorContentsAsAPointer (JNIEnv * env, jobject fd)
+{
+ jfieldID descriptorFID = getJavaIoFileDescriptorDescriptor (env);
+ if (NULL == descriptorFID)
+ {
+ return (void *) -1;
+ }
+ return (void *) ((*env)->GetLongField (env, fd, descriptorFID));
+}
+
+//Alternative Select function
+int
+selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept){
+ PORT_ACCESS_FROM_ENV (env);
+ hytimeval_struct timeP;
+ hyfdset_t fdset_read;
+ I_32 result = 0;
+ I_32 size = 0;
+ if (0 <= uSecTime)
+ hysock_timeval_init (0, uSecTime, &timeP);
+
+ fdset_read = hymem_allocate_memory(sizeof (struct hyfdset_struct));
+ FD_ZERO (&fdset_read->handle);
+ FD_SET (hysocketP->sock, &fdset_read->handle);
+ size =hysocketP->sock + 1;
+
+ if (0 <= uSecTime)
+ result = hysock_select (size, fdset_read, NULL, NULL,&timeP);
+ else
+ result = hysock_select (size, fdset_read, NULL, NULL,NULL);
+ hymem_free_memory(fdset_read);
+ return result;
+}
+
+
+jobject getJavaNetSocketImplFileDescriptor(JNIEnv * env,jobject socketImpl){
+ jclass descriptorCLS;
+ jfieldID descriptorFID;
+
+ descriptorCLS = (*env)->FindClass (env, "java/net/SocketImpl");
+ if (NULL == descriptorCLS)
+ {
+ return NULL;
+ }
+ descriptorFID = (*env)->GetFieldID (env, descriptorCLS, "fd", "Ljava/io/FileDescriptor;");
+ if (NULL == descriptorFID)
+ {
+ return NULL;
+ }
+ return (void *) ((*env)->GetObjectField (env, socketImpl, descriptorFID));
+}
Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.h?rev=375250&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/nio/nethelp.h Mon Feb 6 03:19:15 2006
@@ -0,0 +1,142 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(nethelp_h)
+#define nethelp_h
+#include "iohelp.h"
+#include "hysocket.h"
+#define JAVASOCKOPT_TCP_NODELAY 1
+#define JAVASOCKOPT_SO_REUSEADDR 4
+#define JAVASOCKOPT_MCAST_ADD_MEMBERSHIP 19
+#define JAVASOCKOPT_MCAST_DROP_MEMBERSHIP 20
+#define JAVASOCKOPT_MCAST_TTL 17
+#define JAVASOCKOPT_SO_KEEPALIVE 8
+#define JAVASOCKOPT_MCAST_TIME_TO_LIVE 10 /* Currently unused */
+#define JAVASOCKOPT_SO_BROADCAST 32
+#define JAVASOCKOPT_SO_BINDADDR 15
+#define JAVASOCKOPT_MCAST_INTERFACE 16
+#define JAVASOCKOPT_SO_LINGER 128
+#define JAVASOCKOPT_SO_REUSEPORT 512
+#define JAVASOCKOPT_SO_SNDBUF 4097
+#define JAVASOCKOPT_SO_RCVBUF 4098
+#define JAVASOCKOPT_SO_RCVTIMEOUT 4102
+#define JAVASOCKOPT_IP_TOS 3
+#define JAVASOCKOPT_IP_MULTICAST_LOOP 18
+#define JAVASOCKOPT_IP_MULTICAST_IF2 31
+#define JAVASOCKOPT_SO_OOBINLINE 4099
+#define JAVASOCKOPT_REUSEADDR_AND_REUSEPORT 10001
+
+//--------------------------------------
+//reflect function
+//--------------------------------------
+void
+setJavaIoFileDescriptorContents (JNIEnv * env, jobject fd,
+ void *value);
+
+void *
+getJavaIoFileDescriptorContentsAsAPointer (JNIEnv * env, jobject fd);
+
+jclass
+getJavaLangBooleanClass(JNIEnv * env);
+
+jmethodID
+getJavaLangBooleanInit(JNIEnv * env);
+
+jfieldID
+getJavaLangBooleanValue(JNIEnv * env);
+
+jclass
+getJavaLangByteClass(JNIEnv * env);
+
+jmethodID
+getJavaLangByteInit(JNIEnv * env);
+
+jfieldID
+getJavaLangByteValue(JNIEnv * env);
+
+jclass
+getJavaLangIntegerClass(JNIEnv * env);
+
+jmethodID
+getJavaLangIntegerInit(JNIEnv * env);
+
+jfieldID
+getJavaLangIntegerValue(JNIEnv * env);
+
+jclass
+getJavaNetInetAddressClass(JNIEnv * env);
+
+jfieldID
+getJavaNetInetAddressIpaddress(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressPreferIPv6Addresses(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressStringByte(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressGetByAddressByte(JNIEnv * env);
+jmethodID
+getJavaNetInetAddressInitByte(JNIEnv * env);
+
+jmethodID
+getJavaNetInetAddressInitByteString(JNIEnv * env);
+
+jclass
+getJavaNetSocketClass(JNIEnv * env);
+
+jmethodID
+getJavaNetSocketPreferIPv4Stack(JNIEnv * env);
+
+jclass
+getJavaLangThreadClass(JNIEnv * env);
+
+jmethodID
+getJavaLangThreadYield(JNIEnv * env);
+
+jclass
+getJavaNetDatagramPacketClass(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketLength(JNIEnv * env);
+
+jfieldID
+getJavaNetDatagramPacketPort(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplAddress(JNIEnv * env);
+
+jfieldID
+getJavaNetSocketImplPort(JNIEnv * env);
+
+int
+selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept);
+
+jfieldID getComIBMIoNioServerSocketImplFDDescriptor (JNIEnv * env);
+
+jobject getJavaNetServerSocketSocketImpl(JNIEnv * env,jobject serverSocket);
+
+jobject getJavaNetSocketImplFileDescriptor(JNIEnv * env,jobject socketImpl);
+
+I_32
+connect_with_timeout (JNIEnv * env,
+ hysocket_t sock, hysockaddr_t addr, U_32 timeout,
+ U_32 step, U_8 ** context);
+#endif /* nethelp_h */
+
|