Changeset 61bfc370 in mainline for uspace/srv/net/net/net.c
- Timestamp:
- 2011-01-07T18:57:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e08a733
- Parents:
- 7c34b28f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/net/net.c
r7c34b28f r61bfc370 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;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 int io = setting ? strtol((char *) setting->value, NULL, 16) : 0; 475 477 476 478 rc = netif_probe_req_remote(netif->driver->phone, netif->id, irq, io); … … 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, … … 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 } … … 628 630 { 629 631 measured_string_t *strings; 630 char*data;632 uint8_t *data; 631 633 int rc; 632 634
Note:
See TracChangeset
for help on using the changeset viewer.