Changeset aadf01e in mainline for uspace/srv/net/socket/socket_client.c
- Timestamp:
- 2010-03-07T15:13:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 936835e
- Parents:
- aa85487
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/socket/socket_client.c
raa85487 raadf01e 75 75 /** Default timeout for connections in microseconds. 76 76 */ 77 #define SOCKET_CONNECT_TIMEOUT ( 1 * 1000 * 1000)77 #define SOCKET_CONNECT_TIMEOUT (1 * 1000 * 1000) 78 78 79 79 /** Maximum number of random attempts to find a new socket identifier before switching to the sequence. … … 97 97 /** Socket identifier. 98 98 */ 99 int 99 int socket_id; 100 100 /** Parent module phone. 101 101 */ 102 int 102 int phone; 103 103 /** Parent module service. 104 104 */ 105 services_t 105 services_t service; 106 106 /** Underlying protocol header size. 107 107 * Sending and receiving optimalization. 108 108 */ 109 size_t 109 size_t header_size; 110 110 /** Packet data fragment size. 111 111 * Sending optimalization. 112 112 */ 113 size_t 113 size_t data_fragment_size; 114 114 /** Sending safety lock. 115 115 * Locks the header_size and data_fragment_size attributes. 116 116 */ 117 fibril_rwlock_t 117 fibril_rwlock_t sending_lock; 118 118 /** Received packets queue. 119 119 */ 120 dyn_fifo_t 120 dyn_fifo_t received; 121 121 /** Received packets safety lock. 122 122 * Used for receiving and receive notifications. 123 123 * Locks the received attribute. 124 124 */ 125 fibril_mutex_t 125 fibril_mutex_t receive_lock; 126 126 /** Received packets signaling. 127 127 * Signaled upon receive notification. 128 128 */ 129 fibril_condvar_t 129 fibril_condvar_t receive_signal; 130 130 /** Waiting sockets queue. 131 131 */ 132 dyn_fifo_t 132 dyn_fifo_t accepted; 133 133 /** Waiting sockets safety lock. 134 134 * Used for accepting and accept notifications. 135 135 * Locks the accepted attribute. 136 136 */ 137 fibril_mutex_t 137 fibril_mutex_t accept_lock; 138 138 /** Waiting sockets signaling. 139 139 * Signaled upon accept notification. 140 140 */ 141 fibril_condvar_t 141 fibril_condvar_t accept_signal; 142 142 /** The number of blocked functions called. 143 143 * Used while waiting for the received packets or accepted sockets. 144 144 */ 145 int 145 int blocked; 146 146 }; 147 147 … … 150 150 * @see int_map.h 151 151 */ 152 INT_MAP_DECLARE( sockets, socket_t);152 INT_MAP_DECLARE(sockets, socket_t); 153 153 154 154 /** Socket client library global data. … … 157 157 /** TCP module phone. 158 158 */ 159 int 159 int tcp_phone; 160 160 /** UDP module phone. 161 161 */ 162 int 162 int udp_phone; 163 163 // /** The last socket identifier. 164 164 // */ … … 166 166 /** Active sockets. 167 167 */ 168 sockets_ref 168 sockets_ref sockets; 169 169 /** Safety lock. 170 170 * Write lock is used only for adding or removing sockets. … … 173 173 * No socket lock may be locked if this lock is unlocked. 174 174 */ 175 fibril_rwlock_t 175 fibril_rwlock_t lock; 176 176 } socket_globals = { 177 177 .tcp_phone = -1, … … 183 183 .writers = 0, 184 184 .waiters = { 185 .prev = & 186 .next = & 185 .prev = &socket_globals.lock.waiters, 186 .next = &socket_globals.lock.waiters 187 187 } 188 188 } 189 189 }; 190 190 191 INT_MAP_IMPLEMENT( sockets, socket_t);191 INT_MAP_IMPLEMENT(sockets, socket_t); 192 192 193 193 /** Returns the TCP module phone. … … 196 196 * @returns Other error codes as defined for the bind_service_timeout() function. 197 197 */ 198 static int socket_get_tcp_phone( void);198 static int socket_get_tcp_phone(void); 199 199 200 200 /** Returns the UDP module phone. … … 203 203 * @returns Other error codes as defined for the bind_service_timeout() function. 204 204 */ 205 static int socket_get_udp_phone( void);205 static int socket_get_udp_phone(void); 206 206 207 207 /** Returns the active sockets. 208 208 * @returns The active sockets. 209 209 */ 210 static sockets_ref socket_get_sockets( void);210 static sockets_ref socket_get_sockets(void); 211 211 212 212 /** Tries to find a new free socket identifier. … … 214 214 * @returns ELIMIT if there is no socket identifier available. 215 215 */ 216 static int socket_generate_new_id( void);216 static int socket_generate_new_id(void); 217 217 218 218 /** Default thread for new connections. … … 220 220 * @param[in] icall The initial message call structure. 221 221 */ 222 void socket_connection( ipc_callid_t iid, ipc_call_t * icall);222 void socket_connection(ipc_callid_t iid, ipc_call_t * icall); 223 223 224 224 /** Sends message to the socket parent module with specified data. … … 234 234 * @returns Other error codes as defined for the spcific message. 235 235 */ 236 int socket_send_data( int socket_id, ipcarg_t message, ipcarg_t arg2, const void * data, size_t datalength);236 int socket_send_data(int socket_id, ipcarg_t message, ipcarg_t arg2, const void * data, size_t datalength); 237 237 238 238 /** Initializes a new socket specific data. … … 242 242 * @param[in] service The parent module service. 243 243 */ 244 void socket_initialize( socket_ref socket, int socket_id, int phone, services_t service);244 void socket_initialize(socket_ref socket, int socket_id, int phone, services_t service); 245 245 246 246 /** Clears and destroys the socket. 247 247 * @param[in] socket The socket to be destroyed. 248 248 */ 249 void socket_destroy( socket_ref socket);249 void socket_destroy(socket_ref socket); 250 250 251 251 /** Receives data via the socket. … … 263 263 * @returns Other error codes as defined for the spcific message. 264 264 */ 265 int recvfrom_core( ipcarg_t message, int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen);265 int recvfrom_core(ipcarg_t message, int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen); 266 266 267 267 /** Sends data via the socket to the remote address. … … 280 280 * @returns Other error codes as defined for the NET_SOCKET_SENDTO message. 281 281 */ 282 int sendto_core( ipcarg_t message, int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen);283 284 static int socket_get_tcp_phone( void){285 if( socket_globals.tcp_phone < 0){286 socket_globals.tcp_phone = bind_service_timeout( SERVICE_TCP, 0, 0, SERVICE_TCP, socket_connection, SOCKET_CONNECT_TIMEOUT);282 int sendto_core(ipcarg_t message, int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen); 283 284 static int socket_get_tcp_phone(void){ 285 if(socket_globals.tcp_phone < 0){ 286 socket_globals.tcp_phone = bind_service_timeout(SERVICE_TCP, 0, 0, SERVICE_TCP, socket_connection, SOCKET_CONNECT_TIMEOUT); 287 287 } 288 288 return socket_globals.tcp_phone; 289 289 } 290 290 291 static int socket_get_udp_phone( void){292 if( socket_globals.udp_phone < 0){293 socket_globals.udp_phone = bind_service_timeout( SERVICE_UDP, 0, 0, SERVICE_UDP, socket_connection, SOCKET_CONNECT_TIMEOUT);291 static int socket_get_udp_phone(void){ 292 if(socket_globals.udp_phone < 0){ 293 socket_globals.udp_phone = bind_service_timeout(SERVICE_UDP, 0, 0, SERVICE_UDP, socket_connection, SOCKET_CONNECT_TIMEOUT); 294 294 } 295 295 return socket_globals.udp_phone; 296 296 } 297 297 298 static sockets_ref socket_get_sockets( void ){ 299 if( ! socket_globals.sockets ){ 300 socket_globals.sockets = ( sockets_ref ) malloc( sizeof( sockets_t )); 301 if( ! socket_globals.sockets ) return NULL; 302 if( sockets_initialize( socket_globals.sockets ) != EOK ){ 303 free( socket_globals.sockets ); 298 static sockets_ref socket_get_sockets(void){ 299 if(! socket_globals.sockets){ 300 socket_globals.sockets = (sockets_ref) malloc(sizeof(sockets_t)); 301 if(! socket_globals.sockets){ 302 return NULL; 303 } 304 if(sockets_initialize(socket_globals.sockets) != EOK){ 305 free(socket_globals.sockets); 304 306 socket_globals.sockets = NULL; 305 307 } 306 srand( 308 srand(task_get_id()); 307 309 } 308 310 return socket_globals.sockets; 309 311 } 310 312 311 static int socket_generate_new_id( void){312 sockets_ref 313 int 314 int 313 static int socket_generate_new_id(void){ 314 sockets_ref sockets; 315 int socket_id; 316 int count; 315 317 316 318 sockets = socket_get_sockets(); … … 318 320 // socket_id = socket_globals.last_id; 319 321 do{ 320 if( count < SOCKET_ID_TRIES){322 if(count < SOCKET_ID_TRIES){ 321 323 socket_id = rand() % INT_MAX; 322 324 ++ count; 323 }else if( count == SOCKET_ID_TRIES){325 }else if(count == SOCKET_ID_TRIES){ 324 326 socket_id = 1; 325 327 ++ count; 326 328 // only this branch for last_id 327 329 }else{ 328 if( socket_id < INT_MAX){330 if(socket_id < INT_MAX){ 329 331 ++ socket_id; 330 /* }else if( socket_globals.last_id){332 /* }else if(socket_globals.last_id){ 331 333 * socket_globals.last_id = 0; 332 334 * socket_id = 1; … … 335 337 } 336 338 } 337 }while( sockets_find( sockets, socket_id));339 }while(sockets_find(sockets, socket_id)); 338 340 // last_id = socket_id 339 341 return socket_id; 340 342 } 341 343 342 void socket_initialize( socket_ref socket, int socket_id, int phone, services_t service){344 void socket_initialize(socket_ref socket, int socket_id, int phone, services_t service){ 343 345 socket->socket_id = socket_id; 344 346 socket->phone = phone; 345 347 socket->service = service; 346 dyn_fifo_initialize( & socket->received, SOCKET_INITIAL_RECEIVED_SIZE);347 dyn_fifo_initialize( & socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);348 fibril_mutex_initialize( & socket->receive_lock);349 fibril_condvar_initialize( & socket->receive_signal);350 fibril_mutex_initialize( & socket->accept_lock);351 fibril_condvar_initialize( & socket->accept_signal);352 fibril_rwlock_initialize( & socket->sending_lock);353 } 354 355 void socket_connection( ipc_callid_t iid, ipc_call_t * icall){348 dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 349 dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 350 fibril_mutex_initialize(&socket->receive_lock); 351 fibril_condvar_initialize(&socket->receive_signal); 352 fibril_mutex_initialize(&socket->accept_lock); 353 fibril_condvar_initialize(&socket->accept_signal); 354 fibril_rwlock_initialize(&socket->sending_lock); 355 } 356 357 void socket_connection(ipc_callid_t iid, ipc_call_t * icall){ 356 358 ERROR_DECLARE; 357 359 358 ipc_callid_t 359 ipc_call_t 360 socket_ref 361 362 while( true){363 364 callid = async_get_call( & call);365 switch( IPC_GET_METHOD( call)){360 ipc_callid_t callid; 361 ipc_call_t call; 362 socket_ref socket; 363 364 while(true){ 365 366 callid = async_get_call(&call); 367 switch(IPC_GET_METHOD(call)){ 366 368 case NET_SOCKET_RECEIVED: 367 369 case NET_SOCKET_ACCEPTED: 368 370 case NET_SOCKET_DATA_FRAGMENT_SIZE: 369 fibril_rwlock_read_lock( & socket_globals.lock);371 fibril_rwlock_read_lock(&socket_globals.lock); 370 372 // find the socket 371 socket = sockets_find( socket_get_sockets(), SOCKET_GET_SOCKET_ID( call));372 if( ! socket){373 socket = sockets_find(socket_get_sockets(), SOCKET_GET_SOCKET_ID(call)); 374 if(! socket){ 373 375 ERROR_CODE = ENOTSOCK; 374 376 }else{ 375 switch( IPC_GET_METHOD( call)){377 switch(IPC_GET_METHOD(call)){ 376 378 case NET_SOCKET_RECEIVED: 377 fibril_mutex_lock( & socket->receive_lock);379 fibril_mutex_lock(&socket->receive_lock); 378 380 // push the number of received packet fragments 379 if( ! ERROR_OCCURRED( dyn_fifo_push( & socket->received, SOCKET_GET_DATA_FRAGMENTS( call ), SOCKET_MAX_RECEIVED_SIZE))){381 if(! ERROR_OCCURRED(dyn_fifo_push(&socket->received, SOCKET_GET_DATA_FRAGMENTS(call), SOCKET_MAX_RECEIVED_SIZE))){ 380 382 // signal the received packet 381 fibril_condvar_signal( & socket->receive_signal);383 fibril_condvar_signal(&socket->receive_signal); 382 384 } 383 fibril_mutex_unlock( & socket->receive_lock);385 fibril_mutex_unlock(&socket->receive_lock); 384 386 break; 385 387 case NET_SOCKET_ACCEPTED: 386 388 // push the new socket identifier 387 fibril_mutex_lock( & socket->accept_lock);388 if( ! ERROR_OCCURRED( dyn_fifo_push( & socket->accepted, 1, SOCKET_MAX_ACCEPTED_SIZE))){389 fibril_mutex_lock(&socket->accept_lock); 390 if(! ERROR_OCCURRED(dyn_fifo_push(&socket->accepted, 1, SOCKET_MAX_ACCEPTED_SIZE))){ 389 391 // signal the accepted socket 390 fibril_condvar_signal( & socket->accept_signal);392 fibril_condvar_signal(&socket->accept_signal); 391 393 } 392 fibril_mutex_unlock( & socket->accept_lock);394 fibril_mutex_unlock(&socket->accept_lock); 393 395 break; 394 396 default: 395 397 ERROR_CODE = ENOTSUP; 396 398 } 397 if(( SOCKET_GET_DATA_FRAGMENT_SIZE( call ) > 0)398 && ( SOCKET_GET_DATA_FRAGMENT_SIZE( call ) != socket->data_fragment_size)){399 fibril_rwlock_write_lock( & socket->sending_lock);399 if((SOCKET_GET_DATA_FRAGMENT_SIZE(call) > 0) 400 && (SOCKET_GET_DATA_FRAGMENT_SIZE(call) != socket->data_fragment_size)){ 401 fibril_rwlock_write_lock(&socket->sending_lock); 400 402 // set the data fragment size 401 socket->data_fragment_size = SOCKET_GET_DATA_FRAGMENT_SIZE( call);402 fibril_rwlock_write_unlock( & socket->sending_lock);403 socket->data_fragment_size = SOCKET_GET_DATA_FRAGMENT_SIZE(call); 404 fibril_rwlock_write_unlock(&socket->sending_lock); 403 405 } 404 406 } 405 fibril_rwlock_read_unlock( & socket_globals.lock);407 fibril_rwlock_read_unlock(&socket_globals.lock); 406 408 break; 407 409 default: 408 410 ERROR_CODE = ENOTSUP; 409 411 } 410 ipc_answer_0( callid, ( ipcarg_t ) ERROR_CODE);411 } 412 } 413 414 int socket( int domain, int type, int protocol){412 ipc_answer_0(callid, (ipcarg_t) ERROR_CODE); 413 } 414 } 415 416 int socket(int domain, int type, int protocol){ 415 417 ERROR_DECLARE; 416 418 417 socket_ref 418 int 419 int 420 services_t 419 socket_ref socket; 420 int phone; 421 int socket_id; 422 services_t service; 421 423 422 424 // find the appropriate service 423 switch( domain){425 switch(domain){ 424 426 case PF_INET: 425 switch( type){427 switch(type){ 426 428 case SOCK_STREAM: 427 if( ! protocol ) protocol = IPPROTO_TCP; 428 switch( protocol ){ 429 if(! protocol){ 430 protocol = IPPROTO_TCP; 431 } 432 switch(protocol){ 429 433 case IPPROTO_TCP: 430 434 phone = socket_get_tcp_phone(); … … 436 440 break; 437 441 case SOCK_DGRAM: 438 if( ! protocol ) protocol = IPPROTO_UDP; 439 switch( protocol ){ 442 if(! protocol){ 443 protocol = IPPROTO_UDP; 444 } 445 switch(protocol){ 440 446 case IPPROTO_UDP: 441 447 phone = socket_get_udp_phone(); … … 455 461 return EPFNOSUPPORT; 456 462 } 457 if( phone < 0 ) return phone; 463 if(phone < 0){ 464 return phone; 465 } 458 466 // create a new socket structure 459 socket = ( socket_ref ) malloc( sizeof( socket_t )); 460 if( ! socket ) return ENOMEM; 461 bzero( socket, sizeof( * socket )); 462 fibril_rwlock_write_lock( & socket_globals.lock ); 467 socket = (socket_ref) malloc(sizeof(socket_t)); 468 if(! socket){ 469 return ENOMEM; 470 } 471 bzero(socket, sizeof(*socket)); 472 fibril_rwlock_write_lock(&socket_globals.lock); 463 473 // request a new socket 464 474 socket_id = socket_generate_new_id(); 465 if( socket_id <= 0){466 fibril_rwlock_write_unlock( & socket_globals.lock);467 free( socket);475 if(socket_id <= 0){ 476 fibril_rwlock_write_unlock(&socket_globals.lock); 477 free(socket); 468 478 return socket_id; 469 479 } 470 if( ERROR_OCCURRED(( int ) async_req_3_3( phone, NET_SOCKET, socket_id, 0, service, NULL, ( ipcarg_t * ) & socket->data_fragment_size, ( ipcarg_t * ) & socket->header_size))){471 fibril_rwlock_write_unlock( & socket_globals.lock);472 free( socket);480 if(ERROR_OCCURRED((int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, (ipcarg_t *) &socket->data_fragment_size, (ipcarg_t *) &socket->header_size))){ 481 fibril_rwlock_write_unlock(&socket_globals.lock); 482 free(socket); 473 483 return ERROR_CODE; 474 484 } 475 485 // finish the new socket initialization 476 socket_initialize( socket, socket_id, phone, service);486 socket_initialize(socket, socket_id, phone, service); 477 487 // store the new socket 478 ERROR_CODE = sockets_add( socket_get_sockets(), socket_id, socket);479 fibril_rwlock_write_unlock( & socket_globals.lock);480 if( ERROR_CODE < 0){481 dyn_fifo_destroy( & socket->received);482 dyn_fifo_destroy( & socket->accepted);483 free( socket);484 async_msg_3( phone, NET_SOCKET_CLOSE, ( ipcarg_t ) socket_id, 0, service);488 ERROR_CODE = sockets_add(socket_get_sockets(), socket_id, socket); 489 fibril_rwlock_write_unlock(&socket_globals.lock); 490 if(ERROR_CODE < 0){ 491 dyn_fifo_destroy(&socket->received); 492 dyn_fifo_destroy(&socket->accepted); 493 free(socket); 494 async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0, service); 485 495 return ERROR_CODE; 486 496 } … … 489 499 } 490 500 491 int socket_send_data( int socket_id, ipcarg_t message, ipcarg_t arg2, const void * data, size_t datalength ){ 492 socket_ref socket; 493 aid_t message_id; 494 ipcarg_t result; 495 496 if( ! data ) return EBADMEM; 497 if( ! datalength ) return NO_DATA; 498 499 fibril_rwlock_read_lock( & socket_globals.lock ); 501 int socket_send_data(int socket_id, ipcarg_t message, ipcarg_t arg2, const void * data, size_t datalength){ 502 socket_ref socket; 503 aid_t message_id; 504 ipcarg_t result; 505 506 if(! data){ 507 return EBADMEM; 508 } 509 if(! datalength){ 510 return NO_DATA; 511 } 512 513 fibril_rwlock_read_lock(&socket_globals.lock); 500 514 // find the socket 501 socket = sockets_find( socket_get_sockets(), socket_id);502 if( ! socket){503 fibril_rwlock_read_unlock( & socket_globals.lock);515 socket = sockets_find(socket_get_sockets(), socket_id); 516 if(! socket){ 517 fibril_rwlock_read_unlock(&socket_globals.lock); 504 518 return ENOTSOCK; 505 519 } 506 520 // request the message 507 message_id = async_send_3( socket->phone, message, ( ipcarg_t ) socket->socket_id, arg2, socket->service, NULL);521 message_id = async_send_3(socket->phone, message, (ipcarg_t) socket->socket_id, arg2, socket->service, NULL); 508 522 // send the address 509 async_data_write_start( socket->phone, data, datalength ); 510 fibril_rwlock_read_unlock( & socket_globals.lock ); 511 async_wait_for( message_id, & result ); 512 return ( int ) result; 513 } 514 515 int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen ){ 516 if( addrlen <= 0 ) return EINVAL; 523 async_data_write_start(socket->phone, data, datalength); 524 fibril_rwlock_read_unlock(&socket_globals.lock); 525 async_wait_for(message_id, &result); 526 return (int) result; 527 } 528 529 int bind(int socket_id, const struct sockaddr * my_addr, socklen_t addrlen){ 530 if(addrlen <= 0){ 531 return EINVAL; 532 } 517 533 // send the address 518 return socket_send_data( socket_id, NET_SOCKET_BIND, 0, my_addr, ( size_t ) addrlen ); 519 } 520 521 int listen( int socket_id, int backlog ){ 522 socket_ref socket; 523 int result; 524 525 if( backlog <= 0 ) return EINVAL; 526 fibril_rwlock_read_lock( & socket_globals.lock ); 534 return socket_send_data(socket_id, NET_SOCKET_BIND, 0, my_addr, (size_t) addrlen); 535 } 536 537 int listen(int socket_id, int backlog){ 538 socket_ref socket; 539 int result; 540 541 if(backlog <= 0){ 542 return EINVAL; 543 } 544 fibril_rwlock_read_lock(&socket_globals.lock); 527 545 // find the socket 528 socket = sockets_find( socket_get_sockets(), socket_id);529 if( ! socket){530 fibril_rwlock_read_unlock( & socket_globals.lock);546 socket = sockets_find(socket_get_sockets(), socket_id); 547 if(! socket){ 548 fibril_rwlock_read_unlock(&socket_globals.lock); 531 549 return ENOTSOCK; 532 550 } 533 551 // request listen backlog change 534 result = ( int ) async_req_3_0( socket->phone, NET_SOCKET_LISTEN, ( ipcarg_t ) socket->socket_id, ( ipcarg_t ) backlog, socket->service);535 fibril_rwlock_read_unlock( & socket_globals.lock);552 result = (int) async_req_3_0(socket->phone, NET_SOCKET_LISTEN, (ipcarg_t) socket->socket_id, (ipcarg_t) backlog, socket->service); 553 fibril_rwlock_read_unlock(&socket_globals.lock); 536 554 return result; 537 555 } 538 556 539 int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen ){ 540 socket_ref socket; 541 socket_ref new_socket; 542 aid_t message_id; 543 ipcarg_t ipc_result; 544 int result; 545 ipc_call_t answer; 546 547 if(( ! cliaddr ) || ( ! addrlen )) return EBADMEM; 548 549 fibril_rwlock_write_lock( & socket_globals.lock ); 557 int accept(int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen){ 558 socket_ref socket; 559 socket_ref new_socket; 560 aid_t message_id; 561 ipcarg_t ipc_result; 562 int result; 563 ipc_call_t answer; 564 565 if((! cliaddr) || (! addrlen)){ 566 return EBADMEM; 567 } 568 569 fibril_rwlock_write_lock(&socket_globals.lock); 550 570 // find the socket 551 socket = sockets_find( socket_get_sockets(), socket_id);552 if( ! socket){553 fibril_rwlock_write_unlock( & socket_globals.lock);571 socket = sockets_find(socket_get_sockets(), socket_id); 572 if(! socket){ 573 fibril_rwlock_write_unlock(&socket_globals.lock); 554 574 return ENOTSOCK; 555 575 } 556 fibril_mutex_lock( & socket->accept_lock);576 fibril_mutex_lock(&socket->accept_lock); 557 577 // wait for an accepted socket 558 578 ++ socket->blocked; 559 while( dyn_fifo_value( & socket->accepted ) <= 0){560 fibril_rwlock_write_unlock( & socket_globals.lock);561 fibril_condvar_wait( & socket->accept_signal, & socket->accept_lock);562 fibril_rwlock_write_lock( & socket_globals.lock);579 while(dyn_fifo_value(&socket->accepted) <= 0){ 580 fibril_rwlock_write_unlock(&socket_globals.lock); 581 fibril_condvar_wait(&socket->accept_signal, &socket->accept_lock); 582 fibril_rwlock_write_lock(&socket_globals.lock); 563 583 } 564 584 -- socket->blocked; 565 585 566 586 // create a new scoket 567 new_socket = ( socket_ref ) malloc( sizeof( socket_t));568 if( ! new_socket){569 fibril_mutex_unlock( & socket->accept_lock);570 fibril_rwlock_write_unlock( & socket_globals.lock);587 new_socket = (socket_ref) malloc(sizeof(socket_t)); 588 if(! new_socket){ 589 fibril_mutex_unlock(&socket->accept_lock); 590 fibril_rwlock_write_unlock(&socket_globals.lock); 571 591 return ENOMEM; 572 592 } 573 bzero( new_socket, sizeof( * new_socket));593 bzero(new_socket, sizeof(*new_socket)); 574 594 socket_id = socket_generate_new_id(); 575 if( socket_id <= 0){576 fibril_mutex_unlock( & socket->accept_lock);577 fibril_rwlock_write_unlock( & socket_globals.lock);578 free( new_socket);595 if(socket_id <= 0){ 596 fibril_mutex_unlock(&socket->accept_lock); 597 fibril_rwlock_write_unlock(&socket_globals.lock); 598 free(new_socket); 579 599 return socket_id; 580 600 } 581 socket_initialize( new_socket, socket_id, socket->phone, socket->service);582 result = sockets_add( socket_get_sockets(), new_socket->socket_id, new_socket);583 if( result < 0){584 fibril_mutex_unlock( & socket->accept_lock);585 fibril_rwlock_write_unlock( & socket_globals.lock);586 free( new_socket);601 socket_initialize(new_socket, socket_id, socket->phone, socket->service); 602 result = sockets_add(socket_get_sockets(), new_socket->socket_id, new_socket); 603 if(result < 0){ 604 fibril_mutex_unlock(&socket->accept_lock); 605 fibril_rwlock_write_unlock(&socket_globals.lock); 606 free(new_socket); 587 607 return result; 588 608 } 589 609 590 610 // request accept 591 message_id = async_send_5( socket->phone, NET_SOCKET_ACCEPT, ( ipcarg_t ) socket->socket_id, 0, socket->service, 0, new_socket->socket_id, & answer);611 message_id = async_send_5(socket->phone, NET_SOCKET_ACCEPT, (ipcarg_t) socket->socket_id, 0, socket->service, 0, new_socket->socket_id, &answer); 592 612 // read address 593 ipc_data_read_start( socket->phone, cliaddr, * addrlen);594 fibril_rwlock_write_unlock( & socket_globals.lock);595 async_wait_for( message_id, & ipc_result);613 ipc_data_read_start(socket->phone, cliaddr, * addrlen); 614 fibril_rwlock_write_unlock(&socket_globals.lock); 615 async_wait_for(message_id, &ipc_result); 596 616 result = (int) ipc_result; 597 if( result > 0){598 if( result != socket_id){617 if(result > 0){ 618 if(result != socket_id){ 599 619 result = EINVAL; 600 620 } 601 621 // dequeue the accepted socket if successful 602 dyn_fifo_pop( & socket->accepted);622 dyn_fifo_pop(&socket->accepted); 603 623 // set address length 604 * addrlen = SOCKET_GET_ADDRESS_LENGTH( answer);605 new_socket->data_fragment_size = SOCKET_GET_DATA_FRAGMENT_SIZE( answer);606 }else if( result == ENOTSOCK){624 *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer); 625 new_socket->data_fragment_size = SOCKET_GET_DATA_FRAGMENT_SIZE(answer); 626 }else if(result == ENOTSOCK){ 607 627 // empty the queue if no accepted sockets 608 while( dyn_fifo_pop( & socket->accepted ) > 0);609 } 610 fibril_mutex_unlock( & socket->accept_lock);628 while(dyn_fifo_pop(&socket->accepted) > 0); 629 } 630 fibril_mutex_unlock(&socket->accept_lock); 611 631 return result; 612 632 } 613 633 614 int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen ){ 615 if( ! serv_addr ) return EDESTADDRREQ; 616 if( ! addrlen ) return EDESTADDRREQ; 634 int connect(int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen){ 635 if(! serv_addr){ 636 return EDESTADDRREQ; 637 } 638 if(! addrlen){ 639 return EDESTADDRREQ; 640 } 617 641 // send the address 618 return socket_send_data( socket_id, NET_SOCKET_CONNECT, 0, serv_addr, addrlen);619 } 620 621 int closesocket( int socket_id){642 return socket_send_data(socket_id, NET_SOCKET_CONNECT, 0, serv_addr, addrlen); 643 } 644 645 int closesocket(int socket_id){ 622 646 ERROR_DECLARE; 623 647 624 socket_ref 625 626 fibril_rwlock_write_lock( & socket_globals.lock);627 socket = sockets_find( socket_get_sockets(), socket_id);628 if( ! socket){629 fibril_rwlock_write_unlock( & socket_globals.lock);648 socket_ref socket; 649 650 fibril_rwlock_write_lock(&socket_globals.lock); 651 socket = sockets_find(socket_get_sockets(), socket_id); 652 if(! socket){ 653 fibril_rwlock_write_unlock(&socket_globals.lock); 630 654 return ENOTSOCK; 631 655 } 632 if( socket->blocked){633 fibril_rwlock_write_unlock( & socket_globals.lock);656 if(socket->blocked){ 657 fibril_rwlock_write_unlock(&socket_globals.lock); 634 658 return EINPROGRESS; 635 659 } 636 660 // request close 637 ERROR_PROPAGATE(( int ) async_req_3_0( socket->phone, NET_SOCKET_CLOSE, ( ipcarg_t ) socket->socket_id, 0, socket->service));661 ERROR_PROPAGATE((int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, (ipcarg_t) socket->socket_id, 0, socket->service)); 638 662 // free the socket structure 639 socket_destroy( socket);640 fibril_rwlock_write_unlock( & socket_globals.lock);663 socket_destroy(socket); 664 fibril_rwlock_write_unlock(&socket_globals.lock); 641 665 return EOK; 642 666 } 643 667 644 void socket_destroy( socket_ref socket){645 int 668 void socket_destroy(socket_ref socket){ 669 int accepted_id; 646 670 647 671 // destroy all accepted sockets 648 while(( accepted_id = dyn_fifo_pop( & socket->accepted )) >= 0){649 socket_destroy( sockets_find( socket_get_sockets(), accepted_id));650 } 651 dyn_fifo_destroy( & socket->received);652 dyn_fifo_destroy( & socket->accepted);653 sockets_exclude( socket_get_sockets(), socket->socket_id);654 } 655 656 int send( int socket_id, void * data, size_t datalength, int flags){672 while((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0){ 673 socket_destroy(sockets_find(socket_get_sockets(), accepted_id)); 674 } 675 dyn_fifo_destroy(&socket->received); 676 dyn_fifo_destroy(&socket->accepted); 677 sockets_exclude(socket_get_sockets(), socket->socket_id); 678 } 679 680 int send(int socket_id, void * data, size_t datalength, int flags){ 657 681 // without the address 658 return sendto_core( NET_SOCKET_SEND, socket_id, data, datalength, flags, NULL, 0 ); 659 } 660 661 int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen ){ 662 if( ! toaddr ) return EDESTADDRREQ; 663 if( ! addrlen ) return EDESTADDRREQ; 682 return sendto_core(NET_SOCKET_SEND, socket_id, data, datalength, flags, NULL, 0); 683 } 684 685 int sendto(int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen){ 686 if(! toaddr){ 687 return EDESTADDRREQ; 688 } 689 if(! addrlen){ 690 return EDESTADDRREQ; 691 } 664 692 // with the address 665 return sendto_core( NET_SOCKET_SENDTO, socket_id, data, datalength, flags, toaddr, addrlen ); 666 } 667 668 int sendto_core( ipcarg_t message, int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen ){ 669 socket_ref socket; 670 aid_t message_id; 671 ipcarg_t result; 672 size_t fragments; 673 ipc_call_t answer; 674 675 if( ! data ) return EBADMEM; 676 if( ! datalength ) return NO_DATA; 677 fibril_rwlock_read_lock( & socket_globals.lock ); 693 return sendto_core(NET_SOCKET_SENDTO, socket_id, data, datalength, flags, toaddr, addrlen); 694 } 695 696 int sendto_core(ipcarg_t message, int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen){ 697 socket_ref socket; 698 aid_t message_id; 699 ipcarg_t result; 700 size_t fragments; 701 ipc_call_t answer; 702 703 if(! data){ 704 return EBADMEM; 705 } 706 if(! datalength){ 707 return NO_DATA; 708 } 709 fibril_rwlock_read_lock(&socket_globals.lock); 678 710 // find socket 679 socket = sockets_find( socket_get_sockets(), socket_id);680 if( ! socket){681 fibril_rwlock_read_unlock( & socket_globals.lock);711 socket = sockets_find(socket_get_sockets(), socket_id); 712 if(! socket){ 713 fibril_rwlock_read_unlock(&socket_globals.lock); 682 714 return ENOTSOCK; 683 715 } 684 fibril_rwlock_read_lock( & socket->sending_lock);716 fibril_rwlock_read_lock(&socket->sending_lock); 685 717 // compute data fragment count 686 if( socket->data_fragment_size > 0){687 fragments = ( datalength + socket->header_size) / socket->data_fragment_size;688 if(( datalength + socket->header_size ) % socket->data_fragment_size) ++ fragments;718 if(socket->data_fragment_size > 0){ 719 fragments = (datalength + socket->header_size) / socket->data_fragment_size; 720 if((datalength + socket->header_size) % socket->data_fragment_size) ++ fragments; 689 721 }else{ 690 722 fragments = 1; 691 723 } 692 724 // request send 693 message_id = async_send_5( socket->phone, message, ( ipcarg_t ) socket->socket_id, ( fragments == 1 ? datalength : socket->data_fragment_size ), socket->service, ( ipcarg_t ) flags, fragments, & answer);725 message_id = async_send_5(socket->phone, message, (ipcarg_t) socket->socket_id, (fragments == 1 ? datalength : socket->data_fragment_size), socket->service, (ipcarg_t) flags, fragments, &answer); 694 726 // send the address if given 695 if(( ! toaddr ) || ( async_data_write_start( socket->phone, toaddr, addrlen ) == EOK)){696 if( fragments == 1){727 if((! toaddr) || (async_data_write_start(socket->phone, toaddr, addrlen) == EOK)){ 728 if(fragments == 1){ 697 729 // send all if only one fragment 698 async_data_write_start( socket->phone, data, datalength);730 async_data_write_start(socket->phone, data, datalength); 699 731 }else{ 700 732 // send the first fragment 701 async_data_write_start( socket->phone, data, socket->data_fragment_size - socket->header_size);702 data = (( const uint8_t * ) data) + socket->data_fragment_size - socket->header_size;733 async_data_write_start(socket->phone, data, socket->data_fragment_size - socket->header_size); 734 data = ((const uint8_t *) data) + socket->data_fragment_size - socket->header_size; 703 735 // send the middle fragments 704 while(( -- fragments ) > 1){705 async_data_write_start( socket->phone, data, socket->data_fragment_size);706 data = (( const uint8_t * ) data) + socket->data_fragment_size;736 while((-- fragments) > 1){ 737 async_data_write_start(socket->phone, data, socket->data_fragment_size); 738 data = ((const uint8_t *) data) + socket->data_fragment_size; 707 739 } 708 740 // send the last fragment 709 async_data_write_start( socket->phone, data, ( datalength + socket->header_size ) % socket->data_fragment_size);710 } 711 } 712 async_wait_for( message_id, & result);713 if(( SOCKET_GET_DATA_FRAGMENT_SIZE( answer ) > 0)714 && ( SOCKET_GET_DATA_FRAGMENT_SIZE( answer ) != socket->data_fragment_size)){741 async_data_write_start(socket->phone, data, (datalength + socket->header_size) % socket->data_fragment_size); 742 } 743 } 744 async_wait_for(message_id, &result); 745 if((SOCKET_GET_DATA_FRAGMENT_SIZE(answer) > 0) 746 && (SOCKET_GET_DATA_FRAGMENT_SIZE(answer) != socket->data_fragment_size)){ 715 747 // set the data fragment size 716 socket->data_fragment_size = SOCKET_GET_DATA_FRAGMENT_SIZE( answer);717 } 718 fibril_rwlock_read_unlock( & socket->sending_lock);719 fibril_rwlock_read_unlock( & socket_globals.lock);720 return ( int) result;721 } 722 723 int recv( int socket_id, void * data, size_t datalength, int flags){748 socket->data_fragment_size = SOCKET_GET_DATA_FRAGMENT_SIZE(answer); 749 } 750 fibril_rwlock_read_unlock(&socket->sending_lock); 751 fibril_rwlock_read_unlock(&socket_globals.lock); 752 return (int) result; 753 } 754 755 int recv(int socket_id, void * data, size_t datalength, int flags){ 724 756 // without the address 725 return recvfrom_core( NET_SOCKET_RECV, socket_id, data, datalength, flags, NULL, NULL ); 726 } 727 728 int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen ){ 729 if( ! fromaddr ) return EBADMEM; 730 if( ! addrlen ) return NO_DATA; 757 return recvfrom_core(NET_SOCKET_RECV, socket_id, data, datalength, flags, NULL, NULL); 758 } 759 760 int recvfrom(int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen){ 761 if(! fromaddr){ 762 return EBADMEM; 763 } 764 if(! addrlen){ 765 return NO_DATA; 766 } 731 767 // with the address 732 return recvfrom_core( NET_SOCKET_RECVFROM, socket_id, data, datalength, flags, fromaddr, addrlen ); 733 } 734 735 int recvfrom_core( ipcarg_t message, int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen ){ 736 socket_ref socket; 737 aid_t message_id; 738 ipcarg_t ipc_result; 739 int result; 740 size_t fragments; 741 size_t * lengths; 742 size_t index; 743 ipc_call_t answer; 744 745 if( ! data ) return EBADMEM; 746 if( ! datalength ) return NO_DATA; 747 if( fromaddr && ( ! addrlen )) return EINVAL; 748 fibril_rwlock_read_lock( & socket_globals.lock ); 768 return recvfrom_core(NET_SOCKET_RECVFROM, socket_id, data, datalength, flags, fromaddr, addrlen); 769 } 770 771 int recvfrom_core(ipcarg_t message, int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen){ 772 socket_ref socket; 773 aid_t message_id; 774 ipcarg_t ipc_result; 775 int result; 776 size_t fragments; 777 size_t * lengths; 778 size_t index; 779 ipc_call_t answer; 780 781 if(! data){ 782 return EBADMEM; 783 } 784 if(! datalength){ 785 return NO_DATA; 786 } 787 if(fromaddr && (! addrlen)){ 788 return EINVAL; 789 } 790 fibril_rwlock_read_lock(&socket_globals.lock); 749 791 // find the socket 750 socket = sockets_find( socket_get_sockets(), socket_id);751 if( ! socket){752 fibril_rwlock_read_unlock( & socket_globals.lock);792 socket = sockets_find(socket_get_sockets(), socket_id); 793 if(! socket){ 794 fibril_rwlock_read_unlock(&socket_globals.lock); 753 795 return ENOTSOCK; 754 796 } 755 fibril_mutex_lock( & socket->receive_lock);797 fibril_mutex_lock(&socket->receive_lock); 756 798 // wait for a received packet 757 799 ++ socket->blocked; 758 while(( result = dyn_fifo_value( & socket->received )) <= 0){759 fibril_rwlock_read_unlock( & socket_globals.lock);760 fibril_condvar_wait( & socket->receive_signal, & socket->receive_lock);761 fibril_rwlock_read_lock( & socket_globals.lock);800 while((result = dyn_fifo_value(&socket->received)) <= 0){ 801 fibril_rwlock_read_unlock(&socket_globals.lock); 802 fibril_condvar_wait(&socket->receive_signal, &socket->receive_lock); 803 fibril_rwlock_read_lock(&socket_globals.lock); 762 804 } 763 805 -- socket->blocked; 764 fragments = ( size_t) result;806 fragments = (size_t) result; 765 807 // prepare lengths if more fragments 766 if( fragments > 1){767 lengths = ( size_t * ) malloc( sizeof( size_t ) * fragments + sizeof( size_t));768 if( ! lengths){769 fibril_mutex_unlock( & socket->receive_lock);770 fibril_rwlock_read_unlock( & socket_globals.lock);808 if(fragments > 1){ 809 lengths = (size_t *) malloc(sizeof(size_t) * fragments + sizeof(size_t)); 810 if(! lengths){ 811 fibril_mutex_unlock(&socket->receive_lock); 812 fibril_rwlock_read_unlock(&socket_globals.lock); 771 813 return ENOMEM; 772 814 } 773 815 // request packet data 774 message_id = async_send_4( socket->phone, message, ( ipcarg_t ) socket->socket_id, 0, socket->service, ( ipcarg_t ) flags, & answer);816 message_id = async_send_4(socket->phone, message, (ipcarg_t) socket->socket_id, 0, socket->service, (ipcarg_t) flags, &answer); 775 817 // read the address if desired 776 if(( ! fromaddr ) || ( async_data_read_start( socket->phone, fromaddr, * addrlen ) == EOK)){818 if((! fromaddr) || (async_data_read_start(socket->phone, fromaddr, * addrlen) == EOK)){ 777 819 // read the fragment lengths 778 if( async_data_read_start( socket->phone, lengths, sizeof( int ) * ( fragments + 1 )) == EOK){779 if( lengths[ fragments ] <= datalength){820 if(async_data_read_start(socket->phone, lengths, sizeof(int) * (fragments + 1)) == EOK){ 821 if(lengths[fragments] <= datalength){ 780 822 // read all fragments if long enough 781 for( index = 0; index < fragments; ++ index){782 async_data_read_start( socket->phone, data, lengths[ index ]);783 data = (( uint8_t * ) data ) + lengths[ index];823 for(index = 0; index < fragments; ++ index){ 824 async_data_read_start(socket->phone, data, lengths[index]); 825 data = ((uint8_t *) data) + lengths[index]; 784 826 } 785 827 } 786 828 } 787 829 } 788 free( lengths);830 free(lengths); 789 831 }else{ 790 832 // request packet data 791 message_id = async_send_4( socket->phone, message, ( ipcarg_t ) socket->socket_id, 0, socket->service, ( ipcarg_t ) flags, & answer);833 message_id = async_send_4(socket->phone, message, (ipcarg_t) socket->socket_id, 0, socket->service, (ipcarg_t) flags, &answer); 792 834 // read the address if desired 793 if(( ! fromaddr ) || ( async_data_read_start( socket->phone, fromaddr, * addrlen ) == EOK)){835 if((! fromaddr) || (async_data_read_start(socket->phone, fromaddr, * addrlen) == EOK)){ 794 836 // read all if only one fragment 795 async_data_read_start( socket->phone, data, datalength);796 } 797 } 798 async_wait_for( message_id, & ipc_result);837 async_data_read_start(socket->phone, data, datalength); 838 } 839 } 840 async_wait_for(message_id, &ipc_result); 799 841 result = (int) ipc_result; 800 842 // if successful 801 if( result == EOK){843 if(result == EOK){ 802 844 // dequeue the received packet 803 dyn_fifo_pop( & socket->received);845 dyn_fifo_pop(&socket->received); 804 846 // return read data length 805 result = SOCKET_GET_READ_DATA_LENGTH( answer);847 result = SOCKET_GET_READ_DATA_LENGTH(answer); 806 848 // set address length 807 if( fromaddr && addrlen ) * addrlen = SOCKET_GET_ADDRESS_LENGTH( answer ); 808 } 809 fibril_mutex_unlock( & socket->receive_lock ); 810 fibril_rwlock_read_unlock( & socket_globals.lock ); 849 if(fromaddr && addrlen){ 850 *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer); 851 } 852 } 853 fibril_mutex_unlock(&socket->receive_lock); 854 fibril_rwlock_read_unlock(&socket_globals.lock); 811 855 return result; 812 856 } 813 857 814 int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen ){ 815 socket_ref socket; 816 aid_t message_id; 817 ipcarg_t result; 818 819 if( !( value && optlen )) return EBADMEM; 820 if( !( * optlen )) return NO_DATA; 821 fibril_rwlock_read_lock( & socket_globals.lock ); 858 int getsockopt(int socket_id, int level, int optname, void * value, size_t * optlen){ 859 socket_ref socket; 860 aid_t message_id; 861 ipcarg_t result; 862 863 if(!(value && optlen)){ 864 return EBADMEM; 865 } 866 if(!(*optlen)){ 867 return NO_DATA; 868 } 869 fibril_rwlock_read_lock(&socket_globals.lock); 822 870 // find the socket 823 socket = sockets_find( socket_get_sockets(), socket_id);824 if( ! socket){825 fibril_rwlock_read_unlock( & socket_globals.lock);871 socket = sockets_find(socket_get_sockets(), socket_id); 872 if(! socket){ 873 fibril_rwlock_read_unlock(&socket_globals.lock); 826 874 return ENOTSOCK; 827 875 } 828 876 // request option value 829 message_id = async_send_3( socket->phone, NET_SOCKET_GETSOCKOPT, ( ipcarg_t ) socket->socket_id, ( ipcarg_t ) optname, socket->service, NULL);877 message_id = async_send_3(socket->phone, NET_SOCKET_GETSOCKOPT, (ipcarg_t) socket->socket_id, (ipcarg_t) optname, socket->service, NULL); 830 878 // read the length 831 if( async_data_read_start( socket->phone, optlen, sizeof( * optlen )) == EOK){879 if(async_data_read_start(socket->phone, optlen, sizeof(*optlen)) == EOK){ 832 880 // read the value 833 async_data_read_start( socket->phone, value, * optlen);834 } 835 fibril_rwlock_read_unlock( & socket_globals.lock);836 async_wait_for( message_id, & result);837 return ( int) result;838 } 839 840 int setsockopt( int socket_id, int level, int optname, const void * value, size_t optlen){881 async_data_read_start(socket->phone, value, * optlen); 882 } 883 fibril_rwlock_read_unlock(&socket_globals.lock); 884 async_wait_for(message_id, &result); 885 return (int) result; 886 } 887 888 int setsockopt(int socket_id, int level, int optname, const void * value, size_t optlen){ 841 889 // send the value 842 return socket_send_data( socket_id, NET_SOCKET_SETSOCKOPT, ( ipcarg_t ) optname, value, optlen);890 return socket_send_data(socket_id, NET_SOCKET_SETSOCKOPT, (ipcarg_t) optname, value, optlen); 843 891 844 892 }
Note:
See TracChangeset
for help on using the changeset viewer.