BWAPI
EISBot/c_src/include/jni/jdwpTransport.h
Go to the documentation of this file.
00001 /*
00002  * @(#)jdwpTransport.h  1.8 05/11/17
00003  *
00004  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
00005  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
00006  */
00007 
00008 /*
00009  * Java Debug Wire Protocol Transport Service Provider Interface.
00010  */
00011 
00012 #ifndef JDWPTRANSPORT_H
00013 #define JDWPTRANSPORT_H
00014 
00015 #include "jni.h"
00016 
00017 enum {
00018     JDWPTRANSPORT_VERSION_1_0 = 0x00010000
00019 };
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 struct jdwpTransportNativeInterface_;
00026 
00027 struct _jdwpTransportEnv;
00028 
00029 #ifdef __cplusplus
00030 typedef _jdwpTransportEnv jdwpTransportEnv;
00031 #else
00032 typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
00033 #endif /* __cplusplus */
00034 
00035 /*
00036  * Errors. Universal errors with JVMTI/JVMDI equivalents keep the
00037  * values the same.
00038  */
00039 typedef enum {
00040     JDWPTRANSPORT_ERROR_NONE = 0,
00041     JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
00042     JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
00043     JDWPTRANSPORT_ERROR_INTERNAL = 113,
00044     JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
00045     JDWPTRANSPORT_ERROR_IO_ERROR = 202,
00046     JDWPTRANSPORT_ERROR_TIMEOUT = 203,
00047     JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
00048 } jdwpTransportError;
00049     
00050 
00051 /*
00052  * Structure to define capabilities
00053  */
00054 typedef struct {
00055     unsigned int can_timeout_attach     :1;
00056     unsigned int can_timeout_accept     :1;
00057     unsigned int can_timeout_handshake  :1;
00058     unsigned int reserved3              :1;
00059     unsigned int reserved4              :1;
00060     unsigned int reserved5              :1;
00061     unsigned int reserved6              :1;
00062     unsigned int reserved7              :1;
00063     unsigned int reserved8              :1;
00064     unsigned int reserved9              :1;
00065     unsigned int reserved10             :1;
00066     unsigned int reserved11             :1;
00067     unsigned int reserved12             :1;
00068     unsigned int reserved13             :1;
00069     unsigned int reserved14             :1;
00070     unsigned int reserved15             :1;
00071 } JDWPTransportCapabilities;
00072 
00073 
00074 /*
00075  * Structures to define packet layout.
00076  * 
00077  * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
00078  */
00079 
00080 enum {
00081     JDWPTRANSPORT_FLAGS_NONE     = 0x0,
00082     JDWPTRANSPORT_FLAGS_REPLY    = 0x80
00083 };
00084 
00085 typedef struct {
00086     jint len; 
00087     jint id;
00088     jbyte flags;
00089     jbyte cmdSet;
00090     jbyte cmd;
00091     jbyte *data;
00092 } jdwpCmdPacket;
00093 
00094 typedef struct {
00095     jint len;
00096     jint id;
00097     jbyte flags;
00098     jshort errorCode;
00099     jbyte *data;
00100 } jdwpReplyPacket;
00101 
00102 typedef struct {
00103     union {
00104         jdwpCmdPacket cmd;
00105         jdwpReplyPacket reply;
00106     } type;
00107 } jdwpPacket;
00108 
00109 /*
00110  * JDWP functions called by the transport.
00111  */
00112 typedef struct jdwpTransportCallback {
00113     void *(*alloc)(jint numBytes);   /* Call this for all allocations */
00114     void (*free)(void *buffer);      /* Call this for all deallocations */
00115 } jdwpTransportCallback;
00116 
00117 typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
00118                                                jdwpTransportCallback *callback,
00119                                                jint version,
00120                                                jdwpTransportEnv** env);
00121 
00122 
00123 
00124 /* Function Interface */
00125 
00126 struct jdwpTransportNativeInterface_ {
00127     /*  1 :  RESERVED */
00128     void *reserved1;
00129 
00130     /*  2 : Get Capabilities */
00131     jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
00132          JDWPTransportCapabilities *capabilities_ptr);
00133 
00134     /*  3 : Attach */
00135     jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
00136         const char* address,
00137         jlong attach_timeout,
00138         jlong handshake_timeout);
00139 
00140     /*  4: StartListening */
00141     jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
00142         const char* address, 
00143         char** actual_address);
00144 
00145     /*  5: StopListening */
00146     jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
00147 
00148     /*  6: Accept */
00149     jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
00150         jlong accept_timeout, 
00151         jlong handshake_timeout);
00152 
00153     /*  7: IsOpen */
00154     jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
00155 
00156     /*  8: Close */
00157     jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
00158 
00159     /*  9: ReadPacket */
00160     jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
00161         jdwpPacket *pkt);
00162 
00163     /*  10: Write Packet */
00164     jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
00165         const jdwpPacket* pkt);
00166 
00167     /*  11:  GetLastError */
00168     jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
00169         char** error);
00170 
00171 };
00172 
00173 
00174 /*
00175  * Use inlined functions so that C++ code can use syntax such as
00176  *      env->Attach("mymachine:5000", 10*1000, 0);
00177  *
00178  * rather than using C's :-
00179  *
00180  *      (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
00181  */
00182 struct _jdwpTransportEnv {
00183     const struct jdwpTransportNativeInterface_ *functions;
00184 #ifdef __cplusplus
00185 
00186     jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
00187         return functions->GetCapabilities(this, capabilities_ptr);
00188     }
00189 
00190     jdwpTransportError Attach(const char* address, jlong attach_timeout,
00191                 jlong handshake_timeout) {
00192         return functions->Attach(this, address, attach_timeout, handshake_timeout);
00193     }
00194 
00195     jdwpTransportError StartListening(const char* address,
00196                 char** actual_address) {
00197         return functions->StartListening(this, address, actual_address);
00198     }
00199 
00200     jdwpTransportError StopListening(void) {
00201         return functions->StopListening(this);
00202     }
00203 
00204     jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
00205         return functions->Accept(this, accept_timeout, handshake_timeout);
00206     }
00207 
00208     jboolean IsOpen(void) {
00209         return functions->IsOpen(this);
00210     }
00211 
00212     jdwpTransportError Close(void) {
00213         return functions->Close(this);
00214     }
00215 
00216     jdwpTransportError ReadPacket(jdwpPacket *pkt) {
00217         return functions->ReadPacket(this, pkt);
00218     }
00219 
00220     jdwpTransportError WritePacket(const jdwpPacket* pkt) {
00221         return functions->WritePacket(this, pkt);
00222     }
00223 
00224     jdwpTransportError GetLastError(char** error) {
00225         return functions->GetLastError(this, error);
00226     }
00227 
00228 
00229 #endif /* __cplusplus */
00230 };
00231 
00232 #ifdef __cplusplus
00233 } /* extern "C" */
00234 #endif /* __cplusplus */
00235 
00236 #endif /* JDWPTRANSPORT_H */
00237 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines