Changeset 779541b in mainline for uspace/srv/net/tcp
- Timestamp:
- 2015-05-09T13:43:50Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1d4b815
- Parents:
- 99ea91b2
- Location:
- uspace/srv/net/tcp
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/Makefile
r99ea91b2 r779541b 37 37 rqueue.c \ 38 38 segment.c \ 39 service.c \ 39 40 seq_no.c \ 40 41 tcp.c \ -
uspace/srv/net/tcp/conn.c
r99ea91b2 r779541b 121 121 fibril_condvar_initialize(&conn->cstate_cv); 122 122 123 conn->c state_cb = NULL;123 conn->cb = NULL; 124 124 125 125 conn->cstate = st_listen; … … 275 275 276 276 /* Run user callback function */ 277 if (conn->c state_cb!= NULL) {277 if (conn->cb != NULL && conn->cb->cstate_change != NULL) { 278 278 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_state_set() - run user CB"); 279 conn->c state_cb(conn, conn->cstate_cb_arg);279 conn->cb->cstate_change(conn, conn->cb_arg); 280 280 } else { 281 281 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_state_set() - no user CB"); … … 1007 1007 /* Signal to the receive function that new data has arrived */ 1008 1008 fibril_condvar_broadcast(&conn->rcv_buf_cv); 1009 if (conn->cb != NULL && conn->cb->recv_data != NULL) 1010 conn->cb->recv_data(conn, conn->cb_arg); 1009 1011 1010 1012 log_msg(LOG_DEFAULT, LVL_DEBUG, "Received %zu bytes of data.", xfer_size); … … 1098 1100 conn->rcv_buf_fin = true; 1099 1101 fibril_condvar_broadcast(&conn->rcv_buf_cv); 1102 if (conn->cb != NULL && conn->cb->recv_data != NULL) 1103 conn->cb->recv_data(conn, conn->cb_arg); 1100 1104 1101 1105 tcp_segment_delete(seg); -
uspace/srv/net/tcp/tcp.c
r99ea91b2 r779541b 48 48 #include "pdu.h" 49 49 #include "rqueue.h" 50 #include "service.h" 50 51 #include "std.h" 51 52 #include "tcp.h" … … 192 193 } 193 194 194 // rc = tcp_sock_init();195 //if (rc != EOK) {196 // log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing socketservice.");197 //return ENOENT;198 //}195 rc = tcp_service_init(); 196 if (rc != EOK) { 197 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing service."); 198 return ENOENT; 199 } 199 200 200 201 return EOK; -
uspace/srv/net/tcp/tcp_type.h
r99ea91b2 r779541b 96 96 TCP_EINVPREC, 97 97 /* Security/compartment not allowed */ 98 TCP_EINVCOMP 98 TCP_EINVCOMP, 99 TCP_EAGAIN 99 100 } tcp_error_t; 100 101 … … 154 155 typedef void (*tcp_cstate_cb_t)(tcp_conn_t *, void *); 155 156 157 /** Connection callbacks */ 158 typedef struct { 159 void (*cstate_change)(tcp_conn_t *, void *); 160 void (*recv_data)(tcp_conn_t *, void *); 161 } tcp_cb_t; 162 156 163 /** Connection */ 157 164 struct tcp_conn { … … 159 166 link_t link; 160 167 161 /** Connection state change callbackfunction */162 tcp_c state_cb_t cstate_cb;168 /** Connection callbacks function */ 169 tcp_cb_t *cb; 163 170 /** Argument to @c cstate_cb */ 164 void *c state_cb_arg;171 void *cb_arg; 165 172 166 173 /** Connection identification (local and foreign socket) */ … … 318 325 } tcp_pdu_t; 319 326 320 typedef struct { 327 /** TCP client connection */ 328 typedef struct tcp_cconn { 329 /** Connection */ 330 tcp_conn_t *conn; 331 /** Connection ID for the client */ 332 sysarg_t id; 333 /** Client */ 334 struct tcp_client *client; 335 link_t lclient; 336 } tcp_cconn_t; 337 338 /** TCP client listener */ 339 typedef struct tcp_clst { 340 /** Connection */ 341 tcp_conn_t *conn; 342 /** Listener ID for the client */ 343 sysarg_t id; 344 /** Client */ 345 struct tcp_client *client; 346 /** Link to tcp_client_t.clst */ 347 link_t lclient; 348 } tcp_clst_t; 349 350 /** TCP client */ 351 typedef struct tcp_client { 352 /** Client callbac session */ 321 353 async_sess_t *sess; 322 // socket_cores_t sockets; 354 /** Client's connections */ 355 list_t cconn; /* of tcp_cconn_t */ 356 /** Client's listeners */ 357 list_t clst; 323 358 } tcp_client_t; 324 359 … … 358 393 } tcp_sock_lconn_t; 359 394 360 361 395 #endif 362 396 -
uspace/srv/net/tcp/tqueue.c
r99ea91b2 r779541b 285 285 { 286 286 log_msg(LOG_DEFAULT, LVL_DEBUG, 287 "tcp_transmit_segment( f:(%u),l:(%u), %p)",287 "tcp_transmit_segment(l:(%u),f:(%u), %p)", 288 288 sp->local.port, sp->foreign.port, seg); 289 289 -
uspace/srv/net/tcp/ucall.c
r99ea91b2 r779541b 188 188 /* Wait for data to become available */ 189 189 while (conn->rcv_buf_used == 0 && !conn->rcv_buf_fin && !conn->reset) { 190 tcp_conn_unlock(conn); 191 return TCP_EAGAIN; 190 192 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_receive() - wait for data"); 191 193 fibril_condvar_wait(&conn->rcv_buf_cv, &conn->lock); … … 294 296 } 295 297 296 void tcp_uc_set_c state_cb(tcp_conn_t *conn, tcp_cstate_cb_tcb, void *arg)297 { 298 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_set_c tate_cb(%p, %p, %p)",298 void tcp_uc_set_cb(tcp_conn_t *conn, tcp_cb_t *cb, void *arg) 299 { 300 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_set_cb(%p, %p, %p)", 299 301 conn, cb, arg); 300 302 301 conn->c state_cb = cb;302 conn->c state_cb_arg = arg;303 conn->cb = cb; 304 conn->cb_arg = arg; 303 305 } 304 306 -
uspace/srv/net/tcp/ucall.h
r99ea91b2 r779541b 50 50 extern void tcp_uc_status(tcp_conn_t *, tcp_conn_status_t *); 51 51 extern void tcp_uc_delete(tcp_conn_t *); 52 extern void tcp_uc_set_c state_cb(tcp_conn_t *, tcp_cstate_cb_t, void *);52 extern void tcp_uc_set_cb(tcp_conn_t *, tcp_cb_t *, void *); 53 53 54 54 /*
Note:
See TracChangeset
for help on using the changeset viewer.