Changeset 774e6d1a in mainline for uspace/srv/net/nil/eth/eth.c


Ignore:
Timestamp:
2011-01-09T23:24:53Z (13 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
File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.