Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0e94b979 in mainline for uspace/lib/c/generic/inetcfg.c


Ignore:
Timestamp:
2012-03-08T21:12:44Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
291c792
Parents:
a88a6eac
Message:

Listing configured addresses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/inetcfg.c

    ra88a6eac r0e94b979  
    3535#include <loc.h>
    3636#include <stdlib.h>
     37#include <str.h>
    3738
    3839static async_sess_t *inetcfg_sess = NULL;
     
    156157int inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo)
    157158{
    158         sysarg_t ipv4, bits;
    159         async_exch_t *exch = async_exchange_begin(inetcfg_sess);
    160 
    161         int rc = async_req_1_2(exch, INETCFG_ADDR_GET, addr_id,
    162             &ipv4, &bits);
    163         async_exchange_end(exch);
    164 
    165         if (rc != EOK)
    166                 return rc;
    167 
    168         ainfo->naddr.ipv4 = ipv4;
    169         ainfo->naddr.bits = bits;
     159        ipc_call_t dreply;
     160        sysarg_t dretval;
     161        size_t act_size;
     162        char name_buf[LOC_NAME_MAXLEN + 1];
     163
     164        async_exch_t *exch = async_exchange_begin(inetcfg_sess);
     165
     166        ipc_call_t answer;
     167        aid_t req = async_send_1(exch, INETCFG_ADDR_GET, addr_id, &answer);
     168        aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply);
     169        async_wait_for(dreq, &dretval);
     170
     171        async_exchange_end(exch);
     172
     173        if (dretval != EOK) {
     174                async_wait_for(req, NULL);
     175                return dretval;
     176        }
     177
     178        sysarg_t retval;
     179        async_wait_for(req, &retval);
     180
     181        if (retval != EOK)
     182                return retval;
     183
     184        act_size = IPC_GET_ARG2(dreply);
     185        assert(act_size <= LOC_NAME_MAXLEN);
     186        name_buf[act_size] = '\0';
     187
     188        ainfo->naddr.ipv4 = IPC_GET_ARG1(answer);
     189        ainfo->naddr.bits = IPC_GET_ARG2(answer);
     190        ainfo->ilink = IPC_GET_ARG3(answer);
     191        ainfo->name = str_dup(name_buf);
     192
    170193        return EOK;
    171194}
     
    185208int inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo)
    186209{
    187         async_exch_t *exch = async_exchange_begin(inetcfg_sess);
    188 
    189         int rc = async_req_1_0(exch, INETCFG_LINK_GET, link_id);
    190         async_exchange_end(exch);
    191 
    192         if (rc != EOK)
    193                 return rc;
    194 
    195         linfo->dummy = 0;
     210        ipc_call_t dreply;
     211        sysarg_t dretval;
     212        size_t act_size;
     213        char name_buf[LOC_NAME_MAXLEN + 1];
     214
     215        async_exch_t *exch = async_exchange_begin(inetcfg_sess);
     216
     217        ipc_call_t answer;
     218        aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer);
     219        aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply);
     220        async_wait_for(dreq, &dretval);
     221
     222        async_exchange_end(exch);
     223
     224        if (dretval != EOK) {
     225                async_wait_for(req, NULL);
     226                return dretval;
     227        }
     228
     229        sysarg_t retval;
     230        async_wait_for(req, &retval);
     231
     232        if (retval != EOK)
     233                return retval;
     234
     235        act_size = IPC_GET_ARG2(dreply);
     236        assert(act_size <= LOC_NAME_MAXLEN);
     237        name_buf[act_size] = '\0';
     238
     239        linfo->name = str_dup(name_buf);
     240
    196241        return EOK;
    197242}
Note: See TracChangeset for help on using the changeset viewer.