From: John Hodge Date: Wed, 3 Oct 2012 06:11:18 +0000 (+0800) Subject: AcessNative - TCP client implimented, buggy X-Git-Tag: rel0.15~705 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=2af6772f1d6597cb06b65782051fd0c4f13dfea4;p=tpg%2Facess2.git AcessNative - TCP client implimented, buggy --- diff --git a/AcessNative/RunTest b/AcessNative/RunTest index 6ea88b67..f2621d4f 100755 --- a/AcessNative/RunTest +++ b/AcessNative/RunTest @@ -1,6 +1,6 @@ #!/bin/sh trap '' 2 -#$1 ./AcessKernel --rootapp /Acess/SBin/login -$1 ./AcessKernel --rootapp /Acess/Apps/AxWin/3.0/AxWinWM +$1 ./AcessKernel --rootapp /Acess/SBin/login +#$1 ./AcessKernel --rootapp /Acess/Apps/AxWin/3.0/AxWinWM trap 2 killall ld-acess diff --git a/AcessNative/acesskernel_src/server.c b/AcessNative/acesskernel_src/server.c index 2e3f3a95..02aa290a 100644 --- a/AcessNative/acesskernel_src/server.c +++ b/AcessNative/acesskernel_src/server.c @@ -132,11 +132,15 @@ int Server_WorkerThread(void *ClientPtr) for( ;; ) { fd_set fds; - int nfd = Client->Socket; + int nfd = Client->Socket+1; FD_ZERO(&fds); FD_SET(Client->Socket, &fds); - select(nfd, &fds, NULL, NULL, NULL); // TODO: Timeouts? + int rv = select(nfd, &fds, NULL, NULL, NULL); // TODO: Timeouts? + if(rv <= 0) { + perror("select"); + continue ; + } if( FD_ISSET(Client->Socket, &fds) ) { @@ -144,15 +148,24 @@ int Server_WorkerThread(void *ClientPtr) char lbuf[sizeof(tRequestHeader) + ciMaxParamCount*sizeof(tRequestValue)]; tRequestHeader *hdr = (void*)lbuf; size_t len = recv(Client->Socket, hdr, sizeof(*hdr), 0); - if( len != sizeof(hdr) ) { + Log_Debug("Server", "%i bytes of header", len); + if( len == 0 ) break; + if( len != sizeof(*hdr) ) { // Oops? + Log_Warning("Server", "FD%i bad sized (%i != exp %i)", + Client->Socket, len, sizeof(*hdr)); + continue ; } if( hdr->NParams > ciMaxParamCount ) { // Oops. + Log_Warning("Server", "FD%i too many params (%i > max %i)", + Client->Socket, hdr->NParams, ciMaxParamCount); + continue ; } len = recv(Client->Socket, hdr->Params, hdr->NParams*sizeof(tRequestValue), 0); + Log_Debug("Server", "%i bytes of params", len); if( len != hdr->NParams*sizeof(tRequestValue) ) { // Oops. } @@ -174,6 +187,7 @@ int Server_WorkerThread(void *ClientPtr) hdr = malloc(bufsize); memcpy(hdr, lbuf, hdrsize); len = recv(Client->Socket, hdr->Params + hdr->NParams, bufsize - hdrsize, 0); + Log_Debug("Server", "%i bytes of data", len); if( len != bufsize - hdrsize ) { // Oops? } @@ -183,6 +197,8 @@ int Server_WorkerThread(void *ClientPtr) retHeader = SyscallRecieve(hdr, &retlen); if( !retHeader ) { // Some sort of error + Log_Warning("Server", "SyscallRecieve failed?"); + continue ; } send(Client->Socket, retHeader, retlen, 0); @@ -343,8 +359,13 @@ int Server_ListenThread(void *Unused) len = recv(clientSock, &authhdr, sizeof(authhdr), 0); if( len != sizeof(authhdr) ) { // Some form of error? + Log_Warning("Server", "Client auth block bad size (%i != exp %i)", + len, sizeof(authhdr)); + continue ; } + Log_Debug("Server", "Client assumed PID %i", authhdr.pid); + tClient *client; if( authhdr.pid == 0 ) { // Allocate PID and client structure/thread @@ -365,6 +386,7 @@ int Server_ListenThread(void *Unused) client->Socket = clientSock; } } + Log_Debug("Server", "Client given PID %i", authhdr.pid); len = send(clientSock, &authhdr, sizeof(authhdr), 0); if( len != sizeof(authhdr) ) { diff --git a/AcessNative/acesskernel_src/ui_sdl.c b/AcessNative/acesskernel_src/ui_sdl.c index 520ac009..ae1d8119 100644 --- a/AcessNative/acesskernel_src/ui_sdl.c +++ b/AcessNative/acesskernel_src/ui_sdl.c @@ -102,6 +102,8 @@ Uint32 UI_GetAcessKeyFromSDL(SDLKey Sym, Uint16 Unicode) case SDLK_F11: ret = KEY_F11; break; case SDLK_F12: ret = KEY_F12; break; case SDLK_RETURN: ret = '\n'; break; + case SDLK_LALT: ret = KEY_LALT; break; + case SDLK_RALT: ret = KEY_RALT; break; default: printf("Unhandled key code %i\n", Sym); break; diff --git a/AcessNative/ld-acess_src/request.c b/AcessNative/ld-acess_src/request.c index 2117591d..670cc3d4 100644 --- a/AcessNative/ld-acess_src/request.c +++ b/AcessNative/ld-acess_src/request.c @@ -1,6 +1,6 @@ /* */ -#define DEBUG 0 +#define DEBUG 1 #if DEBUG @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef __WIN32__ # include # include @@ -24,7 +25,7 @@ #include "request.h" #include "../syscalls.h" -#define USE_TCP 0 +#define USE_TCP 1 // === PROTOTYPES === void SendData(void *Data, int Length); @@ -91,7 +92,6 @@ int _InitSyscalls(void) if( connect(gSocket, (struct sockaddr *)&gSyscall_ServerAddr, sizeof(struct sockaddr_in)) < 0 ) { fprintf(stderr, "[ERROR -] Cannot connect to server (localhost:%i)\n", SERVER_PORT); - fprintf(stderr, "[ERROR -] ", giSyscall_ClientID); perror("_InitSyscalls"); #if __WIN32__ closesocket(gSocket); @@ -118,7 +118,19 @@ int _InitSyscalls(void) } #endif - #if !USE_TCP + #if USE_TCP + { + tRequestAuthHdr auth; + auth.pid = giSyscall_ClientID; + SendData(&auth, sizeof(auth)); + int len = ReadData(&auth, sizeof(auth), 5); + if( len == 0 ) { + fprintf(stderr, "Timeout waiting for auth response\n"); + exit(-1); + } + giSyscall_ClientID = auth.pid; + } + #else // Ask server for a client ID if( !giSyscall_ClientID ) { @@ -190,7 +202,7 @@ int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize) data += sizeof(uint32_t); break; case ARG_TYPE_INT64: - DEBUG_S(" 0x%016llx", *(uint64_t*)data); + DEBUG_S(" 0x%016"PRIx64"", *(uint64_t*)data); data += sizeof(uint64_t); break; case ARG_TYPE_STRING: @@ -221,7 +233,7 @@ void SendData(void *Data, int Length) int len; #if USE_TCP - len = send(Data, Length, 0); + len = send(gSocket, Data, Length, 0); #else len = sendto(gSocket, Data, Length, 0, (struct sockaddr*)&gSyscall_ServerAddr, sizeof(gSyscall_ServerAddr)); diff --git a/BuildConf/x86/Makefile.cfg b/BuildConf/x86/Makefile.cfg index 7b3d8a98..76c3d3ce 100644 --- a/BuildConf/x86/Makefile.cfg +++ b/BuildConf/x86/Makefile.cfg @@ -2,10 +2,13 @@ # Acess2 Build Configuration # -CC = i586-elf-gcc -LD = i586-elf-ld +#CC = i586-elf-gcc +#LD = i586-elf-ld +CC = gcc +LD = ld AS = nasm -OBJDUMP = i586-elf-objdump +#OBJDUMP = i586-elf-objdump +OBJDUMP = objdump RM = @rm -f STRIP = strip