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


Ignore:
Timestamp:
2013-12-25T13:05:25Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bc54126c
Parents:
f4a47e52 (diff), 6946f23 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes

File:
1 edited

Legend:

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

    rf4a47e52 r0773396  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444#include <str.h>
    4545#include <sys/types.h>
     46#include <types/inetcfg.h>
    4647
    4748#include "addrobj.h"
     
    151152static int inetcfg_get_link_list(sysarg_t **addrs, size_t *count)
    152153{
    153         return ENOTSUP;
     154        return inet_link_get_id_list(addrs, count);
    154155}
    155156
     
    157158{
    158159        return inet_sroute_get_id_list(sroutes, count);
     160}
     161
     162static int inetcfg_link_add(sysarg_t link_id)
     163{
     164        return inet_link_open(link_id);
    159165}
    160166
     
    170176        linfo->name = str_dup(ilink->svc_name);
    171177        linfo->def_mtu = ilink->def_mtu;
     178        if (ilink->mac_valid) {
     179                addr48(ilink->mac, linfo->mac_addr);
     180        } else {
     181                memset(linfo->mac_addr, 0, sizeof(linfo->mac_addr));
     182        }
     183
    172184        return EOK;
     185}
     186
     187static int inetcfg_link_remove(sysarg_t link_id)
     188{
     189        return ENOTSUP;
    173190}
    174191
     
    411428{
    412429        ipc_callid_t rcallid;
     430        size_t count;
    413431        size_t max_size;
    414432        size_t act_size;
     
    417435        int rc;
    418436
    419         log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_link_list_srv()");
     437        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_addr_list_srv()");
    420438
    421439        if (!async_data_read_receive(&rcallid, &max_size)) {
     
    425443        }
    426444
    427         rc = inetcfg_get_link_list(&id_buf, &act_size);
     445        rc = inetcfg_get_link_list(&id_buf, &count);
    428446        if (rc != EOK) {
    429447                async_answer_0(rcallid, rc);
     
    432450        }
    433451
     452        act_size = count * sizeof(sysarg_t);
    434453        size = min(act_size, max_size);
    435454
     
    474493}
    475494
     495static void inetcfg_link_add_srv(ipc_callid_t callid, ipc_call_t *call)
     496{
     497        sysarg_t link_id;
     498        int rc;
     499
     500        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_link_add_srv()");
     501
     502        link_id = IPC_GET_ARG1(*call);
     503
     504        rc = inetcfg_link_add(link_id);
     505        async_answer_0(callid, rc);
     506}
     507
    476508static void inetcfg_link_get_srv(ipc_callid_t callid, ipc_call_t *call)
    477509{
    478         ipc_callid_t rcallid;
    479         size_t max_size;
     510        ipc_callid_t name_callid;
     511        ipc_callid_t laddr_callid;
     512        size_t name_max_size;
     513        size_t laddr_max_size;
    480514
    481515        sysarg_t link_id;
     
    488522        linfo.name = NULL;
    489523
    490         if (!async_data_read_receive(&rcallid, &max_size)) {
    491                 async_answer_0(rcallid, EREFUSED);
     524        if (!async_data_read_receive(&name_callid, &name_max_size)) {
     525                async_answer_0(name_callid, EREFUSED);
     526                async_answer_0(callid, EREFUSED);
     527                return;
     528        }
     529
     530        if (!async_data_read_receive(&laddr_callid, &laddr_max_size)) {
     531                async_answer_0(name_callid, EREFUSED);
    492532                async_answer_0(callid, EREFUSED);
    493533                return;
     
    496536        rc = inetcfg_link_get(link_id, &linfo);
    497537        if (rc != EOK) {
    498                 async_answer_0(rcallid, rc);
    499                 async_answer_0(callid, rc);
    500                 return;
    501         }
    502 
    503         sysarg_t retval = async_data_read_finalize(rcallid, linfo.name,
    504             min(max_size, str_size(linfo.name)));
     538                async_answer_0(laddr_callid, rc);
     539                async_answer_0(name_callid, rc);
     540                async_answer_0(callid, rc);
     541                return;
     542        }
     543
     544        sysarg_t retval = async_data_read_finalize(name_callid, linfo.name,
     545            min(name_max_size, str_size(linfo.name)));
     546        if (retval != EOK) {
     547                free(linfo.name);
     548                async_answer_0(laddr_callid, retval);
     549                async_answer_0(callid, retval);
     550                return;
     551        }
     552
     553        retval = async_data_read_finalize(laddr_callid, &linfo.mac_addr,
     554            min(laddr_max_size, sizeof(linfo.mac_addr)));
     555
    505556        free(linfo.name);
    506557
    507558        async_answer_1(callid, retval, linfo.def_mtu);
     559}
     560
     561static void inetcfg_link_remove_srv(ipc_callid_t callid, ipc_call_t *call)
     562{
     563        sysarg_t link_id;
     564        int rc;
     565
     566        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_link_remove_srv()");
     567
     568        link_id = IPC_GET_ARG1(*call);
     569
     570        rc = inetcfg_link_remove(link_id);
     571        async_answer_0(callid, rc);
    508572}
    509573
     
    686750                sysarg_t method = IPC_GET_IMETHOD(call);
    687751
     752                log_msg(LOG_DEFAULT, LVL_DEBUG, "method %d", (int)method);
    688753                if (!method) {
    689754                        /* The other side has hung up */
     
    714779                        inetcfg_get_sroute_list_srv(callid, &call);
    715780                        break;
     781                case INETCFG_LINK_ADD:
     782                        inetcfg_link_add_srv(callid, &call);
     783                        break;
    716784                case INETCFG_LINK_GET:
    717785                        inetcfg_link_get_srv(callid, &call);
     786                        break;
     787                case INETCFG_LINK_REMOVE:
     788                        inetcfg_link_remove_srv(callid, &call);
    718789                        break;
    719790                case INETCFG_SROUTE_CREATE:
Note: See TracChangeset for help on using the changeset viewer.