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


Ignore:
Timestamp:
2011-06-01T08:43:42Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8d6c1f1
Parents:
9e2e715 (diff), e51a514 (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:

Huuuuuge merge from development - all the work actually :)

File:
1 edited

Legend:

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

    r9e2e715 reb522e8  
    4343#include <str.h>
    4444#include <errno.h>
    45 
    46 #include <ipc/ipc.h>
     45#include <ipc/nil.h>
    4746#include <ipc/net.h>
    4847#include <ipc/services.h>
    49 
    5048#include <net/modules.h>
    5149#include <net_checksum.h>
     
    5452#include <protocol_map.h>
    5553#include <net/device.h>
    56 #include <netif_interface.h>
     54#include <netif_remote.h>
    5755#include <net_interface.h>
    58 #include <nil_interface.h>
    59 #include <il_interface.h>
     56#include <il_remote.h>
    6057#include <adt/measured_strings.h>
    6158#include <packet_client.h>
    6259#include <packet_remote.h>
    63 #include <nil_local.h>
     60#include <nil_skel.h>
    6461
    6562#include "eth.h"
    66 #include "eth_header.h"
    6763
    6864/** The module name. */
     
    7268#define ETH_PREFIX \
    7369        (sizeof(eth_header_t) + sizeof(eth_header_lsap_t) + \
    74         sizeof(eth_header_snap_t))
     70            sizeof(eth_header_snap_t))
    7571
    7672/** Reserved packet suffix length. */
    77 #define ETH_SUFFIX \
    78         sizeof(eth_fcs_t)
     73#define ETH_SUFFIX  (sizeof(eth_fcs_t))
    7974
    8075/** Maximum packet content length. */
    81 #define ETH_MAX_CONTENT 1500u
     76#define ETH_MAX_CONTENT  1500u
    8277
    8378/** Minimum packet content length. */
    84 #define ETH_MIN_CONTENT 46u
     79#define ETH_MIN_CONTENT  46u
    8580
    8681/** Maximum tagged packet content length. */
    8782#define ETH_MAX_TAGGED_CONTENT(flags) \
    8883        (ETH_MAX_CONTENT - \
    89         ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \
    90         sizeof(eth_header_lsap_t) : 0) - \
    91         (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0))
     84            ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \
     85            sizeof(eth_header_lsap_t) : 0) - \
     86            (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0))
    9287
    9388/** Minimum tagged packet content length. */
    9489#define ETH_MIN_TAGGED_CONTENT(flags) \
    9590        (ETH_MIN_CONTENT - \
    96         ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \
    97         sizeof(eth_header_lsap_t) : 0) - \
    98         (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0))
     91            ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \
     92            sizeof(eth_header_lsap_t) : 0) - \
     93            (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0))
    9994
    10095/** Dummy flag shift value. */
    101 #define ETH_DUMMY_SHIFT 0
     96#define ETH_DUMMY_SHIFT  0
    10297
    10398/** Mode flag shift value. */
    104 #define ETH_MODE_SHIFT  1
     99#define ETH_MODE_SHIFT  1
    105100
    106101/** Dummy device flag.
    107102 * Preamble and FCS are mandatory part of the packets.
    108103 */
    109 #define ETH_DUMMY               (1 << ETH_DUMMY_SHIFT)
     104#define ETH_DUMMY  (1 << ETH_DUMMY_SHIFT)
    110105
    111106/** Returns the dummy flag.
    112107 * @see ETH_DUMMY
    113108 */
    114 #define IS_DUMMY(flags)         ((flags) & ETH_DUMMY)
     109#define IS_DUMMY(flags)  ((flags) & ETH_DUMMY)
    115110
    116111/** Device mode flags.
     
    119114 * @see ETH_8023_2_SNAP
    120115 */
    121 #define ETH_MODE_MASK           (3 << ETH_MODE_SHIFT)
     116#define ETH_MODE_MASK  (3 << ETH_MODE_SHIFT)
    122117
    123118/** DIX Ethernet mode flag. */
    124 #define ETH_DIX                 (1 << ETH_MODE_SHIFT)
    125 
    126 /** Returns whether the DIX Ethernet mode flag is set.
    127  *
    128  * @param[in] flags     The ethernet flags.
     119#define ETH_DIX  (1 << ETH_MODE_SHIFT)
     120
     121/** Return whether the DIX Ethernet mode flag is set.
     122 *
     123 * @param[in] flags Ethernet flags.
    129124 * @see ETH_DIX
    130  */
    131 #define IS_DIX(flags)           (((flags) & ETH_MODE_MASK) == ETH_DIX)
     125 *
     126 */
     127#define IS_DIX(flags)  (((flags) & ETH_MODE_MASK) == ETH_DIX)
    132128
    133129/** 802.3 + 802.2 + LSAP mode flag. */
    134 #define ETH_8023_2_LSAP         (2 << ETH_MODE_SHIFT)
    135 
    136 /** Returns whether the 802.3 + 802.2 + LSAP mode flag is set.
    137  *
    138  * @param[in] flags     The ethernet flags.
     130#define ETH_8023_2_LSAP  (2 << ETH_MODE_SHIFT)
     131
     132/** Return whether the 802.3 + 802.2 + LSAP mode flag is set.
     133 *
     134 * @param[in] flags Ethernet flags.
    139135 * @see ETH_8023_2_LSAP
    140  */
    141 #define IS_8023_2_LSAP(flags)   (((flags) & ETH_MODE_MASK) == ETH_8023_2_LSAP)
     136 *
     137 */
     138#define IS_8023_2_LSAP(flags)  (((flags) & ETH_MODE_MASK) == ETH_8023_2_LSAP)
    142139
    143140/** 802.3 + 802.2 + LSAP + SNAP mode flag. */
    144 #define ETH_8023_2_SNAP         (3 << ETH_MODE_SHIFT)
    145 
    146 /** Returns whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set.
    147  *
    148  * @param[in] flags     The ethernet flags.
     141#define ETH_8023_2_SNAP  (3 << ETH_MODE_SHIFT)
     142
     143/** Return whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set.
     144 *
     145 * @param[in] flags Ethernet flags.
    149146 * @see ETH_8023_2_SNAP
    150  */
    151 #define IS_8023_2_SNAP(flags)   (((flags) & ETH_MODE_MASK) == ETH_8023_2_SNAP)
     147 *
     148 */
     149#define IS_8023_2_SNAP(flags)  (((flags) & ETH_MODE_MASK) == ETH_8023_2_SNAP)
    152150
    153151/** Type definition of the ethernet address type.
     
    155153 */
    156154typedef enum eth_addr_type eth_addr_type_t;
    157 
    158 /** Type definition of the ethernet address type pointer.
    159  * @see eth_addr_type
    160  */
    161 typedef eth_addr_type_t *eth_addr_type_ref;
    162155
    163156/** Ethernet address type. */
     
    178171{
    179172        int index;
    180         eth_proto_ref proto;
     173        eth_proto_t *proto;
    181174
    182175        fibril_rwlock_read_lock(&eth_globals.protos_lock);
     
    206199
    207200        eth_globals.broadcast_addr =
    208             measured_string_create_bulk("\xFF\xFF\xFF\xFF\xFF\xFF",
    209             CONVERT_SIZE(uint8_t, char, ETH_ADDR));
     201            measured_string_create_bulk((uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF", ETH_ADDR);
    210202        if (!eth_globals.broadcast_addr) {
    211203                rc = ENOMEM;
     
    222214        if (rc != EOK) {
    223215                free(eth_globals.broadcast_addr);
    224                 eth_devices_destroy(&eth_globals.devices);
     216                eth_devices_destroy(&eth_globals.devices, free);
    225217        }
    226218out:
     
    239231static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall)
    240232{
    241         packet_t packet;
     233        packet_t *packet;
    242234        int rc;
    243235
    244236        while (true) {
    245                 switch (IPC_GET_METHOD(*icall)) {
     237                switch (IPC_GET_IMETHOD(*icall)) {
    246238                case NET_NIL_DEVICE_STATE:
    247                         nil_device_state_msg_local(0, IPC_GET_DEVICE(icall),
    248                             IPC_GET_STATE(icall));
    249                         ipc_answer_0(iid, EOK);
     239                        nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall),
     240                            IPC_GET_STATE(*icall));
     241                        async_answer_0(iid, EOK);
    250242                        break;
    251243                case NET_NIL_RECEIVED:
    252244                        rc = packet_translate_remote(eth_globals.net_phone,
    253                             &packet, IPC_GET_PACKET(icall));
    254                         if (rc == EOK) {
     245                            &packet, IPC_GET_PACKET(*icall));
     246                        if (rc == EOK)
    255247                                rc = nil_received_msg_local(0,
    256                                     IPC_GET_DEVICE(icall), packet, 0);
    257                         }
    258                         ipc_answer_0(iid, (ipcarg_t) rc);
     248                                    IPC_GET_DEVICE(*icall), packet, 0);
     249                       
     250                        async_answer_0(iid, (sysarg_t) rc);
    259251                        break;
    260252                default:
    261                         ipc_answer_0(iid, (ipcarg_t) ENOTSUP);
     253                        async_answer_0(iid, (sysarg_t) ENOTSUP);
    262254                }
    263255               
     
    273265 * @param[in] service   The device driver service.
    274266 * @param[in] mtu       The device maximum transmission unit.
    275  * @returns             EOK on success.
    276  * @returns             EEXIST if the device with the different service exists.
    277  * @returns             ENOMEM if there is not enough memory left.
    278  * @returns             Other error codes as defined for the
     267 * @return              EOK on success.
     268 * @return              EEXIST if the device with the different service exists.
     269 * @return              ENOMEM if there is not enough memory left.
     270 * @return              Other error codes as defined for the
    279271 *                      net_get_device_conf_req() function.
    280  * @returns             Other error codes as defined for the
     272 * @return              Other error codes as defined for the
    281273 *                      netif_bind_service() function.
    282  * @returns             Other error codes as defined for the
     274 * @return              Other error codes as defined for the
    283275 *                      netif_get_addr_req() function.
    284276 */
     
    286278    size_t mtu)
    287279{
    288         eth_device_ref device;
     280        eth_device_t *device;
    289281        int index;
    290282        measured_string_t names[2] = {
    291283                {
    292                         (char *) "ETH_MODE",
     284                        (uint8_t *) "ETH_MODE",
    293285                        8
    294286                },
    295287                {
    296                         (char *) "ETH_DUMMY",
     288                        (uint8_t *) "ETH_DUMMY",
    297289                        9
    298290                }
    299291        };
    300         measured_string_ref configuration;
     292        measured_string_t *configuration;
    301293        size_t count = sizeof(names) / sizeof(measured_string_t);
    302         char *data;
    303         eth_proto_ref proto;
     294        uint8_t *data;
     295        eth_proto_t *proto;
    304296        int rc;
    305297
     
    320312                        device->mtu = ETH_MAX_TAGGED_CONTENT(device->flags);
    321313               
    322                 printf("Device %d already exists:\tMTU\t= %d\n",
     314                printf("Device %d already exists:\tMTU\t= %zu\n",
    323315                    device->device_id, device->mtu);
    324316                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     
    342334       
    343335        /* Create a new device */
    344         device = (eth_device_ref) malloc(sizeof(eth_device_t));
     336        device = (eth_device_t *) malloc(sizeof(eth_device_t));
    345337        if (!device)
    346338                return ENOMEM;
     
    364356
    365357        if (configuration) {
    366                 if (!str_lcmp(configuration[0].value, "DIX",
     358                if (!str_lcmp((char *) configuration[0].value, "DIX",
    367359                    configuration[0].length)) {
    368360                        device->flags |= ETH_DIX;
    369                 } else if(!str_lcmp(configuration[0].value, "8023_2_LSAP",
     361                } else if(!str_lcmp((char *) configuration[0].value, "8023_2_LSAP",
    370362                    configuration[0].length)) {
    371363                        device->flags |= ETH_8023_2_LSAP;
     
    412404        }
    413405       
    414         printf("%s: Device registered (id: %d, service: %d: mtu: %d, "
    415             "mac: %x:%x:%x:%x:%x:%x, flags: 0x%x)\n",
     406        printf("%s: Device registered (id: %d, service: %d: mtu: %zu, "
     407            "mac: %02x:%02x:%02x:%02x:%02x:%02x, flags: 0x%x)\n",
    416408            NAME, device->device_id, device->service, device->mtu,
    417409            device->addr_data[0], device->addr_data[1],
     
    427419 * @param[in] flags     The device flags.
    428420 * @param[in] packet    The packet.
    429  * @returns             The target registered module.
    430  * @returns             NULL if the packet is not long enough.
    431  * @returns             NULL if the packet is too long.
    432  * @returns             NULL if the raw ethernet protocol is used.
    433  * @returns             NULL if the dummy device FCS checksum is invalid.
    434  * @returns             NULL if the packet address length is not big enough.
    435  */
    436 static eth_proto_ref eth_process_packet(int flags, packet_t packet)
    437 {
    438         eth_header_snap_ref header;
     421 * @return              The target registered module.
     422 * @return              NULL if the packet is not long enough.
     423 * @return              NULL if the packet is too long.
     424 * @return              NULL if the raw ethernet protocol is used.
     425 * @return              NULL if the dummy device FCS checksum is invalid.
     426 * @return              NULL if the packet address length is not big enough.
     427 */
     428static eth_proto_t *eth_process_packet(int flags, packet_t *packet)
     429{
     430        eth_header_snap_t *header;
    439431        size_t length;
    440432        eth_type_t type;
    441433        size_t prefix;
    442434        size_t suffix;
    443         eth_fcs_ref fcs;
     435        eth_fcs_t *fcs;
    444436        uint8_t *data;
    445437        int rc;
     
    454446       
    455447        data = packet_get_data(packet);
    456         header = (eth_header_snap_ref) data;
     448        header = (eth_header_snap_t *) data;
    457449        type = ntohs(header->header.ethertype);
    458450       
     
    461453                prefix = sizeof(eth_header_t);
    462454                suffix = 0;
    463                 fcs = (eth_fcs_ref) data + length - sizeof(eth_fcs_t);
     455                fcs = (eth_fcs_t *) data + length - sizeof(eth_fcs_t);
    464456                length -= sizeof(eth_fcs_t);
    465457        } else if(type <= ETH_MAX_CONTENT) {
     
    487479
    488480                suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U;
    489                 fcs = (eth_fcs_ref) data + prefix + type + suffix;
     481                fcs = (eth_fcs_t *) data + prefix + type + suffix;
    490482                suffix += length - prefix - type;
    491483                length = prefix + type + suffix;
     
    514506
    515507int nil_received_msg_local(int nil_phone, device_id_t device_id,
    516     packet_t packet, services_t target)
    517 {
    518         eth_proto_ref proto;
    519         packet_t next;
    520         eth_device_ref device;
     508    packet_t *packet, services_t target)
     509{
     510        eth_proto_t *proto;
     511        packet_t *next;
     512        eth_device_t *device;
    521513        int flags;
    522514
     
    539531                            proto->service);
    540532                } else {
    541                         // drop invalid/unknown
     533                        /* Drop invalid/unknown */
    542534                        pq_release_remote(eth_globals.net_phone,
    543535                            packet_get_id(packet));
     
    557549 * @param[out] content  The maximum content size.
    558550 * @param[out] suffix   The minimum reserved suffix size.
    559  * @returns             EOK on success.
    560  * @returns             EBADMEM if either one of the parameters is NULL.
    561  * @returns             ENOENT if there is no such device.
     551 * @return              EOK on success.
     552 * @return              EBADMEM if either one of the parameters is NULL.
     553 * @return              ENOENT if there is no such device.
    562554 */
    563555static int eth_packet_space_message(device_id_t device_id, size_t *addr_len,
    564556    size_t *prefix, size_t *content, size_t *suffix)
    565557{
    566         eth_device_ref device;
     558        eth_device_t *device;
    567559
    568560        if (!addr_len || !prefix || !content || !suffix)
     
    591583 * @param[in] type      Type of the desired address.
    592584 * @param[out] address  The device hardware address.
    593  * @returns             EOK on success.
    594  * @returns             EBADMEM if the address parameter is NULL.
    595  * @returns             ENOENT if there no such device.
     585 * @return              EOK on success.
     586 * @return              EBADMEM if the address parameter is NULL.
     587 * @return              ENOENT if there no such device.
    596588 */
    597589static int eth_addr_message(device_id_t device_id, eth_addr_type_t type,
    598     measured_string_ref *address)
    599 {
    600         eth_device_ref device;
     590    measured_string_t **address)
     591{
     592        eth_device_t *device;
    601593
    602594        if (!address)
     
    625617 * @param[in] service   The module service.
    626618 * @param[in] phone     The service phone.
    627  * @returns             EOK on success.
    628  * @returns             ENOENT if the service is not known.
    629  * @returns             ENOMEM if there is not enough memory left.
     619 * @return              EOK on success.
     620 * @return              ENOENT if the service is not known.
     621 * @return              ENOMEM if there is not enough memory left.
    630622 */
    631623static int eth_register_message(services_t service, int phone)
    632624{
    633         eth_proto_ref proto;
     625        eth_proto_t *proto;
    634626        int protocol;
    635627        int index;
     
    646638                return EOK;
    647639        } else {
    648                 proto = (eth_proto_ref) malloc(sizeof(eth_proto_t));
     640                proto = (eth_proto_t *) malloc(sizeof(eth_proto_t));
    649641                if (!proto) {
    650642                        fibril_rwlock_write_unlock(&eth_globals.protos_lock);
     
    678670 * @param[in] ethertype The ethernet protocol type.
    679671 * @param[in] mtu       The device maximum transmission unit.
    680  * @returns             EOK on success.
    681  * @returns             EINVAL if the packet addresses length is not long
     672 * @return              EOK on success.
     673 * @return              EINVAL if the packet addresses length is not long
    682674 *                      enough.
    683  * @returns             EINVAL if the packet is bigger than the device MTU.
    684  * @returns             ENOMEM if there is not enough memory in the packet.
     675 * @return              EINVAL if the packet is bigger than the device MTU.
     676 * @return              ENOMEM if there is not enough memory in the packet.
    685677 */
    686678static int
    687 eth_prepare_packet(int flags, packet_t packet, uint8_t *src_addr, int ethertype,
     679eth_prepare_packet(int flags, packet_t *packet, uint8_t *src_addr, int ethertype,
    688680    size_t mtu)
    689681{
    690         eth_header_snap_ref header;
    691         eth_header_lsap_ref header_lsap;
    692         eth_header_ref header_dix;
    693         eth_fcs_ref fcs;
     682        eth_header_snap_t *header;
     683        eth_header_lsap_t *header_lsap;
     684        eth_header_t *header_dix;
     685        eth_fcs_t *fcs;
    694686        uint8_t *src;
    695687        uint8_t *dest;
     
    697689        int i;
    698690        void *padding;
    699         eth_preamble_ref preamble;
     691        eth_preamble_t *preamble;
    700692
    701693        i = packet_get_addr(packet, &src, &dest);
     
    788780 * @param[in] packet    The packet queue.
    789781 * @param[in] sender    The sending module service.
    790  * @returns             EOK on success.
    791  * @returns             ENOENT if there no such device.
    792  * @returns             EINVAL if the service parameter is not known.
    793  */
    794 static int eth_send_message(device_id_t device_id, packet_t packet,
     782 * @return              EOK on success.
     783 * @return              ENOENT if there no such device.
     784 * @return              EINVAL if the service parameter is not known.
     785 */
     786static int eth_send_message(device_id_t device_id, packet_t *packet,
    795787    services_t sender)
    796788{
    797         eth_device_ref device;
    798         packet_t next;
    799         packet_t tmp;
     789        eth_device_t *device;
     790        packet_t *next;
     791        packet_t *tmp;
    800792        int ethertype;
    801793        int rc;
     
    842834}
    843835
    844 int nil_message_standalone(const char *name, ipc_callid_t callid,
    845     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
    846 {
    847         measured_string_ref address;
    848         packet_t packet;
     836int nil_module_message(ipc_callid_t callid, ipc_call_t *call,
     837    ipc_call_t *answer, size_t *answer_count)
     838{
     839        measured_string_t *address;
     840        packet_t *packet;
    849841        size_t addrlen;
    850842        size_t prefix;
     
    854846       
    855847        *answer_count = 0;
    856         switch (IPC_GET_METHOD(*call)) {
     848        switch (IPC_GET_IMETHOD(*call)) {
    857849        case IPC_M_PHONE_HUNGUP:
    858850                return EOK;
    859851       
    860852        case NET_NIL_DEVICE:
    861                 return eth_device_message(IPC_GET_DEVICE(call),
    862                     IPC_GET_SERVICE(call), IPC_GET_MTU(call));
     853                return eth_device_message(IPC_GET_DEVICE(*call),
     854                    IPC_GET_SERVICE(*call), IPC_GET_MTU(*call));
    863855        case NET_NIL_SEND:
    864856                rc = packet_translate_remote(eth_globals.net_phone, &packet,
    865                     IPC_GET_PACKET(call));
     857                    IPC_GET_PACKET(*call));
    866858                if (rc != EOK)
    867859                        return rc;
    868                 return eth_send_message(IPC_GET_DEVICE(call), packet,
    869                     IPC_GET_SERVICE(call));
     860                return eth_send_message(IPC_GET_DEVICE(*call), packet,
     861                    IPC_GET_SERVICE(*call));
    870862        case NET_NIL_PACKET_SPACE:
    871                 rc = eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen,
     863                rc = eth_packet_space_message(IPC_GET_DEVICE(*call), &addrlen,
    872864                    &prefix, &content, &suffix);
    873865                if (rc != EOK)
    874866                        return rc;
    875                 IPC_SET_ADDR(answer, addrlen);
    876                 IPC_SET_PREFIX(answer, prefix);
    877                 IPC_SET_CONTENT(answer, content);
    878                 IPC_SET_SUFFIX(answer, suffix);
     867                IPC_SET_ADDR(*answer, addrlen);
     868                IPC_SET_PREFIX(*answer, prefix);
     869                IPC_SET_CONTENT(*answer, content);
     870                IPC_SET_SUFFIX(*answer, suffix);
    879871                *answer_count = 4;
    880872                return EOK;
    881873        case NET_NIL_ADDR:
    882                 rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR,
     874                rc = eth_addr_message(IPC_GET_DEVICE(*call), ETH_LOCAL_ADDR,
    883875                    &address);
    884876                if (rc != EOK)
     
    886878                return measured_strings_reply(address, 1);
    887879        case NET_NIL_BROADCAST_ADDR:
    888                 rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR,
     880                rc = eth_addr_message(IPC_GET_DEVICE(*call), ETH_BROADCAST_ADDR,
    889881                    &address);
    890882                if (rc != EOK)
     
    892884                return measured_strings_reply(address, 1);
    893885        case IPC_M_CONNECT_TO_ME:
    894                 return eth_register_message(NIL_GET_PROTO(call),
    895                     IPC_GET_PHONE(call));
     886                return eth_register_message(NIL_GET_PROTO(*call),
     887                    IPC_GET_PHONE(*call));
    896888        }
    897889       
     
    899891}
    900892
    901 /** Default thread for new connections.
    902  *
    903  * @param[in] iid       The initial message identifier.
    904  * @param[in] icall     The initial message call structure.
    905  */
    906 static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    907 {
    908         /*
    909          * Accept the connection
    910          *  - Answer the first IPC_M_CONNECT_ME_TO call.
    911          */
    912         ipc_answer_0(iid, EOK);
    913        
    914         while (true) {
    915                 ipc_call_t answer;
    916                 int answer_count;
    917                
    918                 /* Clear the answer structure */
    919                 refresh_answer(&answer, &answer_count);
    920                
    921                 /* Fetch the next message */
    922                 ipc_call_t call;
    923                 ipc_callid_t callid = async_get_call(&call);
    924                
    925                 /* Process the message */
    926                 int res = nil_module_message_standalone(NAME, callid, &call,
    927                     &answer, &answer_count);
    928                
    929                 /*
    930                  * End if told to either by the message or the processing
    931                  * result.
    932                  */
    933                 if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
    934                     (res == EHANGUP))
    935                         return;
    936                
    937                 /* Answer the message */
    938                 answer_call(callid, res, &answer, answer_count);
    939         }
    940 }
    941 
    942893int main(int argc, char *argv[])
    943894{
    944         int rc;
    945        
    946895        /* Start the module */
    947         rc = nil_module_start_standalone(nil_client_connection);
    948         return rc;
     896        return nil_module_start(SERVICE_ETHERNET);
    949897}
    950898
Note: See TracChangeset for help on using the changeset viewer.