Changeset 89c57b6 in mainline for uspace/srv/net/net/net.c
- Timestamp:
- 2011-04-13T14:45:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88634420
- Parents:
- cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/net/net.c
rcefb126 r89c57b6 36 36 */ 37 37 38 #include "net.h" 39 38 40 #include <async.h> 39 41 #include <ctype.h> … … 43 45 #include <stdio.h> 44 46 #include <str.h> 45 46 #include <ipc/ipc.h> 47 #include <str_error.h> 48 47 49 #include <ipc/services.h> 48 49 #include <net_err.h> 50 #include <net_messages.h> 51 #include <net_modules.h> 50 #include <ipc/net.h> 51 #include <ipc/net_net.h> 52 #include <ipc/il.h> 53 #include <ipc/nil.h> 54 55 #include <net/modules.h> 56 #include <net/packet.h> 57 #include <net/device.h> 58 52 59 #include <adt/char_map.h> 53 60 #include <adt/generic_char_map.h> 54 61 #include <adt/measured_strings.h> 55 62 #include <adt/module_map.h> 56 #include <packet/packet.h> 57 #include <il_messages.h> 63 58 64 #include <netif_remote.h> 59 #include <net_device.h> 60 #include <nil_interface.h> 65 #include <nil_remote.h> 61 66 #include <net_interface.h> 62 67 #include <ip_interface.h> 63 #include <net_net_messages.h> 64 65 #include "net.h" 66 67 /** Networking module name. 68 * 69 */ 68 69 /** Networking module name. */ 70 70 #define NAME "net" 71 71 72 /** File read buffer size. 73 * 74 */ 72 /** File read buffer size. */ 75 73 #define BUFFER_SIZE 256 76 74 77 /** Networking module global data. 78 * 79 */ 75 /** Networking module global data. */ 80 76 net_globals_t net_globals; 81 77 82 78 GENERIC_CHAR_MAP_IMPLEMENT(measured_strings, measured_string_t); 83 79 DEVICE_MAP_IMPLEMENT(netifs, netif_t); 80 81 static int startup(void); 84 82 85 83 /** Add the configured setting to the configuration map. … … 89 87 * @param[in] value The setting value. 90 88 * 91 * @return sEOK on success.92 * @return sENOMEM if there is not enough memory left.93 * 94 */ 95 int add_configuration(measured_strings_ ref configuration, const char*name,96 const char*value)97 { 98 ERROR_DECLARE;99 100 measured_string_ refsetting =89 * @return EOK on success. 90 * @return ENOMEM if there is not enough memory left. 91 * 92 */ 93 int add_configuration(measured_strings_t *configuration, const uint8_t *name, 94 const uint8_t *value) 95 { 96 int rc; 97 98 measured_string_t *setting = 101 99 measured_string_create_bulk(value, 0); 102 103 100 if (!setting) 104 101 return ENOMEM; 105 102 106 103 /* Add the configuration setting */ 107 if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) { 104 rc = measured_strings_add(configuration, name, 0, setting); 105 if (rc != EOK) { 108 106 free(setting); 109 return ERROR_CODE;107 return rc; 110 108 } 111 109 … … 115 113 /** Generate new system-unique device identifier. 116 114 * 117 * @returns The system-unique devic identifier. 118 * 115 * @return The system-unique devic identifier. 119 116 */ 120 117 static device_id_t generate_new_device_id(void) … … 123 120 } 124 121 125 static int parse_line(measured_strings_ ref configuration, char*line)126 { 127 ERROR_DECLARE;122 static int parse_line(measured_strings_t *configuration, uint8_t *line) 123 { 124 int rc; 128 125 129 126 /* From the beginning */ 130 char*name = line;127 uint8_t *name = line; 131 128 132 129 /* Skip comments and blank lines */ … … 139 136 140 137 /* Remember the name start */ 141 char*value = name;138 uint8_t *value = name; 142 139 143 140 /* Skip the name */ … … 169 166 170 167 /* Create a bulk measured string till the end */ 171 measured_string_ refsetting =168 measured_string_t *setting = 172 169 measured_string_create_bulk(value, 0); 173 170 if (!setting) … … 175 172 176 173 /* Add the configuration setting */ 177 if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) { 174 rc = measured_strings_add(configuration, name, 0, setting); 175 if (rc != EOK) { 178 176 free(setting); 179 return ERROR_CODE;177 return rc; 180 178 } 181 179 … … 184 182 185 183 static int read_configuration_file(const char *directory, const char *filename, 186 measured_strings_ref configuration) 187 { 188 ERROR_DECLARE; 189 184 measured_strings_t *configuration) 185 { 190 186 printf("%s: Reading configuration file %s/%s\n", NAME, directory, filename); 191 187 192 188 /* Construct the full filename */ 193 char line[BUFFER_SIZE];194 if (snprintf( line, BUFFER_SIZE, "%s/%s", directory, filename) > BUFFER_SIZE)189 char fname[BUFFER_SIZE]; 190 if (snprintf(fname, BUFFER_SIZE, "%s/%s", directory, filename) > BUFFER_SIZE) 195 191 return EOVERFLOW; 196 192 197 193 /* Open the file */ 198 FILE *cfg = fopen( line, "r");194 FILE *cfg = fopen(fname, "r"); 199 195 if (!cfg) 200 196 return ENOENT; … … 206 202 unsigned int line_number = 0; 207 203 size_t index = 0; 208 while ((!ferror(cfg)) && (!feof(cfg))) { 204 uint8_t line[BUFFER_SIZE]; 205 206 while (!ferror(cfg) && !feof(cfg)) { 209 207 int read = fgetc(cfg); 210 208 if ((read > 0) && (read != '\n') && (read != '\r')) { 211 209 if (index >= BUFFER_SIZE) { 212 210 line[BUFFER_SIZE - 1] = '\0'; 213 fprintf(stderr, "%s: Configuration line %u too long: %s\n",214 NAME, line_number,line);211 fprintf(stderr, "%s: Configuration line %u too " 212 "long: %s\n", NAME, line_number, (char *) line); 215 213 216 214 /* No space left in the line buffer */ 217 215 return EOVERFLOW; 218 } else {219 /* Append the character */220 line[index] = (char) read;221 index++;222 216 } 217 /* Append the character */ 218 line[index] = (uint8_t) read; 219 index++; 223 220 } else { 224 221 /* On error or new line */ 225 222 line[index] = '\0'; 226 223 line_number++; 227 if (ERROR_OCCURRED(parse_line(configuration, line))) 228 fprintf(stderr, "%s: Configuration error on line %u: %s\n", 229 NAME, line_number, line); 224 if (parse_line(configuration, line) != EOK) { 225 fprintf(stderr, "%s: Configuration error on " 226 "line %u: %s\n", NAME, line_number, (char *) line); 227 } 230 228 231 229 index = 0; … … 242 240 * @param[in,out] netif The network interface structure. 243 241 * 244 * @return sEOK on success.245 * @return sOther error codes as defined for the add_configuration() function.242 * @return EOK on success. 243 * @return Other error codes as defined for the add_configuration() function. 246 244 * 247 245 */ … … 253 251 /** Read the networking subsystem global configuration. 254 252 * 255 * @return sEOK on success.256 * @return sOther error codes as defined for the add_configuration() function.253 * @return EOK on success. 254 * @return Other error codes as defined for the add_configuration() function. 257 255 * 258 256 */ … … 269 267 * its own one. 270 268 * 271 * @return sEOK on success.272 * @return sENOMEM if there is not enough memory left.269 * @return EOK on success. 270 * @return ENOMEM if there is not enough memory left. 273 271 * 274 272 */ 275 273 static int net_initialize(async_client_conn_t client_connection) 276 274 { 277 ERROR_DECLARE;275 int rc; 278 276 279 277 netifs_initialize(&net_globals.netifs); … … 282 280 measured_strings_initialize(&net_globals.configuration); 283 281 284 // TODO: dynamic configuration 285 ERROR_PROPAGATE(read_configuration()); 286 287 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 288 LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service)); 289 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 290 DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service)); 291 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 292 ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, 293 connect_to_service)); 294 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 295 NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, 296 connect_to_service)); 282 /* TODO: dynamic configuration */ 283 rc = read_configuration(); 284 if (rc != EOK) 285 return rc; 286 287 rc = add_module(NULL, &net_globals.modules, (uint8_t *) LO_NAME, 288 (uint8_t *) LO_FILENAME, SERVICE_LO, 0, connect_to_service); 289 if (rc != EOK) 290 return rc; 291 292 rc = add_module(NULL, &net_globals.modules, (uint8_t *) NE2000_NAME, 293 (uint8_t *) NE2000_FILENAME, SERVICE_NE2000, 0, connect_to_service); 294 if (rc != EOK) 295 return rc; 296 297 rc = add_module(NULL, &net_globals.modules, (uint8_t *) ETHERNET_NAME, 298 (uint8_t *) ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service); 299 if (rc != EOK) 300 return rc; 301 302 rc = add_module(NULL, &net_globals.modules, (uint8_t *) NILDUMMY_NAME, 303 (uint8_t *) NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service); 304 if (rc != EOK) 305 return rc; 297 306 298 307 /* Build specific initialization */ … … 312 321 * its own one. 313 322 * 314 * @return sEOK on successful module termination.315 * @return sOther error codes as defined for the net_initialize() function.316 * @return sOther error codes as defined for the REGISTER_ME() macro function.323 * @return EOK on successful module termination. 324 * @return Other error codes as defined for the net_initialize() function. 325 * @return Other error codes as defined for the REGISTER_ME() macro function. 317 326 * 318 327 */ 319 328 static int net_module_start(async_client_conn_t client_connection) 320 329 { 321 ERROR_DECLARE;330 int rc; 322 331 323 332 async_set_client_connection(client_connection); 324 ERROR_PROPAGATE(pm_init()); 325 326 ipcarg_t phonehash; 327 328 if (ERROR_OCCURRED(net_initialize(client_connection)) 329 || ERROR_OCCURRED(REGISTER_ME(SERVICE_NETWORKING, &phonehash))){ 330 pm_destroy(); 331 return ERROR_CODE; 332 } 333 333 rc = pm_init(); 334 if (rc != EOK) 335 return rc; 336 337 rc = net_initialize(client_connection); 338 if (rc != EOK) 339 goto out; 340 341 rc = async_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, NULL); 342 if (rc != EOK) 343 goto out; 344 345 rc = startup(); 346 if (rc != EOK) 347 goto out; 348 349 task_retval(0); 334 350 async_manager(); 335 351 352 out: 336 353 pm_destroy(); 337 return EOK;354 return rc; 338 355 } 339 356 … … 341 358 * 342 359 * The network interface configuration is searched first. 343 &360 * 344 361 * @param[in] netif_conf The network interface configuration setting. 345 362 * @param[out] configuration The found configured values. … … 347 364 * @param[out] data The found configuration settings data. 348 365 * 349 * @return sEOK.350 * 351 */ 352 static int net_get_conf(measured_strings_ refnetif_conf,353 measured_string_ ref configuration, size_t count, char**data)366 * @return EOK. 367 * 368 */ 369 static int net_get_conf(measured_strings_t *netif_conf, 370 measured_string_t *configuration, size_t count, uint8_t **data) 354 371 { 355 372 if (data) … … 358 375 size_t index; 359 376 for (index = 0; index < count; index++) { 360 measured_string_ refsetting =377 measured_string_t *setting = 361 378 measured_strings_find(netif_conf, configuration[index].value, 0); 362 379 if (!setting) … … 376 393 } 377 394 378 int net_get_conf_req(int net_phone, measured_string_ ref*configuration,379 size_t count, char**data)380 { 381 if (! (configuration && (count > 0)))395 int net_get_conf_req(int net_phone, measured_string_t **configuration, 396 size_t count, uint8_t **data) 397 { 398 if (!configuration || (count <= 0)) 382 399 return EINVAL; 383 400 … … 386 403 387 404 int net_get_device_conf_req(int net_phone, device_id_t device_id, 388 measured_string_ ref *configuration, size_t count, char**data)405 measured_string_t **configuration, size_t count, uint8_t **data) 389 406 { 390 407 if ((!configuration) || (count == 0)) … … 398 415 } 399 416 400 void net_free_settings(measured_string_ ref settings, char*data)417 void net_free_settings(measured_string_t *settings, uint8_t *data) 401 418 { 402 419 } … … 409 426 * @param[in] netif The network interface specific data. 410 427 * 411 * @return sEOK on success.412 * @return sEINVAL if there are some settings missing.413 * @return sENOENT if the internet protocol module is not known.414 * @return sOther error codes as defined for the netif_probe_req() function.415 * @return sOther error codes as defined for the nil_device_req() function.416 * @return sOther error codes as defined for the needed internet layer417 * 428 * @return EOK on success. 429 * @return EINVAL if there are some settings missing. 430 * @return ENOENT if the internet protocol module is not known. 431 * @return Other error codes as defined for the netif_probe_req() function. 432 * @return Other error codes as defined for the nil_device_req() function. 433 * @return Other error codes as defined for the needed internet layer 434 * registering function. 418 435 * 419 436 */ 420 437 static int start_device(netif_t *netif) 421 438 { 422 ERROR_DECLARE;439 int rc; 423 440 424 441 /* Mandatory netif */ 425 measured_string_ refsetting =426 measured_strings_find(&netif->configuration, CONF_NETIF, 0);442 measured_string_t *setting = 443 measured_strings_find(&netif->configuration, (uint8_t *) CONF_NETIF, 0); 427 444 428 445 netif->driver = get_running_module(&net_globals.modules, setting->value); … … 434 451 435 452 /* Optional network interface layer */ 436 setting = measured_strings_find(&netif->configuration, CONF_NIL, 0);453 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_NIL, 0); 437 454 if (setting) { 438 455 netif->nil = get_running_module(&net_globals.modules, setting->value); … … 446 463 447 464 /* Mandatory internet layer */ 448 setting = measured_strings_find(&netif->configuration, CONF_IL, 0);465 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IL, 0); 449 466 netif->il = get_running_module(&net_globals.modules, setting->value); 450 467 if (!netif->il) { … … 455 472 456 473 /* Hardware configuration */ 457 setting = measured_strings_find(&netif->configuration, CONF_IRQ, 0); 458 int irq = setting ? strtol(setting->value, NULL, 10) : 0; 459 460 setting = measured_strings_find(&netif->configuration, CONF_IO, 0); 461 int io = setting ? strtol(setting->value, NULL, 16) : 0; 462 463 ERROR_PROPAGATE(netif_probe_req_remote(netif->driver->phone, netif->id, irq, io)); 474 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IRQ, 0); 475 int irq = setting ? strtol((char *) setting->value, NULL, 10) : 0; 476 477 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IO, 0); 478 uintptr_t io = setting ? strtol((char *) setting->value, NULL, 16) : 0; 479 480 rc = netif_probe_req(netif->driver->phone, netif->id, irq, (void *) io); 481 if (rc != EOK) 482 return rc; 464 483 465 484 /* Network interface layer startup */ 466 485 services_t internet_service; 467 486 if (netif->nil) { 468 setting = measured_strings_find(&netif->configuration, CONF_MTU, 0);487 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_MTU, 0); 469 488 if (!setting) 470 489 setting = measured_strings_find(&net_globals.configuration, 471 CONF_MTU, 0); 472 473 int mtu = setting ? strtol(setting->value, NULL, 10) : 0; 474 475 ERROR_PROPAGATE(nil_device_req(netif->nil->phone, netif->id, mtu, 476 netif->driver->service)); 490 (uint8_t *) CONF_MTU, 0); 491 492 int mtu = setting ? strtol((char *) setting->value, NULL, 10) : 0; 493 494 rc = nil_device_req(netif->nil->phone, netif->id, mtu, 495 netif->driver->service); 496 if (rc != EOK) 497 return rc; 477 498 478 499 internet_service = netif->nil->service; … … 482 503 /* Inter-network layer startup */ 483 504 switch (netif->il->service) { 484 case SERVICE_IP: 485 ERROR_PROPAGATE(ip_device_req(netif->il->phone, netif->id, 486 internet_service)); 487 break; 488 default: 489 return ENOENT; 490 } 491 492 ERROR_PROPAGATE(netif_start_req_remote(netif->driver->phone, netif->id)); 493 return EOK; 505 case SERVICE_IP: 506 rc = ip_device_req(netif->il->phone, netif->id, 507 internet_service); 508 if (rc != EOK) 509 return rc; 510 break; 511 default: 512 return ENOENT; 513 } 514 515 return netif_start_req(netif->driver->phone, netif->id); 494 516 } 495 517 496 518 /** Read the configuration and start all network interfaces. 497 519 * 498 * @return sEOK on success.499 * @return sEXDEV if there is no available system-unique device identifier.500 * @return sEINVAL if any of the network interface names are not configured.501 * @return sENOMEM if there is not enough memory left.502 * @return sOther error codes as defined for the read_configuration()503 * 504 * @return sOther error codes as defined for the read_netif_configuration()505 * 506 * @return sOther error codes as defined for the start_device() function.520 * @return EOK on success. 521 * @return EXDEV if there is no available system-unique device identifier. 522 * @return EINVAL if any of the network interface names are not configured. 523 * @return ENOMEM if there is not enough memory left. 524 * @return Other error codes as defined for the read_configuration() 525 * function. 526 * @return Other error codes as defined for the read_netif_configuration() 527 * function. 528 * @return Other error codes as defined for the start_device() function. 507 529 * 508 530 */ 509 531 static int startup(void) 510 532 { 511 ERROR_DECLARE; 512 513 const char *conf_files[] = {"lo", "ne2k"}; 533 const char *conf_files[] = { 534 "lo", 535 "ne2k" 536 }; 514 537 size_t count = sizeof(conf_files) / sizeof(char *); 538 int rc; 515 539 516 540 size_t i; … … 524 548 return EXDEV; 525 549 526 ERROR_PROPAGATE(measured_strings_initialize(&netif->configuration)); 550 rc = measured_strings_initialize(&netif->configuration); 551 if (rc != EOK) 552 return rc; 527 553 528 554 /* Read configuration files */ 529 if (ERROR_OCCURRED(read_netif_configuration(conf_files[i], netif))) { 530 measured_strings_destroy(&netif->configuration); 555 rc = read_netif_configuration(conf_files[i], netif); 556 if (rc != EOK) { 557 measured_strings_destroy(&netif->configuration, free); 531 558 free(netif); 532 return ERROR_CODE;559 return rc; 533 560 } 534 561 535 562 /* Mandatory name */ 536 measured_string_ refsetting =537 measured_strings_find(&netif->configuration, CONF_NAME, 0);563 measured_string_t *setting = 564 measured_strings_find(&netif->configuration, (uint8_t *) CONF_NAME, 0); 538 565 if (!setting) { 539 566 fprintf(stderr, "%s: Network interface name is missing\n", NAME); 540 measured_strings_destroy(&netif->configuration );567 measured_strings_destroy(&netif->configuration, free); 541 568 free(netif); 542 569 return EINVAL; … … 547 574 int index = netifs_add(&net_globals.netifs, netif->id, netif); 548 575 if (index < 0) { 549 measured_strings_destroy(&netif->configuration );576 measured_strings_destroy(&netif->configuration, free); 550 577 free(netif); 551 578 return index; … … 556 583 * and needed modules. 557 584 */ 558 if ((ERROR_OCCURRED(char_map_add(&net_globals.netif_names, 559 netif->name, 0, index))) || (ERROR_OCCURRED(start_device(netif)))) { 560 measured_strings_destroy(&netif->configuration); 561 netifs_exclude_index(&net_globals.netifs, index); 562 return ERROR_CODE; 585 rc = char_map_add(&net_globals.netif_names, netif->name, 0, 586 index); 587 if (rc != EOK) { 588 measured_strings_destroy(&netif->configuration, free); 589 netifs_exclude_index(&net_globals.netifs, index, free); 590 return rc; 591 } 592 593 rc = start_device(netif); 594 if (rc != EOK) { 595 printf("%s: Ignoring failed interface %s (%s)\n", NAME, 596 netif->name, str_error(rc)); 597 measured_strings_destroy(&netif->configuration, free); 598 netifs_exclude_index(&net_globals.netifs, index, free); 599 continue; 563 600 } 564 601 … … 571 608 printf("%s: Network interface started (name: %s, id: %d, driver: %s, " 572 609 "nil: %s, il: %s)\n", NAME, netif->name, netif->id, 573 netif->driver->name, netif->nil ?netif->nil->name : "[none]",610 netif->driver->name, netif->nil ? (char *) netif->nil->name : "[none]", 574 611 netif->il->name); 575 612 } … … 580 617 /** Process the networking message. 581 618 * 582 * @param[in] callidThe message identifier.583 * @param[in] callThe message parameters.619 * @param[in] callid The message identifier. 620 * @param[in] call The message parameters. 584 621 * @param[out] answer The message answer parameters. 585 622 * @param[out] answer_count The last parameter for the actual answer 586 623 * in the answer parameter. 587 624 * 588 * @return sEOK on success.589 * @return sENOTSUP if the message is not known.625 * @return EOK on success. 626 * @return ENOTSUP if the message is not known. 590 627 * 591 628 * @see net_interface.h … … 594 631 */ 595 632 int net_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 596 int *answer_count) 597 { 598 ERROR_DECLARE; 599 600 measured_string_ref strings; 601 char *data; 633 size_t *answer_count) 634 { 635 measured_string_t *strings; 636 uint8_t *data; 637 int rc; 602 638 603 639 *answer_count = 0; 604 switch (IPC_GET_METHOD(*call)) { 605 case IPC_M_PHONE_HUNGUP: 606 return EOK; 607 case NET_NET_GET_DEVICE_CONF: 608 ERROR_PROPAGATE(measured_strings_receive(&strings, &data, 609 IPC_GET_COUNT(call))); 610 net_get_device_conf_req(0, IPC_GET_DEVICE(call), &strings, 611 IPC_GET_COUNT(call), NULL); 612 613 /* Strings should not contain received data anymore */ 614 free(data); 615 616 ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call)); 617 free(strings); 618 return ERROR_CODE; 619 case NET_NET_GET_CONF: 620 ERROR_PROPAGATE(measured_strings_receive(&strings, &data, 621 IPC_GET_COUNT(call))); 622 net_get_conf_req(0, &strings, IPC_GET_COUNT(call), NULL); 623 624 /* Strings should not contain received data anymore */ 625 free(data); 626 627 ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call)); 628 free(strings); 629 return ERROR_CODE; 630 case NET_NET_STARTUP: 631 return startup(); 632 } 640 switch (IPC_GET_IMETHOD(*call)) { 641 case IPC_M_PHONE_HUNGUP: 642 return EOK; 643 case NET_NET_GET_DEVICE_CONF: 644 rc = measured_strings_receive(&strings, &data, 645 IPC_GET_COUNT(*call)); 646 if (rc != EOK) 647 return rc; 648 net_get_device_conf_req(0, IPC_GET_DEVICE(*call), &strings, 649 IPC_GET_COUNT(*call), NULL); 650 651 /* Strings should not contain received data anymore */ 652 free(data); 653 654 rc = measured_strings_reply(strings, IPC_GET_COUNT(*call)); 655 free(strings); 656 return rc; 657 case NET_NET_GET_CONF: 658 rc = measured_strings_receive(&strings, &data, 659 IPC_GET_COUNT(*call)); 660 if (rc != EOK) 661 return rc; 662 net_get_conf_req(0, &strings, IPC_GET_COUNT(*call), NULL); 663 664 /* Strings should not contain received data anymore */ 665 free(data); 666 667 rc = measured_strings_reply(strings, IPC_GET_COUNT(*call)); 668 free(strings); 669 return rc; 670 case NET_NET_STARTUP: 671 return startup(); 672 } 673 633 674 return ENOTSUP; 634 675 } … … 646 687 * - Answer the first IPC_M_CONNECT_ME_TO call. 647 688 */ 648 ipc_answer_0(iid, EOK);689 async_answer_0(iid, EOK); 649 690 650 691 while (true) { 651 692 /* Clear the answer structure */ 652 693 ipc_call_t answer; 653 int answer_count;694 size_t answer_count; 654 695 refresh_answer(&answer, &answer_count); 655 696 … … 661 702 int res = net_module_message(callid, &call, &answer, &answer_count); 662 703 663 /* End if said to either by the message or the processing result */664 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))704 /* End if told to either by the message or the processing result */ 705 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP)) 665 706 return; 666 707 … … 672 713 int main(int argc, char *argv[]) 673 714 { 674 ERROR_DECLARE; 675 676 if (ERROR_OCCURRED(net_module_start(net_client_connection))) { 677 fprintf(stderr, "%s: net_module_start error %i\n", NAME, ERROR_CODE); 678 return ERROR_CODE; 679 } 680 681 return EOK; 715 return net_module_start(net_client_connection); 682 716 } 683 717
Note:
See TracChangeset
for help on using the changeset viewer.