Changeset 06b0211b in mainline for uspace/srv/net/tcp/sock.c
- Timestamp:
- 2013-04-29T11:29:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aa2b32c
- Parents:
- ba4799a (diff), df956b9b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/sock.c
rba4799a r06b0211b 203 203 { 204 204 int rc; 205 struct sockaddr *addr;206 size_t addr_ len;205 struct sockaddr_in *addr; 206 size_t addr_size; 207 207 socket_core_t *sock_core; 208 208 tcp_sockdata_t *socket; 209 209 210 210 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_bind()"); 211 211 log_msg(LOG_DEFAULT, LVL_DEBUG, " - async_data_write_accept"); 212 rc = async_data_write_accept((void **) &addr, false, 0, 0, 0, &addr_len); 212 213 addr = NULL; 214 215 rc = async_data_write_accept((void **) &addr, false, 0, 0, 0, &addr_size); 213 216 if (rc != EOK) { 214 217 async_answer_0(callid, rc); 215 return; 216 } 217 218 goto out; 219 } 220 221 if (addr_size != sizeof(struct sockaddr_in)) { 222 async_answer_0(callid, EINVAL); 223 goto out; 224 } 225 218 226 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_bind"); 219 227 rc = socket_bind(&client->sockets, &gsock, SOCKET_GET_SOCKET_ID(call), 220 addr, addr_ len, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END,228 addr, addr_size, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, 221 229 last_used_port); 222 230 if (rc != EOK) { 223 231 async_answer_0(callid, rc); 224 return;225 } 226 232 goto out; 233 } 234 227 235 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_cores_find"); 228 236 sock_core = socket_cores_find(&client->sockets, SOCKET_GET_SOCKET_ID(call)); 229 if (sock_core != NULL) { 230 socket = (tcp_sockdata_t *)sock_core->specific_data; 231 /* XXX Anything to do? */ 232 (void) socket; 233 } 234 237 if (sock_core == NULL) { 238 async_answer_0(callid, ENOENT); 239 goto out; 240 } 241 242 socket = (tcp_sockdata_t *)sock_core->specific_data; 243 /* XXX Anything to do? */ 244 (void) socket; 245 235 246 log_msg(LOG_DEFAULT, LVL_DEBUG, " - success"); 236 247 async_answer_0(callid, EOK); 248 249 out: 250 if (addr != NULL) 251 free(addr); 237 252 } 238 253 … … 249 264 tcp_sock_lconn_t *lconn; 250 265 int i; 266 int rc; 251 267 252 268 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_listen()"); … … 268 284 return; 269 285 } 270 271 socket = (tcp_sockdata_t *)sock_core->specific_data; 272 286 287 if (sock_core->port <= 0) { 288 rc = socket_bind_free_port(&gsock, sock_core, 289 TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, 290 last_used_port); 291 if (rc != EOK) { 292 async_answer_0(callid, rc); 293 return; 294 } 295 296 last_used_port = sock_core->port; 297 } 298 299 socket = (tcp_sockdata_t *) sock_core->specific_data; 300 273 301 /* 274 302 * Prepare @c backlog listening connections. 275 303 */ 276 304 fibril_mutex_lock(&socket->lock); 277 305 278 306 socket->backlog = backlog; 279 307 socket->lconn = calloc(backlog, sizeof(tcp_conn_t *)); … … 283 311 return; 284 312 } 285 313 286 314 log_msg(LOG_DEFAULT, LVL_DEBUG, " - open connections"); 287 315 288 316 lsocket.addr.ipv4 = TCP_IPV4_ANY; 289 317 lsocket.port = sock_core->port; 290 318 fsocket.addr.ipv4 = TCP_IPV4_ANY; 291 319 fsocket.port = TCP_PORT_ANY; 292 320 293 321 for (i = 0; i < backlog; i++) { 294 322 … … 362 390 return; 363 391 } 364 392 365 393 last_used_port = sock_core->port; 366 394 } … … 441 469 return; 442 470 } 471 472 if (sock_core->port <= 0) { 473 rc = socket_bind_free_port(&gsock, sock_core, 474 TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, 475 last_used_port); 476 if (rc != EOK) { 477 async_answer_0(callid, rc); 478 return; 479 } 480 481 last_used_port = sock_core->port; 482 } 443 483 444 484 socket = (tcp_sockdata_t *)sock_core->specific_data;
Note:
See TracChangeset
for help on using the changeset viewer.