Changeset 774e6d1a in mainline for uspace/srv/net/nil


Ignore:
Timestamp:
2011-01-09T23:24:53Z (15 years ago)
Author:
martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4b86dac
Parents:
3c106e88
Message:

partial networking stack overhaul

  • a lot of coding style changes (comments, indentation, etc.)
  • convert several ints to unsigned ints or size_t values
  • streamline many of the IPC-related macros (they no longer dereference the call structure by themselves)
  • get rid of netif_interface.h (containing only aliases for remote functions and not serving any purpose)
  • rename netif_local.{c|h} to netif_skel.{c|h} (it is really just a skeleton)
  • drop the "_remote" and "_standalone" suffixes from most of the netif_ functions (they do not serve any purpose anymore)
  • implement netif_client_connection() as a common framework function for all netif modules
    • update the lo module accordingly
  • ip module now reports the default gateway to the user whenever it is being set
Location:
uspace/srv/net/nil
Files:
5 edited

Legend:

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

    r3c106e88 r774e6d1a  
    5454#include <protocol_map.h>
    5555#include <net/device.h>
    56 #include <netif_interface.h>
     56#include <netif_remote.h>
    5757#include <net_interface.h>
    5858#include <nil_interface.h>
     
    239239                switch (IPC_GET_IMETHOD(*icall)) {
    240240                case NET_NIL_DEVICE_STATE:
    241                         nil_device_state_msg_local(0, IPC_GET_DEVICE(icall),
    242                             IPC_GET_STATE(icall));
     241                        nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall),
     242                            IPC_GET_STATE(*icall));
    243243                        ipc_answer_0(iid, EOK);
    244244                        break;
    245245                case NET_NIL_RECEIVED:
    246246                        rc = packet_translate_remote(eth_globals.net_phone,
    247                             &packet, IPC_GET_PACKET(icall));
     247                            &packet, IPC_GET_PACKET(*icall));
    248248                        if (rc == EOK) {
    249249                                rc = nil_received_msg_local(0,
    250                                     IPC_GET_DEVICE(icall), packet, 0);
     250                                    IPC_GET_DEVICE(*icall), packet, 0);
    251251                        }
    252252                        ipc_answer_0(iid, (sysarg_t) rc);
     
    837837
    838838int nil_message_standalone(const char *name, ipc_callid_t callid,
    839     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     839    ipc_call_t *call, ipc_call_t *answer, size_t *answer_count)
    840840{
    841841        measured_string_t *address;
     
    853853       
    854854        case NET_NIL_DEVICE:
    855                 return eth_device_message(IPC_GET_DEVICE(call),
    856                     IPC_GET_SERVICE(call), IPC_GET_MTU(call));
     855                return eth_device_message(IPC_GET_DEVICE(*call),
     856                    IPC_GET_SERVICE(*call), IPC_GET_MTU(*call));
    857857        case NET_NIL_SEND:
    858858                rc = packet_translate_remote(eth_globals.net_phone, &packet,
    859                     IPC_GET_PACKET(call));
     859                    IPC_GET_PACKET(*call));
    860860                if (rc != EOK)
    861861                        return rc;
    862                 return eth_send_message(IPC_GET_DEVICE(call), packet,
    863                     IPC_GET_SERVICE(call));
     862                return eth_send_message(IPC_GET_DEVICE(*call), packet,
     863                    IPC_GET_SERVICE(*call));
    864864        case NET_NIL_PACKET_SPACE:
    865                 rc = eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen,
     865                rc = eth_packet_space_message(IPC_GET_DEVICE(*call), &addrlen,
    866866                    &prefix, &content, &suffix);
    867867                if (rc != EOK)
    868868                        return rc;
    869                 IPC_SET_ADDR(answer, addrlen);
    870                 IPC_SET_PREFIX(answer, prefix);
    871                 IPC_SET_CONTENT(answer, content);
    872                 IPC_SET_SUFFIX(answer, suffix);
     869                IPC_SET_ADDR(*answer, addrlen);
     870                IPC_SET_PREFIX(*answer, prefix);
     871                IPC_SET_CONTENT(*answer, content);
     872                IPC_SET_SUFFIX(*answer, suffix);
    873873                *answer_count = 4;
    874874                return EOK;
    875875        case NET_NIL_ADDR:
    876                 rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR,
     876                rc = eth_addr_message(IPC_GET_DEVICE(*call), ETH_LOCAL_ADDR,
    877877                    &address);
    878878                if (rc != EOK)
     
    880880                return measured_strings_reply(address, 1);
    881881        case NET_NIL_BROADCAST_ADDR:
    882                 rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR,
     882                rc = eth_addr_message(IPC_GET_DEVICE(*call), ETH_BROADCAST_ADDR,
    883883                    &address);
    884884                if (rc != EOK)
     
    886886                return measured_strings_reply(address, 1);
    887887        case IPC_M_CONNECT_TO_ME:
    888                 return eth_register_message(NIL_GET_PROTO(call),
    889                     IPC_GET_PHONE(call));
     888                return eth_register_message(NIL_GET_PROTO(*call),
     889                    IPC_GET_PHONE(*call));
    890890        }
    891891       
     
    908908        while (true) {
    909909                ipc_call_t answer;
    910                 int answer_count;
     910                size_t count;
    911911               
    912912                /* Clear the answer structure */
    913                 refresh_answer(&answer, &answer_count);
     913                refresh_answer(&answer, &count);
    914914               
    915915                /* Fetch the next message */
     
    919919                /* Process the message */
    920920                int res = nil_module_message_standalone(NAME, callid, &call,
    921                     &answer, &answer_count);
     921                    &answer, &count);
    922922               
    923923                /*
     
    930930               
    931931                /* Answer the message */
    932                 answer_call(callid, res, &answer, answer_count);
     932                answer_call(callid, res, &answer, count);
    933933        }
    934934}
  • uspace/srv/net/nil/eth/eth_header.h

    r3c106e88 r774e6d1a  
    4242
    4343/** Ethernet address length. */
    44 #define ETH_ADDR        6
     44#define ETH_ADDR  6
    4545
    4646/** Ethernet header preamble value. */
    47 #define ETH_PREAMBLE    0x55
     47#define ETH_PREAMBLE  0x55
    4848
    4949/** Ethernet header start of frame value. */
    50 #define ETH_SFD         0xD5
     50#define ETH_SFD  0xD5
    5151
    5252/** IEEE 802.2 unordered information control field. */
    53 #define IEEE_8023_2_UI  0x03
     53#define IEEE_8023_2_UI  0x03
    5454
    5555/** Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.
  • uspace/srv/net/nil/eth/eth_module.c

    r3c106e88 r774e6d1a  
    7878
    7979int nil_module_message_standalone(const char *name, ipc_callid_t callid,
    80     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     80    ipc_call_t *call, ipc_call_t *answer, size_t *count)
    8181{
    82         return nil_message_standalone(name, callid, call, answer, answer_count);
     82        return nil_message_standalone(name, callid, call, answer, count);
    8383}
    8484
  • uspace/srv/net/nil/nildummy/nildummy.c

    r3c106e88 r774e6d1a  
    4747#include <net/modules.h>
    4848#include <net/device.h>
    49 #include <netif_interface.h>
    5049#include <nil_interface.h>
    5150#include <il_interface.h>
     
    5352#include <net/packet.h>
    5453#include <packet_remote.h>
     54#include <netif_remote.h>
    5555#include <nil_local.h>
    5656
     
    113113                case NET_NIL_DEVICE_STATE:
    114114                        rc = nil_device_state_msg_local(0,
    115                             IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));
     115                            IPC_GET_DEVICE(*icall), IPC_GET_STATE(*icall));
    116116                        ipc_answer_0(iid, (sysarg_t) rc);
    117117                        break;
     
    119119                case NET_NIL_RECEIVED:
    120120                        rc = packet_translate_remote(nildummy_globals.net_phone,
    121                             &packet, IPC_GET_PACKET(icall));
     121                            &packet, IPC_GET_PACKET(*icall));
    122122                        if (rc == EOK) {
    123123                                rc = nil_received_msg_local(0,
    124                                     IPC_GET_DEVICE(icall), packet, 0);
     124                                    IPC_GET_DEVICE(*icall), packet, 0);
    125125                        }
    126126                        ipc_answer_0(iid, (sysarg_t) rc);
     
    375375
    376376int nil_message_standalone(const char *name, ipc_callid_t callid,
    377     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     377    ipc_call_t *call, ipc_call_t *answer, size_t *answer_count)
    378378{
    379379        measured_string_t *address;
     
    391391       
    392392        case NET_NIL_DEVICE:
    393                 return nildummy_device_message(IPC_GET_DEVICE(call),
    394                     IPC_GET_SERVICE(call), IPC_GET_MTU(call));
     393                return nildummy_device_message(IPC_GET_DEVICE(*call),
     394                    IPC_GET_SERVICE(*call), IPC_GET_MTU(*call));
    395395       
    396396        case NET_NIL_SEND:
    397397                rc = packet_translate_remote(nildummy_globals.net_phone,
    398                     &packet, IPC_GET_PACKET(call));
     398                    &packet, IPC_GET_PACKET(*call));
    399399                if (rc != EOK)
    400400                        return rc;
    401                 return nildummy_send_message(IPC_GET_DEVICE(call), packet,
    402                     IPC_GET_SERVICE(call));
     401                return nildummy_send_message(IPC_GET_DEVICE(*call), packet,
     402                    IPC_GET_SERVICE(*call));
    403403       
    404404        case NET_NIL_PACKET_SPACE:
    405                 rc = nildummy_packet_space_message(IPC_GET_DEVICE(call),
     405                rc = nildummy_packet_space_message(IPC_GET_DEVICE(*call),
    406406                    &addrlen, &prefix, &content, &suffix);
    407407                if (rc != EOK)
    408408                        return rc;
    409                 IPC_SET_ADDR(answer, addrlen);
    410                 IPC_SET_PREFIX(answer, prefix);
    411                 IPC_SET_CONTENT(answer, content);
    412                 IPC_SET_SUFFIX(answer, suffix);
     409                IPC_SET_ADDR(*answer, addrlen);
     410                IPC_SET_PREFIX(*answer, prefix);
     411                IPC_SET_CONTENT(*answer, content);
     412                IPC_SET_SUFFIX(*answer, suffix);
    413413                *answer_count = 4;
    414414                return EOK;
    415415       
    416416        case NET_NIL_ADDR:
    417                 rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address);
     417                rc = nildummy_addr_message(IPC_GET_DEVICE(*call), &address);
    418418                if (rc != EOK)
    419419                        return rc;
     
    421421       
    422422        case NET_NIL_BROADCAST_ADDR:
    423                 rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address);
     423                rc = nildummy_addr_message(IPC_GET_DEVICE(*call), &address);
    424424                if (rc != EOK)
    425425                        return rc;
     
    427427       
    428428        case IPC_M_CONNECT_TO_ME:
    429                 return nildummy_register_message(NIL_GET_PROTO(call),
    430                     IPC_GET_PHONE(call));
     429                return nildummy_register_message(NIL_GET_PROTO(*call),
     430                    IPC_GET_PHONE(*call));
    431431        }
    432432       
     
    449449        while (true) {
    450450                ipc_call_t answer;
    451                 int answer_count;
     451                size_t count;
    452452               
    453453                /* Clear the answer structure */
    454                 refresh_answer(&answer, &answer_count);
     454                refresh_answer(&answer, &count);
    455455               
    456456                /* Fetch the next message */
     
    460460                /* Process the message */
    461461                int res = nil_module_message_standalone(NAME, callid, &call,
    462                     &answer, &answer_count);
     462                    &answer, &count);
    463463               
    464464                /*
     
    471471               
    472472                /* Answer the message */
    473                 answer_call(callid, res, &answer, answer_count);
     473                answer_call(callid, res, &answer, count);
    474474        }
    475475}
  • uspace/srv/net/nil/nildummy/nildummy_module.c

    r3c106e88 r774e6d1a  
    7979
    8080int nil_module_message_standalone(const char *name, ipc_callid_t callid,
    81     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     81    ipc_call_t *call, ipc_call_t *answer, size_t *count)
    8282{
    83         return nil_message_standalone(name, callid, call, answer, answer_count);
     83        return nil_message_standalone(name, callid, call, answer, count);
    8484}
    8585
Note: See TracChangeset for help on using the changeset viewer.