Changeset 6b82009 in mainline for uspace/lib/net/il/arp_remote.c


Ignore:
Timestamp:
2011-06-22T20:41:41Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef09a7a
Parents:
55091847
Message:

networking stack: convert to the new async framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/il/arp_remote.c

    r55091847 r6b82009  
    3838#include <arp_interface.h>
    3939#include <generic.h>
    40 
    41 #include <async.h>
    42 #include <async_obsolete.h>
    43 #include <errno.h>
    4440#include <ipc/services.h>
    4541#include <ipc/arp.h>
    46 
    4742#include <net/modules.h>
    4843#include <net/device.h>
    4944#include <adt/measured_strings.h>
     45#include <async.h>
     46#include <errno.h>
    5047
    51 /** Connects to the ARP module.
     48/** Connect to the ARP module.
    5249 *
    53  * @param service       The ARP module service. Ignored parameter.
    54  * @return              The ARP module phone on success.
     50 * @return ARP module session on success.
     51 *
    5552 */
    56 int arp_connect_module(services_t service)
     53async_sess_t *arp_connect_module(services_t service)
    5754{
    58         if (service != SERVICE_ARP)
    59                 return EINVAL;
    60 
     55        // FIXME: Get rid of the useless argument
    6156        return connect_to_service(SERVICE_ARP);
    6257}
     
    6459/** Cleans the cache.
    6560 *
    66  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    67  * @return              EOK on success.
     61 * @param[in] sess ARP module session.
     62 *
     63 * @return EOK on success.
     64 *
    6865 */
    69 int arp_clean_cache_req(int arp_phone)
     66int arp_clean_cache_req(async_sess_t *sess)
    7067{
    71         return (int) async_obsolete_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
     68        async_exch_t *exch = async_exchange_begin(sess);
     69        int rc = async_req_0_0(exch, NET_ARP_CLEAN_CACHE);
     70        async_exchange_end(exch);
     71       
     72        return rc;
    7273}
    7374
    74 /** Clears the given protocol address from the cache.
     75/** Clear the given protocol address from the cache.
    7576 *
    76  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    77  * @param[in] device_id The device identifier.
    78  * @param[in] protocol  The requesting protocol service.
    79  * @param[in] address   The protocol address to be cleared.
    80  * @return              EOK on success.
    81  * @return              ENOENT if the mapping is not found.
     77 * @param[in] sess      ARP module session.
     78 * @param[in] device_id Device identifier.
     79 * @param[in] protocol  Requesting protocol service.
     80 * @param[in] address   Protocol address to be cleared.
     81 *
     82 * @return EOK on success.
     83 * @return ENOENT if the mapping is not found.
     84 *
    8285 */
    83 int
    84 arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol,
    85     measured_string_t *address)
     86int arp_clear_address_req(async_sess_t *sess, device_id_t device_id,
     87    services_t protocol, measured_string_t *address)
    8688{
    87         aid_t message_id;
     89        async_exch_t *exch = async_exchange_begin(sess);
     90        aid_t message_id = async_send_2(exch, NET_ARP_CLEAR_ADDRESS,
     91            (sysarg_t) device_id, protocol, NULL);
     92        measured_strings_send(exch, address, 1);
     93        async_exchange_end(exch);
     94       
    8895        sysarg_t result;
     96        async_wait_for(message_id, &result);
     97       
     98        return (int) result;
     99}
    89100
    90         message_id = async_obsolete_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS,
    91             (sysarg_t) device_id, protocol, NULL);
    92         measured_strings_send(arp_phone, address, 1);
     101/** Clear the device cache.
     102 *
     103 * @param[in] sess      ARP module session.
     104 * @param[in] device_id Device identifier.
     105 *
     106 * @return EOK on success.
     107 * @return ENOENT if the device is not found.
     108 *
     109 */
     110int arp_clear_device_req(async_sess_t *sess, device_id_t device_id)
     111{
     112        async_exch_t *exch = async_exchange_begin(sess);
     113        int rc = async_req_1_0(exch, NET_ARP_CLEAR_DEVICE,
     114            (sysarg_t) device_id);
     115        async_exchange_end(exch);
     116       
     117        return rc;
     118}
     119
     120/** Register new device and the requesting protocol service.
     121 *
     122 * Connect to the network interface layer service.
     123 * Determine the device broadcast address, its address lengths and packet size.
     124 *
     125 * @param[in] sess      ARP module session.
     126 * @param[in] device_id New device identifier.
     127 * @param[in] protocol  Requesting protocol service.
     128 * @param[in] netif     Underlying device network interface layer service.
     129 * @param[in] address   Local requesting protocol address of the device.
     130 *
     131 * @return EOK on success.
     132 * @return EEXIST if the device is already used.
     133 * @return ENOMEM if there is not enough memory left.
     134 * @return ENOENT if the network interface service is not known.
     135 * @return EREFUSED if the network interface service is not
     136 *         responding.
     137 * @return Other error codes as defined for the
     138 *         nil_packet_get_size() function.
     139 * @return Other error codes as defined for the nil_get_addr()
     140 *         function.
     141 * @return Other error codes as defined for the
     142 *         nil_get_broadcast_addr() function.
     143 *
     144 */
     145int arp_device_req(async_sess_t *sess, device_id_t device_id,
     146    services_t protocol, services_t netif, measured_string_t *address)
     147{
     148        async_exch_t *exch = async_exchange_begin(sess);
     149        aid_t message_id = async_send_3(exch, NET_ARP_DEVICE,
     150            (sysarg_t) device_id, protocol, netif, NULL);
     151        measured_strings_send(exch, address, 1);
     152        async_exchange_end(exch);
     153       
     154        sysarg_t result;
    93155        async_wait_for(message_id, &result);
    94156
     
    96158}
    97159
    98 /** Clears the device cache.
     160/** Translate the given protocol address to the network interface address.
    99161 *
    100  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    101  * @param[in] device_id The device identifier.
    102  * @return              EOK on success.
    103  * @return              ENOENT if the device is not found.
     162 * Broadcast the ARP request if the mapping is not found.
     163 * Allocate and returns the needed memory block as the data parameter.
     164 *
     165 * @param[in]  sess        ARP module session.
     166 * @param[in]  device_id   Device identifier.
     167 * @param[in]  protocol    Requesting protocol service.
     168 * @param[in]  address     Local requesting protocol address.
     169 * @param[out] translation Translation of the local protocol address.
     170 * @param[out] data        Allocated raw translation data container.
     171 *
     172 * @return EOK on success.
     173 * @return EINVAL if the address parameter is NULL.
     174 * @return EBADMEM if the translation or the data parameters are
     175 *         NULL.
     176 * @return ENOENT if the mapping is not found.
     177 *
    104178 */
    105 int arp_clear_device_req(int arp_phone, device_id_t device_id)
     179int arp_translate_req(async_sess_t *sess, device_id_t device_id,
     180    services_t protocol, measured_string_t *address,
     181    measured_string_t **translation, uint8_t **data)
    106182{
    107         return (int) async_obsolete_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE,
    108             (sysarg_t) device_id);
    109 }
    110 
    111 /** Registers the new device and the requesting protocol service.
    112  *
    113  * Connects to the network interface layer service.
    114  * Determines the device broadcast address, its address lengths and packet size.
    115  *
    116  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    117  * @param[in] device_id The new device identifier.
    118  * @param[in] protocol  The requesting protocol service.
    119  * @param[in] netif     The underlying device network interface layer service.
    120  * @param[in] address   The local requesting protocol address of the device.
    121  * @return              EOK on success.
    122  * @return              EEXIST if the device is already used.
    123  * @return              ENOMEM if there is not enough memory left.
    124  * @return              ENOENT if the network interface service is not known.
    125  * @return              EREFUSED if the network interface service is not
    126  *                      responding.
    127  * @return              Other error codes as defined for the
    128  *                      nil_packet_get_size() function.
    129  * @return              Other error codes as defined for the nil_get_addr()
    130  *                      function.
    131  * @return              Other error codes as defined for the
    132  *                      nil_get_broadcast_addr() function.
    133  */
    134 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol,
    135     services_t netif, measured_string_t *address)
    136 {
    137         aid_t message_id;
    138         sysarg_t result;
    139 
    140         message_id = async_obsolete_send_3(arp_phone, NET_ARP_DEVICE,
    141             (sysarg_t) device_id, protocol, netif, NULL);
    142         measured_strings_send(arp_phone, address, 1);
    143         async_wait_for(message_id, &result);
    144 
    145         return (int) result;
    146 }
    147 
    148 /** Translates the given protocol address to the network interface address.
    149  *
    150  * Broadcasts the ARP request if the mapping is not found.
    151  * Allocates and returns the needed memory block as the data parameter.
    152  *
    153  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    154  * @param[in] device_id The device identifier.
    155  * @param[in] protocol  The requesting protocol service.
    156  * @param[in] address   The local requesting protocol address.
    157  * @param[out] translation The translation of the local protocol address.
    158  * @param[out] data     The allocated raw translation data container.
    159  * @return              EOK on success.
    160  * @return              EINVAL if the address parameter is NULL.
    161  * @return              EBADMEM if the translation or the data parameters are
    162  *                      NULL.
    163  * @return              ENOENT if the mapping is not found.
    164  */
    165 int
    166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
    167     measured_string_t *address, measured_string_t **translation, uint8_t **data)
    168 {
    169         return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
     183        return generic_translate_req(sess, NET_ARP_TRANSLATE, device_id,
    170184            protocol, address, 1, translation, data);
    171185}
Note: See TracChangeset for help on using the changeset viewer.