FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_send.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /** | |
2 * @file rnet_rt_api_send.c | |
3 * | |
4 * RNET_RT API | |
5 * | |
6 * @author Regis Feneon | |
7 * @version 0.1 | |
8 */ | |
9 | |
10 /* | |
11 * $Id: rnet_rt_api_send.c,v 1.4 2002/10/30 15:23:34 rf Exp $ | |
12 * $Name: ti_20021030 $ | |
13 * | |
14 * History: | |
15 * | |
16 * Date Author Modification | |
17 * -------------------------------------------------- | |
18 * 3/22/2002 Regis Feneon Create | |
19 * | |
20 * (C) Copyright 2002 by TI, All Rights Reserved | |
21 * | |
22 */ | |
23 | |
24 #include "rnet_cfg.h" | |
25 #ifdef RNET_CFG_REAL_TRANSPORT | |
26 | |
27 #include "rnet_rt_i.h" | |
28 #include "rnet_rt_env.h" | |
29 | |
30 /** | |
31 * Enqueues the data for sending. | |
32 * | |
33 * Data is sent by enqueueing the data with a call to rnet_send(). | |
34 * The function is not-blocking. | |
35 * | |
36 * In case of TCP, when the data is successfully transmitted to the remote | |
37 * host, the application will be notified with a RNET_SEND_CFM message. | |
38 * | |
39 * Returns RNET_PARTIAL_SENT if not all data could be sent and the function | |
40 * needs to be called again later to send the rest of the data. In that case, | |
41 * the out value of len_p is the number of bytes effectively sent. | |
42 * | |
43 * The buffer is copied by RNET, so the application can free the data buffer | |
44 * when the function returns. | |
45 * | |
46 * TODO: The proper way to use this function. | |
47 * | |
48 * @param desc Connection identifier [IN]. | |
49 * @param buff Pointer on the data to send [IN]. | |
50 * @param len_p Pointer on the length of the data to send [IN]. | |
51 * Pointer on the length of the data effectively sent [OUT]. | |
52 * @return RNET_MEMORY_ERR Not enough memory is available | |
53 * RNET_NOT_INITIALIZED NET subsystem not initialized (internal error). | |
54 * RNET_INTERNAL_ERR Network subsystem failed. | |
55 * or Requested address is a broadcast address. | |
56 * RNET_INVALID_PARAMETER The connection ID is invalid. | |
57 * or The ID is not connected. | |
58 * or Invalid buff parameter. | |
59 * or Connection not bound with bind. | |
60 * RNET_CONN_ABORTED Connection broken due to the "keep-alive" activity | |
61 * detecting a failure while the operation was in progress. | |
62 * or Virtual circuit terminated due to a time-out or other failure. | |
63 * RNET_MSG_SIZE Message oriented connection (UDP), and the message | |
64 * is larger than the maximum supported by the underlying transport. | |
65 * RNET_NET_UNREACHABLE Remote host cannot be reached from this host at this time. | |
66 * RNET_CONN_RESET The virtual circuit was reset by the remote side executing a "hard" | |
67 * or "abortive" close. | |
68 * RNET_TIMEOUT The connection has been dropped, because of a | |
69 * network failure or because the system on the other end went down | |
70 * without notice. | |
71 * RNET_NOT_READY Still processing a callback function. | |
72 * RNET_OK Sending in progress | |
73 * RNET_SEND_CFM will be sent when the sending | |
74 * has been successfully completed. | |
75 */ | |
76 | |
77 T_RNET_RET rnet_rt_send (T_RNET_DESC * desc, | |
78 T_RVF_BUFFER * buff, | |
79 UINT16 * len_p) | |
80 { | |
81 int ret; | |
82 | |
83 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex); | |
84 ret = ngSAIOSend( (NGsock *) desc, buff, *len_p, 0, NULL); | |
85 if( (ret == NG_EWOULDBLOCK) || ((ret > 0) && (ret != *len_p))) { | |
86 /* send RNET_SEND_RDY message when data will be acknowledged */ | |
87 ((T_RNET_RT_SOCK *) desc)->flags |= RNET_RT_SOCKF_NOTIFY_SEND; | |
88 } | |
89 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex); | |
90 | |
91 if( ret == NG_EWOULDBLOCK) { | |
92 ret = 0; | |
93 } | |
94 if( ret >= 0) { | |
95 if( ret != *len_p) { | |
96 /* not all data has been sent */ | |
97 *len_p = ret; | |
98 return( RNET_PARTIAL_SENT); | |
99 } | |
100 return( RNET_OK); | |
101 } | |
102 | |
103 return( rnet_rt_ngip_error( ret)); | |
104 } | |
105 | |
106 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */ | |
107 |