Changeset 80cd7cd in mainline for uspace/lib/net


Ignore:
Timestamp:
2011-01-13T20:58:24Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
87e373b
Parents:
eaef141 (diff), a613fea1 (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:

Merge mainline changes.

Location:
uspace/lib/net
Files:
5 added
5 deleted
18 edited
7 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/Makefile

    reaef141 r80cd7cd  
    4040        generic/protocol_map.c \
    4141        adt/module_map.c \
    42         netif/netif_local.c \
    4342        netif/netif_remote.c \
     43        netif/netif_skel.c \
    4444        nil/nil_remote.c \
    45         il/il_interface.c \
     45        nil/nil_skel.c \
     46        il/il_remote.c \
     47        il/il_skel.c \
    4648        il/ip_remote.c \
    4749        il/ip_client.c \
     
    5052        tl/icmp_client.c \
    5153        tl/socket_core.c \
    52         tl/tl_interface.c \
    53         tl/tl_common.c
     54        tl/tl_common.c \
     55        tl/tl_remote.c \
     56        tl/tl_skel.c
    5457
    5558include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/net/adt/module_map.c

    reaef141 r80cd7cd  
    6363 */
    6464int
    65 add_module(module_t **module, modules_t *modules, const char *name,
    66     const char *filename, services_t service, task_id_t task_id,
     65add_module(module_t **module, modules_t *modules, const uint8_t *name,
     66    const uint8_t *filename, services_t service, task_id_t task_id,
    6767    connect_module_t connect_module)
    6868{
     
    104104 * @return              NULL if there is no such module.
    105105 */
    106 module_t *get_running_module(modules_t *modules, char *name)
     106module_t *get_running_module(modules_t *modules, uint8_t *name)
    107107{
    108108        module_t *module;
     
    113113
    114114        if (!module->task_id) {
    115                 module->task_id = spawn(module->filename);
     115                module->task_id = net_spawn(module->filename);
    116116                if (!module->task_id)
    117117                        return NULL;
     
    123123}
    124124
    125 /** Starts the given module.
     125/** Start the given module.
    126126 *
    127  * @param[in] fname     The module full or relative path filename.
    128  * @return              The new module task identifier on success.
    129  * @return              Zero if there is no such module.
     127 * @param[in] fname The module full or relative path filename.
     128 *
     129 * @return The new module task identifier on success.
     130 * @return Zero if there is no such module.
     131 *
    130132 */
    131 task_id_t spawn(const char *fname)
     133task_id_t net_spawn(const uint8_t *fname)
    132134{
    133135        task_id_t id;
    134136        int rc;
    135137       
    136         rc = task_spawnl(&id, fname, fname, NULL);
     138        rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL);
    137139        if (rc != EOK)
    138140                return 0;
  • uspace/lib/net/generic/generic.c

    reaef141 r80cd7cd  
    100100int
    101101generic_get_addr_req(int phone, int message, device_id_t device_id,
    102     measured_string_t **address, char ** data)
     102    measured_string_t **address, uint8_t **data)
    103103{
    104104        aid_t message_id;
     
    234234generic_translate_req(int phone, int message, device_id_t device_id,
    235235    services_t service, measured_string_t *configuration, size_t count,
    236     measured_string_t **translation, char **data)
     236    measured_string_t **translation, uint8_t **data)
    237237{
    238238        aid_t message_id;
  • uspace/lib/net/generic/net_remote.c

    reaef141 r80cd7cd  
    6363 * @see net_get_conf_req()
    6464 */
    65 void net_free_settings(measured_string_t *settings, char *data)
     65void net_free_settings(measured_string_t *settings, uint8_t *data)
    6666{
    6767        if (settings)
     
    9191int
    9292net_get_conf_req(int net_phone, measured_string_t **configuration,
    93     size_t count, char **data)
     93    size_t count, uint8_t **data)
    9494{
    9595        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
     
    118118int
    119119net_get_device_conf_req(int net_phone, device_id_t device_id,
    120     measured_string_t **configuration, size_t count, char **data)
     120    measured_string_t **configuration, size_t count, uint8_t **data)
    121121{
    122122        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
  • uspace/lib/net/generic/protocol_map.c

    reaef141 r80cd7cd  
    5050        switch (nil) {
    5151        case SERVICE_ETHERNET:
    52         case SERVICE_DP8390:
     52        case SERVICE_NE2000:
    5353                switch (il) {
    5454                case SERVICE_IP:
     
    7676        switch (nil) {
    7777        case SERVICE_ETHERNET:
    78         case SERVICE_DP8390:
     78        case SERVICE_NE2000:
    7979                switch (protocol) {
    8080                case ETH_P_IP:
     
    139139        switch (nil) {
    140140        case SERVICE_ETHERNET:
    141         case SERVICE_DP8390:
     141        case SERVICE_NE2000:
    142142                return HW_ETHER;
    143143        default:
  • uspace/lib/net/il/arp_remote.c

    reaef141 r80cd7cd  
    165165int
    166166arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
    167     measured_string_t *address, measured_string_t **translation, char **data)
     167    measured_string_t *address, measured_string_t **translation, uint8_t **data)
    168168{
    169169        return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
  • uspace/lib/net/il/il_remote.c

    reaef141 r80cd7cd  
    3333/** @file
    3434 * Internetwork layer module interface for the underlying network interface
    35  * layer. This interface is always called by the remote modules.
     35 * layer.
    3636 */
    3737
    38 #include <il_interface.h>
     38#include <il_remote.h>
    3939#include <generic.h>
    4040#include <packet_client.h>
  • uspace/lib/net/il/ip_remote.c

    reaef141 r80cd7cd  
    3636 *
    3737 * @see ip_interface.h
    38  * @see il_interface.h
     38 * @see il_remote.h
    3939 *
    4040 */
     
    121121    services_t service)
    122122{
    123         return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0,
     123        return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0,
    124124            service);
    125125}
     
    170170                free(*header);
    171171        else
    172                 *device_id = IPC_GET_DEVICE(&answer);
     172                *device_id = IPC_GET_DEVICE(answer);
    173173       
    174174        return (int) result;
     
    188188    packet_dimension_t *packet_dimension)
    189189{
    190         return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE,
     190        return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE,
    191191            device_id, packet_dimension);
    192192}
     
    228228    services_t sender, services_t error)
    229229{
    230         return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id,
     230        return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id,
    231231            packet_get_id(packet), sender, error);
    232232}
  • uspace/lib/net/include/adt/module_map.h

    reaef141 r80cd7cd  
    6565        int usage;
    6666        /** Module name. */
    67         const char *name;
     67        const uint8_t *name;
    6868        /** Module full path filename. */
    69         const char *filename;
     69        const uint8_t *filename;
    7070        /** Connecting function. */
    7171        connect_module_t *connect_module;
    7272};
    7373
    74 extern int add_module(module_t **, modules_t *, const char *, const char *,
    75     services_t, task_id_t, connect_module_t *);
    76 extern module_t *get_running_module(modules_t *, char *);
    77 extern task_id_t spawn(const char *);
     74extern int add_module(module_t **, modules_t *, const uint8_t *,
     75    const uint8_t *, services_t, task_id_t, connect_module_t *);
     76extern module_t *get_running_module(modules_t *, uint8_t *);
     77extern task_id_t net_spawn(const uint8_t *);
    7878
    7979#endif
  • uspace/lib/net/include/arp_interface.h

    reaef141 r80cd7cd  
    5050    measured_string_t *);
    5151extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *,
    52     measured_string_t **, char **);
     52    measured_string_t **, uint8_t **);
    5353extern int arp_clear_device_req(int, device_id_t);
    5454extern int arp_clear_address_req(int, device_id_t, services_t,
  • uspace/lib/net/include/generic.h

    reaef141 r80cd7cd  
    5050extern int generic_device_req_remote(int, int, device_id_t, int, services_t);
    5151extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **,
    52     char **);
     52    uint8_t **);
    5353extern int generic_packet_size_req_remote(int, int, device_id_t,
    5454    packet_dimension_t *);
     
    5858    services_t, services_t);
    5959extern int generic_translate_req(int, int, device_id_t, services_t,
    60     measured_string_t *, size_t, measured_string_t **, char **);
     60    measured_string_t *, size_t, measured_string_t **, uint8_t **);
    6161
    6262#endif
  • uspace/lib/net/include/il_remote.h

    reaef141 r80cd7cd  
    3636 */
    3737
    38 #ifndef LIBNET_IL_INTERFACE_H_
    39 #define LIBNET_IL_INTERFACE_H_
     38#ifndef LIBNET_IL_REMOTE_H_
     39#define LIBNET_IL_REMOTE_H_
    4040
    4141#include <ipc/services.h>
  • uspace/lib/net/include/il_skel.h

    reaef141 r80cd7cd  
    11/*
    2  * Copyright (c) 2008 Lukas Mejdrech
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup tcp
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
     33#ifndef LIBNET_IL_SKEL_H_
     34#define LIBNET_IL_SKEL_H_
     35
    3336/** @file
    34  * TCP standalone module implementation.
    35  * Contains skeleton module functions mapping.
    36  * The functions are used by the module skeleton as module specific entry
    37  * points.
    38  * @see module.c
     37 * Internetwork layer module skeleton.
     38 * The skeleton has to be part of each internetwork layer module.
    3939 */
    4040
    41 #include "tcp.h"
    42 #include "tcp_module.h"
    43 
    4441#include <async.h>
    45 #include <stdio.h>
    46 #include <errno.h>
     42#include <fibril_synch.h>
    4743#include <ipc/ipc.h>
    4844#include <ipc/services.h>
    4945
    50 #include <net/ip_protocols.h>
    51 #include <net/modules.h>
     46#include <adt/measured_strings.h>
     47#include <net/device.h>
    5248#include <net/packet.h>
    53 #include <net_interface.h>
    5449
    55 #include <ip_interface.h>
    56 #include <tl_local.h>
     50/** Module initialization.
     51 *
     52 * This has to be implemented in user code.
     53 *
     54 * @param[in] net_phone Networking module phone.
     55 *
     56 * @return EOK on success.
     57 * @return Other error codes as defined for each specific module
     58 *         initialize function.
     59 *
     60 */
     61extern int il_initialize(int net_phone);
    5762
    58 /** TCP module global data. */
    59 extern tcp_globals_t tcp_globals;
     63/** Process the internetwork layer module message.
     64 *
     65 * This has to be implemented in user code.
     66 *
     67 * @param[in]  callid Message identifier.
     68 * @param[in]  call   Message parameters.
     69 * @param[out] answer Answer.
     70 * @param[out] count  Number of arguments of the answer.
     71 *
     72 * @return EOK on success.
     73 * @return Other error codes as defined for each specific module.
     74 *
     75 */
     76extern int il_module_message(ipc_callid_t callid, ipc_call_t *call,
     77    ipc_call_t *answer, size_t *answer_count);
    6078
    61 int tl_module_start_standalone(async_client_conn_t client_connection)
    62 {
    63         sysarg_t phonehash;
    64         int rc;
     79extern int il_module_start(int);
    6580
    66         async_set_client_connection(client_connection);
    67         tcp_globals.net_phone = net_connect_module();
    68 
    69         rc = pm_init();
    70         if (rc != EOK)
    71                 return rc;
    72 
    73         rc = tcp_initialize(client_connection);
    74         if (rc != EOK)
    75                 goto out;
    76 
    77         rc = ipc_connect_to_me(PHONE_NS, SERVICE_TCP, 0, 0, &phonehash);
    78         if (rc != EOK)
    79                 goto out;
    80        
    81         async_manager();
    82        
    83 out:
    84         pm_destroy();
    85         return rc;
    86 }
    87 
    88 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    89     ipc_call_t *answer, int *answer_count)
    90 {
    91         return tcp_message_standalone(callid, call, answer, answer_count);
    92 }
     81#endif
    9382
    9483/** @}
  • uspace/lib/net/include/net_interface.h

    reaef141 r80cd7cd  
    4545
    4646extern int net_get_device_conf_req(int, device_id_t, measured_string_t **,
    47     size_t, char **);
    48 extern int net_get_conf_req(int, measured_string_t **, size_t, char **);
    49 extern void net_free_settings(measured_string_t *, char *);
     47    size_t, uint8_t **);
     48extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **);
     49extern void net_free_settings(measured_string_t *, uint8_t *);
    5050extern int net_connect_module(void);
    5151
  • uspace/lib/net/include/netif_remote.h

    reaef141 r80cd7cd  
    4141#include <net/packet.h>
    4242
    43 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_t **,
    44     char **);
    45 extern int netif_probe_req_remote(int, device_id_t, int, int);
    46 extern int netif_send_msg_remote(int, device_id_t, packet_t *, services_t);
    47 extern int netif_start_req_remote(int, device_id_t);
    48 extern int netif_stop_req_remote(int, device_id_t);
    49 extern int netif_stats_req_remote(int, device_id_t, device_stats_t *);
    50 extern int netif_bind_service_remote(services_t, device_id_t, services_t,
     43extern int netif_get_addr_req(int, device_id_t, measured_string_t **,
     44    uint8_t **);
     45extern int netif_probe_req(int, device_id_t, int, void *);
     46extern int netif_send_msg(int, device_id_t, packet_t *, services_t);
     47extern int netif_start_req(int, device_id_t);
     48extern int netif_stop_req(int, device_id_t);
     49extern int netif_stats_req(int, device_id_t, device_stats_t *);
     50extern int netif_bind_service(services_t, device_id_t, services_t,
    5151    async_client_conn_t);
    5252
  • uspace/lib/net/include/netif_skel.h

    reaef141 r80cd7cd  
    3636 */
    3737
    38 #ifndef NET_NETIF_LOCAL_H_
    39 #define NET_NETIF_LOCAL_H_
     38#ifndef NET_NETIF_SKEL_H_
     39#define NET_NETIF_SKEL_H_
    4040
    4141#include <async.h>
     
    7676 *
    7777 * This function has to be implemented in user code.
     78 *
    7879 */
    7980extern int netif_initialize(void);
     
    8384 * This has to be implemented in user code.
    8485 *
    85  * @param[in] device_id The device identifier.
    86  * @param[in] irq       The device interrupt number.
    87  * @param[in] io        The device input/output address.
    88  *
    89  * @return              EOK on success.
    90  * @return              Other error codes as defined for the find_device()
    91  *                      function.
    92  * @return              Other error codes as defined for the specific module
    93  *                      message implementation.
    94  */
    95 extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io);
     86 * @param[in] device_id Device identifier.
     87 * @param[in] irq       Device interrupt number.
     88 * @param[in] io        Device input/output address.
     89 *
     90 * @return EOK on success.
     91 * @return Other error codes as defined for the find_device()
     92 *         function.
     93 * @return Other error codes as defined for the specific module
     94 *         message implementation.
     95 *
     96 */
     97extern int netif_probe_message(device_id_t device_id, int irq, void *io);
    9698
    9799/** Send the packet queue.
     
    99101 * This has to be implemented in user code.
    100102 *
    101  * @param[in] device_id The device identifier.
    102  * @param[in] packet    The packet queue.
    103  * @param[in] sender    The sending module service.
    104  *
    105  * @return              EOK on success.
    106  * @return              EFORWARD if the device is not active (in the
    107  *                      NETIF_ACTIVE state).
    108  * @return              Other error codes as defined for the find_device()
    109  *                      function.
    110  * @return              Other error codes as defined for the specific module
    111  *                      message implementation.
     103 * @param[in] device_id Device identifier.
     104 * @param[in] packet    Packet queue.
     105 * @param[in] sender    Sending module service.
     106 *
     107 * @return EOK on success.
     108 * @return EFORWARD if the device is not active (in the
     109 *         NETIF_ACTIVE state).
     110 * @return Other error codes as defined for the find_device()
     111 *         function.
     112 * @return Other error codes as defined for the specific module
     113 *         message implementation.
     114 *
    112115 */
    113116extern int netif_send_message(device_id_t device_id, packet_t *packet,
     
    118121 * This has to be implemented in user code.
    119122 *
    120  * @param[in] device    The device structure.
    121  *
    122  * @return              EOK on success.
    123  * @return              Other error codes as defined for the find_device()
    124  *                      function.
    125  * @return              Other error codes as defined for the specific module
    126  *                      message implementation.
     123 * @param[in] device Device structure.
     124 *
     125 * @return New network interface state (non-negative values).
     126 * @return Other error codes as defined for the find_device()
     127 *         function.
     128 * @return Other error codes as defined for the specific module
     129 *         message implementation.
     130 
     131 *
    127132 */
    128133extern int netif_start_message(netif_device_t *device);
     
    132137 * This has to be implemented in user code.
    133138 *
    134  * @param[in] device    The device structure.
    135  *
    136  * @return              EOK on success.
    137  * @return              Other error codes as defined for the find_device()
    138  *                      function.
    139  * @return              Other error codes as defined for the specific module
    140  *                      message implementation.
     139 * @param[in] device Device structure.
     140 *
     141 * @return EOK on success.
     142 * @return Other error codes as defined for the find_device()
     143 *         function.
     144 * @return Other error codes as defined for the specific module
     145 *         message implementation.
     146 *
    141147 */
    142148extern int netif_stop_message(netif_device_t *device);
     
    146152 * This has to be implemented in user code.
    147153 *
    148  * @param[in] device_id The device identifier.
    149  * @param[out] address  The device local hardware address.
    150  *
    151  * @return              EOK on success.
    152  * @return              EBADMEM if the address parameter is NULL.
    153  * @return              ENOENT if there no such device.
    154  * @return              Other error codes as defined for the find_device()
    155  *                      function.
    156  * @return              Other error codes as defined for the specific module
    157  *                      message implementation.
     154 * @param[in] device_id Device identifier.
     155 * @param[out] address  Device local hardware address.
     156 *
     157 * @return EOK on success.
     158 * @return EBADMEM if the address parameter is NULL.
     159 * @return ENOENT if there no such device.
     160 * @return Other error codes as defined for the find_device()
     161 *         function.
     162 * @return Other error codes as defined for the specific module
     163 *         message implementation.
     164 *
    158165 */
    159166extern int netif_get_addr_message(device_id_t device_id,
     
    165172 * skeleton. This has to be implemented in user code.
    166173 *
    167  * @param[in] callid    The message identifier.
    168  * @param[in] call      The message parameters.
    169  * @param[out] answer   The message answer parameters.
    170  * @param[out] answer_count The last parameter for the actual answer in
    171  *                      the answer parameter.
    172  *
    173  * @return              EOK on success.
    174  * @return              ENOTSUP if the message is not known.
    175  * @return              Other error codes as defined for the specific module
    176  *                      message implementation.
     174 * @param[in]  callid Message identifier.
     175 * @param[in]  call   Message.
     176 * @param[out] answer Answer.
     177 * @param[out] count  Number of answer arguments.
     178 *
     179 * @return EOK on success.
     180 * @return ENOTSUP if the message is not known.
     181 * @return Other error codes as defined for the specific module
     182 *         message implementation.
     183 *
    177184 */
    178185extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
    179     ipc_call_t *answer, int *answer_count);
     186    ipc_call_t *answer, size_t *count);
    180187
    181188/** Return the device usage statistics.
     
    183190 * This has to be implemented in user code.
    184191 *
    185  * @param[in] device_id The device identifier.
    186  * @param[out] stats    The device usage statistics.
    187  *
    188  * @return              EOK on success.
    189  * @return              Other error codes as defined for the find_device()
    190  *                      function.
    191  * @return              Other error codes as defined for the specific module
    192  *                      message implementation.
     192 * @param[in]  device_id Device identifier.
     193 * @param[out] stats     Device usage statistics.
     194 *
     195 * @return EOK on success.
     196 * @return Other error codes as defined for the find_device()
     197 *         function.
     198 * @return Other error codes as defined for the specific module
     199 *         message implementation.
     200 *
    193201 */
    194202extern int netif_get_device_stats(device_id_t device_id,
    195203    device_stats_t *stats);
    196 
    197 extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **,
    198     char **);
    199 extern int netif_probe_req_local(int, device_id_t, int, int);
    200 extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t);
    201 extern int netif_start_req_local(int, device_id_t);
    202 extern int netif_stop_req_local(int, device_id_t);
    203 extern int netif_stats_req_local(int, device_id_t, device_stats_t *);
    204 extern int netif_bind_service_local(services_t, device_id_t, services_t,
    205     async_client_conn_t);
    206204
    207205extern int find_device(device_id_t, netif_device_t **);
     
    209207extern void netif_pq_release(packet_id_t);
    210208extern packet_t *netif_packet_get_1(size_t);
    211 extern int netif_init_module(async_client_conn_t);
    212 
    213 extern int netif_module_message_standalone(const char *, ipc_callid_t,
    214     ipc_call_t *, ipc_call_t *, int *);
    215 extern int netif_module_start_standalone(async_client_conn_t);
     209
     210extern int netif_module_start(void);
    216211
    217212#endif
  • uspace/lib/net/include/nil_remote.h

    reaef141 r80cd7cd  
    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/include/socket_core.h

    reaef141 r80cd7cd  
    8686        void *specific_data;
    8787        /** Socket ports map key. */
    88         const char *key;
     88        const uint8_t *key;
    8989        /** Length of the Socket ports map key. */
    9090        size_t key_length;
     
    118118    void (*)(socket_core_t *));
    119119extern int socket_reply_packets(packet_t *, size_t *);
    120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const char *,
     120extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
    121121    size_t);
    122122extern void socket_port_release(socket_ports_t *, socket_core_t *);
    123123extern int socket_port_add(socket_ports_t *, int, socket_core_t *,
    124     const char *, size_t);
     124    const uint8_t *, size_t);
    125125
    126126#endif
  • uspace/lib/net/include/tl_remote.h

    reaef141 r80cd7cd  
    3535 */
    3636
    37 #ifndef LIBNET_TL_INTERFACE_H_
    38 #define LIBNET_TL_INTERFACE_H_
     37#ifndef LIBNET_TL_REMOTE_H_
     38#define LIBNET_TL_REMOTE_H_
    3939
    4040#include <async.h>
     
    5252/*@{*/
    5353
    54 extern int tl_received_msg(int, device_id_t, packet_t *, services_t, services_t);
     54extern int tl_received_msg(int, device_id_t, packet_t *, services_t,
     55    services_t);
    5556
    5657/*@}*/
  • uspace/lib/net/netif/netif_remote.c

    reaef141 r80cd7cd  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    4949/** Return the device local hardware address.
    5050 *
    51  * @param[in] netif_phone The network interface phone.
    52  * @param[in] device_id The device identifier.
    53  * @param[out] address  The device local hardware address.
    54  * @param[out] data     The address data.
    55  * @return              EOK on success.
    56  * @return              EBADMEM if the address parameter is NULL.
    57  * @return              ENOENT if there no such device.
    58  * @return              Other error codes as defined for the
    59  *                      netif_get_addr_message() function.
     51 * @param[in]  netif_phone Network interface phone.
     52 * @param[in]  device_id   Device identifier.
     53 * @param[out] address     Device local hardware address.
     54 * @param[out] data        Address data.
     55 *
     56 * @return EOK on success.
     57 * @return EBADMEM if the address parameter is NULL.
     58 * @return ENOENT if there no such device.
     59 * @return Other error codes as defined for the
     60 *         netif_get_addr_message() function.
     61 *
    6062 */
    61 int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
    62     measured_string_t **address, char **data)
     63int netif_get_addr_req(int netif_phone, device_id_t device_id,
     64    measured_string_t **address, uint8_t **data)
    6365{
    6466        return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id,
     
    6870/** Probe the existence of the device.
    6971 *
    70  * @param[in] netif_phone The network interface phone.
    71  * @param[in] device_id The device identifier.
    72  * @param[in] irq       The device interrupt number.
    73  * @param[in] io        The device input/output address.
    74  * @return              EOK on success.
    75  * @return              Other error codes as defined for the
    76  *                      netif_probe_message().
     72 * @param[in] netif_phone Network interface phone.
     73 * @param[in] device_id   Device identifier.
     74 * @param[in] irq         Device interrupt number.
     75 * @param[in] io          Device input/output address.
     76 *
     77 * @return EOK on success.
     78 * @return Other error codes as defined for the
     79 *         netif_probe_message().
     80 *
    7781 */
    78 int
    79 netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
     82int netif_probe_req(int netif_phone, device_id_t device_id, int irq, void *io)
    8083{
    81         return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io);
     84        return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq,
     85            (sysarg_t) io);
    8286}
    8387
    8488/** Send the packet queue.
    8589 *
    86  * @param[in] netif_phone The network interface phone.
    87  * @param[in] device_id The device identifier.
    88  * @param[in] packet    The packet queue.
    89  * @param[in] sender    The sending module service.
    90  * @return              EOK on success.
    91  * @return              Other error codes as defined for the generic_send_msg()
    92  *                      function.
     90 * @param[in] netif_phone Network interface phone.
     91 * @param[in] device_id   Device identifier.
     92 * @param[in] packet      Packet queue.
     93 * @param[in] sender      Sending module service.
     94 *
     95 * @return EOK on success.
     96 * @return Other error codes as defined for the generic_send_msg()
     97 *         function.
     98 *
    9399 */
    94 int
    95 netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet,
     100int netif_send_msg(int netif_phone, device_id_t device_id, packet_t *packet,
    96101    services_t sender)
    97102{
     
    102107/** Start the device.
    103108 *
    104  * @param[in] netif_phone The network interface phone.
    105  * @param[in] device_id The device identifier.
    106  * @return              EOK on success.
    107  * @return              Other error codes as defined for the find_device()
    108  *                      function.
    109  * @return              Other error codes as defined for the
    110  *                      netif_start_message() function.
     109 * @param[in] netif_phone Network interface phone.
     110 * @param[in] device_id   Device identifier.
     111 *
     112 * @return EOK on success.
     113 * @return Other error codes as defined for the find_device()
     114 *         function.
     115 * @return Other error codes as defined for the
     116 *         netif_start_message() function.
     117 *
    111118 */
    112 int netif_start_req_remote(int netif_phone, device_id_t device_id)
     119int netif_start_req(int netif_phone, device_id_t device_id)
    113120{
    114121        return async_req_1_0(netif_phone, NET_NETIF_START, device_id);
     
    117124/** Stop the device.
    118125 *
    119  * @param[in] netif_phone The network interface phone.
    120  * @param[in] device_id The device identifier.
    121  * @return              EOK on success.
    122  * @return              Other error codes as defined for the find_device()
    123  *                      function.
    124  * @return              Other error codes as defined for the
    125  *                      netif_stop_message() function.
     126 * @param[in] netif_phone Network interface phone.
     127 * @param[in] device_id   Device identifier.
     128 *
     129 * @return EOK on success.
     130 * @return Other error codes as defined for the find_device()
     131 *         function.
     132 * @return Other error codes as defined for the
     133 *         netif_stop_message() function.
     134 *
    126135 */
    127 int netif_stop_req_remote(int netif_phone, device_id_t device_id)
     136int netif_stop_req(int netif_phone, device_id_t device_id)
    128137{
    129138        return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id);
     
    132141/** Return the device usage statistics.
    133142 *
    134  * @param[in] netif_phone The network interface phone.
    135  * @param[in] device_id The device identifier.
    136  * @param[out] stats    The device usage statistics.
     143 * @param[in] netif_phone Network interface phone.
     144 * @param[in] device_id   Device identifier.
     145 * @param[out] stats      Device usage statistics.
     146 *
    137147 * @return EOK on success.
     148 *
    138149 */
    139 int netif_stats_req_remote(int netif_phone, device_id_t device_id,
     150int netif_stats_req(int netif_phone, device_id_t device_id,
    140151    device_stats_t *stats)
    141152{
     
    153164}
    154165
    155 /** Create bidirectional connection with the network interface module and
    156  * registers the message receiver.
     166/** Create bidirectional connection with the network interface module
     167 *
     168 * Create bidirectional connection with the network interface module and
     169 * register the message receiver.
    157170 *
    158171 * @param[in] service   The network interface module service.
     
    161174 * @param[in] receiver  The message receiver.
    162175 *
    163  * @return              The phone of the needed service.
    164  * @return              EOK on success.
    165  * @return              Other error codes as defined for the bind_service()
    166  *                      function.
     176 * @return The phone of the needed service.
     177 * @return EOK on success.
     178 * @return Other error codes as defined for the bind_service()
     179 *         function.
     180 *
    167181 */
    168 int
    169 netif_bind_service_remote(services_t service, device_id_t device_id,
     182int netif_bind_service(services_t service, device_id_t device_id,
    170183    services_t me, async_client_conn_t receiver)
    171184{
  • uspace/lib/net/netif/netif_skel.c

    reaef141 r80cd7cd  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    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>
    55 #include <netif_local.h>
    56 #include <netif_interface.h>
     54#include <netif_skel.h>
     55#include <nil_remote.h>
    5756
    5857DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
     
    6362/** Probe the existence of the device.
    6463 *
    65  * @param[in] netif_phone The network interface phone.
    66  * @param[in] device_id The device identifier.
    67  * @param[in] irq       The device interrupt number.
    68  * @param[in] io        The device input/output address.
    69  * @return              EOK on success.
    70  * @return              Other error codes as defined for the
    71  *                      netif_probe_message().
    72  */
    73 int
    74 netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
     64 * @param[in] netif_phone Network interface phone.
     65 * @param[in] device_id   Device identifier.
     66 * @param[in] irq         Device interrupt number.
     67 * @param[in] io          Device input/output address.
     68 *
     69 * @return EOK on success.
     70 * @return Other error codes as defined for the
     71 *         netif_probe_message().
     72 *
     73 */
     74static int netif_probe_req_local(int netif_phone, device_id_t device_id,
     75    int irq, void *io)
    7576{
    7677        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8384/** Send the packet queue.
    8485 *
    85  * @param[in] netif_phone The network interface phone.
    86  * @param[in] device_id The device identifier.
    87  * @param[in] packet    The packet queue.
    88  * @param[in] sender    The sending module service.
    89  * @return              EOK on success.
    90  * @return              Other error codes as defined for the generic_send_msg()
    91  *                      function.
    92  */
    93 int netif_send_msg_local(int netif_phone, device_id_t device_id,
     86 * @param[in] netif_phone Network interface phone.
     87 * @param[in] device_id   Device identifier.
     88 * @param[in] packet      Packet queue.
     89 * @param[in] sender      Sending module service.
     90 *
     91 * @return EOK on success.
     92 * @return Other error codes as defined for the generic_send_msg()
     93 *         function.
     94 *
     95 */
     96static int netif_send_msg_local(int netif_phone, device_id_t device_id,
    9497    packet_t *packet, services_t sender)
    9598{
     
    103106/** Start the device.
    104107 *
    105  * @param[in] netif_phone The network interface phone.
    106  * @param[in] device_id The device identifier.
    107  * @return              EOK on success.
    108  * @return              Other error codes as defined for the find_device()
    109  *                      function.
    110  * @return              Other error codes as defined for the
    111  *                      netif_start_message() function.
    112  */
    113 int netif_start_req_local(int netif_phone, device_id_t device_id)
    114 {
    115         int rc;
    116        
     108 * @param[in] netif_phone Network interface phone.
     109 * @param[in] device_id   Device identifier.
     110 *
     111 * @return EOK on success.
     112 * @return Other error codes as defined for the find_device()
     113 *         function.
     114 * @return Other error codes as defined for the
     115 *         netif_start_message() function.
     116 *
     117 */
     118static int netif_start_req_local(int netif_phone, device_id_t device_id)
     119{
    117120        fibril_rwlock_write_lock(&netif_globals.lock);
    118121       
    119122        netif_device_t *device;
    120         rc = find_device(device_id, &device);
     123        int rc = find_device(device_id, &device);
    121124        if (rc != EOK) {
    122125                fibril_rwlock_write_unlock(&netif_globals.lock);
     
    127130        if (result > NETIF_NULL) {
    128131                int phone = device->nil_phone;
     132                nil_device_state_msg(phone, device_id, result);
    129133                fibril_rwlock_write_unlock(&netif_globals.lock);
    130                 nil_device_state_msg(phone, device_id, result);
    131134                return EOK;
    132135        }
     
    139142/** Stop the device.
    140143 *
    141  * @param[in] netif_phone The network interface phone.
    142  * @param[in] device_id The device identifier.
    143  * @return              EOK on success.
    144  * @return              Other error codes as defined for the find_device()
    145  *                      function.
    146  * @return              Other error codes as defined for the
    147  *                      netif_stop_message() function.
    148  */
    149 int netif_stop_req_local(int netif_phone, device_id_t device_id)
    150 {
    151         int rc;
    152        
     144 * @param[in] netif_phone Network interface phone.
     145 * @param[in] device_id   Device identifier.
     146 *
     147 * @return EOK on success.
     148 * @return Other error codes as defined for the find_device()
     149 *         function.
     150 * @return Other error codes as defined for the
     151 *         netif_stop_message() function.
     152 *
     153 */
     154static int netif_stop_req_local(int netif_phone, device_id_t device_id)
     155{
    153156        fibril_rwlock_write_lock(&netif_globals.lock);
    154157       
    155158        netif_device_t *device;
    156         rc = find_device(device_id, &device);
     159        int rc = find_device(device_id, &device);
    157160        if (rc != EOK) {
    158161                fibril_rwlock_write_unlock(&netif_globals.lock);
     
    163166        if (result > NETIF_NULL) {
    164167                int phone = device->nil_phone;
     168                nil_device_state_msg(phone, device_id, result);
    165169                fibril_rwlock_write_unlock(&netif_globals.lock);
    166                 nil_device_state_msg(phone, device_id, result);
    167170                return EOK;
    168171        }
     
    173176}
    174177
    175 /** Return the device usage statistics.
    176  *
    177  * @param[in] netif_phone The network interface phone.
    178  * @param[in] device_id The device identifier.
    179  * @param[out] stats    The device usage statistics.
    180  * @return EOK on success.
    181  */
    182 int netif_stats_req_local(int netif_phone, device_id_t device_id,
    183     device_stats_t *stats)
    184 {
    185         fibril_rwlock_read_lock(&netif_globals.lock);
    186         int res = netif_get_device_stats(device_id, stats);
    187         fibril_rwlock_read_unlock(&netif_globals.lock);
    188        
    189         return res;
    190 }
    191 
    192 /** Return the device local hardware address.
    193  *
    194  * @param[in] netif_phone The network interface phone.
    195  * @param[in] device_id The device identifier.
    196  * @param[out] address  The device local hardware address.
    197  * @param[out] data     The address data.
    198  * @return              EOK on success.
    199  * @return              EBADMEM if the address parameter is NULL.
    200  * @return              ENOENT if there no such device.
    201  * @return              Other error codes as defined for the
    202  *                      netif_get_addr_message() function.
    203  */
    204 int netif_get_addr_req_local(int netif_phone, device_id_t device_id,
    205     measured_string_t **address, char **data)
    206 {
    207         int rc;
    208        
    209         if (!address || !data)
    210                 return EBADMEM;
    211        
    212         fibril_rwlock_read_lock(&netif_globals.lock);
    213        
    214         measured_string_t translation;
    215         rc = netif_get_addr_message(device_id, &translation);
    216         if (rc == EOK) {
    217                 *address = measured_string_copy(&translation);
    218                 rc = (*address) ? EOK : ENOMEM;
    219         }
    220        
    221         fibril_rwlock_read_unlock(&netif_globals.lock);
    222        
    223         *data = (**address).value;
    224        
    225         return rc;
    226 }
    227 
    228178/** Find the device specific data.
    229179 *
    230  * @param[in] device_id The device identifier.
    231  * @param[out] device   The device specific data.
    232  * @return              EOK on success.
    233  * @return              ENOENT if device is not found.
    234  * @return              EPERM if the device is not initialized.
     180 * @param[in]  device_id Device identifier.
     181 * @param[out] device    Device specific data.
     182 *
     183 * @return EOK on success.
     184 * @return ENOENT if device is not found.
     185 * @return EPERM if the device is not initialized.
     186 *
    235187 */
    236188int find_device(device_id_t device_id, netif_device_t **device)
     
    251203/** Clear the usage statistics.
    252204 *
    253  * @param[in] stats     The usage statistics.
     205 * @param[in] stats The usage statistics.
     206 *
    254207 */
    255208void null_device_stats(device_stats_t *stats)
     
    258211}
    259212
    260 /** Initialize the netif module.
    261  *
    262  * @param[in] client_connection The client connection functio to be registered.
    263  * @return              EOK on success.
    264  * @return              Other error codes as defined for each specific module
    265  *                      message function.
    266  */
    267 int netif_init_module(async_client_conn_t client_connection)
    268 {
    269         int rc;
    270        
    271         async_set_client_connection(client_connection);
    272        
    273         netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
    274         netif_device_map_initialize(&netif_globals.device_map);
    275        
    276         rc = pm_init();
     213/** Release the given packet.
     214 *
     215 * Prepared for future optimization.
     216 *
     217 * @param[in] packet_id The packet identifier.
     218 *
     219 */
     220void netif_pq_release(packet_id_t packet_id)
     221{
     222        pq_release_remote(netif_globals.net_phone, packet_id);
     223}
     224
     225/** Allocate new packet to handle the given content size.
     226 *
     227 * @param[in] content Minimum content size.
     228 *
     229 * @return The allocated packet.
     230 * @return NULL on error.
     231 *
     232 */
     233packet_t *netif_packet_get_1(size_t content)
     234{
     235        return packet_get_1_remote(netif_globals.net_phone, content);
     236}
     237
     238/** Register the device notification receiver,
     239 *
     240 * Register a  network interface layer module as the device
     241 * notification receiver.
     242 *
     243 * @param[in] device_id Device identifier.
     244 * @param[in] phone     Network interface layer module phone.
     245 *
     246 * @return EOK on success.
     247 * @return ENOENT if there is no such device.
     248 * @return ELIMIT if there is another module registered.
     249 *
     250 */
     251static int register_message(device_id_t device_id, int phone)
     252{
     253        netif_device_t *device;
     254        int rc = find_device(device_id, &device);
    277255        if (rc != EOK)
    278256                return rc;
    279257       
    280         fibril_rwlock_initialize(&netif_globals.lock);
    281        
    282         rc = netif_initialize();
    283         if (rc != EOK) {
    284                 pm_destroy();
    285                 return rc;
    286         }
    287        
     258        if (device->nil_phone >= 0)
     259                return ELIMIT;
     260       
     261        device->nil_phone = phone;
    288262        return EOK;
    289263}
    290264
    291 /** Release the given packet.
    292  *
    293  * Prepared for future optimization.
    294  *
    295  * @param[in] packet_id The packet identifier.
    296  */
    297 void netif_pq_release(packet_id_t packet_id)
    298 {
    299         pq_release_remote(netif_globals.net_phone, packet_id);
    300 }
    301 
    302 /** Allocate new packet to handle the given content size.
    303  *
    304  * @param[in] content   The minimum content size.
    305  * @return              The allocated packet.
    306  * @return              NULL if there is an error.
    307  *
    308  */
    309 packet_t *netif_packet_get_1(size_t content)
    310 {
    311         return packet_get_1_remote(netif_globals.net_phone, content);
    312 }
    313 
    314 /** Register the device notification receiver, the network interface layer
    315  * module.
    316  *
    317  * @param[in] name      Module name.
    318  * @param[in] device_id The device identifier.
    319  * @param[in] phone     The network interface layer module phone.
    320  * @return              EOK on success.
    321  * @return              ENOENT if there is no such device.
    322  * @return              ELIMIT if there is another module registered.
    323  */
    324 static int register_message(const char *name, device_id_t device_id, int phone)
    325 {
    326         netif_device_t *device;
    327         int rc;
    328        
    329         rc = find_device(device_id, &device);
    330         if (rc != EOK)
    331                 return rc;
    332        
    333         if (device->nil_phone > 0)
    334                 return ELIMIT;
    335        
    336         device->nil_phone = phone;
    337         printf("%s: Receiver of device %d registered (phone: %d)\n",
    338             name, device->device_id, device->nil_phone);
    339         return EOK;
    340 }
    341 
    342265/** Process the netif module messages.
    343266 *
    344  * @param[in] name      Module name.
    345  * @param[in] callid    The message identifier.
    346  * @param[in] call      The message parameters.
    347  * @param[out] answer   The message answer parameters.
    348  * @param[out] answer_count The last parameter for the actual answer in the
    349  *                      answer parameter.
    350  * @return              EOK on success.
    351  * @return              ENOTSUP if the message is not known.
    352  * @return              Other error codes as defined for each specific module
    353  *                      message function.
     267 * @param[in]  callid Mmessage identifier.
     268 * @param[in]  call   Message.
     269 * @param[out] answer Answer.
     270 * @param[out] count  Number of arguments of the answer.
     271 *
     272 * @return EOK on success.
     273 * @return ENOTSUP if the message is unknown.
     274 * @return Other error codes as defined for each specific module
     275 *         message function.
    354276 *
    355277 * @see IS_NET_NETIF_MESSAGE()
    356278 *
    357279 */
    358 int netif_module_message_standalone(const char *name, ipc_callid_t callid,
    359     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     280static int netif_module_message(ipc_callid_t callid, ipc_call_t *call,
     281    ipc_call_t *answer, size_t *count)
    360282{
    361283        size_t length;
     
    365287        int rc;
    366288       
    367         *answer_count = 0;
     289        *count = 0;
     290       
    368291        switch (IPC_GET_IMETHOD(*call)) {
    369292        case IPC_M_PHONE_HUNGUP:
     
    371294       
    372295        case NET_NETIF_PROBE:
    373                 return netif_probe_req_local(0, IPC_GET_DEVICE(call),
    374                     NETIF_GET_IRQ(call), NETIF_GET_IO(call));
    375                    
     296                return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
     297                    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
     298       
    376299        case IPC_M_CONNECT_TO_ME:
    377300                fibril_rwlock_write_lock(&netif_globals.lock);
    378                 rc = register_message(name, IPC_GET_DEVICE(call),
    379                     IPC_GET_PHONE(call));
     301               
     302                rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
     303               
    380304                fibril_rwlock_write_unlock(&netif_globals.lock);
    381305                return rc;
    382                
     306       
    383307        case NET_NETIF_SEND:
    384308                rc = packet_translate_remote(netif_globals.net_phone, &packet,
    385                     IPC_GET_PACKET(call));
     309                    IPC_GET_PACKET(*call));
    386310                if (rc != EOK)
    387311                        return rc;
    388                 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
    389                     IPC_GET_SENDER(call));
    390                
     312               
     313                return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
     314                    IPC_GET_SENDER(*call));
     315       
    391316        case NET_NETIF_START:
    392                 return netif_start_req_local(0, IPC_GET_DEVICE(call));
    393                
     317                return netif_start_req_local(0, IPC_GET_DEVICE(*call));
     318       
    394319        case NET_NETIF_STATS:
    395320                fibril_rwlock_read_lock(&netif_globals.lock);
    396 
     321               
    397322                rc = async_data_read_receive(&callid, &length);
    398323                if (rc != EOK) {
     
    400325                        return rc;
    401326                }
     327               
    402328                if (length < sizeof(device_stats_t)) {
    403329                        fibril_rwlock_read_unlock(&netif_globals.lock);
    404330                        return EOVERFLOW;
    405331                }
    406 
    407                 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats);
     332               
     333                rc = netif_get_device_stats(IPC_GET_DEVICE(*call), &stats);
    408334                if (rc == EOK) {
    409335                        rc = async_data_read_finalize(callid, &stats,
    410336                            sizeof(device_stats_t));
    411337                }
    412 
     338               
    413339                fibril_rwlock_read_unlock(&netif_globals.lock);
    414340                return rc;
    415 
     341       
    416342        case NET_NETIF_STOP:
    417                 return netif_stop_req_local(0, IPC_GET_DEVICE(call));
    418                
     343                return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
     344       
    419345        case NET_NETIF_GET_ADDR:
    420346                fibril_rwlock_read_lock(&netif_globals.lock);
    421                 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address);
     347               
     348                rc = netif_get_addr_message(IPC_GET_DEVICE(*call), &address);
    422349                if (rc == EOK)
    423350                        rc = measured_strings_reply(&address, 1);
     351               
    424352                fibril_rwlock_read_unlock(&netif_globals.lock);
    425353                return rc;
    426354        }
    427355       
    428         return netif_specific_message(callid, call, answer, answer_count);
     356        return netif_specific_message(callid, call, answer, count);
     357}
     358
     359/** Default fibril for new module connections.
     360 *
     361 * @param[in] iid   Initial message identifier.
     362 * @param[in] icall Initial message call structure.
     363 *
     364 */
     365static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     366{
     367        /*
     368         * Accept the connection by answering
     369         * the initial IPC_M_CONNECT_ME_TO call.
     370         */
     371        ipc_answer_0(iid, EOK);
     372       
     373        while (true) {
     374                ipc_call_t answer;
     375                size_t count;
     376               
     377                /* Clear the answer structure */
     378                refresh_answer(&answer, &count);
     379               
     380                /* Fetch the next message */
     381                ipc_call_t call;
     382                ipc_callid_t callid = async_get_call(&call);
     383               
     384                /* Process the message */
     385                int res = netif_module_message(callid, &call, &answer, &count);
     386               
     387                /* End if said to either by the message or the processing result */
     388                if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
     389                    (res == EHANGUP))
     390                        return;
     391               
     392                /* Answer the message */
     393                answer_call(callid, res, &answer, count);
     394        }
    429395}
    430396
     
    435401 * messages in an infinite loop.
    436402 *
    437  * @param[in] client_connection The client connection processing function.
    438  *                      The module skeleton propagates its own one.
    439  * @return              EOK on success.
    440  * @return              Other error codes as defined for each specific module
    441  *                      message function.
    442  */
    443 int netif_module_start_standalone(async_client_conn_t client_connection)
    444 {
    445         int rc;
    446        
    447         rc = netif_init_module(client_connection);
     403 * @return EOK on success.
     404 * @return Other error codes as defined for each specific module
     405 *         message function.
     406 *
     407 */
     408int netif_module_start(void)
     409{
     410        async_set_client_connection(netif_client_connection);
     411       
     412        netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
     413        netif_device_map_initialize(&netif_globals.device_map);
     414       
     415        int rc = pm_init();
    448416        if (rc != EOK)
    449417                return rc;
     418       
     419        fibril_rwlock_initialize(&netif_globals.lock);
     420       
     421        rc = netif_initialize();
     422        if (rc != EOK) {
     423                pm_destroy();
     424                return rc;
     425        }
    450426       
    451427        async_manager();
  • uspace/lib/net/nil/nil_remote.c

    reaef141 r80cd7cd  
    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/tl/socket_core.c

    reaef141 r80cd7cd  
    161161static int
    162162socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket,
    163     const char *key, size_t key_length)
     163    const uint8_t *key, size_t key_length)
    164164{
    165165        socket_core_t **socket_ref;
     
    216216                goto fail;
    217217       
    218         rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,
    219             0);
     218        rc = socket_port_add_core(socket_port, socket,
     219            (const uint8_t *) SOCKET_MAP_KEY_LISTENING, 0);
    220220        if (rc != EOK)
    221221                goto fail;
     
    602602 */
    603603socket_core_t *
    604 socket_port_find(socket_ports_t *global_sockets, int port, const char *key,
     604socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key,
    605605    size_t key_length)
    606606{
     
    680680int
    681681socket_port_add(socket_ports_t *global_sockets, int port,
    682     socket_core_t *socket, const char *key, size_t key_length)
     682    socket_core_t *socket, const uint8_t *key, size_t key_length)
    683683{
    684684        socket_port_t *socket_port;
  • uspace/lib/net/tl/tl_common.c

    reaef141 r80cd7cd  
    4242#include <ip_remote.h>
    4343#include <ip_interface.h>
    44 #include <tl_interface.h>
     44#include <tl_remote.h>
    4545
    4646#include <net/socket_codes.h>
  • uspace/lib/net/tl/tl_remote.c

    reaef141 r80cd7cd  
    3131 */
    3232
    33 #include <tl_interface.h>
     33#include <tl_remote.h>
    3434#include <generic.h>
    3535#include <packet_client.h>
     
    5757 *
    5858 */
    59 int
    60 tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet,
     59int tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet,
    6160    services_t target, services_t error)
    6261{
Note: See TracChangeset for help on using the changeset viewer.