Changeset 49d819b4 in mainline for uspace/srv/net/net/net.c


Ignore:
Timestamp:
2010-11-02T23:15:18Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7ae3d6f
Parents:
e06ef614 (diff), d0d1f4f (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 from lp:~jakub/helenos/net.

File:
1 edited

Legend:

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

    re06ef614 r49d819b4  
    3636 */
    3737
     38#include "net.h"
     39
    3840#include <async.h>
    3941#include <ctype.h>
     
    5254
    5355#include <net/modules.h>
     56#include <net/packet.h>
     57#include <net/device.h>
     58
    5459#include <adt/char_map.h>
    5560#include <adt/generic_char_map.h>
    5661#include <adt/measured_strings.h>
    5762#include <adt/module_map.h>
    58 #include <net/packet.h>
     63
    5964#include <netif_remote.h>
    60 #include <net/device.h>
    6165#include <nil_interface.h>
    6266#include <net_interface.h>
    6367#include <ip_interface.h>
    6468
    65 #include "net.h"
    66 
    67 /** Networking module name.
    68  *
    69  */
     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
     
    10096        measured_string_ref setting =
    10197            measured_string_create_bulk(value, 0);
    102        
    10398        if (!setting)
    10499                return ENOMEM;
     
    206201        unsigned int line_number = 0;
    207202        size_t index = 0;
    208         while ((!ferror(cfg)) && (!feof(cfg))) {
     203        while (!ferror(cfg) && !feof(cfg)) {
    209204                int read = fgetc(cfg);
    210205                if ((read > 0) && (read != '\n') && (read != '\r')) {
     
    326321        ipcarg_t phonehash;
    327322       
    328         if (ERROR_OCCURRED(net_initialize(client_connection))
    329             || ERROR_OCCURRED(REGISTER_ME(SERVICE_NETWORKING, &phonehash))){
     323        if (ERROR_OCCURRED(net_initialize(client_connection)) ||
     324            ERROR_OCCURRED(REGISTER_ME(SERVICE_NETWORKING, &phonehash))) {
    330325                pm_destroy();
    331326                return ERROR_CODE;
     
    379374    size_t count, char **data)
    380375{
    381         if (!(configuration && (count > 0)))
     376        if (!configuration || (count <= 0))
    382377                return EINVAL;
    383378       
     
    482477        /* Inter-network layer startup */
    483478        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;
     479        case SERVICE_IP:
     480                ERROR_PROPAGATE(ip_device_req(netif->il->phone, netif->id,
     481                    internet_service));
     482                break;
     483        default:
     484                return ENOENT;
    490485        }
    491486       
     
    511506        ERROR_DECLARE;
    512507       
    513         const char *conf_files[] = {"lo", "ne2k"};
     508        const char *conf_files[] = {
     509                "lo",
     510                "ne2k"
     511        };
    514512        size_t count = sizeof(conf_files) / sizeof(char *);
    515513       
     
    603601        *answer_count = 0;
    604602        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();
     603        case IPC_M_PHONE_HUNGUP:
     604                return EOK;
     605        case NET_NET_GET_DEVICE_CONF:
     606                ERROR_PROPAGATE(measured_strings_receive(&strings, &data,
     607                    IPC_GET_COUNT(call)));
     608                net_get_device_conf_req(0, IPC_GET_DEVICE(call), &strings,
     609                    IPC_GET_COUNT(call), NULL);
     610               
     611                /* Strings should not contain received data anymore */
     612                free(data);
     613               
     614                ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call));
     615                free(strings);
     616                return ERROR_CODE;
     617        case NET_NET_GET_CONF:
     618                ERROR_PROPAGATE(measured_strings_receive(&strings, &data,
     619                    IPC_GET_COUNT(call)));
     620                net_get_conf_req(0, &strings, IPC_GET_COUNT(call), NULL);
     621               
     622                /* Strings should not contain received data anymore */
     623                free(data);
     624               
     625                ERROR_CODE = measured_strings_reply(strings, IPC_GET_COUNT(call));
     626                free(strings);
     627                return ERROR_CODE;
     628        case NET_NET_STARTUP:
     629                return startup();
    632630        }
    633631        return ENOTSUP;
     
    661659                int res = net_module_message(callid, &call, &answer, &answer_count);
    662660               
    663                 /* End if said to either by the message or the processing result */
     661                /* End if told to either by the message or the processing result */
    664662                if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
    665663                        return;
Note: See TracChangeset for help on using the changeset viewer.