From 43df10fde7e1e82a634a7117f7fb2dbf2b74e786 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 10 Feb 1999 19:53:42 +0000 Subject: Removing socket test. --- socket/Makefile | 63 ------ socket/buffer.c | 192 ------------------- socket/buffer.h | 39 ---- socket/init.c | 465 --------------------------------------------- socket/pgmHost/Makefile | 52 ----- socket/pgmHost/clientTcp.c | 114 ----------- socket/pgmHost/clientUdp.c | 78 -------- socket/pgmHost/serverTcp.c | 118 ------------ socket/pgmHost/serverUdp.c | 94 --------- socket/system.h | 53 ------ 10 files changed, 1268 deletions(-) delete mode 100644 socket/Makefile delete mode 100644 socket/buffer.c delete mode 100644 socket/buffer.h delete mode 100644 socket/init.c delete mode 100644 socket/pgmHost/Makefile delete mode 100644 socket/pgmHost/clientTcp.c delete mode 100644 socket/pgmHost/clientUdp.c delete mode 100644 socket/pgmHost/serverTcp.c delete mode 100644 socket/pgmHost/serverUdp.c delete mode 100644 socket/system.h diff --git a/socket/Makefile b/socket/Makefile deleted file mode 100644 index 9946b7b..0000000 --- a/socket/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -# $Id$ -# - -SAMPLE=socket -PGM=${ARCH}/$(SAMPLE).exe - -MANAGERS=io event semaphore timer rate_monotonic - -# C source names, if any, go here -- minus the .c -C_PIECES=buffer init -C_FILES=$(C_PIECES:%=%.c) -C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) - -H_FILES=system.h buffer.h - -DOCTYPES= -DOCS=$(DOCTYPES:%=$(SAMPLE).%) - -SRCS=$(DOCS) $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES) -OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES) - -PRINT_SRCS=$(DOCS) - -PGM=${ARCH}/$(SAMPLE).exe - -include $(RTEMS_MAKEFILE_PATH)/Makefile.inc -include $(RTEMS_CUSTOM) -include $(PROJECT_ROOT)/make/leaf.cfg - -# -# (OPTIONAL) Add local stuff here using += -# - -DEFINES += -CPPFLAGS += -CFLAGS += -CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000 # KA9Q needs more space -CFLAGS_OPTIMIZE_V += -CFLAGS_DEBUG_V += -v -qrtems_debug - -LD_PATHS += -LD_LIBS += - -# -# Add your list of files to delete here. The config files -# already know how to delete some stuff, so you may want -# to just run 'make clean' first to see what gets missed. -# 'make clobber' already includes 'make clean' -# - -CLEAN_ADDITIONS += -CLOBBER_ADDITIONS += - -all: ${ARCH} $(SRCS) $(PGM) - -${PGM}: $(OBJS) $(LINK_FILES) - $(make-exe) - -# Install the program(s), appending _g or _p as appropriate. -# for include files, just use $(INSTALL) -install: all - $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests diff --git a/socket/buffer.c b/socket/buffer.c deleted file mode 100644 index dc5cdac..0000000 --- a/socket/buffer.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * buffer.c : generate an executable to test the sockets. - * it is used to create/test the sent/receive messages - * - * $Id$ - */ - -#include -#include "buffer.h" - -typedef unsigned char BOOLEAN; -typedef BOOLEAN *PBOOLEAN; - -#define TRUE 1 -#define FALSE 0 -#define SIZE_INTERVAL 50 -#define CHAR_BUFFER '0' -#define CHAR_LIMIT 'L' -#define CHAR_END 'E' - -static unsigned long s_BufferId_ul = 0; -static unsigned long s_BufferId_ul_rcv = 1; - -static int Length = 10; -static int koYes = 0; -static int frameAfterKo = 5; - -unsigned char * BuildBuffer() { - unsigned char * Buffer_puc; - unsigned long * Buffer_pul; - int i; - int SizeDataBuffer_i; - - - /* Seed the random-number generator with current time so that - * the numbers will be different every time we run. - */ - /*srand( (unsigned int)(s_BufferId_ul*time(NULL)));*/ - - Length++; - if (Length > 2000) - Length = 10; - - Buffer_puc = (unsigned char *)malloc(Length); - if( Buffer_puc == NULL ) - printf( "Insufficient memory available\n" ); - - /* Build the buffer - * The first word = The length of the buffer - * Every SIZE_INTERVAL char write the CHAR_LIMIT - * The last cahr is CHAR_END - * The other char is CHAR_BUFFER */ - - - /* Intialize the length of the buffer in the first word */ - Buffer_pul = (unsigned long *)Buffer_puc; - *Buffer_pul = Length; - - /* Intialize the length of the buffer in the first word*/ - Buffer_pul++; - s_BufferId_ul++; - *Buffer_pul = s_BufferId_ul; - - /* Intialize the buffer with the CHAR_LIMIT and CHAR_BUFFER */ - SizeDataBuffer_i = Length-8; - Buffer_puc+=8; - - for (i= 0; i and length=<%d>/<0x%x>\n", s_BufferId_ul, Length, Length); - fflush(stdout); - - return Buffer_puc; - -} - - -void FreeBuffer(unsigned char * p_Buffer_puc){ - free(p_Buffer_puc); -} - - -unsigned char * AllocBuffer() -{ - unsigned char * Buffer_puc; - - Buffer_puc = (unsigned char *)malloc(SIZE_MAX_RCV_BUFFER); - - if( Buffer_puc == NULL ){ - printf("Insufficient memory available\n"); - fflush(stdout); - } - return Buffer_puc; -} - - - -unsigned long CheckBuffer(unsigned char * p_Buffer_puc) -{ - - BOOLEAN CheckBuffer_b = TRUE; - unsigned long * Buffer_pul; - unsigned long LenBuffer_ul; - int i=0; - unsigned long BufferId_ul, j; - - - /*Retrieve the length of the buffer*/ - Buffer_pul = (unsigned long *)p_Buffer_puc; - LenBuffer_ul = *Buffer_pul; - - /* Retrieve the Id of the buffer*/ - Buffer_pul++; - BufferId_ul = *Buffer_pul; - - if (BufferId_ul < s_BufferId_ul_rcv) { - s_BufferId_ul_rcv = BufferId_ul; - } - - if (BufferId_ul > s_BufferId_ul_rcv) { - for (j = 0; j < (BufferId_ul - s_BufferId_ul_rcv); j++) { - printf("!!!!!!!! Buffer ID=<%ld> lost !!!!!!!!\n", s_BufferId_ul_rcv); - fflush(stdout); - s_BufferId_ul_rcv++ ; - } - /* error */ - koYes = 0; /* if koYes = 1 here, the prog will stop 5 reception after */ - } - - s_BufferId_ul_rcv++ ; - - /* Print the information*/ - printf("Buffer receive ID=<%ld> and length=<%ld>/<0x%lx> :",BufferId_ul,LenBuffer_ul,LenBuffer_ul); - fflush(stdout); - - /* Check the end character*/ - if(p_Buffer_puc[LenBuffer_ul-2]!=CHAR_END){ - CheckBuffer_b = FALSE; - } - - /* Check the sequence characters*/ - p_Buffer_puc+=8; - - while((CheckBuffer_b)&&(i<(int)(LenBuffer_ul-10))) - { - - if( (i%SIZE_INTERVAL)==0 ) - CheckBuffer_b = (p_Buffer_puc[i]==CHAR_LIMIT); - else - CheckBuffer_b = (p_Buffer_puc[i]==CHAR_BUFFER); - - i++; - } - - p_Buffer_puc-=8; - - if (CheckBuffer_b) { - printf("OK\n"); - fflush(stdout); - } - else { - /* error */ - koYes = 0; /* if koYes = 1 here, the prog will stop 5 receptions after */ - printf("KO ???\n"); - fflush(stdout); - } - - if (koYes){ - frameAfterKo-- ; - if (frameAfterKo == 0) - return 0; - } - - return BufferId_ul; - -} - - - - - - diff --git a/socket/buffer.h b/socket/buffer.h deleted file mode 100644 index 1eab6ec..0000000 --- a/socket/buffer.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * buffer.h : generate an executable to test the sockets. - * contains some useful declarations - * - * $Id$ - */ - -#ifndef _BUFFER_H -#define _BUFFER_H - -#include - - -#define SIZE_MAX_IP_HEADER 20 -#define SIZE_MAX_TCP_HEADER 20 -#define SIZE_MAX_UDP_HEADER 8 -#define SIZE_MAX_BUFFER 5*1024 - SIZE_MAX_IP_HEADER - SIZE_MAX_TCP_HEADER - -/* - *The receive buffer size max shall be able to receive - *the payload and the headers (IP and TCP/UDP): - *- max IP header = 0xf ulong (ulong = 4bytes) - *- max TCP header = 0xf ulong (ulong = 4bytes) - *- max UDP header = 8 bytes) - */ -#define SIZE_MAX_RCV_BUFFER SIZE_MAX_BUFFER + (2*4*0xf) - -#define DEFAULT_PORT_SERVER 12345 -#define DEFAULT_PORT_CLIENT 54321 -#define DEF_MAXLOOP -1 - - -unsigned char * BuildBuffer(); -void FreeBuffer(unsigned char * p_Buffer_puc); -unsigned char * AllocBuffer(); -unsigned long CheckBuffer(unsigned char * p_Buffer_puc); - -#endif /* _BUFFER_H */ - diff --git a/socket/init.c b/socket/init.c deleted file mode 100644 index 291840c..0000000 --- a/socket/init.c +++ /dev/null @@ -1,465 +0,0 @@ -/* Init - * - * This routine is the initialization task for this test program. - * - * Don't forget to change the IP addresses - * - * $Id$ - */ - -#define TEST_INIT - -#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024) -#define CONFIGURE_MAXIMUM_SEMAPHORES 20 -#define CONFIGURE_MAXIMUM_TASKS 20 -#define CONFIGURE_MAXIMUM_TIMERS 10 -#define CONFIGURE_MAXIMUM_PERIODS 1 - -#include "system.h" - -#include -#include -#include -#include -#include -#include - -#define ARGUMENT 0 - -/* define and include for socket test */ -/*#define PINKFLOYD */ - -/*#define SERVER*/ -#define CLIENT - -/*#define UDP*/ /* if enabled, testing UDP socket else TCP socket */ - -#include "buffer.h" - - -#define DEFAULT_IP_SERVER "194.2.81.61" -#define DEFAULT_LISTEN_IP_SERVER "194.2.81.126" -#define DEFAULT_IP_CLIENT "194.2.81.126" -#define DEFAULT_LISTEN_IP_CLIENT "194.2.81.61" - -rtems_task Init( - rtems_task_argument argument -) -{ - unsigned int oldPri; - rtems_name task_name; - rtems_id tid; - rtems_status_code status; - - - - printf("\n\n*** SAMPLE SINGLE PROCESSOR APPLICATION ***\n\r" ); - printf("Creating and starting an application task\n\r" ); - fflush(stdout); - - rtems_task_set_priority (RTEMS_SELF, 30, &oldPri); - - rtems_ka9q_start (10); - -#ifdef PINKFLOYD - if (rtems_ka9q_execute_command("attach rtems " - "broadcast n " - "ip 194.2.81.127 " - "irno 5 " - "bpar 0xd0000 " - "port 0x240 " - "ether 00:E0:29:12:3f:85 ")) -#else - if (rtems_ka9q_execute_command("attach rtems " - "broadcast y " - "ip 194.2.81.61 " - "irno 3 " - "bpar 0xcc000 " - "port 0x260 " - "ether 00:E0:29:12:40:77 ")) -#endif - rtems_panic ("Can't attach Ethernet driver."); - - if (rtems_ka9q_execute_command("ifconfig rtems " - "broadcast 255.255.255.255")) - rtems_panic ("Can't configure Ethernet driver."); - - if (rtems_ka9q_execute_command ("arp add 255.255.255.255 " - "ether FF:FF:FF:FF:FF:FF")) - rtems_panic ("Can't add broadcast entry to ARP table."); - - if (rtems_ka9q_execute_command ("ifconfig rtems " - "netmask 255.255.255.0")) - rtems_panic ("Can't set netmask."); - - if (rtems_ka9q_execute_command ("route add default rtems")) - rtems_panic ("Can't add default route."); - - rtems_ka9q_execute_command ("route"); - - if (rtems_ka9q_execute_command ("arp gratuitous rtems")) - rtems_panic ("Can't send gratuitous ARP.\n"); - - printf("End of INIT\n\r"); - fflush(stdout); - -#ifdef SERVER - printf("Creation of SERVER SocketTask\n\r"); - fflush(stdout); - - task_name = rtems_build_name( 'T', 'A', '1', ' ' ); - if ((status = rtems_task_create( task_name, 20, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_INTERRUPT_LEVEL(0), - RTEMS_DEFAULT_ATTRIBUTES, &tid )) - != RTEMS_SUCCESSFUL){ - printf("status = %d\n",status); - rtems_panic ("Can't create task.\n"); - } - -#ifdef UDP - status = rtems_task_start(tid, testUdpServerSocket, 0); -#else - status = rtems_task_start(tid, testTcpServerSocket, 0); -#endif - -#endif /* SERVER */ - -#ifdef CLIENT - printf("Creation of CLIENT SocketTask\n\r"); - fflush(stdout); - - task_name = rtems_build_name( 'T', 'A', '2', ' ' ); - if ((status = rtems_task_create( task_name, 20, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_INTERRUPT_LEVEL(0), - RTEMS_DEFAULT_ATTRIBUTES, &tid )) - != RTEMS_SUCCESSFUL){ - printf("status = %d\n",status); - rtems_panic ("Can't create task.\n"); - } - -#ifdef UDP - status = rtems_task_start(tid, testUdpClientSocket, 0); -#else - status = rtems_task_start(tid, testTcpClientSocket, 0); -#endif - -#endif /* CLIENT */ - - status = rtems_task_delete( RTEMS_SELF ); -} - - - -rtems_task testUdpServerSocket( - rtems_task_argument argument - ){ - - int sd; - struct sockaddr_in server, from; - int fromlen; - char *tabChar; - int rc; - unsigned long msgId; - char *server_name= "localhost"; - unsigned short port; - - /****************************************/ - /* Now, we are going to test the socket */ - /****************************************/ - - printf("Task testServerSocket : created\n\r"); - fflush(stdout); - - port = DEFAULT_PORT_SERVER; - server_name = DEFAULT_IP_SERVER; - - bzero((void *)(&server), sizeof(server)); - server.sin_family = AF_INET; - server.sin_addr.s_addr = aton (server_name); - - server.sin_port = htons(port); - - sd = socket(AF_INET,SOCK_DGRAM, 0); - if (sd == -1) { - printf(" socket failed errno = %d\n", errno); - return ; - } - - rc = bind(sd, (struct sockaddr *)&server, sizeof(server)) ; - if (rc == -1) { - printf(" bind failed errno = %d\n", errno); - return ; - } - - tabChar = AllocBuffer(); - - if(!tabChar) { - printf("malloc failed ...\n"); - return ; - } - - bzero((void *)(&from), sizeof(from)); - from.sin_family = AF_INET; - from.sin_addr.s_addr = aton (DEFAULT_LISTEN_IP_SERVER); - fromlen = sizeof(from); - - msgId = 0; - - for(;;){ - rc=recvfrom(sd, tabChar, SIZE_MAX_RCV_BUFFER, 0, (struct sockaddr *)&from, &fromlen); - - if (rc < 0) { - printf("\n Recvfrom error %d\n\n",errno); - fflush(stdout); - } - else{ - msgId = CheckBuffer(tabChar); - } - if (msgId == 0) - break ; - } - - FreeBuffer(tabChar); - -} - - -rtems_task testUdpClientSocket( - rtems_task_argument argument - ){ - - int sd; - struct sockaddr_in server; - char *tabChar; - int i; - char *server_name= "localhost"; - unsigned short port; - unsigned long lenChar; - struct timespec timeToWait, timeRem; - - /****************************************/ - /* Now, we are going to test the socket */ - /****************************************/ - - printf("Task testClientSocket : created\n\r"); - fflush(stdout); - - port = DEFAULT_PORT_CLIENT; - server_name = DEFAULT_IP_CLIENT; - - bzero((void *)(&server), sizeof(server)); - server.sin_family = AF_INET; - server.sin_addr.s_addr = aton (server_name); - - server.sin_port = htons(port); - - sd = socket(AF_INET,SOCK_DGRAM, 0); - if (sd == -1) { - printf(" socket failed errno = %d\n", errno); - return ; - } - - while(1) { - tabChar = BuildBuffer(); - lenChar = *((unsigned long *)(tabChar)); - i = sendto(sd, tabChar, lenChar, 0, (struct sockaddr *)&server, sizeof(server)); - - if (i == -1) { - fprintf(stderr,"sendto() failed (at least local errors): %d\n", errno); - return ; - } - - timeToWait.tv_sec = 1; - timeToWait.tv_nsec = 0; - nanosleep(&timeToWait, &timeRem); - FreeBuffer(tabChar); - } - -} - -rtems_task testTcpServerSocket( - rtems_task_argument argument - ){ - int sd, psd; - struct sockaddr_in server; - struct sockaddr_in from; - int fromlen; - char *tabChar; - int rc; - int i; - char *server_name= "localhost"; - unsigned short port; - - - /****************************************/ - /* Now, we are going to test the socket */ - /****************************************/ - - printf("Task testServerSocket : created\n\r"); - fflush(stdout); - - port = DEFAULT_PORT_SERVER; - server_name = DEFAULT_IP_SERVER; - - bzero((void *)(&server), sizeof(server)); - server.sin_family = AF_INET; - server.sin_addr.s_addr = aton (server_name); - - server.sin_port = htons(port); - - sd = socket (AF_INET,SOCK_STREAM,0); - printf("socket() returns <%d>\n", sd); - fflush(stdout); - - if (sd<0) { - printf("socket() call failure: opening stream socket\n"); - fflush(stdout); - exit(-1); - } - - rc = bind( sd, (struct sockaddr *)&server, sizeof(server) ) ; - if (rc == -1) { - printf("bind failed errno = %d\n", errno); - fflush(stdout); - close_s(sd); - return; - } - printf("bind() returns <%d>\n", rc); - fflush(stdout); - - printf("Server Port is: %d\n", ntohs(server.sin_port)); - fflush(stdout); - rc = listen(sd,5); - printf("listen() returns <%d>\n", rc); - fflush(stdout); - fromlen = sizeof(from); - - tabChar = AllocBuffer(); - if(!tabChar) { - printf("malloc failed ...\n"); - fflush(stdout); - return; - } - - psd = accept(sd,(struct sockaddr *)&from, &fromlen); - printf("accept() returns <%d>\n", psd); - fflush(stdout); - - for(;;){ - rc = recv(psd, tabChar, SIZE_MAX_RCV_BUFFER, 0 ); - - if (rc == -1) { - printf("recv() failed errno = %d\n", errno); - fflush(stdout); - close_s(sd); - return; - } - - if (rc == 0) { - continue; - } - - if (CheckBuffer(tabChar) == 0){ - printf("Received %d bytes, data [%s] from client\n",rc,tabChar); - printf("Packet received:<%d> bytes\n", rc); - printf("Received:<"); - fflush(stdout); - tabChar += 8; - for (i=0; i\n"); - } - } - - FreeBuffer(tabChar); - -} - - -rtems_task testTcpClientSocket( - rtems_task_argument argument - ){ - int sd; - struct sockaddr_in server; - /*struct hostent *hp;*/ - struct sockaddr_in from; - int fromlen; - int i,retval; - char *tabChar; - char *server_name= "localhost"; - unsigned short port; - unsigned long lenChar; - struct timespec timeToWait, timeRem; - - /****************************************/ - /* Now, we are going to test the socket */ - /****************************************/ - - printf("Task testServerSocket : created\n\r"); - fflush(stdout); - - port = DEFAULT_PORT_CLIENT; - server_name = DEFAULT_IP_CLIENT; - - bzero((void *)(&server), sizeof(server)); - - sd = socket (AF_INET,SOCK_STREAM,0); - printf("socket() result:<%d>\n", sd); - fflush(stdout); - - if (sd<0) { - printf("opening stream socket\n"); - fflush(stdout); - return; - } - - server.sin_addr.s_addr = aton (server_name); - - server.sin_family = AF_INET; - server.sin_port = htons(port); - - /* Connect to TCP/SERVER */ - if ( (retval = connect(sd, (struct sockaddr *)&server, sizeof(server))) < 0 ) { - close_s(sd); - perror("connecting stream socket"); - fflush(stdout); - exit(0); - } - printf("connect() result:<%d>\n", retval); - fflush(stdout); - fromlen = sizeof(from); - if ( (retval = getpeername(sd,(struct sockaddr *)&from,&fromlen)) <0){ - perror("could't get peername\n"); - fflush(stdout); - exit(1); - } - printf("getpeername() result:<%d>\n", retval); - printf("Connected to TCP/Server:"); - printf("%s:%d\n", inet_ntoa((int32)(from.sin_addr.s_addr)), ntohs(from.sin_port)); - fflush(stdout); - - printf("Now, let's send packets..."); - fflush(stdout); - - while(1) { - - tabChar = BuildBuffer(); - lenChar = *((unsigned long *)(tabChar)); - - i = send(sd, tabChar, lenChar, 0); - if (i == -1) - { - fprintf(stderr,"send() failed (at least locally detected errors)\n"); - fflush(stdout); - return; - } - - timeToWait.tv_sec = 1; - timeToWait.tv_nsec = 0; - nanosleep(&timeToWait, &timeRem); - FreeBuffer(tabChar); - - } - - close_s(sd); -} - diff --git a/socket/pgmHost/Makefile b/socket/pgmHost/Makefile deleted file mode 100644 index 035a130..0000000 --- a/socket/pgmHost/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# -# $Id$ -# - -# we use host compiler in this directory -USE_HOST_COMPILER=yes - -# C source names, if any, go here -- minus the .c -C_PIECES=buffer serverTcp clientTcp serverUdp clientUdp -C_FILES=$(C_PIECES:%=%.c) -C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) - -H_FILES= - -SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES) -OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES) - -include $(RTEMS_MAKEFILE_PATH)/Makefile.inc -include $(RTEMS_CUSTOM) -include $(PROJECT_ROOT)/make/leaf.cfg - -PGMS=$(ARCH)/serverTcp$(EXEEXT) $(ARCH)/clientTcp$(EXEEXT) \ - $(ARCH)/serverUdp$(EXEEXT) $(ARCH)/clientUdp$(EXEEXT) - -# -# (OPTIONAL) Add local stuff here using += -# - -DEFINES += -CPPFLAGS += -I.. -CFLAGS += - -LD_PATHS += -LD_LIBS += $(ARCH)/buffer.o -LDFLAGS += - -# -# Add your list of files to delete here. The config files -# already know how to delete some stuff, so you may want -# to just run 'make clean' first to see what gets missed. -# 'make clobber' already includes 'make clean' -# - -CLEAN_ADDITIONS += $(HOST_ARCH) -CLOBBER_ADDITIONS += buffer.c - -all: $(ARCH) buffer.c $(OBJS) $(SRCS) $(PGMS) - $(INSTALL_VARIANT) -m 555 ${PGMS} ${PROJECT_RELEASE}/tests - $(INSTALL_VARIANT) -m 555 ${PGMS} ${PROJECT_RELEASE}/samples - -buffer.c: - $(LN) ../buffer.c . diff --git a/socket/pgmHost/clientTcp.c b/socket/pgmHost/clientTcp.c deleted file mode 100644 index 407d0ce..0000000 --- a/socket/pgmHost/clientTcp.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * clientTcp.c : generate an executable to test the TCP Sockets. - * the RTEMS target must be configured as server. - * Don't forget to change the IP address. - * - * $Id$ - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "../buffer.h" - -#define DEFAULT_IP "194.2.81.61" -#define DEFAULT_LISTEN_IP "194.2.81.126" - -int main(int argc, char** argv ) -{ - int sd; - struct sockaddr_in server; - struct hostent *hp; - struct sockaddr_in from; - int fromlen; - int i,retval; - char *tabChar; - char *server_name= "localhost"; - unsigned short port; - unsigned long lenChar; - struct timespec timeToWait, timeRem; - - printf("main begin...\n"); - port = DEFAULT_PORT_SERVER; - server_name = DEFAULT_IP; - - bzero(&server, sizeof(server)); - - sd = socket (AF_INET,SOCK_STREAM,0); - printf("socket() result:<%d>\n", sd); - - if (sd<0) { - printf("opening stream socket\n"); - exit(-1); - } - - if (inet_aton (server_name, (struct in_addr*)&(server.sin_addr.s_addr)) == 0) { - printf("%s : IP address: bad format\n", - argv[0]); - } - - server.sin_family = AF_INET; - server.sin_port = htons(port); - - /* Connect to TCP/SERVER */ - if ( (retval = connect(sd, &server, sizeof(server))) < 0 ) { - close(sd); - perror("connecting stream socket"); - exit(0); - } - printf("connect() result:<%d>\n", retval); - fromlen = sizeof(from); - if ( (retval = getpeername(sd,&from,&fromlen)) <0){ - perror("could't get peername\n"); - exit(1); - } - printf("getpeername() result:<%d>\n", retval); - printf("Connected to TCP/Server:"); - printf("%s:%d\n", inet_ntoa(from.sin_addr), ntohs(from.sin_port)); - - if ((hp = gethostbyaddr((const char *)(&from.sin_addr.s_addr), - sizeof(from.sin_addr.s_addr),AF_INET)) == NULL) - fprintf(stderr, "Can't find host %s\n", inet_ntoa(from.sin_addr)); - else - printf("(Name is : %s)\n", hp->h_name); - - printf("Now, let's send packets..."); - - while(1) { - - tabChar = BuildBuffer(); - lenChar = *((unsigned long *)(tabChar)); - - i = send(sd, tabChar, lenChar, 0); - if (i == -1) - { - fprintf(stderr,"send() failed (at least locally detected errors)\n"); - return -1; - } - timeToWait.tv_sec = 1; - timeToWait.tv_nsec = 0; - nanosleep(&timeToWait, &timeRem); - - FreeBuffer(tabChar); - - } - - close(sd); - exit (0); -} - - diff --git a/socket/pgmHost/clientUdp.c b/socket/pgmHost/clientUdp.c deleted file mode 100644 index 90070c4..0000000 --- a/socket/pgmHost/clientUdp.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * clientUdp.c : generate an executable to test the UDP Sockets. - * the RTEMS target must be configured as server. - * Don't forget to change the IP address. - * - * $Id$ - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "../buffer.h" - -#define DEFAULT_IP "194.2.81.61" -#define DEFAULT_LISTEN_IP "194.2.81.126" - - -int main(int argc, char** argv) -{ - int sd; - struct sockaddr_in server; - int i; - char *tabChar; - char *server_name= "localhost"; - unsigned short port; - unsigned long lenChar; - struct timespec timeToWait, timeRem; - - - printf("main begin...\n"); - port = DEFAULT_PORT_SERVER; - server_name = DEFAULT_IP; - - bzero(&server, sizeof(server)); - - sd = socket (AF_INET,SOCK_DGRAM,0); - if (inet_aton (server_name, (struct in_addr*)&(server.sin_addr.s_addr)) == 0) { - printf("%s : IP address: bad format\n", - argv[0]); - } - - server.sin_family = AF_INET; - server.sin_port = htons(port); - - printf("server : %X port : %X\n", server.sin_addr.s_addr, server.sin_port); - - while(1) { - - tabChar = BuildBuffer(); - lenChar = *((unsigned long *)(tabChar)); - i = sendto(sd, tabChar, lenChar, 0, (struct sockaddr *)&server, sizeof(server)); - - if (i == -1) { - fprintf(stderr,"sendto() failed : %d\n", errno); - return -1; - } - - timeToWait.tv_sec = 1; - timeToWait.tv_nsec = 0; - nanosleep(&timeToWait, &timeRem); - - FreeBuffer(tabChar); - } - return 0; -} - diff --git a/socket/pgmHost/serverTcp.c b/socket/pgmHost/serverTcp.c deleted file mode 100644 index 413ac1e..0000000 --- a/socket/pgmHost/serverTcp.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * serverTcp.c : generate an executable to test the TCP Sockets. - * the RTEMS target must be configured as client. - * Don't forget to change the IP address. - * - * $Id$ - */ - - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "../buffer.h" - -#define DEFAULT_IP "194.2.81.126" -#define DEFAULT_LISTEN_IP "194.2.81.61" - -int main(int argc, char** argv) -{ - int sd, psd; - struct sockaddr_in server; - struct sockaddr_in from; - int fromlen; - char *tabChar; - int rc; - int i; - char *server_name= "localhost"; - unsigned short port; - - - printf("main begin...\n"); - port = DEFAULT_PORT_CLIENT; - server_name = DEFAULT_IP; - - bzero(&server, sizeof(server)); - server.sin_family = AF_INET; - - if (inet_aton (server_name, (struct in_addr*)&(server.sin_addr.s_addr)) == 0) { - printf("Usage : %s IP address in ascii format : xxx.xxx.xxx.xxx\n", - argv[0]); - return 1; - } - - server.sin_port = htons(port); - - sd = socket (PF_INET,SOCK_STREAM,0); - printf("socket() returns <%d>\n", sd); - - if (sd<0) { - printf("socket() call failure: opening stream socket\n"); - exit(-1); - } - - rc = bind( sd, &server, sizeof(server) ) ; - if (rc == -1) { - printf("%s : bind failed errno = %d\n", argv[0], errno); - close(sd); - return 1; - } - printf("bind() returns <%d>\n", rc); - - printf("Server Port is: %d\n", ntohs(server.sin_port)); - rc = listen(sd,5); - printf("listen() returns <%d>\n", rc); - fromlen = sizeof(from); - - tabChar = AllocBuffer(); - if(!tabChar) { - printf("malloc failed ...\n"); - return 1; - } - - psd = accept(sd, &from, &fromlen); - printf("accept() returns <%d>\n", psd); - - - printf("TCP Server : ready to receive messages...\n"); - - for(;;){ - rc = recv(psd, tabChar, SIZE_MAX_RCV_BUFFER, 0 ); - - if (rc == -1) { - printf("%s : recv() failed errno = %d\n", argv[0], errno); - close(sd); - return 1; - } - - if (rc == 0) { - continue; - } - if (CheckBuffer(tabChar) == 0){ - printf("Received %d bytes, data [%s] from client\n",rc,tabChar); - printf("Packet received:<%d> bytes\n", rc); - printf("Received:<"); - tabChar += 8; - for (i=0; i\n"); - } - } - - FreeBuffer(tabChar); - -} - diff --git a/socket/pgmHost/serverUdp.c b/socket/pgmHost/serverUdp.c deleted file mode 100644 index 60ed9de..0000000 --- a/socket/pgmHost/serverUdp.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * serverUdp.c : generate an executable to test the UDP Sockets. - * the RTEMS target must be configured as client. - * Don't forget to change the IP address. - * - * $Id$ - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "../buffer.h" - -#define DEFAULT_IP "194.2.81.126" -#define DEFAULT_LISTEN_IP "194.2.81.61" - -int main(int argc, char** argv) -{ - - int sd; - struct sockaddr_in server, from; - int fromlen; - char *tabChar; - int rc; - unsigned long msgId; - char *server_name= "localhost"; - unsigned short port; - - port = DEFAULT_PORT_CLIENT; - server_name = DEFAULT_IP; - - bzero(&server, sizeof(server)); - server.sin_family = AF_INET; - inet_aton (server_name, (struct in_addr*)&(server.sin_addr.s_addr)); - - server.sin_port = htons(port); - - sd = socket(AF_INET,SOCK_DGRAM, 0); - if (sd == -1) { - printf(" socket failed errno = %d\n", errno); - return 0; - } - - rc = bind(sd, (struct sockaddr *)&server, sizeof(server)) ; - if (rc == -1) { - printf(" bind failed errno = %d\n", errno); - return 0; - } - - tabChar = AllocBuffer(); - - if(!tabChar) { - printf("malloc failed ...\n"); - return 0; - } - - bzero(&from, sizeof(from)); - from.sin_family = AF_INET; - inet_aton (DEFAULT_LISTEN_IP, (struct in_addr*)&(from.sin_addr.s_addr)); - fromlen = sizeof(from); - - printf("UDP Server : ready to receive messages...\n"); - - msgId = 0; - - for(;;){ - rc=recvfrom(sd, tabChar, SIZE_MAX_RCV_BUFFER, 0, (struct sockaddr *)&from, &fromlen); - - if (rc < 0) { - printf("\n Recvfrom error %d\n\n",errno); - } - else{ - msgId = CheckBuffer(tabChar); - } - if (msgId == 0) - break ; - } - - FreeBuffer(tabChar); - return 0; -} - diff --git a/socket/system.h b/socket/system.h deleted file mode 100644 index 3c74c5d..0000000 --- a/socket/system.h +++ /dev/null @@ -1,53 +0,0 @@ -/* system.h - * - * This include file contains information that is included in every - * function in the test set. - * - * COPYRIGHT (c) 1989-1998. - * On-Line Applications Research Corporation (OAR). - * Copyright assigned to U.S. Government, 1994. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.OARcorp.com/rtems/license.html. - * - * $Id$ - */ - -#include - -/* functions */ - -rtems_task Init( - rtems_task_argument argument -); - -rtems_task testUdpServerSocket( - rtems_task_argument argument -); -rtems_task testUdpClientSocket( - rtems_task_argument argument -); -rtems_task testTcpServerSocket( - rtems_task_argument argument -); -rtems_task testTcpClientSocket( - rtems_task_argument argument -); - -/* configuration information */ - -#define CONFIGURE_SPTEST - -#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE - -#include - -/* global variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - -/* end of include file */ -- cgit v1.2.3