Changeset fe8dfa6 in mainline for uspace/lib/net


Ignore:
Timestamp:
2011-01-11T15:57:39Z (14 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)

Location:
uspace/lib/net
Files:
1 added
2 deleted
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/Makefile

    r04aade50 rfe8dfa6  
    4343        netif/netif_skel.c \
    4444        nil/nil_remote.c \
     45        nil/nil_skel.c \
    4546        il/il_interface.c \
    4647        il/ip_remote.c \
  • uspace/lib/net/include/nil_remote.h

    r04aade50 rfe8dfa6  
    3737#include <net/device.h>
    3838#include <net/packet.h>
     39#include <generic.h>
    3940
    40 extern int nil_device_state_msg_remote(int, device_id_t, int);
    41 extern int nil_received_msg_remote(int, device_id_t, packet_t *, services_t);
     41#define nil_bind_service(service, device_id, me, receiver) \
     42        bind_service(service, device_id, me, 0, receiver)
     43
     44#define nil_packet_size_req(nil_phone, device_id, packet_dimension) \
     45        generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, \
     46            device_id, packet_dimension)
     47
     48#define nil_get_addr_req(nil_phone, device_id, address, data) \
     49        generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data)
     50
     51#define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \
     52        generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, \
     53            address, data)
     54
     55#define nil_send_msg(nil_phone, device_id, packet, sender) \
     56        generic_send_msg_remote(nil_phone, NET_NIL_SEND, device_id, \
     57            packet_get_id(packet), sender, 0)
     58
     59#define nil_device_req(nil_phone, device_id, mtu, netif_service) \
     60        generic_device_req_remote(nil_phone, NET_NIL_DEVICE, device_id, mtu, \
     61            netif_service)
     62
     63extern int nil_device_state_msg(int, device_id_t, int);
     64extern int nil_received_msg(int, device_id_t, packet_t *, services_t);
    4265
    4366#endif
  • uspace/lib/net/netif/netif_skel.c

    r04aade50 rfe8dfa6  
    3333/** @file
    3434 * Network interface module skeleton implementation.
    35  * @see netif.h
     35 * @see netif_skel.h
    3636 */
    3737
     
    5252#include <adt/measured_strings.h>
    5353#include <net/device.h>
    54 #include <nil_interface.h>
    5554#include <netif_skel.h>
     55#include <nil_remote.h>
    5656
    5757DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
  • uspace/lib/net/nil/nil_remote.c

    r04aade50 rfe8dfa6  
    3333/** @file
    3434 * Network interface layer interface implementation for remote modules.
    35  * @see nil_interface.h
     35 * @see nil_remote.h
    3636 */
    3737
    3838#include <nil_remote.h>
    39 #include <nil_interface.h>
    4039#include <generic.h>
    4140#include <net/device.h>
    4241#include <net/packet.h>
    4342#include <packet_client.h>
    44 
    4543#include <ipc/nil.h>
    4644
    4745/** Notify the network interface layer about the device state change.
    4846 *
    49  * @param[in] nil_phone The network interface layer phone.
    50  * @param[in] device_id The device identifier.
    51  * @param[in] state     The new device state.
    52  * @return              EOK on success.
    53  * @return              Other error codes as defined for each specific module
    54  *                      device state function.
     47 * @param[in] nil_phone Network interface layer phone.
     48 * @param[in] device_id Device identifier.
     49 * @param[in] state     New device state.
     50 *
     51 * @return EOK on success.
     52 * @return Other error codes as defined for each specific module
     53 *         device state function.
     54 *
    5555 */
    56 int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state)
     56int nil_device_state_msg(int nil_phone, device_id_t device_id, int state)
    5757{
    5858        return generic_device_state_msg_remote(nil_phone, NET_NIL_DEVICE_STATE,
     
    6565 * upper layers.
    6666 *
    67  * @param[in] nil_phone The network interface layer phone.
    68  * @param[in] device_id The source device identifier.
    69  * @param[in] packet    The received packet or the received packet queue.
    70  * @param target        The target service. Ignored parameter.
    71  * @return              EOK on success.
    72  * @return              Other error codes as defined for each specific module
    73  *                      received function.
     67 * @param[in] nil_phone Network interface layer phone.
     68 * @param[in] device_id Source device identifier.
     69 * @param[in] packet    Received packet or the received packet queue.
     70 * @param[in] target    Target service. Ignored parameter.
     71 *
     72 * @return EOK on success.
     73 * @return Other error codes as defined for each specific module
     74 *         received function.
     75 *
    7476 */
    75 int nil_received_msg_remote(int nil_phone, device_id_t device_id,
     77int nil_received_msg(int nil_phone, device_id_t device_id,
    7678    packet_t *packet, services_t target)
    7779{
  • 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.