Changeset 0ab68f6 in mainline
- Timestamp:
- 2010-11-07T20:48:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a5d238f
- Parents:
- 88b127b
- Location:
- uspace/lib/net
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/adt/module_map.c
r88b127b r0ab68f6 38 38 #include <task.h> 39 39 #include <unistd.h> 40 #include <err .h>40 #include <errno.h> 41 41 42 42 #include <ipc/services.h> … … 67 67 connect_module_t connect_module) 68 68 { 69 ERROR_DECLARE;70 71 69 module_ref tmp_module; 70 int rc; 72 71 73 72 tmp_module = (module_ref) malloc(sizeof(module_t)); … … 83 82 tmp_module->connect_module = connect_module; 84 83 85 if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0,86 tmp_module))) {84 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 85 if (rc != EOK) { 87 86 free(tmp_module); 88 return ERROR_CODE;87 return rc; 89 88 } 90 89 if (module) -
uspace/lib/net/generic/packet_remote.c
r88b127b r0ab68f6 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <err.h>41 40 #include <ipc/ipc.h> 42 41 #include <ipc/packet.h> … … 67 66 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size) 68 67 { 69 ERROR_DECLARE;70 71 68 ipc_call_t answer; 72 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 69 aid_t message; 70 int rc; 71 72 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 73 74 74 *packet = (packet_t) as_get_mappable_page(size); 75 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||76 ERROR_OCCURRED(pm_add(*packet))) {75 rc = async_share_in_start_0_0(phone, *packet, size); 76 if (rc != EOK) { 77 77 munmap(*packet, size); 78 78 async_wait_for(message, NULL); 79 return ERROR_CODE; 79 return rc; 80 } 81 rc = pm_add(*packet); 82 if (rc != EOK) { 83 munmap(*packet, size); 84 async_wait_for(message, NULL); 85 return rc; 80 86 } 81 87 … … 103 109 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 104 110 { 105 ERROR_DECLARE;111 int rc; 106 112 107 113 if (!packet) … … 112 118 ipcarg_t size; 113 119 114 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, 115 packet_id, &size)); 116 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 120 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 if (rc != EOK) 123 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 125 if (rc != EOK) 126 return rc; 117 127 } 118 128 if ((*packet)->next) { … … 141 151 size_t max_prefix, size_t max_suffix) 142 152 { 143 ERROR_DECLARE;144 145 153 ipcarg_t packet_id; 146 154 ipcarg_t size; 147 148 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, 149 max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))) 155 int rc; 156 157 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 158 max_prefix, max_suffix, &packet_id, &size); 159 if (rc != EOK) 150 160 return NULL; 151 161 … … 153 163 packet_t packet = pm_find(packet_id); 154 164 if (!packet) { 155 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,156 size)))165 rc = packet_return(phone, &packet, packet_id, size); 166 if (rc != EOK) 157 167 return NULL; 158 168 } … … 172 182 packet_t packet_get_1_remote(int phone, size_t content) 173 183 { 174 ERROR_DECLARE;175 176 184 ipcarg_t packet_id; 177 185 ipcarg_t size; 178 179 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 180 &packet_id, &size))) 186 int rc; 187 188 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 189 &size); 190 if (rc != EOK) 181 191 return NULL; 182 192 183 193 packet_t packet = pm_find(packet_id); 184 194 if (!packet) { 185 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,186 size)))195 rc = packet_return(phone, &packet, packet_id, size); 196 if (rc != EOK) 187 197 return NULL; 188 198 } -
uspace/lib/net/netif/netif_local.c
r88b127b r0ab68f6 43 43 #include <ipc/services.h> 44 44 #include <ipc/netif.h> 45 #include <err .h>45 #include <errno.h> 46 46 47 47 #include <generic.h> … … 113 113 int netif_start_req_local(int netif_phone, device_id_t device_id) 114 114 { 115 ERROR_DECLARE;115 int rc; 116 116 117 117 fibril_rwlock_write_lock(&netif_globals.lock); 118 118 119 119 netif_device_t *device; 120 if (ERROR_OCCURRED(find_device(device_id, &device))) { 120 rc = find_device(device_id, &device); 121 if (rc != EOK) { 121 122 fibril_rwlock_write_unlock(&netif_globals.lock); 122 return ERROR_CODE;123 return rc; 123 124 } 124 125 … … 148 149 int netif_stop_req_local(int netif_phone, device_id_t device_id) 149 150 { 150 ERROR_DECLARE;151 int rc; 151 152 152 153 fibril_rwlock_write_lock(&netif_globals.lock); 153 154 154 155 netif_device_t *device; 155 if (ERROR_OCCURRED(find_device(device_id, &device))) { 156 rc = find_device(device_id, &device); 157 if (rc != EOK) { 156 158 fibril_rwlock_write_unlock(&netif_globals.lock); 157 return ERROR_CODE;159 return rc; 158 160 } 159 161 … … 203 205 measured_string_ref *address, char **data) 204 206 { 205 ERROR_DECLARE;207 int rc; 206 208 207 209 if (!address || !data) … … 211 213 212 214 measured_string_t translation; 213 if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) { 215 rc = netif_get_addr_message(device_id, &translation); 216 if (rc == EOK) { 214 217 *address = measured_string_copy(&translation); 215 ERROR_CODE= (*address) ? EOK : ENOMEM;218 rc = (*address) ? EOK : ENOMEM; 216 219 } 217 220 … … 220 223 *data = (**address).value; 221 224 222 return ERROR_CODE;225 return rc; 223 226 } 224 227 … … 264 267 int netif_init_module(async_client_conn_t client_connection) 265 268 { 266 ERROR_DECLARE;269 int rc; 267 270 268 271 async_set_client_connection(client_connection); … … 271 274 netif_device_map_initialize(&netif_globals.device_map); 272 275 273 ERROR_PROPAGATE(pm_init()); 276 rc = pm_init(); 277 if (rc != EOK) 278 return rc; 274 279 275 280 fibril_rwlock_initialize(&netif_globals.lock); 276 if (ERROR_OCCURRED(netif_initialize())) { 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 277 284 pm_destroy(); 278 return ERROR_CODE;285 return rc; 279 286 } 280 287 … … 317 324 static int register_message(const char *name, device_id_t device_id, int phone) 318 325 { 319 ERROR_DECLARE;320 321 326 netif_device_t *device; 322 ERROR_PROPAGATE(find_device(device_id, &device)); 323 if(device->nil_phone > 0) 327 int rc; 328 329 rc = find_device(device_id, &device); 330 if (rc != EOK) 331 return rc; 332 333 if (device->nil_phone > 0) 324 334 return ELIMIT; 325 335 … … 349 359 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 350 360 { 351 ERROR_DECLARE;352 353 361 size_t length; 354 362 device_stats_t stats; 355 363 packet_t packet; 356 364 measured_string_t address; 365 int rc; 357 366 358 367 *answer_count = 0; … … 367 376 case IPC_M_CONNECT_TO_ME: 368 377 fibril_rwlock_write_lock(&netif_globals.lock); 369 ERROR_CODE= register_message(name, IPC_GET_DEVICE(call),378 rc = register_message(name, IPC_GET_DEVICE(call), 370 379 IPC_GET_PHONE(call)); 371 380 fibril_rwlock_write_unlock(&netif_globals.lock); 372 return ERROR_CODE;381 return rc; 373 382 374 383 case NET_NETIF_SEND: 375 ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone, 376 &packet, IPC_GET_PACKET(call))); 384 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET(call)); 386 if (rc != EOK) 387 return rc; 377 388 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 378 389 IPC_GET_SENDER(call)); 379 390 380 391 case NET_NETIF_START: 381 392 return netif_start_req_local(0, IPC_GET_DEVICE(call)); … … 384 395 fibril_rwlock_read_lock(&netif_globals.lock); 385 396 386 if (ERROR_OCCURRED(async_data_read_receive(&callid, &length))) { 397 rc = async_data_read_receive(&callid, &length); 398 if (rc != EOK) { 387 399 fibril_rwlock_read_unlock(&netif_globals.lock); 388 return ERROR_CODE;400 return rc; 389 401 } 390 402 if (length < sizeof(device_stats_t)) { … … 393 405 } 394 406 395 if (ERROR_NONE(netif_get_device_stats(IPC_GET_DEVICE(call),396 &stats))) {397 ERROR_CODE= async_data_read_finalize(callid, &stats,407 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats); 408 if (rc == EOK) { 409 rc = async_data_read_finalize(callid, &stats, 398 410 sizeof(device_stats_t)); 399 411 } 400 412 401 413 fibril_rwlock_read_unlock(&netif_globals.lock); 402 return ERROR_CODE;414 return rc; 403 415 404 416 case NET_NETIF_STOP: … … 407 419 case NET_NETIF_GET_ADDR: 408 420 fibril_rwlock_read_lock(&netif_globals.lock); 409 if (ERROR_NONE(netif_get_addr_message(IPC_GET_DEVICE(call),410 &address)))411 ERROR_CODE= measured_strings_reply(&address, 1);421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address); 422 if (rc == EOK) 423 rc = measured_strings_reply(&address, 1); 412 424 fibril_rwlock_read_unlock(&netif_globals.lock); 413 return ERROR_CODE;425 return rc; 414 426 } 415 427 … … 431 443 int netif_module_start_standalone(async_client_conn_t client_connection) 432 444 { 433 ERROR_DECLARE; 434 435 ERROR_PROPAGATE(netif_init_module(client_connection)); 445 int rc; 446 447 rc = netif_init_module(client_connection); 448 if (rc != EOK) 449 return rc; 436 450 437 451 async_manager(); -
uspace/lib/net/tl/socket_core.c
r88b127b r0ab68f6 48 48 #include <stdlib.h> 49 49 #include <errno.h> 50 #include <err.h>51 50 52 51 #include <adt/dynamic_fifo.h> … … 164 163 const char *key, size_t key_length) 165 164 { 166 ERROR_DECLARE;167 168 165 socket_core_ref *socket_ref; 166 int rc; 169 167 170 168 // create a wrapper … … 175 173 *socket_ref = socket; 176 174 // add the wrapper 177 if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key, 178 key_length, socket_ref))) { 175 rc = socket_port_map_add(&socket_port->map, key, key_length, 176 socket_ref); 177 if (rc != EOK) { 179 178 free(socket_ref); 180 return ERROR_CODE;179 return rc; 181 180 } 182 181 … … 204 203 int port) 205 204 { 206 ERROR_DECLARE;207 208 205 socket_port_ref socket_port; 206 int rc; 209 207 210 208 // create a wrapper … … 214 212 215 213 socket_port->count = 0; 216 if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) || 217 ERROR_OCCURRED(socket_port_add_core(socket_port, socket, 218 SOCKET_MAP_KEY_LISTENING, 0))) { 219 socket_port_map_destroy(&socket_port->map); 220 free(socket_port); 221 return ERROR_CODE; 222 } 214 rc = socket_port_map_initialize(&socket_port->map); 215 if (rc != EOK) 216 goto fail; 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING, 219 0); 220 if (rc != EOK) 221 goto fail; 223 222 224 223 // register the incomming port 225 ERROR_CODE = socket_ports_add(global_sockets, port, socket_port); 226 if (ERROR_CODE < 0) { 227 socket_port_map_destroy(&socket_port->map); 228 free(socket_port); 229 return ERROR_CODE; 230 } 224 rc = socket_ports_add(global_sockets, port, socket_port); 225 if (rc < 0) 226 goto fail; 231 227 232 228 socket->port = port; 233 229 return EOK; 230 231 fail: 232 socket_port_map_destroy(&socket_port->map); 233 free(socket_port); 234 return rc; 235 234 236 } 235 237 … … 416 418 void *specific_data, int *socket_id) 417 419 { 418 ERROR_DECLARE;419 420 420 socket_core_ref socket; 421 int res;422 421 int positive; 422 int rc; 423 423 424 424 if (!socket_id) … … 447 447 socket->key_length = 0; 448 448 socket->specific_data = specific_data; 449 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,450 SOCKET_INITIAL_RECEIVED_SIZE))) {449 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 450 if (rc != EOK) { 451 451 free(socket); 452 return ERROR_CODE; 453 } 454 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted, 455 SOCKET_INITIAL_ACCEPTED_SIZE))) { 452 return rc; 453 } 454 455 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 456 if (rc != EOK) { 456 457 dyn_fifo_destroy(&socket->received); 457 458 free(socket); 458 return ERROR_CODE;459 return rc; 459 460 } 460 461 socket->socket_id = *socket_id; 461 r es= socket_cores_add(local_sockets, socket->socket_id, socket);462 if (r es< 0) {462 rc = socket_cores_add(local_sockets, socket->socket_id, socket); 463 if (rc < 0) { 463 464 dyn_fifo_destroy(&socket->received); 464 465 dyn_fifo_destroy(&socket->accepted); 465 466 free(socket); 466 return r es;467 return rc; 467 468 } 468 469 … … 523 524 int socket_reply_packets(packet_t packet, size_t *length) 524 525 { 525 ERROR_DECLARE;526 527 526 packet_t next_packet; 528 527 size_t fragments; 529 528 size_t *lengths; 530 529 size_t index; 530 int rc; 531 531 532 532 if (!length) … … 536 536 if (!next_packet) { 537 537 // write all if only one fragment 538 ERROR_PROPAGATE(data_reply(packet_get_data(packet), 539 packet_get_data_length(packet))); 538 rc = data_reply(packet_get_data(packet), 539 packet_get_data_length(packet)); 540 if (rc != EOK) 541 return rc; 540 542 // store the total length 541 543 *length = packet_get_data_length(packet); … … 564 566 565 567 // write the fragment lengths 566 if (ERROR_OCCURRED(data_reply(lengths,567 sizeof(int) * (fragments + 1)))) {568 rc = data_reply(lengths, sizeof(int) * (fragments + 1)); 569 if (rc != EOK) { 568 570 free(lengths); 569 return ERROR_CODE;571 return rc; 570 572 } 571 573 next_packet = packet; … … 573 575 // write the fragments 574 576 for (index = 0; index < fragments; ++index) { 575 ERROR_CODE= data_reply(packet_get_data(next_packet),577 rc = data_reply(packet_get_data(next_packet), 576 578 lengths[index]); 577 if ( ERROR_OCCURRED(ERROR_CODE)) {579 if (rc != EOK) { 578 580 free(lengths); 579 return ERROR_CODE;581 return rc; 580 582 } 581 583 next_packet = pq_next(next_packet); … … 680 682 socket_core_ref socket, const char *key, size_t key_length) 681 683 { 682 ERROR_DECLARE;683 684 684 socket_port_ref socket_port; 685 int rc; 685 686 686 687 // find ports … … 690 691 691 692 // add the socket 692 ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key, 693 key_length)); 693 rc = socket_port_add_core(socket_port, socket, key, key_length); 694 if (rc != EOK) 695 return rc; 694 696 695 697 socket->port = port; -
uspace/lib/net/tl/tl_common.c
r88b127b r0ab68f6 54 54 #include <ipc/services.h> 55 55 #include <errno.h> 56 #include <err.h>57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 124 123 packet_dimension_ref *packet_dimension) 125 124 { 126 ERROR_DECLARE;125 int rc; 127 126 128 127 if (!packet_dimension) … … 137 136 return ENOMEM; 138 137 139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,140 *packet_dimension))) {138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension); 139 if (rc != EOK) { 141 140 free(*packet_dimension); 142 return ERROR_CODE;141 return rc; 143 142 } 144 143 145 ERROR_CODE= packet_dimensions_add(packet_dimensions, device_id,144 rc = packet_dimensions_add(packet_dimensions, device_id, 146 145 *packet_dimension); 147 if ( ERROR_CODE< 0) {146 if (rc < 0) { 148 147 free(*packet_dimension); 149 return ERROR_CODE;148 return rc; 150 149 } 151 150 } … … 292 291 socklen_t addrlen) 293 292 { 294 ERROR_DECLARE;295 296 293 ipc_callid_t callid; 297 294 size_t length; 298 void * data; 295 void *data; 296 int rc; 299 297 300 298 if (!dimension) … … 319 317 320 318 // read the data into the packet 321 if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) || 322 // set the packet destination address 323 ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, 324 addrlen))) { 319 rc = async_data_write_finalize(callid, data, length); 320 if (rc != EOK) { 325 321 pq_release_remote(packet_phone, packet_get_id(*packet)); 326 return ERROR_CODE; 322 return rc; 323 } 324 325 // set the packet destination address 326 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 if (rc != EOK) { 328 pq_release_remote(packet_phone, packet_get_id(*packet)); 329 return rc; 327 330 } 328 331
Note:
See TracChangeset
for help on using the changeset viewer.