< prev index next >

src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c

Print this page




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 #include <stdio.h>
  26 #include <string.h>
  27 #include <errno.h>
  28 #include <stdlib.h>
  29 #include <ctype.h>
  30 

  31 #include "jdwpTransport.h"
  32 #include "sysSocket.h"
  33 
  34 #ifdef _WIN32
  35  #include <winsock2.h>
  36  #include <ws2tcpip.h>
  37 #else
  38  #include <arpa/inet.h>
  39  #include <sys/socket.h>
  40 #endif
  41 
  42 /*
  43  * The Socket Transport Library.
  44  *
  45  * This module is an implementation of the Java Debug Wire Protocol Transport
  46  * Service Provider Interface - see src/share/javavm/export/jdwpTransport.h.
  47  */
  48 
  49 static int serverSocketFD;
  50 static int socketFD = -1;


1001         if (len == 0) { /* Impossible: parseOptions() would reject it */
1002             fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
1003             RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
1004                          "allow option should not be empty");
1005         } else if (*allowed_peers == '*') {
1006             if (len != 1) {
1007                 fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
1008                 RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
1009                              "allow option '*' cannot be expanded");
1010             }
1011         } else {
1012             int err = parseAllowedPeers(allowed_peers);
1013             if (err != JDWPTRANSPORT_ERROR_NONE) {
1014                 return err;
1015             }
1016         }
1017     }
1018     return JDWPTRANSPORT_ERROR_NONE;
1019 }
1020 
1021 jint JNICALL
1022 jdwpTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr,
1023                      jint version, jdwpTransportEnv** env)
1024 {
1025     if (version < JDWPTRANSPORT_VERSION_1_0 ||
1026         version > JDWPTRANSPORT_VERSION_1_1) {
1027         return JNI_EVERSION;
1028     }
1029     if (initialized) {
1030         /*
1031          * This library doesn't support multiple environments (yet)
1032          */
1033         return JNI_EEXIST;
1034     }
1035     initialized = JNI_TRUE;
1036     jvm = vm;
1037     callback = cbTablePtr;
1038 
1039     /* initialize interface table */
1040     interface.GetCapabilities = &socketTransport_getCapabilities;
1041     interface.Attach = &socketTransport_attach;


  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 #include <stdio.h>
  26 #include <string.h>
  27 #include <errno.h>
  28 #include <stdlib.h>
  29 #include <ctype.h>
  30 
  31 #include "jni.h"
  32 #include "jdwpTransport.h"
  33 #include "sysSocket.h"
  34 
  35 #ifdef _WIN32
  36  #include <winsock2.h>
  37  #include <ws2tcpip.h>
  38 #else
  39  #include <arpa/inet.h>
  40  #include <sys/socket.h>
  41 #endif
  42 
  43 /*
  44  * The Socket Transport Library.
  45  *
  46  * This module is an implementation of the Java Debug Wire Protocol Transport
  47  * Service Provider Interface - see src/share/javavm/export/jdwpTransport.h.
  48  */
  49 
  50 static int serverSocketFD;
  51 static int socketFD = -1;


1002         if (len == 0) { /* Impossible: parseOptions() would reject it */
1003             fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
1004             RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
1005                          "allow option should not be empty");
1006         } else if (*allowed_peers == '*') {
1007             if (len != 1) {
1008                 fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
1009                 RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
1010                              "allow option '*' cannot be expanded");
1011             }
1012         } else {
1013             int err = parseAllowedPeers(allowed_peers);
1014             if (err != JDWPTRANSPORT_ERROR_NONE) {
1015                 return err;
1016             }
1017         }
1018     }
1019     return JDWPTRANSPORT_ERROR_NONE;
1020 }
1021 
1022 JNIEXPORT jint JNICALL
1023 jdwpTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr,
1024                      jint version, jdwpTransportEnv** env)
1025 {
1026     if (version < JDWPTRANSPORT_VERSION_1_0 ||
1027         version > JDWPTRANSPORT_VERSION_1_1) {
1028         return JNI_EVERSION;
1029     }
1030     if (initialized) {
1031         /*
1032          * This library doesn't support multiple environments (yet)
1033          */
1034         return JNI_EEXIST;
1035     }
1036     initialized = JNI_TRUE;
1037     jvm = vm;
1038     callback = cbTablePtr;
1039 
1040     /* initialize interface table */
1041     interface.GetCapabilities = &socketTransport_getCapabilities;
1042     interface.Attach = &socketTransport_attach;
< prev index next >