Changeset fe8dfa6 in mainline for uspace/lib/net/nil/nil_skel.c


Ignore:
Timestamp:
2011-01-11T15:57:39Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
77429d3
Parents:
04aade50
Message:

networking: streamline NIL skeleton and NIL modules (nildummy, eth)

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/nil/nil_skel.c

    r04aade50 rfe8dfa6  
    2727 */
    2828
    29 /** @addtogroup nildummy
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
    3333/** @file
    34  *  Dummy network interface layer module stub.
    35  *  @see module.c
     34 * Network network interface layer module implementation.
     35 * @see nil_skel.h
    3636 */
    3737
    38 #include <async.h>
    39 #include <stdio.h>
     38#include <bool.h>
    4039#include <errno.h>
     40#include <nil_skel.h>
     41#include <net_interface.h>
     42#include <net/modules.h>
    4143
    42 #include <ipc/ipc.h>
    43 #include <ipc/services.h>
     44/** Default thread for new connections.
     45 *
     46 * @param[in] iid   The initial message identifier.
     47 * @param[in] icall The initial message call structure.
     48 *
     49 */
     50static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     51{
     52        /*
     53         * Accept the connection by answering
     54         * the initial IPC_M_CONNECT_ME_TO call.
     55         */
     56        ipc_answer_0(iid, EOK);
     57       
     58        while (true) {
     59                ipc_call_t answer;
     60                size_t count;
     61               
     62                /* Clear the answer structure */
     63                refresh_answer(&answer, &count);
     64               
     65                /* Fetch the next message */
     66                ipc_call_t call;
     67                ipc_callid_t callid = async_get_call(&call);
     68               
     69                /* Process the message */
     70                int res = nil_module_message(callid, &call, &answer,
     71                    &count);
     72               
     73                /*
     74                 * End if told to either by the message or the processing
     75                 * result.
     76                 */
     77                if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
     78                    (res == EHANGUP))
     79                        return;
     80               
     81                /* Answer the message */
     82                answer_call(callid, res, &answer, count);
     83        }
     84}
    4485
    45 #include <net/modules.h>
    46 #include <net_interface.h>
    47 #include <net/packet.h>
    48 #include <nil_local.h>
    49 
    50 #include "nildummy.h"
    51 
    52 int nil_module_start_standalone(async_client_conn_t client_connection)
     86/** Start the network interface layer module.
     87 *
     88 * Initialize the client connection serving function, initialize
     89 * the module, register the module service and start the async
     90 * manager, processing IPC messages in an infinite loop.
     91 *
     92 * @param[in] service Service identification.
     93 *
     94 * @return EOK on success.
     95 * @return Other error codes as defined for the pm_init() function.
     96 * @return Other error codes as defined for the nil_initialize()
     97 *         function.
     98 * @return Other error codes as defined for the REGISTER_ME() macro
     99 *         function.
     100 *
     101 */
     102int nil_module_start(int service)
    53103{
    54         sysarg_t phonehash;
    55         int rc;
    56        
    57         async_set_client_connection(client_connection);
     104        async_set_client_connection(nil_client_connection);
    58105        int net_phone = net_connect_module();
    59106       
    60         rc = pm_init();
     107        int rc = pm_init();
    61108        if (rc != EOK)
    62109                return rc;
    63        
    64110       
    65111        rc = nil_initialize(net_phone);
     
    67113                goto out;
    68114       
    69         rc = ipc_connect_to_me(PHONE_NS, SERVICE_NILDUMMY, 0, 0, &phonehash);
     115        sysarg_t phonehash;
     116        rc = ipc_connect_to_me(PHONE_NS, service, 0, 0, &phonehash);
    70117        if (rc != EOK)
    71118                goto out;
    72119       
    73120        async_manager();
    74 
     121       
    75122out:
    76123        pm_destroy();
     
    78125}
    79126
    80 int nil_module_message_standalone(const char *name, ipc_callid_t callid,
    81     ipc_call_t *call, ipc_call_t *answer, size_t *count)
    82 {
    83         return nil_message_standalone(name, callid, call, answer, count);
    84 }
    85 
    86127/** @}
    87128 */
Note: See TracChangeset for help on using the changeset viewer.