Changeset 1ffa73b in mainline for uspace/srv/net/net/net.c


Ignore:
Timestamp:
2011-01-10T16:33:08Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b207803
Parents:
863d45e (diff), 6610565b (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.
Message:

Merge development/ changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/net/net.c

    r863d45e r1ffa73b  
    9090 *
    9191 */
    92 int add_configuration(measured_strings_t *configuration, const char *name,
    93     const char *value)
     92int add_configuration(measured_strings_t *configuration, const uint8_t *name,
     93    const uint8_t *value)
    9494{
    9595        int rc;
     
    119119}
    120120
    121 static int parse_line(measured_strings_t *configuration, char *line)
     121static int parse_line(measured_strings_t *configuration, uint8_t *line)
    122122{
    123123        int rc;
    124124       
    125125        /* From the beginning */
    126         char *name = line;
     126        uint8_t *name = line;
    127127       
    128128        /* Skip comments and blank lines */
     
    135135       
    136136        /* Remember the name start */
    137         char *value = name;
     137        uint8_t *value = name;
    138138       
    139139        /* Skip the name */
     
    186186       
    187187        /* 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)
    190190                return EOVERFLOW;
    191191       
    192192        /* Open the file */
    193         FILE *cfg = fopen(line, "r");
     193        FILE *cfg = fopen(fname, "r");
    194194        if (!cfg)
    195195                return ENOENT;
     
    201201        unsigned int line_number = 0;
    202202        size_t index = 0;
     203        uint8_t line[BUFFER_SIZE];
     204       
    203205        while (!ferror(cfg) && !feof(cfg)) {
    204206                int read = fgetc(cfg);
     
    207209                                line[BUFFER_SIZE - 1] = '\0';
    208210                                fprintf(stderr, "%s: Configuration line %u too "
    209                                     "long: %s\n", NAME, line_number, line);
     211                                    "long: %s\n", NAME, line_number, (char *) line);
    210212                               
    211213                                /* No space left in the line buffer */
     
    213215                        }
    214216                        /* Append the character */
    215                         line[index] = (char) read;
     217                        line[index] = (uint8_t) read;
    216218                        index++;
    217219                } else {
     
    221223                        if (parse_line(configuration, line) != EOK) {
    222224                                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);
    224226                        }
    225227                       
     
    282284                return rc;
    283285       
    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);
    298300        if (rc != EOK)
    299301                return rc;
     
    364366 */
    365367static 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)
    367369{
    368370        if (data)
     
    390392
    391393int net_get_conf_req(int net_phone, measured_string_t **configuration,
    392     size_t count, char **data)
     394    size_t count, uint8_t **data)
    393395{
    394396        if (!configuration || (count <= 0))
     
    399401
    400402int 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)
    402404{
    403405        if ((!configuration) || (count == 0))
     
    411413}
    412414
    413 void net_free_settings(measured_string_t *settings, char *data)
     415void net_free_settings(measured_string_t *settings, uint8_t *data)
    414416{
    415417}
     
    437439        /* Mandatory netif */
    438440        measured_string_t *setting =
    439             measured_strings_find(&netif->configuration, CONF_NETIF, 0);
     441            measured_strings_find(&netif->configuration, (uint8_t *) CONF_NETIF, 0);
    440442       
    441443        netif->driver = get_running_module(&net_globals.modules, setting->value);
     
    447449       
    448450        /* 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);
    450452        if (setting) {
    451453                netif->nil = get_running_module(&net_globals.modules, setting->value);
     
    459461       
    460462        /* 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);
    462464        netif->il = get_running_module(&net_globals.modules, setting->value);
    463465        if (!netif->il) {
     
    468470       
    469471        /* 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);
    477479        if (rc != EOK)
    478480                return rc;
     
    481483        services_t internet_service;
    482484        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);
    484486                if (!setting)
    485487                        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;
    489491               
    490492                rc = nil_device_req(netif->nil->phone, netif->id, mtu,
     
    509511        }
    510512       
    511         return netif_start_req_remote(netif->driver->phone, netif->id);
     513        return netif_start_req(netif->driver->phone, netif->id);
    512514}
    513515
     
    558560                /* Mandatory name */
    559561                measured_string_t *setting =
    560                     measured_strings_find(&netif->configuration, CONF_NAME, 0);
     562                    measured_strings_find(&netif->configuration, (uint8_t *) CONF_NAME, 0);
    561563                if (!setting) {
    562564                        fprintf(stderr, "%s: Network interface name is missing\n", NAME);
     
    602604                printf("%s: Network interface started (name: %s, id: %d, driver: %s, "
    603605                    "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]",
    605607                    netif->il->name);
    606608        }
     
    611613/** Process the networking message.
    612614 *
    613  * @param[in] callid        The message identifier.
    614  * @param[in] call          The message parameters.
     615 * @param[in]  callid       The message identifier.
     616 * @param[in]  call         The message parameters.
    615617 * @param[out] answer       The message answer parameters.
    616618 * @param[out] answer_count The last parameter for the actual answer
     
    625627 */
    626628int net_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer,
    627     int *answer_count)
     629    size_t *answer_count)
    628630{
    629631        measured_string_t *strings;
    630         char *data;
     632        uint8_t *data;
    631633        int rc;
    632634       
     
    637639        case NET_NET_GET_DEVICE_CONF:
    638640                rc = measured_strings_receive(&strings, &data,
    639                     IPC_GET_COUNT(call));
     641                    IPC_GET_COUNT(*call));
    640642                if (rc != EOK)
    641643                        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);
    644646               
    645647                /* Strings should not contain received data anymore */
    646648                free(data);
    647649               
    648                 rc = measured_strings_reply(strings, IPC_GET_COUNT(call));
     650                rc = measured_strings_reply(strings, IPC_GET_COUNT(*call));
    649651                free(strings);
    650652                return rc;
    651653        case NET_NET_GET_CONF:
    652654                rc = measured_strings_receive(&strings, &data,
    653                     IPC_GET_COUNT(call));
     655                    IPC_GET_COUNT(*call));
    654656                if (rc != EOK)
    655657                        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);
    657659               
    658660                /* Strings should not contain received data anymore */
    659661                free(data);
    660662               
    661                 rc = measured_strings_reply(strings, IPC_GET_COUNT(call));
     663                rc = measured_strings_reply(strings, IPC_GET_COUNT(*call));
    662664                free(strings);
    663665                return rc;
     
    686688                /* Clear the answer structure */
    687689                ipc_call_t answer;
    688                 int answer_count;
     690                size_t answer_count;
    689691                refresh_answer(&answer, &answer_count);
    690692               
Note: See TracChangeset for help on using the changeset viewer.