Changeset 6610565b in mainline for uspace/srv/net/net/net.c
- Timestamp:
- 2011-01-10T16:20:56Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1ffa73b, 8048c648, 8426912a, 977fcea, f401312
- Parents:
- a97ea0f (diff), 4a5c6c1 (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
ra97ea0f r6610565b 90 90 * 91 91 */ 92 int add_configuration(measured_strings_t *configuration, const char*name,93 const char*value)92 int add_configuration(measured_strings_t *configuration, const uint8_t *name, 93 const uint8_t *value) 94 94 { 95 95 int rc; … … 119 119 } 120 120 121 static int parse_line(measured_strings_t *configuration, char*line)121 static int parse_line(measured_strings_t *configuration, uint8_t *line) 122 122 { 123 123 int rc; 124 124 125 125 /* From the beginning */ 126 char*name = line;126 uint8_t *name = line; 127 127 128 128 /* Skip comments and blank lines */ … … 135 135 136 136 /* Remember the name start */ 137 char*value = name;137 uint8_t *value = name; 138 138 139 139 /* Skip the name */ … … 186 186 187 187 /* Construct the full filename */ 188 char line[BUFFER_SIZE];189 if (snprintf( line, BUFFER_SIZE, "%s/%s", directory, filename) > BUFFER_SIZE)188 char fname[BUFFER_SIZE]; 189 if (snprintf(fname, BUFFER_SIZE, "%s/%s", directory, filename) > BUFFER_SIZE) 190 190 return EOVERFLOW; 191 191 192 192 /* Open the file */ 193 FILE *cfg = fopen( line, "r");193 FILE *cfg = fopen(fname, "r"); 194 194 if (!cfg) 195 195 return ENOENT; … … 201 201 unsigned int line_number = 0; 202 202 size_t index = 0; 203 uint8_t line[BUFFER_SIZE]; 204 203 205 while (!ferror(cfg) && !feof(cfg)) { 204 206 int read = fgetc(cfg); … … 207 209 line[BUFFER_SIZE - 1] = '\0'; 208 210 fprintf(stderr, "%s: Configuration line %u too " 209 "long: %s\n", NAME, line_number, line);211 "long: %s\n", NAME, line_number, (char *) line); 210 212 211 213 /* No space left in the line buffer */ … … 213 215 } 214 216 /* Append the character */ 215 line[index] = ( char) read;217 line[index] = (uint8_t) read; 216 218 index++; 217 219 } else { … … 221 223 if (parse_line(configuration, line) != EOK) { 222 224 fprintf(stderr, "%s: Configuration error on " 223 "line %u: %s\n", NAME, line_number, line);225 "line %u: %s\n", NAME, line_number, (char *) line); 224 226 } 225 227 … … 282 284 return rc; 283 285 284 rc = add_module(NULL, &net_globals.modules, LO_NAME, LO_FILENAME,285 SERVICE_LO, 0, connect_to_service);286 if (rc != EOK) 287 return rc; 288 rc = add_module(NULL, &net_globals.modules, DP8390_NAME,289 DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service);290 if (rc != EOK) 291 return rc; 292 rc = add_module(NULL, &net_globals.modules, ETHERNET_NAME,293 ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service);294 if (rc != EOK) 295 return rc; 296 rc = add_module(NULL, &net_globals.modules, NILDUMMY_NAME,297 NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service);286 rc = add_module(NULL, &net_globals.modules, (uint8_t *) LO_NAME, 287 (uint8_t *) LO_FILENAME, SERVICE_LO, 0, connect_to_service); 288 if (rc != EOK) 289 return rc; 290 rc = add_module(NULL, &net_globals.modules, (uint8_t *) DP8390_NAME, 291 (uint8_t *) DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service); 292 if (rc != EOK) 293 return rc; 294 rc = add_module(NULL, &net_globals.modules, (uint8_t *) ETHERNET_NAME, 295 (uint8_t *) ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service); 296 if (rc != EOK) 297 return rc; 298 rc = add_module(NULL, &net_globals.modules, (uint8_t *) NILDUMMY_NAME, 299 (uint8_t *) NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service); 298 300 if (rc != EOK) 299 301 return rc; … … 364 366 */ 365 367 static int net_get_conf(measured_strings_t *netif_conf, 366 measured_string_t *configuration, size_t count, char**data)368 measured_string_t *configuration, size_t count, uint8_t **data) 367 369 { 368 370 if (data) … … 390 392 391 393 int net_get_conf_req(int net_phone, measured_string_t **configuration, 392 size_t count, char**data)394 size_t count, uint8_t **data) 393 395 { 394 396 if (!configuration || (count <= 0)) … … 399 401 400 402 int net_get_device_conf_req(int net_phone, device_id_t device_id, 401 measured_string_t **configuration, size_t count, char**data)403 measured_string_t **configuration, size_t count, uint8_t **data) 402 404 { 403 405 if ((!configuration) || (count == 0)) … … 411 413 } 412 414 413 void net_free_settings(measured_string_t *settings, char*data)415 void net_free_settings(measured_string_t *settings, uint8_t *data) 414 416 { 415 417 } … … 437 439 /* Mandatory netif */ 438 440 measured_string_t *setting = 439 measured_strings_find(&netif->configuration, CONF_NETIF, 0);441 measured_strings_find(&netif->configuration, (uint8_t *) CONF_NETIF, 0); 440 442 441 443 netif->driver = get_running_module(&net_globals.modules, setting->value); … … 447 449 448 450 /* Optional network interface layer */ 449 setting = measured_strings_find(&netif->configuration, CONF_NIL, 0);451 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_NIL, 0); 450 452 if (setting) { 451 453 netif->nil = get_running_module(&net_globals.modules, setting->value); … … 459 461 460 462 /* Mandatory internet layer */ 461 setting = measured_strings_find(&netif->configuration, CONF_IL, 0);463 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IL, 0); 462 464 netif->il = get_running_module(&net_globals.modules, setting->value); 463 465 if (!netif->il) { … … 468 470 469 471 /* Hardware configuration */ 470 setting = measured_strings_find(&netif->configuration, CONF_IRQ, 0);471 int irq = setting ? strtol( setting->value, NULL, 10) : 0;472 473 setting = measured_strings_find(&netif->configuration, CONF_IO, 0);474 int io = setting ? strtol(setting->value, NULL, 16) : 0;475 476 rc = netif_probe_req _remote(netif->driver->phone, netif->id, irq,io);472 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IRQ, 0); 473 int irq = setting ? strtol((char *) setting->value, NULL, 10) : 0; 474 475 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IO, 0); 476 uintptr_t io = setting ? strtol((char *) setting->value, NULL, 16) : 0; 477 478 rc = netif_probe_req(netif->driver->phone, netif->id, irq, (void *) io); 477 479 if (rc != EOK) 478 480 return rc; … … 481 483 services_t internet_service; 482 484 if (netif->nil) { 483 setting = measured_strings_find(&netif->configuration, CONF_MTU, 0);485 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_MTU, 0); 484 486 if (!setting) 485 487 setting = measured_strings_find(&net_globals.configuration, 486 CONF_MTU, 0);487 488 int mtu = setting ? strtol( setting->value, NULL, 10) : 0;488 (uint8_t *) CONF_MTU, 0); 489 490 int mtu = setting ? strtol((char *) setting->value, NULL, 10) : 0; 489 491 490 492 rc = nil_device_req(netif->nil->phone, netif->id, mtu, … … 509 511 } 510 512 511 return netif_start_req _remote(netif->driver->phone, netif->id);513 return netif_start_req(netif->driver->phone, netif->id); 512 514 } 513 515 … … 558 560 /* Mandatory name */ 559 561 measured_string_t *setting = 560 measured_strings_find(&netif->configuration, CONF_NAME, 0);562 measured_strings_find(&netif->configuration, (uint8_t *) CONF_NAME, 0); 561 563 if (!setting) { 562 564 fprintf(stderr, "%s: Network interface name is missing\n", NAME); … … 602 604 printf("%s: Network interface started (name: %s, id: %d, driver: %s, " 603 605 "nil: %s, il: %s)\n", NAME, netif->name, netif->id, 604 netif->driver->name, netif->nil ?netif->nil->name : "[none]",606 netif->driver->name, netif->nil ? (char *) netif->nil->name : "[none]", 605 607 netif->il->name); 606 608 } … … 611 613 /** Process the networking message. 612 614 * 613 * @param[in] callidThe message identifier.614 * @param[in] callThe message parameters.615 * @param[in] callid The message identifier. 616 * @param[in] call The message parameters. 615 617 * @param[out] answer The message answer parameters. 616 618 * @param[out] answer_count The last parameter for the actual answer … … 625 627 */ 626 628 int net_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 627 int *answer_count)629 size_t *answer_count) 628 630 { 629 631 measured_string_t *strings; 630 char*data;632 uint8_t *data; 631 633 int rc; 632 634 … … 637 639 case NET_NET_GET_DEVICE_CONF: 638 640 rc = measured_strings_receive(&strings, &data, 639 IPC_GET_COUNT( call));641 IPC_GET_COUNT(*call)); 640 642 if (rc != EOK) 641 643 return rc; 642 net_get_device_conf_req(0, IPC_GET_DEVICE( call), &strings,643 IPC_GET_COUNT( call), NULL);644 net_get_device_conf_req(0, IPC_GET_DEVICE(*call), &strings, 645 IPC_GET_COUNT(*call), NULL); 644 646 645 647 /* Strings should not contain received data anymore */ 646 648 free(data); 647 649 648 rc = measured_strings_reply(strings, IPC_GET_COUNT( call));650 rc = measured_strings_reply(strings, IPC_GET_COUNT(*call)); 649 651 free(strings); 650 652 return rc; 651 653 case NET_NET_GET_CONF: 652 654 rc = measured_strings_receive(&strings, &data, 653 IPC_GET_COUNT( call));655 IPC_GET_COUNT(*call)); 654 656 if (rc != EOK) 655 657 return rc; 656 net_get_conf_req(0, &strings, IPC_GET_COUNT( call), NULL);658 net_get_conf_req(0, &strings, IPC_GET_COUNT(*call), NULL); 657 659 658 660 /* Strings should not contain received data anymore */ 659 661 free(data); 660 662 661 rc = measured_strings_reply(strings, IPC_GET_COUNT( call));663 rc = measured_strings_reply(strings, IPC_GET_COUNT(*call)); 662 664 free(strings); 663 665 return rc; … … 686 688 /* Clear the answer structure */ 687 689 ipc_call_t answer; 688 int answer_count;690 size_t answer_count; 689 691 refresh_answer(&answer, &answer_count); 690 692
Note:
See TracChangeset
for help on using the changeset viewer.