Changeset a2e3ee6 in mainline for uspace/srv/net/inetsrv/inetcfg.c


Ignore:
Timestamp:
2013-06-20T16:45:58Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08bb73b
Parents:
19a4f73
Message:

use new network address infrastructure (towards IPv6 support)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/inetsrv/inetcfg.c

    r19a4f73 ra2e3ee6  
    5656        inet_link_t *ilink;
    5757        inet_addrobj_t *addr;
    58         iplink_addr_t iaddr;
     58        inet_addr_t iaddr;
    5959        int rc;
    6060
     
    8282        }
    8383
    84         iaddr.ipv4 = addr->naddr.ipv4;
     84        inet_naddr_addr(&addr->naddr, &iaddr);
    8585        rc = iplink_addr_add(ilink->iplink, &iaddr);
    8686        if (rc != EOK) {
     
    254254        }
    255255
    256         naddr.ipv4 = IPC_GET_ARG1(*call);
    257         naddr.bits = IPC_GET_ARG2(*call);
    258         link_id    = IPC_GET_ARG3(*call);
     256        inet_naddr_unpack(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), &naddr);
     257        link_id = IPC_GET_ARG3(*call);
    259258
    260259        addr_id = 0;
     
    279278static void inetcfg_addr_get_srv(ipc_callid_t callid, ipc_call_t *call)
    280279{
     280        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_addr_get_srv()");
     281       
     282        sysarg_t addr_id = IPC_GET_ARG1(*call);
     283       
     284        inet_addr_info_t ainfo;
     285       
     286        inet_naddr_any(&ainfo.naddr);
     287        ainfo.ilink = 0;
     288        ainfo.name = NULL;
     289       
    281290        ipc_callid_t rcallid;
    282291        size_t max_size;
    283 
    284         sysarg_t addr_id;
    285         inet_addr_info_t ainfo;
    286         int rc;
    287 
    288         addr_id = IPC_GET_ARG1(*call);
    289         log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_addr_get_srv()");
    290 
    291         ainfo.naddr.ipv4 = 0;
    292         ainfo.naddr.bits = 0;
    293         ainfo.ilink = 0;
    294         ainfo.name = NULL;
    295 
     292       
    296293        if (!async_data_read_receive(&rcallid, &max_size)) {
    297294                async_answer_0(rcallid, EREFUSED);
     
    299296                return;
    300297        }
    301 
    302         rc = inetcfg_addr_get(addr_id, &ainfo);
    303         if (rc != EOK) {
    304                 async_answer_0(callid, rc);
    305                 return;
    306         }
    307 
     298       
     299        int rc = inetcfg_addr_get(addr_id, &ainfo);
     300        if (rc != EOK) {
     301                async_answer_0(callid, rc);
     302                return;
     303        }
     304       
     305        uint32_t naddr_addr;
     306        uint8_t naddr_bits;
     307        rc = inet_naddr_pack(&ainfo.naddr, &naddr_addr, &naddr_bits);
     308        if (rc != EOK) {
     309                async_answer_0(callid, rc);
     310                return;
     311        }
     312       
    308313        sysarg_t retval = async_data_read_finalize(rcallid, ainfo.name,
    309314            min(max_size, str_size(ainfo.name)));
    310315        free(ainfo.name);
    311 
    312         async_answer_3(callid, retval, ainfo.naddr.ipv4, ainfo.naddr.bits,
    313             ainfo.ilink);
     316       
     317        async_answer_3(callid, retval, (sysarg_t) naddr_addr,
     318            (sysarg_t) naddr_bits, ainfo.ilink);
    314319}
    315320
     
    476481    ipc_call_t *call)
    477482{
     483        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_create_srv()");
     484       
    478485        char *name;
     486        int rc = async_data_write_accept((void **) &name, true, 0, LOC_NAME_MAXLEN,
     487            0, NULL);
     488        if (rc != EOK) {
     489                async_answer_0(callid, rc);
     490                return;
     491        }
     492       
    479493        inet_naddr_t dest;
    480494        inet_addr_t router;
    481         sysarg_t sroute_id;
    482         int rc;
    483 
    484         log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_create_srv()");
    485 
    486         rc = async_data_write_accept((void **) &name, true, 0, LOC_NAME_MAXLEN,
    487             0, NULL);
    488         if (rc != EOK) {
    489                 async_answer_0(callid, rc);
    490                 return;
    491         }
    492 
    493         dest.ipv4   = IPC_GET_ARG1(*call);
    494         dest.bits   = IPC_GET_ARG2(*call);
    495         router.ipv4 = IPC_GET_ARG3(*call);
    496 
    497         sroute_id = 0;
     495       
     496        inet_naddr_unpack(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), &dest);
     497        inet_addr_unpack(IPC_GET_ARG3(*call), &router);
     498       
     499        sysarg_t sroute_id = 0;
    498500        rc = inetcfg_sroute_create(name, &dest, &router, &sroute_id);
    499501        free(name);
     
    516518static void inetcfg_sroute_get_srv(ipc_callid_t callid, ipc_call_t *call)
    517519{
     520        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_get_srv()");
     521       
     522        sysarg_t sroute_id = IPC_GET_ARG1(*call);
     523       
     524        inet_sroute_info_t srinfo;
     525       
     526        inet_naddr_any(&srinfo.dest);
     527        inet_addr_any(&srinfo.router);
     528        srinfo.name = NULL;
     529       
    518530        ipc_callid_t rcallid;
    519531        size_t max_size;
    520 
    521         sysarg_t sroute_id;
    522         inet_sroute_info_t srinfo;
    523         int rc;
    524 
    525         sroute_id = IPC_GET_ARG1(*call);
    526         log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_get_srv()");
    527 
    528         srinfo.dest.ipv4 = 0;
    529         srinfo.dest.bits = 0;
    530         srinfo.router.ipv4 = 0;
    531         srinfo.name = NULL;
    532 
    533532        if (!async_data_read_receive(&rcallid, &max_size)) {
    534533                async_answer_0(rcallid, EREFUSED);
     
    536535                return;
    537536        }
    538 
    539         rc = inetcfg_sroute_get(sroute_id, &srinfo);
    540         if (rc != EOK) {
    541                 async_answer_0(callid, rc);
    542                 return;
    543         }
    544 
     537       
     538        int rc = inetcfg_sroute_get(sroute_id, &srinfo);
     539        if (rc != EOK) {
     540                async_answer_0(callid, rc);
     541                return;
     542        }
     543       
     544        uint32_t dest_addr;
     545        uint8_t dest_bits;
     546        rc = inet_naddr_pack(&srinfo.dest, &dest_addr, &dest_bits);
     547        if (rc != EOK) {
     548                async_answer_0(callid, rc);
     549                return;
     550        }
     551       
     552        uint32_t router_addr;
     553        rc = inet_addr_pack(&srinfo.router, &router_addr);
     554        if (rc != EOK) {
     555                async_answer_0(callid, rc);
     556                return;
     557        }
     558       
    545559        sysarg_t retval = async_data_read_finalize(rcallid, srinfo.name,
    546560            min(max_size, str_size(srinfo.name)));
    547561        free(srinfo.name);
    548 
    549         async_answer_3(callid, retval, srinfo.dest.ipv4, srinfo.dest.bits,
    550             srinfo.router.ipv4);
     562       
     563        async_answer_3(callid, retval, (sysarg_t) dest_addr,
     564            (sysarg_t) dest_bits, (sysarg_t) router_addr);
    551565}
    552566
Note: See TracChangeset for help on using the changeset viewer.