Showing the changes to java/pkg2/java/net (47 of 18352 files). Show all
Unified · Split
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,16 @@ | |||
| 1 | # javal v1.5 generated file: edit with care | ||
| 2 | |||
| 3 | DatagramPacket_L : module | ||
| 4 | { | ||
| 5 | DatagramPacket_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | buf : JArrayB; | ||
| 9 | length : int; | ||
| 10 | address : JObject; | ||
| 11 | port : int; | ||
| 12 | }; | ||
| 13 | |||
| 14 | init : fn( jni_p : JNI ); | ||
| 15 | |||
| 16 | }; | ||
Empty file added.
Empty file added.
| @@ -0,0 +1,14 @@ | |||
| 1 | # generated file edit with care | ||
| 2 | |||
| 3 | DatagramSocketImpl_L : module | ||
| 4 | { | ||
| 5 | DatagramSocketImpl_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | localPort : int; | ||
| 9 | fd : ref FileDescriptor_obj; | ||
| 10 | }; | ||
| 11 | |||
| 12 | init : fn( jni_p : JNI ); | ||
| 13 | |||
| 14 | }; | ||
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,218 @@ | |||
| 1 | implement InetAddressImpl_L; | ||
| 2 | |||
| 3 | # javal v1.5 generated file: edit with care | ||
| 4 | |||
| 5 | include "jni.m"; | ||
| 6 | jni : JNI; | ||
| 7 | ClassModule, | ||
| 8 | JString, | ||
| 9 | JArray, | ||
| 10 | JArrayI, | ||
| 11 | JArrayC, | ||
| 12 | JArrayB, | ||
| 13 | JArrayS, | ||
| 14 | JArrayJ, | ||
| 15 | JArrayF, | ||
| 16 | JArrayD, | ||
| 17 | JArrayZ, | ||
| 18 | JArrayJObject, | ||
| 19 | JArrayJClass, | ||
| 20 | JArrayJString, | ||
| 21 | JClass, | ||
| 22 | JThread, | ||
| 23 | JObject : import jni; | ||
| 24 | |||
| 25 | #>> extra pre includes here | ||
| 26 | #<< | ||
| 27 | |||
| 28 | include "InetAddressImpl_L.m"; | ||
| 29 | |||
| 30 | #>> extra post includes here | ||
| 31 | |||
| 32 | include "InetAddress_L.m"; | ||
| 33 | inet: InetAddress_L; # declare pointer to module name | ||
| 34 | |||
| 35 | include "srv.m"; | ||
| 36 | srv: Srv; | ||
| 37 | |||
| 38 | sys: Sys; | ||
| 39 | |||
| 40 | include "jnet.m"; | ||
| 41 | jnet: JNET; | ||
| 42 | |||
| 43 | DEBUG, AF_INET: import jnet; | ||
| 44 | FD: import sys; | ||
| 45 | InetAddress_obj: import inet; # import adt object for p0 ref | ||
| 46 | Value: import jni; | ||
| 47 | |||
| 48 | #<< | ||
| 49 | |||
| 50 | init( jni_p : JNI ) | ||
| 51 | { | ||
| 52 | # save java native inteface mod instance | ||
| 53 | jni = jni_p; | ||
| 54 | #>>extra initialization here | ||
| 55 | |||
| 56 | sys = jni->sys; | ||
| 57 | if((srv = load Srv Srv->BUILTINPATH) == nil | ||
| 58 | && (srv = load Srv Srv->PATH) == nil) | ||
| 59 | jni->InitError( jni->sys->sprint( "java.net.InetAddressImpl: could not load Srv: %r" ) ); | ||
| 60 | |||
| 61 | #<< | ||
| 62 | } | ||
| 63 | |||
| 64 | getLocalHostName_rString( this : ref InetAddressImpl_obj) : JString | ||
| 65 | {#>> | ||
| 66 | |||
| 67 | fd: ref FD; | ||
| 68 | buf:= array[256] of byte; | ||
| 69 | |||
| 70 | if (DEBUG) | ||
| 71 | sys->print("Entering getLocalHostName\n"); | ||
| 72 | |||
| 73 | fd = sys->open("/dev/sysname", sys->OREAD); | ||
| 74 | |||
| 75 | if (fd != nil ) | ||
| 76 | n := sys->read(fd, buf, 256); | ||
| 77 | else | ||
| 78 | return jni->NewString("localhost"); | ||
| 79 | |||
| 80 | if (n <= 0) { | ||
| 81 | return jni->NewString("localhost"); | ||
| 82 | if (DEBUG) | ||
| 83 | sys->print(" Bad return from /dev/sysname\n"); | ||
| 84 | } | ||
| 85 | if (DEBUG) | ||
| 86 | sys->print(" Name from dev/sysname: %s\n", string buf[0:n]); | ||
| 87 | return jni->NewString(string buf[0:n]); | ||
| 88 | |||
| 89 | } | ||
| 90 | #<< | ||
| 91 | |||
| 92 | makeAnyLocalAddress_rInetAddress_V( this : ref InetAddressImpl_obj, p0 : JObject) | ||
| 93 | {#>> | ||
| 94 | |||
| 95 | # p0 must be changed to a type InetAddress_obj in arg list | ||
| 96 | # Must include InetAddress_L.m also in this file. | ||
| 97 | |||
| 98 | if (DEBUG) | ||
| 99 | sys->print("Entering makeAnyLocalAddress\n"); | ||
| 100 | |||
| 101 | |||
| 102 | #p0.address = jnet->INADDR_ANY; | ||
| 103 | |||
| 104 | val := ref Value.TInt( jnet->INADDR_ANY ); | ||
| 105 | n := jni->SetObjField( p0, "address", val ); | ||
| 106 | if (DEBUG ) | ||
| 107 | sys->print("makeAnyLocalAddr: Return from SetObjField %d\n",n); | ||
| 108 | |||
| 109 | #p0.family = jnet->AF_INET; | ||
| 110 | val = ref Value.TInt( jnet->AF_INET ); | ||
| 111 | n = jni->SetObjField( p0, "family", val ); | ||
| 112 | if (DEBUG ) | ||
| 113 | sys->print("makeAnyLocalAddr: Return from SetObjField %d\n",n); | ||
| 114 | }#<< | ||
| 115 | |||
| 116 | lookupAllHostAddr_rString_aaB( this : ref InetAddressImpl_obj, p0 : JString) : JArray | ||
| 117 | {#>> | ||
| 118 | |||
| 119 | if (DEBUG) | ||
| 120 | sys->print("Entering lookupAllHostAddr\n"); | ||
| 121 | |||
| 122 | iplist,AddrList: list of string; | ||
| 123 | hostname,str,temp: string; | ||
| 124 | j: int; | ||
| 125 | |||
| 126 | hostname = p0.str; | ||
| 127 | if (DEBUG) | ||
| 128 | sys->print("hostname is %s \n", p0.str); | ||
| 129 | AddrList = srv->iph2a(hostname); | ||
| 130 | if (DEBUG) | ||
| 131 | sys->print("InetAddressImpl:Got AddrList\n"); | ||
| 132 | |||
| 133 | |||
| 134 | b:= array[len AddrList] of { array[jnet->IPADDRLEN] of byte }; | ||
| 135 | |||
| 136 | if (AddrList != nil) { | ||
| 137 | for(i:=0;i<len AddrList;i++) { | ||
| 138 | str = hd AddrList; | ||
| 139 | if (DEBUG) | ||
| 140 | sys->print(" Addrlist hd = %s\n", str); | ||
| 141 | AddrList = tl AddrList; | ||
| 142 | |||
| 143 | # insure net byte ordered byte[][] | ||
| 144 | ( j, iplist ) = sys->tokenize( str, "."); | ||
| 145 | for (k:=0; k<j; k++) { | ||
| 146 | temp = hd iplist; | ||
| 147 | if (DEBUG) | ||
| 148 | sys->print("iplist hd = %s\n", temp); | ||
| 149 | iplist = tl iplist; | ||
| 150 | if (DEBUG) | ||
| 151 | sys->print("b[%d][%d]\n", i,k); | ||
| 152 | b[i][k] = byte temp; | ||
| 153 | if (DEBUG) | ||
| 154 | sys->print("InetAddressGetHostByName: tokenize b[%d][%d] = %d\n", i, k, int b[i][k]); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | return jni->MkAAByte( b ); | ||
| 158 | } else { | ||
| 159 | jni->ThrowException( "java.net.UnknownHostException", "Host unknown" ); | ||
| 160 | return nil; | ||
| 161 | } | ||
| 162 | |||
| 163 | }#<< | ||
| 164 | |||
| 165 | getHostByAddr_I_rString( this : ref InetAddressImpl_obj, p0 : int) : JString | ||
| 166 | {#>> | ||
| 167 | |||
| 168 | address: string; | ||
| 169 | |||
| 170 | # p0 is the address | ||
| 171 | # IPV4 only.... | ||
| 172 | |||
| 173 | |||
| 174 | if (DEBUG) | ||
| 175 | sys->print("Entering getHostByAddr\n"); | ||
| 176 | |||
| 177 | if( !p0 ) | ||
| 178 | jni->ThrowException( "java.net.UnknownHostException", | ||
| 179 | "Gethostbyaddr Bad Address" ); | ||
| 180 | |||
| 181 | if (DEBUG) | ||
| 182 | sys->print("GetHostByAddr: p0 = %d\n", p0); | ||
| 183 | |||
| 184 | b:= array[jnet->IPADDRLEN] of byte; | ||
| 185 | |||
| 186 | b[0] = byte ( p0 >> 24 ); | ||
| 187 | b[1] = byte ( p0 >> 16 ); | ||
| 188 | b[2] = byte ( p0 >> 8 ); | ||
| 189 | b[3] = byte p0; | ||
| 190 | |||
| 191 | address = string b[0] + "." + string b[1] + "." + string b[2] + "." + | ||
| 192 | string b[3]; | ||
| 193 | |||
| 194 | HostList := srv->ipa2h(address); | ||
| 195 | |||
| 196 | if ( len HostList == 0 ) { | ||
| 197 | if (DEBUG) | ||
| 198 | sys->print("GetHostByAddr: ipa2h returned nil on %s\n", | ||
| 199 | address); | ||
| 200 | jni->ThrowException( "java.net.UnknownHostException", | ||
| 201 | "Gethostbyaddr Bad Address" ); | ||
| 202 | return nil; | ||
| 203 | } | ||
| 204 | |||
| 205 | return jni->NewString( string hd HostList ); | ||
| 206 | |||
| 207 | }#<< | ||
| 208 | |||
| 209 | getInetFamily_I( this : ref InetAddressImpl_obj) : int | ||
| 210 | {#>> | ||
| 211 | |||
| 212 | if (DEBUG) | ||
| 213 | sys->print("Entering getInetFamily\n"); | ||
| 214 | #This is a nasty piece of work here... | ||
| 215 | return AF_INET; | ||
| 216 | |||
| 217 | }#<< | ||
| 218 | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | # javal v1.5 generated file: edit with care | ||
| 2 | |||
| 3 | InetAddressImpl_L : module | ||
| 4 | { | ||
| 5 | InetAddressImpl_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | }; | ||
| 9 | |||
| 10 | init : fn( jni_p : JNI ); | ||
| 11 | getLocalHostName_rString : fn( this : ref InetAddressImpl_obj) : JString; | ||
| 12 | makeAnyLocalAddress_rInetAddress_V : fn( this : ref InetAddressImpl_obj, p0 : JObject); | ||
| 13 | lookupAllHostAddr_rString_aaB : fn( this : ref InetAddressImpl_obj, p0 : JString) : JArray; | ||
| 14 | getHostByAddr_I_rString : fn( this : ref InetAddressImpl_obj, p0 : int) : JString; | ||
| 15 | getInetFamily_I : fn( this : ref InetAddressImpl_obj) : int; | ||
| 16 | |||
| 17 | }; | ||
| @@ -0,0 +1,12 @@ | |||
| 1 | # generated file edit with care | ||
| 2 | |||
| 3 | InetAddress_L : module | ||
| 4 | { | ||
| 5 | InetAddress_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | hostName : JString; | ||
| 9 | address : int; | ||
| 10 | family : int; | ||
| 11 | }; | ||
| 12 | }; | ||
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,695 @@ | |||
| 1 | implement PlainDatagramSocketImpl_L; | ||
| 2 | |||
| 3 | # javal v1.5 generated file: edit with care | ||
| 4 | |||
| 5 | include "jni.m"; | ||
| 6 | jni : JNI; | ||
| 7 | ClassModule, | ||
| 8 | JString, | ||
| 9 | JArray, | ||
| 10 | JArrayI, | ||
| 11 | JArrayC, | ||
| 12 | JArrayB, | ||
| 13 | JArrayS, | ||
| 14 | JArrayJ, | ||
| 15 | JArrayF, | ||
| 16 | JArrayD, | ||
| 17 | JArrayZ, | ||
| 18 | JArrayJObject, | ||
| 19 | JArrayJClass, | ||
| 20 | JArrayJString, | ||
| 21 | JClass, | ||
| 22 | JThread, | ||
| 23 | JObject : import jni; | ||
| 24 | |||
| 25 | #>> extra pre includes here | ||
| 26 | #<< | ||
| 27 | |||
| 28 | include "PlainDatagramSocketImpl_L.m"; | ||
| 29 | |||
| 30 | #>> extra post includes here | ||
| 31 | |||
| 32 | include "jnet.m"; | ||
| 33 | jnet: JNET; | ||
| 34 | |||
| 35 | include "java/io/FileDescriptor_L.m"; | ||
| 36 | fildes: FileDescriptor_L; | ||
| 37 | |||
| 38 | include "InetAddress_L.m"; | ||
| 39 | inet: InetAddress_L; | ||
| 40 | |||
| 41 | InetAddress_obj: import inet; #make sure p0 ref works properly | ||
| 42 | |||
| 43 | include "DatagramPacket_L.m"; | ||
| 44 | pkt: DatagramPacket_L; | ||
| 45 | |||
| 46 | include "srv.m"; | ||
| 47 | srv: Srv; | ||
| 48 | |||
| 49 | sys: Sys; | ||
| 50 | |||
| 51 | strp: String; | ||
| 52 | |||
| 53 | c: Cast; | ||
| 54 | |||
| 55 | |||
| 56 | DEBUG, AF_INET: import jnet; | ||
| 57 | FD: import sys; | ||
| 58 | DatagramPacket_obj: import pkt; #make sure p0 ref works properly | ||
| 59 | FileDescriptor_obj: import fildes; | ||
| 60 | Value: import jni; | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | #<< | ||
| 65 | |||
| 66 | init( jni_p : JNI ) | ||
| 67 | { | ||
| 68 | # save java native inteface mod instance | ||
| 69 | jni = jni_p; | ||
| 70 | #>>extra initialization here | ||
| 71 | |||
| 72 | sys = jni->sys; | ||
| 73 | strp = jni->str; | ||
| 74 | c = jni->CastMod(); | ||
| 75 | if((srv = load Srv Srv->BUILTINPATH) == nil | ||
| 76 | && (srv = load Srv Srv->PATH) == nil) | ||
| 77 | jni->InitError( jni->sys->sprint( "java.net.PlainDatagramSocketImpl: could not load Srv: %r" ) ); | ||
| 78 | |||
| 79 | #<< | ||
| 80 | } | ||
| 81 | |||
| 82 | bind_I_rInetAddress_V( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject) | ||
| 83 | {#>> | ||
| 84 | |||
| 85 | fd: ref FD; | ||
| 86 | buf:= array[50] of byte; | ||
| 87 | byteary:= array[6] of byte; | ||
| 88 | i,n: int; | ||
| 89 | str: string; | ||
| 90 | arg: list of string; | ||
| 91 | |||
| 92 | # Create the localaddress/localport assoc to a socket...... | ||
| 93 | |||
| 94 | # p1 is a ref to InetAddress_obj | ||
| 95 | # p0 is the localport | ||
| 96 | |||
| 97 | if (DEBUG) | ||
| 98 | sys->print("PlainDgramBind: Entering....\n"); | ||
| 99 | |||
| 100 | if( this.cfd == nil ) { | ||
| 101 | if (DEBUG) | ||
| 102 | sys->print("Attempt to Bind using cfd = nil\n"); | ||
| 103 | jni->ThrowException("java.net.SocketException", | ||
| 104 | "Socket closed"); | ||
| 105 | } | ||
| 106 | |||
| 107 | # Check for address presence... | ||
| 108 | if (p1 == nil) { | ||
| 109 | if( DEBUG ) | ||
| 110 | sys->print("PlainDgramSocketImplBind: No address given\n"); | ||
| 111 | jni->ThrowException("java.lang.NullPointerException", "null Address" ); | ||
| 112 | } | ||
| 113 | |||
| 114 | # assume IPv4... | ||
| 115 | |||
| 116 | v := jni->GetObjField( p1, "address", "I"); | ||
| 117 | |||
| 118 | if (DEBUG && v == nil) | ||
| 119 | sys->print("DGrambind: GetObjField returned nil\n"); | ||
| 120 | if (DEBUG) | ||
| 121 | sys->print("DGrambind: GetObjField done\n"); | ||
| 122 | vl := v.Int(); | ||
| 123 | |||
| 124 | b := array[jnet->IPADDRLEN] of byte; | ||
| 125 | b[0] = byte (vl >> 24 ); | ||
| 126 | b[1] = byte (vl >> 16 ); | ||
| 127 | b[2] = byte (vl >> 8 ); | ||
| 128 | b[3] = byte vl; | ||
| 129 | |||
| 130 | if (p0) | ||
| 131 | str = "announce " + string b[0] + "." + string b[1] + "." + | ||
| 132 | string b[2] + "." + string b[3] + "!" + | ||
| 133 | string p0; | ||
| 134 | else | ||
| 135 | str = "announce " + string b[0] + "." + string b[1] + | ||
| 136 | + "." + string b[2] + "." + string b[3] ; | ||
| 137 | |||
| 138 | |||
| 139 | n = sys->write( this.cfd.fd, array of byte str, len str ); | ||
| 140 | |||
| 141 | if( n <= 0 ) { | ||
| 142 | if (DEBUG) | ||
| 143 | sys->print( "Datagram %s to ctl file failed\n", str); | ||
| 144 | jni->ThrowException( "java.net.SocketException", | ||
| 145 | "Bind error"); | ||
| 146 | } | ||
| 147 | |||
| 148 | str = "/net/" + "udp/" + string this.connection + "/local"; | ||
| 149 | if (DEBUG) | ||
| 150 | sys->print( "PlainDatagramSocketBind: opening file %s to get local port\n", str); | ||
| 151 | fd = sys->open( str, sys->OREAD ); | ||
| 152 | if ( fd == nil ) { | ||
| 153 | if (DEBUG) | ||
| 154 | sys->print( "PlainDatagramSocketBind: Open of local file returned nil fd\n"); | ||
| 155 | jni->ThrowException( "java.net.SocketException", | ||
| 156 | "Bind local file open error"); | ||
| 157 | } | ||
| 158 | n = sys->read( fd, buf, len buf); | ||
| 159 | |||
| 160 | |||
| 161 | if ( n <= 0 ) { | ||
| 162 | if (DEBUG) | ||
| 163 | sys->print( "PlainDatagramSocketBind: Read of local file returned %d\n", n); | ||
| 164 | jni->ThrowException( "java.net.SocketException", | ||
| 165 | "Bind local file read error"); | ||
| 166 | } | ||
| 167 | |||
| 168 | ( i, arg) = sys->tokenize(string buf[0:n], "!"); | ||
| 169 | arg = tl arg; | ||
| 170 | |||
| 171 | if (DEBUG) | ||
| 172 | sys->print( "PlainDatagramSocketBind: Returning port # %d\n", int hd arg); | ||
| 173 | this.localPort = int hd arg; | ||
| 174 | |||
| 175 | if (DEBUG) | ||
| 176 | sys->print("PlainDgramBind: Leaving....\n"); | ||
| 177 | |||
| 178 | }#<< | ||
| 179 | |||
| 180 | send_rDatagramPacket_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | ||
| 181 | {#>> | ||
| 182 | #p0 - Datagram Packet obj ref | ||
| 183 | |||
| 184 | b:= array[jnet->IPADDRLEN] of byte; | ||
| 185 | str: string; | ||
| 186 | |||
| 187 | if (DEBUG) | ||
| 188 | sys->print("PlainDgramsend: Entering....\n"); | ||
| 189 | |||
| 190 | if (this.cfd == nil ) { | ||
| 191 | if (DEBUG) | ||
| 192 | sys->print( "PlainDatagramSocketSend: ref FileDescriptor_obj for cfd is nil\n"); | ||
| 193 | jni->ThrowException( "java.net.SocketException", | ||
| 194 | "Socket closed"); | ||
| 195 | } | ||
| 196 | |||
| 197 | if ( p0 == nil ) { | ||
| 198 | if (DEBUG) | ||
| 199 | sys->print( "PlainDatagramSocketSend: ref DatagramPacket_obj is nil\n"); | ||
| 200 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 201 | "Null DatagramPacket arg"); | ||
| 202 | } | ||
| 203 | |||
| 204 | #Check buf field... | ||
| 205 | Pb := jni->GetObjField( p0, "buf", "[B"); | ||
| 206 | if ( Pb == nil ) { | ||
| 207 | if (DEBUG) | ||
| 208 | sys->print( "PlainDatagramSocketSend: ref DatagramPacket_obj buf is nil\n"); | ||
| 209 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 210 | "Null DatagramPacket_obj buffer ref"); | ||
| 211 | } | ||
| 212 | if (DEBUG) | ||
| 213 | sys->print("Dgramsend: GetObjField returned %x\n", Pb); | ||
| 214 | |||
| 215 | Pbvl := Pb.Object(); | ||
| 216 | if (DEBUG) | ||
| 217 | sys->print("Dgramsend: GetObjField returned %x\n", Pbvl); | ||
| 218 | |||
| 219 | |||
| 220 | #Check address field.... | ||
| 221 | if (DEBUG) | ||
| 222 | sys->print("DGramsend: Doing GetObjField Packet.address\n"); | ||
| 223 | I := jni->GetObjField( p0, "address", "Ljava.net.InetAddress;"); | ||
| 224 | if ( I == nil ) { | ||
| 225 | if (DEBUG) | ||
| 226 | sys->print( "PlainDatagramSocketSend: ref DatagramPacket_obj address is nil\n"); | ||
| 227 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 228 | "Null DatagramPacket_obj address ref"); | ||
| 229 | } | ||
| 230 | |||
| 231 | #address is an InetAddress ref | ||
| 232 | Ivl := I.Object(); | ||
| 233 | if (DEBUG) | ||
| 234 | sys->print("Dgramsend: GetObjField returned %x\n", Ivl); | ||
| 235 | |||
| 236 | if (DEBUG) | ||
| 237 | sys->print("DGramsend: Doing GetObjField Packet.address.address\n"); | ||
| 238 | v := jni->GetObjField( Ivl, "address", "I"); | ||
| 239 | |||
| 240 | if (DEBUG && v == nil) | ||
| 241 | sys->print("DGramsend: GetObjField returned nil\n"); | ||
| 242 | vl := v.Int(); | ||
| 243 | |||
| 244 | if (DEBUG) | ||
| 245 | sys->print("Dgramsend: GetObjField returned %d\n", vl); | ||
| 246 | |||
| 247 | b[0] = byte (vl >> 24); | ||
| 248 | b[1] = byte (vl >> 16); | ||
| 249 | b[2] = byte (vl >> 8); | ||
| 250 | b[3] = byte (vl); | ||
| 251 | |||
| 252 | a := string b[0]+"."+string b[1]+"."+string b[2]+ | ||
| 253 | "."+string b[3]; | ||
| 254 | |||
| 255 | # Check port.... | ||
| 256 | if (DEBUG) | ||
| 257 | sys->print("DGramsend: Doing GetObjField Packet.port\n"); | ||
| 258 | v = jni->GetObjField( p0, "port", "I"); | ||
| 259 | |||
| 260 | if (DEBUG && v == nil) | ||
| 261 | sys->print("DGramsend: GetObjField returned nil\n"); | ||
| 262 | |||
| 263 | vl = v.Int(); | ||
| 264 | if (DEBUG) | ||
| 265 | sys->print("Dgramsend: GetObjField returned %d\n", vl); | ||
| 266 | if ( vl <= 0 ) | ||
| 267 | str = "connect " + a; | ||
| 268 | else | ||
| 269 | str = "connect " + a + "!" + string vl; | ||
| 270 | |||
| 271 | if( DEBUG ) | ||
| 272 | sys->print( "DGramsend: connect str = %s\n", str); | ||
| 273 | |||
| 274 | n := sys->write( this.cfd.fd, array of byte str, len array of byte str ); | ||
| 275 | if( n <= 0 ) { | ||
| 276 | if (DEBUG) | ||
| 277 | sys->print( "DGramsend: connect cmd failed %d\n", n); | ||
| 278 | jni->ThrowException( "java.net.SocketException", | ||
| 279 | "Datagram send ctl file error"); | ||
| 280 | } | ||
| 281 | |||
| 282 | #Get buf.ary field.... | ||
| 283 | ar := c->ToJArrayB( Pbvl ); | ||
| 284 | n = sys->write( this.fd.fd, ar.ary, len ar.ary); | ||
| 285 | if ( n <= 0 ) { | ||
| 286 | # set length to zero... | ||
| 287 | val := ref Value.TInt(0); | ||
| 288 | jni->SetObjField( p0, "length", val ); | ||
| 289 | if (DEBUG) | ||
| 290 | sys->print( "PlainDatagramSocketSend: write of data file returned %d\n", n); | ||
| 291 | jni->ThrowException( "java.net.SocketException", | ||
| 292 | "Send: data file write error"); | ||
| 293 | } | ||
| 294 | |||
| 295 | val := ref Value.TInt(n); | ||
| 296 | jni->SetObjField( p0, "length", val ); | ||
| 297 | |||
| 298 | if (DEBUG) | ||
| 299 | sys->print("PlainDgramsend: Leaving...\n"); | ||
| 300 | |||
| 301 | }#<< | ||
| 302 | |||
| 303 | peek_rInetAddress_I( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) : int | ||
| 304 | {#>> | ||
| 305 | if (DEBUG) | ||
| 306 | sys->print( "PlainDatagramSocketPeek: Unsupported entry.\n"); | ||
| 307 | jni->ThrowException( "java.net.SocketException", | ||
| 308 | "Peek: Unsupported option"); | ||
| 309 | return -1; | ||
| 310 | }#<< | ||
| 311 | |||
| 312 | receive_rDatagramPacket_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | ||
| 313 | {#>> | ||
| 314 | |||
| 315 | # p0 = ref DatagramPacket | ||
| 316 | |||
| 317 | str,temp: string; | ||
| 318 | st: list of string; | ||
| 319 | m: int; | ||
| 320 | |||
| 321 | |||
| 322 | |||
| 323 | if (DEBUG) | ||
| 324 | sys->print("PlainDgramreceive: Entering...\n"); | ||
| 325 | |||
| 326 | if (this.cfd == nil ) { | ||
| 327 | if (DEBUG) | ||
| 328 | sys->print( "PlainDatagramSocketRead: ref FileDescriptor_obj for cfd is nil\n"); | ||
| 329 | jni->ThrowException( "java.net.SocketException", | ||
| 330 | "Socket closed"); | ||
| 331 | } | ||
| 332 | |||
| 333 | if ( p0 == nil ) { | ||
| 334 | if (DEBUG) | ||
| 335 | sys->print( "PlainDatagramSocketRead: ref DatagramPacket_obj is nil\n"); | ||
| 336 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 337 | "Null DatagramPacket_obj ref"); | ||
| 338 | } | ||
| 339 | |||
| 340 | #Check buf field... | ||
| 341 | Pb := jni->GetObjField( p0, "buf", "[B"); | ||
| 342 | if ( Pb == nil ) { | ||
| 343 | if (DEBUG) | ||
| 344 | sys->print( "PlainDatagramSocketRecv: ref DatagramPacket_obj buf is nil\n"); | ||
| 345 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 346 | "Null DatagramPacket_obj buffer ref"); | ||
| 347 | } | ||
| 348 | if (DEBUG) | ||
| 349 | sys->print("DgramRecv: GetObjField returned %x\n", Pb); | ||
| 350 | |||
| 351 | Pbvl := Pb.Object(); | ||
| 352 | if (DEBUG) | ||
| 353 | sys->print("DgramRecv: GetObjField returned %x\n", Pbvl); | ||
| 354 | |||
| 355 | #Get buf.ary field.... | ||
| 356 | ar := c->ToJArrayB( Pbvl ); | ||
| 357 | |||
| 358 | n := sys->read( this.fd.fd, ar.ary, len ar.ary); | ||
| 359 | val := ref Value.TInt(n); | ||
| 360 | jni->SetObjField( p0, "length", val ); | ||
| 361 | |||
| 362 | if ( n < 0 ) { | ||
| 363 | if (DEBUG) | ||
| 364 | sys->print( "PlainDatagramSocketRead: read of data file returned %d\n", n); | ||
| 365 | jni->ThrowException( "java.net.SocketException", | ||
| 366 | "PlainDatagramSocketReceive: data file read error"); | ||
| 367 | } | ||
| 368 | |||
| 369 | if (DEBUG) | ||
| 370 | sys->print( "PlainDatagramSocketReceive: read of data file: %s\n", string ar.ary[0:n]); | ||
| 371 | |||
| 372 | # Timeout logic... | ||
| 373 | if( this.timeout != 0 ) { | ||
| 374 | temp = jnet->timeout + " " + string this.timeout; | ||
| 375 | rc := sys->write(this.cfd.fd, array of byte temp, | ||
| 376 | len array of byte temp); | ||
| 377 | if (DEBUG) | ||
| 378 | sys->print("DatagramSocketImplReceive: fixing timeout value %s\n", string this.timeout); | ||
| 379 | if ( rc <= 0 ) | ||
| 380 | jni->ThrowException("java.net.SocketException", | ||
| 381 | "DatagramSocketImplReceive: Unable to set timeout"); | ||
| 382 | } | ||
| 383 | |||
| 384 | # Check status file for timeout... | ||
| 385 | |||
| 386 | buf:= array[256] of byte; | ||
| 387 | |||
| 388 | temp = "/net/udp/" + string this.connection + "/status"; | ||
| 389 | sfd := sys->open( temp, sys->OREAD ); | ||
| 390 | if (sfd == nil ) { | ||
| 391 | if (DEBUG) | ||
| 392 | sys->print( "DatagramSocketImplReceive: Open of status file %s returned nil fd\n", temp); | ||
| 393 | jni->ThrowException( "java.net.SocketException", | ||
| 394 | "DatagramSocketImplReceive: Read failed"); | ||
| 395 | } | ||
| 396 | |||
| 397 | k := sys->read(sfd, buf, len buf); | ||
| 398 | |||
| 399 | if ( k <= 0 ) { | ||
| 400 | if (DEBUG) | ||
| 401 | sys->print("DgramReceive: status file read: %d\n", n); | ||
| 402 | jni->ThrowException( "java.net.SocketException", | ||
| 403 | "DatagramSocketImplReceive: status file read failed"); | ||
| 404 | } | ||
| 405 | |||
| 406 | |||
| 407 | if (DEBUG) | ||
| 408 | sys->print("DgramSocketreceive: Got status: %s\n", string buf[0:k]); | ||
| 409 | |||
| 410 | (m, st) = sys->tokenize( string buf[:k], " \n\t"); | ||
| 411 | |||
| 412 | if ( m != 0 ) | ||
| 413 | for(i:=0;i<m;i++) { | ||
| 414 | str = hd st; | ||
| 415 | if ( strp->prefix( str, "timed-out" )) { | ||
| 416 | if (DEBUG) | ||
| 417 | sys->print( "DatagramSocketImplReceive: timeout\n"); | ||
| 418 | jni->ThrowException("java.io.InterruptedIOException", | ||
| 419 | "DatagramSocketImplReceive: Read timed out."); | ||
| 420 | } | ||
| 421 | st = tl st; | ||
| 422 | } | ||
| 423 | else | ||
| 424 | if (DEBUG) | ||
| 425 | sys->print( "DatagramSocketImplReceive: Can't tokenize\n"); | ||
| 426 | |||
| 427 | |||
| 428 | if (DEBUG) | ||
| 429 | sys->print( "DatagramSocketImplReceive: Doing NewObject\n"); | ||
| 430 | # Default constructor... | ||
| 431 | I_obj := jni->NewObject( jni->FindClass( "java/net/InetAddress" )); | ||
| 432 | |||
| 433 | if (DEBUG) | ||
| 434 | sys->print( "DatagramSocketImplReceive: NewObject Done\n"); | ||
| 435 | str = "/net/" + "udp/" + string this.connection + "/remote"; | ||
| 436 | fd := sys->open(str, sys->OREAD); | ||
| 437 | |||
| 438 | if ( fd == nil ) { | ||
| 439 | if (DEBUG) | ||
| 440 | sys->print("Dgramreceive: Can't open %s\n", str); | ||
| 441 | jni->ThrowException( "java.net.SocketException", | ||
| 442 | "DatagramSocketImplreceive: Unable to obtain remote fd\n"); | ||
| 443 | } | ||
| 444 | |||
| 445 | n = sys->read(fd, buf, len buf); | ||
| 446 | |||
| 447 | if (n <= 0) { | ||
| 448 | if (DEBUG) | ||
| 449 | sys->print("DgramSocketreceive: Can't read %s\n", str); | ||
| 450 | jni->ThrowException( "java.net.SocketException", | ||
| 451 | "DatagramSocketImplreceive: Unable to obtain remote addr\n"); | ||
| 452 | } | ||
| 453 | |||
| 454 | if (DEBUG) | ||
| 455 | sys->print("DgramSocketreceive: Remote file read has %s\n", string buf[0:n]); | ||
| 456 | |||
| 457 | (m, st) = sys->tokenize( string buf[:n], "!"); | ||
| 458 | if ( m == 0 ) { | ||
| 459 | if (DEBUG) | ||
| 460 | sys->print("DgramSocketReceive: Can't tokenize %s\n", str); | ||
| 461 | jni->ThrowException( "java.net.SocketException", | ||
| 462 | "DatagramSocketImplReceive: Unable to tokenize remote\n"); | ||
| 463 | } | ||
| 464 | |||
| 465 | str = hd st; | ||
| 466 | st = tl st; | ||
| 467 | |||
| 468 | iplist: list of string; | ||
| 469 | ( i, iplist ) = sys->tokenize( str, "."); | ||
| 470 | if (DEBUG) | ||
| 471 | sys->print("DgramSocketreceive: tokenize iplist i = %d\n", i); | ||
| 472 | b:= array[len iplist] of byte; | ||
| 473 | for (j:=0; j<i; j++) { | ||
| 474 | temp = hd iplist; | ||
| 475 | iplist = tl iplist; | ||
| 476 | b[j] = byte temp; | ||
| 477 | } | ||
| 478 | |||
| 479 | i = 0; | ||
| 480 | i |= int b[0] <<24; | ||
| 481 | i |= int b[1] <<16; | ||
| 482 | i |= int b[2] <<8; | ||
| 483 | i |= int b[3]; | ||
| 484 | if (DEBUG ) | ||
| 485 | sys->print("DgramSocketreceive: shifted remote addr = %d\n",i); | ||
| 486 | |||
| 487 | val = ref Value.TInt( int hd st ); | ||
| 488 | n = jni->SetObjField( p0, "port", val ); | ||
| 489 | if (DEBUG ) | ||
| 490 | sys->print("DgramSocketRecv: Return from SetObjField port %d\n",n ); | ||
| 491 | |||
| 492 | nval := ref Value.TObject( I_obj ); | ||
| 493 | n = jni->SetObjField( p0, "address", nval ); | ||
| 494 | if (DEBUG ) | ||
| 495 | sys->print("DgramSocketRecv: Return from SetObjField addr %d\n",n ); | ||
| 496 | |||
| 497 | if (DEBUG ) | ||
| 498 | sys->print("DgramSocketRecv: Finished setting InetAddr ref\n" ); | ||
| 499 | |||
| 500 | val = ref Value.TInt( i ); | ||
| 501 | n = jni->SetObjField( I_obj, "address", val ); | ||
| 502 | if (DEBUG ) | ||
| 503 | sys->print("DgramSocketRecv: Return from Inetaddr addr SetObjField %d\n",n ); | ||
| 504 | |||
| 505 | val = ref Value.TInt( jnet->AF_INET ); | ||
| 506 | n = jni->SetObjField( I_obj, "family", val ); | ||
| 507 | if (DEBUG ) | ||
| 508 | sys->print("DgramSocketRecv: Return from family SetObjField %d\n",n ); | ||
| 509 | |||
| 510 | if (DEBUG) | ||
| 511 | sys->print("PlainDgramRecv: Leaving...\n"); | ||
| 512 | |||
| 513 | }#<< | ||
| 514 | |||
| 515 | setTTL_B_V( this : ref PlainDatagramSocketImpl_obj, p0 : int) | ||
| 516 | {#>> | ||
| 517 | if (DEBUG) | ||
| 518 | sys->print( "PlainDatagramSocketSetTTL: Unsupported.\n"); | ||
| 519 | jni->ThrowException( "java.net.SocketException", | ||
| 520 | "setTTL: Unsupported option"); | ||
| 521 | }#<< | ||
| 522 | |||
| 523 | getTTL_B( this : ref PlainDatagramSocketImpl_obj) : int | ||
| 524 | {#>> | ||
| 525 | if (DEBUG) | ||
| 526 | sys->print( "PlainDatagramSocketGetTTL: Unsupported.\n"); | ||
| 527 | jni->ThrowException( "java.net.SocketException", | ||
| 528 | "getTTL: Unsupported option"); | ||
| 529 | return -1; | ||
| 530 | }#<< | ||
| 531 | |||
| 532 | join_rInetAddress_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | ||
| 533 | {#>> | ||
| 534 | if (DEBUG) | ||
| 535 | sys->print( "PlainDatagramSocketJoin: Unsupported.\n"); | ||
| 536 | jni->ThrowException( "java.net.SocketException", | ||
| 537 | "Join: Unsupported option"); | ||
| 538 | }#<< | ||
| 539 | |||
| 540 | leave_rInetAddress_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | ||
| 541 | {#>> | ||
| 542 | if (DEBUG) | ||
| 543 | sys->print( "PlainDatagramSocketLeave: Unsupported.\n"); | ||
| 544 | jni->ThrowException( "java.net.SocketException", | ||
| 545 | "Leave: Unsupported option"); | ||
| 546 | }#<< | ||
| 547 | |||
| 548 | datagramSocketCreate_V( this : ref PlainDatagramSocketImpl_obj) | ||
| 549 | {#>> | ||
| 550 | |||
| 551 | dir: string; | ||
| 552 | cfd: ref FD; | ||
| 553 | |||
| 554 | if (DEBUG) | ||
| 555 | sys->print("DgramCreate: Entering...\n"); | ||
| 556 | |||
| 557 | #Open clone device and allocate a connection | ||
| 558 | dir = "/net/udp/clone"; | ||
| 559 | cfd = sys->open(dir, sys->ORDWR); | ||
| 560 | if (cfd == nil) { | ||
| 561 | if( DEBUG ) | ||
| 562 | sys->print( "DgramCreate: Unable to open clone device\n"); | ||
| 563 | jni->ThrowException( "java.net.SocketException", | ||
| 564 | "Unable to create socket"); | ||
| 565 | } | ||
| 566 | |||
| 567 | #The following gets a connection number string | ||
| 568 | buf := array[10] of byte; | ||
| 569 | n := sys->read(cfd, buf, len buf); | ||
| 570 | if (n < 0) { | ||
| 571 | if (DEBUG) | ||
| 572 | sys->print("DgramCreate: Ctl file read returned no connection num!\n"); | ||
| 573 | jni->ThrowException( "java.net.SocketException", | ||
| 574 | "Unable to create socket"); | ||
| 575 | } | ||
| 576 | |||
| 577 | if (DEBUG) | ||
| 578 | sys->print("DgramCreate: ctl read connection #: %s\n", | ||
| 579 | string buf[:n]); | ||
| 580 | |||
| 581 | if (DEBUG) | ||
| 582 | sys->print("DgramCreate: Storing cfd #\n"); | ||
| 583 | this.cfd.fd = cfd; | ||
| 584 | r := string buf[:n]; | ||
| 585 | if (DEBUG) | ||
| 586 | sys->print("DgramCreate: Storing conn #\n"); | ||
| 587 | this.connection = int r; | ||
| 588 | |||
| 589 | #Open data file and get a handle... | ||
| 590 | dir = "/net/" + "udp/" + string this.connection + "/data"; | ||
| 591 | cfd = sys->open(dir, sys->ORDWR); | ||
| 592 | if (cfd == nil) { | ||
| 593 | if( DEBUG ) | ||
| 594 | sys->print( "DatagramCreate: Unable to open %s\n", dir); | ||
| 595 | jni->ThrowException( "java.net.SocketException", | ||
| 596 | "Unable to create socket"); | ||
| 597 | } | ||
| 598 | if (DEBUG) | ||
| 599 | sys->print("DgramCreate: Storing fd #\n"); | ||
| 600 | this.fd.fd = cfd; | ||
| 601 | }#<< | ||
| 602 | |||
| 603 | datagramSocketClose_V( this : ref PlainDatagramSocketImpl_obj) | ||
| 604 | {#>> | ||
| 605 | |||
| 606 | if (DEBUG) | ||
| 607 | sys->print( "In socket close routine"); | ||
| 608 | this.fd = nil; | ||
| 609 | this.cfd = nil; | ||
| 610 | |||
| 611 | |||
| 612 | }#<< | ||
| 613 | |||
| 614 | socketSetOption_I_rObject_V( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject) | ||
| 615 | {#>> | ||
| 616 | |||
| 617 | if( p0 == jnet->IP_MULTICAST_IF ){ | ||
| 618 | if (DEBUG) | ||
| 619 | sys->print("PlainDatagramSocketImplSetOption: MULTICAST"); | ||
| 620 | jni->ThrowException("java.net.SocketException", | ||
| 621 | "invalid DatagramSocket Option"); | ||
| 622 | } | ||
| 623 | }#<< | ||
| 624 | |||
| 625 | socketGetOption_I_I( this : ref PlainDatagramSocketImpl_obj, p0 : int) : int | ||
| 626 | {#>> | ||
| 627 | |||
| 628 | # p0 = option | ||
| 629 | |||
| 630 | buf := array[256] of byte; | ||
| 631 | temp, str: string; | ||
| 632 | iplist, st: list of string; | ||
| 633 | m,i : int; | ||
| 634 | |||
| 635 | ctype := "udp"; | ||
| 636 | if (DEBUG) | ||
| 637 | sys->print("PlainDatagramSocketImplGetOption: Entering...\n"); | ||
| 638 | |||
| 639 | if ( this.fd == nil ) { | ||
| 640 | if (DEBUG) | ||
| 641 | sys->print("PlainDatagramSocketImplGetOption: Null this.fd\n"); | ||
| 642 | jni->ThrowException("java.net.SocketException", "Socket Closed"); | ||
| 643 | } | ||
| 644 | |||
| 645 | if( p0 == jnet->IP_MULTICAST_IF ) { | ||
| 646 | if (DEBUG) | ||
| 647 | sys->print("PlainDatagramSocketImplGetOption: MULTICAST"); | ||
| 648 | jni->ThrowException("java.net.SocketException", "invalid DatagramSocket Option"); | ||
| 649 | } else if ( p0 == jnet->SO_BINADDR ) { | ||
| 650 | if (DEBUG) | ||
| 651 | sys->print("PlainDatagramSocketImplGetOption: BINADDR"); | ||
| 652 | sfd := sys->open("/dev/sysname", sys->OREAD); | ||
| 653 | if(( m = sys->read(sfd, buf, len buf)) < 0 ) { | ||
| 654 | if (DEBUG) | ||
| 655 | sys->print("DatagramSocketGetOpt: SO_BINADDR: /dev/sysna me read failed\n"); | ||
| 656 | return -1; | ||
| 657 | } | ||
| 658 | st = srv->iph2a(string buf[0:m]); | ||
| 659 | if (st == nil) { | ||
| 660 | if (DEBUG) | ||
| 661 | sys->print("DsockGetOpt: iph2a returned nil list\n"); | ||
| 662 | jni->ThrowException( "java.net.SocketException", | ||
| 663 | "socketGetOption: SO_BINADDR: Unable to get local addres s"); | ||
| 664 | } | ||
| 665 | str = hd st; | ||
| 666 | if (DEBUG) | ||
| 667 | sys->print("socketGetOption: st hd = %s\n", str); | ||
| 668 | # insure net byte ordered byte[] | ||
| 669 | ( i, iplist ) = sys->tokenize( str, "."); | ||
| 670 | if (DEBUG) | ||
| 671 | sys->print("socketGetOption: iplist tokenize i = %d\n", i); | ||
| 672 | b:= array[len iplist] of byte; | ||
| 673 | for (j:=0; j<i; j++) { | ||
| 674 | temp = hd iplist; | ||
| 675 | iplist = tl iplist; | ||
| 676 | b[j] = byte temp; | ||
| 677 | } | ||
| 678 | i=0; | ||
| 679 | i |= int ( b[0] << 24) ; | ||
| 680 | i |= int ( b[1] << 16 ); | ||
| 681 | i |= int ( b[2] << 8 ); | ||
| 682 | i |= int ( b[3] ); | ||
| 683 | if (DEBUG ) | ||
| 684 | sys->print("DgramSocketGetOpt: BINADDR = %d\n", i); | ||
| 685 | return i; | ||
| 686 | } else | ||
| 687 | jni->ThrowException( "java.net.SocketException", | ||
| 688 | "DatagramSocketGetOption: Unsupported Option."); | ||
| 689 | if (DEBUG) | ||
| 690 | sys->print("PlainDatagramSocketImplGetOption: Leaving...\n"); | ||
| 691 | |||
| 692 | return -1; | ||
| 693 | }#<< | ||
| 694 | |||
| 695 | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | # javal v1.5 generated file: edit with care | ||
| 2 | |||
| 3 | PlainDatagramSocketImpl_L : module | ||
| 4 | { | ||
| 5 | PlainDatagramSocketImpl_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | localPort : int; | ||
| 9 | fd : ref FileDescriptor_obj; | ||
| 10 | cfd : ref FileDescriptor_obj; | ||
| 11 | connection : int; | ||
| 12 | timeout : int; | ||
| 13 | }; | ||
| 14 | |||
| 15 | init : fn( jni_p : JNI ); | ||
| 16 | bind_I_rInetAddress_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject); | ||
| 17 | send_rDatagramPacket_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | ||
| 18 | peek_rInetAddress_I : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) : int; | ||
| 19 | receive_rDatagramPacket_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | ||
| 20 | setTTL_B_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int); | ||
| 21 | getTTL_B : fn( this : ref PlainDatagramSocketImpl_obj) : int; | ||
| 22 | join_rInetAddress_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | ||
| 23 | leave_rInetAddress_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | ||
| 24 | datagramSocketCreate_V : fn( this : ref PlainDatagramSocketImpl_obj); | ||
| 25 | datagramSocketClose_V : fn( this : ref PlainDatagramSocketImpl_obj); | ||
| 26 | socketSetOption_I_rObject_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject); | ||
| 27 | socketGetOption_I_I : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int) : int; | ||
| 28 | |||
| 29 | }; | ||
Empty file added.
| @@ -0,0 +1,685 @@ | |||
| 1 | implement PlainSocketImpl_L; | ||
| 2 | |||
| 3 | include "jni.m"; | ||
| 4 | jni : JNI; | ||
| 5 | ClassModule, | ||
| 6 | JString, | ||
| 7 | JArray, | ||
| 8 | JArrayI, | ||
| 9 | JArrayC, | ||
| 10 | JArrayB, | ||
| 11 | JArrayS, | ||
| 12 | JArrayJ, | ||
| 13 | JArrayF, | ||
| 14 | JArrayD, | ||
| 15 | JArrayZ, | ||
| 16 | JArrayJObject, | ||
| 17 | JArrayJClass, | ||
| 18 | JArrayJString, | ||
| 19 | JClass, | ||
| 20 | JObject : import jni; | ||
| 21 | |||
| 22 | #>> extra pre includes here | ||
| 23 | #<< | ||
| 24 | |||
| 25 | include "PlainSocketImpl_L.m"; | ||
| 26 | |||
| 27 | #>> extra post includes here | ||
| 28 | |||
| 29 | include "jnet.m"; | ||
| 30 | jnet: JNET; | ||
| 31 | |||
| 32 | include "java/io/FileDescriptor_L.m"; | ||
| 33 | fildes: FileDescriptor_L; | ||
| 34 | |||
| 35 | include "InetAddress_L.m"; | ||
| 36 | inet: InetAddress_L; | ||
| 37 | |||
| 38 | include "srv.m"; | ||
| 39 | srv: Srv; | ||
| 40 | |||
| 41 | |||
| 42 | FileDescriptor_obj: import fildes; | ||
| 43 | InetAddress_obj: import inet; | ||
| 44 | |||
| 45 | # This next file was once generated by javal, now it must be hand crafted. | ||
| 46 | include "SocketImpl_L.m"; | ||
| 47 | sock: SocketImpl_L; | ||
| 48 | |||
| 49 | sys: Sys; | ||
| 50 | |||
| 51 | strp: String; | ||
| 52 | |||
| 53 | DEBUG: import jnet; | ||
| 54 | FD: import sys; | ||
| 55 | SocketImpl_obj: import sock; | ||
| 56 | Value: import jni; | ||
| 57 | |||
| 58 | #<< | ||
| 59 | |||
| 60 | init( jni_p : JNI ) | ||
| 61 | { | ||
| 62 | # save java native inteface mod instance | ||
| 63 | jni = jni_p; | ||
| 64 | #>>extra initialization here | ||
| 65 | |||
| 66 | sys = jni->sys; | ||
| 67 | strp = jni->str; | ||
| 68 | if((srv = load Srv Srv->BUILTINPATH) == nil | ||
| 69 | && (srv = load Srv Srv->PATH) == nil) | ||
| 70 | jni->InitError( jni->sys->sprint( "java.net.PlainSocketImpl: could not load Srv: %r" ) ); | ||
| 71 | |||
| 72 | #<< | ||
| 73 | } | ||
| 74 | |||
| 75 | socketCreate_Z_V( this : ref PlainSocketImpl_obj, p0 : int) | ||
| 76 | {#>> | ||
| 77 | |||
| 78 | cfd,fd: ref FD; | ||
| 79 | dir,ctype: string; | ||
| 80 | |||
| 81 | if (DEBUG) | ||
| 82 | sys->print("Entering socketCreate\n"); | ||
| 83 | |||
| 84 | # Set socket ctype... | ||
| 85 | if ( p0 ) { | ||
| 86 | ctype = "tcp"; | ||
| 87 | this.ctype = jnet->SOCK_STREAM; | ||
| 88 | } else { | ||
| 89 | ctype = "udp"; | ||
| 90 | this.ctype = jnet->SOCK_DGRAM; | ||
| 91 | } | ||
| 92 | |||
| 93 | #Open clone device and allocate a connection | ||
| 94 | dir = "/net/" + ctype + "/clone"; | ||
| 95 | cfd = sys->open(dir, sys->ORDWR); | ||
| 96 | if (cfd == nil) { | ||
| 97 | if( DEBUG ) | ||
| 98 | sys->print( "Unable to open clone device\n"); | ||
| 99 | jni->ThrowException( "java.net.SocketException", | ||
| 100 | "Unable to create socket"); | ||
| 101 | } | ||
| 102 | this.cfd.fd = cfd; | ||
| 103 | |||
| 104 | buf := array[10] of byte; | ||
| 105 | n := sys->read(cfd, buf, len buf); | ||
| 106 | if (n < 0) { | ||
| 107 | if (DEBUG) | ||
| 108 | sys->print("socketCreate bad ctl file read\n"); | ||
| 109 | jni->ThrowException( "java.net.SocketException", | ||
| 110 | "socketCreate: Unable to create socket"); | ||
| 111 | } | ||
| 112 | if (DEBUG) | ||
| 113 | sys->print("socketCreate: ctl read connection #: %s\n", string buf[0:n]); | ||
| 114 | s := string buf[:n]; | ||
| 115 | |||
| 116 | if (DEBUG) | ||
| 117 | sys->print("socketCreate: s is %s\n", s ); | ||
| 118 | this.connection = int s; | ||
| 119 | |||
| 120 | # Populate data fd........ | ||
| 121 | dir = "/net/" + ctype + "/" + string this.connection + "/data"; | ||
| 122 | if (DEBUG) | ||
| 123 | sys->print("socketCreate: data dir: %s\n", dir); | ||
| 124 | fd = sys->open(dir, sys->ORDWR); | ||
| 125 | |||
| 126 | if ( fd == nil ) { | ||
| 127 | if (DEBUG) | ||
| 128 | sys->print("socketCreate: Attempt to open %s - no fd returned\n", dir); | ||
| 129 | jni->ThrowException( "java.net.SocketException", | ||
| 130 | "Connect error: can't open connection"); | ||
| 131 | } | ||
| 132 | |||
| 133 | this.fd.fd = fd; | ||
| 134 | |||
| 135 | if (DEBUG) | ||
| 136 | sys->print("socketCreate: leaving \n"); | ||
| 137 | }#<< | ||
| 138 | |||
| 139 | socketConnect_rInetAddress_I_V( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int) | ||
| 140 | {#>> | ||
| 141 | b:= array[4] of byte; | ||
| 142 | buf:= array[50] of byte; | ||
| 143 | port,str,ctype: string; | ||
| 144 | arg: list of string; | ||
| 145 | i,n: int; | ||
| 146 | fd: ref FD; | ||
| 147 | |||
| 148 | if (DEBUG) | ||
| 149 | sys->print("socketConnect: entering.. \n"); | ||
| 150 | # Get network ctype and address and port....... | ||
| 151 | |||
| 152 | # Note p0 is an InetAddress_obj ref..... | ||
| 153 | if ( p0 != nil ) { | ||
| 154 | b[0] = byte (p0.address >> 24); | ||
| 155 | b[1] = byte (p0.address >> 16); | ||
| 156 | b[2] = byte (p0.address >> 8); | ||
| 157 | b[3] = byte (p0.address); | ||
| 158 | str = string b[0]+"."+string b[1]+"."+string b[2]+ | ||
| 159 | "."+string b[3]; | ||
| 160 | if( DEBUG ) { | ||
| 161 | sys->print( "socketConnect: byte array = %s\n", str ); | ||
| 162 | } | ||
| 163 | } else { | ||
| 164 | if( DEBUG ) | ||
| 165 | sys->print( "socketConnect: InetAddress ref = nil!\n"); | ||
| 166 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 167 | "Null InetAddress"); | ||
| 168 | } | ||
| 169 | |||
| 170 | if (this.ctype == jnet->SOCK_STREAM) | ||
| 171 | ctype = "tcp"; | ||
| 172 | else | ||
| 173 | ctype = "udp"; | ||
| 174 | |||
| 175 | |||
| 176 | # port is the third arg... | ||
| 177 | if (p1>0) | ||
| 178 | port = string p1; | ||
| 179 | else { | ||
| 180 | if( DEBUG ) | ||
| 181 | sys->print( "socketConnect: No server port arg provided\n"); | ||
| 182 | jni->ThrowException( "java.net.SocketException", | ||
| 183 | "No port argument"); | ||
| 184 | } | ||
| 185 | |||
| 186 | # Make string to write to ctl and issue connect.... | ||
| 187 | |||
| 188 | cstr := "connect " + str + "!" + port; | ||
| 189 | if( DEBUG ) | ||
| 190 | sys->print( "socketConnect: connect str = %s\n", cstr); | ||
| 191 | if ( this.cfd != nil ) | ||
| 192 | n = sys->write( this.cfd.fd, array of byte cstr, | ||
| 193 | len array of byte cstr ); | ||
| 194 | else { | ||
| 195 | if (DEBUG) | ||
| 196 | sys->print("socketConnect: ctl fd == nil!\n"); | ||
| 197 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 198 | "socketConnect: ctl file fd nil"); | ||
| 199 | } | ||
| 200 | |||
| 201 | if( n <= 0 ) { | ||
| 202 | if (DEBUG) | ||
| 203 | sys->print( "Connect cmd to ctl file returned bad byte count %d\n",n); | ||
| 204 | jni->ThrowException( "java.net.SocketException", | ||
| 205 | "Connect write error"); | ||
| 206 | } | ||
| 207 | this.address = p0; | ||
| 208 | this.port = p1; | ||
| 209 | |||
| 210 | # Populate local port........ | ||
| 211 | |||
| 212 | if (this.localport == 0) { # If there was no bind | ||
| 213 | cstr = "/net/"+ctype+"/"+string this.connection+"/local"; | ||
| 214 | fd = sys->open(cstr, sys->OREAD); | ||
| 215 | if ( fd == nil ) { | ||
| 216 | if (DEBUG) | ||
| 217 | sys->print("socketConnect: Open %s failed.\n", | ||
| 218 | cstr ); | ||
| 219 | jni->ThrowException( "java.net.SocketException", | ||
| 220 | "Connect error"); | ||
| 221 | } | ||
| 222 | n = sys->read( fd, buf, len buf ); | ||
| 223 | if ( n <= 0 ) { | ||
| 224 | if (DEBUG) | ||
| 225 | sys->print("Connect Error: Read of %s returned %d\n", cstr ,n ); | ||
| 226 | jni->ThrowException( "java.net.SocketException", | ||
| 227 | "Connect error"); | ||
| 228 | } | ||
| 229 | |||
| 230 | if (DEBUG) | ||
| 231 | sys->print("socketConnect: Read of %s returned %s\n", | ||
| 232 | cstr, string buf[:n]); | ||
| 233 | ( i, arg) = sys->tokenize(string buf[0:n], "!"); | ||
| 234 | if (i == 0) { | ||
| 235 | if (DEBUG) | ||
| 236 | sys->print("Connect Error: tokenize of /local"); | ||
| 237 | jni->ThrowException( "java.net.SocketException", | ||
| 238 | "Connect error"); | ||
| 239 | } | ||
| 240 | arg = tl arg; | ||
| 241 | str = hd arg; | ||
| 242 | if (DEBUG) | ||
| 243 | sys->print("socketConnect: Tokenize for local port returned %s\n", str); | ||
| 244 | this.localport = int str; | ||
| 245 | } | ||
| 246 | }#<< | ||
| 247 | |||
| 248 | socketBind_rInetAddress_I_V( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int) | ||
| 249 | {#>> | ||
| 250 | |||
| 251 | buf:= array[50] of byte; | ||
| 252 | b := array[jnet->IPADDRLEN] of byte; | ||
| 253 | i: int; | ||
| 254 | arg: list of string; | ||
| 255 | |||
| 256 | if (DEBUG) | ||
| 257 | sys->print("Entering socketBind\n"); | ||
| 258 | |||
| 259 | # Create the localaddress/localport assoc to a socket...... | ||
| 260 | |||
| 261 | # Note p0 is a ref to InetAddress_obj | ||
| 262 | # The ip address was shifted in previously so... | ||
| 263 | # IPV4 only.... | ||
| 264 | if ( p0 != nil ) { | ||
| 265 | if (DEBUG) | ||
| 266 | sys->print( "socketBind: p0.address = %d\n",p0.address); | ||
| 267 | b[0] = byte (p0.address >> 24); | ||
| 268 | b[1] = byte (p0.address >> 16); | ||
| 269 | b[2] = byte (p0.address >> 8); | ||
| 270 | b[3] = byte (p0.address); | ||
| 271 | x := string b[0]+"."+string b[1]+"."+string b[2]+ | ||
| 272 | "."+string b[3]; | ||
| 273 | if (DEBUG) | ||
| 274 | sys->print("socketBind: Bind using %s \n", x); | ||
| 275 | } else | ||
| 276 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 277 | "Null InetAddress"); | ||
| 278 | |||
| 279 | if( this.fd == nil ) { | ||
| 280 | if (DEBUG) | ||
| 281 | sys->print("Attempt to Bind using cfd = nil\n"); | ||
| 282 | jni->ThrowException("java.net.SocketException", "Null Socket"); | ||
| 283 | } | ||
| 284 | |||
| 285 | # bind is announce | ||
| 286 | |||
| 287 | if (p1) | ||
| 288 | str := "announce " + string b[0] + "." + string b[1] + | ||
| 289 | + "." + string b[2] + "." + | ||
| 290 | string b[3] + "!" + string p1; | ||
| 291 | else | ||
| 292 | str = "announce " + string b[0] + "." + string b[1] + | ||
| 293 | + "." + string b[2] + "." + string b[3] ; | ||
| 294 | |||
| 295 | if( DEBUG ) | ||
| 296 | sys->print("socketBind: announce port is: %s\n", string p1); | ||
| 297 | |||
| 298 | |||
| 299 | n := sys->write( this.cfd.fd, array of byte str, len array of byte str ); | ||
| 300 | |||
| 301 | if( n <= 0 ) { | ||
| 302 | if (DEBUG) | ||
| 303 | sys->print( "socketBind: %s to ctl failed\n", str); | ||
| 304 | jni->ThrowException( "java.net.SocketException", | ||
| 305 | "Bind error"); | ||
| 306 | } | ||
| 307 | |||
| 308 | # Populate local port........ | ||
| 309 | if (this.ctype == jnet->SOCK_STREAM) | ||
| 310 | ctype := "tcp"; | ||
| 311 | else | ||
| 312 | ctype = "udp"; | ||
| 313 | |||
| 314 | cstr := "/net/"+ctype+"/"+string this.connection+"/local"; | ||
| 315 | fd := sys->open(cstr, sys->OREAD); | ||
| 316 | if ( fd == nil ) { | ||
| 317 | if (DEBUG) | ||
| 318 | sys->print("socketBind: Open %s failed.\n", | ||
| 319 | cstr ); | ||
| 320 | jni->ThrowException( "java.net.SocketException", | ||
| 321 | "Bind error"); | ||
| 322 | } | ||
| 323 | n = sys->read( fd, buf, len buf ); | ||
| 324 | if ( n <= 0 ) { | ||
| 325 | if (DEBUG) | ||
| 326 | sys->print("Bind Error: Read of %s returned %d\n", cstr ,n ); | ||
| 327 | jni->ThrowException( "java.net.SocketException", | ||
| 328 | "Bind error - opening /local"); | ||
| 329 | } | ||
| 330 | |||
| 331 | if (DEBUG) | ||
| 332 | sys->print("socketConnect: Read of %s returned %s\n", | ||
| 333 | cstr, string buf[:n]); | ||
| 334 | ( i, arg) = sys->tokenize(string buf[0:n], "!"); | ||
| 335 | if (i == 0) { | ||
| 336 | if (DEBUG) | ||
| 337 | sys->print("Bind Error: tokenize of /local"); | ||
| 338 | jni->ThrowException( "java.net.SocketException", | ||
| 339 | "Bind error"); | ||
| 340 | } | ||
| 341 | arg = tl arg; | ||
| 342 | str = hd arg; | ||
| 343 | if (DEBUG) | ||
| 344 | sys->print("socketBind: Tokenize for local port returned %s\n", str); | ||
| 345 | this.localport = int str; | ||
| 346 | this.address = p0; | ||
| 347 | }#<< | ||
| 348 | |||
| 349 | socketListen_I_V( this : ref PlainSocketImpl_obj, p0 : int) | ||
| 350 | {#>> | ||
| 351 | |||
| 352 | # Maybe should just return here max q is always 5...... | ||
| 353 | if (DEBUG) | ||
| 354 | sys->print( "In socket listen routine\n"); | ||
| 355 | |||
| 356 | }#<< | ||
| 357 | |||
| 358 | socketAccept_rSocketImpl_V( this : ref PlainSocketImpl_obj, p0 : ref SocketImpl_obj ) | ||
| 359 | {#>> | ||
| 360 | # p0 is a ref to SocketImpl_obj | ||
| 361 | |||
| 362 | ctype,dir: string; | ||
| 363 | buf := array[200] of byte; | ||
| 364 | str: string; | ||
| 365 | st: list of string; | ||
| 366 | m,n : int; | ||
| 367 | |||
| 368 | if (DEBUG) | ||
| 369 | sys->print( "In socketAccept\n"); | ||
| 370 | |||
| 371 | if ( p0 == nil ) { | ||
| 372 | if( DEBUG ) | ||
| 373 | sys->print( "socketAccept: PlainSocketImpl ref = nil!\n"); | ||
| 374 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 375 | "Null Socket Ptr"); | ||
| 376 | } | ||
| 377 | |||
| 378 | if (this.ctype == jnet->SOCK_STREAM) | ||
| 379 | ctype = "tcp"; | ||
| 380 | else | ||
| 381 | ctype = "udp"; | ||
| 382 | |||
| 383 | if( this.timeout != 0 ) { | ||
| 384 | temp:= jnet->timeout + " " + string this.timeout; | ||
| 385 | if (DEBUG) | ||
| 386 | sys->print("socketAccept: writing to ctl: %s\n", temp); | ||
| 387 | if ( this.cfd != nil ) | ||
| 388 | rc := sys->write(this.cfd.fd, array of byte temp, | ||
| 389 | len array of byte temp); | ||
| 390 | else { | ||
| 391 | if (DEBUG) | ||
| 392 | sys->print("socketAccept: ctl fd is nil\n"); | ||
| 393 | jni->ThrowException( "java.lang.NullPointerException", | ||
| 394 | "Null CTL FD"); | ||
| 395 | } | ||
| 396 | |||
| 397 | |||
| 398 | if (DEBUG) | ||
| 399 | sys->print("socketAccept: wrote to ctl: %s\n", temp); | ||
| 400 | if ( rc <= 0 ) { | ||
| 401 | if (DEBUG) | ||
| 402 | sys->print("socketAccept: Bad write to ctl: %s\n", temp); | ||
| 403 | jni->ThrowException("java.net.SocketException", | ||
| 404 | "socketAccept: Unable to set timeout"); | ||
| 405 | } | ||
| 406 | } | ||
| 407 | |||
| 408 | dir = "/net/" + ctype + "/" + string this.connection + "/listen"; | ||
| 409 | if ((lfd := sys->open(dir, sys->ORDWR)) == nil ) { | ||
| 410 | if (DEBUG) | ||
| 411 | sys->print( "Open of listen file %s returned nil fd\n", dir); | ||
| 412 | jni->ThrowException( "java.net.SocketException", | ||
| 413 | "socketAccept: accept failed"); | ||
| 414 | } | ||
| 415 | |||
| 416 | # Check status file to see if timed out... | ||
| 417 | dir = "/net/" + ctype + "/" + string this.connection + "/status"; | ||
| 418 | if ((sfd := sys->open(dir, sys->OREAD)) == nil ) { | ||
| 419 | if (DEBUG) | ||
| 420 | sys->print( "socketAccept: Open of status file %s returned nil fd\n", dir); | ||
| 421 | jni->ThrowException( "java.net.SocketException", | ||
| 422 | "socketAccept: status file open failed"); | ||
| 423 | } | ||
| 424 | |||
| 425 | n = sys->read(sfd, buf, len buf); | ||
| 426 | if ( n <= 0 ) { | ||
| 427 | if (DEBUG) | ||
| 428 | sys->print("socketAccept: status file read: %d\n", n); | ||
| 429 | jni->ThrowException( "java.net.SocketException", | ||
| 430 | "socketAccept: status file read failed"); | ||
| 431 | } | ||
| 432 | |||
| 433 | if (DEBUG) | ||
| 434 | sys->print("socketAccept: Got status: %s\n", string buf[0:n]); | ||
| 435 | (m, st) = sys->tokenize( string buf[:n], " \t\n"); | ||
| 436 | |||
| 437 | for(i:=0;i<m;i++) { | ||
| 438 | str = hd st; | ||
| 439 | if ( strp->prefix( str, "timed-out" )) { | ||
| 440 | if (DEBUG) | ||
| 441 | sys->print( "socketAccept: Status is timeout\n"); | ||
| 442 | jni->ThrowException("java.io.InterruptedIOException", | ||
| 443 | "socketAccept: accept timed out."); | ||
| 444 | } | ||
| 445 | st = tl st; | ||
| 446 | } | ||
| 447 | |||
| 448 | # Need to save the dfd and cfd. Note SocketImpl is abstract... | ||
| 449 | if (DEBUG) | ||
| 450 | sys->print( "socketAccept: Storing fd from listen in SocketImpl_obj\n"); | ||
| 451 | # Get connection... | ||
| 452 | n = sys->read(lfd, buf, len buf); | ||
| 453 | if (n <= 0) { | ||
| 454 | if (DEBUG) | ||
| 455 | sys->print(" SocketAccept: ctl file read bad return code\n"); | ||
| 456 | jni->ThrowException( "java.net.SocketException", | ||
| 457 | "socketAccept: Unable to accept socket"); | ||
| 458 | } | ||
| 459 | |||
| 460 | if (DEBUG) | ||
| 461 | sys->print("socketAccept: listen ctl conn #: %s\n", string buf[0:n]); | ||
| 462 | |||
| 463 | s := string buf[0:n]; | ||
| 464 | if (DEBUG) | ||
| 465 | sys->print("socketAccept: storing connection number = %d in SocketImpl.\n", int s ); | ||
| 466 | p0.connection = int s; # save connection number | ||
| 467 | if (DEBUG) | ||
| 468 | sys->print("socketAccept: storing connection ctype = %d in SocketImpl.\n", this.ctype ); | ||
| 469 | p0.ctype = this.ctype; # save connection ctype | ||
| 470 | |||
| 471 | dir = "/net/" + ctype + "/" + string p0.connection + "/data"; | ||
| 472 | if ((fd := sys->open( dir, sys->ORDWR)) == nil ) { | ||
| 473 | if (DEBUG) | ||
| 474 | sys->print(" SocketAccept: open of %s failed\n", dir); | ||
| 475 | |||
| 476 | jni->ThrowException( "java.net.SocketException", | ||
| 477 | "Unable to open accepted socket"); | ||
| 478 | } | ||
| 479 | if (DEBUG) | ||
| 480 | sys->print("SocketAccept: About to store dfd in SocketImpl fd (abstract class)\n"); | ||
| 481 | p0.fd.fd = fd; #Store data file fd..... | ||
| 482 | |||
| 483 | if (DEBUG) | ||
| 484 | sys->print(" socketAccept: storing accepted cfd now\n" ); | ||
| 485 | p0.cfd.fd = lfd; # store in class... | ||
| 486 | |||
| 487 | }#<< | ||
| 488 | |||
| 489 | socketAvailable_I( this : ref PlainSocketImpl_obj) : int | ||
| 490 | {#>> | ||
| 491 | |||
| 492 | if (DEBUG) | ||
| 493 | sys->print( "In socket available routine\n"); | ||
| 494 | jni->ThrowException( "java.io.IOException", "socketAvailable: Unsupported function" ); | ||
| 495 | return -1; | ||
| 496 | |||
| 497 | }#<< | ||
| 498 | |||
| 499 | socketClose_V( this : ref PlainSocketImpl_obj) | ||
| 500 | {#>> | ||
| 501 | if (DEBUG) | ||
| 502 | sys->print( "In socket close routine\n"); | ||
| 503 | this.fd = nil; | ||
| 504 | this.cfd = nil; | ||
| 505 | this = nil; | ||
| 506 | |||
| 507 | }#<< | ||
| 508 | |||
| 509 | initProto_V( ) | ||
| 510 | {#>> | ||
| 511 | if (DEBUG) | ||
| 512 | sys->print( "In initProto routine\n"); | ||
| 513 | return; | ||
| 514 | }#<< | ||
| 515 | |||
| 516 | socketSetOption_I_Z_rObject_V( this : ref PlainSocketImpl_obj, p0 : int,p1 : int,p2 : JObject) | ||
| 517 | {#>> | ||
| 518 | # p0 = opt | ||
| 519 | # p1 = enable | ||
| 520 | # p2 = val | ||
| 521 | |||
| 522 | if (DEBUG) | ||
| 523 | sys->print( "In SocketSetOption routine"); | ||
| 524 | |||
| 525 | if ( this.cfd == nil ) { | ||
| 526 | if (DEBUG) | ||
| 527 | sys->print("PlainSocketImplSetOption: Null this.fd\n"); | ||
| 528 | jni->ThrowException("java.net.SocketException", "Socket Closed"); | ||
| 529 | } | ||
| 530 | |||
| 531 | if (this.ctype == jnet->SOCK_STREAM) | ||
| 532 | ctype := "tcp"; | ||
| 533 | else | ||
| 534 | ctype = "udp"; | ||
| 535 | |||
| 536 | if( p0 == jnet->TCP_NODELAY ) | ||
| 537 | s := "tcp_nodelay " + string p1; | ||
| 538 | else if ( p0 == jnet->SO_LINGER ) | ||
| 539 | if ( p1 > 0 ) { | ||
| 540 | if( p2 != nil ) { | ||
| 541 | v := jni->GetObjField( p2, "value", "I"); | ||
| 542 | vl := v.Int(); | ||
| 543 | s = "linger " + string vl; | ||
| 544 | } | ||
| 545 | } else | ||
| 546 | s = "linger " + "-1"; | ||
| 547 | else | ||
| 548 | jni->ThrowException( "java.net.SocketException", | ||
| 549 | "Socket Option Unsupported"); | ||
| 550 | |||
| 551 | if ( DEBUG ) | ||
| 552 | sys->print("SocketSetOpt: Option given is: %s\n", s ); | ||
| 553 | |||
| 554 | n := sys->write( this.cfd.fd, array of byte s, len array of byte s ); | ||
| 555 | |||
| 556 | if( n <= 0 ) { | ||
| 557 | if (DEBUG) | ||
| 558 | sys->print( "SetSockOpt: cmd to ctl file returned bad byte count %d\n",n); | ||
| 559 | jni->ThrowException( "java.net.SocketException", | ||
| 560 | "SetSocketOption error"); | ||
| 561 | } | ||
| 562 | }#<< | ||
| 563 | |||
| 564 | socketGetOption_I_I( this : ref PlainSocketImpl_obj, p0 : int) : int | ||
| 565 | {#>> | ||
| 566 | |||
| 567 | temp,ctype,dir: string; | ||
| 568 | buf:= array[256] of byte; | ||
| 569 | s,str: string; | ||
| 570 | iplist,st: list of string; | ||
| 571 | m,n,i : int; | ||
| 572 | |||
| 573 | # p0 == socket option | ||
| 574 | |||
| 575 | if (DEBUG) | ||
| 576 | sys->print( "In SocketGetOption routine"); | ||
| 577 | |||
| 578 | if ( this.fd == nil ) { | ||
| 579 | if (DEBUG) | ||
| 580 | sys->print("PlainSocketImplGetOption: this.fd is null\n"); | ||
| 581 | jni->ThrowException("java.net.SocketException", "Socket Closed"); | ||
| 582 | } | ||
| 583 | |||
| 584 | |||
| 585 | if (this.ctype == jnet->SOCK_STREAM) | ||
| 586 | ctype = "tcp"; | ||
| 587 | else | ||
| 588 | ctype = "udp"; | ||
| 589 | |||
| 590 | if (p0 == jnet->SO_LINGER ) | ||
| 591 | s = "linger"; | ||
| 592 | else if ( p0 == jnet->TCP_NODELAY ) | ||
| 593 | s = "tcp_nodelay"; | ||
| 594 | else if ( p0 == jnet->SO_BINADDR ){ | ||
| 595 | sfd := sys->open("/dev/sysname", sys->OREAD); | ||
| 596 | if ( sfd == nil ) { | ||
| 597 | jni->ThrowException( "java.net.SocketException", | ||
| 598 | "socketGetOpt: Inferno sysname file open failed"); | ||
| 599 | } | ||
| 600 | |||
| 601 | if(( m = sys->read(sfd, buf, len buf)) < 0 ) { | ||
| 602 | if (DEBUG) | ||
| 603 | sys->print("SocketGetOpt: SO_BINADDR: /dev/sysname read failed\n"); | ||
| 604 | return -1; | ||
| 605 | } | ||
| 606 | st = srv->iph2a(string buf[0:m]); | ||
| 607 | if (st == nil) { | ||
| 608 | if (DEBUG) | ||
| 609 | sys->print("sockGetOpt: iph2a returned nil list\n"); | ||
| 610 | jni->ThrowException( "java.net.SocketException", | ||
| 611 | "socketGetOption: SO_BINADDR: Unable to get local address"); | ||
| 612 | } | ||
| 613 | str = hd st; | ||
| 614 | if (DEBUG) | ||
| 615 | sys->print("socketGetOption: st hd = %s\n", str); | ||
| 616 | # insure net byte ordered byte[] | ||
| 617 | ( i, iplist ) = sys->tokenize( str, "."); | ||
| 618 | if ( i == 0 ) { | ||
| 619 | if (DEBUG) | ||
| 620 | sys->print("sockGetOpt: tokenize 0 size list\n"); | ||
| 621 | jni->ThrowException( "java.net.SocketException", | ||
| 622 | "socketGetOption: SO_BINADDR: Unable tokenize local address"); | ||
| 623 | } | ||
| 624 | b:= array[len iplist] of byte; | ||
| 625 | for (j:=0; j<len iplist; j++) { | ||
| 626 | temp = hd iplist; | ||
| 627 | if (DEBUG ) | ||
| 628 | sys->print("socketGetOpt: temp = %s\n", temp); | ||
| 629 | iplist = tl iplist; | ||
| 630 | b[j] = byte temp; | ||
| 631 | } | ||
| 632 | i=0; | ||
| 633 | i |= int ( b[0] << 24) ; | ||
| 634 | i |= int ( b[1] << 16 ); | ||
| 635 | i |= int ( b[2] << 8 ); | ||
| 636 | i |= int ( b[3] ); | ||
| 637 | if (DEBUG ) | ||
| 638 | sys->print("socketGetOpt: returning BINADDR = %d\n", i); | ||
| 639 | return i; | ||
| 640 | } else | ||
| 641 | jni->ThrowException( "java.net.SocketException", | ||
| 642 | "socketGetOption: Unknown Option"); | ||
| 643 | |||
| 644 | |||
| 645 | # Get status file string ... | ||
| 646 | dir = "/net/" + ctype + "/" + string this.connection + "/status"; | ||
| 647 | |||
| 648 | if ((sfd := sys->open( dir, sys->OREAD )) == nil ) { | ||
| 649 | if (DEBUG) | ||
| 650 | sys->print("socketGetOpt: Open status file %s return"+ | ||
| 651 | "ed nil fd\n", dir); | ||
| 652 | jni->ThrowException( "java.net.SocketException", | ||
| 653 | "socketGetOpt: Inferno Status file open failed"); | ||
| 654 | } | ||
| 655 | |||
| 656 | n = sys->read(sfd, buf, len buf); | ||
| 657 | if ( n <= 0 ) { | ||
| 658 | if( DEBUG ) | ||
| 659 | sys->print("socketGetOpt: status file bad read %d\n", n); | ||
| 660 | return -1; | ||
| 661 | } | ||
| 662 | if (DEBUG) | ||
| 663 | sys->print("socketGetOpt: status file has: %s\n", string buf[0:n]); | ||
| 664 | |||
| 665 | (m, st) = sys->tokenize( string buf[:n], " \t\n"); | ||
| 666 | if ( m == 0 ) | ||
| 667 | jni->ThrowException( "java.net.SocketException", | ||
| 668 | "socketGetOption: Unable to tokenize status info"); | ||
| 669 | |||
| 670 | for(i=0;i<m;i++) { | ||
| 671 | str = hd st; | ||
| 672 | st = tl st; | ||
| 673 | if ( strp->prefix( str, s )) { | ||
| 674 | if (p0 == jnet -> SO_LINGER) | ||
| 675 | return int hd st; | ||
| 676 | else if ( p0 == jnet -> TCP_NODELAY) | ||
| 677 | if ( int hd st != 0 ) | ||
| 678 | return 0; | ||
| 679 | else | ||
| 680 | break; | ||
| 681 | } | ||
| 682 | } | ||
| 683 | |||
| 684 | return -1; | ||
| 685 | }#<< | ||
| @@ -0,0 +1,30 @@ | |||
| 1 | # generated file edit with care | ||
| 2 | |||
| 3 | PlainSocketImpl_L : module | ||
| 4 | { | ||
| 5 | PlainSocketImpl_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | cfd : ref FileDescriptor_obj; | ||
| 9 | ctype : int; | ||
| 10 | connection : int; | ||
| 11 | fd : ref FileDescriptor_obj; | ||
| 12 | address : ref InetAddress_obj; | ||
| 13 | port : int; | ||
| 14 | localport : int; | ||
| 15 | timeout : int; | ||
| 16 | }; | ||
| 17 | |||
| 18 | init : fn( jni_p : JNI ); | ||
| 19 | socketCreate_Z_V : fn( this : ref PlainSocketImpl_obj, p0 : int); | ||
| 20 | socketConnect_rInetAddress_I_V : fn( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int); | ||
| 21 | socketBind_rInetAddress_I_V : fn( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int); | ||
| 22 | socketListen_I_V : fn( this : ref PlainSocketImpl_obj, p0 : int); | ||
| 23 | socketAccept_rSocketImpl_V : fn( this : ref PlainSocketImpl_obj, p0 : ref SocketImpl_obj); | ||
| 24 | socketAvailable_I : fn( this : ref PlainSocketImpl_obj) : int; | ||
| 25 | socketClose_V : fn( this : ref PlainSocketImpl_obj); | ||
| 26 | initProto_V : fn( ); | ||
| 27 | socketSetOption_I_Z_rObject_V : fn( this : ref PlainSocketImpl_obj, p0 : int,p1 : int,p2 : JObject); | ||
| 28 | socketGetOption_I_I : fn( this : ref PlainSocketImpl_obj, p0 : int) : int; | ||
| 29 | |||
| 30 | }; | ||
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,19 @@ | |||
| 1 | # generated file edit with care | ||
| 2 | |||
| 3 | SocketImpl_L : module | ||
| 4 | { | ||
| 5 | SocketImpl_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | cfd : ref FileDescriptor_obj; | ||
| 9 | ctype: int; | ||
| 10 | connection: int; | ||
| 11 | fd : ref FileDescriptor_obj; | ||
| 12 | address : ref InetAddress_obj; | ||
| 13 | port : int; | ||
| 14 | localport : int; | ||
| 15 | }; | ||
| 16 | |||
| 17 | init : fn( jni_p : JNI ); | ||
| 18 | |||
| 19 | }; | ||
Empty file added.
| @@ -0,0 +1,173 @@ | |||
| 1 | implement SocketInputStream_L; | ||
| 2 | |||
| 3 | include "jni.m"; | ||
| 4 | jni : JNI; | ||
| 5 | ClassModule, | ||
| 6 | JString, | ||
| 7 | JArray, | ||
| 8 | JArrayI, | ||
| 9 | JArrayC, | ||
| 10 | JArrayB, | ||
| 11 | JArrayS, | ||
| 12 | JArrayJ, | ||
| 13 | JArrayF, | ||
| 14 | JArrayD, | ||
| 15 | JArrayZ, | ||
| 16 | JArrayJObject, | ||
| 17 | JArrayJString, | ||
| 18 | JClass, | ||
| 19 | JObject : import jni; | ||
| 20 | |||
| 21 | #>> extra pre includes here | ||
| 22 | |||
| 23 | #<< | ||
| 24 | |||
| 25 | include "SocketInputStream_L.m"; | ||
| 26 | |||
| 27 | #>> extra post includes here | ||
| 28 | |||
| 29 | include "jnet.m"; | ||
| 30 | jnet: JNET; | ||
| 31 | |||
| 32 | include "java/io/FileDescriptor_L.m"; | ||
| 33 | fildes: FileDescriptor_L; | ||
| 34 | |||
| 35 | include "InetAddress_L.m"; | ||
| 36 | inet: InetAddress_L; | ||
| 37 | |||
| 38 | FileDescriptor_obj: import fildes; | ||
| 39 | InetAddress_obj: import inet; | ||
| 40 | |||
| 41 | include "SocketImpl_L.m"; | ||
| 42 | sock: SocketImpl_L; | ||
| 43 | |||
| 44 | SocketImpl_obj: import sock; | ||
| 45 | |||
| 46 | include "PlainSocketImpl_L.m"; | ||
| 47 | psock: PlainSocketImpl_L; | ||
| 48 | |||
| 49 | sys: Sys; | ||
| 50 | strp: String; | ||
| 51 | DEBUG: import jnet; | ||
| 52 | FD: import sys; | ||
| 53 | |||
| 54 | PlainSocketImpl_obj: import psock; | ||
| 55 | |||
| 56 | #<< | ||
| 57 | |||
| 58 | init( jni_p : JNI ) | ||
| 59 | { | ||
| 60 | # save java native inteface mod instance | ||
| 61 | jni = jni_p; | ||
| 62 | #>>extra initialization here | ||
| 63 | |||
| 64 | sys = jni->sys; | ||
| 65 | strp = jni->str; | ||
| 66 | |||
| 67 | #<< | ||
| 68 | } | ||
| 69 | |||
| 70 | socketRead_aB_I_I_I( this : ref SocketInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int | ||
| 71 | {#>> | ||
| 72 | |||
| 73 | |||
| 74 | st: list of string; | ||
| 75 | str: string; | ||
| 76 | m: int; | ||
| 77 | |||
| 78 | # p1 = offset | ||
| 79 | # p2 = length | ||
| 80 | |||
| 81 | if (p0 == nil ) { | ||
| 82 | if ( DEBUG ) | ||
| 83 | sys->print( "socketRead: p0 ptr to JArrayB is nil\n"); | ||
| 84 | jni->ThrowException( "java.lang.NullPointerException", ""); | ||
| 85 | } | ||
| 86 | |||
| 87 | if (this.fd == nil ) { | ||
| 88 | if ( DEBUG ) | ||
| 89 | sys->print( "socketRead: this.fd == 0, socket must be closed\n"); | ||
| 90 | jni->ThrowException( "java.net.SocketException", "Socket was closed"); | ||
| 91 | } | ||
| 92 | |||
| 93 | if ( p2 <0 || p1 < 0 || p1 + p2 > len p0.ary ) { | ||
| 94 | if ( DEBUG ) | ||
| 95 | sys->print( "socketRead: offset: %d/length: %d wrong in byte array\n",p1,p2); | ||
| 96 | jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", ""); | ||
| 97 | } | ||
| 98 | |||
| 99 | |||
| 100 | if (this.impl == nil ) { | ||
| 101 | if ( DEBUG ) | ||
| 102 | sys->print( "socketRead: p0 ptr to SocketImpl is nil\n"); | ||
| 103 | jni->ThrowException( "java.lang.NullPointerException", "null SocketImpl ref"); | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | # The TIMEOUT logic... Note modifications to SocketInputStream_L.m | ||
| 108 | # had to be made to support impl ptr as a ref to PlainSocketImpl_obj instead | ||
| 109 | # of JOBJECT... | ||
| 110 | |||
| 111 | if( this.impl.timeout != 0 ) { | ||
| 112 | temp:= jnet->timeout + " " + string this.impl.timeout; | ||
| 113 | rc := sys->write(this.impl.cfd.fd, array of byte temp, len temp); | ||
| 114 | if (DEBUG) | ||
| 115 | sys->print("socketRead: fixing timeout value %s\n", string this.impl.timeout); | ||
| 116 | if ( rc <= 0 ) | ||
| 117 | jni->ThrowException("java.net.SocketException", | ||
| 118 | "socketRead: Unable to set timeout"); | ||
| 119 | } | ||
| 120 | |||
| 121 | # Do Read of data file into buffer... | ||
| 122 | if (DEBUG) | ||
| 123 | sys->print("Reading into JArrayB for %d bytes\n",p2); | ||
| 124 | |||
| 125 | n := sys->read(this.fd.fd, array of byte p0.ary[p1: ], p2); | ||
| 126 | |||
| 127 | if (DEBUG) | ||
| 128 | sys->print("SocketInputStream: read of socket: %s\n", string p0.ary[p1:n]); | ||
| 129 | |||
| 130 | # Check status file to for timeout... | ||
| 131 | |||
| 132 | if (this.impl.ctype == jnet->SOCK_STREAM) | ||
| 133 | ctype:= "tcp"; | ||
| 134 | else | ||
| 135 | ctype = "udp"; | ||
| 136 | |||
| 137 | buf:= array[256] of byte; | ||
| 138 | |||
| 139 | dir := "/net/" + ctype + "/" + string this.impl.connection + "/status"; | ||
| 140 | sfd := sys->open( dir, sys->OREAD ); | ||
| 141 | if (sfd == nil ) { | ||
| 142 | if (DEBUG) | ||
| 143 | sys->print( "socketInputStreamRead: Open of status file %s returned nil fd\n", dir); | ||
| 144 | jni->ThrowException( "java.net.SocketException", | ||
| 145 | "socketInputStreamRead: Read failed"); | ||
| 146 | } | ||
| 147 | |||
| 148 | k := sys->read(sfd, buf, len buf); | ||
| 149 | if (DEBUG) | ||
| 150 | sys->print("socketInputStreamRead: status file has: %s\n", string buf[0:k]); | ||
| 151 | if ( k > 0 ) { | ||
| 152 | (m, st) = sys->tokenize( string buf, " \t\n"); | ||
| 153 | for(i:=0;i<m;i++) { | ||
| 154 | str = hd st; | ||
| 155 | if ( strp->prefix( str, "timed-out" )) { | ||
| 156 | if (DEBUG) | ||
| 157 | sys->print( "socketAccept: timeout\n"); | ||
| 158 | jni->ThrowException("java.io.InterruptedIOException", | ||
| 159 | "socketInputStreamRead: Read timed out."); | ||
| 160 | } | ||
| 161 | st = tl st; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | |||
| 166 | if ( n < 0 ) { | ||
| 167 | if ( DEBUG ) | ||
| 168 | sys->print( "socketRead: Read failed with code %d\n", n); | ||
| 169 | jni->ThrowException( "java.net.SocketException", "Read failed"); | ||
| 170 | } | ||
| 171 | return n; | ||
| 172 | |||
| 173 | }#<< | ||
| @@ -0,0 +1,17 @@ | |||
| 1 | # generated file edit with care | ||
| 2 | |||
| 3 | SocketInputStream_L : module | ||
| 4 | { | ||
| 5 | SocketInputStream_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | fd : ref FileDescriptor_obj; | ||
| 9 | eof : int; | ||
| 10 | impl : ref PlainSocketImpl_obj; | ||
| 11 | temp : JArrayB; | ||
| 12 | }; | ||
| 13 | |||
| 14 | init : fn( jni_p : JNI ); | ||
| 15 | socketRead_aB_I_I_I : fn( this : ref SocketInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int; | ||
| 16 | |||
| 17 | }; | ||
Empty file added.
Empty file added.
| @@ -0,0 +1,95 @@ | |||
| 1 | implement SocketOutputStream_L; | ||
| 2 | |||
| 3 | include "jni.m"; | ||
| 4 | jni : JNI; | ||
| 5 | ClassModule, | ||
| 6 | JString, | ||
| 7 | JArray, | ||
| 8 | JArrayI, | ||
| 9 | JArrayC, | ||
| 10 | JArrayB, | ||
| 11 | JArrayS, | ||
| 12 | JArrayJ, | ||
| 13 | JArrayF, | ||
| 14 | JArrayD, | ||
| 15 | JArrayZ, | ||
| 16 | JArrayJObject, | ||
| 17 | JArrayJString, | ||
| 18 | JClass, | ||
| 19 | JObject : import jni; | ||
| 20 | |||
| 21 | #>> extra pre includes here | ||
| 22 | |||
| 23 | #<< | ||
| 24 | |||
| 25 | include "SocketOutputStream_L.m"; | ||
| 26 | |||
| 27 | #>> extra post includes here | ||
| 28 | |||
| 29 | |||
| 30 | include "jnet.m"; | ||
| 31 | jnet: JNET; | ||
| 32 | |||
| 33 | include "java/io/FileDescriptor_L.m"; | ||
| 34 | fildes: FileDescriptor_L; | ||
| 35 | |||
| 36 | include "InetAddress_L.m"; | ||
| 37 | inet: InetAddress_L; | ||
| 38 | |||
| 39 | sys: Sys; | ||
| 40 | |||
| 41 | DEBUG: import jnet; | ||
| 42 | FD: import sys; | ||
| 43 | FileDescriptor_obj: import fildes; | ||
| 44 | InetAddress_obj: import inet; | ||
| 45 | |||
| 46 | #<< | ||
| 47 | |||
| 48 | init( jni_p : JNI ) | ||
| 49 | { | ||
| 50 | # save java native inteface mod instance | ||
| 51 | jni = jni_p; | ||
| 52 | #>>extra initialization here | ||
| 53 | |||
| 54 | sys = jni->sys; | ||
| 55 | |||
| 56 | if (DEBUG) | ||
| 57 | sys->print("socketOutputStream: init()\n"); | ||
| 58 | #<< | ||
| 59 | } | ||
| 60 | |||
| 61 | socketWrite_aB_I_I_V( this : ref SocketOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int) | ||
| 62 | {#>> | ||
| 63 | |||
| 64 | |||
| 65 | if (this.fd == nil ) { | ||
| 66 | if ( DEBUG ) | ||
| 67 | sys->print( "socketWrite: this.fd == 0, socket must be closed\n"); | ||
| 68 | jni->ThrowException( "java.net.SocketException", "Socket was closed"); | ||
| 69 | } | ||
| 70 | |||
| 71 | if ( p2 <0 || p1 < 0 || p1 + p2 > len p0.ary ) { | ||
| 72 | if ( DEBUG ) | ||
| 73 | sys->print( "socketWrite: offset: %d/length: %d wrong in byte array\n",p1,p2); | ||
| 74 | jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", ""); | ||
| 75 | } | ||
| 76 | |||
| 77 | if (p0 == nil ) { | ||
| 78 | if ( DEBUG ) | ||
| 79 | sys->print( "socketWrite: p0 ptr to JArrayB is nil\n"); | ||
| 80 | jni->ThrowException( "java.lang.NullPointerException", ""); | ||
| 81 | } | ||
| 82 | |||
| 83 | # Write into buffer... | ||
| 84 | if (DEBUG) | ||
| 85 | sys->print("Writing into JArrayB for %d bytes\n",p2); | ||
| 86 | n := sys->write(this.fd.fd, p0.ary[p1: ], p2); | ||
| 87 | if ( n < 0 ) { | ||
| 88 | if ( DEBUG ) | ||
| 89 | sys->print( "socketWrite: Read failed with code %d\n", n); | ||
| 90 | jni->ThrowException( "java.net.SocketException", "Write failed"); | ||
| 91 | } | ||
| 92 | return; | ||
| 93 | |||
| 94 | }#<< | ||
| 95 | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | # generated file edit with care | ||
| 2 | |||
| 3 | SocketOutputStream_L : module | ||
| 4 | { | ||
| 5 | SocketOutputStream_obj : adt | ||
| 6 | { | ||
| 7 | cl_mod : ClassModule; | ||
| 8 | fd : ref FileDescriptor_obj; | ||
| 9 | impl : JObject; | ||
| 10 | temp : JArrayB; | ||
| 11 | }; | ||
| 12 | |||
| 13 | init : fn( jni_p : JNI ); | ||
| 14 | socketWrite_aB_I_I_V : fn( this : ref SocketOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int); | ||
| 15 | |||
| 16 | }; | ||
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,23 @@ | |||
| 1 | JNET: module | ||
| 2 | { | ||
| 3 | # These are taken from solaris | ||
| 4 | |||
| 5 | AF_INET: con 2; | ||
| 6 | INADDR_ANY: con 0; | ||
| 7 | |||
| 8 | SOCK_STREAM: con 2; | ||
| 9 | SOCK_DGRAM: con 1; | ||
| 10 | SO_LINGER: con 16r80; | ||
| 11 | SO_REUSEADDR: con 16r04; | ||
| 12 | TCP_NODELAY: con 16r01; | ||
| 13 | |||
| 14 | SO_BINADDR: con 16r0F; | ||
| 15 | IP_MULTICAST_IF: con 16r10; | ||
| 16 | |||
| 17 | timeout: con "rcvtimeo"; | ||
| 18 | linger: con "linger"; | ||
| 19 | nodelay: con "nodelay"; | ||
| 20 | |||
| 21 | IPADDRLEN: con 4; | ||
| 22 | DEBUG: con 0; | ||
| 23 | }; | ||
| @@ -0,0 +1,100 @@ | |||
| 1 | <../../../../mkconfig | ||
| 2 | |||
| 3 | TARG=\ | ||
| 4 | BindException.dis\ | ||
| 5 | ConnectException.dis\ | ||
| 6 | ContentHandler.dis\ | ||
| 7 | ContentHandlerFactory.dis\ | ||
| 8 | DatagramPacket.dis\ | ||
| 9 | DatagramSocket.dis\ | ||
| 10 | DatagramSocketImpl.dis\ | ||
| 11 | FileNameMap.dis\ | ||
| 12 | HttpURLConnection.dis\ | ||
| 13 | InetAddress.dis\ | ||
| 14 | InetAddressImpl.dis\ | ||
| 15 | MalformedURLException.dis\ | ||
| 16 | MulticastSocket.dis\ | ||
| 17 | # for NoRouteToHostException.dis\ | ||
| 18 | r9PkdNz+JgG1Itcw2f6YJ.dis\ | ||
| 19 | # for PlainDatagramSocketImpl.dis\ | ||
| 20 | 5zd2a5CaD3UBT8TZHMXzK.dis\ | ||
| 21 | PlainSocketImpl.dis\ | ||
| 22 | ProtocolException.dis\ | ||
| 23 | ServerSocket.dis\ | ||
| 24 | Socket.dis\ | ||
| 25 | SocketException.dis\ | ||
| 26 | SocketImpl.dis\ | ||
| 27 | SocketImplFactory.dis\ | ||
| 28 | SocketInputStream.dis\ | ||
| 29 | SocketOptions.dis\ | ||
| 30 | SocketOutputStream.dis\ | ||
| 31 | URL.dis\ | ||
| 32 | URLConnection.dis\ | ||
| 33 | URLEncoder.dis\ | ||
| 34 | URLStreamHandler.dis\ | ||
| 35 | # for URLStreamHandlerFactory.dis\ | ||
| 36 | O1DuMby-OVJt3a8-blgAl.dis\ | ||
| 37 | UnknownContentHandler.dis\ | ||
| 38 | UnknownHostException.dis\ | ||
| 39 | # for UnknownServiceException.dis\ | ||
| 40 | r10zsfdVB4eiod6AyF43R.dis\ | ||
| 41 | # Limbo code\ | ||
| 42 | InetAddressImpl_L.dis\ | ||
| 43 | # for PlainDatagramSocketImpl_L.dis\ | ||
| 44 | 5zd2a5CaD3UBT8TZHMXzK_L.dis\ | ||
| 45 | PlainSocketImpl_L.dis\ | ||
| 46 | SocketInputStream_L.dis\ | ||
| 47 | SocketOutputStream_L.dis\ | ||
| 48 | |||
| 49 | MODULES=\ | ||
| 50 | $ROOT/java/module/classloader.m\ | ||
| 51 | $ROOT/java/module/jni.m\ | ||
| 52 | $ROOT/java/module/cast.m\ | ||
| 53 | DatagramPacket_L.m\ | ||
| 54 | DatagramSocketImpl_L.m\ | ||
| 55 | InetAddressImpl_L.m\ | ||
| 56 | InetAddress_L.m\ | ||
| 57 | PlainDatagramSocketImpl_L.m\ | ||
| 58 | PlainSocketImpl_L.m\ | ||
| 59 | SocketImpl_L.m\ | ||
| 60 | SocketInputStream_L.m\ | ||
| 61 | SocketOutputStream_L.m\ | ||
| 62 | jnet.m\ | ||
| 63 | |||
| 64 | SYSMODULES=\ | ||
| 65 | draw.m\ | ||
| 66 | hash.m\ | ||
| 67 | keyring.m\ | ||
| 68 | loader.m\ | ||
| 69 | math.m\ | ||
| 70 | string.m\ | ||
| 71 | sys.m\ | ||
| 72 | |||
| 73 | DISBIN=$ROOT/java/dis/java/java/net | ||
| 74 | |||
| 75 | <$ROOT/mkfiles/mkjava | ||
| 76 | |||
| 77 | LIMBOINCL=\ | ||
| 78 | $LIMBOINCL\ | ||
| 79 | -I$ROOT/java/pkg\ | ||
| 80 | |||
| 81 | InetAddressImpl.dis: InetAddress.class | ||
| 82 | j2d InetAddressImpl.class | ||
| 83 | |||
| 84 | r9PkdNz+JgG1Itcw2f6YJ.dis: NoRouteToHostException.class | ||
| 85 | j2d NoRouteToHostException.class | ||
| 86 | |||
| 87 | 5zd2a5CaD3UBT8TZHMXzK.dis: PlainDatagramSocketImpl.class | ||
| 88 | j2d PlainDatagramSocketImpl.class | ||
| 89 | |||
| 90 | UnknownContentHandler.dis: URLConnection.class | ||
| 91 | j2d UnknownContentHandler.class | ||
| 92 | |||
| 93 | O1DuMby-OVJt3a8-blgAl.dis: URLStreamHandlerFactory.class | ||
| 94 | j2d URLStreamHandlerFactory.class | ||
| 95 | |||
| 96 | r10zsfdVB4eiod6AyF43R.dis: UnknownServiceException.class | ||
| 97 | j2d UnknownServiceException.class | ||
| 98 | |||
| 99 | 5zd2a5CaD3UBT8TZHMXzK_L.dis: PlainDatagramSocketImpl_L.b | ||
| 100 | limbo $LIMBOFLAGS $LIMBOINCL -gw -o $target PlainDatagramSocketImpl_L.b | ||