Changeset d0d1f4f in mainline


Ignore:
Timestamp:
2010-11-02T23:13:21Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49d819b4, a8e5051
Parents:
ef4b112
Message:

Cleanup net.

Location:
uspace/srv/net/net
Files:
3 edited

Legend:

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

    ref4b112 rd0d1f4f  
    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;
  • uspace/srv/net/net/net.h

    ref4b112 rd0d1f4f  
    3636 */
    3737
    38 #ifndef __NET_NET_H__
    39 #define __NET_NET_H__
     38#ifndef NET_NET_H_
     39#define NET_NET_H_
    4040
    4141#include <ipc/ipc.h>
  • uspace/srv/net/net/net_standalone.c

    ref4b112 rd0d1f4f  
    2828
    2929/** @addtogroup net
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Wrapper for the standalone networking module.
     34 * Wrapper for the standalone networking module.
    3535 */
    3636
     37#include "net.h"
     38
    3739#include <str.h>
    38 
     40#include <adt/measured_strings.h>
     41#include <adt/module_map.h>
    3942#include <ipc/ipc.h>
    4043#include <ipc/net.h>
    4144
    4245#include <ip_interface.h>
    43 #include <adt/measured_strings.h>
    44 #include <adt/module_map.h>
    4546#include <packet_server.h>
    4647
    47 #include "net.h"
    48 
    49 /** Networking module global data.
    50  */
     48/** Networking module global data. */
    5149extern net_globals_t net_globals;
    5250
     
    6058 *
    6159 */
    62 int net_initialize_build(async_client_conn_t client_connection){
     60int net_initialize_build(async_client_conn_t client_connection)
     61{
    6362        ERROR_DECLARE;
    6463       
Note: See TracChangeset for help on using the changeset viewer.