Changeset faa3588 in mainline


Ignore:
Timestamp:
2010-10-16T15:47:36Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af7638e
Parents:
9f9c7fd
Message:

Cleanup ARP module interfaces.

Location:
uspace/lib/net
Files:
2 edited

Legend:

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

    r9f9c7fd rfaa3588  
    2727 */
    2828
    29 /** @addtogroup arp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ARP interface implementation for remote modules.
    35  *  @see arp_interface.h
     34 * ARP interface implementation for remote modules.
     35 * @see arp_interface.h
    3636 */
    3737
     
    4949#include <adt/measured_strings.h>
    5050
    51 int arp_connect_module(services_t service){
    52         if(service != SERVICE_ARP){
     51/** Connects to the ARP module.
     52 *
     53 * @param service       The ARP module service. Ignored parameter.
     54 * @returns             The ARP module phone on success.
     55 */
     56int arp_connect_module(services_t service)
     57{
     58        if (service != SERVICE_ARP)
    5359                return EINVAL;
    54         }
     60
    5561        return connect_to_service(SERVICE_ARP);
    5662}
    5763
    58 int arp_clean_cache_req(int arp_phone){
     64/** Cleans the cache.
     65 *
     66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     67 * @returns             EOK on success.
     68 */
     69int arp_clean_cache_req(int arp_phone)
     70{
    5971        return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
    6072}
    6173
    62 int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){
     74/** Clears the given protocol address from the cache.
     75 *
     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 * @returns             EOK on success.
     81 * @returns             ENOENT if the mapping is not found.
     82 */
     83int
     84arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol,
     85    measured_string_ref address)
     86{
    6387        aid_t message_id;
    6488        ipcarg_t result;
    6589
    66         message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, (ipcarg_t) device_id, protocol, NULL);
     90        message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS,
     91            (ipcarg_t) device_id, protocol, NULL);
    6792        measured_strings_send(arp_phone, address, 1);
    6893        async_wait_for(message_id, &result);
     94
    6995        return (int) result;
    7096}
    7197
    72 int arp_clear_device_req(int arp_phone, device_id_t device_id){
    73         return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id);
     98/** Clears the device cache.
     99 *
     100 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     101 * @param[in] device_id The device identifier.
     102 * @returns             EOK on success.
     103 * @returns             ENOENT if the device is not found.
     104 */
     105int arp_clear_device_req(int arp_phone, device_id_t device_id)
     106{
     107        return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE,
     108            (ipcarg_t) device_id);
    74109}
    75110
    76 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
     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 * @returns             EOK on success.
     122 * @returns             EEXIST if the device is already used.
     123 * @returns             ENOMEM if there is not enough memory left.
     124 * @returns             ENOENT if the network interface service is not known.
     125 * @returns             EREFUSED if the network interface service is not
     126 *                      responding.
     127 * @returns             Other error codes as defined for the
     128 *                      nil_packet_get_size() function.
     129 * @returns             Other error codes as defined for the nil_get_addr()
     130 *                      function.
     131 * @returns             Other error codes as defined for the
     132 *                      nil_get_broadcast_addr() function.
     133 */
     134int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol,
     135    services_t netif, measured_string_ref address)
     136{
    77137        aid_t message_id;
    78138        ipcarg_t result;
    79139
    80         message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL);
     140        message_id = async_send_3(arp_phone, NET_ARP_DEVICE,
     141            (ipcarg_t) device_id, protocol, netif, NULL);
    81142        measured_strings_send(arp_phone, address, 1);
    82143        async_wait_for(message_id, &result);
     144
    83145        return (int) result;
    84146}
    85147
    86 task_id_t arp_task_get_id(void){
     148/** Returns the ARP task identifier.
     149 *
     150 * @returns             0 if called by the remote module.
     151 */
     152task_id_t arp_task_get_id(void)
     153{
    87154        return 0;
    88155}
    89156
    90 int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
    91         return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data);
     157/** Translates the given protocol address to the network interface address.
     158 *
     159 * Broadcasts the ARP request if the mapping is not found.
     160 * Allocates and returns the needed memory block as the data parameter.
     161 *
     162 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     163 * @param[in] device_id The device identifier.
     164 * @param[in] protocol  The requesting protocol service.
     165 * @param[in] address   The local requesting protocol address.
     166 * @param[out] translation The translation of the local protocol address.
     167 * @param[out] data     The allocated raw translation data container.
     168 * @returns             EOK on success.
     169 * @returns             EINVAL if the address parameter is NULL.
     170 * @returns             EBADMEM if the translation or the data parameters are
     171 *                      NULL.
     172 * @returns             ENOENT if the mapping is not found.
     173 */
     174int
     175arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
     176    measured_string_ref address, measured_string_ref *translation, char **data)
     177{
     178        return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
     179            protocol, address, 1, translation, data);
    92180}
    93181
  • uspace/lib/net/include/arp_interface.h

    r9f9c7fd rfaa3588  
    2727 */
    2828
    29 /** @addtogroup arp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    33 #ifndef __NET_ARP_INTERFACE_H__
    34 #define __NET_ARP_INTERFACE_H__
     33#ifndef LIBNET_ARP_INTERFACE_H_
     34#define LIBNET_ARP_INTERFACE_H_
    3535
    3636#include <adt/measured_strings.h>
     
    4343
    4444/** @name ARP module interface
    45  *  This interface is used by other modules.
     45 * This interface is used by other modules.
    4646 */
    4747/*@{*/
    4848
    49 /** Registers the new device and the requesting protocol service.
    50  *  Connects to the network interface layer service.
    51  *  Determines the device broadcast address, its address lengths and packet size.
    52  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    53  *  @param[in] device_id The new device identifier.
    54  *  @param[in] protocol The requesting protocol service.
    55  *  @param[in] netif The underlying device network interface layer service.
    56  *  @param[in] address The local requesting protocol address of the device.
    57  *  @returns EOK on success.
    58  *  @returns EEXIST if the device is already used.
    59  *  @returns ENOMEM if there is not enough memory left.
    60  *  @returns ENOENT if the network interface service is not known.
    61  *  @returns EREFUSED if the network interface service is not responding.
    62  *  @returns Other error codes as defined for the nil_packet_get_size() function.
    63  *  @returns Other error codes as defined for the nil_get_addr() function.
    64  *  @returns Other error codes as defined for the nil_get_broadcast_addr() function.
    65  */
    66 extern int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address);
    67 
    68 /** Translates the given protocol address to the network interface address.
    69  *  Broadcasts the ARP request if the mapping is not found.
    70  *  Allocates and returns the needed memory block as the data parameter.
    71  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    72  *  @param[in] device_id The device identifier.
    73  *  @param[in] protocol The requesting protocol service.
    74  *  @param[in] address The local requesting protocol address.
    75  *  @param[out] translation The translation of the local protocol address.
    76  *  @param[out] data The allocated raw translation data container.
    77  *  @returns EOK on success.
    78  *  @returns EINVAL if the address parameter is NULL.
    79  *  @returns EBADMEM if the translation or the data parameters are NULL.
    80  *  @returns ENOENT if the mapping is not found.
    81  */
    82 extern int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data);
    83 
    84 /** Clears the device cache.
    85  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    86  *  @param[in] device_id The device identifier.
    87  *  @returns EOK on success.
    88  *  @returns ENOENT if the device is not found.
    89  */
    90 extern int arp_clear_device_req(int arp_phone, device_id_t device_id);
    91 
    92 /** Clears the given protocol address from the cache.
    93  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    94  *  @param[in] device_id The device identifier.
    95  *  @param[in] protocol The requesting protocol service.
    96  *  @param[in] address The protocol address to be cleared.
    97  *  @returns EOK on success.
    98  *  @returns ENOENT if the mapping is not found.
    99  */
    100 extern int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address);
    101 
    102 /** Cleans the cache.
    103  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    104  *  @returns EOK on success.
    105  */
    106 extern int arp_clean_cache_req(int arp_phone);
    107 
    108 /** Connects to the ARP module.
    109  *  @param service The ARP module service. Ignored parameter.
    110  *  @returns The ARP module phone on success.
    111  */
    112 extern int arp_connect_module(services_t service);
    113 
    114 /** Returns the ARP task identifier.
    115  *  @returns 0 if called by the remote module.
    116  */
     49extern int arp_device_req(int, device_id_t, services_t, services_t,
     50    measured_string_ref);
     51extern int arp_translate_req(int, device_id_t, services_t, measured_string_ref,
     52    measured_string_ref *, char **);
     53extern int arp_clear_device_req(int, device_id_t);
     54extern int arp_clear_address_req(int, device_id_t, services_t,
     55    measured_string_ref);
     56extern int arp_clean_cache_req(int);
     57extern int arp_connect_module(services_t);
    11758extern task_id_t arp_task_get_id(void);
    11859
Note: See TracChangeset for help on using the changeset viewer.