Changeset 89c57b6 in mainline for uspace/srv/net/net/net.c


Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    rcefb126 r89c57b6  
    3636 */
    3737
     38#include "net.h"
     39
    3840#include <async.h>
    3941#include <ctype.h>
     
    4345#include <stdio.h>
    4446#include <str.h>
    45 
    46 #include <ipc/ipc.h>
     47#include <str_error.h>
     48
    4749#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
    5259#include <adt/char_map.h>
    5360#include <adt/generic_char_map.h>
    5461#include <adt/measured_strings.h>
    5562#include <adt/module_map.h>
    56 #include <packet/packet.h>
    57 #include <il_messages.h>
     63
    5864#include <netif_remote.h>
    59 #include <net_device.h>
    60 #include <nil_interface.h>
     65#include <nil_remote.h>
    6166#include <net_interface.h>
    6267#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. */
    7070#define NAME  "net"
    7171
    72 /** File read buffer size.
    73  *
    74  */
     72/** File read buffer size. */
    7573#define BUFFER_SIZE  256
    7674
    77 /** Networking module global data.
    78  *
    79  */
     75/** Networking module global data. */
    8076net_globals_t net_globals;
    8177
    8278GENERIC_CHAR_MAP_IMPLEMENT(measured_strings, measured_string_t);
    8379DEVICE_MAP_IMPLEMENT(netifs, netif_t);
     80
     81static int startup(void);
    8482
    8583/** Add the configured setting to the configuration map.
     
    8987 * @param[in] value         The setting value.
    9088 *
    91  * @returns EOK on success.
    92  * @returns ENOMEM 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_ref setting =
     89 * @return EOK on success.
     90 * @return ENOMEM if there is not enough memory left.
     91 *
     92 */
     93int 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 =
    10199            measured_string_create_bulk(value, 0);
    102        
    103100        if (!setting)
    104101                return ENOMEM;
    105102       
    106103        /* 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) {
    108106                free(setting);
    109                 return ERROR_CODE;
     107                return rc;
    110108        }
    111109       
     
    115113/** Generate new system-unique device identifier.
    116114 *
    117  * @returns The system-unique devic identifier.
    118  *
     115 * @return              The system-unique devic identifier.
    119116 */
    120117static device_id_t generate_new_device_id(void)
     
    123120}
    124121
    125 static int parse_line(measured_strings_ref configuration, char *line)
    126 {
    127         ERROR_DECLARE;
     122static int parse_line(measured_strings_t *configuration, uint8_t *line)
     123{
     124        int rc;
    128125       
    129126        /* From the beginning */
    130         char *name = line;
     127        uint8_t *name = line;
    131128       
    132129        /* Skip comments and blank lines */
     
    139136       
    140137        /* Remember the name start */
    141         char *value = name;
     138        uint8_t *value = name;
    142139       
    143140        /* Skip the name */
     
    169166       
    170167        /* Create a bulk measured string till the end */
    171         measured_string_ref setting =
     168        measured_string_t *setting =
    172169            measured_string_create_bulk(value, 0);
    173170        if (!setting)
     
    175172       
    176173        /* 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) {
    178176                free(setting);
    179                 return ERROR_CODE;
     177                return rc;
    180178        }
    181179       
     
    184182
    185183static 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{
    190186        printf("%s: Reading configuration file %s/%s\n", NAME, directory, filename);
    191187       
    192188        /* 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)
    195191                return EOVERFLOW;
    196192       
    197193        /* Open the file */
    198         FILE *cfg = fopen(line, "r");
     194        FILE *cfg = fopen(fname, "r");
    199195        if (!cfg)
    200196                return ENOENT;
     
    206202        unsigned int line_number = 0;
    207203        size_t index = 0;
    208         while ((!ferror(cfg)) && (!feof(cfg))) {
     204        uint8_t line[BUFFER_SIZE];
     205       
     206        while (!ferror(cfg) && !feof(cfg)) {
    209207                int read = fgetc(cfg);
    210208                if ((read > 0) && (read != '\n') && (read != '\r')) {
    211209                        if (index >= BUFFER_SIZE) {
    212210                                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);
    215213                               
    216214                                /* No space left in the line buffer */
    217215                                return EOVERFLOW;
    218                         } else {
    219                                 /* Append the character */
    220                                 line[index] = (char) read;
    221                                 index++;
    222216                        }
     217                        /* Append the character */
     218                        line[index] = (uint8_t) read;
     219                        index++;
    223220                } else {
    224221                        /* On error or new line */
    225222                        line[index] = '\0';
    226223                        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                        }
    230228                       
    231229                        index = 0;
     
    242240 * @param[in,out] netif The network interface structure.
    243241 *
    244  * @returns EOK on success.
    245  * @returns Other 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.
    246244 *
    247245 */
     
    253251/** Read the networking subsystem global configuration.
    254252 *
    255  * @returns EOK on success.
    256  * @returns Other 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.
    257255 *
    258256 */
     
    269267 *                              its own one.
    270268 *
    271  * @returns EOK on success.
    272  * @returns ENOMEM if there is not enough memory left.
     269 * @return EOK on success.
     270 * @return ENOMEM if there is not enough memory left.
    273271 *
    274272 */
    275273static int net_initialize(async_client_conn_t client_connection)
    276274{
    277         ERROR_DECLARE;
     275        int rc;
    278276       
    279277        netifs_initialize(&net_globals.netifs);
     
    282280        measured_strings_initialize(&net_globals.configuration);
    283281       
    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;
    297306       
    298307        /* Build specific initialization */
     
    312321 *                              its own one.
    313322 *
    314  * @returns EOK on successful module termination.
    315  * @returns Other error codes as defined for the net_initialize() function.
    316  * @returns Other 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.
    317326 *
    318327 */
    319328static int net_module_start(async_client_conn_t client_connection)
    320329{
    321         ERROR_DECLARE;
     330        int rc;
    322331       
    323332        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);
    334350        async_manager();
    335        
     351
     352out:
    336353        pm_destroy();
    337         return EOK;
     354        return rc;
    338355}
    339356
     
    341358 *
    342359 * The network interface configuration is searched first.
    343  &
     360 *
    344361 * @param[in]  netif_conf    The network interface configuration setting.
    345362 * @param[out] configuration The found configured values.
     
    347364 * @param[out] data          The found configuration settings data.
    348365 *
    349  * @returns EOK.
    350  *
    351  */
    352 static int net_get_conf(measured_strings_ref netif_conf,
    353     measured_string_ref configuration, size_t count, char **data)
     366 * @return EOK.
     367 *
     368 */
     369static int net_get_conf(measured_strings_t *netif_conf,
     370    measured_string_t *configuration, size_t count, uint8_t **data)
    354371{
    355372        if (data)
     
    358375        size_t index;
    359376        for (index = 0; index < count; index++) {
    360                 measured_string_ref setting =
     377                measured_string_t *setting =
    361378                    measured_strings_find(netif_conf, configuration[index].value, 0);
    362379                if (!setting)
     
    376393}
    377394
    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)))
     395int net_get_conf_req(int net_phone, measured_string_t **configuration,
     396    size_t count, uint8_t **data)
     397{
     398        if (!configuration || (count <= 0))
    382399                return EINVAL;
    383400       
     
    386403
    387404int 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)
    389406{
    390407        if ((!configuration) || (count == 0))
     
    398415}
    399416
    400 void net_free_settings(measured_string_ref settings, char *data)
     417void net_free_settings(measured_string_t *settings, uint8_t *data)
    401418{
    402419}
     
    409426 * @param[in] netif The network interface specific data.
    410427 *
    411  * @returns EOK on success.
    412  * @returns EINVAL if there are some settings missing.
    413  * @returns ENOENT if the internet protocol module is not known.
    414  * @returns Other error codes as defined for the netif_probe_req() function.
    415  * @returns Other error codes as defined for the nil_device_req() function.
    416  * @returns Other error codes as defined for the needed internet layer
    417  *          registering function.
     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.
    418435 *
    419436 */
    420437static int start_device(netif_t *netif)
    421438{
    422         ERROR_DECLARE;
     439        int rc;
    423440       
    424441        /* Mandatory netif */
    425         measured_string_ref setting =
    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);
    427444       
    428445        netif->driver = get_running_module(&net_globals.modules, setting->value);
     
    434451       
    435452        /* 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);
    437454        if (setting) {
    438455                netif->nil = get_running_module(&net_globals.modules, setting->value);
     
    446463       
    447464        /* 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);
    449466        netif->il = get_running_module(&net_globals.modules, setting->value);
    450467        if (!netif->il) {
     
    455472       
    456473        /* 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;
    464483       
    465484        /* Network interface layer startup */
    466485        services_t internet_service;
    467486        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);
    469488                if (!setting)
    470489                        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;
    477498               
    478499                internet_service = netif->nil->service;
     
    482503        /* Inter-network layer startup */
    483504        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);
    494516}
    495517
    496518/** Read the configuration and start all network interfaces.
    497519 *
    498  * @returns EOK on success.
    499  * @returns EXDEV if there is no available system-unique device identifier.
    500  * @returns EINVAL if any of the network interface names are not configured.
    501  * @returns ENOMEM if there is not enough memory left.
    502  * @returns Other error codes as defined for the read_configuration()
    503  *          function.
    504  * @returns Other error codes as defined for the read_netif_configuration()
    505  *          function.
    506  * @returns Other 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.
    507529 *
    508530 */
    509531static int startup(void)
    510532{
    511         ERROR_DECLARE;
    512        
    513         const char *conf_files[] = {"lo", "ne2k"};
     533        const char *conf_files[] = {
     534                "lo",
     535                "ne2k"
     536        };
    514537        size_t count = sizeof(conf_files) / sizeof(char *);
     538        int rc;
    515539       
    516540        size_t i;
     
    524548                        return EXDEV;
    525549               
    526                 ERROR_PROPAGATE(measured_strings_initialize(&netif->configuration));
     550                rc = measured_strings_initialize(&netif->configuration);
     551                if (rc != EOK)
     552                        return rc;
    527553               
    528554                /* 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);
    531558                        free(netif);
    532                         return ERROR_CODE;
     559                        return rc;
    533560                }
    534561               
    535562                /* Mandatory name */
    536                 measured_string_ref setting =
    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);
    538565                if (!setting) {
    539566                        fprintf(stderr, "%s: Network interface name is missing\n", NAME);
    540                         measured_strings_destroy(&netif->configuration);
     567                        measured_strings_destroy(&netif->configuration, free);
    541568                        free(netif);
    542569                        return EINVAL;
     
    547574                int index = netifs_add(&net_globals.netifs, netif->id, netif);
    548575                if (index < 0) {
    549                         measured_strings_destroy(&netif->configuration);
     576                        measured_strings_destroy(&netif->configuration, free);
    550577                        free(netif);
    551578                        return index;
     
    556583                 * and needed modules.
    557584                 */
    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;
    563600                }
    564601               
     
    571608                printf("%s: Network interface started (name: %s, id: %d, driver: %s, "
    572609                    "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]",
    574611                    netif->il->name);
    575612        }
     
    580617/** Process the networking message.
    581618 *
    582  * @param[in] callid        The message identifier.
    583  * @param[in] call          The message parameters.
     619 * @param[in]  callid       The message identifier.
     620 * @param[in]  call         The message parameters.
    584621 * @param[out] answer       The message answer parameters.
    585622 * @param[out] answer_count The last parameter for the actual answer
    586623 *                          in the answer parameter.
    587624 *
    588  * @returns EOK on success.
    589  * @returns ENOTSUP if the message is not known.
     625 * @return EOK on success.
     626 * @return ENOTSUP if the message is not known.
    590627 *
    591628 * @see net_interface.h
     
    594631 */
    595632int 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;
    602638       
    603639        *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       
    633674        return ENOTSUP;
    634675}
     
    646687         *  - Answer the first IPC_M_CONNECT_ME_TO call.
    647688         */
    648         ipc_answer_0(iid, EOK);
     689        async_answer_0(iid, EOK);
    649690       
    650691        while (true) {
    651692                /* Clear the answer structure */
    652693                ipc_call_t answer;
    653                 int answer_count;
     694                size_t answer_count;
    654695                refresh_answer(&answer, &answer_count);
    655696               
     
    661702                int res = net_module_message(callid, &call, &answer, &answer_count);
    662703               
    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))
    665706                        return;
    666707               
     
    672713int main(int argc, char *argv[])
    673714{
    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);
    682716}
    683717
Note: See TracChangeset for help on using the changeset viewer.