FreeCalypso > hg > fc-tourmaline
comparison src/g23m-fad/tcpip/rnet/rnet_api.c @ 1:fa8dc04885d8
src/g23m-*: import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:25:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:4e78acac3d88 | 1:fa8dc04885d8 |
---|---|
1 /** | |
2 * @file rnet_api.c | |
3 * | |
4 * Riviera NET. | |
5 * | |
6 * Code of the Riviera TCP/IP stack (non-blocking) API. | |
7 * Platform independent code. | |
8 * | |
9 * @author Vincent Oberle (v-oberle@ti.com) | |
10 * @version 0.1 | |
11 */ | |
12 | |
13 /* | |
14 * History: | |
15 * | |
16 * Date Author Modification | |
17 * -------------------------------------------------- | |
18 * 01/25/2002 Vincent Oberle Create | |
19 * 03/14/2002 Vincent Oberle Support of multiple implementations | |
20 * 03/27/2002 Jose Yp-Tcha Adding Real Transport configuration | |
21 * 06/24/2002 Regis Feneon Adding RNET_RT+WINDOWS configuration | |
22 * (C) Copyright 2002 by Texas Instruments Incorporated, All Rights Reserved | |
23 */ | |
24 | |
25 /* See this file for comments */ | |
26 #include "rnet_api.h" | |
27 | |
28 #include "rnet_trace_i.h" | |
29 | |
30 | |
31 #ifdef _WINDOWS | |
32 #if defined RNET_CFG_WINSOCK | |
33 #include "rnet_ws/rnet_ws_api.h" | |
34 #elif defined RNET_CFG_REAL_TRANSPORT | |
35 #include "rnet_rt/rnet_rt_api.h" | |
36 #else | |
37 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
38 return RNET_NOT_SUPPORTED; | |
39 #endif | |
40 #else | |
41 #if defined RNET_CFG_REAL_TRANSPORT | |
42 #include "rnet_rt/rnet_rt_api.h" | |
43 #elif defined RNET_CFG_BRIDGE | |
44 #include "rnet_br/rnet_br_api.h" | |
45 #endif | |
46 #endif | |
47 | |
48 //#define RNET_BENCHMARKING | |
49 #ifdef RNET_BENCHMARKING | |
50 | |
51 #include "timer.h" | |
52 | |
53 #define MAX_FUNCTION 20 | |
54 typedef enum { | |
55 new = 0, | |
56 set_traffic_class, | |
57 bind, | |
58 listen, | |
59 connect, | |
60 send, | |
61 recv, | |
62 recv_from, | |
63 shutdown, | |
64 close, | |
65 get_local_adr, | |
66 get_buff_size, | |
67 get_max_packet_size, | |
68 get_host_info, | |
69 get_proto, | |
70 set_user_data, | |
71 get_user_data | |
72 } RNET_BENCHMARK_FUNC; | |
73 | |
74 struct { | |
75 UINT16 nbtick_avg; | |
76 UINT16 nbtick_max; | |
77 UINT16 nbtick_min; | |
78 UINT32 nb_calls; | |
79 UINT8 overload; | |
80 } rnet_benchmarking[MAX_FUNCTION]; | |
81 | |
82 T_RNET_RET ret; | |
83 | |
84 void rnet_benchmarking_start_timer(void) | |
85 { | |
86 TM_EnableTimer( 1 ); | |
87 TM_ResetTimer( 1, 0xFFFF, 0, 0 ); // un tick = 2.4 microsecondes | |
88 TM_StartTimer( 1 ); | |
89 } | |
90 | |
91 void rnet_benchmarking_stop_timer(void) | |
92 { | |
93 TM_StopTimer( 1 ); | |
94 } | |
95 | |
96 UINT16 rnet_benchmarking_read_timer(void) | |
97 { | |
98 return((0xFFFF - TM_ReadTimer(1))); | |
99 } | |
100 | |
101 void rnet_benchmarking_todo(RNET_BENCHMARK_FUNC val, char *lib) | |
102 { | |
103 UINT16 cur_timer; | |
104 char loclib[80]; | |
105 | |
106 rnet_benchmarking[val].nb_calls++; | |
107 cur_timer = rnet_benchmarking_read_timer(); | |
108 if (cur_timer == 0) | |
109 rnet_benchmarking[val].overload++; | |
110 else { | |
111 rnet_benchmarking[val].nbtick_avg = ((rnet_benchmarking[val].nbtick_avg * | |
112 (rnet_benchmarking[val].nb_calls-1)) + cur_timer ) / | |
113 rnet_benchmarking[val].nb_calls; | |
114 if (rnet_benchmarking[val].nbtick_max < cur_timer) | |
115 rnet_benchmarking[val].nbtick_max = cur_timer; | |
116 if ((rnet_benchmarking[val].nbtick_min > cur_timer) || (rnet_benchmarking[val].nbtick_min == 0)) | |
117 rnet_benchmarking[val].nbtick_min = cur_timer; | |
118 } | |
119 sprintf(loclib, "RNET_RT benchmarking %s nbtick_avg: %d\n", lib, rnet_benchmarking[val].nbtick_avg); | |
120 RNET_TRACE_LOW(loclib); | |
121 sprintf(loclib, "RNET_RT benchmarking %s nbtick_max: %d\n", lib, rnet_benchmarking[val].nbtick_max); | |
122 RNET_TRACE_LOW(loclib); | |
123 sprintf(loclib, "RNET_RT benchmarking %s nbtick_min: %d\n", lib, rnet_benchmarking[val].nbtick_min); | |
124 RNET_TRACE_LOW(loclib); | |
125 sprintf(loclib, "RNET_RT benchmarking %s nb_calls: %d\n", lib, rnet_benchmarking[val].nb_calls); | |
126 RNET_TRACE_LOW(loclib); | |
127 sprintf(loclib, "RNET_RT benchmarking %s overload: %d\n", lib, rnet_benchmarking[val].overload); | |
128 RNET_TRACE_LOW(loclib); | |
129 } | |
130 | |
131 #endif | |
132 | |
133 /** | |
134 * Creates a new connection identifier (T_RNET_DESC). | |
135 */ | |
136 T_RNET_RET rnet_new (T_RNET_IPPROTO proto, | |
137 T_RNET_DESC ** desc, | |
138 T_RV_RETURN_PATH return_path) | |
139 { | |
140 #ifdef _WINDOWS | |
141 #if defined RNET_CFG_WINSOCK | |
142 return rnet_ws_new(proto, desc, return_path); | |
143 #elif defined RNET_CFG_REAL_TRANSPORT | |
144 return rnet_rt_new(proto, desc, return_path); | |
145 #else | |
146 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
147 return RNET_NOT_SUPPORTED; | |
148 #endif | |
149 #else | |
150 #if defined RNET_CFG_REAL_TRANSPORT | |
151 #ifdef RNET_BENCHMARKING | |
152 rnet_benchmarking_start_timer(); | |
153 ret = rnet_rt_new(proto, desc, return_path); | |
154 rnet_benchmarking_todo(new, "new"); | |
155 return(ret); | |
156 #else | |
157 return rnet_rt_new(proto, desc, return_path); | |
158 #endif | |
159 #elif defined RNET_CFG_BRIDGE | |
160 return rnet_br_new(proto, desc, return_path); | |
161 #else | |
162 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
163 return RNET_NOT_SUPPORTED; | |
164 #endif | |
165 #endif | |
166 } | |
167 | |
168 /** | |
169 * Sets the traffic class of a connection ID. | |
170 * | |
171 * Note that this function is NOT implemented under Windows. | |
172 */ | |
173 T_RNET_RET rnet_set_traffic_class (T_RNET_DESC * desc, | |
174 T_RNET_TRAFFIC_CLASS traffic_class) | |
175 { | |
176 #ifdef _WINDOWS | |
177 #if defined RNET_CFG_WINSOCK | |
178 RNET_TRACE_ERROR("RNET: rnet_set_traffic_class not supported under Windows"); | |
179 return RNET_NOT_SUPPORTED; | |
180 #elif defined RNET_CFG_REAL_TRANSPORT | |
181 RNET_TRACE_ERROR("RNET: rnet_set_traffic_class not supported for step one"); | |
182 return RNET_NOT_SUPPORTED; | |
183 #else | |
184 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
185 return RNET_NOT_SUPPORTED; | |
186 #endif | |
187 #else | |
188 #if defined RNET_CFG_REAL_TRANSPORT | |
189 RNET_TRACE_ERROR("RNET: rnet_set_traffic_class not supported for step one"); | |
190 return RNET_NOT_SUPPORTED; | |
191 #else | |
192 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
193 return RNET_NOT_SUPPORTED; | |
194 #endif | |
195 #endif | |
196 } | |
197 | |
198 /** | |
199 * Binds the connection to a local IP address and port number. | |
200 */ | |
201 T_RNET_RET rnet_bind (T_RNET_DESC * desc, | |
202 T_RNET_IP_ADDR local_addr, | |
203 T_RNET_PORT local_port) | |
204 { | |
205 #ifdef _WINDOWS | |
206 #if defined RNET_CFG_WINSOCK | |
207 return rnet_ws_bind(desc, local_addr, local_port); | |
208 #elif defined RNET_CFG_REAL_TRANSPORT | |
209 return rnet_rt_bind(desc, local_addr, local_port); | |
210 #else | |
211 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
212 return RNET_NOT_SUPPORTED; | |
213 #endif | |
214 #else | |
215 #if defined RNET_CFG_REAL_TRANSPORT | |
216 #ifdef RNET_BENCHMARKING | |
217 rnet_benchmarking_start_timer(); | |
218 ret = rnet_rt_bind(desc, local_addr, local_port); | |
219 rnet_benchmarking_todo(bind, "bind"); | |
220 return(ret); | |
221 #else | |
222 return rnet_rt_bind(desc, local_addr, local_port); | |
223 #endif | |
224 #elif defined RNET_CFG_BRIDGE | |
225 return rnet_br_bind(desc, local_addr, local_port); | |
226 #else | |
227 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
228 return RNET_NOT_SUPPORTED; | |
229 #endif | |
230 #endif | |
231 } | |
232 | |
233 /** | |
234 * Commands a connection to start listening for incoming connections. | |
235 */ | |
236 T_RNET_RET rnet_listen (T_RNET_DESC *desc) | |
237 { | |
238 #ifdef _WINDOWS | |
239 #if defined RNET_CFG_WINSOCK | |
240 return rnet_ws_listen(desc); | |
241 #elif defined RNET_CFG_REAL_TRANSPORT | |
242 return rnet_rt_listen(desc); | |
243 #else | |
244 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
245 return RNET_NOT_SUPPORTED; | |
246 #endif | |
247 #else | |
248 #if defined RNET_CFG_REAL_TRANSPORT | |
249 #ifdef RNET_BENCHMARKING | |
250 rnet_benchmarking_start_timer(); | |
251 ret = rnet_rt_listen(desc); | |
252 rnet_benchmarking_todo(listen, "listen"); | |
253 return(ret); | |
254 #else | |
255 return rnet_rt_listen(desc); | |
256 #endif | |
257 #elif defined RNET_CFG_BRIDGE | |
258 return rnet_br_listen(desc); | |
259 #else | |
260 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
261 return RNET_NOT_SUPPORTED; | |
262 #endif | |
263 #endif | |
264 } | |
265 | |
266 /** | |
267 * Sets up the connection ID to connect to the remote host. | |
268 */ | |
269 T_RNET_RET rnet_connect (T_RNET_DESC * desc, | |
270 T_RNET_IP_ADDR peer_addr, | |
271 T_RNET_PORT peer_port) | |
272 { | |
273 #ifdef _WINDOWS | |
274 #if defined RNET_CFG_WINSOCK | |
275 return rnet_ws_connect(desc, peer_addr, peer_port); | |
276 #elif defined RNET_CFG_REAL_TRANSPORT | |
277 return rnet_rt_connect(desc, peer_addr, peer_port); | |
278 #else | |
279 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
280 return RNET_NOT_SUPPORTED; | |
281 #endif | |
282 #else | |
283 #if defined RNET_CFG_REAL_TRANSPORT | |
284 #ifdef RNET_BENCHMARKING | |
285 rnet_benchmarking_start_timer(); | |
286 ret = rnet_rt_connect(desc, peer_addr, peer_port); | |
287 rnet_benchmarking_todo(connect, "connect"); | |
288 return(ret); | |
289 #else | |
290 return rnet_rt_connect(desc, peer_addr, peer_port); | |
291 #endif | |
292 #elif defined RNET_CFG_BRIDGE | |
293 return rnet_br_connect(desc, peer_addr, peer_port); | |
294 #else | |
295 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
296 return RNET_NOT_SUPPORTED; | |
297 #endif | |
298 #endif | |
299 } | |
300 | |
301 /** | |
302 * Enqueues the data for sending. | |
303 */ | |
304 T_RNET_RET rnet_send (T_RNET_DESC * desc, | |
305 T_RVF_BUFFER *buff, | |
306 UINT16 * len_p) | |
307 { | |
308 #ifdef _WINDOWS | |
309 #if defined RNET_CFG_WINSOCK | |
310 return rnet_ws_send(desc, buff, len_p); | |
311 #elif defined RNET_CFG_REAL_TRANSPORT | |
312 return rnet_rt_send(desc, buff, len_p); | |
313 #else | |
314 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
315 return RNET_NOT_SUPPORTED; | |
316 #endif | |
317 #else | |
318 #if defined RNET_CFG_REAL_TRANSPORT | |
319 #ifdef RNET_BENCHMARKING | |
320 rnet_benchmarking_start_timer(); | |
321 ret = rnet_rt_send(desc, buff, len_p); | |
322 rnet_benchmarking_todo(send, "send"); | |
323 return(ret); | |
324 #else | |
325 return rnet_rt_send(desc, buff, len_p); | |
326 #endif | |
327 #elif defined RNET_CFG_BRIDGE | |
328 return rnet_br_send(desc, buff, len_p); | |
329 #else | |
330 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
331 return RNET_NOT_SUPPORTED; | |
332 #endif | |
333 #endif | |
334 } | |
335 | |
336 /** | |
337 * Read the waiting data. | |
338 */ | |
339 T_RNET_RET rnet_recv (T_RNET_DESC * desc, | |
340 T_RVF_BUFFER *buff, | |
341 UINT16 * len_p) | |
342 { | |
343 #ifdef _WINDOWS | |
344 #if defined RNET_CFG_WINSOCK | |
345 return rnet_ws_recv(desc, buff, len_p); | |
346 #elif defined RNET_CFG_REAL_TRANSPORT | |
347 return rnet_rt_recv(desc, buff, len_p); | |
348 #else | |
349 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
350 return RNET_NOT_SUPPORTED; | |
351 #endif | |
352 #else | |
353 #if defined RNET_CFG_REAL_TRANSPORT | |
354 #ifdef RNET_BENCHMARKING | |
355 rnet_benchmarking_start_timer(); | |
356 ret = rnet_rt_recv(desc, buff, len_p); | |
357 rnet_benchmarking_todo(recv, "recv"); | |
358 return(ret); | |
359 #else | |
360 return rnet_rt_recv(desc, buff, len_p); | |
361 #endif | |
362 #elif defined RNET_CFG_BRIDGE | |
363 return rnet_br_recv(desc, buff, len_p); | |
364 #else | |
365 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
366 return RNET_NOT_SUPPORTED; | |
367 #endif | |
368 #endif | |
369 } | |
370 | |
371 /** | |
372 * Read the waiting data. | |
373 */ | |
374 T_RNET_RET rnet_recv_from (T_RNET_DESC * desc, | |
375 T_RVF_BUFFER * buff, | |
376 UINT16 * len_p, | |
377 T_RNET_IP_ADDR * from_addr, | |
378 T_RNET_PORT * from_port) | |
379 { | |
380 #ifdef _WINDOWS | |
381 #if defined RNET_CFG_WINSOCK | |
382 return rnet_ws_recv_from(desc, buff, len_p, from_addr, from_port); | |
383 #elif defined RNET_CFG_REAL_TRANSPORT | |
384 return rnet_rt_recv_from(desc, buff, len_p, from_addr, from_port); | |
385 #else | |
386 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
387 return RNET_NOT_SUPPORTED; | |
388 #endif | |
389 #else | |
390 #if defined RNET_CFG_REAL_TRANSPORT | |
391 #ifdef RNET_BENCHMARKING | |
392 rnet_benchmarking_start_timer(); | |
393 ret = rnet_rt_recv_from(desc, buff, len_p, from_addr, from_port); | |
394 rnet_benchmarking_todo(recv_from, "recv_from"); | |
395 return(ret); | |
396 #else | |
397 return rnet_rt_recv_from(desc, buff, len_p, from_addr, from_port); | |
398 #endif | |
399 #elif defined RNET_CFG_BRIDGE | |
400 return rnet_br_recv_from(desc, buff, len_p, from_addr, from_port); | |
401 #else | |
402 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
403 return RNET_NOT_SUPPORTED; | |
404 #endif | |
405 #endif | |
406 } | |
407 | |
408 /** | |
409 * Disables the sending on a socket and informs the peer | |
410 * about it. | |
411 */ | |
412 T_RNET_RET rnet_shutdown (T_RNET_DESC * desc) | |
413 { | |
414 #ifdef _WINDOWS | |
415 #if defined RNET_CFG_WINSOCK | |
416 return rnet_ws_shutdown(desc); | |
417 #elif defined RNET_CFG_REAL_TRANSPORT | |
418 return rnet_rt_shutdown(desc); | |
419 #else | |
420 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
421 return RNET_NOT_SUPPORTED; | |
422 #endif | |
423 #else | |
424 #if defined RNET_CFG_REAL_TRANSPORT | |
425 #ifdef RNET_BENCHMARKING | |
426 rnet_benchmarking_start_timer(); | |
427 ret = rnet_rt_shutdown(desc); | |
428 rnet_benchmarking_todo(shutdown, "shutdown"); | |
429 return(ret); | |
430 #else | |
431 return rnet_rt_shutdown(desc); | |
432 #endif | |
433 #elif defined RNET_CFG_BRIDGE | |
434 return rnet_br_shutdown(desc); | |
435 #else | |
436 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
437 return RNET_NOT_SUPPORTED; | |
438 #endif | |
439 #endif | |
440 } | |
441 | |
442 /** | |
443 * Closes the connection. | |
444 */ | |
445 T_RNET_RET rnet_close (T_RNET_DESC * desc) | |
446 { | |
447 #ifdef _WINDOWS | |
448 #if defined RNET_CFG_WINSOCK | |
449 return rnet_ws_close(desc); | |
450 #elif defined RNET_CFG_REAL_TRANSPORT | |
451 return rnet_rt_close(desc); | |
452 #else | |
453 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
454 return RNET_NOT_SUPPORTED; | |
455 #endif | |
456 #else | |
457 #if defined RNET_CFG_REAL_TRANSPORT | |
458 #ifdef RNET_BENCHMARKING | |
459 rnet_benchmarking_start_timer(); | |
460 ret = rnet_rt_close(desc); | |
461 rnet_benchmarking_todo(close, "close"); | |
462 return(ret); | |
463 #else | |
464 return rnet_rt_close(desc); | |
465 #endif | |
466 #elif defined RNET_CFG_BRIDGE | |
467 return rnet_br_close(desc); | |
468 #else | |
469 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
470 return RNET_NOT_SUPPORTED; | |
471 #endif | |
472 #endif | |
473 } | |
474 | |
475 /** | |
476 * Gets the local address and port of a connection ID. | |
477 */ | |
478 T_RNET_RET rnet_get_local_addr_port (T_RNET_DESC * desc, | |
479 T_RNET_IP_ADDR * local_addr, | |
480 T_RNET_PORT * local_port) | |
481 { | |
482 #ifdef _WINDOWS | |
483 #if defined RNET_CFG_WINSOCK | |
484 return rnet_ws_get_local_addr_port(desc, local_addr, local_port); | |
485 #elif defined RNET_CFG_REAL_TRANSPORT | |
486 return rnet_rt_get_local_addr_port(desc, local_addr, local_port); | |
487 #else | |
488 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
489 return RNET_NOT_SUPPORTED; | |
490 #endif | |
491 #else | |
492 #if defined RNET_CFG_REAL_TRANSPORT | |
493 #ifdef RNET_BENCHMARKING | |
494 rnet_benchmarking_start_timer(); | |
495 ret = rnet_rt_get_local_addr_port(desc, local_addr, local_port); | |
496 rnet_benchmarking_todo(get_local_adr, "get_local_adr"); | |
497 return(ret); | |
498 #else | |
499 return rnet_rt_get_local_addr_port(desc, local_addr, local_port); | |
500 #endif | |
501 #elif defined RNET_CFG_BRIDGE | |
502 return rnet_br_get_local_addr_port(desc, local_addr, local_port); | |
503 #else | |
504 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
505 return RNET_NOT_SUPPORTED; | |
506 #endif | |
507 #endif | |
508 } | |
509 | |
510 /** | |
511 * Use to determine the amount of data pending in the network's input buffer | |
512 * that can be read from the connection ID. | |
513 */ | |
514 T_RNET_RET rnet_get_buff_size (T_RNET_DESC * desc, | |
515 UINT32 * size) | |
516 { | |
517 #ifdef _WINDOWS | |
518 #if defined RNET_CFG_WINSOCK | |
519 return rnet_ws_get_buff_size(desc, size); | |
520 #elif defined RNET_CFG_REAL_TRANSPORT | |
521 return rnet_rt_get_buff_size(desc, size); | |
522 #else | |
523 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
524 return RNET_NOT_SUPPORTED; | |
525 #endif | |
526 #else | |
527 #if defined RNET_CFG_REAL_TRANSPORT | |
528 #ifdef RNET_BENCHMARKING | |
529 rnet_benchmarking_start_timer(); | |
530 ret = rnet_rt_get_buff_size(desc, size); | |
531 rnet_benchmarking_todo(get_buff_size, "get_buff_size"); | |
532 return(ret); | |
533 #else | |
534 return rnet_rt_get_buff_size(desc, size); | |
535 #endif | |
536 #elif defined RNET_CFG_BRIDGE | |
537 return rnet_br_get_buff_size(desc, size); | |
538 #else | |
539 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
540 return RNET_NOT_SUPPORTED; | |
541 #endif | |
542 #endif | |
543 } | |
544 | |
545 /** | |
546 * Indicates the maximum send size of a message for message-oriented | |
547 * descriptor (UDP) as implemented by a particular service provider. | |
548 */ | |
549 T_RNET_RET rnet_get_max_packet_size (T_RNET_DESC * desc, | |
550 UINT32 * size) | |
551 { | |
552 #ifdef _WINDOWS | |
553 #if defined RNET_CFG_WINSOCK | |
554 return rnet_ws_get_max_packet_size(desc, size); | |
555 #elif defined RNET_CFG_REAL_TRANSPORT | |
556 return rnet_rt_get_max_packet_size(desc, size); | |
557 #else | |
558 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
559 return RNET_NOT_SUPPORTED; | |
560 #endif | |
561 #else | |
562 #if defined RNET_CFG_REAL_TRANSPORT | |
563 #ifdef RNET_BENCHMARKING | |
564 rnet_benchmarking_start_timer(); | |
565 ret = rnet_rt_get_max_packet_size(desc, size); | |
566 rnet_benchmarking_todo(get_max_packet_size, "get_max_packet_size"); | |
567 return(ret); | |
568 #else | |
569 return rnet_rt_get_max_packet_size(desc, size); | |
570 #endif | |
571 #elif defined RNET_CFG_BRIDGE | |
572 return rnet_br_get_max_packet_size(desc, size); | |
573 #else | |
574 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
575 return RNET_NOT_SUPPORTED; | |
576 #endif | |
577 #endif | |
578 | |
579 } | |
580 | |
581 /** | |
582 * Requests host information corresponding to a host name or to a | |
583 * network address. | |
584 */ | |
585 T_RNET_RET rnet_get_host_info (char *name, | |
586 T_RNET_IP_ADDR addr, | |
587 T_RV_RETURN_PATH return_path, | |
588 void * user_data) | |
589 { | |
590 #ifdef _WINDOWS | |
591 #if defined RNET_CFG_WINSOCK | |
592 return rnet_ws_get_host_info(name, addr, return_path,user_data); | |
593 #elif defined RNET_CFG_REAL_TRANSPORT | |
594 return rnet_rt_get_host_info(name, addr, return_path,user_data); | |
595 #else | |
596 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
597 return RNET_NOT_SUPPORTED; | |
598 #endif | |
599 #else | |
600 #if defined RNET_CFG_REAL_TRANSPORT | |
601 #ifdef RNET_BENCHMARKING | |
602 rnet_benchmarking_start_timer(); | |
603 ret = rnet_rt_get_host_info(name, addr, return_path,user_data); | |
604 rnet_benchmarking_todo(get_host_info, "get_host_info"); | |
605 return(ret); | |
606 #else | |
607 | |
608 return rnet_rt_get_host_info(name, addr, return_path,user_data); | |
609 #endif | |
610 #elif defined RNET_CFG_BRIDGE | |
611 return rnet_br_get_host_info(name, addr, return_path,user_data); | |
612 #else | |
613 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
614 return RNET_NOT_SUPPORTED; | |
615 #endif | |
616 #endif | |
617 } | |
618 | |
619 /** | |
620 * Retrieves the protocol associated to a connection descriptor. | |
621 */ | |
622 T_RNET_IPPROTO rnet_get_proto (T_RNET_DESC *desc) | |
623 { | |
624 #ifdef _WINDOWS | |
625 #if defined RNET_CFG_WINSOCK | |
626 return rnet_ws_get_proto(desc); | |
627 #elif defined RNET_CFG_REAL_TRANSPORT | |
628 return rnet_rt_get_proto(desc); | |
629 #else | |
630 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
631 return RNET_NOT_SUPPORTED; | |
632 #endif | |
633 #else | |
634 #if defined RNET_CFG_REAL_TRANSPORT | |
635 #ifdef RNET_BENCHMARKING | |
636 rnet_benchmarking_start_timer(); | |
637 ret = rnet_rt_get_proto(desc); | |
638 rnet_benchmarking_todo(get_proto, "get_proto"); | |
639 return(ret); | |
640 #else | |
641 return rnet_rt_get_proto(desc); | |
642 #endif | |
643 #elif defined RNET_CFG_BRIDGE | |
644 return rnet_br_get_proto(desc); | |
645 #else | |
646 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
647 return RNET_IPPROTO_UDP; | |
648 #endif | |
649 #endif | |
650 } | |
651 | |
652 /** | |
653 * Associates an application specific pointer to a connection ID. | |
654 */ | |
655 void rnet_set_user_data (T_RNET_DESC *desc, void *user_data) | |
656 { | |
657 #ifdef _WINDOWS | |
658 #if defined RNET_CFG_WINSOCK | |
659 rnet_ws_set_user_data(desc, user_data); | |
660 #elif defined RNET_CFG_REAL_TRANSPORT | |
661 rnet_rt_set_user_data(desc, user_data); | |
662 #else | |
663 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
664 return RNET_NOT_SUPPORTED; | |
665 #endif | |
666 #else | |
667 #if defined RNET_CFG_REAL_TRANSPORT | |
668 #ifdef RNET_BENCHMARKING | |
669 rnet_benchmarking_start_timer(); | |
670 rnet_rt_set_user_data(desc, user_data); | |
671 rnet_benchmarking_todo(set_user_data, "set_user_data"); | |
672 #else | |
673 rnet_rt_set_user_data(desc, user_data); | |
674 #endif | |
675 #elif defined RNET_CFG_BRIDGE | |
676 rnet_br_set_user_data(desc, user_data); | |
677 #else | |
678 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
679 #endif | |
680 #endif | |
681 } | |
682 | |
683 /** | |
684 * Returns the application specific pointer associated to the connection ID. | |
685 */ | |
686 void * rnet_get_user_data (T_RNET_DESC *desc) | |
687 { | |
688 #ifdef _WINDOWS | |
689 #if defined RNET_CFG_WINSOCK | |
690 return rnet_ws_get_user_data(desc); | |
691 #elif defined RNET_CFG_REAL_TRANSPORT | |
692 return (void *)rnet_rt_get_user_data(desc); | |
693 #else | |
694 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
695 return RNET_NOT_SUPPORTED; | |
696 #endif | |
697 #else | |
698 #if defined RNET_CFG_REAL_TRANSPORT | |
699 #ifdef RNET_BENCHMARKING | |
700 void *retv; | |
701 rnet_benchmarking_start_timer(); | |
702 retv = (void *)rnet_rt_get_user_data(desc); | |
703 rnet_benchmarking_todo(get_user_data, "get_user_data"); | |
704 return(retv); | |
705 #else | |
706 return (void *)rnet_rt_get_user_data(desc); | |
707 #endif | |
708 #elif defined RNET_CFG_BRIDGE | |
709 return rnet_br_get_user_data(desc); | |
710 #else | |
711 RNET_TRACE_ERROR("RNET: No implementation chosen"); | |
712 return NULL; | |
713 #endif | |
714 #endif | |
715 } | |
716 |