Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/generic/net_remote.c

    r609243f4 r61bfc370  
    3838#include <ipc/services.h>
    3939#include <ipc/net_net.h>
     40
    4041#include <malloc.h>
    41 #include <async.h>
    42 #include <devman.h>
     42
    4343#include <generic.h>
    4444#include <net/modules.h>
     
    4747#include <adt/measured_strings.h>
    4848
    49 /** Connect to the networking module.
     49/** Connects to the networking module.
    5050 *
    51  * @return Networking module session on success.
    52  *
     51 * @return              The networking module phone on success.
    5352 */
    54 async_sess_t *net_connect_module(void)
     53int net_connect_module(void)
    5554{
    5655        return connect_to_service(SERVICE_NETWORKING);
    5756}
    5857
    59 /** Free the received settings.
     58/** Frees the received settings.
    6059 *
    61  * @param[in] settings Received settings.
    62  * @param[in] data     Received settings data.
    63  *
    64  * @see net_get_device_conf_req()
     60 * @param[in] settings  The received settings.
     61 * @param[in] data      The received settings data.
     62 * @see net_get_device_conf_req()
    6563 * @see net_get_conf_req()
    66  *
    6764 */
    6865void net_free_settings(measured_string_t *settings, uint8_t *data)
     
    7471}
    7572
    76 /** Return the global configuration.
     73/** Returns the global configuration.
    7774 *
    7875 * The configuration names are read and the appropriate settings are set
     
    8077 * configuration.
    8178 *
    82  * @param[in]     sess          Networking module session.
    83  * @param[in,out] configuration Requested configuration. The names are
    84  *                              read and the appropriate settings are set
    85  *                              instead.
     79 * @param[in] net_phone The networking module phone.
     80 * @param[in,out] configuration The requested configuration. The names are read
     81 * and the appropriate settings are set instead.
    8682 *
    87  * @param[in]     count         Configuration entries count.
    88  * @param[in,out] data          Configuration and settings data.
    89  *
    90  * @return EOK on success.
    91  * @return EINVAL if the configuration is NULL.
    92  * @return EINVAL if the count is zero.
    93  * @return Other error codes as defined for the
    94  *         generic_translate_req() function.
    95  *
     83 * @param[in] count     The configuration entries count.
     84 * @param[in,out] data  The configuration and settings data.
     85 * @return              EOK on success.
     86 * @return              EINVAL if the configuration is NULL.
     87 * @return              EINVAL if the count is zero.
     88 * @return              Other error codes as defined for the
     89 *                      generic_translate_req() function.
    9690 */
    97 int net_get_conf_req(async_sess_t *sess, measured_string_t **configuration,
     91int
     92net_get_conf_req(int net_phone, measured_string_t **configuration,
    9893    size_t count, uint8_t **data)
    9994{
    100         return generic_translate_req(sess, NET_NET_GET_CONF, 0, 0,
     95        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
    10196            *configuration, count, configuration, data);
    10297}
    10398
    104 /** Return the device specific configuration.
     99/** Returns the device specific configuration.
    105100 *
    106  * Return the global configuration if the device specific is not found.
     101 * Returns the global configuration if the device specific is not found.
    107102 * The configuration names are read and the appropriate settings are set
    108103 * instead. Call net_free_settings() function to release the returned
    109104 * configuration.
    110105 *
    111  * @param[in]     sess          The networking module session.
    112  * @param[in]     device_id     Device identifier.
    113  * @param[in,out] configuration Requested device configuration. The names
    114  *                              are read and the appropriate settings are
    115  *                              set instead.
    116  * @param[in]     count         Configuration entries count.
    117  * @param[in,out] data          Configuration and settings data.
    118  *
    119  * @return EOK on success.
    120  * @return EINVAL if the configuration is NULL.
    121  * @return EINVAL if the count is zero.
    122  * @return Other error codes as defined for the
    123  *         generic_translate_req() function.
    124  *
     106 * @param[in] net_phone The networking module phone.
     107 * @param[in] device_id The device identifier.
     108 * @param[in,out] configuration The requested device configuration. The names
     109 *                      are read and the appropriate settings are set instead.
     110 * @param[in] count     The configuration entries count.
     111 * @param[in,out] data  The configuration and settings data.
     112 * @return              EOK on success.
     113 * @return              EINVAL if the configuration is NULL.
     114 * @return              EINVAL if the count is zero.
     115 * @return              Other error codes as defined for the
     116 *                      generic_translate_req() function.
    125117 */
    126 int net_get_device_conf_req(async_sess_t *sess, nic_device_id_t device_id,
     118int
     119net_get_device_conf_req(int net_phone, device_id_t device_id,
    127120    measured_string_t **configuration, size_t count, uint8_t **data)
    128121{
    129         return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF,
     122        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
    130123            device_id, 0, *configuration, count, configuration, data);
    131 }
    132 
    133 int net_get_devices_req(async_sess_t *sess, measured_string_t **devices,
    134     size_t *count, uint8_t **data)
    135 {
    136         if ((!devices) || (!count))
    137                 return EBADMEM;
    138        
    139         async_exch_t *exch = async_exchange_begin(sess);
    140        
    141         int rc = async_req_0_1(exch, NET_NET_GET_DEVICES_COUNT, count);
    142         if (rc != EOK) {
    143                 async_exchange_end(exch);
    144                 return rc;
    145         }
    146        
    147         if (*count == 0) {
    148                 async_exchange_end(exch);
    149                 *data = NULL;
    150                 return EOK;
    151         }
    152        
    153         aid_t message_id = async_send_0(exch, NET_NET_GET_DEVICES, NULL);
    154         rc = measured_strings_return(exch, devices, data, *count);
    155        
    156         async_exchange_end(exch);
    157        
    158         sysarg_t result;
    159         async_wait_for(message_id, &result);
    160        
    161         if ((rc == EOK) && (result != EOK)) {
    162                 free(*devices);
    163                 free(*data);
    164         }
    165        
    166         return (int) result;
    167 }
    168 
    169 int net_driver_ready(async_sess_t *sess, devman_handle_t handle)
    170 {
    171         async_exch_t *exch = async_exchange_begin(sess);
    172         int rc = async_req_1_0(exch, NET_NET_DRIVER_READY, handle);
    173         async_exchange_end(exch);
    174        
    175         return rc;
    176124}
    177125
Note: See TracChangeset for help on using the changeset viewer.