Changeset 854e79a6 in mainline
- Timestamp:
- 2011-11-17T14:53:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 004a5fe
- Parents:
- 4f3f6285
- Location:
- uspace/srv/net/tl/tcp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/state.c
r4f3f6285 r854e79a6 54 54 * @param acpass Active/passive 55 55 * @param conn Connection 56 * 57 * XXX We should be able to call active open on an existing listening 58 * connection. 56 59 */ 57 60 void tcp_uc_open(uint16_t lport, tcp_sock_t *fsock, acpass_t acpass, … … 80 83 81 84 /** SEND user call */ 82 void tcp_uc_send(tcp_conn_t *conn, void *data, size_t size, xflags_t flags) 85 tcp_error_t tcp_uc_send(tcp_conn_t *conn, void *data, size_t size, 86 xflags_t flags) 83 87 { 84 88 size_t buf_free; … … 86 90 87 91 log_msg(LVL_DEBUG, "tcp_uc_send()"); 92 93 if (conn->cstate == st_closed) 94 return TCP_ENOTEXIST; 95 96 if (conn->cstate == st_listen) { 97 /* Change connection to active */ 98 tcp_conn_sync(conn); 99 } 100 101 if (conn->snd_buf_fin) 102 return TCP_ECLOSING; 88 103 89 104 while (size > 0) { … … 102 117 103 118 tcp_tqueue_new_data(conn); 119 120 return TCP_EOK; 104 121 } 105 122 106 123 /** RECEIVE user call */ 107 void tcp_uc_receive(tcp_conn_t *conn, void *buf, size_t size, size_t *rcvd,108 xflags_t *xflags)124 tcp_error_t tcp_uc_receive(tcp_conn_t *conn, void *buf, size_t size, 125 size_t *rcvd, xflags_t *xflags) 109 126 { 110 127 size_t xfer_size; … … 112 129 log_msg(LVL_DEBUG, "tcp_uc_receive()"); 113 130 114 /*115 * XXX Handle all states for all user calls properly, return116 * errors as appropriate.117 */118 131 if (conn->cstate == st_closed) 119 return; 120 132 return TCP_ENOTEXIST; 121 133 122 134 fibril_mutex_lock(&conn->rcv_buf_lock); … … 130 142 if (conn->rcv_buf_used == 0) { 131 143 /* End of data, peer closed connection. */ 132 /* XXX How should RECEIVE signal end of data? */133 144 assert(conn->rcv_buf_fin); 134 145 *rcvd = 0; 135 146 *xflags = 0; 136 return ;147 return TCP_ECLOSING; 137 148 } 138 149 … … 158 169 log_msg(LVL_DEBUG, "tcp_uc_receive() - returning %zu bytes", 159 170 xfer_size); 171 172 return TCP_EOK; 160 173 } 161 174 162 175 /** CLOSE user call */ 163 voidtcp_uc_close(tcp_conn_t *conn)176 tcp_error_t tcp_uc_close(tcp_conn_t *conn) 164 177 { 165 178 log_msg(LVL_DEBUG, "tcp_uc_close()"); 179 180 if (conn->cstate == st_closed) 181 return TCP_ENOTEXIST; 182 183 if (conn->snd_buf_fin) 184 return TCP_ECLOSING; 166 185 167 186 conn->snd_buf_fin = true; 168 187 tcp_tqueue_new_data(conn); 188 189 return TCP_EOK; 169 190 } 170 191 … … 211 232 } 212 233 213 /** Retransmission timeout */214 void tcp_to_retransmit(void)215 {216 log_msg(LVL_DEBUG, "tcp_to_retransmit()");217 }218 219 234 /** 220 235 * @} -
uspace/srv/net/tl/tcp/state.h
r4f3f6285 r854e79a6 43 43 */ 44 44 extern void tcp_uc_open(uint16_t, tcp_sock_t *, acpass_t, tcp_conn_t **); 45 extern voidtcp_uc_send(tcp_conn_t *, void *, size_t, xflags_t);46 extern voidtcp_uc_receive(tcp_conn_t *, void *, size_t, size_t *, xflags_t *);47 extern voidtcp_uc_close(tcp_conn_t *);45 extern tcp_error_t tcp_uc_send(tcp_conn_t *, void *, size_t, xflags_t); 46 extern tcp_error_t tcp_uc_receive(tcp_conn_t *, void *, size_t, size_t *, xflags_t *); 47 extern tcp_error_t tcp_uc_close(tcp_conn_t *); 48 48 extern void tcp_uc_abort(tcp_conn_t *); 49 49 extern void tcp_uc_status(tcp_conn_t *, tcp_conn_status_t *); … … 58 58 */ 59 59 extern void tcp_to_user(void); 60 extern void tcp_to_retransmit(void);61 60 62 61 #endif -
uspace/srv/net/tl/tcp/tcp_type.h
r4f3f6285 r854e79a6 68 68 } tcp_cstate_t; 69 69 70 /** Error codes returned by TCP user calls (per the spec). */ 71 typedef enum { 72 /* OK */ 73 TCP_EOK, 74 /* Connection aborted due to user timeout */ 75 TCP_EABORTED, 76 /* Connection already exists */ 77 TCP_EEXISTS, 78 /* Connection closing */ 79 TCP_ECLOSING, 80 /* Connection does not exist */ 81 TCP_ENOTEXIST, 82 /* Connection illegal for this process */ 83 TCP_EILLEGAL, 84 /* Connection not open */ 85 TCP_ENOTOPEN, 86 /* Connection reset */ 87 TCP_ERESET, 88 /* Foreign socket unspecified */ 89 TCP_EUNSPEC, 90 /* Insufficient resources */ 91 TCP_ENORES, 92 /* Precedence not allowed */ 93 TCP_EINVPREC, 94 /* Security/compartment not allowed */ 95 TCP_EINVCOMP 96 } tcp_error_t; 97 70 98 typedef enum { 71 99 XF_PUSH = 0x1,
Note:
See TracChangeset
for help on using the changeset viewer.