Changes in / [3da12d74:9fd39d6] in mainline


Ignore:
Location:
uspace
Files:
4 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/netstart/Makefile

    r3da12d74 r9fd39d6  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBNET_PREFIX)/libnet.a
    32 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include
     31LIBS =
     32EXTRA_CFLAGS =
    3333
    3434BINARY = netstart
  • uspace/srv/net/net/net.c

    r3da12d74 r9fd39d6  
    4242#include <ddi.h>
    4343#include <errno.h>
    44 #include <err.h>
    4544#include <malloc.h>
    4645#include <stdio.h>
     
    9291    const char *value)
    9392{
    94         ERROR_DECLARE;
     93        int rc;
    9594       
    9695        measured_string_ref setting =
     
    10099       
    101100        /* Add the configuration setting */
    102         if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) {
     101        rc = measured_strings_add(configuration, name, 0, setting);
     102        if (rc != EOK) {
    103103                free(setting);
    104                 return ERROR_CODE;
     104                return rc;
    105105        }
    106106       
     
    110110/** Generate new system-unique device identifier.
    111111 *
    112  * @returns The system-unique devic identifier.
    113  *
     112 * @returns             The system-unique devic identifier.
    114113 */
    115114static device_id_t generate_new_device_id(void)
     
    120119static int parse_line(measured_strings_ref configuration, char *line)
    121120{
    122         ERROR_DECLARE;
     121        int rc;
    123122       
    124123        /* From the beginning */
     
    170169       
    171170        /* Add the configuration setting */
    172         if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) {
     171        rc = measured_strings_add(configuration, name, 0, setting);
     172        if (rc != EOK) {
    173173                free(setting);
    174                 return ERROR_CODE;
     174                return rc;
    175175        }
    176176       
     
    181181    measured_strings_ref configuration)
    182182{
    183         ERROR_DECLARE;
    184        
    185183        printf("%s: Reading configuration file %s/%s\n", NAME, directory, filename);
    186184       
     
    206204                        if (index >= BUFFER_SIZE) {
    207205                                line[BUFFER_SIZE - 1] = '\0';
    208                                 fprintf(stderr, "%s: Configuration line %u too long: %s\n",
    209                                     NAME, line_number, line);
     206                                fprintf(stderr, "%s: Configuration line %u too "
     207                                    "long: %s\n", NAME, line_number, line);
    210208                               
    211209                                /* No space left in the line buffer */
    212210                                return EOVERFLOW;
    213                         } else {
    214                                 /* Append the character */
    215                                 line[index] = (char) read;
    216                                 index++;
    217211                        }
     212                        /* Append the character */
     213                        line[index] = (char) read;
     214                        index++;
    218215                } else {
    219216                        /* On error or new line */
    220217                        line[index] = '\0';
    221218                        line_number++;
    222                         if (ERROR_OCCURRED(parse_line(configuration, line)))
    223                                 fprintf(stderr, "%s: Configuration error on line %u: %s\n",
    224                                     NAME, line_number, line);
     219                        if (parse_line(configuration, line) != EOK) {
     220                                fprintf(stderr, "%s: Configuration error on "
     221                                    "line %u: %s\n", NAME, line_number, line);
     222                        }
    225223                       
    226224                        index = 0;
     
    270268static int net_initialize(async_client_conn_t client_connection)
    271269{
    272         ERROR_DECLARE;
     270        int rc;
    273271       
    274272        netifs_initialize(&net_globals.netifs);
     
    278276       
    279277        // TODO: dynamic configuration
    280         ERROR_PROPAGATE(read_configuration());
    281        
    282         ERROR_PROPAGATE(add_module(NULL, &net_globals.modules,
    283             LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service));
    284         ERROR_PROPAGATE(add_module(NULL, &net_globals.modules,
    285             DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service));
    286         ERROR_PROPAGATE(add_module(NULL, &net_globals.modules,
    287             ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0,
    288             connect_to_service));
    289         ERROR_PROPAGATE(add_module(NULL, &net_globals.modules,
    290             NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0,
    291             connect_to_service));
     278        rc = read_configuration();
     279        if (rc != EOK)
     280                return rc;
     281       
     282        rc = add_module(NULL, &net_globals.modules, LO_NAME, LO_FILENAME,
     283            SERVICE_LO, 0, connect_to_service);
     284        if (rc != EOK)
     285                return rc;
     286        rc = add_module(NULL, &net_globals.modules, DP8390_NAME,
     287            DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service);
     288        if (rc != EOK)
     289                return rc;
     290        rc = add_module(NULL, &net_globals.modules, ETHERNET_NAME,
     291            ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service);
     292        if (rc != EOK)
     293                return rc;
     294        rc = add_module(NULL, &net_globals.modules, NILDUMMY_NAME,
     295            NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service);
     296        if (rc != EOK)
     297                return rc;
    292298       
    293299        /* Build specific initialization */
     
    314320static int net_module_start(async_client_conn_t client_connection)
    315321{
    316         ERROR_DECLARE;
     322        ipcarg_t phonehash;
     323        int rc;
    317324       
    318325        async_set_client_connection(client_connection);
    319         ERROR_PROPAGATE(pm_init());
    320        
    321         ipcarg_t phonehash;
    322        
    323         if (ERROR_OCCURRED(net_initialize(client_connection)) ||
    324             ERROR_OCCURRED(REGISTER_ME(SERVICE_NETWORKING, &phonehash))) {
    325                 pm_destroy();
    326                 return ERROR_CODE;
    327         }
     326        rc = pm_init();
     327        if (rc != EOK)
     328                return rc;
     329       
     330       
     331        rc = net_initialize(client_connection);
     332        if (rc != EOK)
     333                goto out;
     334       
     335        rc = REGISTER_ME(SERVICE_NETWORKING, &phonehash);
     336        if (rc != EOK)
     337                goto out;
    328338       
    329339        async_manager();
    330        
     340
     341out:
    331342        pm_destroy();
    332         return EOK;
     343        return rc;
    333344}
    334345
     
    415426static int start_device(netif_t *netif)
    416427{
    417         ERROR_DECLARE;
     428        int rc;
    418429       
    419430        /* Mandatory netif */
     
    456467        int io = setting ? strtol(setting->value, NULL, 16) : 0;
    457468       
    458         ERROR_PROPAGATE(netif_probe_req_remote(netif->driver->phone, netif->id, irq, io));
     469        rc = netif_probe_req_remote(netif->driver->phone, netif->id, irq, io);
     470        if (rc != EOK)
     471                return rc;
    459472       
    460473        /* Network interface layer startup */
     
    468481                int mtu = setting ? strtol(setting->value, NULL, 10) : 0;
    469482               
    470                 ERROR_PROPAGATE(nil_device_req(netif->nil->phone, netif->id, mtu,
    471                     netif->driver->service));
     483                rc = nil_device_req(netif->nil->phone, netif->id, mtu,
     484                    netif->driver->service);
     485                if (rc != EOK)
     486                        return rc;
    472487               
    473488                internet_service = netif->nil->service;
     
    478493        switch (netif->il->service) {
    479494        case SERVICE_IP:
    480                 ERROR_PROPAGATE(ip_device_req(netif->il->phone, netif->id,
    481                     internet_service));
     495                rc = ip_device_req(netif->il->phone, netif->id,
     496                    internet_service);
     497                if (rc != EOK)
     498                        return rc;
    482499                break;
    483500        default:
     
    485502        }
    486503       
    487         ERROR_PROPAGATE(netif_start_req_remote(netif->driver->phone, netif->id));
    488         return EOK;
     504        return netif_start_req_remote(netif->driver->phone, netif->id);
    489505}
    490506
     
    504520static int startup(void)
    505521{
    506         ERROR_DECLARE;
    507        
    508522        const char *conf_files[] = {
    509523                "lo",
     
    511525        };
    512526        size_t count = sizeof(conf_files) / sizeof(char *);
     527        int rc;
    513528       
    514529        size_t i;
     
    522537                        return EXDEV;
    523538               
    524                 ERROR_PROPAGATE(measured_strings_initialize(&netif->configuration));
     539                rc = measured_strings_initialize(&netif->configuration);
     540                if (rc != EOK)
     541                        return rc;
    525542               
    526543                /* Read configuration files */
    527                 if (ERROR_OCCURRED(read_netif_configuration(conf_files[i], netif))) {
     544                rc = read_netif_configuration(conf_files[i], netif);
     545                if (rc != EOK) {
    528546                        measured_strings_destroy(&netif->configuration);
    529547                        free(netif);
    530                         return ERROR_CODE;
     548                        return rc;
    531549                }
    532550               
     
    554572                 * and needed modules.
    555573                 */
    556                 if ((ERROR_OCCURRED(char_map_add(&net_globals.netif_names,
    557                     netif->name, 0, index))) || (ERROR_OCCURRED(start_device(netif)))) {
     574                rc = char_map_add(&net_globals.netif_names, netif->name, 0,
     575                    index);
     576                if (rc != EOK) {
    558577                        measured_strings_destroy(&netif->configuration);
    559578                        netifs_exclude_index(&net_globals.netifs, index);
    560                         return ERROR_CODE;
     579                        return rc;
     580                }
     581               
     582                rc = start_device(netif);
     583                if (rc != EOK) {
     584                        measured_strings_destroy(&netif->configuration);
     585                        netifs_exclude_index(&net_globals.netifs, index);
     586                        return rc;
    561587                }
    562588               
     
    594620    int *answer_count)
    595621{
    596         ERROR_DECLARE;
    597        
    598622        measured_string_ref strings;
    599623        char *data;
     624        int rc;
    600625       
    601626        *answer_count = 0;
     
    604629                return EOK;
    605630        case NET_NET_GET_DEVICE_CONF:
    606                 ERROR_PROPAGATE(measured_strings_receive(&strings, &data,
    607                     IPC_GET_COUNT(call)));
     631                rc = measured_strings_receive(&strings, &data,
     632                    IPC_GET_COUNT(call));
     633                if (rc != EOK)
     634                        return rc;
    608635                net_get_device_conf_req(0, IPC_GET_DEVICE(call), &strings,
    609636                    IPC_GET_COUNT(call), NULL);
     
    612639                free(data);
    613640               
    614                 ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call));
     641                rc = measured_strings_reply(strings, IPC_GET_COUNT(call));
    615642                free(strings);
    616                 return ERROR_CODE;
     643                return rc;
    617644        case NET_NET_GET_CONF:
    618                 ERROR_PROPAGATE(measured_strings_receive(&strings, &data,
    619                     IPC_GET_COUNT(call)));
     645                rc = measured_strings_receive(&strings, &data,
     646                    IPC_GET_COUNT(call));
     647                if (rc != EOK)
     648                        return rc;
    620649                net_get_conf_req(0, &strings, IPC_GET_COUNT(call), NULL);
    621650               
     
    623652                free(data);
    624653               
    625                 ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call));
     654                rc = measured_strings_reply(strings, IPC_GET_COUNT(call));
    626655                free(strings);
    627                 return ERROR_CODE;
     656                return rc;
    628657        case NET_NET_STARTUP:
    629658                return startup();
    630659        }
     660       
    631661        return ENOTSUP;
    632662}
     
    670700int main(int argc, char *argv[])
    671701{
    672         ERROR_DECLARE;
    673        
    674         if (ERROR_OCCURRED(net_module_start(net_client_connection))) {
    675                 fprintf(stderr, "%s: net_module_start error %i\n", NAME, ERROR_CODE);
    676                 return ERROR_CODE;
     702        int rc;
     703       
     704        rc = net_module_start(net_client_connection);
     705        if (rc != EOK) {
     706                fprintf(stderr, "%s: net_module_start error %i\n", NAME, rc);
     707                return rc;
    677708        }
    678709       
  • uspace/srv/net/net/net_standalone.c

    r3da12d74 r9fd39d6  
    4242#include <ipc/ipc.h>
    4343#include <ipc/net.h>
     44#include <errno.h>
    4445
    4546#include <ip_interface.h>
     
    6061int net_initialize_build(async_client_conn_t client_connection)
    6162{
    62         ERROR_DECLARE;
     63        int rc;
    6364       
    6465        task_id_t task_id = spawn("/srv/ip");
     
    6667                return EINVAL;
    6768       
    68         ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, IP_NAME,
    69             IP_FILENAME, SERVICE_IP, task_id, ip_connect_module));
     69        rc = add_module(NULL, &net_globals.modules, IP_NAME,
     70            IP_FILENAME, SERVICE_IP, task_id, ip_connect_module);
     71        if (rc != EOK)
     72                return rc;
    7073       
    7174        if (!spawn("/srv/icmp"))
Note: See TracChangeset for help on using the changeset viewer.