From 9d51e282da919b91d376c39d8e030b3eddf690fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 14:39:23 +0200 Subject: [PATCH] server & client test --- kernel/init.c | 7 ++----- kernel/shell.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 kernel/shell.c diff --git a/kernel/init.c b/kernel/init.c index f12e8c4e..bb9aef76 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -153,13 +153,11 @@ int network_init(void) kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); mmnif_open(); kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - return 0; - -#if 0 + // return 0; #if defined(CONFIG_LWIP) // Initialize lwIP modules - lwip_init(); +// lwip_init(); #endif #if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK)) @@ -167,5 +165,4 @@ int network_init(void) #else return 0; #endif -#endif } diff --git a/kernel/shell.c b/kernel/shell.c new file mode 100644 index 00000000..386464bb --- /dev/null +++ b/kernel/shell.c @@ -0,0 +1,48 @@ +#include "shell.h" + +#include "server.h" +#include "client.h" + +static Server srv; +static int emac_id = -1; + +static Client cli; + +void shell_on_connect(ServerEventArgs* e) +{ + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) + emac_id = e->ClientID; + + kprintf("link engaged\n"); +} + +void shell_on_disconnect(ServerEventArgs* e) +{ + kpritnf("connection lost from %s:%d",inet_ntoa(sender->ConnectionsAddr[e->ClientID].sin_addr),ntohs(sender->ConnectionsAddr[e->ClientID].sin_port)); +} + +void shell_on_read(ServerEventArgs* e) +{ + if (emac_id != -1 && e->ClientID != emac_id) + srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); + + // else commandos oder so +} + +void shell_init(int srv_or_cli) +{ + if (srv_or_cli) + { + server_init(&srv,5555,49); + srv._OnConnect = shell_on_connect; + srv._OnDisconnect = shell_on_disconnect; + srv._OnRead = shell_on_read; + } + else + { + cli_init(&cli); + while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + sleep(1); + } + +}