FreeCalypso > hg > fc-magnetite
annotate src/gpf2/tst/drv/socket.c @ 581:a0a45c5eb3ef
gsmcomp.c: bumping trace partition size to 220 like in gprscomp.c
This change is safe in terms of RAM usage because all of these partition
pools have already been moved from XRAM to IRAM earlier, and our IRAM
usage in VO configs is currently quite low - the one near the limit
is XRAM on C11x.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 29 Jan 2019 03:52:49 +0000 |
parents | cd37d228dae0 |
children |
rev | line source |
---|---|
294
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 | File: socket.c |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 | Copyright 2002 Texas Instruments Berlin, AG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 | All rights reserved. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 | This file is confidential and a trade secret of Texas |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 | Instruments Berlin, AG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 | The receipt of or possession of this file does not convey |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 | any rights to reproduce or disclose its contents or to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 | manufacture, use, or sell anything it may describe, in |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 | whole, or in part, without the specific written consent of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 | Texas Instruments Berlin, AG. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 +----------------------------------------------------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 | Purpose : This Modul contains the socket driver adaptation |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 +----------------------------------------------------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #define GNU_COMPILER |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #undef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #undef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /*==== INCLUDES =============================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #if defined _NUCLEUS_ || defined _TOOLS_ /* socket-driver running on windows OS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 /*lint -e717 suppress info do...while(0); */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /*lint -esym(550,rc) suppress info not accessed */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 /*lint -e813, suppress Info 813: auto variable has size > 100 -> uncritical in this context */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /*lint -e801, suppress Info 801: Use of goto is deprecated */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include <windows.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include <winsock.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #include <stdio.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #include <stdio.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 #include <fcntl.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 #include <io.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 #endif /* SOCK_TRACE */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 #endif /* #ifdef _NUCLEUS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 #ifdef _PSOS_ /* socket-driver running on pSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #define _PNA_30_BACK |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 #include <psos.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #include "bsp.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 #include <pna.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 #include <prepc.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 #include <rescfg.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #endif /* #ifdef _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 #include "vxWorks.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 #include "sockLib.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 #include "inetLib.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 #include "ioLib.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 #include "selectLib.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 #include "errnoLib.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 #include "logLib.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 /* undefine the MALLOC and FREE of VxWorks to avoid warnings */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 #undef MALLOC |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 #undef FREE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 /* More operating systems go here */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 #ifdef _LINUX_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 #include <sys/types.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 #include <sys/socket.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 #include <netinet/in.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 #include <netinet/tcp.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 #include <sys/ioctl.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 #include <errno.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 #include <netdb.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 #ifdef _SOLARIS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 #include <sys/types.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 #include <sys/socket.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 #include <netinet/in.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 #include <netinet/tcp.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 #include <sys/ioctl.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 #include <errno.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 #include <netdb.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 #include <sys/filio.h> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 #ifndef OLD_FRAME |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 #include "typedefs.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 #include "os.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 #include "socket.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 #include "tools.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 #include "vsi.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 #include "drvconf.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 #include "tstheader.h" |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 /*==== DEFINITIONS ==========================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 #define MAX_PENDING_CONNECTS 5 /* The backlog allowed for listen() */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 #define SEND_TIMEOUTUSEC 500 /* minimal timeout value for sending*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 #define INVALID_HANDLE NULL |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 #define INVALID_SIGNALTYPE 0 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 #define NO_FLAGS_SET 0 /* Used with recv()/send() */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 #define MAX_ETH_LEN (1500-40) /* Maximum size of a Ethernet packet without IP headers */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 #define WRBUF_LEN 2048 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 #define ALLOWED_SOCKET_SIGNALS (DRV_SIGTYPE_READ|DRV_SIGTYPE_CONNECT|DRV_SIGTYPE_DISCONNECT) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 #if defined _NUCLEUS_ || defined _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 typedef ULONG SIZETYPE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 #define GETTIME(t) (t = GetTickCount()) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 #define GETREADSIZE(sok,psiz) ioctlsocket(sok, FIONREAD,(ULONG*)psiz) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 #define READ_SOCKET(s,b,l) recv((s),(b),(int)(l),NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 #define WRITE_SOCKET(s,b,l) send((s),(const char*)(b),(l),NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 #define CLOSE_SOCKET(s) closesocket(s) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 #endif /* #ifdef _NUCLEUS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 #ifdef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 typedef int SOCKET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 typedef int SIZETYPE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 typedef struct hostent HOSTENT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 #define h_addr h_addr_list[0] |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 typedef HOSTENT * PHOSTENT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 #define FAR /**/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 #define SOCKADDR_IN struct sockaddr_in |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 #define SOCKET_ERROR (-1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 #define INVALID_SOCKET (-1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 #define GETTIME(t) os_GetTime (0, &(t)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 #define GETREADSIZE(sok,psiz) ioctl(sok, FIOREAD,(char*)psiz) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 #define READ_SOCKET(s,b,l) recv((s),(b),(int)(l),NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 #define WRITE_SOCKET(s,b,l) send((s),(char *)(b),(int)(l),NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 #define CLOSE_SOCKET(s) close(s) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 #endif /* #ifdef _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 #define SOCKADDR_IN struct sockaddr_in |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 #define FAR /* nil */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 #define SOCKET_ERROR ERROR |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 #define INVALID_SOCKET ERROR |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 typedef int SOCKET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 typedef int SIZETYPE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 #define GETTIME(t) os_GetTime (0, &(t)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 #define GETREADSIZE(sok,psiz) ioctl(sok, FIONREAD, (int)psiz) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 #define READ_SOCKET(s,b,l) recv((s), (b), (int)(l), NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 #define WRITE_SOCKET(s,b,l) send((s), (char *)(b), (int)(l), NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 #define CLOSE_SOCKET(s) close(s) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 #if defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 #define SOCKADDR_IN struct sockaddr_in |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 #define FAR /* nil */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 #define SOCKET_ERROR (-1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 #define INVALID_SOCKET (-1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 typedef int SIZETYPE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 #define GETTIME(t) os_GetTime (0, &(t)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 #define GETREADSIZE(sok,psiz) ioctl(sok, FIONREAD, (int)psiz) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 #define READ_SOCKET(s,b,l) recv((s), (b), (int)(l), NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 #define WRITE_SOCKET(s,b,l) send((s), (char *)(b), (int)(l), NO_FLAGS_SET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 #define CLOSE_SOCKET(s) close(s) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 #define PORT_NO 6392 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 #define TX_BUFFER_SIZE 8192 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 #define RX_BUFFER_SIZE 8192 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 #define TX_TIMEOUT_MSEC 10000 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 #define RX_TIMEOUT_MSEC 10000 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 #define SOCKET_PRIO 115 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 #define SOCKET_STACK 8192 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 #elif defined _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 #define SOCKET_PRIO 110 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 #define SOCKET_STACK 1024 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 #elif defined _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 #define SOCKET_PRIO 1 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 #define SOCKET_STACK 1024 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 #define SOCKET_PRIO 1 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 #define SOCKET_STACK 1024 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 #define TI_MODE 0x0001 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 /*==== TYPES ================================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 typedef enum |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 SST_PL0, /* 0 bytes of packet length read*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 SST_PL1, /* 1 bytes of packet length read*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 SST_DATA0, /* 0 bytes of data read*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 SST_DATAx /* not all data read */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 } T_SOCK_STATE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 typedef struct |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 USHORT Connect; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 SOCKET Listener; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 SOCKET Socket; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 USHORT EnabledSignals; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 OS_HANDLE ThreadID ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 USHORT SocketHandle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 T_DRV_CB_FUNC Callback; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 } Client_Type; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 /*==== EXTERNALS ============================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 EXTERN BOOL socket_flush; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 /*==== LOCAL VARS ===========================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 LOCAL socket_DCB_Type L_DCB ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 LOCAL Client_Type L_ClientData ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 LOCAL BOOL L_ThreadActive ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 LOCAL T_DRV_SIGNAL SocketSignal; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 LOCAL UBYTE wrbuf[WRBUF_LEN+2]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 LOCAL UBYTE *wrbuf_pos = wrbuf; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 T_SOCK_STATE sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 ULONG fh_sock = -1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 LOCAL char stbuf[80]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 LOCAL BOOL isLittleEndian = TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 int tst_socket; /* for psos */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 int tst_socket_initialized; /* flag for pSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 int tst_socket_in_TxLen; /* for pSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 /*==== DIAGNOSTICS ==========================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 #include <STDIO.H> |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 static char *logfile = "socket.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 static char *bufferfullfile = "bufferfull.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 static char *inprocessfile = "inprogress.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 static char *noconnectfile1 = "noconnect1.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 static char *noconnectfile2 = "noconnect2.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 static char *noconnectfile3 = "noconnect3.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 static char *readerrorfile = "readerror.log"; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 static FILE *fp = NULL; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 /*==== END DIAGNOSTICS ======================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 extern USHORT ext_data_pool_handle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 GLOBAL ULONG drv_socket_task_stack_size = SOCKET_STACK; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 GLOBAL USHORT drv_socket_task_prio = SOCKET_PRIO; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 /*==== PRIVATE FUNCTIONS ====================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 | Function : L_CreateThread |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 | Description : This function creates a thread. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 | Parameters : ThreadFunc - pointer to the function beeing a thread |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 | Return : FALSE - Thread not created |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 | TRUE - Thread create (Thread ID stored in |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 | L_ClientData.ThreadID |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 #ifdef OLD_FRAME |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 BOOL L_CreateThread (USHORT (*ThreadFunc)(USHORT,ULONG)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 return (CreateThread ((LPSECURITY_ATTRIBUTES) NULL, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 0, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 (LPTHREAD_START_ROUTINE)ThreadFunc, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 (LPVOID) NULL, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 0, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 &L_ClientData.ThreadID) != NULL); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 BOOL L_CreateThread (void (*ThreadFunc)(T_HANDLE,ULONG)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 if ( os_CreateTask (0, (char*)"SOCKET", ThreadFunc, drv_socket_task_stack_size, drv_socket_task_prio, &L_ClientData.ThreadID, ext_data_pool_handle) < 0L ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 return FALSE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 if ( os_StartTask (0, L_ClientData.ThreadID, 0) < 0 ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 return FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 return TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 | Function : L_SetSocketBuffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 | Description : This function sets the IP read and write buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 | Parameters : in_TxLen - size of transmission buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 | in_RxLen - size of receiver buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 | Return : FALSE - either the read or write buffer could not |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 | be set. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 | TRUE - OK |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 LOCAL BOOL L_SetSocketBuffer (USHORT in_TxLen, USHORT in_RxLen) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 int in_TxLen1 = (int) in_TxLen; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 int in_RxLen1 = (int) in_RxLen; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 #ifndef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 int nodelay = TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 #if defined (_VXWORKS_) || defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 struct linger nolinger = {0, 0}; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 int linger = TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 int rc=0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 if (in_TxLen > 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 if ( (rc=setsockopt(L_ClientData.Socket, SOL_SOCKET, SO_SNDBUF, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 (char*)&in_TxLen1, sizeof(in_TxLen1))) != 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 rc = errnoGet (); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 #if defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 rc = errno; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 rc = WSAGetLastError(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 #if defined _NUCLEUS_ || defined _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 printf("SOCKET: setsockopt() returned error code %d\n", rc); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 return FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 #if defined (_VXWORKS_) || defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 if (setsockopt(L_ClientData.Socket, SOL_SOCKET, SO_LINGER, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 (char*)&nolinger, sizeof(nolinger))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 if (setsockopt(L_ClientData.Socket, SOL_SOCKET, (int)SO_DONTLINGER, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 (char*)&linger, sizeof(linger))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 return FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 if (setsockopt(L_ClientData.Socket, IPPROTO_TCP, TCP_NODELAY, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 (char*)&nodelay, sizeof(nodelay))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 return FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 #else /* PSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 tst_socket_in_TxLen = in_TxLen; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 #endif /* PSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 if (in_RxLen > 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 if (setsockopt(L_ClientData.Socket, SOL_SOCKET, SO_RCVBUF, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 (char *) &in_RxLen1, sizeof(in_RxLen1))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 return FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 return TRUE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 | Function : L_Disconnect |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 | Description : This function is called when the connection to the peer entity |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 | is lost. If the release signal is set a signal is generated. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 | Return : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 LOCAL void L_Disconnect (void) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 L_ClientData.Connect = FALSE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 if (L_ClientData.EnabledSignals != INVALID_SIGNALTYPE) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 SocketSignal.SignalType = DRV_SIGTYPE_DISCONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 SocketSignal.DrvHandle = L_ClientData.SocketHandle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 (*L_ClientData.Callback)(&SocketSignal) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 | Function : L_AsyncSelect |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 | Description : This function waits (blocking) for either something to read |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 | or an execption on the socket. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 | Return : FALSE - failure on the socket |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 | TRUE - a read event was signalled |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 LOCAL BOOL L_AsyncSelect (void) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 fd_set fd_r ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 fd_set fd_e ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 int status, rc; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 /* wait for possibility to read */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 FD_ZERO(&fd_r); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 FD_SET(L_ClientData.Socket, &fd_r); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 FD_ZERO(&fd_e); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 FD_SET(L_ClientData.Socket, &fd_e); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 status = select(FD_SETSIZE, &fd_r, NULL, &fd_e, (struct timeval *) 0); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 if (status > 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 if (!FD_ISSET (L_ClientData.Socket, &fd_e)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 if (L_ClientData.Callback != NULL) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 if (FD_ISSET (L_ClientData.Socket, &fd_r)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 SIZETYPE size ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 if ((rc = GETREADSIZE( L_ClientData.Socket, &size)) != 0 || !size) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 if (fh_sock != -1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 char sstop[10]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 ULONG stop = GetTickCount(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 sprintf(sstop, "%03d:%03d", (stop/1000) % 1000, stop % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 sprintf(stbuf, "reset at %s rc=%d size=%d left %d \n", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 sstop, rc, size, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 wrbuf_pos-wrbuf); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 write (fh_sock, stbuf, strlen(stbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 /* close(fh_sock); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 fh_sock = -1; */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 os_SuspendTask ( 0, 2 ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 CLOSE_SOCKET (L_ClientData.Socket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 L_ClientData.Socket = INVALID_SOCKET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 wrbuf_pos = wrbuf; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 return FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 /* Indicate that it is possible to read something */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 if (L_ClientData.EnabledSignals & DRV_SIGTYPE_READ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 SocketSignal.SignalType = DRV_SIGTYPE_READ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 SocketSignal.DrvHandle = L_ClientData.SocketHandle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 (*L_ClientData.Callback)(&SocketSignal) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 return TRUE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 return FALSE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 | Function : L_ClientThread |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 | Description : This function is a thread used if the driver is configured to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 | be a client. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 | Return : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 void L_ClientThread (T_HANDLE Handle, ULONG Value ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 L_ThreadActive = TRUE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 L_SetSocketBuffer (L_DCB.tx_buffer_size, L_DCB.rx_buffer_size) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 /*------------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 Listen what's goning on on the socket |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 -------------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 while (L_ThreadActive) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 if (!L_AsyncSelect()) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 L_ThreadActive = FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 L_Disconnect() ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 | Function : L_ServerThread |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 | Description : This function is a thread used if the driver is configured to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 | be a server. It serves only one client. It cycles between |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 | two modes, wait for a client to connect and listening on the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 | connection for any further action. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 | The thread exits when the flag L_ThreadActive is set to false. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 | Return : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 void L_ServerThread (T_HANDLE TaskHandle, ULONG Value) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 BOOL BufferSizeSet; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 SOCKADDR_IN local_sin; /* Local socket - internet style */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 SOCKADDR_IN clientAddr; /* client */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 int sockAddrSize = sizeof (struct sockaddr_in); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 memset ((char *) &local_sin, 0, sockAddrSize); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 local_sin.sin_len = (u_char) sockAddrSize; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 #endif/* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 L_ClientData.Listener = socket (AF_INET, SOCK_STREAM, 0); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 if (L_ClientData.Listener == INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 goto error; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 if (L_DCB.port == SOCKET_INVALID_PORT) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 goto error; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 local_sin.sin_addr.s_addr = htonl(INADDR_ANY); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 local_sin.sin_family = AF_INET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 local_sin.sin_port = htons(L_DCB.port); /* Convert to network ordering */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 /*------------------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 Associate an address with a socket. (bind) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 -------------------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 #ifdef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 if (bind (L_ClientData.Listener, (struct sockaddr_in*) &local_sin, sizeof(local_sin)) != 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 /* Look at the following cast of local_sin. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 * This is from VxWorks Network 5.4 Programmer’s Guide, example 7-1, page 131 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 if (bind (L_ClientData.Listener, (struct sockaddr*) &local_sin, sockAddrSize) == ERROR) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 if (bind (L_ClientData.Listener, (const struct sockaddr FAR *) &local_sin, sizeof(local_sin)) != 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 CLOSE_SOCKET (L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 goto error; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 if (listen (L_ClientData.Listener, MAX_PENDING_CONNECTS) == ERROR) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 if (listen (L_ClientData.Listener, MAX_PENDING_CONNECTS) != 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 CLOSE_SOCKET (L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 goto error; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 BufferSizeSet = FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 L_ThreadActive = TRUE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 while (L_ThreadActive) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 /*------------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 Wait for somebody to connect |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 -------------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 if (L_ClientData.Socket != INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 if (fh_sock != -1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 char sstop[10]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 ULONG stop = GetTickCount(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 sprintf(sstop, "%03d:%03d", (stop/1000) % 1000, stop % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 sprintf(stbuf, "close at %s socket=%d\n", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 sstop, L_ClientData.Socket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 write (fh_sock, stbuf, strlen(stbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 /* close(fh_sock); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 fh_sock = -1; */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 CLOSE_SOCKET (L_ClientData.Socket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 L_ClientData.Socket = INVALID_SOCKET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 wrbuf_pos = wrbuf; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 if ((L_ClientData.Socket = accept (L_ClientData.Listener, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 (struct sockaddr *) &clientAddr, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 &sockAddrSize)) != ERROR) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 L_ClientData.Socket = accept(L_ClientData.Listener, NULL, NULL) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 if (L_ClientData.Socket != INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 if (fh_sock == -1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 fh_sock = open("SOCK_S.dbg", O_WRONLY| O_TEXT| O_TRUNC| O_CREAT, 0666); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 if (fh_sock != -1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 char sstop[10]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 ULONG stop = GetTickCount(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 sprintf(sstop, "%03d:%03d", (stop/1000) % 1000, stop % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 sprintf(stbuf, "accept at %s socket=%d listener=%d\n", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 sstop, L_ClientData.Socket, L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 write (fh_sock, stbuf, strlen(stbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 #ifdef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 ULONG tid; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 int err; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 /* for pSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 /* wait for TST task */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 while( t_ident( FRM_TST_NAME, 0, &tid ) != 0 ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 tm_wkafter( 10 ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 tst_socket = shr_socket( L_ClientData.Socket, (int)tid ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 if( tst_socket < 0 ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 err = errno; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 goto error; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 if (!BufferSizeSet) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 L_SetSocketBuffer (L_DCB.tx_buffer_size, L_DCB.rx_buffer_size) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 /* Signalisiere Connect */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 L_ClientData.Connect = TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 if (L_ClientData.EnabledSignals & DRV_SIGTYPE_CONNECT) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 SocketSignal.SignalType = DRV_SIGTYPE_CONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 SocketSignal.DrvHandle = L_ClientData.SocketHandle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 (*L_ClientData.Callback)(&SocketSignal) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 /*------------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 Listen what's goning on on the socket |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 -------------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 while (L_ThreadActive) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 if (!L_AsyncSelect()) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 L_Disconnect() ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 break ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 error: |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 #ifndef OLD_FRAME |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 for(;;) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 os_SuspendTask( 0, 1000 ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 | Function : socket_Create |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 | Description : This function is used to set up the driver to act as a |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 | server. The function tries to initialize the socket, creates |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 | a thread in which it awaits first awaits the establishement |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 | of a connection by a client. As soon as a client has |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 | connected a signal (SOCKET_CONNECTED) is generated (call |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 | socket_SetSignal() to activate a signal). From this time the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 | driver is able to send data (socket_write()) to the client and |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 | to read received data (socket_read()). To get notified about |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 | the reception of data the apropriate signal has to be set. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 | In the case of a successful completion the driver returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 | DRV_OK. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 | If the driver is already busy DRV_INPROCESS is returned. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 | If the driver is not configured, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 | DRV_ NOTCONFIGURED. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 | Return : DRV_OK - Function successful |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 | DRV_INPROCESS - The driver is currently reading data. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 | The data is incomplete. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 | DRV_NOTCONFIGURED - The driver is not yet configured |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 | SOCKET_ERRORUNSPEC - Error occured during initialization |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 LOCAL UBYTE L_CreateServer (void) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 if (!L_CreateThread (L_ServerThread)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 CLOSE_SOCKET (L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 printf("SOCKET: now listening on port %i ...\n",L_DCB.port); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 | Function : socket_WriteToOS |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 | Description : This function is used to write data to the driver of operating |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 | system. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 | The parameter thr_BufferSize contains the number of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 | characters to write. In the case of a successful completion, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 | the function returns DRV_OK. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 | Parameters : in_BufferPtr - This parameter points to the buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 | that is passed to the driver for |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 | further processing |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 | thr_BufferSize - number of characters to write. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 | Return : DRV_OK - Function successful |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 | DRV_INPROCESS - Driver is busy writing data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 | SOCKET_NOCONNECT - Connection not available |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 LOCAL UBYTE socket_WriteToOS (void* in_BufferPtr, USHORT thr_BufferSize) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 int err; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 USHORT c_written; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 #ifndef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 fd_set fd_w; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 fd_set fd_e; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 struct timeval tv; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 if (L_ClientData.Socket == INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 return SOCKET_NOCONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 if ( L_ClientData.Connect == FALSE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 return SOCKET_NOCONNECT ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 tv.tv_sec = (int)(L_DCB.tx_timeout_msec / 1000) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 tv.tv_usec = SEND_TIMEOUTUSEC ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 FD_ZERO(&fd_w); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 FD_SET(L_ClientData.Socket, &fd_w); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 FD_ZERO(&fd_e); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 FD_SET(L_ClientData.Socket, &fd_e); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 if (select(FD_SETSIZE, NULL, &fd_w, &fd_e, &tv) <= 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 char buffer[200]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 char *ptr = in_BufferPtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 char c = ptr[21]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 fp = fopen(inprocessfile, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 if ( *ptr == 'P' ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 ptr[21] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 ptr[thr_BufferSize] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 strcpy (buffer, "errno:" ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 sprintf (&buffer[6], "%8d", WSAGetLastError() ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 buffer[14] = ' '; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 memcpy (&buffer[15], ptr, (thr_BufferSize)+1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 fprintf (fp, "%s\n", buffer ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 ptr[21] = c; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 err = errnoGet (); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 err = errno; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 printf("SOCKET: socket write failed with error code: %d\n",err ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 return DRV_INPROCESS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 if (FD_ISSET (L_ClientData.Socket, &fd_e)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 char buffer[200]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 char *ptr = in_BufferPtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 char c = ptr[21]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 fp = fopen(noconnectfile1, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 if ( *ptr == 'P' ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 ptr[21] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 ptr[thr_BufferSize] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 strcpy (buffer, "errno:" ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 sprintf (&buffer[6], "%8d", WSAGetLastError() ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 buffer[14] = ' '; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 memcpy (&buffer[15], ptr, (thr_BufferSize)+1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 fprintf (fp, "%s\n", buffer ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 ptr[21] = c; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 return SOCKET_NOCONNECT ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 /*--------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 Send the data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 ---------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 c_written = (USHORT) WRITE_SOCKET(L_ClientData.Socket, in_BufferPtr, (USHORT)thr_BufferSize); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 if (c_written == (USHORT)SOCKET_ERROR || c_written != thr_BufferSize) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 char buffer[200]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 char *ptr = in_BufferPtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 char c = ptr[21]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 fp = fopen(noconnectfile2, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 if ( *ptr == 'P' ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 ptr[21] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 ptr[thr_BufferSize] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 strcpy (buffer, "errno:" ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 sprintf (&buffer[6], "%8d", WSAGetLastError() ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 buffer[14] = ' '; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 memcpy (&buffer[15], ptr, (thr_BufferSize)+1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 fprintf (fp, "%s\n", buffer ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 ptr[21] = c; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 return SOCKET_NOCONNECT ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 if (fh_sock != -1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 char sstop[10]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 ULONG stop = GetTickCount(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 sprintf(sstop, "%03d:%03d", (stop/1000) % 1000, stop % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 sprintf(stbuf, "sent %d at %s\n", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 thr_BufferSize, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 sstop); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 write (fh_sock, stbuf, strlen(stbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 /* pSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 /*--------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 Send the data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 ---------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 c_written = (USHORT) WRITE_SOCKET(tst_socket, in_BufferPtr, (USHORT)thr_BufferSize); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 if (c_written == (USHORT)SOCKET_ERROR || c_written != thr_BufferSize) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 err = errno; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 return SOCKET_NOCONNECT ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 #endif /* _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 /*==== PUBLIC FUNCTIONS =====================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 | Function : socket_Exit |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 | Description : The function is called when the driver functionality is no |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 | longer required. The function "de-allocates" the resources |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 | and releases active connections. The driver terminates |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 | regardless of any outstanding data to be sent. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 | Return : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 void socket_Exit (void) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 os_DestroyTask ( 0, L_ClientData.ThreadID ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 socket_Close() ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 | Function : socket_Open |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 | Description : This function is used to establish a connection to server or |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 | activate the driver to act as a server, using the settings of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 | the socket_DCB. A hostname must be specified to open a |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 | connection to a server, in this case the driver runs in the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 | client mode. If no hostname is specified the driver will run in |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 | server mode. In the server mode it serves a single client. As |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 | soon as a client is connected the CONNECT signal is generated. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 | In case of a successful completion the driver is no able to send |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 | data (socket_write()) to the peer entity and to read data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 | received from the peer entity (socket_read()). To get notified |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 | about the reception of data the appropriate signal has to be set |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 | (socket_SetSignal()). |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 | In the case of a successful completion the driver returns DRV_OK. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 | If the driver is already busy DRV_INPROCESS is returned. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 | If the driver is not configured, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 | DRV_NOTCONFIGURED. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 | If an error occurs while establishing the requested mode, the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 | function returns SOCKET_ERRUNSPEC. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 | Return : DRV_OK - Function successful |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 | DRV_INPROCESS - The driver is currently reading data. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 | The data is incomplete. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 | DRV_NOTCONFIGURED - The driver is not yet configured |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 | SOCKET_ERRUNSPEC - Error occured during initialization |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 USHORT socket_Open (void) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 SOCKADDR_IN dest_sin; /* DESTination Socket INternet */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 SOCKET connectsocket; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 int sockAddrSize; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 #if defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 struct hostent* phe; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 PHOSTENT phe; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 if (L_ThreadActive) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 return DRV_INPROCESS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 /*--------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 if no hostname is specified we |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 open as a server |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 ---------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 if (!*L_DCB.hostname) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 return L_CreateServer() ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 connectsocket = socket (AF_INET, SOCK_STREAM, 0); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 if (connectsocket == INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 #ifdef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 if ( !gethostbyname(L_DCB.hostname, phe)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 CLOSE_SOCKET(connectsocket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 #else /* _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 sockAddrSize = sizeof (struct sockaddr_in); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 memset((char *) &dest_sin, 0, sockAddrSize); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 dest_sin.sin_len = (u_char) sockAddrSize; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 dest_sin.sin_family = AF_INET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 dest_sin.sin_port = htons(L_DCB.port); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 if (((dest_sin.sin_addr.s_addr = inet_addr (L_DCB.hostname)) == ERROR) && |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 ((dest_sin.sin_addr.s_addr = hostGetByName (L_DCB.hostname)) == ERROR)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 CLOSE_SOCKET(connectsocket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 phe = gethostbyname(L_DCB.hostname); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
977 if (!phe) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
978 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
979 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
980 printf("SOCKET: host %s not found ;-(\n",L_DCB.hostname); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
981 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
982 CLOSE_SOCKET(connectsocket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
983 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
984 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
985 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
986 #endif /* _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
987 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
988 #ifndef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
989 memset(&dest_sin, 0, sizeof(struct sockaddr_in)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
990 memcpy((char*)&(dest_sin.sin_addr), phe->h_addr, (unsigned int)((int)(phe->h_length))); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
991 dest_sin.sin_family = AF_INET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
992 if ( L_DCB.config & TI_MODE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
993 dest_sin.sin_port = L_DCB.port; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
994 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
995 dest_sin.sin_port = htons(L_DCB.port); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
996 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
997 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
998 #ifdef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
999 if (connect (connectsocket, (struct sockaddr_in*) &dest_sin, sizeof(dest_sin))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1000 #else /* _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1001 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1002 if (connect (connectsocket, (struct sockaddr*) &dest_sin, sockAddrSize) == ERROR) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1003 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1004 #if defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1005 if (connect (connectsocket, (struct sockaddr*) &dest_sin, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1006 sizeof(dest_sin))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1007 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1008 if (connect (connectsocket, (const PSOCKADDR) &dest_sin, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1009 sizeof(dest_sin))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1010 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1011 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1012 #endif /* defined(_PSOS_) || defined(_VXWORKS_) */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1013 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1014 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1015 printf("SOCKET: connection to %s on port %i failed ;-(\n",L_DCB.hostname,L_DCB.port); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1016 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1017 CLOSE_SOCKET(connectsocket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1018 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1019 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1020 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1021 printf("SOCKET: successfully connected to %s on port %i\n",L_DCB.hostname,L_DCB.port); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1022 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1023 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1024 if (!L_CreateThread (L_ClientThread)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1025 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1026 CLOSE_SOCKET (L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1027 return SOCKET_ERRUNSPEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1028 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1029 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1030 L_ClientData.Socket = connectsocket ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1031 L_ClientData.Connect = TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1032 if (L_ClientData.EnabledSignals & DRV_SIGTYPE_CONNECT) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1033 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1034 SocketSignal.SignalType = DRV_SIGTYPE_CONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1035 SocketSignal.DrvHandle = L_ClientData.SocketHandle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1036 (*L_ClientData.Callback)(&SocketSignal) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1037 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1038 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1039 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1040 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1041 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1042 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1043 | Function : socket_Close |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1044 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1045 | Description : This function is used by a client to close the connection or |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1046 | by server to shut down the server functionality. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1047 | In case of a successful completion the connection is shutdown |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1048 | and neither socket_Read nor socket_Write will be successful. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1049 | To get notified about the termination of a connection the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1050 | appropriate signal has to be set (socket_SetSignal()). |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1051 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1052 | Parameters : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1053 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1054 | Return : - |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1055 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1056 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1057 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1058 USHORT socket_Close (void) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1059 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1060 L_ThreadActive = FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1061 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1062 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1063 if (fh_sock != -1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1064 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1065 char sstop[10]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1066 ULONG stop = GetTickCount(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1067 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1068 sprintf(sstop, "%03d:%03d", (stop/1000) % 1000, stop % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1069 sprintf(stbuf, "socket_Close at %s socket=%d listener=%d\n", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1070 sstop, L_ClientData.Socket, L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1071 write (fh_sock, stbuf, strlen(stbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1072 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1073 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1074 if (L_ClientData.Socket != INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1075 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1076 CLOSE_SOCKET (L_ClientData.Socket); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1077 L_ClientData.Socket = INVALID_SOCKET; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1078 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1079 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1080 if (L_ClientData.Listener != INVALID_SOCKET) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1081 CLOSE_SOCKET (L_ClientData.Listener); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1082 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1083 L_ClientData.ThreadID = 0 ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1084 return DRV_OK; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1085 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1086 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1087 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1088 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1089 | Function : socket_Read_with_Timeout |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1090 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1091 | Description : This function is used to read data from the USART driver. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1092 | For more details see socket_Read() |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1093 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1094 | Return: >= 0 - Number of bytes read |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1095 | SOCKET_ERROR - error occurred |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1096 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1097 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1098 LOCAL ULONG socket_Read_with_Timeout( void* destBuf, ULONG reqLen ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1099 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1100 ULONG timeout, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1101 totalBytes = 0, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1102 stop_timeout ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1103 int readBytes, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1104 attempts = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1105 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1106 /* calculate timeout time */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1107 GETTIME( stop_timeout ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1108 stop_timeout = stop_timeout + L_DCB.rx_timeout_msec ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1109 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1110 /* read nonblocking until requested data is read or timeout */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1111 do |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1112 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1113 readBytes = (SHORT)READ_SOCKET( L_ClientData.Socket, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1114 ((char *)destBuf) + totalBytes, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1115 reqLen - totalBytes ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1116 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1117 if( readBytes < 0 || readBytes == SOCKET_ERROR ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1118 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1119 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1120 #ifndef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1121 fp = fopen(readerrorfile, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1122 fprintf (fp, "WSAGetLastError returned: %8d", WSAGetLastError() ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1123 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1124 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1125 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1126 return 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1127 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1128 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1129 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1130 totalBytes += (unsigned int)readBytes; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1131 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1132 GETTIME (timeout) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1133 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1134 if( totalBytes < reqLen ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1135 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1136 if (attempts++) /* try to get data by two consecutive accesses |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1137 then sleep (but this should not be necessary) */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1138 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1139 #ifdef OLD_FRAME |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1140 Sleep (1) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1141 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1142 os_SuspendTask ( 0, 1 ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1143 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1144 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1145 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1146 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1147 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1148 return totalBytes; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1149 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1150 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1151 } while (timeout < stop_timeout); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1152 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1153 return 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1154 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1155 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1156 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1157 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1158 | Function : socket_Read |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1159 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1160 | Description : This function is used to read data from the USART driver. The |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1161 | data is copied into the buffer to which out_BufferPtr points. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1162 | The parameter *thr_BufferSizePtr contains the size of the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1163 | buffer in characters. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1164 | In the case of a successful completion, the driver's buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1165 | is cleared. The driver keeps the data available when calling |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1166 | the function drv_Look(). |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1167 | If the driver is not configured, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1168 | DRV_NOTCONFIGURED. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1169 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1170 | NOTE: When calling the function with a buffer size of 0, the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1171 | function will return DRV_OK. The size of the buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1172 | needed to store the available data is stored in the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1173 | parameter *thr_BufferSizePtr. In this case, the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1174 | out_BufferPtr can be set to NULL. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1175 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1176 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1177 | Parameters : out_BufferPtr - This parameter points to the buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1178 | wherein the data is to be copied |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1179 | thr_BufferSizePtr - On call: number of characters to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1180 | read. If the function returns DRV_OK, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1181 | it contains the number of characters |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1182 | read. If the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1183 | DRV_INPROCESS, it contains 0. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1184 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1185 | Return : DRV_OK - Function successful |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1186 | DRV_INPROCESS - The driver is currently reading data. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1187 | The data is incomplete. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1188 | DRV_NOTCONFIGURED - The driver is not yet configured |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1189 | SOCKET_NOCONNECT - Connection not available |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1190 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1191 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1192 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1193 USHORT socket_Read (void* out_BufferPtr, ULONG* thr_BufferSizePtr) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1194 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1195 #ifdef _VXWORKS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1196 SIZETYPE pending_data_size = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1197 #else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1198 ULONG pending_data_size = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1199 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1200 ULONG bytesToRead, bytesReq; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1201 int rc; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1202 static USHORT packet_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1203 union |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1204 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1205 USHORT s; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1206 UBYTE b[2]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1207 } conv; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1208 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1209 static ULONG BytesRead = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1210 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1211 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1212 static ULONG start; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1213 static ULONG lasttime = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1214 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1215 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1216 bytesReq = *thr_BufferSizePtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1217 *thr_BufferSizePtr = 0; /* no bytes returned yet */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1218 while ( (rc = (GETREADSIZE( L_ClientData.Socket, &pending_data_size ))) == 0 && |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1219 pending_data_size > 0 ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1220 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1221 switch (sock_state) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1222 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1223 case SST_PL0: |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1224 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1225 GETTIME (start) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1226 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1227 packet_size = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1228 if (pending_data_size >= 2) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1229 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1230 bytesToRead = 2; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1231 sock_state = SST_DATA0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1232 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1233 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1234 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1235 bytesToRead = 1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1236 sock_state = SST_PL1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1237 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1238 if ( !(L_DCB.config & TI_MODE) ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1239 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1240 if (socket_Read_with_Timeout(&packet_size, bytesToRead) != bytesToRead) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1241 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1242 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1243 return SOCKET_NOCONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1244 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1245 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1246 break; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1247 case SST_PL1: |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1248 if (socket_Read_with_Timeout(((char*)&packet_size)+1, 1) != 1) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1249 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1250 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1251 return SOCKET_NOCONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1252 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1253 sock_state = SST_DATA0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1254 break; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1255 case SST_DATA0: |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1256 if ( !(L_DCB.config & TI_MODE) && isLittleEndian ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1257 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1258 conv.b[0] = *(((UBYTE*)&packet_size)+1); /* LSB */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1259 conv.b[1] = * (UBYTE*)&packet_size; /* MSB */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1260 packet_size = conv.s; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1261 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1262 /*lint -fallthrough*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1263 case SST_DATAx: |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1264 /* now read the packet payload or a part of it */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1265 if ( L_DCB.config & TI_MODE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1266 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1267 bytesToRead = (pending_data_size < bytesReq) ? pending_data_size : bytesReq; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1268 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1269 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1270 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1271 bytesToRead = (packet_size < bytesReq) ? packet_size : bytesReq; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1272 if (pending_data_size < bytesToRead) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1273 bytesToRead = pending_data_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1274 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1275 if( (*thr_BufferSizePtr = |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1276 socket_Read_with_Timeout( ((char *)out_BufferPtr), bytesToRead )) != |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1277 bytesToRead ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1278 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1279 *thr_BufferSizePtr = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1280 if ( !(L_DCB.config & TI_MODE) ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1281 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1282 return SOCKET_NOCONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1283 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1284 #ifdef SOCK_TRACE |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1285 if (fh_sock != -1 && sock_state == SST_DATA0 && bytesToRead >= 13) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1286 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1287 char split[10+1]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1288 char sstart[20], sstop[20]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1289 static ULONG c_received = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1290 ULONG len = packet_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1291 ULONG stop = GetTickCount(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1292 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1293 if (((char*)out_BufferPtr)[13] == 'T') |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1294 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1295 memcpy(split, ((char*)out_BufferPtr)+9, 7); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1296 split[7] = '\0'; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1297 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1298 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1299 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1300 memcpy(split, ((char*)out_BufferPtr)+9, 4); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1301 split[4] = '\0'; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1302 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1303 if (start != lasttime) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1304 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1305 if (lasttime - start > 11) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1306 sprintf(sstart, "->%d %03d:%03d\n", c_received, (start/1000) % 1000, start % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1307 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1308 sprintf(sstart, "%03d:%03d\n", (start/1000) % 1000, start % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1309 c_received = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1310 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1311 c_received += packet_size + 2; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1312 if (start != stop) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1313 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1314 sprintf(sstop, "->%d %03d:%03d\n", c_received, (stop/1000) % 1000, stop % 1000); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1315 c_received = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1316 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1317 sprintf(stbuf, "%s%d %s\n%s", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1318 (start != lasttime) ? sstart : "", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1319 packet_size + 2, split, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1320 (start != stop) ? sstop : ""); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1321 write (fh_sock, stbuf, strlen(stbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1322 lasttime = stop; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1323 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1324 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1325 if ( !(L_DCB.config & TI_MODE) ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1326 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1327 if (*thr_BufferSizePtr == packet_size) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1328 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1329 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1330 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1331 packet_size -= (USHORT)*thr_BufferSizePtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1332 sock_state = SST_DATAx; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1333 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1334 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1335 return DRV_OK; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1336 /*lint -e527 suppress Warning -- Unreachable */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1337 break; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1338 /*lint +e527 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1339 } /* switch */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1340 } /* while */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1341 if (rc) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1342 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1343 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1344 return SOCKET_NOCONNECT; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1345 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1346 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1347 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1348 static char Buffer[2000]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1349 memcpy (Buffer+BytesRead,out_BufferPtr,*thr_BufferSizePtr); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1350 BytesRead += *thr_BufferSizePtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1351 if ( (Buffer[0] == 'P') ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1352 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1353 OS_TIME time; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1354 char c = Buffer[21]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1355 fp = fopen(logfile, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1356 Buffer[21] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1357 os_GetTime ( 0, &time ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1358 fprintf (fp, "P%ld IN: %s\n", time/10, &Buffer[9] ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1359 Buffer[21] = c; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1360 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1361 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1362 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1363 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1364 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1365 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1366 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1367 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1368 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1369 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1370 | Function : socket_Write |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1371 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1372 | Description : This function is used to write data to the driver. The |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1373 | parameter *thr_BufferSizePtr contains the number of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1374 | characters to write. In the case of a successful completion, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1375 | the function returns DRV_OK. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1376 | If the data cannot be written because the storage capacity of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1377 | the driver has been exhausted, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1378 | DRV_BUFFER_FULL and the maximum number of characters that can |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1379 | be written in *thr_BufferSizePtr. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1380 | If the driver is currently busy writing data and therefore |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1381 | cannot accept further data to be written, it returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1382 | DRV_INPROCESS and sets the parameter *thr_BufferSizePtr to 0. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1383 | If the driver is not configured, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1384 | DRV_ NOTCONFIGURED. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1385 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1386 | NOTE: When calling the function with a buffer size of 0, the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1387 | function will return the number of characters that can be |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1388 | written in the parameter *thr_BufferSizePtr. In this |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1389 | case, the in_BufferPtr can be set to NULL. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1390 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1391 | Parameters : in_BufferPtr - This parameter points to the buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1392 | that is passed to the driver for |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1393 | further processing |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1394 | thr_BufferSizePtr - On call: number of characters to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1395 | write. If the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1396 | DRV_BUFFER_FULL, it contains the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1397 | maximum number of characters that can |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1398 | be written. If the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1399 | DRV_OK, it contains the number of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1400 | characters written. If the function |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1401 | returns DRV_INPROCESS, it contains 0. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1402 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1403 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1404 | Return : DRV_OK - Function successful |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1405 | DRV_BUFFER_FULL - Not enough space |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1406 | DRV_INPROCESS - Driver is busy writing data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1407 | DRV_NOTCONFIGURED - The driver is not yet configured |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1408 | SOCKET_NOCONNECT - Connection not available |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1409 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1410 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1411 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1412 /*lint -esym(613,auxb) suppress warning possibly use off NULL pointer auxb */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1413 /*lint -esym(644,auxb) suppress warning possibly not initialized */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1414 /*lint -e668 suppress warning possibly passing NULL pointer to memcpy */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1415 USHORT socket_Write (void* in_BufferPtr, ULONG* thr_BufferSizePtr) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1416 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1417 UBYTE rc = DRV_OK; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1418 int max_len, rest; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1419 char * auxb; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1420 ULONG buffer_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1421 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1422 buffer_size = *thr_BufferSizePtr & ~PRIM_FLAG_MASK; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1423 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1424 #ifndef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1425 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1426 UBYTE Prim = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1427 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1428 char *ptr = in_BufferPtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1429 if ( *ptr == 'P' ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1430 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1431 OS_TIME time; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1432 char c = ptr[21]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1433 fp = fopen(logfile, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1434 ptr[21] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1435 os_GetTime ( 0, &time ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1436 fprintf (fp, "P%ld OUT: %s\n", time/10, &ptr[9] ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1437 ptr[21] = c; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1438 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1439 Prim = 1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1440 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1441 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1442 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1443 #else /* _PSOS */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1444 if( !tst_socket_initialized ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1445 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1446 if (tst_socket_in_TxLen > 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1447 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1448 int nodelay = TRUE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1449 if (setsockopt(tst_socket, SOL_SOCKET, SO_SNDBUF, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1450 (char*)&tst_socket_in_TxLen, sizeof(tst_socket_in_TxLen))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1451 return DRV_INITFAILURE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1452 if (setsockopt(tst_socket, IPPROTO_TCP, TCP_NODELAY, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1453 (char*)&nodelay, sizeof(nodelay))) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1454 return DRV_INITFAILURE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1455 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1456 tst_socket_initialized = 1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1457 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1458 #endif /* _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1459 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1460 if ( L_DCB.config & TI_MODE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1461 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1462 /* add TI-MUX header */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1463 auxb=(char*)malloc(buffer_size+2); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1464 memcpy((void*)(auxb+2),in_BufferPtr,buffer_size); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1465 auxb[0]=19; /* assigned to L23 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1466 auxb[1]=(char)buffer_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1467 in_BufferPtr=auxb; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1468 buffer_size+=2; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1469 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1470 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1471 max_len = (L_DCB.tx_buffer_size < WRBUF_LEN) ? L_DCB.tx_buffer_size : WRBUF_LEN; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1472 if (max_len < (int)buffer_size) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1473 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1474 #ifndef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1475 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1476 char buffer[200]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1477 char *ptr = in_BufferPtr; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1478 char c = ptr[21]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1479 fp = fopen(bufferfullfile, "at"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1480 if ( *ptr == 'P' ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1481 ptr[21] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1482 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1483 ptr[buffer_size] = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1484 strcpy (buffer, "errno:" ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1485 sprintf (&buffer[6], "%8d", WSAGetLastError() ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1486 buffer[14] = ' '; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1487 memcpy (&buffer[15], ptr, (buffer_size)+1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1488 fprintf (fp, "%s\n", buffer ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1489 ptr[21] = c; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1490 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1491 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1492 #endif /* _PSOS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1493 if ( L_DCB.config & TI_MODE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1494 free(auxb); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1495 *thr_BufferSizePtr = (unsigned int)max_len | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1496 (*thr_BufferSizePtr & PRIM_FLAG_MASK) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1497 return DRV_BUFFER_FULL ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1498 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1499 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1500 rest = MAX_ETH_LEN - (wrbuf_pos - wrbuf); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1501 if (buffer_size + 2 >= (unsigned int)rest) /* more than maximum ethernet packet size needed ?*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1502 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1503 /*--------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1504 send the buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1505 ---------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1506 rc = socket_WriteToOS(wrbuf, (USHORT)(wrbuf_pos - wrbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1507 wrbuf_pos = wrbuf; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1508 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1509 if (rc != DRV_OK) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1510 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1511 if ( L_DCB.config & TI_MODE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1512 free(auxb); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1513 *thr_BufferSizePtr = (*thr_BufferSizePtr & PRIM_FLAG_MASK) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1514 return rc; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1515 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1516 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1517 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1518 if ( !(L_DCB.config & TI_MODE) ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1519 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1520 /*------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1521 put the size of the data into buffer (MSB first) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1522 ------------------------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1523 if (isLittleEndian) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1524 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1525 *wrbuf_pos = *(((UBYTE*)&buffer_size)+1); /* MSB */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1526 *(wrbuf_pos+1) = * (UBYTE*)&buffer_size; /* LSB */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1527 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1528 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1529 *((USHORT*)wrbuf_pos) = (USHORT)buffer_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1530 wrbuf_pos += 2; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1531 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1532 /*--------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1533 put the data itself into buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1534 ---------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1535 memcpy(wrbuf_pos, in_BufferPtr, (size_t)buffer_size); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1536 wrbuf_pos += buffer_size; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1537 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1538 if (socket_flush) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1539 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1540 /*--------------------------------- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1541 send the buffer |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1542 ---------------------------------*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1543 rc = socket_WriteToOS(wrbuf, (USHORT)(wrbuf_pos - wrbuf)); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1544 wrbuf_pos = wrbuf; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1545 socket_flush = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1546 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1547 if (rc != DRV_OK) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1548 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1549 *thr_BufferSizePtr = (*thr_BufferSizePtr & PRIM_FLAG_MASK) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1550 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1551 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1552 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1553 if ( L_DCB.config & TI_MODE ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1554 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1555 free(auxb); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1556 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1557 return rc ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1558 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1559 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1560 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1561 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1562 | Function : socket_Flush |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1563 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1564 | Description : This function flushes the socket write buffer where data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1565 | is stored until a complete packet can be sent or the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1566 | transmission is forced by an external setting of the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1567 | socket_flush flag. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1568 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1569 | Parameters : --- |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1570 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1571 | Return : DRV_OK - Function completed successfully |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1572 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1573 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1574 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1575 USHORT socket_Flush ( void ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1576 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1577 ULONG len = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1578 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1579 socket_flush = 1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1580 return ( socket_Write(NULL, &len) ); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1581 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1582 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1583 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1584 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1585 | Function : socket_SetSignal |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1586 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1587 | Description : This function is used to define a single or multiple signals |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1588 | that is/are indicated to the process when the event identified |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1589 | in the signal information data type as SignalType occurs. The |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1590 | USART uses only the standard signals defined in [C_8415.0026]. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1591 | To remove a signal, call the function socket_ResetSignal(). |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1592 | If one of the parameters of the signal information data is |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1593 | invalid, the function returns DRV_INVALID_PARAMS. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1594 | If no signal call-back function has been defined at the time |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1595 | of initialization, the driver returns DRV_SIGFCT_NOTAVAILABLE. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1596 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1597 | Parameters : in_SignalIDPtr - Pointer to the signal information |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1598 | data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1599 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1600 | Return : DRV_OK - Function completed successfully |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1601 | DRV_INVALID_PARAMS - One or more parameters are out of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1602 | range or invalid |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1603 | DRV_SIGFCT_NOTAVAILABLE - Event signaling functionality is |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1604 | not available |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1605 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1606 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1607 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1608 USHORT socket_SetSignal (USHORT SignalType) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1609 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1610 if (L_ClientData.Callback == NULL) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1611 return DRV_SIGFCT_NOTAVAILABLE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1612 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1613 if (SignalType & ALLOWED_SOCKET_SIGNALS) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1614 L_ClientData.EnabledSignals |= SignalType; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1615 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1616 return DRV_INVALID_PARAMS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1617 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1618 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1619 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1620 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1621 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1622 | Function : socket_ResetSignal |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1623 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1624 | Description : This function is used to remove previously set single or |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1625 | multiple signals. The signals that are removed are identified |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1626 | by the Signal Information Data element called SignalType. All |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1627 | other elements of the Signal Information Data must be |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1628 | identical to the signal(s) that are to be removed (process |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1629 | handle and signal value). If the SignalID provided cannot be |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1630 | located, the function returns DRV_INVALID_PARAMS. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1631 | If no signal call-back function has been defined at the time |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1632 | of initialization, the driver returns DRV_SIGFCT_NOTAVAILABLE. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1633 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1634 | Parameters : in_SignalIDPtr - Pointer to the signal information |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1635 | data |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1636 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1637 | Return : DRV_OK - Function completed successfully |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1638 | DRV_INVALID_PARAMS - One or more parameters are out of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1639 | range or invalid |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1640 | DRV_SIGFCT_NOTAVAILABLE - Event signaling functionality is |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1641 | not available |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1642 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1643 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1644 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1645 USHORT socket_ResetSignal (USHORT SignalType) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1646 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1647 if (L_ClientData.Callback == NULL) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1648 return DRV_SIGFCT_NOTAVAILABLE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1649 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1650 if (SignalType & ALLOWED_SOCKET_SIGNALS) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1651 L_ClientData.EnabledSignals &= ~SignalType; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1652 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1653 return DRV_INVALID_PARAMS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1654 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1655 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1656 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1657 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1658 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1659 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1660 | Function : socket_SetConfig |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1661 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1662 | Description : This function is used to configure the driver (port, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1663 | transmission rate, flow control, etc). The driver can be |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1664 | configured at any one time before a connection is opened. The |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1665 | parameters that can be configured are included in the USART's |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1666 | device control block socket_DCB_Type. For detailed information |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1667 | about the contents of the device control block, refer to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1668 | Chapter 2.1.1. If any value of the configuration is out of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1669 | range or invalid in combination with any other value of the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1670 | configuration, the function returns DRV_INVALID_PARAMS. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1671 | Call the socket_GetConfig() function to retrieve the driver's |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1672 | configuration. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1673 | The driver needs to be configured after initialization. Only |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1674 | the following functions can be called while the driver is not |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1675 | configured: socket_Clear, socket_SetSignal and socket_GetSignal. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1676 | All other functions return DRV_NOTCONFIGURED. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1677 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1678 | Parameters : in_DCBPtr - Pointer to the driver control block |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1679 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1680 | Return : DRV_OK - Function completed successfully |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1681 | DRV_INVALID_PARAMS - One or more parameters are out of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1682 | range or invalid |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1683 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1684 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1685 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1686 USHORT socket_SetConfig (char* in_DCBPtr) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1687 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1688 char token [SOCKET_MAX_LEN_HOSTNAME+1]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1689 USHORT port; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1690 unsigned int len; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1691 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1692 if ( (len = GetNextToken (in_DCBPtr, token, " #")) == 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1693 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1694 return DRV_INVALID_PARAMS; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1695 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1696 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1697 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1698 in_DCBPtr += (len+1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1699 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1700 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1701 port = (USHORT)atoi(token); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1702 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1703 if ( (len = GetNextToken (in_DCBPtr, token, " #")) == 0) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1704 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1705 return DRV_INVALID_PARAMS; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1706 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1707 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1708 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1709 in_DCBPtr += (len+1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1710 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1711 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1712 if ( !strcmp ( DRV_TI_MODE, token ) ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1713 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1714 L_DCB.config = TI_MODE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1715 sock_state = SST_DATAx; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1716 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1717 else if ( !strcmp ( DRV_DEFAULT, token ) ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1718 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1719 L_DCB.config = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1720 sock_state = SST_PL0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1721 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1722 else |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1723 return DRV_INVALID_PARAMS; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1724 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1725 if ( (len = GetNextToken (in_DCBPtr, token, " #")) == 0 ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1726 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1727 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1728 gethostname (token,SOCKET_MAX_LEN_HOSTNAME); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1729 #endif /* _TOOLS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1730 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1731 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1732 if (L_ThreadActive) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1733 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1734 /* check if host is already used */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1735 if (strcmp(L_DCB.hostname, token)==0 && L_DCB.port==port) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1736 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1737 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1738 printf("SOCKET: keeping connection to host %s on port %u\n",L_DCB.hostname,L_DCB.port); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1739 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1740 return DRV_OK; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1741 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1742 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1743 socket_Close(); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1744 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1745 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1746 L_DCB.port=port; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1747 strcpy ( L_DCB.hostname, token); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1748 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1749 if (socket_Open () != DRV_OK) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1750 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1751 return DRV_INVALID_PARAMS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1752 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1753 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1754 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1755 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1756 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1757 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1758 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1759 | Function : socket_GetConfig |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1760 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1761 | Description : This function is used to retrieve the configuration of the |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1762 | driver. The configuration is returned in the driver control |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1763 | block to which the pointer provided out_DCBPtr points. For |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1764 | detailed information about the contents of the device control |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1765 | block, refer to Chapter 2.1.1. The configuration can be |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1766 | requested at any one time. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1767 | If the driver is not configured, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1768 | DRV_ NOTCONFIGURED. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1769 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1770 | Parameters : out_DCBPtr - Pointer to the driver control block |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1771 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1772 | Return : DRV_OK - Function completed successfully |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1773 | DRV_INVALID_PARAMS - One or more parameters are out of |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1774 | range or invalid |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1775 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1776 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1777 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1778 USHORT socket_GetConfig (socket_DCB_Type* out_DCBPtr) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1779 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1780 if (out_DCBPtr == NULL) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1781 return DRV_INVALID_PARAMS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1782 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1783 memcpy (out_DCBPtr, &L_DCB, sizeof (L_DCB)) ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1784 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1785 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1786 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1787 /* |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1788 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1789 | Function : socket_Init |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1790 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1791 | Description : The function initializes the internal data of the driver. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1792 | The function returns DRV_INITIALIZED if the driver has |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1793 | already been initialized and is ready to be used or is |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1794 | already in use. In the case of an initialization failure, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1795 | i.e. the driver cannot be used, the function returns |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1796 | DRV_INITFAILURE. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1797 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1798 | Parameters : in_SignalCBPtr - This parameter points to the function that |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1799 | is called at the time an event that is to |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1800 | be signaled occurs. This value can be set |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1801 | to NULL if event signaling should not be |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1802 | possible. |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1803 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1804 | Return : DRV_OK - Initialization successful |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1805 | DRV_INITIALIZED - Driver already initialized |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1806 | DRV_INITFAILURE - Initialization failed |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1807 | |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1808 +------------------------------------------------------------------------------ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1809 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1810 GLOBAL USHORT socket_Init ( USHORT DrvHandle, T_DRV_CB_FUNC CallbackFunc, T_DRV_EXPORT const **DrvInfo ) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1811 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1812 static const T_DRV_EXPORT Socket_Info = |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1813 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1814 "SOCKET", |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1815 0, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1816 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1817 #ifdef _TOOLS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1818 socket_Init, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1819 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1820 socket_Exit, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1821 socket_Read, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1822 socket_Write, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1823 NULL, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1824 NULL, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1825 socket_Flush, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1826 socket_SetSignal, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1827 socket_ResetSignal, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1828 socket_SetConfig, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1829 NULL, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1830 NULL, |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1831 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1832 }; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1833 union |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1834 { |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1835 USHORT s; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1836 UBYTE b[2]; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1837 } test; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1838 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1839 #ifndef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1840 #if defined (_VXWORKS_) || defined (_LINUX_) || defined (_SOLARIS_) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1841 /* ToDo: vxWorks-libs initiieren |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1842 sockLib |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1843 inetLib |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1844 */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1845 #else /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1846 WSADATA WSAData; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1847 if (WSAStartup(MAKEWORD(1,1), &WSAData)) |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1848 return DRV_INITFAILURE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1849 #endif /* _VXWORKS_ */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1850 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1851 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1852 test.s = 1; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1853 isLittleEndian = (test.b[0] == 1); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1854 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1855 L_ThreadActive = FALSE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1856 L_DCB.config = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1857 L_DCB.port = 6392; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1858 L_DCB.tx_buffer_size = TX_BUFFER_SIZE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1859 L_DCB.rx_buffer_size = RX_BUFFER_SIZE ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1860 L_DCB.tx_timeout_msec = TX_TIMEOUT_MSEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1861 L_DCB.rx_timeout_msec = RX_TIMEOUT_MSEC; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1862 *L_DCB.hostname = 0 ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1863 L_ClientData.Connect = FALSE; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1864 L_ClientData.SocketHandle = DrvHandle; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1865 L_ClientData.Socket = INVALID_SOCKET ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1866 L_ClientData.Listener = INVALID_SOCKET ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1867 #ifdef _PSOS_ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1868 tst_socket = INVALID_SOCKET ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1869 tst_socket_initialized = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1870 tst_socket_in_TxLen = 0; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1871 #endif |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1872 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1873 L_ClientData.Callback = CallbackFunc ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1874 L_ClientData.EnabledSignals = ALLOWED_SOCKET_SIGNALS ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1875 *DrvInfo = &Socket_Info; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1876 #ifdef SOCKET_DEBUG |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1877 fp = fopen(logfile,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1878 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1879 fp = fopen(inprocessfile,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1880 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1881 fp = fopen(bufferfullfile,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1882 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1883 fp = fopen(noconnectfile1,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1884 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1885 fp = fopen(noconnectfile2,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1886 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1887 fp = fopen(noconnectfile3,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1888 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1889 fp = fopen(readerrorfile,"wt"); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1890 fclose(fp); |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1891 #endif /* SOCKET_DEBUG */ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1892 return DRV_OK ; |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1893 } |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1894 |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1895 /*==== END OF FILE ==========================================================*/ |
cd37d228dae0
src/gpf2/{misc,tst}: import from TCS211 semi-src
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1896 |