Changeset 6b82009 in mainline for uspace/lib
- Timestamp:
- 2011-06-22T20:41:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef09a7a
- Parents:
- 55091847
- Location:
- uspace/lib
- Files:
-
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/measured_strings.c
r55091847 r6b82009 42 42 #include <errno.h> 43 43 #include <async.h> 44 #include <async_obsolete.h>45 44 46 45 /** Creates a new measured string bundled with a copy of the given string … … 298 297 * size has to be negotiated in advance. 299 298 * 300 * @param[in] phone The other module phone.299 * @param[in] exch Exchange. 301 300 * @param[out] strings The returned measured strings array. 302 301 * @param[out] data The measured strings data. This memory block stores the … … 305 304 * @return EOK on success. 306 305 * @return EINVAL if the strings or data parameter is NULL. 307 * @return EINVAL if the phone or count parameter is not positive.306 * @return EINVAL if the exch or count parameter is invalid. 308 307 * @return EINVAL if the sent array differs in size. 309 308 * @return ENOMEM if there is not enough memory left. … … 311 310 * async_data_read_start() function. 312 311 */ 313 int 314 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data, 315 size_t count) 312 int measured_strings_return(async_exch_t *exch, measured_string_t **strings, 313 uint8_t **data, size_t count) 316 314 { 317 315 size_t *lengths; … … 320 318 int rc; 321 319 322 if (( phone < 0) || (!strings) || (!data) || (count <= 0))320 if ((exch == NULL) || (!strings) || (!data) || (count <= 0)) 323 321 return EINVAL; 324 322 … … 327 325 return ENOMEM; 328 326 329 rc = async_ obsolete_data_read_start(phone, lengths,327 rc = async_data_read_start(exch, lengths, 330 328 sizeof(size_t) * (count + 1)); 331 329 if (rc != EOK) { … … 352 350 (*strings)[index].length = lengths[index]; 353 351 if (lengths[index] > 0) { 354 rc = async_ obsolete_data_read_start(phone, next, lengths[index]);352 rc = async_data_read_start(exch, next, lengths[index]); 355 353 if (rc != EOK) { 356 354 free(lengths); … … 376 374 * size has to be negotiated in advance. 377 375 * 378 * @param[in] phone The other module phone.376 * @param[in] exch Exchange. 379 377 * @param[in] strings The measured strings array to be transferred. 380 378 * @param[in] count The measured strings array size. 381 379 * @return EOK on success. 382 380 * @return EINVAL if the strings parameter is NULL. 383 * @return EINVAL if the phone or count parameter is not positive.381 * @return EINVAL if the exch or count parameter is invalid. 384 382 * @return Other error codes as defined for the 385 383 * async_data_write_start() function. 386 384 */ 387 int 388 measured_strings_send(int phone, const measured_string_t *strings, 385 int measured_strings_send(async_exch_t *exch, const measured_string_t *strings, 389 386 size_t count) 390 387 { … … 393 390 int rc; 394 391 395 if (( phone < 0) || (!strings) || (count <= 0))392 if ((exch == NULL) || (!strings) || (count <= 0)) 396 393 return EINVAL; 397 394 … … 400 397 return ENOMEM; 401 398 402 rc = async_ obsolete_data_write_start(phone, lengths,399 rc = async_data_write_start(exch, lengths, 403 400 sizeof(size_t) * (count + 1)); 404 401 if (rc != EOK) { … … 411 408 for (index = 0; index < count; index++) { 412 409 if (strings[index].length > 0) { 413 rc = async_ obsolete_data_write_start(phone, strings[index].value,410 rc = async_data_write_start(exch, strings[index].value, 414 411 strings[index].length); 415 412 if (rc != EOK) … … 423 420 /** @} 424 421 */ 425 -
uspace/lib/c/generic/net/icmp_api.c
r55091847 r6b82009 42 42 #include <net/ip_codes.h> 43 43 #include <async.h> 44 #include <async_obsolete.h>45 44 #include <sys/types.h> 46 45 #include <sys/time.h> … … 55 54 * timeout occurs. 56 55 * 57 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.56 * @param[in] sess The ICMP session. 58 57 * @param[in] size The message data length in bytes. 59 58 * @param[in] timeout The timeout in milliseconds. … … 74 73 */ 75 74 int 76 icmp_echo_msg( int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl,75 icmp_echo_msg(async_sess_t *sess, size_t size, mseconds_t timeout, ip_ttl_t ttl, 77 76 ip_tos_t tos, int dont_fragment, const struct sockaddr *addr, 78 77 socklen_t addrlen) … … 83 82 if (addrlen <= 0) 84 83 return EINVAL; 85 86 message_id = async_obsolete_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, 84 85 async_exch_t *exch = async_exchange_begin(sess); 86 87 message_id = async_send_5(exch, NET_ICMP_ECHO, size, timeout, ttl, 87 88 tos, (sysarg_t) dont_fragment, NULL); 88 89 89 90 /* Send the address */ 90 async_obsolete_data_write_start(icmp_phone, addr, (size_t) addrlen); 91 async_data_write_start(exch, addr, (size_t) addrlen); 92 93 async_exchange_end(exch); 91 94 92 95 async_wait_for(message_id, &result); -
uspace/lib/c/generic/net/icmp_common.c
r55091847 r6b82009 45 45 /** Connect to the ICMP module. 46 46 * 47 * @return ICMP module phone on success.47 * @return ICMP module session. 48 48 * 49 49 */ 50 inticmp_connect_module(void)50 async_sess_t *icmp_connect_module(void) 51 51 { 52 52 return connect_to_service(SERVICE_ICMP); -
uspace/lib/c/generic/net/modules.c
r55091847 r6b82009 40 40 41 41 #include <async.h> 42 #include <async_obsolete.h>43 42 #include <malloc.h> 44 43 #include <errno.h> … … 47 46 #include <net/modules.h> 48 47 #include <ns.h> 49 #include <ns_obsolete.h>50 51 /** The time between connect requests in microseconds. */52 #define MODULE_WAIT_TIME (10 * 1000)53 48 54 49 /** Answer a call. … … 98 93 } 99 94 100 /** Create bidirectional connection with the needed module service and register s95 /** Create bidirectional connection with the needed module service and register 101 96 * the message receiver. 102 97 * 103 * @param[in] need The needed module service. 104 * @param[in] arg1 The first parameter. 105 * @param[in] arg2 The second parameter. 106 * @param[in] arg3 The third parameter. 107 * @param[in] client_receiver The message receiver. 108 * 109 * @return The phone of the needed service. 110 * @return Other error codes as defined for the ipc_connect_to_me() 111 * function. 112 */ 113 int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 114 async_client_conn_t client_receiver) 98 * @param[in] need Needed module service. 99 * @param[in] arg1 First parameter. 100 * @param[in] arg2 Second parameter. 101 * @param[in] arg3 Third parameter. 102 * @param[in] client_receiver Message receiver. 103 * 104 * @return Session to the needed service. 105 * @return Other error codes as defined for the async_connect_to_me() 106 * function. 107 * 108 */ 109 async_sess_t *bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, 110 sysarg_t arg3, async_client_conn_t client_receiver) 115 111 { 116 112 /* Connect to the needed service */ 117 int phone= connect_to_service(need);118 if ( phone >= 0) {113 async_sess_t *sess = connect_to_service(need); 114 if (sess != NULL) { 119 115 /* Request the bidirectional connection */ 120 int rc = async_obsolete_connect_to_me(phone, arg1, arg2, arg3, 116 async_exch_t *exch = async_exchange_begin(sess); 117 int rc = async_connect_to_me(exch, arg1, arg2, arg3, 121 118 client_receiver, NULL); 119 async_exchange_end(exch); 120 122 121 if (rc != EOK) { 123 async_obsolete_hangup(phone); 124 return rc; 122 async_hangup(sess); 123 errno = rc; 124 return NULL; 125 125 } 126 126 } 127 127 128 return phone; 129 } 130 131 /** Connects to the needed module. 132 * 133 * @param[in] need The needed module service. 134 * @return The phone of the needed service. 135 */ 136 int connect_to_service(services_t need) 137 { 138 return service_obsolete_connect_blocking(need, 0, 0); 139 } 140 141 /** Replies the data to the other party. 142 * 143 * @param[in] data The data buffer to be sent. 128 return sess; 129 } 130 131 /** Connect to the needed module. 132 * 133 * @param[in] need Needed module service. 134 * 135 * @return Session to the needed service. 136 * @return NULL if the connection timeouted. 137 * 138 */ 139 async_sess_t *connect_to_service(services_t need) 140 { 141 return service_connect_blocking(EXCHANGE_SERIALIZE, need, 0, 0); 142 } 143 144 /** Reply the data to the other party. 145 * 146 * @param[in] data The data buffer to be sent. 144 147 * @param[in] data_length The buffer length. 145 * @return EOK on success. 146 * @return EINVAL if the client does not expect the data. 147 * @return EOVERFLOW if the client does not expect all the data. 148 * Only partial data are transfered. 149 * @return Other error codes as defined for the 150 * async_data_read_finalize() function. 148 * 149 * @return EOK on success. 150 * @return EINVAL if the client does not expect the data. 151 * @return EOVERFLOW if the client does not expect all the data. 152 * Only partial data are transfered. 153 * @return Other error codes as defined for the 154 * async_data_read_finalize() function. 155 * 151 156 */ 152 157 int data_reply(void *data, size_t data_length) … … 154 159 size_t length; 155 160 ipc_callid_t callid; 156 161 157 162 /* Fetch the request */ 158 163 if (!async_data_read_receive(&callid, &length)) 159 164 return EINVAL; 160 165 161 166 /* Check the requested data size */ 162 167 if (length < data_length) { … … 164 169 return EOVERFLOW; 165 170 } 166 171 167 172 /* Send the data */ 168 173 return async_data_read_finalize(callid, data, data_length); -
uspace/lib/c/generic/net/socket_client.c
r55091847 r6b82009 39 39 #include <assert.h> 40 40 #include <async.h> 41 #include <async_obsolete.h>42 41 #include <fibril_synch.h> 43 42 #include <stdint.h> … … 84 83 /** Socket identifier. */ 85 84 int socket_id; 86 /** Parent module phone. */87 int phone;85 /** Parent module session. */ 86 async_sess_t *sess; 88 87 /** Parent module service. */ 89 88 services_t service; … … 144 143 /** Socket client library global data. */ 145 144 static struct socket_client_globals { 146 /** TCP module phone. */ 147 int tcp_phone; 148 /** UDP module phone. */ 149 int udp_phone; 150 151 // /** The last socket identifier. 152 // */ 153 // int last_id; 145 /** TCP module session. */ 146 async_sess_t *tcp_sess; 147 /** UDP module session. */ 148 async_sess_t *udp_sess; 154 149 155 150 /** Active sockets. */ … … 164 159 fibril_rwlock_t lock; 165 160 } socket_globals = { 166 .tcp_phone = -1, 167 .udp_phone = -1, 168 // .last_id = 0, 161 .tcp_sess = NULL, 162 .udp_sess = NULL, 169 163 .sockets = NULL, 170 164 .lock = FIBRIL_RWLOCK_INITIALIZER(socket_globals.lock) … … 280 274 } 281 275 282 /** Returns the TCP module phone. 283 * 284 * Connects to the TCP module if necessary. 285 * 286 * @return The TCP module phone. 287 * @return Other error codes as defined for the 288 * bind_service() function. 289 */ 290 static int socket_get_tcp_phone(void) 291 { 292 if (socket_globals.tcp_phone < 0) { 293 socket_globals.tcp_phone = bind_service(SERVICE_TCP, 276 /** Return the TCP module session. 277 * 278 * Connect to the TCP module if necessary. 279 * 280 * @return The TCP module session. 281 * 282 */ 283 static async_sess_t *socket_get_tcp_sess(void) 284 { 285 if (socket_globals.tcp_sess == NULL) { 286 socket_globals.tcp_sess = bind_service(SERVICE_TCP, 294 287 0, 0, SERVICE_TCP, socket_connection); 295 288 } 296 289 297 return socket_globals.tcp_phone; 298 } 299 300 /** Returns the UDP module phone. 301 * 302 * Connects to the UDP module if necessary. 303 * 304 * @return The UDP module phone. 305 * @return Other error codes as defined for the 306 * bind_service() function. 307 */ 308 static int socket_get_udp_phone(void) 309 { 310 if (socket_globals.udp_phone < 0) { 311 socket_globals.udp_phone = bind_service(SERVICE_UDP, 290 return socket_globals.tcp_sess; 291 } 292 293 /** Return the UDP module session. 294 * 295 * Connect to the UDP module if necessary. 296 * 297 * @return The UDP module session. 298 * 299 */ 300 static async_sess_t *socket_get_udp_sess(void) 301 { 302 if (socket_globals.udp_sess == NULL) { 303 socket_globals.udp_sess = bind_service(SERVICE_UDP, 312 304 0, 0, SERVICE_UDP, socket_connection); 313 305 } 314 306 315 return socket_globals.udp_ phone;307 return socket_globals.udp_sess; 316 308 } 317 309 … … 329 321 sockets = socket_get_sockets(); 330 322 count = 0; 331 // socket_id = socket_globals.last_id;332 323 333 324 do { … … 342 333 if (socket_id < INT_MAX) { 343 334 ++socket_id; 344 /* } else if(socket_globals.last_id) { 345 * socket_globals.last_id = 0; 346 * socket_id = 1; 347 */ } else { 335 } else { 348 336 return ELIMIT; 349 337 } 350 338 } 351 339 } while (sockets_find(sockets, socket_id)); 352 353 // last_id = socket_id 340 354 341 return socket_id; 355 342 } … … 358 345 * 359 346 * @param[in,out] socket The socket to be initialized. 360 * @param[in] socket_id The new socket identifier. 361 * @param[in] phone The parent module phone. 362 * @param[in] service The parent module service. 363 */ 364 static void 365 socket_initialize(socket_t *socket, int socket_id, int phone, 366 services_t service) 347 * @param[in] socket_id The new socket identifier. 348 * @param[in] sess The parent module session. 349 * @param[in] service The parent module service. 350 */ 351 static void socket_initialize(socket_t *socket, int socket_id, 352 async_sess_t *sess, services_t service) 367 353 { 368 354 socket->socket_id = socket_id; 369 socket-> phone = phone;355 socket->sess = sess; 370 356 socket->service = service; 371 357 dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); … … 397 383 { 398 384 socket_t *socket; 399 int phone;385 async_sess_t *sess; 400 386 int socket_id; 401 387 services_t service; … … 414 400 switch (protocol) { 415 401 case IPPROTO_TCP: 416 phone = socket_get_tcp_phone();402 sess = socket_get_tcp_sess(); 417 403 service = SERVICE_TCP; 418 404 break; … … 429 415 switch (protocol) { 430 416 case IPPROTO_UDP: 431 phone = socket_get_udp_phone();417 sess = socket_get_udp_sess(); 432 418 service = SERVICE_UDP; 433 419 break; … … 450 436 } 451 437 452 if ( phone < 0)453 return phone;438 if (sess == NULL) 439 return ENOENT; 454 440 455 441 /* Create a new socket structure */ … … 468 454 return socket_id; 469 455 } 470 471 rc = (int) async_obsolete_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 456 457 async_exch_t *exch = async_exchange_begin(sess); 458 rc = (int) async_req_3_3(exch, NET_SOCKET, socket_id, 0, service, NULL, 472 459 &fragment_size, &header_size); 460 async_exchange_end(exch); 461 473 462 if (rc != EOK) { 474 463 fibril_rwlock_write_unlock(&socket_globals.lock); … … 481 470 482 471 /* Finish the new socket initialization */ 483 socket_initialize(socket, socket_id, phone, service);472 socket_initialize(socket, socket_id, sess, service); 484 473 /* Store the new socket */ 485 474 rc = sockets_add(socket_get_sockets(), socket_id, socket); … … 490 479 dyn_fifo_destroy(&socket->accepted); 491 480 free(socket); 492 async_obsolete_msg_3(phone, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0, 481 482 exch = async_exchange_begin(sess); 483 async_msg_3(exch, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0, 493 484 service); 485 async_exchange_end(exch); 486 494 487 return rc; 495 488 } … … 535 528 536 529 /* Request the message */ 537 message_id = async_obsolete_send_3(socket->phone, message, 530 async_exch_t *exch = async_exchange_begin(socket->sess); 531 message_id = async_send_3(exch, message, 538 532 (sysarg_t) socket->socket_id, arg2, socket->service, NULL); 539 533 /* Send the address */ 540 async_obsolete_data_write_start(socket->phone, data, datalength); 534 async_data_write_start(exch, data, datalength); 535 async_exchange_end(exch); 541 536 542 537 fibril_rwlock_read_unlock(&socket_globals.lock); … … 595 590 596 591 /* Request listen backlog change */ 597 result = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_LISTEN, 592 async_exch_t *exch = async_exchange_begin(socket->sess); 593 result = (int) async_req_3_0(exch, NET_SOCKET_LISTEN, 598 594 (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service); 595 async_exchange_end(exch); 599 596 600 597 fibril_rwlock_read_unlock(&socket_globals.lock); … … 666 663 return socket_id; 667 664 } 668 socket_initialize(new_socket, socket_id, socket-> phone,665 socket_initialize(new_socket, socket_id, socket->sess, 669 666 socket->service); 670 667 result = sockets_add(socket_get_sockets(), new_socket->socket_id, … … 678 675 679 676 /* Request accept */ 680 message_id = async_obsolete_send_5(socket->phone, NET_SOCKET_ACCEPT, 677 async_exch_t *exch = async_exchange_begin(socket->sess); 678 message_id = async_send_5(exch, NET_SOCKET_ACCEPT, 681 679 (sysarg_t) socket->socket_id, 0, socket->service, 0, 682 680 new_socket->socket_id, &answer); 683 681 684 682 /* Read address */ 685 async_obsolete_data_read_start(socket->phone, cliaddr, *addrlen); 683 async_data_read_start(exch, cliaddr, *addrlen); 684 async_exchange_end(exch); 685 686 686 fibril_rwlock_write_unlock(&socket_globals.lock); 687 687 async_wait_for(message_id, &ipc_result); … … 777 777 778 778 /* Request close */ 779 rc = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_CLOSE, 779 async_exch_t *exch = async_exchange_begin(socket->sess); 780 rc = (int) async_req_3_0(exch, NET_SOCKET_CLOSE, 780 781 (sysarg_t) socket->socket_id, 0, socket->service); 782 async_exchange_end(exch); 783 781 784 if (rc != EOK) { 782 785 fibril_rwlock_write_unlock(&socket_globals.lock); … … 850 853 851 854 /* Request send */ 852 message_id = async_obsolete_send_5(socket->phone, message, 855 async_exch_t *exch = async_exchange_begin(socket->sess); 856 857 message_id = async_send_5(exch, message, 853 858 (sysarg_t) socket->socket_id, 854 859 (fragments == 1 ? datalength : socket->data_fragment_size), … … 857 862 /* Send the address if given */ 858 863 if (!toaddr || 859 (async_ obsolete_data_write_start(socket->phone, toaddr, addrlen) == EOK)) {864 (async_data_write_start(exch, toaddr, addrlen) == EOK)) { 860 865 if (fragments == 1) { 861 866 /* Send all if only one fragment */ 862 async_ obsolete_data_write_start(socket->phone, data, datalength);867 async_data_write_start(exch, data, datalength); 863 868 } else { 864 869 /* Send the first fragment */ 865 async_ obsolete_data_write_start(socket->phone, data,870 async_data_write_start(exch, data, 866 871 socket->data_fragment_size - socket->header_size); 867 872 data = ((const uint8_t *) data) + … … 870 875 /* Send the middle fragments */ 871 876 while (--fragments > 1) { 872 async_ obsolete_data_write_start(socket->phone, data,877 async_data_write_start(exch, data, 873 878 socket->data_fragment_size); 874 879 data = ((const uint8_t *) data) + … … 877 882 878 883 /* Send the last fragment */ 879 async_ obsolete_data_write_start(socket->phone, data,884 async_data_write_start(exch, data, 880 885 (datalength + socket->header_size) % 881 886 socket->data_fragment_size); 882 887 } 883 888 } 889 890 async_exchange_end(exch); 884 891 885 892 async_wait_for(message_id, &result); … … 1023 1030 return 0; 1024 1031 } 1032 1033 async_exch_t *exch = async_exchange_begin(socket->sess); 1025 1034 1026 1035 /* Prepare lengths if more fragments */ … … 1035 1044 1036 1045 /* Request packet data */ 1037 message_id = async_ obsolete_send_4(socket->phone, message,1046 message_id = async_send_4(exch, message, 1038 1047 (sysarg_t) socket->socket_id, 0, socket->service, 1039 1048 (sysarg_t) flags, &answer); … … 1041 1050 /* Read the address if desired */ 1042 1051 if(!fromaddr || 1043 (async_ obsolete_data_read_start(socket->phone, fromaddr,1052 (async_data_read_start(exch, fromaddr, 1044 1053 *addrlen) == EOK)) { 1045 1054 /* Read the fragment lengths */ 1046 if (async_ obsolete_data_read_start(socket->phone, lengths,1055 if (async_data_read_start(exch, lengths, 1047 1056 sizeof(int) * (fragments + 1)) == EOK) { 1048 1057 if (lengths[fragments] <= datalength) { … … 1051 1060 for (index = 0; index < fragments; 1052 1061 ++index) { 1053 async_obsolete_data_read_start( 1054 socket->phone, data, 1062 async_data_read_start(exch, data, 1055 1063 lengths[index]); 1056 1064 data = ((uint8_t *) data) + … … 1064 1072 } else { /* fragments == 1 */ 1065 1073 /* Request packet data */ 1066 message_id = async_ obsolete_send_4(socket->phone, message,1074 message_id = async_send_4(exch, message, 1067 1075 (sysarg_t) socket->socket_id, 0, socket->service, 1068 1076 (sysarg_t) flags, &answer); … … 1070 1078 /* Read the address if desired */ 1071 1079 if (!fromaddr || 1072 (async_obsolete_data_read_start(socket->phone, fromaddr, 1073 *addrlen) == EOK)) { 1080 (async_data_read_start(exch, fromaddr, *addrlen) == EOK)) { 1074 1081 /* Read all if only one fragment */ 1075 async_ obsolete_data_read_start(socket->phone, data, datalength);1082 async_data_read_start(exch, data, datalength); 1076 1083 } 1077 1084 } 1085 1086 async_exchange_end(exch); 1078 1087 1079 1088 async_wait_for(message_id, &ipc_result); … … 1187 1196 1188 1197 /* Request option value */ 1189 message_id = async_obsolete_send_3(socket->phone, NET_SOCKET_GETSOCKOPT, 1198 async_exch_t *exch = async_exchange_begin(socket->sess); 1199 1200 message_id = async_send_3(exch, NET_SOCKET_GETSOCKOPT, 1190 1201 (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service, 1191 1202 NULL); 1192 1203 1193 1204 /* Read the length */ 1194 if (async_ obsolete_data_read_start(socket->phone, optlen,1205 if (async_data_read_start(exch, optlen, 1195 1206 sizeof(*optlen)) == EOK) { 1196 1207 /* Read the value */ 1197 async_obsolete_data_read_start(socket->phone, value, *optlen); 1198 } 1208 async_data_read_start(exch, value, *optlen); 1209 } 1210 1211 async_exchange_end(exch); 1199 1212 1200 1213 fibril_rwlock_read_unlock(&socket_globals.lock); -
uspace/lib/c/include/adt/measured_strings.h
r55091847 r6b82009 41 41 42 42 #include <sys/types.h> 43 #include <async.h> 43 44 44 45 /** Type definition of the character string with measured length. … … 64 65 extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t); 65 66 extern int measured_strings_reply(const measured_string_t *, size_t); 66 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t); 67 extern int measured_strings_send(int, const measured_string_t *, size_t); 67 68 extern int measured_strings_return(async_exch_t *, measured_string_t **, 69 uint8_t **, size_t); 70 extern int measured_strings_send(async_exch_t *, const measured_string_t *, 71 size_t); 68 72 69 73 #endif -
uspace/lib/c/include/ipc/net.h
r55091847 r6b82009 335 335 #define IPC_GET_ERROR(call) ((services_t) IPC_GET_ARG4(call)) 336 336 337 /** Return the phone message argument.338 *339 * @param[in] call Message call structure.340 *341 */342 #define IPC_GET_PHONE(call) ((int) IPC_GET_ARG5(call))343 344 337 /** Set the device identifier in the message answer. 345 338 * -
uspace/lib/c/include/net/icmp_api.h
r55091847 r6b82009 42 42 #include <sys/types.h> 43 43 #include <sys/time.h> 44 45 44 #include <adt/measured_strings.h> 46 45 #include <net/ip_codes.h> 47 46 #include <net/icmp_codes.h> 48 47 #include <net/icmp_common.h> 48 #include <async.h> 49 49 50 50 /** @name ICMP module application interface … … 53 53 /*@{*/ 54 54 55 extern int icmp_echo_msg( int, size_t, mseconds_t, ip_ttl_t, ip_tos_t, int,56 const struct sockaddr *, socklen_t);55 extern int icmp_echo_msg(async_sess_t *, size_t, mseconds_t, ip_ttl_t, ip_tos_t, 56 int, const struct sockaddr *, socklen_t); 57 57 58 58 /*@}*/ -
uspace/lib/c/include/net/icmp_common.h
r55091847 r6b82009 40 40 #include <ipc/services.h> 41 41 #include <sys/time.h> 42 #include <async.h> 42 43 43 extern inticmp_connect_module(void);44 extern async_sess_t *icmp_connect_module(void); 44 45 45 46 #endif -
uspace/lib/c/include/net/modules.h
r55091847 r6b82009 46 46 #include <sys/time.h> 47 47 48 /** Connect to the neededmodule function type definition.48 /** Connect to module function type definition. 49 49 * 50 * @param[in] need The needed module service. 51 * 52 * @return The phone of the needed service. 50 * @return Session to the service. 53 51 * 54 52 */ 55 typedef int connect_module_t(services_t need);53 typedef async_sess_t *connect_module_t(services_t); 56 54 57 55 extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t); 58 extern intbind_service(services_t, sysarg_t, sysarg_t, sysarg_t,56 extern async_sess_t *bind_service(services_t, sysarg_t, sysarg_t, sysarg_t, 59 57 async_client_conn_t); 60 extern intconnect_to_service(services_t);58 extern async_sess_t *connect_to_service(services_t); 61 59 extern int data_reply(void *, size_t); 62 60 extern void refresh_answer(ipc_call_t *, size_t *); -
uspace/lib/net/adt/module_map.c
r55091847 r6b82009 39 39 #include <unistd.h> 40 40 #include <errno.h> 41 42 #include <ipc/services.h>43 44 41 #include <net/modules.h> 45 46 42 #include <adt/generic_char_map.h> 47 43 #include <adt/module_map.h> … … 49 45 GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t) 50 46 51 /** Add smodule to the module map.47 /** Add module to the module map. 52 48 * 53 * @param[out] module The module structure added. 54 * @param[in] modules The module map. 55 * @param[in] name The module name. 56 * @param[in] filename The full path filename. 57 * @param[in] service The module service. 58 * @param[in] task_id The module current task identifier. Zero means not 59 * running. 60 * @param[in] connect_module The module connecting function. 61 * @return EOK on success. 62 * @return ENOMEM if there is not enough memory left. 49 * @param[out] module Module structure added. 50 * @param[in] modules Module map. 51 * @param[in] name Module name. 52 * @param[in] filename Full path filename. 53 * @param[in] service Module service. 54 * @param[in] task_id Module current task identifier. 55 * Zero means not running. 56 * @param[in] connect_module Module connecting function. 57 * 58 * @return EOK on success. 59 * @return ENOMEM if there is not enough memory left. 60 * 63 61 */ 64 int 65 add_module(module_t **module, modules_t *modules, const uint8_t *name, 62 int add_module(module_t **module, modules_t *modules, const uint8_t *name, 66 63 const uint8_t *filename, services_t service, task_id_t task_id, 67 64 connect_module_t connect_module) … … 69 66 module_t *tmp_module; 70 67 int rc; 71 68 72 69 tmp_module = (module_t *) malloc(sizeof(module_t)); 73 70 if (!tmp_module) 74 71 return ENOMEM; 75 72 76 73 tmp_module->task_id = task_id; 77 tmp_module-> phone = 0;74 tmp_module->sess = NULL; 78 75 tmp_module->usage = 0; 79 76 tmp_module->name = name; … … 81 78 tmp_module->service = service; 82 79 tmp_module->connect_module = connect_module; 83 80 84 81 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 85 82 if (rc != EOK) { … … 87 84 return rc; 88 85 } 86 89 87 if (module) 90 88 *module = tmp_module; 91 89 92 90 return EOK; 93 91 } 94 92 95 /** Search es and returnsthe specified module.93 /** Search and return the specified module. 96 94 * 97 95 * If the module is not running, the module filaname is spawned. 98 96 * If the module is not connected, the connect_function is called. 99 97 * 100 * @param[in] modules The module map. 101 * @param[in] name The module name. 102 * @return The running module found. It does not have to be 103 * connected. 104 * @return NULL if there is no such module. 98 * @param[in] modules Module map. 99 * @param[in] name Module name. 100 * 101 * @return The running module found. It does not have to be 102 * connected. 103 * @return NULL if there is no such module. 104 * 105 105 */ 106 106 module_t *get_running_module(modules_t *modules, uint8_t *name) 107 107 { 108 module_t *module; 109 110 module = modules_find(modules, name, 0); 108 module_t *module = modules_find(modules, name, 0); 111 109 if (!module) 112 110 return NULL; 113 111 114 112 if (!module->task_id) { 115 113 module->task_id = net_spawn(module->filename); … … 117 115 return NULL; 118 116 } 119 if (!module->phone) 120 module->phone = module->connect_module(module->service); 121 117 118 if (!module->sess) 119 module->sess = module->connect_module(module->service); 120 122 121 return module; 123 122 } -
uspace/lib/net/generic/generic.c
r55091847 r6b82009 37 37 #include <generic.h> 38 38 #include <async.h> 39 #include <async_obsolete.h>40 39 #include <ipc/services.h> 41 40 #include <net/device.h> … … 45 44 /** Notify the module about the device state change. 46 45 * 47 * @param[in] phone The service module phone. 48 * @param[in] message The service specific message. 49 * @param[in] device_id The device identifier. 50 * @param[in] state The new device state. 51 * @param[in] target The target module service. 52 * @return EOK on success. 53 * 54 */ 55 int 56 generic_device_state_msg_remote(int phone, int message, device_id_t device_id, 57 int state, services_t target) 58 { 59 async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id, 60 (sysarg_t) state, target); 46 * @param[in] sess Service module session. 47 * @param[in] message Service specific message. 48 * @param[in] device_id Device identifier. 49 * @param[in] state New device state. 50 * @param[in] target Target module service. 51 * 52 * @return EOK on success. 53 * 54 */ 55 int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message, 56 device_id_t device_id, sysarg_t state, services_t target) 57 { 58 async_exch_t *exch = async_exchange_begin(sess); 59 async_msg_3(exch, message, (sysarg_t) device_id, state, target); 60 async_exchange_end(exch); 61 61 62 62 return EOK; … … 65 65 /** Notify a module about the device. 66 66 * 67 * @param[in] phone The service module phone. 68 * @param[in] message The service specific message. 69 * @param[in] device_id The device identifier. 70 * @param[in] arg2 The second argument of the message. 71 * @param[in] service The device module service. 72 * @return EOK on success. 73 * @return Other error codes as defined for the specific service 74 * message. 75 * 76 */ 77 int 78 generic_device_req_remote(int phone, int message, device_id_t device_id, 79 int arg2, services_t service) 80 { 81 return (int) async_obsolete_req_3_0(phone, (sysarg_t) message, 82 (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service); 67 * @param[in] sess Service module session. 68 * @param[in] message Service specific message. 69 * @param[in] device_id Device identifier. 70 * @param[in] arg2 Second argument of the message. 71 * @param[in] service Device module service. 72 * 73 * @return EOK on success. 74 * @return Other error codes as defined for the specific service 75 * message. 76 * 77 */ 78 int generic_device_req_remote(async_sess_t *sess, sysarg_t message, 79 device_id_t device_id, sysarg_t arg2, services_t service) 80 { 81 async_exch_t *exch = async_exchange_begin(sess); 82 int rc = async_req_3_0(exch, message, (sysarg_t) device_id, 83 arg2, (sysarg_t) service); 84 async_exchange_end(exch); 85 86 return rc; 83 87 } 84 88 85 89 /** Returns the address. 86 90 * 87 * @param[in] phone The service module phone. 88 * @param[in] message The service specific message. 89 * @param[in] device_id The device identifier. 90 * @param[out] address The desired address. 91 * @param[out] data The address data container. 92 * @return EOK on success. 93 * @return EBADMEM if the address parameter and/or the data 94 * parameter is NULL. 95 * @return Other error codes as defined for the specific service 96 * message. 97 */ 98 int 99 generic_get_addr_req(int phone, int message, device_id_t device_id, 100 measured_string_t **address, uint8_t **data) 101 { 102 aid_t message_id; 91 * @param[in] sess Service module session. 92 * @param[in] message Service specific message. 93 * @param[in] device_id Device identifier. 94 * @param[out] address Desired address. 95 * @param[out] data Address data container. 96 * 97 * @return EOK on success. 98 * @return EBADMEM if the address parameter and/or the data 99 * parameter is NULL. 100 * @return Other error codes as defined for the specific service 101 * message. 102 * 103 */ 104 int generic_get_addr_req(async_sess_t *sess, sysarg_t message, 105 device_id_t device_id, measured_string_t **address, uint8_t **data) 106 { 107 if ((!address) || (!data)) 108 return EBADMEM; 109 110 /* Request the address */ 111 async_exch_t *exch = async_exchange_begin(sess); 112 aid_t message_id = async_send_1(exch, message, (sysarg_t) device_id, 113 NULL); 114 int rc = measured_strings_return(exch, address, data, 1); 115 async_exchange_end(exch); 116 103 117 sysarg_t result; 104 int string;105 106 if (!address || !data)107 return EBADMEM;108 109 /* Request the address */110 message_id = async_obsolete_send_1(phone, (sysarg_t) message,111 (sysarg_t) device_id, NULL);112 string = measured_strings_return(phone, address, data, 1);113 118 async_wait_for(message_id, &result); 114 119 115 120 /* If not successful */ 116 if (( string== EOK) && (result != EOK)) {121 if ((rc == EOK) && (result != EOK)) { 117 122 /* Clear the data */ 118 123 free(*address); … … 125 130 /** Return the device packet dimension for sending. 126 131 * 127 * @param[in] phone The service module phone. 128 * @param[in] message The service specific message. 129 * @param[in] device_id The device identifier. 130 * @param[out] packet_dimension The packet dimension. 131 * @return EOK on success. 132 * @return EBADMEM if the packet_dimension parameter is NULL. 133 * @return Other error codes as defined for the specific service 134 * message. 135 */ 136 int 137 generic_packet_size_req_remote(int phone, int message, device_id_t device_id, 138 packet_dimension_t *packet_dimension) 132 * @param[in] sess Service module session. 133 * @param[in] message Service specific message. 134 * @param[in] device_id Device identifier. 135 * @param[out] packet_dimension Packet dimension. 136 * 137 * @return EOK on success. 138 * @return EBADMEM if the packet_dimension parameter is NULL. 139 * @return Other error codes as defined for the specific service 140 * message. 141 * 142 */ 143 int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message, 144 device_id_t device_id, packet_dimension_t *packet_dimension) 139 145 { 140 146 if (!packet_dimension) … … 146 152 sysarg_t suffix; 147 153 148 sysarg_t result = async_obsolete_req_1_4(phone, (sysarg_t) message, 149 (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix); 154 async_exch_t *exch = async_exchange_begin(sess); 155 sysarg_t result = async_req_1_4(exch, message, (sysarg_t) device_id, 156 &addr_len, &prefix, &content, &suffix); 157 async_exchange_end(exch); 150 158 151 159 packet_dimension->prefix = (size_t) prefix; … … 159 167 /** Pass the packet queue to the module. 160 168 * 161 * @param[in] phone The service module phone. 162 * @param[in] message The service specific message. 163 * @param[in] device_id The device identifier. 164 * @param[in] packet_id The received packet or the received packet queue 165 * identifier. 166 * @param[in] target The target module service. 167 * @param[in] error The error module service. 168 * @return EOK on success. 169 */ 170 int 171 generic_received_msg_remote(int phone, int message, device_id_t device_id, 172 packet_id_t packet_id, services_t target, services_t error) 173 { 169 * @param[in] sess Service module session. 170 * @param[in] message Service specific message. 171 * @param[in] device_id Device identifier. 172 * @param[in] packet_id Received packet or the received packet queue 173 * identifier. 174 * @param[in] target Target module service. 175 * @param[in] error Error module service. 176 * 177 * @return EOK on success. 178 * 179 */ 180 int generic_received_msg_remote(async_sess_t *sess, sysarg_t message, 181 device_id_t device_id, packet_id_t packet_id, services_t target, 182 services_t error) 183 { 184 async_exch_t *exch = async_exchange_begin(sess); 185 174 186 if (error) { 175 async_ obsolete_msg_4(phone, (sysarg_t)message, (sysarg_t) device_id,187 async_msg_4(exch, message, (sysarg_t) device_id, 176 188 (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error); 177 189 } else { 178 async_ obsolete_msg_3(phone, (sysarg_t)message, (sysarg_t) device_id,190 async_msg_3(exch, message, (sysarg_t) device_id, 179 191 (sysarg_t) packet_id, (sysarg_t) target); 180 192 } 181 193 194 async_exchange_end(exch); 195 182 196 return EOK; 183 197 } … … 185 199 /** Send the packet queue. 186 200 * 187 * @param[in] phone The service module phone. 188 * @param[in] message The service specific message. 189 * @param[in] device_id The device identifier. 190 * @param[in] packet_id The packet or the packet queue identifier. 191 * @param[in] sender The sending module service. 192 * @param[in] error The error module service. 193 * @return EOK on success. 194 * 195 */ 196 int 197 generic_send_msg_remote(int phone, int message, device_id_t device_id, 198 packet_id_t packet_id, services_t sender, services_t error) 199 { 201 * @param[in] sess Service module session. 202 * @param[in] message Service specific message. 203 * @param[in] device_id Device identifier. 204 * @param[in] packet_id Packet or the packet queue identifier. 205 * @param[in] sender Sending module service. 206 * @param[in] error Error module service. 207 * 208 * @return EOK on success. 209 * 210 */ 211 int generic_send_msg_remote(async_sess_t *sess, sysarg_t message, 212 device_id_t device_id, packet_id_t packet_id, services_t sender, 213 services_t error) 214 { 215 async_exch_t *exch = async_exchange_begin(sess); 216 200 217 if (error) { 201 async_ obsolete_msg_4(phone, (sysarg_t)message, (sysarg_t) device_id,218 async_msg_4(exch, message, (sysarg_t) device_id, 202 219 (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error); 203 220 } else { 204 async_ obsolete_msg_3(phone, (sysarg_t)message, (sysarg_t) device_id,221 async_msg_3(exch, message, (sysarg_t) device_id, 205 222 (sysarg_t) packet_id, (sysarg_t) sender); 206 223 } 207 224 225 async_exchange_end(exch); 226 208 227 return EOK; 209 228 } … … 213 232 * Allocates and returns the needed memory block as the data parameter. 214 233 * 215 * @param[in] phone The service module phone. 216 * @param[in] message The service specific message. 217 * @param[in] device_id The device identifier. 218 * @param[in] service The module service. 219 * @param[in] configuration The key strings. 220 * @param[in] count The number of configuration keys. 221 * @param[out] translation The translated values. 222 * @param[out] data The translation data container. 223 * @return EOK on success. 224 * @return EINVAL if the configuration parameter is NULL. 225 * @return EINVAL if the count parameter is zero. 226 * @return EBADMEM if the translation or the data parameters are 227 * NULL. 228 * @return Other error codes as defined for the specific service 229 * message. 230 */ 231 int 232 generic_translate_req(int phone, int message, device_id_t device_id, 233 services_t service, measured_string_t *configuration, size_t count, 234 * @param[in] sess Service module session. 235 * @param[in] message Service specific message. 236 * @param[in] device_id Device identifier. 237 * @param[in] service Module service. 238 * @param[in] configuration Key strings. 239 * @param[in] count Number of configuration keys. 240 * @param[out] translation Translated values. 241 * @param[out] data Translation data container. 242 * 243 * @return EOK on success. 244 * @return EINVAL if the configuration parameter is NULL. 245 * @return EINVAL if the count parameter is zero. 246 * @return EBADMEM if the translation or the data parameters are 247 * NULL. 248 * @return Other error codes as defined for the specific service 249 * message. 250 * 251 */ 252 int generic_translate_req(async_sess_t *sess, sysarg_t message, 253 device_id_t device_id, services_t service, 254 measured_string_t *configuration, size_t count, 234 255 measured_string_t **translation, uint8_t **data) 235 256 { 236 aid_t message_id; 257 if ((!configuration) || (count == 0)) 258 return EINVAL; 259 260 if ((!translation) || (!data)) 261 return EBADMEM; 262 263 /* Request the translation */ 264 async_exch_t *exch = async_exchange_begin(sess); 265 aid_t message_id = async_send_3(exch, message, (sysarg_t) device_id, 266 (sysarg_t) count, (sysarg_t) service, NULL); 267 measured_strings_send(exch, configuration, count); 268 int rc = measured_strings_return(exch, translation, data, count); 269 async_exchange_end(exch); 270 237 271 sysarg_t result; 238 int string;239 240 if (!configuration || (count == 0))241 return EINVAL;242 if (!translation || !data)243 return EBADMEM;244 245 /* Request the translation */246 message_id = async_obsolete_send_3(phone, (sysarg_t) message,247 (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);248 measured_strings_send(phone, configuration, count);249 string = measured_strings_return(phone, translation, data, count);250 272 async_wait_for(message_id, &result); 251 273 252 274 /* If not successful */ 253 if (( string== EOK) && (result != EOK)) {275 if ((rc == EOK) && (result != EOK)) { 254 276 /* Clear the data */ 255 277 free(*translation); 256 278 free(*data); 257 279 } 258 280 259 281 return (int) result; 260 282 } -
uspace/lib/net/generic/net_remote.c
r55091847 r6b82009 47 47 #include <adt/measured_strings.h> 48 48 49 /** Connect sto the networking module.49 /** Connect to the networking module. 50 50 * 51 * @return The networking module phone on success. 51 * @return Networking module session on success. 52 * 52 53 */ 53 intnet_connect_module(void)54 async_sess_t *net_connect_module(void) 54 55 { 55 56 return connect_to_service(SERVICE_NETWORKING); 56 57 } 57 58 58 /** Free sthe received settings.59 /** Free the received settings. 59 60 * 60 * @param[in] settings The received settings. 61 * @param[in] data The received settings data. 62 * @see net_get_device_conf_req() 61 * @param[in] settings Received settings. 62 * @param[in] data Received settings data. 63 * 64 * @see net_get_device_conf_req() 63 65 * @see net_get_conf_req() 66 * 64 67 */ 65 68 void net_free_settings(measured_string_t *settings, uint8_t *data) … … 71 74 } 72 75 73 /** Return sthe global configuration.76 /** Return the global configuration. 74 77 * 75 78 * The configuration names are read and the appropriate settings are set … … 77 80 * configuration. 78 81 * 79 * @param[in] net_phone The networking module phone. 80 * @param[in,out] configuration The requested configuration. The names are read 81 * and the appropriate settings are set instead. 82 * @param[in] sess Networking module session. 83 * @param[in,out] configuration Requested configuration. The names are 84 * read and the appropriate settings are set 85 * instead. 82 86 * 83 * @param[in] count The configuration entries count. 84 * @param[in,out] data The configuration and settings data. 85 * @return EOK on success. 86 * @return EINVAL if the configuration is NULL. 87 * @return EINVAL if the count is zero. 88 * @return Other error codes as defined for the 89 * generic_translate_req() function. 87 * @param[in] count Configuration entries count. 88 * @param[in,out] data Configuration and settings data. 89 * 90 * @return EOK on success. 91 * @return EINVAL if the configuration is NULL. 92 * @return EINVAL if the count is zero. 93 * @return Other error codes as defined for the 94 * generic_translate_req() function. 95 * 90 96 */ 91 int 92 net_get_conf_req(int net_phone, measured_string_t **configuration, 97 int net_get_conf_req(async_sess_t *sess, measured_string_t **configuration, 93 98 size_t count, uint8_t **data) 94 99 { 95 return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,100 return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF, 0, 0, 96 101 *configuration, count, configuration, data); 97 102 } 98 103 99 /** Return sthe device specific configuration.104 /** Return the device specific configuration. 100 105 * 101 * Return sthe global configuration if the device specific is not found.106 * Return the global configuration if the device specific is not found. 102 107 * The configuration names are read and the appropriate settings are set 103 108 * instead. Call net_free_settings() function to release the returned 104 109 * configuration. 105 110 * 106 * @param[in] net_phone The networking module phone. 107 * @param[in] device_id The device identifier. 108 * @param[in,out] configuration The requested device configuration. The names 109 * are read and the appropriate settings are set instead. 110 * @param[in] count The configuration entries count. 111 * @param[in,out] data The configuration and settings data. 112 * @return EOK on success. 113 * @return EINVAL if the configuration is NULL. 114 * @return EINVAL if the count is zero. 115 * @return Other error codes as defined for the 116 * generic_translate_req() function. 111 * @param[in] sess The networking module session. 112 * @param[in] device_id Device identifier. 113 * @param[in,out] configuration Requested device configuration. The names 114 * are read and the appropriate settings are 115 * set instead. 116 * @param[in] count Configuration entries count. 117 * @param[in,out] data Configuration and settings data. 118 * 119 * @return EOK on success. 120 * @return EINVAL if the configuration is NULL. 121 * @return EINVAL if the count is zero. 122 * @return Other error codes as defined for the 123 * generic_translate_req() function. 124 * 117 125 */ 118 int 119 net_get_device_conf_req(int net_phone, device_id_t device_id, 126 int net_get_device_conf_req(async_sess_t *sess, device_id_t device_id, 120 127 measured_string_t **configuration, size_t count, uint8_t **data) 121 128 { 122 return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF,129 return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF, 123 130 device_id, 0, *configuration, count, configuration, data); 124 131 } -
uspace/lib/net/generic/packet_client.c
r55091847 r6b82009 247 247 } 248 248 249 /** Returns the packet copy. 250 * 251 * Copies the addresses, data, order and metric values. 252 * Does not copy the queue placement. 253 * 254 * @param[in] phone The packet server module phone. 255 * @param[in] packet The original packet. 256 * @return The packet copy. 257 * @return NULL on error. 258 */ 259 packet_t *packet_get_copy(int phone, packet_t *packet) 260 { 261 packet_t *copy; 262 uint8_t * src = NULL; 263 uint8_t * dest = NULL; 264 size_t addrlen; 265 266 if (!packet_is_valid(packet)) 267 return NULL; 268 249 /** Return the packet copy. 250 * 251 * Copy the addresses, data, order and metric values. 252 * Queue placement is not copied. 253 * 254 * @param[in] sess Packet server module session. 255 * @param[in] packet Original packet. 256 * 257 * @return Packet copy. 258 * @return NULL on error. 259 * 260 */ 261 packet_t *packet_get_copy(async_sess_t *sess, packet_t *packet) 262 { 263 if (!packet_is_valid(packet)) 264 return NULL; 265 269 266 /* Get a new packet */ 270 copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet),267 packet_t *copy = packet_get_4_remote(sess, PACKET_DATA_LENGTH(packet), 271 268 PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix, 272 269 PACKET_MIN_SUFFIX(packet)); 270 273 271 if (!copy) 274 272 return NULL; 275 273 276 274 /* Get addresses */ 277 addrlen = packet_get_addr(packet, &src, &dest); 275 uint8_t *src = NULL; 276 uint8_t *dest = NULL; 277 size_t addrlen = packet_get_addr(packet, &src, &dest); 278 278 279 /* Copy data */ 279 280 if ((packet_copy_data(copy, packet_get_data(packet), … … 286 287 return copy; 287 288 } else { 288 pq_release_remote( phone, copy->packet_id);289 pq_release_remote(sess, copy->packet_id); 289 290 return NULL; 290 291 } -
uspace/lib/net/generic/packet_remote.c
r55091847 r6b82009 37 37 38 38 #include <async.h> 39 #include <async_obsolete.h>40 39 #include <errno.h> 41 40 #include <ipc/packet.h> … … 52 51 * Create the local packet mapping as well. 53 52 * 54 * @param[in] phone The packet server module phone.55 * @param[out] packet The packet reference pointer to store the received53 * @param[in] sess Packet server module session. 54 * @param[out] packet Packet reference pointer to store the received 56 55 * packet reference. 57 * @param[in] packet_id The packet identifier.58 * @param[in] size The packet total size in bytes.56 * @param[in] packet_id Packet identifier. 57 * @param[in] size Packet total size in bytes. 59 58 * 60 59 * @return EOK on success. 61 60 * @return Other error codes as defined for the pm_add() function. 62 * @return Other error codes as defined for the async_obsolete_share_in_start() function. 63 * 64 */ 65 static int 66 packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size) 67 { 61 * @return Other error codes as defined for the async_share_in_start() 62 * function. 63 * 64 */ 65 static int packet_return(async_sess_t *sess, packet_t **packet, 66 packet_id_t packet_id, size_t size) 67 { 68 *packet = (packet_t *) as_get_mappable_page(size); 69 70 async_exch_t *exch = async_exchange_begin(sess); 68 71 ipc_call_t answer; 69 aid_t message ;70 int rc ;71 72 message = async_obsolete_send_1(phone, NET_PACKET_GET, packet_id, &answer);73 74 *packet = (packet_t *) as_get_mappable_page(size);75 rc = async_obsolete_share_in_start_0_0(phone, *packet, size);72 aid_t message = async_send_1(exch, NET_PACKET_GET, packet_id, &answer); 73 int rc = async_share_in_start_0_0(exch, *packet, size); 74 async_exchange_end(exch); 75 76 sysarg_t result; 77 async_wait_for(message, &result); 78 76 79 if (rc != EOK) { 77 80 munmap(*packet, size); 78 async_wait_for(message, NULL);79 81 return rc; 80 82 } 83 81 84 rc = pm_add(*packet); 82 85 if (rc != EOK) { 83 86 munmap(*packet, size); 84 async_wait_for(message, NULL);85 87 return rc; 86 88 } 87 89 88 sysarg_t result;89 async_wait_for(message, &result);90 91 90 return result; 92 91 } 93 92 94 /** Translates the packet identifier to the packet reference. 95 * 96 * Tries to find mapping first. 97 * Contacts the packet server to share the packet if the mapping is not present. 98 * 99 * @param[in] phone The packet server module phone. 100 * @param[out] packet The packet reference. 101 * @param[in] packet_id The packet identifier. 102 * @return EOK on success. 103 * @return EINVAL if the packet parameter is NULL. 104 * @return Other error codes as defined for the NET_PACKET_GET_SIZE 105 * message. 106 * @return Other error codes as defined for the packet_return() 107 * function. 108 */ 109 int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id) 110 { 111 int rc; 112 93 /** Translate the packet identifier to the packet reference. 94 * 95 * Try to find mapping first. The packet server is asked to share 96 * the packet if the mapping is not present. 97 * 98 * @param[in] sess Packet server module session. 99 * @param[out] packet Packet reference. 100 * @param[in] packet_id Packet identifier. 101 * 102 * @return EOK on success. 103 * @return EINVAL if the packet parameter is NULL. 104 * @return Other error codes as defined for the NET_PACKET_GET_SIZE 105 * message. 106 * @return Other error codes as defined for the packet_return() 107 * function. 108 * 109 */ 110 int packet_translate_remote(async_sess_t *sess, packet_t **packet, 111 packet_id_t packet_id) 112 { 113 113 if (!packet) 114 114 return EINVAL; … … 116 116 *packet = pm_find(packet_id); 117 117 if (!*packet) { 118 async_exch_t *exch = async_exchange_begin(sess); 118 119 sysarg_t size; 120 int rc = async_req_1_1(exch, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 async_exchange_end(exch); 119 123 120 rc = async_obsolete_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,121 &size);122 124 if (rc != EOK) 123 125 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 126 127 rc = packet_return(sess, packet, packet_id, size); 125 128 if (rc != EOK) 126 129 return rc; 127 130 } 131 128 132 if ((*packet)->next) { 129 133 packet_t *next; 130 131 return packet_translate_remote(phone, &next, (*packet)->next); 134 return packet_translate_remote(sess, &next, (*packet)->next); 132 135 } 133 136 … … 135 138 } 136 139 137 /** Obtains the packet of the given dimensions. 138 * 139 * Contacts the packet server to return the appropriate packet. 140 * 141 * @param[in] phone The packet server module phone. 142 * @param[in] addr_len The source and destination addresses maximal length in 143 * bytes. 144 * @param[in] max_prefix The maximal prefix length in bytes. 145 * @param[in] max_content The maximal content length in bytes. 146 * @param[in] max_suffix The maximal suffix length in bytes. 147 * @return The packet reference. 148 * @return NULL on error. 149 */ 150 packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 151 size_t max_prefix, size_t max_suffix) 152 { 140 /** Obtain the packet of given dimensions. 141 * 142 * Contact the packet server to return the appropriate packet. 143 * 144 * @param[in] sess Packet server module session. 145 * @param[in] addr_len Source and destination addresses maximal length 146 * in bytes. 147 * @param[in] max_prefix Maximal prefix length in bytes. 148 * @param[in] max_content Maximal content length in bytes. 149 * @param[in] max_suffix Maximal suffix length in bytes. 150 * 151 * @return The packet reference. 152 * @return NULL on error. 153 * 154 */ 155 packet_t *packet_get_4_remote(async_sess_t *sess, size_t max_content, 156 size_t addr_len, size_t max_prefix, size_t max_suffix) 157 { 158 async_exch_t *exch = async_exchange_begin(sess); 153 159 sysarg_t packet_id; 154 160 sysarg_t size; 155 int rc; 156 157 rc = async_obsolete_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 161 int rc = async_req_4_2(exch, NET_PACKET_CREATE_4, max_content, addr_len, 158 162 max_prefix, max_suffix, &packet_id, &size); 163 async_exchange_end(exch); 164 159 165 if (rc != EOK) 160 166 return NULL; 161 167 162 163 168 packet_t *packet = pm_find(packet_id); 164 169 if (!packet) { 165 rc = packet_return( phone, &packet, packet_id, size);170 rc = packet_return(sess, &packet, packet_id, size); 166 171 if (rc != EOK) 167 172 return NULL; … … 171 176 } 172 177 173 /** Obtains the packet of the given content size. 174 * 175 * Contacts the packet server to return the appropriate packet. 176 * 177 * @param[in] phone The packet server module phone. 178 * @param[in] content The maximal content length in bytes. 179 * @return The packet reference. 180 * @return NULL on error. 181 */ 182 packet_t *packet_get_1_remote(int phone, size_t content) 183 { 178 /** Obtain the packet of given content size. 179 * 180 * Contact the packet server to return the appropriate packet. 181 * 182 * @param[in] sess Packet server module session. 183 * @param[in] content Maximal content length in bytes. 184 * 185 * @return The packet reference. 186 * @return NULL on error. 187 * 188 */ 189 packet_t *packet_get_1_remote(async_sess_t *sess, size_t content) 190 { 191 async_exch_t *exch = async_exchange_begin(sess); 184 192 sysarg_t packet_id; 185 193 sysarg_t size; 186 int rc; 187 188 rc = async_obsolete_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 194 int rc = async_req_1_2(exch, NET_PACKET_CREATE_1, content, &packet_id, 189 195 &size); 196 async_exchange_end(exch); 197 190 198 if (rc != EOK) 191 199 return NULL; … … 193 201 packet_t *packet = pm_find(packet_id); 194 202 if (!packet) { 195 rc = packet_return( phone, &packet, packet_id, size);203 rc = packet_return(sess, &packet, packet_id, size); 196 204 if (rc != EOK) 197 205 return NULL; … … 201 209 } 202 210 203 /** Release sthe packet queue.211 /** Release the packet queue. 204 212 * 205 213 * All packets in the queue are marked as free for use. … … 208 216 * received or obtained again. 209 217 * 210 * @param[in] phone The packet server module phone. 211 * @param[in] packet_id The packet identifier. 212 */ 213 void pq_release_remote(int phone, packet_id_t packet_id) 214 { 215 async_obsolete_msg_1(phone, NET_PACKET_RELEASE, packet_id); 218 * @param[in] sess Packet server module session. 219 * @param[in] packet_id Packet identifier. 220 * 221 */ 222 void pq_release_remote(async_sess_t *sess, packet_id_t packet_id) 223 { 224 async_exch_t *exch = async_exchange_begin(sess); 225 async_msg_1(exch, NET_PACKET_RELEASE, packet_id); 226 async_exchange_end(exch); 216 227 } 217 228 -
uspace/lib/net/il/arp_remote.c
r55091847 r6b82009 38 38 #include <arp_interface.h> 39 39 #include <generic.h> 40 41 #include <async.h>42 #include <async_obsolete.h>43 #include <errno.h>44 40 #include <ipc/services.h> 45 41 #include <ipc/arp.h> 46 47 42 #include <net/modules.h> 48 43 #include <net/device.h> 49 44 #include <adt/measured_strings.h> 45 #include <async.h> 46 #include <errno.h> 50 47 51 /** Connect sto the ARP module.48 /** Connect to the ARP module. 52 49 * 53 * @ param service The ARP module service. Ignored parameter.54 * @return The ARP module phone on success.50 * @return ARP module session on success. 51 * 55 52 */ 56 intarp_connect_module(services_t service)53 async_sess_t *arp_connect_module(services_t service) 57 54 { 58 if (service != SERVICE_ARP) 59 return EINVAL; 60 55 // FIXME: Get rid of the useless argument 61 56 return connect_to_service(SERVICE_ARP); 62 57 } … … 64 59 /** Cleans the cache. 65 60 * 66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 67 * @return EOK on success. 61 * @param[in] sess ARP module session. 62 * 63 * @return EOK on success. 64 * 68 65 */ 69 int arp_clean_cache_req( int arp_phone)66 int arp_clean_cache_req(async_sess_t *sess) 70 67 { 71 return (int) async_obsolete_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE); 68 async_exch_t *exch = async_exchange_begin(sess); 69 int rc = async_req_0_0(exch, NET_ARP_CLEAN_CACHE); 70 async_exchange_end(exch); 71 72 return rc; 72 73 } 73 74 74 /** Clear sthe given protocol address from the cache.75 /** Clear the given protocol address from the cache. 75 76 * 76 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 77 * @param[in] device_id The device identifier. 78 * @param[in] protocol The requesting protocol service. 79 * @param[in] address The protocol address to be cleared. 80 * @return EOK on success. 81 * @return ENOENT if the mapping is not found. 77 * @param[in] sess ARP module session. 78 * @param[in] device_id Device identifier. 79 * @param[in] protocol Requesting protocol service. 80 * @param[in] address Protocol address to be cleared. 81 * 82 * @return EOK on success. 83 * @return ENOENT if the mapping is not found. 84 * 82 85 */ 83 int 84 arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, 85 measured_string_t *address) 86 int arp_clear_address_req(async_sess_t *sess, device_id_t device_id, 87 services_t protocol, measured_string_t *address) 86 88 { 87 aid_t message_id; 89 async_exch_t *exch = async_exchange_begin(sess); 90 aid_t message_id = async_send_2(exch, NET_ARP_CLEAR_ADDRESS, 91 (sysarg_t) device_id, protocol, NULL); 92 measured_strings_send(exch, address, 1); 93 async_exchange_end(exch); 94 88 95 sysarg_t result; 96 async_wait_for(message_id, &result); 97 98 return (int) result; 99 } 89 100 90 message_id = async_obsolete_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, 91 (sysarg_t) device_id, protocol, NULL); 92 measured_strings_send(arp_phone, address, 1); 101 /** Clear the device cache. 102 * 103 * @param[in] sess ARP module session. 104 * @param[in] device_id Device identifier. 105 * 106 * @return EOK on success. 107 * @return ENOENT if the device is not found. 108 * 109 */ 110 int arp_clear_device_req(async_sess_t *sess, device_id_t device_id) 111 { 112 async_exch_t *exch = async_exchange_begin(sess); 113 int rc = async_req_1_0(exch, NET_ARP_CLEAR_DEVICE, 114 (sysarg_t) device_id); 115 async_exchange_end(exch); 116 117 return rc; 118 } 119 120 /** Register new device and the requesting protocol service. 121 * 122 * Connect to the network interface layer service. 123 * Determine the device broadcast address, its address lengths and packet size. 124 * 125 * @param[in] sess ARP module session. 126 * @param[in] device_id New device identifier. 127 * @param[in] protocol Requesting protocol service. 128 * @param[in] netif Underlying device network interface layer service. 129 * @param[in] address Local requesting protocol address of the device. 130 * 131 * @return EOK on success. 132 * @return EEXIST if the device is already used. 133 * @return ENOMEM if there is not enough memory left. 134 * @return ENOENT if the network interface service is not known. 135 * @return EREFUSED if the network interface service is not 136 * responding. 137 * @return Other error codes as defined for the 138 * nil_packet_get_size() function. 139 * @return Other error codes as defined for the nil_get_addr() 140 * function. 141 * @return Other error codes as defined for the 142 * nil_get_broadcast_addr() function. 143 * 144 */ 145 int arp_device_req(async_sess_t *sess, device_id_t device_id, 146 services_t protocol, services_t netif, measured_string_t *address) 147 { 148 async_exch_t *exch = async_exchange_begin(sess); 149 aid_t message_id = async_send_3(exch, NET_ARP_DEVICE, 150 (sysarg_t) device_id, protocol, netif, NULL); 151 measured_strings_send(exch, address, 1); 152 async_exchange_end(exch); 153 154 sysarg_t result; 93 155 async_wait_for(message_id, &result); 94 156 … … 96 158 } 97 159 98 /** Clears the device cache.160 /** Translate the given protocol address to the network interface address. 99 161 * 100 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 101 * @param[in] device_id The device identifier. 102 * @return EOK on success. 103 * @return ENOENT if the device is not found. 162 * Broadcast the ARP request if the mapping is not found. 163 * Allocate and returns the needed memory block as the data parameter. 164 * 165 * @param[in] sess ARP module session. 166 * @param[in] device_id Device identifier. 167 * @param[in] protocol Requesting protocol service. 168 * @param[in] address Local requesting protocol address. 169 * @param[out] translation Translation of the local protocol address. 170 * @param[out] data Allocated raw translation data container. 171 * 172 * @return EOK on success. 173 * @return EINVAL if the address parameter is NULL. 174 * @return EBADMEM if the translation or the data parameters are 175 * NULL. 176 * @return ENOENT if the mapping is not found. 177 * 104 178 */ 105 int arp_clear_device_req(int arp_phone, device_id_t device_id) 179 int arp_translate_req(async_sess_t *sess, device_id_t device_id, 180 services_t protocol, measured_string_t *address, 181 measured_string_t **translation, uint8_t **data) 106 182 { 107 return (int) async_obsolete_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, 108 (sysarg_t) device_id); 109 } 110 111 /** Registers the new device and the requesting protocol service. 112 * 113 * Connects to the network interface layer service. 114 * Determines the device broadcast address, its address lengths and packet size. 115 * 116 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 117 * @param[in] device_id The new device identifier. 118 * @param[in] protocol The requesting protocol service. 119 * @param[in] netif The underlying device network interface layer service. 120 * @param[in] address The local requesting protocol address of the device. 121 * @return EOK on success. 122 * @return EEXIST if the device is already used. 123 * @return ENOMEM if there is not enough memory left. 124 * @return ENOENT if the network interface service is not known. 125 * @return EREFUSED if the network interface service is not 126 * responding. 127 * @return Other error codes as defined for the 128 * nil_packet_get_size() function. 129 * @return Other error codes as defined for the nil_get_addr() 130 * function. 131 * @return Other error codes as defined for the 132 * nil_get_broadcast_addr() function. 133 */ 134 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, 135 services_t netif, measured_string_t *address) 136 { 137 aid_t message_id; 138 sysarg_t result; 139 140 message_id = async_obsolete_send_3(arp_phone, NET_ARP_DEVICE, 141 (sysarg_t) device_id, protocol, netif, NULL); 142 measured_strings_send(arp_phone, address, 1); 143 async_wait_for(message_id, &result); 144 145 return (int) result; 146 } 147 148 /** Translates the given protocol address to the network interface address. 149 * 150 * Broadcasts the ARP request if the mapping is not found. 151 * Allocates and returns the needed memory block as the data parameter. 152 * 153 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 154 * @param[in] device_id The device identifier. 155 * @param[in] protocol The requesting protocol service. 156 * @param[in] address The local requesting protocol address. 157 * @param[out] translation The translation of the local protocol address. 158 * @param[out] data The allocated raw translation data container. 159 * @return EOK on success. 160 * @return EINVAL if the address parameter is NULL. 161 * @return EBADMEM if the translation or the data parameters are 162 * NULL. 163 * @return ENOENT if the mapping is not found. 164 */ 165 int 166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, 167 measured_string_t *address, measured_string_t **translation, uint8_t **data) 168 { 169 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, 183 return generic_translate_req(sess, NET_ARP_TRANSLATE, device_id, 170 184 protocol, address, 1, translation, data); 171 185 } -
uspace/lib/net/il/il_remote.c
r55091847 r6b82009 39 39 #include <generic.h> 40 40 #include <packet_client.h> 41 42 41 #include <ipc/services.h> 43 42 #include <ipc/il.h> 44 45 43 #include <net/device.h> 46 44 #include <net/packet.h> … … 48 46 /** Notify the internetwork layer modules about the device state change. 49 47 * 50 * @param[in] il_phone The internetwork layer module phone used for 51 * (semi)remote calls. 52 * @param[in] device_id The device identifier. 53 * @param[in] state The new device state. 54 * @param[in] target The target internetwork module service to be 48 * @param[in] sess Internetwork layer module session. 49 * @param[in] device_id Device identifier. 50 * @param[in] state New device state. 51 * @param[in] target Target internetwork module service to be 55 52 * delivered to. 56 53 * … … 58 55 * 59 56 */ 60 int il_device_state_msg( int il_phone, device_id_t device_id,57 int il_device_state_msg(async_sess_t *sess, device_id_t device_id, 61 58 device_state_t state, services_t target) 62 59 { 63 return generic_device_state_msg_remote( il_phone, NET_IL_DEVICE_STATE,60 return generic_device_state_msg_remote(sess, NET_IL_DEVICE_STATE, 64 61 device_id, state, target); 65 62 } … … 67 64 /** Notify the internetwork layer modules about the received packet/s. 68 65 * 69 * @param[in] il_phone The internetwork layer module phone used for 70 * (semi)remote calls. 71 * @param[in] device_id The device identifier. 72 * @param[in] packet The received packet or the received packet queue. 73 * @param[in] target The target internetwork module service to be 66 * @param[in] sess Internetwork layer module session. 67 * @param[in] device_id Device identifier. 68 * @param[in] packet Received packet or the received packet queue. 69 * @param[in] target Target internetwork module service to be 74 70 * delivered to. 75 71 * … … 77 73 * 78 74 */ 79 int il_received_msg( int il_phone, device_id_t device_id, packet_t *packet,75 int il_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet, 80 76 services_t target) 81 77 { 82 return generic_received_msg_remote( il_phone, NET_IL_RECEIVED, device_id,78 return generic_received_msg_remote(sess, NET_IL_RECEIVED, device_id, 83 79 packet_get_id(packet), target, 0); 84 80 } … … 86 82 /** Notify the internetwork layer modules about the mtu change. 87 83 * 88 * @param[in] il_phone The internetwork layer module phone used for 89 * (semi)remote calls. 90 * @param[in] device_id The device identifier. 91 * @param[in] mtu The new mtu value. 92 * @param[in] target The target internetwork module service to be 84 * @param[in] sess Internetwork layer module session. 85 * @param[in] device_id Device identifier. 86 * @param[in] mtu New MTU value. 87 * @param[in] target Target internetwork module service to be 93 88 * delivered to. 94 89 * … … 96 91 * 97 92 */ 98 int il_mtu_changed_msg( int il_phone, device_id_t device_id, size_t mtu,93 int il_mtu_changed_msg(async_sess_t *sess, device_id_t device_id, size_t mtu, 99 94 services_t target) 100 95 { 101 return generic_device_state_msg_remote( il_phone, NET_IL_MTU_CHANGED,102 device_id, (int)mtu, target);96 return generic_device_state_msg_remote(sess, NET_IL_MTU_CHANGED, 97 device_id, mtu, target); 103 98 } 104 99 -
uspace/lib/net/il/il_skel.c
r55091847 r6b82009 38 38 #include <bool.h> 39 39 #include <errno.h> 40 #include <ns.h> 40 41 #include <il_skel.h> 41 42 #include <net_interface.h> 42 43 #include <net/modules.h> 43 #include <async_obsolete.h>44 45 // FIXME: remove this header46 #include <kernel/ipc/ipc_methods.h>47 44 48 45 /** Default thread for new connections. … … 100 97 * @return Other error codes as defined for the il_initialize() 101 98 * function. 102 * @return Other error codes as defined for the REGISTER_ME() macro103 * function.104 99 * 105 100 */ 106 int il_module_start( int service)101 int il_module_start(sysarg_t service) 107 102 { 108 103 async_set_client_connection(il_client_connection); 109 int net_phone= net_connect_module();110 if ( net_phone < 0)111 return net_phone;104 async_sess_t *sess = net_connect_module(); 105 if (!sess) 106 return ENOENT; 112 107 113 108 int rc = pm_init(); … … 115 110 return rc; 116 111 117 rc = il_initialize( net_phone);112 rc = il_initialize(sess); 118 113 if (rc != EOK) 119 114 goto out; 120 115 121 rc = async_obsolete_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);116 rc = service_register(service); 122 117 if (rc != EOK) 123 118 goto out; -
uspace/lib/net/il/ip_remote.c
r55091847 r6b82009 44 44 #include <packet_client.h> 45 45 #include <generic.h> 46 #include <async_obsolete.h>47 46 #include <ipc/services.h> 48 47 #include <ipc/il.h> 49 48 #include <ipc/ip.h> 50 51 49 #include <net/modules.h> 52 50 #include <net/device.h> … … 57 55 * The target network is routed using this device. 58 56 * 59 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 60 * @param[in] device_id The device identifier. 61 * @param[in] address The target network address. 62 * @param[in] netmask The target network mask. 63 * @param[in] gateway The target network gateway. Not used if zero. 64 */ 65 int ip_add_route_req_remote(int ip_phone, device_id_t device_id, 57 * @param[in] sess IP module sessions. 58 * @param[in] device_id Device identifier. 59 * @param[in] address Target network address. 60 * @param[in] netmask Target network mask. 61 * @param[in] gateway Target network gateway. Not used if zero. 62 * 63 */ 64 int ip_add_route_req_remote(async_sess_t *sess, device_id_t device_id, 66 65 in_addr_t address, in_addr_t netmask, in_addr_t gateway) 67 66 { 68 return (int) async_obsolete_req_4_0(ip_phone, NET_IP_ADD_ROUTE, 67 async_exch_t *exch = async_exchange_begin(sess); 68 int rc = async_req_4_0(exch, NET_IP_ADD_ROUTE, 69 69 (sysarg_t) device_id, (sysarg_t) gateway.s_addr, 70 70 (sysarg_t) address.s_addr, (sysarg_t) netmask.s_addr); 71 } 72 73 /** Creates bidirectional connection with the ip module service and registers 71 async_exchange_end(exch); 72 73 return rc; 74 } 75 76 /** Create bidirectional connection with the ip module service and register 74 77 * the message receiver. 75 78 * 76 * @param[in] service TheIP module service.77 * @param[in] protocol The transport layer protocol.78 * @param[in] me The requesting module service.79 * @param[in] receiver The message receiver. Used for remote connection.80 * @return The phone of the needed service.81 * @return EOK on success.82 * @return Other error codes as defined for the bind_service()83 * function.84 */ 85 intip_bind_service(services_t service, int protocol, services_t me,79 * @param[in] service IP module service. 80 * @param[in] protocol Transport layer protocol. 81 * @param[in] me Rquesting module service. 82 * @param[in] receiver Message receiver. Used for remote connection. 83 * 84 * @return Session to the needed service. 85 * @return NULL on failure. 86 * 87 */ 88 async_sess_t *ip_bind_service(services_t service, int protocol, services_t me, 86 89 async_client_conn_t receiver) 87 90 { 88 return (int)bind_service(service, (sysarg_t) protocol, me, service,91 return bind_service(service, (sysarg_t) protocol, me, service, 89 92 receiver); 90 93 } 91 94 92 /** Connects to the IP module. 93 * 94 * @param service The IP module service. Ignored parameter. 95 * @return The IP module phone on success. 96 */ 97 int ip_connect_module(services_t service) 98 { 95 /** Connect to the IP module. 96 * 97 * @return The IP module session. 98 * 99 */ 100 async_sess_t *ip_connect_module(services_t service) 101 { 102 // FIXME: Get rid of the useless argument 99 103 return connect_to_service(SERVICE_IP); 100 104 } … … 105 109 * If the device uses ARP registers also the new ARP device. 106 110 * 107 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 108 * @param[in] device_id The new device identifier. 109 * @param[in] netif The underlying device network interface layer service. 110 * @return EOK on success. 111 * @return ENOMEM if there is not enough memory left. 112 * @return EINVAL if the device configuration is invalid. 113 * @return ENOTSUP if the device uses IPv6. 114 * @return ENOTSUP if the device uses DHCP. 115 * @return Other error codes as defined for the 116 * net_get_device_conf_req() function. 117 * @return Other error codes as defined for the arp_device_req() 118 * function. 119 */ 120 int ip_device_req_remote(int ip_phone, device_id_t device_id, 121 services_t service) 122 { 123 return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0, 124 service); 111 * @param[in] sess IP module session. 112 * @param[in] device_id New device identifier. 113 * 114 * @return EOK on success. 115 * @return ENOMEM if there is not enough memory left. 116 * @return EINVAL if the device configuration is invalid. 117 * @return ENOTSUP if the device uses IPv6. 118 * @return ENOTSUP if the device uses DHCP. 119 * @return Other error codes as defined for the 120 * net_get_device_conf_req() function. 121 * @return Other error codes as defined for the arp_device_req() 122 * function. 123 * 124 */ 125 int ip_device_req_remote(async_sess_t *sess, device_id_t device_id) 126 { 127 return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0, 0); 125 128 } 126 129 … … 128 131 * destination address. 129 132 * 130 * @param[in] ip_phone The IP module phone used for (semi)remote calls.131 * @param[in] protocol The transport protocol.132 * @param[in] destination The destination address.133 * @param[in] addrlen The destination address length.134 * @param[out] device_id The device identifier.135 * @param[out] header The constructed IP pseudo header.136 * @param[out] headerlen TheIP pseudo header length.137 * 138 */ 139 int ip_get_route_req_remote( int ip_phone, ip_protocol_t protocol,133 * @param[in] sess IP module session. 134 * @param[in] protocol Transport protocol. 135 * @param[in] destination Destination address. 136 * @param[in] addrlen Destination address length. 137 * @param[out] device_id Device identifier. 138 * @param[out] header Constructed IP pseudo header. 139 * @param[out] headerlen IP pseudo header length. 140 * 141 */ 142 int ip_get_route_req_remote(async_sess_t *sess, ip_protocol_t protocol, 140 143 const struct sockaddr *destination, socklen_t addrlen, 141 144 device_id_t *device_id, void **header, size_t *headerlen) 142 145 { 143 if ( !destination|| (addrlen == 0))146 if ((!destination) || (addrlen == 0)) 144 147 return EINVAL; 145 148 146 if ( !device_id || !header || !headerlen)149 if ((!device_id) || (!header) || (!headerlen)) 147 150 return EBADMEM; 148 151 149 152 *header = NULL; 150 153 154 async_exch_t *exch = async_exchange_begin(sess); 155 151 156 ipc_call_t answer; 152 aid_t message_id = async_ obsolete_send_1(ip_phone, NET_IP_GET_ROUTE,157 aid_t message_id = async_send_1(exch, NET_IP_GET_ROUTE, 153 158 (sysarg_t) protocol, &answer); 154 159 155 if ((async_ obsolete_data_write_start(ip_phone, destination, addrlen) == EOK) &&156 (async_ obsolete_data_read_start(ip_phone, headerlen,157 sizeof(*headerlen)) == EOK) &&(*headerlen > 0)) {160 if ((async_data_write_start(exch, destination, addrlen) == EOK) && 161 (async_data_read_start(exch, headerlen, sizeof(*headerlen)) == EOK) && 162 (*headerlen > 0)) { 158 163 *header = malloc(*headerlen); 159 164 if (*header) { 160 if (async_ obsolete_data_read_start(ip_phone, *header,165 if (async_data_read_start(exch, *header, 161 166 *headerlen) != EOK) 162 167 free(*header); … … 164 169 } 165 170 171 async_exchange_end(exch); 172 166 173 sysarg_t result; 167 174 async_wait_for(message_id, &result); … … 177 184 /** Return the device packet dimension for sending. 178 185 * 179 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 180 * @param[in] device_id The device identifier. 181 * @param[out] packet_dimension The packet dimension. 182 * @return EOK on success. 183 * @return ENOENT if there is no such device. 184 * @return Other error codes as defined for the 185 * generic_packet_size_req_remote() function. 186 */ 187 int ip_packet_size_req_remote(int ip_phone, device_id_t device_id, 186 * @param[in] sess IP module session. 187 * @param[in] device_id Device identifier. 188 * @param[out] packet_dimension Packet dimension. 189 * 190 * @return EOK on success. 191 * @return ENOENT if there is no such device. 192 * @return Other error codes as defined for the 193 * generic_packet_size_req_remote() function. 194 * 195 */ 196 int ip_packet_size_req_remote(async_sess_t *sess, device_id_t device_id, 188 197 packet_dimension_t *packet_dimension) 189 198 { 190 return generic_packet_size_req_remote( ip_phone, NET_IP_PACKET_SPACE,199 return generic_packet_size_req_remote(sess, NET_IP_PACKET_SPACE, 191 200 device_id, packet_dimension); 192 201 } … … 194 203 /** Notify the IP module about the received error notification packet. 195 204 * 196 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 197 * @param[in] device_id The device identifier. 198 * @param[in] packet The received packet or the received packet queue. 199 * @param[in] target The target internetwork module service to be 200 * delivered to. 201 * @param[in] error The packet error reporting service. Prefixes the 202 * received packet. 203 * @return EOK on success. 204 */ 205 int ip_received_error_msg_remote(int ip_phone, device_id_t device_id, 205 * @param[in] sess IP module session. 206 * @param[in] device_id Device identifier. 207 * @param[in] packet Received packet or the received packet queue. 208 * @param[in] target Target internetwork module service to be 209 * delivered to. 210 * @param[in] error Packet error reporting service. Prefixes the 211 * received packet. 212 * 213 * @return EOK on success. 214 * 215 */ 216 int ip_received_error_msg_remote(async_sess_t *sess, device_id_t device_id, 206 217 packet_t *packet, services_t target, services_t error) 207 218 { 208 return generic_received_msg_remote( ip_phone, NET_IP_RECEIVED_ERROR,219 return generic_received_msg_remote(sess, NET_IP_RECEIVED_ERROR, 209 220 device_id, packet_get_id(packet), target, error); 210 221 } … … 214 225 * The packets may get fragmented if needed. 215 226 * 216 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 217 * @param[in] device_id The device identifier. 218 * @param[in] packet The packet fragments as a packet queue. All the 219 * packets have to have the same destination address. 220 * @param[in] sender The sending module service. 221 * @param[in] error The packet error reporting service. Prefixes the 222 * received packet. 223 * @return EOK on success. 224 * @return Other error codes as defined for the generic_send_msg() 225 * function. 226 */ 227 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t *packet, 228 services_t sender, services_t error) 229 { 230 return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id, 227 * @param[in] sess IP module session. 228 * @param[in] device_id Device identifier. 229 * @param[in] packet Packet fragments as a packet queue. All the 230 * packets have to have the same destination address. 231 * @param[in] sender Sending module service. 232 * @param[in] error Packet error reporting service. Prefixes the 233 * received packet. 234 * 235 * @return EOK on success. 236 * @return Other error codes as defined for the generic_send_msg() 237 * function. 238 * 239 */ 240 int ip_send_msg_remote(async_sess_t *sess, device_id_t device_id, 241 packet_t *packet, services_t sender, services_t error) 242 { 243 return generic_send_msg_remote(sess, NET_IP_SEND, device_id, 231 244 packet_get_id(packet), sender, error); 232 245 } … … 236 249 * This gateway is used if no other route is found. 237 250 * 238 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 239 * @param[in] device_id The device identifier. 240 * @param[in] gateway The default gateway. 241 */ 242 int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id, 251 * @param[in] sess IP module session. 252 * @param[in] device_id Device identifier. 253 * @param[in] gateway Default gateway. 254 * 255 */ 256 int ip_set_gateway_req_remote(async_sess_t *sess, device_id_t device_id, 243 257 in_addr_t gateway) 244 258 { 245 return (int) async_obsolete_req_2_0(ip_phone, NET_IP_SET_GATEWAY, 259 async_exch_t *exch = async_exchange_begin(sess); 260 int rc = async_req_2_0(exch, NET_IP_SET_GATEWAY, 246 261 (sysarg_t) device_id, (sysarg_t) gateway.s_addr); 262 async_exchange_end(exch); 263 264 return rc; 247 265 } 248 266 -
uspace/lib/net/include/adt/module_map.h
r55091847 r6b82009 39 39 40 40 #include <task.h> 41 #include < ipc/services.h>41 #include <async.h> 42 42 #include <net/modules.h> 43 43 #include <adt/generic_char_map.h> … … 60 60 /** Module service identifier. */ 61 61 services_t service; 62 /** Module phoneif running and connected. */63 int phone;62 /** Module session if running and connected. */ 63 async_sess_t *sess; 64 64 /** Usage counter. */ 65 65 int usage; -
uspace/lib/net/include/arp_interface.h
r55091847 r6b82009 36 36 #include <adt/measured_strings.h> 37 37 #include <task.h> 38 39 38 #include <ipc/services.h> 40 41 39 #include <net/device.h> 42 40 #include <net/socket.h> 41 #include <async.h> 43 42 44 43 /** @name ARP module interface … … 47 46 /*@{*/ 48 47 49 extern int arp_device_req( int, device_id_t, services_t, services_t,48 extern int arp_device_req(async_sess_t *, device_id_t, services_t, services_t, 50 49 measured_string_t *); 51 extern int arp_translate_req( int, device_id_t, services_t, measured_string_t *,52 measured_string_t * *, uint8_t **);53 extern int arp_clear_device_req( int, device_id_t);54 extern int arp_clear_address_req( int, device_id_t, services_t,50 extern int arp_translate_req(async_sess_t *, device_id_t, services_t, 51 measured_string_t *, measured_string_t **, uint8_t **); 52 extern int arp_clear_device_req(async_sess_t *, device_id_t); 53 extern int arp_clear_address_req(async_sess_t *, device_id_t, services_t, 55 54 measured_string_t *); 56 extern int arp_clean_cache_req( int);57 extern intarp_connect_module(services_t);55 extern int arp_clean_cache_req(async_sess_t *); 56 extern async_sess_t *arp_connect_module(services_t); 58 57 59 58 /*@}*/ -
uspace/lib/net/include/generic.h
r55091847 r6b82009 38 38 #define LIBNET_GENERIC_H_ 39 39 40 #include <async.h>41 40 #include <ipc/services.h> 42 43 41 #include <net/device.h> 44 42 #include <adt/measured_strings.h> 45 43 #include <net/packet.h> 44 #include <async.h> 46 45 47 extern int generic_device_state_msg_remote(int, int, device_id_t, int, 48 services_t); 49 extern int generic_device_req_remote(int, int, device_id_t, int, services_t); 50 extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **, 51 uint8_t **); 52 extern int generic_packet_size_req_remote(int, int, device_id_t, 46 extern int generic_device_state_msg_remote(async_sess_t *, sysarg_t, 47 device_id_t, sysarg_t, services_t); 48 extern int generic_device_req_remote(async_sess_t *, sysarg_t, device_id_t, 49 sysarg_t, services_t); 50 extern int generic_get_addr_req(async_sess_t *, sysarg_t, device_id_t, 51 measured_string_t **, uint8_t **); 52 extern int generic_packet_size_req_remote(async_sess_t *, sysarg_t, device_id_t, 53 53 packet_dimension_t *); 54 extern int generic_received_msg_remote( int, int, device_id_t, packet_id_t,55 services_t, services_t);56 extern int generic_send_msg_remote( int, int, device_id_t, packet_id_t,57 services_t, services_t);58 extern int generic_translate_req( int, int, device_id_t, services_t,59 measured_string_t *, size_t, measured_string_t **, uint8_t **);54 extern int generic_received_msg_remote(async_sess_t *, sysarg_t, device_id_t, 55 packet_id_t, services_t, services_t); 56 extern int generic_send_msg_remote(async_sess_t *, sysarg_t, device_id_t, 57 packet_id_t, services_t, services_t); 58 extern int generic_translate_req(async_sess_t *, sysarg_t, device_id_t, 59 services_t, measured_string_t *, size_t, measured_string_t **, uint8_t **); 60 60 61 61 #endif -
uspace/lib/net/include/icmp_remote.h
r55091847 r6b82009 36 36 #include <net/socket_codes.h> 37 37 #include <sys/types.h> 38 39 38 #include <net/device.h> 40 39 #include <adt/measured_strings.h> … … 44 43 #include <net/icmp_codes.h> 45 44 #include <net/icmp_common.h> 45 #include <async.h> 46 46 47 47 /** @name ICMP module interface … … 50 50 /*@{*/ 51 51 52 extern int icmp_destination_unreachable_msg( int, icmp_code_t, icmp_param_t,53 packet_t *);54 extern int icmp_source_quench_msg( int, packet_t *);55 extern int icmp_time_exceeded_msg( int, icmp_code_t, packet_t *);56 extern int icmp_parameter_problem_msg( int, icmp_code_t, icmp_param_t,52 extern int icmp_destination_unreachable_msg(async_sess_t *, icmp_code_t, 53 icmp_param_t, packet_t *); 54 extern int icmp_source_quench_msg(async_sess_t *, packet_t *); 55 extern int icmp_time_exceeded_msg(async_sess_t *, icmp_code_t, packet_t *); 56 extern int icmp_parameter_problem_msg(async_sess_t *, icmp_code_t, icmp_param_t, 57 57 packet_t *); 58 58 -
uspace/lib/net/include/il_remote.h
r55091847 r6b82009 41 41 #include <ipc/services.h> 42 42 #include <sys/types.h> 43 44 43 #include <net/device.h> 45 44 #include <net/packet.h> 45 #include <async.h> 46 46 47 47 /** @name Internetwork layer module interface … … 50 50 /*@{*/ 51 51 52 extern int il_device_state_msg(int, device_id_t, device_state_t, services_t); 53 extern int il_received_msg(int, device_id_t, packet_t *, services_t); 54 extern int il_mtu_changed_msg(int, device_id_t, size_t, services_t); 52 extern int il_device_state_msg(async_sess_t *, device_id_t, device_state_t, 53 services_t); 54 extern int il_received_msg(async_sess_t *, device_id_t, packet_t *, services_t); 55 extern int il_mtu_changed_msg(async_sess_t *, device_id_t, size_t, services_t); 55 56 56 57 /*@}*/ -
uspace/lib/net/include/il_skel.h
r55091847 r6b82009 39 39 */ 40 40 41 #include <async.h>42 #include <fibril_synch.h>43 41 #include <ipc/services.h> 44 45 42 #include <adt/measured_strings.h> 46 43 #include <net/device.h> 47 44 #include <net/packet.h> 45 #include <async.h> 48 46 49 47 /** Module initialization. … … 51 49 * This has to be implemented in user code. 52 50 * 53 * @param[in] net_phone Networking module phone.51 * @param[in] sess Networking module session. 54 52 * 55 53 * @return EOK on success. … … 58 56 * 59 57 */ 60 extern int il_initialize( int net_phone);58 extern int il_initialize(async_sess_t *sess); 61 59 62 60 /** Process the internetwork layer module message. … … 76 74 ipc_call_t *answer, size_t *answer_count); 77 75 78 extern int il_module_start( int);76 extern int il_module_start(sysarg_t); 79 77 80 78 #endif -
uspace/lib/net/include/ip_interface.h
r55091847 r6b82009 35 35 36 36 #include <net/socket_codes.h> 37 #include <async.h>38 37 #include <ipc/services.h> 39 40 38 #include <net/device.h> 41 39 #include <net/packet.h> 42 43 40 #include <net/in.h> 44 41 #include <net/ip_codes.h> 45 46 42 #include <ip_remote.h> 43 #include <async.h> 47 44 48 45 #define ip_received_error_msg ip_received_error_msg_remote … … 61 58 /** The transport layer notification function type definition. 62 59 * 63 * Notif iesthe transport layer modules about the received packet/s.60 * Notify the transport layer modules about the received packet/s. 64 61 * 65 * @param[in] device_id The device identifier. 66 * @param[in] packet The received packet or the received packet queue. 67 * @param[in] receiver The receiving module service. 68 * @param[in] error The packet error reporting service. Prefixes the 69 * received packet. 70 * @return EOK on success. 62 * @param[in] device_id Device identifier. 63 * @param[in] packet Received packet or the received packet queue. 64 * @param[in] receiver Receiving module service. 65 * @param[in] error Packet error reporting service. Prefixes the 66 * received packet. 67 * 68 * @return EOK on success. 69 * 71 70 */ 72 71 typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t *packet, 73 72 services_t receiver, services_t error); 74 73 75 extern intip_bind_service(services_t, int, services_t, async_client_conn_t);76 extern intip_connect_module(services_t);74 extern async_sess_t *ip_bind_service(services_t, int, services_t, async_client_conn_t); 75 extern async_sess_t *ip_connect_module(services_t); 77 76 78 77 /*@}*/ -
uspace/lib/net/include/ip_remote.h
r55091847 r6b82009 35 35 36 36 #include <ipc/services.h> 37 38 37 #include <net/ip_codes.h> 39 38 #include <net/inet.h> … … 42 41 #include <net/device.h> 43 42 #include <net/socket.h> 43 #include <async.h> 44 44 45 extern int ip_set_gateway_req_remote(int, device_id_t, in_addr_t); 46 extern int ip_packet_size_req_remote(int, device_id_t, packet_dimension_t *); 47 extern int ip_received_error_msg_remote(int, device_id_t, packet_t *, services_t, 48 services_t); 49 extern int ip_device_req_remote(int, device_id_t, services_t); 50 extern int ip_add_route_req_remote(int, device_id_t, in_addr_t, in_addr_t, 51 in_addr_t); 52 extern int ip_send_msg_remote(int, device_id_t, packet_t *, services_t, 53 services_t); 54 extern int ip_get_route_req_remote(int, ip_protocol_t, const struct sockaddr *, 55 socklen_t, device_id_t *, void **, size_t *); 45 extern int ip_set_gateway_req_remote(async_sess_t *, device_id_t, in_addr_t); 46 extern int ip_packet_size_req_remote(async_sess_t *, device_id_t, 47 packet_dimension_t *); 48 extern int ip_received_error_msg_remote(async_sess_t *, device_id_t, packet_t *, 49 services_t, services_t); 50 extern int ip_device_req_remote(async_sess_t *, device_id_t); 51 extern int ip_add_route_req_remote(async_sess_t *, device_id_t, in_addr_t, 52 in_addr_t, in_addr_t); 53 extern int ip_send_msg_remote(async_sess_t *, device_id_t, packet_t *, 54 services_t, services_t); 55 extern int ip_get_route_req_remote(async_sess_t *, ip_protocol_t, 56 const struct sockaddr *, socklen_t, device_id_t *, void **, size_t *); 56 57 57 58 #endif -
uspace/lib/net/include/net_interface.h
r55091847 r6b82009 38 38 #include <net/device.h> 39 39 #include <adt/measured_strings.h> 40 #include <async.h> 40 41 41 42 /** @name Networking module interface … … 44 45 /*@{*/ 45 46 46 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **, 47 size_t, uint8_t **); 48 extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **); 47 extern int net_get_device_conf_req(async_sess_t *, device_id_t, 48 measured_string_t **, size_t, uint8_t **); 49 extern int net_get_conf_req(async_sess_t *, measured_string_t **, size_t, 50 uint8_t **); 49 51 extern void net_free_settings(measured_string_t *, uint8_t *); 50 extern intnet_connect_module(void);52 extern async_sess_t *net_connect_module(void); 51 53 52 54 /*@}*/ -
uspace/lib/net/include/netif_remote.h
r55091847 r6b82009 34 34 #define LIBNET_NETIF_REMOTE_H_ 35 35 36 #include <async.h>37 36 #include <ipc/services.h> 38 37 #include <adt/measured_strings.h> 39 40 38 #include <net/device.h> 41 39 #include <net/packet.h> 40 #include <async.h> 42 41 43 extern int netif_get_addr_req( int, device_id_t, measured_string_t **,42 extern int netif_get_addr_req(async_sess_t *, device_id_t, measured_string_t **, 44 43 uint8_t **); 45 extern int netif_probe_req( int, device_id_t, int, void *);46 extern int netif_send_msg( int, device_id_t, packet_t *, services_t);47 extern int netif_start_req( int, device_id_t);48 extern int netif_stop_req( int, device_id_t);49 extern int netif_stats_req( int, device_id_t, device_stats_t *);50 extern intnetif_bind_service(services_t, device_id_t, services_t,44 extern int netif_probe_req(async_sess_t *, device_id_t, int, void *); 45 extern int netif_send_msg(async_sess_t *, device_id_t, packet_t *, services_t); 46 extern int netif_start_req(async_sess_t *, device_id_t); 47 extern int netif_stop_req(async_sess_t *, device_id_t); 48 extern int netif_stats_req(async_sess_t *, device_id_t, device_stats_t *); 49 extern async_sess_t *netif_bind_service(services_t, device_id_t, services_t, 51 50 async_client_conn_t); 52 51 -
uspace/lib/net/include/netif_skel.h
r55091847 r6b82009 39 39 #define NET_NETIF_SKEL_H_ 40 40 41 #include <async.h>42 41 #include <fibril_synch.h> 43 42 #include <ipc/services.h> 44 45 43 #include <adt/measured_strings.h> 46 44 #include <net/device.h> 47 45 #include <net/packet.h> 46 #include <async.h> 48 47 49 48 /** Network interface device specific data. */ 50 49 typedef struct { 51 device_id_t device_id; /**< Device identifier. */ 52 int nil_phone; /**< Receiving network interface layer phone. */ 53 device_state_t state; /**< Actual device state. */ 54 void *specific; /**< Driver specific data. */ 50 device_id_t device_id; /**< Device identifier. */ 51 device_state_t state; /**< Actual device state. */ 52 void *specific; /**< Driver specific data. */ 55 53 } netif_device_t; 56 54 … … 65 63 /** Network interface module skeleton global data. */ 66 64 typedef struct { 67 int net_phone; /**< Networking module phone. */ 65 async_sess_t *sess; /**< Networking module session. */ 66 async_sess_t *nil_sess; /**< Network interface layer session. */ 68 67 netif_device_map_t device_map; /**< Device map. */ 69 68 fibril_rwlock_t lock; /**< Safety lock. */ … … 127 126 * @return Other error codes as defined for the specific module 128 127 * message implementation. 129 130 128 * 131 129 */ … … 207 205 extern packet_t *netif_packet_get_1(size_t); 208 206 209 extern int netif_module_start( void);207 extern int netif_module_start(sysarg_t); 210 208 211 209 #endif -
uspace/lib/net/include/nil_remote.h
r55091847 r6b82009 38 38 #include <net/packet.h> 39 39 #include <generic.h> 40 #include <async.h> 40 41 41 42 #define nil_bind_service(service, device_id, me, receiver) \ 42 43 bind_service(service, device_id, me, 0, receiver) 43 44 44 #define nil_packet_size_req( nil_phone, device_id, packet_dimension) \45 generic_packet_size_req_remote( nil_phone, NET_NIL_PACKET_SPACE, \45 #define nil_packet_size_req(sess, device_id, packet_dimension) \ 46 generic_packet_size_req_remote(sess, NET_NIL_PACKET_SPACE, \ 46 47 device_id, packet_dimension) 47 48 48 #define nil_get_addr_req( nil_phone, device_id, address, data) \49 generic_get_addr_req( nil_phone, NET_NIL_ADDR, device_id, address, data)49 #define nil_get_addr_req(sess, device_id, address, data) \ 50 generic_get_addr_req(sess, NET_NIL_ADDR, device_id, address, data) 50 51 51 #define nil_get_broadcast_addr_req( nil_phone, device_id, address, data) \52 generic_get_addr_req( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, \52 #define nil_get_broadcast_addr_req(sess, device_id, address, data) \ 53 generic_get_addr_req(sess, NET_NIL_BROADCAST_ADDR, device_id, \ 53 54 address, data) 54 55 55 #define nil_send_msg( nil_phone, device_id, packet, sender) \56 generic_send_msg_remote( nil_phone, NET_NIL_SEND, device_id, \56 #define nil_send_msg(sess, device_id, packet, sender) \ 57 generic_send_msg_remote(sess, NET_NIL_SEND, device_id, \ 57 58 packet_get_id(packet), sender, 0) 58 59 59 #define nil_device_req(nil_phone, device_id, mtu, netif_service) \ 60 generic_device_req_remote(nil_phone, NET_NIL_DEVICE, device_id, mtu, \ 61 netif_service) 60 #define nil_device_req(sess, device_id, mtu) \ 61 generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, 0)\ 62 62 63 extern int nil_device_state_msg(int, device_id_t, int); 64 extern int nil_received_msg(int, device_id_t, packet_t *, services_t); 63 extern int nil_device_state_msg(async_sess_t *, device_id_t, sysarg_t); 64 extern int nil_received_msg(async_sess_t *, device_id_t, packet_t *, 65 services_t); 65 66 66 67 #endif -
uspace/lib/net/include/nil_skel.h
r55091847 r6b82009 39 39 #define LIBNET_NIL_SKEL_H_ 40 40 41 #include <async.h>42 #include <fibril_synch.h>43 41 #include <ipc/services.h> 44 45 42 #include <adt/measured_strings.h> 46 43 #include <net/device.h> 47 44 #include <net/packet.h> 45 #include <async.h> 48 46 49 47 /** Module initialization. … … 51 49 * This has to be implemented in user code. 52 50 * 53 * @param[in] net_phone Networking module phone.51 * @param[in] sess Networking module session. 54 52 * 55 53 * @return EOK on success. … … 58 56 * 59 57 */ 60 extern int nil_initialize( int net_phone);58 extern int nil_initialize(async_sess_t *sess); 61 59 62 60 /** Notify the network interface layer about the device state change. … … 64 62 * This has to be implemented in user code. 65 63 * 66 * @param[in] nil_phone Network interface layer phone.67 64 * @param[in] device_id Device identifier. 68 65 * @param[in] state New device state. … … 73 70 * 74 71 */ 75 extern int nil_device_state_msg_local( int, device_id_t, int);72 extern int nil_device_state_msg_local(device_id_t device_id, sysarg_t state); 76 73 77 74 /** Pass the packet queue to the network interface layer. … … 82 79 * This has to be implemented in user code. 83 80 * 84 * @param[in] nil_phone Network interface layer phone.85 81 * @param[in] device_id Source device identifier. 86 82 * @param[in] packet Received packet or the received packet queue. … … 92 88 * 93 89 */ 94 extern int nil_received_msg_local(int, device_id_t, packet_t *, services_t); 90 extern int nil_received_msg_local(device_id_t device_id, packet_t *packet, 91 services_t target); 95 92 96 93 /** Message processing function. … … 98 95 * This has to be implemented in user code. 99 96 * 100 * @param[in] name Module name.101 97 * @param[in] callid Message identifier. 102 98 * @param[in] call Message parameters. … … 112 108 * 113 109 */ 114 extern int nil_module_message(ipc_callid_t , ipc_call_t *, ipc_call_t *,115 size_t *);110 extern int nil_module_message(ipc_callid_t callid, ipc_call_t *call, 111 ipc_call_t *answer, size_t *count); 116 112 117 extern int nil_module_start( int);113 extern int nil_module_start(sysarg_t); 118 114 119 115 #endif -
uspace/lib/net/include/packet_client.h
r55091847 r6b82009 49 49 50 50 #include <net/packet.h> 51 #include <async.h> 51 52 52 53 /** @name Packet client interface */ … … 108 109 extern int packet_get_addr(const packet_t *, uint8_t **, uint8_t **); 109 110 extern int packet_set_addr(packet_t *, const uint8_t *, const uint8_t *, size_t); 110 extern packet_t *packet_get_copy( int, packet_t *);111 extern packet_t *packet_get_copy(async_sess_t *, packet_t *); 111 112 112 113 /*@}*/ -
uspace/lib/net/include/packet_remote.h
r55091847 r6b82009 36 36 #include <net/packet.h> 37 37 #include <sys/types.h> 38 #include <async.h> 38 39 39 extern int packet_translate_remote(int, packet_t **, packet_id_t); 40 extern packet_t *packet_get_4_remote(int, size_t, size_t, size_t, size_t); 41 extern packet_t *packet_get_1_remote(int, size_t); 42 extern void pq_release_remote(int, packet_id_t); 40 extern int packet_translate_remote(async_sess_t *, packet_t **, packet_id_t); 41 extern packet_t *packet_get_4_remote(async_sess_t *, size_t, size_t, size_t, 42 size_t); 43 extern packet_t *packet_get_1_remote(async_sess_t *, size_t); 44 extern void pq_release_remote(async_sess_t *, packet_id_t); 43 45 44 46 #endif -
uspace/lib/net/include/socket_core.h
r55091847 r6b82009 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 45 45 #include <net/device.h> 46 46 #include <net/packet.h> 47 #include <async.h> 47 48 48 49 /** Initial size of the received packet queue. */ 49 #define SOCKET_INITIAL_RECEIVED_SIZE 50 #define SOCKET_INITIAL_RECEIVED_SIZE 4 50 51 51 52 /** Maximum size of the received packet queue. */ 52 #define SOCKET_MAX_RECEIVED_SIZE 53 #define SOCKET_MAX_RECEIVED_SIZE 0 53 54 54 55 /** Initial size of the sockets for acceptance queue. */ 55 #define SOCKET_INITIAL_ACCEPTED_SIZE 56 #define SOCKET_INITIAL_ACCEPTED_SIZE 1 56 57 57 58 /** Maximum size of the sockets for acceptance queue. */ 58 #define SOCKET_MAX_ACCEPTEDED_SIZE 59 #define SOCKET_MAX_ACCEPTEDED_SIZE 0 59 60 60 61 /** Listening sockets' port map key. */ 61 #define SOCKET_MAP_KEY_LISTENING 62 #define SOCKET_MAP_KEY_LISTENING "L" 62 63 63 64 /** Type definition of the socket core. … … 75 76 /** Socket identifier. */ 76 77 int socket_id; 77 /** Client application phone. */78 int phone;78 /** Client application session. */ 79 async_sess_t *sess; 79 80 /** Bound port. */ 80 81 int port; … … 108 109 INT_MAP_DECLARE(socket_ports, socket_port_t); 109 110 110 extern void socket_cores_release( int, socket_cores_t *, socket_ports_t *,111 void (*)(socket_core_t *));111 extern void socket_cores_release(async_sess_t *, socket_cores_t *, 112 socket_ports_t *, void (*)(socket_core_t *)); 112 113 extern int socket_bind(socket_cores_t *, socket_ports_t *, int, void *, size_t, 113 114 int, int, int); 114 115 extern int socket_bind_free_port(socket_ports_t *, socket_core_t *, int, int, 115 116 int); 116 extern int socket_create(socket_cores_t *, int, void *, int *);117 extern int socket_destroy( int, int, socket_cores_t *, socket_ports_t *,118 void (*)(socket_core_t *));117 extern int socket_create(socket_cores_t *, async_sess_t *, void *, int *); 118 extern int socket_destroy(async_sess_t *, int, socket_cores_t *, 119 socket_ports_t *, void (*)(socket_core_t *)); 119 120 extern int socket_reply_packets(packet_t *, size_t *); 120 121 extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *, -
uspace/lib/net/include/tl_common.h
r55091847 r6b82009 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 39 39 40 40 #include <ipc/services.h> 41 42 41 #include <net/socket_codes.h> 43 42 #include <net/packet.h> 44 43 #include <net/device.h> 45 44 #include <net/inet.h> 45 #include <async.h> 46 46 47 47 /** Device packet dimensions. … … 51 51 DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t); 52 52 53 extern int tl_get_ip_packet_dimension( int, packet_dimensions_t *,53 extern int tl_get_ip_packet_dimension(async_sess_t *, packet_dimensions_t *, 54 54 device_id_t, packet_dimension_t **); 55 55 extern int tl_get_address_port(const struct sockaddr *, int, uint16_t *); … … 57 57 size_t); 58 58 extern int tl_set_address_port(struct sockaddr *, int, uint16_t); 59 extern int tl_prepare_icmp_packet(int, int, packet_t *, services_t); 60 extern int tl_socket_read_packet_data(int, packet_t **, size_t, 59 extern int tl_prepare_icmp_packet(async_sess_t *, async_sess_t *, packet_t *, 60 services_t); 61 extern int tl_socket_read_packet_data(async_sess_t *, packet_t **, size_t, 61 62 const packet_dimension_t *, const struct sockaddr *, socklen_t); 62 63 … … 65 66 /** @} 66 67 */ 67 -
uspace/lib/net/include/tl_remote.h
r55091847 r6b82009 38 38 #define LIBNET_TL_REMOTE_H_ 39 39 40 #include <async.h>41 40 #include <ipc/services.h> 42 41 #include <ipc/tl.h> 43 44 42 #include <generic.h> 45 43 #include <net/device.h> 46 44 #include <net/packet.h> 47 45 #include <packet_client.h> 46 #include <async.h> 48 47 49 48 /** @name Transport layer module interface … … 52 51 /*@{*/ 53 52 54 extern int tl_received_msg( int, device_id_t, packet_t *, services_t,53 extern int tl_received_msg(async_sess_t *, device_id_t, packet_t *, services_t, 55 54 services_t); 56 55 -
uspace/lib/net/include/tl_skel.h
r55091847 r6b82009 39 39 */ 40 40 41 #include <async.h>42 41 #include <fibril_synch.h> 43 42 #include <ipc/services.h> 44 45 43 #include <adt/measured_strings.h> 46 44 #include <net/device.h> 47 45 #include <net/packet.h> 46 #include <async.h> 48 47 49 48 /** Module initialization. … … 51 50 * This has to be implemented in user code. 52 51 * 53 * @param[in] net_phone Networking module phone.52 * @param[in] sess Networking module session. 54 53 * 55 54 * @return EOK on success. … … 58 57 * 59 58 */ 60 extern int tl_initialize( int net_phone);59 extern int tl_initialize(async_sess_t *sess); 61 60 62 61 /** Per-connection module initialization. … … 83 82 ipc_call_t *, size_t *); 84 83 85 extern int tl_module_start( int);84 extern int tl_module_start(sysarg_t); 86 85 87 86 #endif -
uspace/lib/net/netif/netif_remote.c
r55091847 r6b82009 38 38 #include <packet_client.h> 39 39 #include <generic.h> 40 #include <async_obsolete.h>41 40 #include <ipc/services.h> 42 41 #include <ipc/netif.h> 43 44 42 #include <net/modules.h> 45 43 #include <adt/measured_strings.h> … … 49 47 /** Return the device local hardware address. 50 48 * 51 * @param[in] netif_phone Network interface phone.52 * @param[in] device_id 53 * @param[out] address 54 * @param[out] data 49 * @param[in] sess Network interface session. 50 * @param[in] device_id Device identifier. 51 * @param[out] address Device local hardware address. 52 * @param[out] data Address data. 55 53 * 56 54 * @return EOK on success. … … 61 59 * 62 60 */ 63 int netif_get_addr_req( int netif_phone, device_id_t device_id,61 int netif_get_addr_req(async_sess_t *sess, device_id_t device_id, 64 62 measured_string_t **address, uint8_t **data) 65 63 { 66 return generic_get_addr_req( netif_phone, NET_NETIF_GET_ADDR, device_id,64 return generic_get_addr_req(sess, NET_NETIF_GET_ADDR, device_id, 67 65 address, data); 68 66 } … … 70 68 /** Probe the existence of the device. 71 69 * 72 * @param[in] netif_phone Network interface phone.73 * @param[in] device_id 74 * @param[in] irq 75 * @param[in] io 70 * @param[in] sess Network interface session. 71 * @param[in] device_id Device identifier. 72 * @param[in] irq Device interrupt number. 73 * @param[in] io Device input/output address. 76 74 * 77 75 * @return EOK on success. … … 80 78 * 81 79 */ 82 int netif_probe_req( int netif_phone, device_id_t device_id, int irq, void *io)80 int netif_probe_req(async_sess_t *sess, device_id_t device_id, int irq, void *io) 83 81 { 84 return async_obsolete_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, 82 async_exch_t *exch = async_exchange_begin(sess); 83 int rc = async_req_3_0(exch, NET_NETIF_PROBE, device_id, (sysarg_t) irq, 85 84 (sysarg_t) io); 85 async_exchange_end(exch); 86 87 return rc; 86 88 } 87 89 88 90 /** Send the packet queue. 89 91 * 90 * @param[in] netif_phone Network interface phone.91 * @param[in] device_id 92 * @param[in] packet 93 * @param[in] sender 92 * @param[in] sess Network interface session. 93 * @param[in] device_id Device identifier. 94 * @param[in] packet Packet queue. 95 * @param[in] sender Sending module service. 94 96 * 95 97 * @return EOK on success. … … 98 100 * 99 101 */ 100 int netif_send_msg( int netif_phone, device_id_t device_id, packet_t *packet,102 int netif_send_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet, 101 103 services_t sender) 102 104 { 103 return generic_send_msg_remote( netif_phone, NET_NETIF_SEND, device_id,105 return generic_send_msg_remote(sess, NET_NETIF_SEND, device_id, 104 106 packet_get_id(packet), sender, 0); 105 107 } … … 107 109 /** Start the device. 108 110 * 109 * @param[in] netif_phone Network interface phone.110 * @param[in] device_id 111 * @param[in] sess Network interface session. 112 * @param[in] device_id Device identifier. 111 113 * 112 114 * @return EOK on success. … … 117 119 * 118 120 */ 119 int netif_start_req( int netif_phone, device_id_t device_id)121 int netif_start_req(async_sess_t *sess, device_id_t device_id) 120 122 { 121 return async_obsolete_req_1_0(netif_phone, NET_NETIF_START, device_id); 123 async_exch_t *exch = async_exchange_begin(sess); 124 int rc = async_req_1_0(exch, NET_NETIF_START, device_id); 125 async_exchange_end(exch); 126 127 return rc; 122 128 } 123 129 124 130 /** Stop the device. 125 131 * 126 * @param[in] netif_phone Network interface phone.127 * @param[in] device_id 132 * @param[in] sess Network interface session. 133 * @param[in] device_id Device identifier. 128 134 * 129 135 * @return EOK on success. … … 134 140 * 135 141 */ 136 int netif_stop_req( int netif_phone, device_id_t device_id)142 int netif_stop_req(async_sess_t *sess, device_id_t device_id) 137 143 { 138 return async_obsolete_req_1_0(netif_phone, NET_NETIF_STOP, device_id); 144 async_exch_t *exch = async_exchange_begin(sess); 145 int rc = async_req_1_0(exch, NET_NETIF_STOP, device_id); 146 async_exchange_end(exch); 147 148 return rc; 139 149 } 140 150 141 151 /** Return the device usage statistics. 142 152 * 143 * @param[in] netif_phone Network interface phone.144 * @param[in] device_idDevice identifier.145 * @param[out] stats 153 * @param[in] sess Network interface session. 154 * @param[in] device_id Device identifier. 155 * @param[out] stats Device usage statistics. 146 156 * 147 157 * @return EOK on success. 148 158 * 149 159 */ 150 int netif_stats_req( int netif_phone, device_id_t device_id,160 int netif_stats_req(async_sess_t *sess, device_id_t device_id, 151 161 device_stats_t *stats) 152 162 { … … 154 164 return EBADMEM; 155 165 156 aid_t message_id = async_obsolete_send_1(netif_phone, NET_NETIF_STATS, 166 async_exch_t *exch = async_exchange_begin(sess); 167 aid_t message_id = async_send_1(exch, NET_NETIF_STATS, 157 168 (sysarg_t) device_id, NULL); 158 async_obsolete_data_read_start(netif_phone, stats, sizeof(*stats)); 169 async_data_read_start(exch, stats, sizeof(*stats)); 170 async_exchange_end(exch); 159 171 160 172 sysarg_t result; … … 169 181 * register the message receiver. 170 182 * 171 * @param[in] service The network interface module service.172 * @param[in] device_id The device identifier.173 * @param[in] me The requesting module service.174 * @param[in] receiver The message receiver.183 * @param[in] service Network interface module service. 184 * @param[in] device_id Device identifier. 185 * @param[in] me Requesting module service. 186 * @param[in] receiver Message receiver. 175 187 * 176 * @return The phone of the needed service. 177 * @return EOK on success. 178 * @return Other error codes as defined for the bind_service() 179 * function. 188 * @return Session to the needed service. 189 * @return NULL on failure. 180 190 * 181 191 */ 182 intnetif_bind_service(services_t service, device_id_t device_id,192 async_sess_t *netif_bind_service(services_t service, device_id_t device_id, 183 193 services_t me, async_client_conn_t receiver) 184 194 { -
uspace/lib/net/netif/netif_skel.c
r55091847 r6b82009 54 54 #include <nil_remote.h> 55 55 56 // FIXME: remove this header57 #include <kernel/ipc/ipc_methods.h>58 59 56 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); 60 57 … … 64 61 /** Probe the existence of the device. 65 62 * 66 * @param[in] netif_phone Network interface phone.67 63 * @param[in] device_id Device identifier. 68 64 * @param[in] irq Device interrupt number. … … 74 70 * 75 71 */ 76 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 77 int irq, void *io) 72 static int netif_probe_req_local(device_id_t device_id, int irq, void *io) 78 73 { 79 74 fibril_rwlock_write_lock(&netif_globals.lock); … … 86 81 /** Send the packet queue. 87 82 * 88 * @param[in] netif_phone Network interface phone.89 83 * @param[in] device_id Device identifier. 90 84 * @param[in] packet Packet queue. … … 96 90 * 97 91 */ 98 static int netif_send_msg_local( int netif_phone, device_id_t device_id,99 packet_t *packet,services_t sender)92 static int netif_send_msg_local(device_id_t device_id, packet_t *packet, 93 services_t sender) 100 94 { 101 95 fibril_rwlock_write_lock(&netif_globals.lock); … … 108 102 /** Start the device. 109 103 * 110 * @param[in] netif_phone Network interface phone.111 104 * @param[in] device_id Device identifier. 112 105 * … … 118 111 * 119 112 */ 120 static int netif_start_req_local( int netif_phone,device_id_t device_id)113 static int netif_start_req_local(device_id_t device_id) 121 114 { 122 115 fibril_rwlock_write_lock(&netif_globals.lock); … … 131 124 int result = netif_start_message(device); 132 125 if (result > NETIF_NULL) { 133 int phone = device->nil_phone; 134 nil_device_state_msg(phone, device_id, result); 126 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 135 127 fibril_rwlock_write_unlock(&netif_globals.lock); 136 128 return EOK; … … 144 136 /** Stop the device. 145 137 * 146 * @param[in] netif_phone Network interface phone.147 138 * @param[in] device_id Device identifier. 148 139 * … … 154 145 * 155 146 */ 156 static int netif_stop_req_local( int netif_phone,device_id_t device_id)147 static int netif_stop_req_local(device_id_t device_id) 157 148 { 158 149 fibril_rwlock_write_lock(&netif_globals.lock); … … 167 158 int result = netif_stop_message(device); 168 159 if (result > NETIF_NULL) { 169 int phone = device->nil_phone; 170 nil_device_state_msg(phone, device_id, result); 160 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 171 161 fibril_rwlock_write_unlock(&netif_globals.lock); 172 162 return EOK; … … 222 212 void netif_pq_release(packet_id_t packet_id) 223 213 { 224 pq_release_remote(netif_globals. net_phone, packet_id);214 pq_release_remote(netif_globals.sess, packet_id); 225 215 } 226 216 … … 235 225 packet_t *netif_packet_get_1(size_t content) 236 226 { 237 return packet_get_1_remote(netif_globals.net_phone, content); 238 } 239 240 /** Register the device notification receiver, 241 * 242 * Register a network interface layer module as the device 243 * notification receiver. 244 * 245 * @param[in] device_id Device identifier. 246 * @param[in] phone Network interface layer module phone. 247 * 248 * @return EOK on success. 249 * @return ENOENT if there is no such device. 250 * @return ELIMIT if there is another module registered. 251 * 252 */ 253 static int register_message(device_id_t device_id, int phone) 254 { 255 netif_device_t *device; 256 int rc = find_device(device_id, &device); 257 if (rc != EOK) 258 return rc; 259 260 if (device->nil_phone >= 0) 261 return ELIMIT; 262 263 device->nil_phone = phone; 264 return EOK; 227 return packet_get_1_remote(netif_globals.sess, content); 265 228 } 266 229 … … 296 259 switch (IPC_GET_IMETHOD(*call)) { 297 260 case NET_NETIF_PROBE: 298 return netif_probe_req_local( 0,IPC_GET_DEVICE(*call),261 return netif_probe_req_local(IPC_GET_DEVICE(*call), 299 262 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 300 263 301 case IPC_M_CONNECT_TO_ME:302 fibril_rwlock_write_lock(&netif_globals.lock);303 304 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));305 306 fibril_rwlock_write_unlock(&netif_globals.lock);307 return rc;308 309 264 case NET_NETIF_SEND: 310 rc = packet_translate_remote(netif_globals. net_phone, &packet,265 rc = packet_translate_remote(netif_globals.sess, &packet, 311 266 IPC_GET_PACKET(*call)); 312 267 if (rc != EOK) 313 268 return rc; 314 269 315 return netif_send_msg_local( 0,IPC_GET_DEVICE(*call), packet,270 return netif_send_msg_local(IPC_GET_DEVICE(*call), packet, 316 271 IPC_GET_SENDER(*call)); 317 272 318 273 case NET_NETIF_START: 319 return netif_start_req_local( 0,IPC_GET_DEVICE(*call));274 return netif_start_req_local(IPC_GET_DEVICE(*call)); 320 275 321 276 case NET_NETIF_STATS: … … 343 298 344 299 case NET_NETIF_STOP: 345 return netif_stop_req_local( 0,IPC_GET_DEVICE(*call));300 return netif_stop_req_local(IPC_GET_DEVICE(*call)); 346 301 347 302 case NET_NETIF_GET_ADDR: … … 403 358 * messages in an infinite loop. 404 359 * 360 * @param[in] nil_service Network interface layer service. 361 * 405 362 * @return EOK on success. 406 363 * @return Other error codes as defined for each specific module … … 408 365 * 409 366 */ 410 int netif_module_start( void)367 int netif_module_start(sysarg_t nil_service) 411 368 { 412 369 async_set_client_connection(netif_client_connection); 413 370 414 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 371 netif_globals.sess = connect_to_service(SERVICE_NETWORKING); 372 netif_globals.nil_sess = connect_to_service(nil_service); 415 373 netif_device_map_initialize(&netif_globals.device_map); 416 374 -
uspace/lib/net/nil/nil_remote.c
r55091847 r6b82009 45 45 /** Notify the network interface layer about the device state change. 46 46 * 47 * @param[in] nil_phone Network interface layer phone.47 * @param[in] sess Network interface layer session. 48 48 * @param[in] device_id Device identifier. 49 49 * @param[in] state New device state. … … 54 54 * 55 55 */ 56 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state) 56 int nil_device_state_msg(async_sess_t *sess, device_id_t device_id, 57 sysarg_t state) 57 58 { 58 return generic_device_state_msg_remote( nil_phone, NET_NIL_DEVICE_STATE,59 return generic_device_state_msg_remote(sess, NET_NIL_DEVICE_STATE, 59 60 device_id, state, 0); 60 61 } … … 65 66 * upper layers. 66 67 * 67 * @param[in] nil_phone Network interface layer phone.68 * @param[in] sess Network interface layer session. 68 69 * @param[in] device_id Source device identifier. 69 70 * @param[in] packet Received packet or the received packet queue. … … 75 76 * 76 77 */ 77 int nil_received_msg( int nil_phone, device_id_t device_id,78 int nil_received_msg(async_sess_t *sess, device_id_t device_id, 78 79 packet_t *packet, services_t target) 79 80 { 80 return generic_received_msg_remote( nil_phone, NET_NIL_RECEIVED,81 return generic_received_msg_remote(sess, NET_NIL_RECEIVED, 81 82 device_id, packet_get_id(packet), target, 0); 82 83 } -
uspace/lib/net/nil/nil_skel.c
r55091847 r6b82009 38 38 #include <bool.h> 39 39 #include <errno.h> 40 #include <ns.h> 40 41 #include <nil_skel.h> 41 42 #include <net_interface.h> 42 43 #include <net/modules.h> 43 #include <async_obsolete.h>44 45 // FIXME: remove this header46 #include <kernel/ipc/ipc_methods.h>47 44 48 45 /** Default thread for new connections. … … 100 97 * @return Other error codes as defined for the nil_initialize() 101 98 * function. 102 * @return Other error codes as defined for the REGISTER_ME() macro103 * function.104 99 * 105 100 */ 106 int nil_module_start( int service)101 int nil_module_start(sysarg_t service) 107 102 { 108 103 async_set_client_connection(nil_client_connection); 109 int net_phone= net_connect_module();110 if ( net_phone < 0)111 return net_phone;104 async_sess_t *sess = net_connect_module(); 105 if (!sess) 106 return ENOENT; 112 107 113 108 int rc = pm_init(); … … 115 110 return rc; 116 111 117 rc = nil_initialize( net_phone);112 rc = nil_initialize(sess); 118 113 if (rc != EOK) 119 114 goto out; 120 115 121 rc = async_obsolete_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);116 rc = service_register(service); 122 117 if (rc != EOK) 123 118 goto out; -
uspace/lib/net/tl/icmp_remote.c
r55091847 r6b82009 39 39 #include <net/modules.h> 40 40 #include <packet_client.h> 41 42 #include <async.h>43 #include <async_obsolete.h>44 #include <errno.h>45 41 #include <ipc/services.h> 46 42 #include <ipc/icmp.h> 47 43 #include <sys/types.h> 44 #include <async.h> 45 #include <errno.h> 48 46 49 /** Send sthe Destination Unreachable error notification packet.47 /** Send the Destination Unreachable error notification packet. 50 48 * 51 49 * Beginning of the packet is sent as the notification packet data. … … 53 51 * packet. 54 52 * 55 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 56 * @param[in] code The error specific code. 57 * @param[in] mtu The error MTU value. 58 * @param[in] packet The original packet. 59 * @return EOK on success. 60 * @return EPERM if the ICMP error notifications are disabled. 61 * @return ENOMEM if there is not enough memory left. 53 * @param[in] sess ICMP module session. 54 * @param[in] code Error specific code. 55 * @param[in] mtu Error MTU value. 56 * @param[in] packet Original packet. 57 * 58 * @return EOK on success. 59 * @return EPERM if the ICMP error notifications are disabled. 60 * @return ENOMEM if there is not enough memory left. 61 * 62 62 */ 63 int 64 icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, 63 int icmp_destination_unreachable_msg(async_sess_t *sess, icmp_code_t code, 65 64 icmp_param_t mtu, packet_t *packet) 66 65 { 67 async_obsolete_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (sysarg_t) code, 66 async_exch_t *exch = async_exchange_begin(sess); 67 async_msg_3(exch, NET_ICMP_DEST_UNREACH, (sysarg_t) code, 68 68 (sysarg_t) packet_get_id(packet), (sysarg_t) mtu); 69 async_exchange_end(exch); 70 69 71 return EOK; 70 72 } 71 73 72 /** Send sthe Source Quench error notification packet.74 /** Send the Source Quench error notification packet. 73 75 * 74 76 * Beginning of the packet is sent as the notification packet data. … … 76 78 * packet. 77 79 * 78 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 79 * @param[in] packet The original packet. 80 * @return EOK on success. 81 * @return EPERM if the ICMP error notifications are disabled. 82 * @return ENOMEM if there is not enough memory left. 80 * @param[in] sess ICMP module session. 81 * @param[in] packet Original packet. 82 * 83 * @return EOK on success. 84 * @return EPERM if the ICMP error notifications are disabled. 85 * @return ENOMEM if there is not enough memory left. 86 * 83 87 */ 84 int icmp_source_quench_msg( int icmp_phone, packet_t *packet)88 int icmp_source_quench_msg(async_sess_t *sess, packet_t *packet) 85 89 { 86 async_obsolete_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, 90 async_exch_t *exch = async_exchange_begin(sess); 91 async_msg_2(exch, NET_ICMP_SOURCE_QUENCH, 0, 87 92 (sysarg_t) packet_get_id(packet)); 93 async_exchange_end(exch); 94 88 95 return EOK; 89 96 } 90 97 91 /** Send sthe Time Exceeded error notification packet.98 /** Send the Time Exceeded error notification packet. 92 99 * 93 100 * Beginning of the packet is sent as the notification packet data. … … 95 102 * packet. 96 103 * 97 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 98 * @param[in] code The error specific code. 99 * @param[in] packet The original packet. 100 * @return EOK on success. 101 * @return EPERM if the ICMP error notifications are disabled. 102 * @return ENOMEM if there is not enough memory left. 104 * @param[in] sess ICMP module session. 105 * @param[in] code Error specific code. 106 * @param[in] packet Original packet. 107 * 108 * @return EOK on success. 109 * @return EPERM if the ICMP error notifications are disabled. 110 * @return ENOMEM if there is not enough memory left. 111 * 103 112 */ 104 int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t *packet) 113 int icmp_time_exceeded_msg(async_sess_t *sess, icmp_code_t code, 114 packet_t *packet) 105 115 { 106 async_obsolete_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code, 116 async_exch_t *exch = async_exchange_begin(sess); 117 async_msg_2(exch, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code, 107 118 (sysarg_t) packet_get_id(packet)); 119 async_exchange_end(exch); 120 108 121 return EOK; 109 122 } 110 123 111 /** Send sthe Parameter Problem error notification packet.124 /** Send the Parameter Problem error notification packet. 112 125 * 113 126 * Beginning of the packet is sent as the notification packet data. … … 115 128 * packet. 116 129 * 117 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 118 * @param[in] code The error specific code. 119 * @param[in] pointer The problematic parameter offset. 120 * @param[in] packet The original packet. 121 * @return EOK on success. 122 * @return EPERM if the ICMP error notifications are disabled. 123 * @return ENOMEM if there is not enough memory left. 130 * @param[in] sess ICMP module session. 131 * @param[in] code Error specific code. 132 * @param[in] pointer Problematic parameter offset. 133 * @param[in] packet Original packet. 134 * 135 * @return EOK on success. 136 * @return EPERM if the ICMP error notifications are disabled. 137 * @return ENOMEM if there is not enough memory left. 138 * 124 139 */ 125 int icmp_parameter_problem_msg( int icmp_phone, icmp_code_t code,140 int icmp_parameter_problem_msg(async_sess_t *sess, icmp_code_t code, 126 141 icmp_param_t pointer, packet_t *packet) 127 142 { 128 async_obsolete_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (sysarg_t) code, 143 async_exch_t *exch = async_exchange_begin(sess); 144 async_msg_3(exch, NET_ICMP_PARAMETERPROB, (sysarg_t) code, 129 145 (sysarg_t) packet_get_id(packet), (sysarg_t) pointer); 146 async_exchange_end(exch); 147 130 148 return EOK; 131 149 } … … 133 151 /** @} 134 152 */ 135 -
uspace/lib/net/tl/socket_core.c
r55091847 r6b82009 38 38 #include <packet_client.h> 39 39 #include <packet_remote.h> 40 41 40 #include <net/socket_codes.h> 42 41 #include <net/in.h> … … 44 43 #include <net/packet.h> 45 44 #include <net/modules.h> 46 47 45 #include <stdint.h> 48 46 #include <stdlib.h> 49 47 #include <errno.h> 50 51 48 #include <adt/dynamic_fifo.h> 52 49 #include <adt/int_map.h> … … 56 53 * switching to the sequence. 57 54 */ 58 #define SOCKET_ID_TRIES 55 #define SOCKET_ID_TRIES 100 59 56 60 57 /** Bound port sockets.*/ … … 72 69 INT_MAP_IMPLEMENT(socket_ports, socket_port_t); 73 70 74 /** Destroy sthe socket.71 /** Destroy the socket. 75 72 * 76 73 * If the socket is bound, the port is released. 77 * Release s all buffered packets, calls the release function and removesthe74 * Release all buffered packets, call the release function and remove the 78 75 * socket from the local sockets. 79 76 * 80 * @param[in] packet_phone The packet server phone to release buffered packets.81 * @param[in] socket The socket to be destroyed.82 * @param[in,out] local_sockets The local sockets to be updated.83 * @param[in,out] global_sockets The global sockets to be updated.84 * @param[in] socket_release The client release callback function.85 * /86 static void 87 s ocket_destroy_core(int packet_phone, socket_core_t *socket,77 * @param[in] sess Packet server session. 78 * @param[in] socket Socket to be destroyed. 79 * @param[in,out] local_sockets Local sockets to be updated. 80 * @param[in,out] global_sockets Global sockets to be updated. 81 * @param[in] socket_release Client release callback function. 82 * 83 */ 84 static void socket_destroy_core(async_sess_t *sess, socket_core_t *socket, 88 85 socket_cores_t *local_sockets, socket_ports_t *global_sockets, 89 86 void (* socket_release)(socket_core_t *socket)) 90 87 { 91 int packet_id;92 93 88 /* If bound */ 94 89 if (socket->port) { … … 98 93 99 94 /* Release all received packets */ 95 int packet_id; 100 96 while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0) 101 pq_release_remote( packet_phone, packet_id);102 97 pq_release_remote(sess, packet_id); 98 103 99 dyn_fifo_destroy(&socket->received); 104 100 dyn_fifo_destroy(&socket->accepted); 105 101 106 102 if (socket_release) 107 103 socket_release(socket); 108 104 109 105 socket_cores_exclude(local_sockets, socket->socket_id, free); 110 106 } 111 107 112 /** Destroy slocal sockets.113 * 114 * Release s all buffered packets and callsthe release function for each of the108 /** Destroy local sockets. 109 * 110 * Release all buffered packets and call the release function for each of the 115 111 * sockets. 116 112 * 117 * @param[in] packet_phone The packet server phone to release buffered packets.118 * @param[in] local_sockets The local sockets to be destroyed.119 * @param[in,out] global_sockets The global sockets to be updated.120 * @param[in] socket_release The client release callback function.121 * /122 void 123 socket_cores_release(int packet_phone, socket_cores_t *local_sockets,113 * @param[in] sess Packet server session. 114 * @param[in] local_sockets Local sockets to be destroyed. 115 * @param[in,out] global_sockets Global sockets to be updated. 116 * @param[in] socket_release Client release callback function. 117 * 118 */ 119 void socket_cores_release(async_sess_t *sess, socket_cores_t *local_sockets, 124 120 socket_ports_t *global_sockets, 125 121 void (* socket_release)(socket_core_t *socket)) 126 122 { 127 int index;128 129 123 if (!socket_cores_is_valid(local_sockets)) 130 124 return; 131 125 132 126 local_sockets->magic = 0; 133 127 128 int index; 134 129 for (index = 0; index < local_sockets->next; ++index) { 135 130 if (socket_cores_item_is_valid(&local_sockets->items[index])) { 136 131 local_sockets->items[index].magic = 0; 137 132 138 133 if (local_sockets->items[index].value) { 139 socket_destroy_core( packet_phone,134 socket_destroy_core(sess, 140 135 local_sockets->items[index].value, 141 136 local_sockets, global_sockets, … … 146 141 } 147 142 } 148 143 149 144 free(local_sockets->items); 150 145 } … … 406 401 } 407 402 408 /** Creates a new socket. 409 * 410 * @param[in,out] local_sockets The local sockets to be updated. 411 * @param[in] app_phone The application phone. 412 * @param[in] specific_data The socket specific data. 413 * @param[in,out] socket_id The new socket identifier. A new identifier is 414 * chosen if set to zero or negative. A negative identifier 415 * is chosen if set to negative. 416 * @return EOK on success. 417 * @return EINVAL if the socket_id parameter is NULL. 418 * @return ENOMEM if there is not enough memory left. 419 */ 420 int 421 socket_create(socket_cores_t *local_sockets, int app_phone, 403 /** Create a new socket. 404 * 405 * @param[in,out] local_sockets Local sockets to be updated. 406 * @param[in] sess Application session. 407 * @param[in] specific_data Socket specific data. 408 * @param[in,out] socket_id New socket identifier. A new identifier 409 * is chosen if set to zero or negative. 410 * A negative identifier is chosen if set 411 * to negative. 412 * 413 * @return EOK on success. 414 * @return EINVAL if the socket_id parameter is NULL. 415 * @return ENOMEM if there is not enough memory left. 416 * 417 */ 418 int socket_create(socket_cores_t *local_sockets, async_sess_t* sess, 422 419 void *specific_data, int *socket_id) 423 420 { … … 446 443 447 444 /* Initialize */ 448 socket-> phone = app_phone;445 socket->sess = sess; 449 446 socket->port = -1; 450 447 socket->key = NULL; … … 475 472 } 476 473 477 /** Destroy sthe socket.474 /** Destroy the socket. 478 475 * 479 476 * If the socket is bound, the port is released. 480 * Release s all buffered packets, calls the release function and removesthe477 * Release all buffered packets, call the release function and remove the 481 478 * socket from the local sockets. 482 479 * 483 * @param[in] packet_phone The packet server phone to release buffered packets. 484 * @param[in] socket_id The socket identifier. 485 * @param[in,out] local_sockets The local sockets to be updated. 486 * @param[in,out] global_sockets The global sockets to be updated. 487 * @param[in] socket_release The client release callback function. 488 * @return EOK on success. 489 * @return ENOTSOCK if the socket is not found. 480 * @param[in] sess Packet server session. 481 * @param[in] socket_id Socket identifier. 482 * @param[in,out] local_sockets Local sockets to be updated. 483 * @param[in,out] global_sockets Global sockets to be updated. 484 * @param[in] socket_release Client release callback function. 485 * 486 * @return EOK on success. 487 * @return ENOTSOCK if the socket is not found. 488 * 490 489 */ 491 490 int 492 socket_destroy( int packet_phone, int socket_id, socket_cores_t *local_sockets,491 socket_destroy(async_sess_t *sess, int socket_id, socket_cores_t *local_sockets, 493 492 socket_ports_t *global_sockets, 494 493 void (*socket_release)(socket_core_t *socket)) 495 494 { 496 socket_core_t *socket;497 int accepted_id;498 499 495 /* Find the socket */ 500 socket = socket_cores_find(local_sockets, socket_id);496 socket_core_t *socket = socket_cores_find(local_sockets, socket_id); 501 497 if (!socket) 502 498 return ENOTSOCK; 503 499 504 500 /* Destroy all accepted sockets */ 501 int accepted_id; 505 502 while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0) 506 socket_destroy( packet_phone, accepted_id, local_sockets,503 socket_destroy(sess, accepted_id, local_sockets, 507 504 global_sockets, socket_release); 508 505 509 socket_destroy_core( packet_phone, socket, local_sockets, global_sockets,506 socket_destroy_core(sess, socket, local_sockets, global_sockets, 510 507 socket_release); 511 508 -
uspace/lib/net/tl/tl_common.c
r55091847 r6b82009 43 43 #include <ip_interface.h> 44 44 #include <tl_remote.h> 45 46 45 #include <net/socket_codes.h> 47 46 #include <net/in.h> … … 50 49 #include <net/device.h> 51 50 #include <net/packet.h> 52 53 51 #include <async.h> 54 52 #include <ipc/services.h> … … 107 105 * The reply is cached then. 108 106 * 109 * @param[in] ip_phone The IP moduel phone for (semi)remote calls. 110 * @param[in] packet_dimensions The packet dimensions cache. 111 * @param[in] device_id The device identifier. 112 * @param[out] packet_dimension The IP packet dimensions. 113 * @return EOK on success. 114 * @return EBADMEM if the packet_dimension parameter is NULL. 115 * @return ENOMEM if there is not enough memory left. 116 * @return EINVAL if the packet_dimensions cache is not valid. 117 * @return Other codes as defined for the ip_packet_size_req() 118 * function. 119 */ 120 int 121 tl_get_ip_packet_dimension(int ip_phone, 107 * @param[in] sess IP module session. 108 * @param[in] packet_dimensions Packet dimensions cache. 109 * @param[in] device_id Device identifier. 110 * @param[out] packet_dimension IP packet dimensions. 111 * 112 * @return EOK on success. 113 * @return EBADMEM if the packet_dimension parameter is NULL. 114 * @return ENOMEM if there is not enough memory left. 115 * @return EINVAL if the packet_dimensions cache is not valid. 116 * @return Other codes as defined for the ip_packet_size_req() 117 * function. 118 * 119 */ 120 int tl_get_ip_packet_dimension(async_sess_t *sess, 122 121 packet_dimensions_t *packet_dimensions, device_id_t device_id, 123 122 packet_dimension_t **packet_dimension) 124 123 { 125 int rc;126 127 124 if (!packet_dimension) 128 125 return EBADMEM; … … 133 130 /* Ask for and remember them if not found */ 134 131 *packet_dimension = malloc(sizeof(**packet_dimension)); 135 if (!*packet_dimension)132 if (!*packet_dimension) 136 133 return ENOMEM; 137 134 138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);135 int rc = ip_packet_size_req(sess, device_id, *packet_dimension); 139 136 if (rc != EOK) { 140 137 free(*packet_dimension); … … 236 233 /** Prepares the packet for ICMP error notification. 237 234 * 238 * Keeps the first packet and releases all the others. 239 * Releases all the packets on error. 240 * 241 * @param[in] packet_phone The packet server module phone. 242 * @param[in] icmp_phone The ICMP module phone. 243 * @param[in] packet The packet to be send. 244 * @param[in] error The packet error reporting service. Prefixes the 245 * received packet. 246 * @return EOK on success. 247 * @return ENOENT if no packet may be sent. 248 */ 249 int 250 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t *packet, 251 services_t error) 252 { 253 packet_t *next; 235 * Keep the first packet and release all the others. 236 * Release all the packets on error. 237 * 238 * @param[in] packet_sess Packet server module session. 239 * @param[in] icmp_sess ICMP module phone. 240 * @param[in] packet Packet to be send. 241 * @param[in] error Packet error reporting service. Prefixes the 242 * received packet. 243 * 244 * @return EOK on success. 245 * @return ENOENT if no packet may be sent. 246 * 247 */ 248 int tl_prepare_icmp_packet(async_sess_t *packet_sess, async_sess_t *icmp_sess, 249 packet_t *packet, services_t error) 250 { 251 /* Detach the first packet and release the others */ 252 packet_t *next = pq_detach(packet); 253 if (next) 254 pq_release_remote(packet_sess, packet_get_id(next)); 255 254 256 uint8_t *src; 255 int length; 256 257 /* Detach the first packet and release the others */ 258 next = pq_detach(packet); 259 if (next) 260 pq_release_remote(packet_phone, packet_get_id(next)); 261 262 length = packet_get_addr(packet, &src, NULL); 263 if ((length > 0) && (!error) && (icmp_phone >= 0) && 257 int length = packet_get_addr(packet, &src, NULL); 258 if ((length > 0) && (!error) && (icmp_sess) && 264 259 /* 265 260 * Set both addresses to the source one (avoids the source address … … 269 264 return EOK; 270 265 } else 271 pq_release_remote(packet_ phone, packet_get_id(packet));272 266 pq_release_remote(packet_sess, packet_get_id(packet)); 267 273 268 return ENOENT; 274 269 } … … 276 271 /** Receives data from the socket into a packet. 277 272 * 278 * @param[in] packet_phone The packet server module phone. 279 * @param[out] packet The new created packet. 280 * @param[in] prefix Reserved packet data prefix length. 281 * @param[in] dimension The packet dimension. 282 * @param[in] addr The destination address. 283 * @param[in] addrlen The address length. 284 * @return Number of bytes received. 285 * @return EINVAL if the client does not send data. 286 * @return ENOMEM if there is not enough memory left. 287 * @return Other error codes as defined for the 288 * async_data_read_finalize() function. 289 */ 290 int 291 tl_socket_read_packet_data(int packet_phone, packet_t **packet, size_t prefix, 292 const packet_dimension_t *dimension, const struct sockaddr *addr, 293 socklen_t addrlen) 273 * @param[in] sess Packet server module session. 274 * @param[out] packet New created packet. 275 * @param[in] prefix Reserved packet data prefix length. 276 * @param[in] dimension Packet dimension. 277 * @param[in] addr Destination address. 278 * @param[in] addrlen Address length. 279 * 280 * @return Number of bytes received. 281 * @return EINVAL if the client does not send data. 282 * @return ENOMEM if there is not enough memory left. 283 * @return Other error codes as defined for the 284 * async_data_read_finalize() function. 285 * 286 */ 287 int tl_socket_read_packet_data(async_sess_t *sess, packet_t **packet, 288 size_t prefix, const packet_dimension_t *dimension, 289 const struct sockaddr *addr, socklen_t addrlen) 294 290 { 295 291 ipc_callid_t callid; … … 306 302 307 303 /* Get a new packet */ 308 *packet = packet_get_4_remote( packet_phone, length, dimension->addr_len,304 *packet = packet_get_4_remote(sess, length, dimension->addr_len, 309 305 prefix + dimension->prefix, dimension->suffix); 310 306 if (!packet) … … 314 310 data = packet_suffix(*packet, length); 315 311 if (!data) { 316 pq_release_remote( packet_phone, packet_get_id(*packet));312 pq_release_remote(sess, packet_get_id(*packet)); 317 313 return ENOMEM; 318 314 } … … 321 317 rc = async_data_write_finalize(callid, data, length); 322 318 if (rc != EOK) { 323 pq_release_remote( packet_phone, packet_get_id(*packet));319 pq_release_remote(sess, packet_get_id(*packet)); 324 320 return rc; 325 321 } … … 328 324 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 329 325 if (rc != EOK) { 330 pq_release_remote( packet_phone, packet_get_id(*packet));326 pq_release_remote(sess, packet_get_id(*packet)); 331 327 return rc; 332 328 } -
uspace/lib/net/tl/tl_remote.c
r55091847 r6b82009 34 34 #include <generic.h> 35 35 #include <packet_client.h> 36 37 36 #include <ipc/services.h> 38 37 #include <ipc/tl.h> 39 40 38 #include <net/device.h> 41 39 #include <net/packet.h> 40 #include <async.h> 42 41 43 42 /** Notify the remote transport layer modules about the received packet/s. 44 43 * 45 * @param[in] tl_phone The transport layer module phone used for remote calls.46 * @param[in] device_id The device identifier.47 * @param[in] packet The received packet or the received packet queue.44 * @param[in] sess Transport layer module session. 45 * @param[in] device_id Device identifier. 46 * @param[in] packet Received packet or the received packet queue. 48 47 * The packet queue is used to carry a fragmented 49 48 * datagram. The first packet contains the headers, 50 49 * the others contain only data. 51 * @param[in] target T he target transport layer module service to be50 * @param[in] target Target transport layer module service to be 52 51 * delivered to. 53 * @param[in] error The packet error reporting service. Prefixes the52 * @param[in] error Packet error reporting service. Prefixes the 54 53 * received packet. 55 54 * … … 57 56 * 58 57 */ 59 int tl_received_msg( int tl_phone, device_id_t device_id, packet_t *packet,58 int tl_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet, 60 59 services_t target, services_t error) 61 60 { 62 return generic_received_msg_remote( tl_phone, NET_TL_RECEIVED, device_id,61 return generic_received_msg_remote(sess, NET_TL_RECEIVED, device_id, 63 62 packet_get_id(packet), target, error); 64 63 } -
uspace/lib/net/tl/tl_skel.c
r55091847 r6b82009 38 38 #include <bool.h> 39 39 #include <errno.h> 40 #include <ns.h> 40 41 #include <tl_skel.h> 41 42 #include <net_interface.h> 42 43 #include <net/modules.h> 43 #include <async_obsolete.h>44 45 // FIXME: remove this header46 #include <kernel/ipc/ipc_methods.h>47 44 48 45 /** Default thread for new connections. 49 46 * 50 * @param[in] iid 51 * @param[in] icall 52 * @param[in] arg 47 * @param[in] iid The initial message identifier. 48 * @param[in] icall The initial message call structure. 49 * @param[in] arg Local argument. 53 50 * 54 51 */ … … 107 104 * 108 105 */ 109 int tl_module_start( int service)106 int tl_module_start(sysarg_t service) 110 107 { 111 108 async_set_client_connection(tl_client_connection); 112 int net_phone= net_connect_module();113 if ( net_phone < 0)114 return net_phone;109 async_sess_t *sess = net_connect_module(); 110 if (!sess) 111 return ENOENT; 115 112 116 113 int rc = pm_init(); … … 118 115 return rc; 119 116 120 rc = tl_initialize( net_phone);117 rc = tl_initialize(sess); 121 118 if (rc != EOK) 122 119 goto out; 123 120 124 rc = async_obsolete_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);121 rc = service_register(service); 125 122 if (rc != EOK) 126 123 goto out; -
uspace/lib/packet/generic/packet_server.c
r55091847 r6b82009 36 36 37 37 #include <packet_server.h> 38 39 38 #include <align.h> 40 39 #include <assert.h> … … 317 316 * packet_release_wrapper() function. 318 317 */ 319 int 320 packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 318 int packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 321 319 size_t *answer_count) 322 320 { 323 321 packet_t *packet; 324 325 *answer_count = 0;326 322 327 323 if (!IPC_GET_IMETHOD(*call)) 328 324 return EOK; 329 325 326 *answer_count = 0; 330 327 switch (IPC_GET_IMETHOD(*call)) { 331 328 case NET_PACKET_CREATE_1:
Note:
See TracChangeset
for help on using the changeset viewer.