Debian Codegraph @

lib/networking.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/lib/networking.h $
21 * $Revision: 1.9 $
22 * $Date: 2004/12/05 04:00:20 $
23 * $Author: ryan $
24 *
25 *
26 *
27 * $Log: networking.h,v $
28 * Revision 1.10 2004/12/05 04:38:23 ryan
29 * Disable IPX support.
30 *
31 * Revision 1.9 2004/12/05 04:00:20 ryan
32 * MacOS X patches.
33 *
34 * Revision 1.8 2004/03/21 17:11:39 kevinb
35 * Fixes so linux will compile again. Tested with gcc-2.96
36 *
37 * Revision 1.7 2004/02/25 00:04:06 ryan
38 * Removed loki_utils dependency and ported to MacOS X (runs, but incomplete).
39 *
40 * Revision 1.6 2004/02/09 04:14:51 kevinb
41 * Added newlines to all headers to reduce number of warnings printed
42 *
43 * Made some small changes to get everything compiling.
44 *
45 * All Ready to merge the 1.5 tree.
46 *
47 * Revision 1.5 2001/01/13 21:48:46 icculus
48 * patched to (re)compile on win32.
49 *
50 * Revision 1.4 2000/09/22 19:05:40 icculus
51 * updated
52 *
53 * Revision 1.3 2000/06/24 01:15:15 icculus
54 * patched to compile.
55 *
56 * Revision 1.2 2000/06/03 14:33:51 icculus
57 * Merge with Outrage 1.4 tree...
58 *
59 * Revision 1.1.1.1 2000/04/18 00:00:38 icculus
60 * initial checkin
61 *
62 *
63 * 49 8/31/99 5:30p Jason
64 * network statistics code
65 *
66 * 48 8/21/99 3:14a Jeff
67 * real async lookup in linux
68 *
69 * 47 7/29/99 10:33a Kevin
70 * Macintosh Updates
71 *
72 * 45 7/28/99 ????? Kevin
73 * Mac Stuff
74 *
75 * 44 5/22/99 1:57a Kevin
76 * increased timeout in reliable code
77 *
78 * 43 5/19/99 5:21p Kevin
79 * changed return value of nw_GetHostAddressFromNumbers()
80 *
81 * 42 5/10/99 10:53p Ardussi
82 * changes to compile on Mac
83 *
84 * 41 4/30/99 5:06p Kevin
85 * misc dedicated server, networking and low memory enhancements
86 *
87 * 40 4/17/99 3:44p Kevin
88 * Demo2 changes & fixes
89 *
90 * 39 4/17/99 6:14a Jeff
91 * fixed errors compiling due to typos
92 *
93 * 38 4/17/99 5:50a Jeff
94 * added defines and macros for Linux port
95 *
96 * 37 4/16/99 6:00p Kevin
97 * Bunches of Demo stuff
98 *
99 * 36 4/15/99 2:57a Jeff
100 * added some defines and includes needed for linux ipx
101 *
102 * 35 4/12/99 3:16p Kevin
103 * Added a bunch of stuff for the linux version
104 *
105 * 34 2/24/99 12:48p Kevin
106 * Added urgent flag to nw_SendReliable. It causes the packet to go out
107 * that frame.
108 *
109 * 33 2/05/99 7:24p Kevin
110 * Added NAGLE type packet buffering to reliable networking code
111 *
112 * 32 1/26/99 9:44p Jeff
113 * moved tcplog functions to mono library
114 *
115 * 31 1/13/99 6:48a Jeff
116 * made linux friendly with some #ifdef's
117 *
118 * 29 1/08/99 2:58p Kevin
119 * Added TCP mprintf support so you can log to a remote machine.
120 *
121 * 28 12/23/98 6:38p Kevin
122 * All UDP data (except gamespy) now uses one (registered) port number
123 *
124 * 27 12/03/98 9:29a Kevin
125 * Added better ip selection code
126 *
127 * 26 11/02/98 6:41p Jason
128 * changed demo port number
129 *
130 * 25 10/12/98 8:39p Kevin
131 * removed mprintf's and fixed some smallish bugs
132 *
133 * 24 10/01/98 11:37a Kevin
134 * UI fixes and stuff
135 *
136 * 23 9/28/98 11:02a Kevin
137 * added Networking defer, and fixed some UI issues
138 *
139 * 22 9/22/98 2:29p Kevin
140 * moved ships allowed code out of dll and into main app. Also added
141 * powerup exclusions
142 *
143 * 21 9/21/98 11:19a Kevin
144 * check protocol before entering multiplayer screens
145 *
146 * 20 9/04/98 1:51p Kevin
147 * implemented asyncronous gethostbyname
148 *
149 * 19 8/14/98 4:54p Kevin
150 * More directplay stuff
151 *
152 * 18 8/13/98 6:32p Kevin
153 * Initial implementation of directplay API
154 *
155 */
156 #ifndef NETWORKING_H
157 #define NETWORKING_Hcxx . . $ `lib/networking.h:157:9`!
158
159 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
160 #include <cstdint>
161
162 #if defined(WIN32)
163 // Windows includes
164 #include <winsock.h>
165
166 // helper macros for working with SOCKADDR_IN to make it look nicer between windows and Linux
167 static inline void INADDR_SET_SUN_SADDR(struct in_addr *st, uint32_t value) { st->S_un.S_addr = value; }
168 static inline void INADDR_GET_SUN_SADDR(struct in_addr *st, uint32_t *value) { *value = st->S_un.S_addr; }
169 static inline void INADDR_SET_SUN_SUNW(struct in_addr *st, uint16_t s_w1, uint16_t s_w2) {
170 st->S_un.S_un_w.s_w1 = s_w1;
171 st->S_un.S_un_w.s_w2 = s_w2;
172 }
173 static inline void INADDR_GET_SUN_SUNW(struct in_addr *st, uint16_t *s_w1, uint16_t *s_w2) {
174 *s_w1 = st->S_un.S_un_w.s_w1;
175 *s_w2 = st->S_un.S_un_w.s_w2;
176 }
177 static inline void INADDR_SET_SUN_SUNB(struct in_addr *st, uint8_t s_b1, uint8_t s_b2, uint8_t s_b3,
178 uint8_t s_b4) {
179 st->S_un.S_un_b.s_b1 = s_b1;
180 st->S_un.S_un_b.s_b2 = s_b2;
181 st->S_un.S_un_b.s_b3 = s_b3;
182 st->S_un.S_un_b.s_b4 = s_b4;
183 }
184 static inline void INADDR_GET_SUN_SUNB(struct in_addr *st, uint8_t *s_b1, uint8_t *s_b2, uint8_t *s_b3,
185 uint8_t *s_b4) {
186 *s_b1 = st->S_un.S_un_b.s_b1;
187 *s_b2 = st->S_un.S_un_b.s_b2;
188 *s_b3 = st->S_un.S_un_b.s_b3;
189 *s_b4 = st->S_un.S_un_b.s_b4;
190 }
191
192 #elif defined(POSIXcxx . . $ `<built-in>:477:9`!)
193 // Linux includes/defines
194
195 #include <sys/types.h>
196 #include <sys/socket.h>
197 #include <stdio.h>
198 #include <unistd.h>
199 #include <sys/types.h>
200 #include <sys/socket.h>
201 #include <netinet/in.h>
202 #include <arpa/inet.h>
203 #include <netdb.h>
204 #include <sys/uio.h>
205 #include <sys/ioctl.h>
206 #include <sys/time.h>
207 #include <errno.h>
208 #include <pthread.h>
209 #include <fcntl.h>
210
211 // rcg06212000 my SDL adds.
212 #include "SDL.h"
213 #include "SDL_thread.h"
214
215 #include "linux_fix.h"cxx . . $ `<file>/linux/linux_fix.h`/
216
217 #define SOCKETcxx . . $ `lib/networking.h:217:9`! int
218 #define BOOLcxx . . $ `lib/networking.h:218:9`! bool
219 #define SOCKADDR_INcxx . . $ `lib/networking.h:219:9`! sockaddr_in
220 #define SOCKADDRcxx . . $ `lib/networking.h:220:9`! sockaddr
221 #define INVALID_SOCKETcxx . . $ `lib/networking.h:221:9`! -1
222
223 #ifdef TRUEcxx . . $ `networking/networking.cpp:309:9`!
224 #undef TRUEcxx . . $ `networking/networking.cpp:309:9`!
225 #endif
226 #define TRUEcxx . . $ `lib/networking.h:226:9`! true
227
228 #ifdef FALSEcxx . . $ `networking/networking.cpp:310:9`!
229 #undef FALSEcxx . . $ `networking/networking.cpp:310:9`!
230 #endif
231 #define FALSEcxx . . $ `lib/networking.h:231:9`! false
232 #define HOSTENTcxx . . $ `lib/networking.h:232:9`! struct hostent
233 #define SOCKET_ERRORcxx . . $ `lib/networking.h:233:9`! -1
234
235 // Winsock = sockets error translation
236 #define WSAEWOULDBLOCKcxx . . $ `lib/networking.h:236:9`! EWOULDBLOCKcxx . . $ `<external>/17922322188510340118/errno.h:22:9`!
237 #define WSAEINVALcxx . . $ `lib/networking.h:237:9`! EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!
238 #define WSAENOPROTOOPTcxx . . $ `lib/networking.h:238:9`! ENOPROTOOPTcxx . . $ `<external>/17922322188510340118/errno.h:76:9`!
239
240 #ifndef WSAGetLastErrorcxx . . $ `netcon/includes/inetgetfile.h:129:9`!
241 #define WSAGetLastErrorcxx . . $ `lib/networking.h:241:9`!() errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!
242 #endif
243
244 extern bool Use_DirectPlaycxx . . $ Use_DirectPlay.;
245
246 // helper macros for working with SOCKADDR_IN to make it look nicer between windows and Linux
247 static inline void INADDR_SET_SUN_SADDRcxx . . $ INADDR_SET_SUN_SADDR(7cb0f3b2dce9e5d8).(struct in_addr *st, uint32_tcxx . . $ uint32_t# value) { st->s_addr = value; }
248 static inline void INADDR_GET_SUN_SADDRcxx . . $ INADDR_GET_SUN_SADDR(b429acab2015c2b1).(struct in_addr *st, uint32_tcxx . . $ uint32_t# *value) { *value = st->s_addr; }
249 static inline void INADDR_SET_SUN_SUNWcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).(struct in_addr *st, uint16_tcxx . . $ uint16_t# s_w1, uint16_tcxx . . $ uint16_t# s_w2) {
250 unioncxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0# {
251 structcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_1# {
252 uint8_tcxx . . $ uint8_t# s_b1cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_1#s_b1., s_b2cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_1#s_b2., s_b3cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_1#s_b3., s_b4cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_1#s_b4.;
253 } S_un_bcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#S_un_b.;
254 structcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_2# {
255 uint16_tcxx . . $ uint16_t# s_w1cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_2#s_w1., s_w2cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_2#s_w2.;
256 } S_un_wcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#S_un_w.;
257 uint32_tcxx . . $ uint32_t# S_addrcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#S_addr.;
258 } S_un;
259
260 S_un.S_un_wcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#S_un_w..s_w1cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_2#s_w1. = s_w1;
261 S_un.S_un_wcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#S_un_w..s_w2cxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#$anonymous_type_2#s_w2. = s_w2;
262 st->s_addr = S_un.S_addrcxx . . $ INADDR_SET_SUN_SUNW(b7841925302b80b).$anonymous_type_0#S_addr.;
263 }
264 static inline void INADDR_GET_SUN_SUNWcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).(struct in_addr *st, uint16_tcxx . . $ uint16_t# *s_w1, uint16_tcxx . . $ uint16_t# *s_w2) {
265 unioncxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3# {
266 structcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_4# {
267 uint8_tcxx . . $ uint8_t# s_b1cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_4#s_b1., s_b2cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_4#s_b2., s_b3cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_4#s_b3., s_b4cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_4#s_b4.;
268 } S_un_bcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#S_un_b.;
269 structcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_5# {
270 uint16_tcxx . . $ uint16_t# s_w1cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_5#s_w1., s_w2cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_5#s_w2.;
271 } S_un_wcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#S_un_w.;
272 uint32_tcxx . . $ uint32_t# S_addrcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#S_addr.;
273 } S_un;
274
275 S_un.S_addrcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#S_addr. = st->s_addr;
276 *s_w1 = S_un.S_un_wcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#S_un_w..s_w1cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_5#s_w1.;
277 *s_w2 = S_un.S_un_wcxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#S_un_w..s_w2cxx . . $ INADDR_GET_SUN_SUNW(65112804f16df7d9).$anonymous_type_3#$anonymous_type_5#s_w2.;
278 }
279 static inline void INADDR_SET_SUN_SUNBcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).(struct in_addr *st, uint8_tcxx . . $ uint8_t# s_b1, uint8_tcxx . . $ uint8_t# s_b2, uint8_tcxx . . $ uint8_t# s_b3,
280 uint8_tcxx . . $ uint8_t# s_b4) {
281 unioncxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6# {
282 structcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7# {
283 uint8_tcxx . . $ uint8_t# s_b1cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b1., s_b2cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b2., s_b3cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b3., s_b4cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b4.;
284 } S_un_bcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_un_b.;
285 structcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_8# {
286 uint16_tcxx . . $ uint16_t# s_w1cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_8#s_w1., s_w2cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_8#s_w2.;
287 } S_un_wcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_un_w.;
288 uint32_tcxx . . $ uint32_t# S_addrcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_addr.;
289 } S_un;
290
291 S_un.S_un_bcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_un_b..s_b1cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b1. = s_b1;
292 S_un.S_un_bcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_un_b..s_b2cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b2. = s_b2;
293 S_un.S_un_bcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_un_b..s_b3cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b3. = s_b3;
294 S_un.S_un_bcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_un_b..s_b4cxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#$anonymous_type_7#s_b4. = s_b4;
295 st->s_addr = S_un.S_addrcxx . . $ INADDR_SET_SUN_SUNB(c2901968f692be52).$anonymous_type_6#S_addr.;
296 }
297 static inline void INADDR_GET_SUN_SUNBcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).(struct in_addr *st, uint8_tcxx . . $ uint8_t# *s_b1, uint8_tcxx . . $ uint8_t# *s_b2, uint8_tcxx . . $ uint8_t# *s_b3,
298 uint8_tcxx . . $ uint8_t# *s_b4) {
299 unioncxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9# {
300 structcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10# {
301 uint8_tcxx . . $ uint8_t# s_b1cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b1., s_b2cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b2., s_b3cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b3., s_b4cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b4.;
302 } S_un_bcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_un_b.;
303 structcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_11# {
304 uint16_tcxx . . $ uint16_t# s_w1cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_11#s_w1., s_w2cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_11#s_w2.;
305 } S_un_wcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_un_w.;
306 uint32_tcxx . . $ uint32_t# S_addrcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_addr.;
307 } S_un;
308
309 S_un.S_addrcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_addr. = st->s_addr;
310 *s_b1 = S_un.S_un_bcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_un_b..s_b1cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b1.;
311 *s_b2 = S_un.S_un_bcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_un_b..s_b2cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b2.;
312 *s_b3 = S_un.S_un_bcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_un_b..s_b3cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b3.;
313 *s_b4 = S_un.S_un_bcxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#S_un_b..s_b4cxx . . $ INADDR_GET_SUN_SUNB(b580536de0b51808).$anonymous_type_9#$anonymous_type_10#s_b4.;
314 }
315 #endif // OS
316
317 #define NWT_UNRELIABLEcxx . . $ `lib/networking.h:317:9`! 1
318 #define NWT_RELIABLEcxx . . $ `lib/networking.h:318:9`! 2
319
320 // This is the max size of a packet - DO NOT INCREASE THIS NUMBER ABOVE 512!
321 #define MAX_PACKET_SIZEcxx . . $ `lib/networking.h:321:9`! 512
322 #if 1 // ndef DEMO
323 #define DEFAULT_GAME_PORTcxx . . $ `lib/networking.h:323:9`! D3_DEFAULT_PORT
324 #else
325 #define DEFAULT_GAME_PORT 6250
326 #endif
327 // Network flags
328 #define NF_CHECKSUMcxx . . $ `lib/networking.h:328:9`! 1
329 #define NF_NOSEQINCcxx . . $ `lib/networking.h:329:9`! 2
330
331 enum network_protocolcxx . . $ network_protocol# : uint32_tcxx . . $ uint32_t#
332 {
333 NP_NONEcxx . . $ NP_NONE.,
334 NP_TCPcxx . . $ NP_TCP.,
335 NP_IPXcxx . . $ NP_IPX.,
336 NP_DIRECTPLAYcxx . . $ NP_DIRECTPLAY.
337 };
338
339 struct network_addresscxx . . $ network_address# {
340 uint8_tcxx . . $ uint8_t# addresscxx . . $ network_address#address.[6];
341 uint16_tcxx . . $ uint16_t# portcxx . . $ network_address#port.;
342 uint8_tcxx . . $ uint8_t# net_idcxx . . $ network_address#net_id.[4];
343 network_protocolcxx . . $ network_protocol# connection_typecxx . . $ network_address#connection_type.; // IPX, IP, modem, etc.
344 };
345
346 extern BOOLcxx . . $ `lib/networking.h:218:9`! DP_activecxx . . $ DP_active.;
347 extern BOOLcxx . . $ `lib/networking.h:218:9`! TCP_activecxx . . $ TCP_active.;
348 extern BOOLcxx . . $ `lib/networking.h:218:9`! IPX_activecxx . . $ IPX_active.;
349
350 // create a new non-blocking socket
351 int make_nonblockingcxx . . $ make_nonblocking(7864480464b09eea).(SOCKETcxx . . $ `lib/networking.h:217:9`! sock);
352
353 // Get the info from RAS
354 uint32_tcxx . . $ uint32_t# psnet_ras_statuscxx . . $ psnet_ras_status(db52760e79bf9054).();
355
356 // function to shutdown and close the given socket. It takes a couple of things into consideration
357 // when closing, such as possibly reiniting reliable sockets if they are closed here.
358 void nw_CloseSocketcxx . . $ nw_CloseSocket(11b0e290e57a7e53).(SOCKETcxx . . $ `lib/networking.h:217:9`! *sockp);
359
360 // Inits the sockets layer to activity
361 void nw_InitNetworkingcxx . . $ nw_InitNetworking(d4f767463ce0a6b3).(int iReadBufSizeOverride = -1);
362
363 // called by psnet_init to initialize the listen socket used by a host/server
364 int nw_InitReliableSocketcxx . . $ nw_InitReliableSocket(b126dc7c1de90089).();
365
366 // function which checks the Listen_socket for possibly incoming requests to be connected.
367 // returns 0 on error or nothing waiting. 1 if we should try to accept
368 int nw_CheckListenSocketcxx . . $ nw_CheckListenSocket(974bd2fc5f961852).(network_addresscxx . . $ network_address# *from_addr);
369
370 // Inits the sockets that the application will be using
371 void nw_InitSocketscxx . . $ nw_InitSockets(ed53e3bbd3fa2f69).(uint16_tcxx . . $ uint16_t# port);
372
373 // Connects a client to a server
374 void nw_ConnectToServercxx . . $ nw_ConnectToServer(cabc7cbaf24da8c).(SOCKETcxx . . $ `lib/networking.h:217:9`! *socket, network_addresscxx . . $ network_address# *server_addr);
375
376 // Returns internet address format from string address format...ie "204.243.217.14"
377 // turns into 1414829242
378 uint32_tcxx . . $ uint32_t# nw_GetHostAddressFromNumberscxx . . $ nw_GetHostAddressFromNumbers(33ab057182e9f89d).(char *str);
379
380 // Fills in the string with the string address from the internet address
381 void nw_GetNumbersFromHostAddresscxx . . $ nw_GetNumbersFromHostAddress(29331e2dd3eba175).(network_addresscxx . . $ network_address# *address, char *str);
382
383 // returns the ip address of this computer
384 uint32_tcxx . . $ uint32_t# nw_GetThisIPcxx . . $ nw_GetThisIP(db52760e79bf9054).();
385
386 // function which checks the Listen_socket for possibly incoming requests to be connected.
387 // returns 0 on error or nothing waiting. 1 if we should try to accept
388 int nw_CheckListenSocketcxx . . $ nw_CheckListenSocket(974bd2fc5f961852).(network_addresscxx . . $ network_address# *from_addr);
389
390 // Calculates a unique uint16_t checksum for a stream of data
391 uint16_tcxx . . $ uint16_t# nw_CalculateChecksumcxx . . $ nw_CalculateChecksum(c5bffbc6db657e6d).(void *vptr, int len);
392
393 // Sends data on an unreliable socket
394 int nw_Sendcxx . . $ nw_Send(102d2f582237fe86).(network_addresscxx . . $ network_address# *who_to, void *data, int len, int flags);
395
396 // nw_ReceiveFromSocket will get data out of the socket and stuff it into the packet_buffers
397 // nw_Receive now calls this function, then determines which of the packet buffers
398 // to package up and use
399 void nw_ReceiveFromSocketcxx . . $ nw_ReceiveFromSocket(49f6e7a06ebc5aa8).();
400
401 // routine to "free" a packet buffer
402 void nw_FreePacketcxx . . $ nw_FreePacket(d4f767463ce0a6b3).(int id);
403
404 // nw_Recieve will call the above function to read data out of the socket. It will then determine
405 // which of the buffers we should use and pass to the routine which called us
406 int nw_Receivecxx . . $ nw_Receive(4faaf8d0141e84f4).(void *data, network_addresscxx . . $ network_address# *from_addr);
407
408 // nw_SendReliable sends the given data through the given reliable socket.
409 int nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(uint32_tcxx . . $ uint32_t# socketid, uint8_tcxx . . $ uint8_t# *data, int length, bool urgent = false);
410
411 // function which reads data off of a reliable socket. recv() should read the totaly amount of data
412 // available I believe. (i.e. we shouldn't read only part of a message with one call....I may be wrong
413 // and this may be a source of bugs).
414 int nw_ReceiveReliablecxx . . $ nw_ReceiveReliable(ef9024b465536c23).(SOCKETcxx . . $ `lib/networking.h:217:9`! socket, uint8_tcxx . . $ uint8_t# *buffer, int max_len);
415
416 // Returns the current protocol in use
417 int nw_GetProtocolTypecxx . . $ nw_GetProtocolType(b126dc7c1de90089).();
418
419 // Copies my address into the passed argument
420 void nw_GetMyAddresscxx . . $ nw_GetMyAddress(f2758234d0c8cb80).(network_addresscxx . . $ network_address# *addr);
421
422 // Sends a packet to the game tracker
423 int nw_SendGameTrackerPackercxx . . $ nw_SendGameTrackerPacker(dedf1e9b1c614a07).(void *packet);
424
425 // Checks for an incoming game tracker packet.
426 int nw_ReceiveGameTrackercxx . . $ nw_ReceiveGameTracker(dedf1e9b1c614a07).(void *packet);
427
428 // Send a packet to the pilot tracker
429 int nw_SendPilotTrackerPacketcxx . . $ nw_SendPilotTrackerPacket(dedf1e9b1c614a07).(void *packet);
430
431 // Checks for an incoming pilot tracker packet.
432 int nw_ReceivePilotTrackercxx . . $ nw_ReceivePilotTracker(dedf1e9b1c614a07).(void *packet);
433
434 int nw_PingComparecxx . . $ nw_PingCompare(9148c8c3ff42c9d8).(const void *arg1, const void *arg2);
435
436 // initialize the buffering system
437 void nw_psnet_buffer_initcxx . . $ nw_psnet_buffer_init(49f6e7a06ebc5aa8).();
438
439 // buffer a packet (maintain order!)
440 void nw_psnet_buffer_packetcxx . . $ nw_psnet_buffer_packet(c3263a6d42f31e8c).(uint8_tcxx . . $ uint8_t# *data, int length, network_addresscxx . . $ network_address# *from);
441
442 // get the index of the next packet in order!
443 int nw_psnet_buffer_get_nextcxx . . $ nw_psnet_buffer_get_next(c5ce5346f0e0aa21).(uint8_tcxx . . $ uint8_t# *data, int *length, network_addresscxx . . $ network_address# *from);
444
445 // get the index of the next packet in order!
446 int nw_psnet_buffer_get_next_by_packet_idcxx . . $ nw_psnet_buffer_get_next_by_packet_id(9ff6ce25d7357603).(uint8_tcxx . . $ uint8_t# *data, int *length, uint32_tcxx . . $ uint32_t# packet_id);
447
448 // This is all the reliable UDP stuff...
449 #define MAXNETBUFFERScxx . . $ `lib/networking.h:449:9`! \
450 150 // Maximum network buffers (For between network and upper level functions, which is
451 // required in case of out of order packets
452 #define NETRETRYTIMEcxx . . $ `lib/networking.h:452:9`! .75 // Time after sending before we resend
453 #define MIN_NET_RETRYTIMEcxx . . $ `lib/networking.h:453:9`! .2
454 #define NETTIMEOUTcxx . . $ `lib/networking.h:454:9`! 300 // Time after receiving the last packet before we drop that user
455 #define NETHEARTBEATTIMEcxx . . $ `lib/networking.h:455:9`! 10 // How often to send a heartbeat
456 #define MAXRELIABLESOCKETScxx . . $ `lib/networking.h:456:9`! 40 // Max reliable sockets to open at once...
457 #define NETBUFFERSIZEcxx . . $ `lib/networking.h:457:9`! 600 // Max size of a network packet
458
459 // Network Types
460 #define RNT_ACKcxx . . $ `lib/networking.h:460:9`! 1 // ACK Packet
461 #define RNT_DATAcxx . . $ `lib/networking.h:461:9`! 2 // Data Packet
462 #define RNT_DATA_COMPcxx . . $ `lib/networking.h:462:9`! 3 // Compressed Data Packet
463 #define RNT_REQ_CONNcxx . . $ `lib/networking.h:463:9`! 4 // Requesting a connection
464 #define RNT_DISCONNECTcxx . . $ `lib/networking.h:464:9`! 5 // Disconnecting a connection
465 #define RNT_HEARTBEATcxx . . $ `lib/networking.h:465:9`! 6 // Heartbeat -- send every NETHEARTBEATTIME
466 #define RNT_I_AM_HEREcxx . . $ `lib/networking.h:466:9`! 7
467
468 // Reliable socket states
469 #define RNF_UNUSEDcxx . . $ `lib/networking.h:469:9`! 0 // Completely clean socket..
470 #define RNF_CONNECTEDcxx . . $ `lib/networking.h:470:9`! 1 // Connected and running fine
471 #define RNF_BROKENcxx . . $ `lib/networking.h:471:9`! 2 // Broken - disconnected abnormally
472 #define RNF_DISCONNECTEDcxx . . $ `lib/networking.h:472:9`! 3 // Disconnected cleanly
473 #define RNF_CONNECTINGcxx . . $ `lib/networking.h:473:9`! 4 // We received the connecting message, but haven't told the game yet.
474 #define RNF_LIMBOcxx . . $ `lib/networking.h:474:9`! 5 // between connecting and connected
475
476 void nw_SendReliableAckcxx . . $ nw_SendReliableAck(763f9aad6809bec8).(SOCKADDRcxx . . $ `lib/networking.h:220:9`! *raddr, uint32_tcxx . . $ uint32_t# sig, network_protocolcxx . . $ network_protocol# link_type, float time_sent);
477 void nw_WorkReliablecxx . . $ nw_WorkReliable(c3263a6d42f31e8c).(uint8_tcxx . . $ uint8_t# *data, int len, network_addresscxx . . $ network_address# *naddr);
478 int nw_Compresscxx . . $ nw_Compress(8bc41909eac9e5d8).(void *srcdata, void *destdata, int count);
479 int nw_Uncompresscxx . . $ nw_Uncompress(8bc41909eac9e5d8).(void *compdata, void *uncompdata, int count);
480
481 #define NW_AGHBN_CANCELcxx . . $ `lib/networking.h:481:9`! 1
482 #define NW_AGHBN_LOOKUPcxx . . $ `lib/networking.h:482:9`! 2
483 #define NW_AGHBN_READcxx . . $ `lib/networking.h:483:9`! 3
484
485 struct async_dns_lookupcxx . . $ async_dns_lookup# {
486 uint32_tcxx . . $ uint32_t# ipcxx . . $ async_dns_lookup#ip.; // resolved host. Write only to worker thread.
487 char *hostcxx . . $ async_dns_lookup#host.; // host name to resolve. read only to worker thread
488 bool donecxx . . $ async_dns_lookup#done.; // write only to the worker thread. Signals that the operation is complete
489 bool errorcxx . . $ async_dns_lookup#error.; // write only to worker thread. Thread sets this if the name doesn't resolve
490 bool abortcxx . . $ async_dns_lookup#abort.; // read only to worker thread. If this is set, don't fill in the struct.
491
492 // rcg06212000 added to let us join the thread at completion...
493 #if defined(POSIXcxx . . $ `<built-in>:478:9`!)
494 SDL_Thread *threadIdcxx . . $ async_dns_lookup#threadId.;
495 #endif
496 };
497
498 #ifdef WIN32
499 #define CDECLCALL __cdecl
500 #else
501 #define CDECLCALLcxx . . $ `lib/networking.h:501:9`!
502 #endif
503 #if defined(POSIXcxx . . $ `<built-in>:477:9`!)
504 // rcg06192000 used to return void *.
505 int CDECLCALLcxx . . $ `lib/networking.h:501:9`! gethostbynameworkercxx . . $ gethostbynameworker(dedf1e9b1c614a07).(void *parm);
506 #else
507 void CDECLCALL gethostbynameworker(void *parm);
508 #endif
509
510 int nw_Asyncgethostbynamecxx . . $ nw_Asyncgethostbyname(d1564d04be42e0f9).(uint32_tcxx . . $ uint32_t# *ip, int command, char *hostname);
511 int nw_ReccomendPPScxx . . $ nw_ReccomendPPS(b126dc7c1de90089).();
512 void nw_DoNetworkIdlecxx . . $ nw_DoNetworkIdle(49f6e7a06ebc5aa8).(void);
513
514 typedef void *(*NetworkReceiveCallbackcxx . . $ NetworkReceiveCallback#)(uint8_tcxx . . $ uint8_t# *data, int len, network_addresscxx . . $ network_address# *from);
515 int nw_RegisterCallbackcxx . . $ nw_RegisterCallback(d121e3b72e81a360).(NetworkReceiveCallbackcxx . . $ NetworkReceiveCallback# nfp, uint8_tcxx . . $ uint8_t# id);
516 NetworkReceiveCallbackcxx . . $ NetworkReceiveCallback# nw_UnRegisterCallbackcxx . . $ nw_UnRegisterCallback(bb45880c2285615c).(uint8_tcxx . . $ uint8_t# id);
517 int nw_SendWithIDcxx . . $ nw_SendWithID(4aa96ed29f5182c6).(uint8_tcxx . . $ uint8_t# id, uint8_tcxx . . $ uint8_t# *data, int len, network_addresscxx . . $ network_address# *who_to);
518 int nw_DoReceiveCallbackscxx . . $ nw_DoReceiveCallbacks(b126dc7c1de90089).(void);
519 void nw_HandleConnectResponsecxx . . $ nw_HandleConnectResponse(c3263a6d42f31e8c).(uint8_tcxx . . $ uint8_t# *data, int len, network_addresscxx . . $ network_address# *server_addr);
520 int nw_RegisterCallbackcxx . . $ nw_RegisterCallback(d121e3b72e81a360).(NetworkReceiveCallbackcxx . . $ NetworkReceiveCallback# nfp, uint8_tcxx . . $ uint8_t# id);
521 void nw_HandleUnreliableDatacxx . . $ nw_HandleUnreliableData(c3263a6d42f31e8c).(uint8_tcxx . . $ uint8_t# *data, int len, network_addresscxx . . $ network_address# *from_addr);
522 void nw_ReliableResendcxx . . $ nw_ReliableResend(49f6e7a06ebc5aa8).(void);
523 int nw_CheckReliableSocketcxx . . $ nw_CheckReliableSocket(7864480464b09eea).(int socknum);
524
525 struct tNetworkStatuscxx . . $ tNetworkStatus# {
526 // TCP/IP Status lines
527 int udp_total_packets_sentcxx . . $ tNetworkStatus#udp_total_packets_sent.; // total number of packets sent out on the network (unreliable)
528 int udp_total_packets_reccxx . . $ tNetworkStatus#udp_total_packets_rec.; // total number of packets recieved on the network (unrealiable)
529 int udp_total_bytes_sentcxx . . $ tNetworkStatus#udp_total_bytes_sent.; // total number of bytes sent (unreliable)
530 int udp_total_bytes_reccxx . . $ tNetworkStatus#udp_total_bytes_rec.; // total number of bytes recieved (unreliable)
531
532 int tcp_total_packets_sentcxx . . $ tNetworkStatus#tcp_total_packets_sent.; // total number of packets sent out on the network (reliable)
533 int tcp_total_packets_reccxx . . $ tNetworkStatus#tcp_total_packets_rec.; // total number of packets recieved on the network (reliable)
534 int tcp_total_bytes_sentcxx . . $ tNetworkStatus#tcp_total_bytes_sent.; // total number of bytes sent (reliable)
535 int tcp_total_bytes_reccxx . . $ tNetworkStatus#tcp_total_bytes_rec.; // total number of bytes recieved (reliable)
536 int tcp_total_packets_resentcxx . . $ tNetworkStatus#tcp_total_packets_resent.; // total number of packets resent (reliable)
537 int tcp_total_bytes_resentcxx . . $ tNetworkStatus#tcp_total_bytes_resent.; // total number of bytes resent (reliable)
538
539 // IPX Status lines
540 int ipx_total_packets_sentcxx . . $ tNetworkStatus#ipx_total_packets_sent.; // total number of packets sent out on the network (unreliable)
541 int ipx_total_packets_reccxx . . $ tNetworkStatus#ipx_total_packets_rec.; // total number of packets recieved on the network (unrealiable)
542 int ipx_total_bytes_sentcxx . . $ tNetworkStatus#ipx_total_bytes_sent.; // total number of bytes sent (unreliable)
543 int ipx_total_bytes_reccxx . . $ tNetworkStatus#ipx_total_bytes_rec.; // total number of bytes recieved (unreliable)
544
545 int spx_total_packets_sentcxx . . $ tNetworkStatus#spx_total_packets_sent.; // total number of packets sent out on the network (reliable)
546 int spx_total_packets_reccxx . . $ tNetworkStatus#spx_total_packets_rec.; // total number of packets recieved on the network (reliable)
547 int spx_total_bytes_sentcxx . . $ tNetworkStatus#spx_total_bytes_sent.; // total number of bytes sent (reliable)
548 int spx_total_bytes_reccxx . . $ tNetworkStatus#spx_total_bytes_rec.; // total number of bytes recieved (reliable)
549 int spx_total_packets_resentcxx . . $ tNetworkStatus#spx_total_packets_resent.; // total number of packets resent (reliable)
550 int spx_total_bytes_resentcxx . . $ tNetworkStatus#spx_total_bytes_resent.; // total number of bytes resent (reliable)
551 }; // network status information
552
553 // fills in the buffer with network stats
554 // pass NULL to reset the stats
555 void nw_GetNetworkStatscxx . . $ nw_GetNetworkStats(3e736517eddecfba).(tNetworkStatuscxx . . $ tNetworkStatus# *stats);
556
557 #endif