Changes in / [9ce7eb5:3da12d74] in mainline
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/netstart/Makefile
r9ce7eb5 r3da12d74 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = 32 EXTRA_CFLAGS = 31 LIBS = $(LIBNET_PREFIX)/libnet.a 32 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include 33 33 34 34 BINARY = netstart -
uspace/lib/c/generic/net/modules.c
r9ce7eb5 r3da12d74 41 41 #include <async.h> 42 42 #include <malloc.h> 43 #include <err no.h>43 #include <err.h> 44 44 #include <sys/time.h> 45 45 … … 137 137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 int rc;139 ERROR_DECLARE; 140 140 141 141 /* Connect to the needed service */ … … 144 144 /* Request the bidirectional connection */ 145 145 ipcarg_t phonehash; 146 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); 148 if (rc != EOK) { 146 if (ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, 147 &phonehash))) { 149 148 ipc_hangup(phone); 150 return rc;149 return ERROR_CODE; 151 150 } 152 151 async_new_connection(phonehash, 0, NULL, client_receiver); … … 213 212 int data_receive(void **data, size_t *length) 214 213 { 214 ERROR_DECLARE; 215 215 216 ipc_callid_t callid; 216 int rc;217 217 218 218 if (!data || !length) … … 229 229 230 230 // fetch the data 231 rc = async_data_write_finalize(callid, *data, *length); 232 if (rc != EOK) { 231 if (ERROR_OCCURRED(async_data_write_finalize(callid, *data, *length))) { 233 232 free(data); 234 return rc;233 return ERROR_CODE; 235 234 } 236 235 -
uspace/lib/c/generic/net/packet.c
r9ce7eb5 r3da12d74 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h> 43 44 44 45 #include <sys/mman.h> … … 90 91 int pm_init(void) 91 92 { 92 int rc;93 ERROR_DECLARE; 93 94 94 95 fibril_rwlock_initialize(&pm_globals.lock); 95 96 96 fibril_rwlock_write_lock(&pm_globals.lock); 97 rc = gpm_initialize(&pm_globals.packet_map);97 ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map)); 98 98 fibril_rwlock_write_unlock(&pm_globals.lock); 99 100 return rc; 99 return EOK; 101 100 } 102 101 … … 140 139 int pm_add(packet_t packet) 141 140 { 141 ERROR_DECLARE; 142 142 143 packet_map_ref map; 143 int rc;144 144 145 145 if (!packet_is_valid(packet)) … … 160 160 } 161 161 bzero(map, sizeof(packet_map_t)); 162 rc = gpm_add(&pm_globals.packet_map, map);163 if (rc< 0) {162 if ((ERROR_CODE = 163 gpm_add(&pm_globals.packet_map, map)) < 0) { 164 164 fibril_rwlock_write_unlock(&pm_globals.lock); 165 165 free(map); 166 return rc;166 return ERROR_CODE; 167 167 } 168 168 } while (PACKET_MAP_PAGE(packet->packet_id) >= -
uspace/lib/c/generic/net/socket_client.c
r9ce7eb5 r3da12d74 43 43 #include <stdlib.h> 44 44 #include <errno.h> 45 #include <err.h> 45 46 46 47 #include <ipc/services.h> … … 211 212 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall) 212 213 { 214 ERROR_DECLARE; 215 213 216 ipc_callid_t callid; 214 217 ipc_call_t call; 215 218 socket_ref socket; 216 int rc;217 219 218 220 loop: … … 229 231 SOCKET_GET_SOCKET_ID(call)); 230 232 if (!socket) { 231 rc= ENOTSOCK;233 ERROR_CODE = ENOTSOCK; 232 234 fibril_rwlock_read_unlock(&socket_globals.lock); 233 235 break; … … 238 240 fibril_mutex_lock(&socket->receive_lock); 239 241 // push the number of received packet fragments 240 rc =dyn_fifo_push(&socket->received,242 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->received, 241 243 SOCKET_GET_DATA_FRAGMENTS(call), 242 SOCKET_MAX_RECEIVED_SIZE); 243 if (rc == EOK) { 244 SOCKET_MAX_RECEIVED_SIZE))) { 244 245 // signal the received packet 245 246 fibril_condvar_signal(&socket->receive_signal); … … 251 252 // push the new socket identifier 252 253 fibril_mutex_lock(&socket->accept_lock); 253 rc = dyn_fifo_push(&socket->accepted, 1, 254 SOCKET_MAX_ACCEPTED_SIZE); 255 if (rc != EOK) { 254 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->accepted, 255 1, SOCKET_MAX_ACCEPTED_SIZE))) { 256 256 // signal the accepted socket 257 257 fibril_condvar_signal(&socket->accept_signal); … … 261 261 262 262 default: 263 rc= ENOTSUP;263 ERROR_CODE = ENOTSUP; 264 264 } 265 265 … … 280 280 281 281 default: 282 rc= ENOTSUP;283 } 284 285 ipc_answer_0(callid, (ipcarg_t) rc);282 ERROR_CODE = ENOTSUP; 283 } 284 285 ipc_answer_0(callid, (ipcarg_t) ERROR_CODE); 286 286 goto loop; 287 287 } … … 405 405 int socket(int domain, int type, int protocol) 406 406 { 407 ERROR_DECLARE; 408 407 409 socket_ref socket; 408 410 int phone; … … 411 413 ipcarg_t fragment_size; 412 414 ipcarg_t header_size; 413 int rc;414 415 415 416 // find the appropriate service … … 478 479 } 479 480 480 rc = (int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 481 &fragment_size, &header_size); 482 if (rc != EOK) { 481 if (ERROR_OCCURRED((int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, 482 service, NULL, &fragment_size, &header_size))) { 483 483 fibril_rwlock_write_unlock(&socket_globals.lock); 484 484 free(socket); 485 return rc;485 return ERROR_CODE; 486 486 } 487 487 … … 492 492 socket_initialize(socket, socket_id, phone, service); 493 493 // store the new socket 494 rc= sockets_add(socket_get_sockets(), socket_id, socket);494 ERROR_CODE = sockets_add(socket_get_sockets(), socket_id, socket); 495 495 496 496 fibril_rwlock_write_unlock(&socket_globals.lock); 497 if ( rc< 0) {497 if (ERROR_CODE < 0) { 498 498 dyn_fifo_destroy(&socket->received); 499 499 dyn_fifo_destroy(&socket->accepted); … … 501 501 async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0, 502 502 service); 503 return rc;503 return ERROR_CODE; 504 504 } 505 505 … … 770 770 int closesocket(int socket_id) 771 771 { 772 ERROR_DECLARE; 773 772 774 socket_ref socket; 773 int rc;774 775 775 776 fibril_rwlock_write_lock(&socket_globals.lock); … … 786 787 787 788 // request close 788 rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 789 (ipcarg_t) socket->socket_id, 0, socket->service); 790 if (rc != EOK) { 791 fibril_rwlock_write_unlock(&socket_globals.lock); 792 return rc; 793 } 789 ERROR_PROPAGATE((int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 790 (ipcarg_t) socket->socket_id, 0, socket->service)); 794 791 // free the socket structure 795 792 socket_destroy(socket); -
uspace/srv/net/net/net.c
r9ce7eb5 r3da12d74 42 42 #include <ddi.h> 43 43 #include <errno.h> 44 #include <err.h> 44 45 #include <malloc.h> 45 46 #include <stdio.h> … … 91 92 const char *value) 92 93 { 93 int rc;94 ERROR_DECLARE; 94 95 95 96 measured_string_ref setting = … … 99 100 100 101 /* Add the configuration setting */ 101 rc = measured_strings_add(configuration, name, 0, setting); 102 if (rc != EOK) { 102 if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) { 103 103 free(setting); 104 return rc;104 return ERROR_CODE; 105 105 } 106 106 … … 110 110 /** Generate new system-unique device identifier. 111 111 * 112 * @returns The system-unique devic identifier. 112 * @returns The system-unique devic identifier. 113 * 113 114 */ 114 115 static device_id_t generate_new_device_id(void) … … 119 120 static int parse_line(measured_strings_ref configuration, char *line) 120 121 { 121 int rc;122 ERROR_DECLARE; 122 123 123 124 /* From the beginning */ … … 169 170 170 171 /* Add the configuration setting */ 171 rc = measured_strings_add(configuration, name, 0, setting); 172 if (rc != EOK) { 172 if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) { 173 173 free(setting); 174 return rc;174 return ERROR_CODE; 175 175 } 176 176 … … 181 181 measured_strings_ref configuration) 182 182 { 183 ERROR_DECLARE; 184 183 185 printf("%s: Reading configuration file %s/%s\n", NAME, directory, filename); 184 186 … … 204 206 if (index >= BUFFER_SIZE) { 205 207 line[BUFFER_SIZE - 1] = '\0'; 206 fprintf(stderr, "%s: Configuration line %u too "207 "long: %s\n",NAME, line_number, line);208 fprintf(stderr, "%s: Configuration line %u too long: %s\n", 209 NAME, line_number, line); 208 210 209 211 /* No space left in the line buffer */ 210 212 return EOVERFLOW; 213 } else { 214 /* Append the character */ 215 line[index] = (char) read; 216 index++; 211 217 } 212 /* Append the character */213 line[index] = (char) read;214 index++;215 218 } else { 216 219 /* On error or new line */ 217 220 line[index] = '\0'; 218 221 line_number++; 219 if (parse_line(configuration, line) != EOK) { 220 fprintf(stderr, "%s: Configuration error on " 221 "line %u: %s\n", NAME, line_number, line); 222 } 222 if (ERROR_OCCURRED(parse_line(configuration, line))) 223 fprintf(stderr, "%s: Configuration error on line %u: %s\n", 224 NAME, line_number, line); 223 225 224 226 index = 0; … … 268 270 static int net_initialize(async_client_conn_t client_connection) 269 271 { 270 int rc;272 ERROR_DECLARE; 271 273 272 274 netifs_initialize(&net_globals.netifs); … … 276 278 277 279 // TODO: dynamic configuration 278 rc = read_configuration(); 279 if (rc != EOK) 280 return rc; 281 282 rc = add_module(NULL, &net_globals.modules, LO_NAME, LO_FILENAME, 283 SERVICE_LO, 0, connect_to_service); 284 if (rc != EOK) 285 return rc; 286 rc = add_module(NULL, &net_globals.modules, DP8390_NAME, 287 DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service); 288 if (rc != EOK) 289 return rc; 290 rc = add_module(NULL, &net_globals.modules, ETHERNET_NAME, 291 ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service); 292 if (rc != EOK) 293 return rc; 294 rc = add_module(NULL, &net_globals.modules, NILDUMMY_NAME, 295 NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service); 296 if (rc != EOK) 297 return rc; 280 ERROR_PROPAGATE(read_configuration()); 281 282 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 283 LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service)); 284 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 285 DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service)); 286 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 287 ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, 288 connect_to_service)); 289 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 290 NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, 291 connect_to_service)); 298 292 299 293 /* Build specific initialization */ … … 320 314 static int net_module_start(async_client_conn_t client_connection) 321 315 { 316 ERROR_DECLARE; 317 318 async_set_client_connection(client_connection); 319 ERROR_PROPAGATE(pm_init()); 320 322 321 ipcarg_t phonehash; 323 int rc; 324 325 async_set_client_connection(client_connection); 326 rc = pm_init(); 327 if (rc != EOK) 328 return rc; 329 330 331 rc = net_initialize(client_connection); 332 if (rc != EOK) 333 goto out; 334 335 rc = REGISTER_ME(SERVICE_NETWORKING, &phonehash); 336 if (rc != EOK) 337 goto out; 322 323 if (ERROR_OCCURRED(net_initialize(client_connection)) || 324 ERROR_OCCURRED(REGISTER_ME(SERVICE_NETWORKING, &phonehash))) { 325 pm_destroy(); 326 return ERROR_CODE; 327 } 338 328 339 329 async_manager(); 340 341 out: 330 342 331 pm_destroy(); 343 return rc;332 return EOK; 344 333 } 345 334 … … 426 415 static int start_device(netif_t *netif) 427 416 { 428 int rc;417 ERROR_DECLARE; 429 418 430 419 /* Mandatory netif */ … … 467 456 int io = setting ? strtol(setting->value, NULL, 16) : 0; 468 457 469 rc = netif_probe_req_remote(netif->driver->phone, netif->id, irq, io); 470 if (rc != EOK) 471 return rc; 458 ERROR_PROPAGATE(netif_probe_req_remote(netif->driver->phone, netif->id, irq, io)); 472 459 473 460 /* Network interface layer startup */ … … 481 468 int mtu = setting ? strtol(setting->value, NULL, 10) : 0; 482 469 483 rc = nil_device_req(netif->nil->phone, netif->id, mtu, 484 netif->driver->service); 485 if (rc != EOK) 486 return rc; 470 ERROR_PROPAGATE(nil_device_req(netif->nil->phone, netif->id, mtu, 471 netif->driver->service)); 487 472 488 473 internet_service = netif->nil->service; … … 493 478 switch (netif->il->service) { 494 479 case SERVICE_IP: 495 rc = ip_device_req(netif->il->phone, netif->id, 496 internet_service); 497 if (rc != EOK) 498 return rc; 480 ERROR_PROPAGATE(ip_device_req(netif->il->phone, netif->id, 481 internet_service)); 499 482 break; 500 483 default: … … 502 485 } 503 486 504 return netif_start_req_remote(netif->driver->phone, netif->id); 487 ERROR_PROPAGATE(netif_start_req_remote(netif->driver->phone, netif->id)); 488 return EOK; 505 489 } 506 490 … … 520 504 static int startup(void) 521 505 { 506 ERROR_DECLARE; 507 522 508 const char *conf_files[] = { 523 509 "lo", … … 525 511 }; 526 512 size_t count = sizeof(conf_files) / sizeof(char *); 527 int rc;528 513 529 514 size_t i; … … 537 522 return EXDEV; 538 523 539 rc = measured_strings_initialize(&netif->configuration); 540 if (rc != EOK) 541 return rc; 524 ERROR_PROPAGATE(measured_strings_initialize(&netif->configuration)); 542 525 543 526 /* Read configuration files */ 544 rc = read_netif_configuration(conf_files[i], netif); 545 if (rc != EOK) { 527 if (ERROR_OCCURRED(read_netif_configuration(conf_files[i], netif))) { 546 528 measured_strings_destroy(&netif->configuration); 547 529 free(netif); 548 return rc;530 return ERROR_CODE; 549 531 } 550 532 … … 572 554 * and needed modules. 573 555 */ 574 rc = char_map_add(&net_globals.netif_names, netif->name, 0, 575 index); 576 if (rc != EOK) { 556 if ((ERROR_OCCURRED(char_map_add(&net_globals.netif_names, 557 netif->name, 0, index))) || (ERROR_OCCURRED(start_device(netif)))) { 577 558 measured_strings_destroy(&netif->configuration); 578 559 netifs_exclude_index(&net_globals.netifs, index); 579 return rc; 580 } 581 582 rc = start_device(netif); 583 if (rc != EOK) { 584 measured_strings_destroy(&netif->configuration); 585 netifs_exclude_index(&net_globals.netifs, index); 586 return rc; 560 return ERROR_CODE; 587 561 } 588 562 … … 620 594 int *answer_count) 621 595 { 596 ERROR_DECLARE; 597 622 598 measured_string_ref strings; 623 599 char *data; 624 int rc;625 600 626 601 *answer_count = 0; … … 629 604 return EOK; 630 605 case NET_NET_GET_DEVICE_CONF: 631 rc = measured_strings_receive(&strings, &data, 632 IPC_GET_COUNT(call)); 633 if (rc != EOK) 634 return rc; 606 ERROR_PROPAGATE(measured_strings_receive(&strings, &data, 607 IPC_GET_COUNT(call))); 635 608 net_get_device_conf_req(0, IPC_GET_DEVICE(call), &strings, 636 609 IPC_GET_COUNT(call), NULL); … … 639 612 free(data); 640 613 641 rc= measured_strings_reply(strings, IPC_GET_COUNT(call));614 ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call)); 642 615 free(strings); 643 return rc;616 return ERROR_CODE; 644 617 case NET_NET_GET_CONF: 645 rc = measured_strings_receive(&strings, &data, 646 IPC_GET_COUNT(call)); 647 if (rc != EOK) 648 return rc; 618 ERROR_PROPAGATE(measured_strings_receive(&strings, &data, 619 IPC_GET_COUNT(call))); 649 620 net_get_conf_req(0, &strings, IPC_GET_COUNT(call), NULL); 650 621 … … 652 623 free(data); 653 624 654 rc= measured_strings_reply(strings, IPC_GET_COUNT(call));625 ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call)); 655 626 free(strings); 656 return rc;627 return ERROR_CODE; 657 628 case NET_NET_STARTUP: 658 629 return startup(); 659 630 } 660 661 631 return ENOTSUP; 662 632 } … … 700 670 int main(int argc, char *argv[]) 701 671 { 702 int rc; 703 704 rc = net_module_start(net_client_connection); 705 if (rc != EOK) { 706 fprintf(stderr, "%s: net_module_start error %i\n", NAME, rc); 707 return rc; 672 ERROR_DECLARE; 673 674 if (ERROR_OCCURRED(net_module_start(net_client_connection))) { 675 fprintf(stderr, "%s: net_module_start error %i\n", NAME, ERROR_CODE); 676 return ERROR_CODE; 708 677 } 709 678 -
uspace/srv/net/net/net_standalone.c
r9ce7eb5 r3da12d74 42 42 #include <ipc/ipc.h> 43 43 #include <ipc/net.h> 44 #include <errno.h>45 44 46 45 #include <ip_interface.h> … … 61 60 int net_initialize_build(async_client_conn_t client_connection) 62 61 { 63 int rc;62 ERROR_DECLARE; 64 63 65 64 task_id_t task_id = spawn("/srv/ip"); … … 67 66 return EINVAL; 68 67 69 rc = add_module(NULL, &net_globals.modules, IP_NAME, 70 IP_FILENAME, SERVICE_IP, task_id, ip_connect_module); 71 if (rc != EOK) 72 return rc; 68 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, IP_NAME, 69 IP_FILENAME, SERVICE_IP, task_id, ip_connect_module)); 73 70 74 71 if (!spawn("/srv/icmp"))
Note:
See TracChangeset
for help on using the changeset viewer.