source: mainline/uspace/srv/net/inetsrv/inetcfg.c@ 02a09ed

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 02a09ed was 02a09ed, checked in by Martin Decky <martin@…>, 12 years ago

add basic infrastructure for IPv6 (inactive)
make inet_addr_t a universal address type

  • Property mode set to 100644
File size: 16.2 KB
RevLine 
[0e25780]1/*
2 * Copyright (c) 2012 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup inet
30 * @{
31 */
32/**
33 * @file
34 * @brief
35 */
36
37#include <async.h>
38#include <errno.h>
39#include <macros.h>
40#include <io/log.h>
41#include <ipc/inet.h>
42#include <loc.h>
43#include <stdlib.h>
[0e94b979]44#include <str.h>
[0e25780]45#include <sys/types.h>
46
[45aa22c]47#include "addrobj.h"
[b4ec1ea]48#include "inetsrv.h"
[45aa22c]49#include "inet_link.h"
[0e25780]50#include "inetcfg.h"
[8bf672d]51#include "sroute.h"
[0e25780]52
[291c792]53static int inetcfg_addr_create_static(char *name, inet_naddr_t *naddr,
54 sysarg_t link_id, sysarg_t *addr_id)
[0e25780]55{
[45aa22c]56 inet_link_t *ilink;
57 inet_addrobj_t *addr;
[a2e3ee6]58 inet_addr_t iaddr;
[45aa22c]59 int rc;
60
61 ilink = inet_link_get_by_id(link_id);
62 if (ilink == NULL) {
[a1a101d]63 log_msg(LOG_DEFAULT, LVL_DEBUG, "Link %lu not found.",
[45aa22c]64 (unsigned long) link_id);
65 return ENOENT;
66 }
67
68 addr = inet_addrobj_new();
[8bf672d]69 if (addr == NULL) {
70 *addr_id = 0;
71 return ENOMEM;
72 }
73
[45aa22c]74 addr->naddr = *naddr;
75 addr->ilink = ilink;
[291c792]76 addr->name = str_dup(name);
[bf9e6fc]77 rc = inet_addrobj_add(addr);
78 if (rc != EOK) {
[a1a101d]79 log_msg(LOG_DEFAULT, LVL_DEBUG, "Duplicate address name '%s'.", addr->name);
[bf9e6fc]80 inet_addrobj_delete(addr);
81 return rc;
82 }
[45aa22c]83
[a2e3ee6]84 inet_naddr_addr(&addr->naddr, &iaddr);
[45aa22c]85 rc = iplink_addr_add(ilink->iplink, &iaddr);
86 if (rc != EOK) {
[a1a101d]87 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed setting IP address on internet link.");
[45aa22c]88 inet_addrobj_remove(addr);
89 inet_addrobj_delete(addr);
90 return rc;
91 }
92
93 return EOK;
[0e25780]94}
95
96static int inetcfg_addr_delete(sysarg_t addr_id)
97{
[fa101c4]98 inet_addrobj_t *addr;
99
100 addr = inet_addrobj_get_by_id(addr_id);
101 if (addr == NULL)
102 return ENOENT;
103
104 inet_addrobj_remove(addr);
105 inet_addrobj_delete(addr);
106
107 return EOK;
[0e25780]108}
109
110static int inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo)
111{
[0e94b979]112 inet_addrobj_t *addr;
113
114 addr = inet_addrobj_get_by_id(addr_id);
115 if (addr == NULL)
116 return ENOENT;
117
118 ainfo->naddr = addr->naddr;
119 ainfo->ilink = addr->ilink->svc_id;
120 ainfo->name = str_dup(addr->name);
121
122 return EOK;
[0e25780]123}
124
[fa101c4]125static int inetcfg_addr_get_id(char *name, sysarg_t link_id, sysarg_t *addr_id)
126{
127 inet_link_t *ilink;
128 inet_addrobj_t *addr;
129
130 ilink = inet_link_get_by_id(link_id);
131 if (ilink == NULL) {
[a1a101d]132 log_msg(LOG_DEFAULT, LVL_DEBUG, "Link %zu not found.", (size_t) link_id);
[fa101c4]133 return ENOENT;
134 }
135
136 addr = inet_addrobj_find_by_name(name, ilink);
137 if (addr == NULL) {
[a1a101d]138 log_msg(LOG_DEFAULT, LVL_DEBUG, "Address '%s' not found.", name);
[fa101c4]139 return ENOENT;
140 }
141
142 *addr_id = addr->id;
143 return EOK;
144}
145
[0e25780]146static int inetcfg_get_addr_list(sysarg_t **addrs, size_t *count)
147{
[0e94b979]148 return inet_addrobj_get_id_list(addrs, count);
[0e25780]149}
150
151static int inetcfg_get_link_list(sysarg_t **addrs, size_t *count)
152{
153 return ENOTSUP;
154}
155
[8bf672d]156static int inetcfg_get_sroute_list(sysarg_t **sroutes, size_t *count)
157{
158 return inet_sroute_get_id_list(sroutes, count);
159}
160
[0e94b979]161static int inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo)
[0e25780]162{
[0e94b979]163 inet_link_t *ilink;
164
165 ilink = inet_link_get_by_id(link_id);
166 if (ilink == NULL) {
167 return ENOENT;
168 }
169
170 linfo->name = str_dup(ilink->svc_name);
[347768d]171 linfo->def_mtu = ilink->def_mtu;
[0e94b979]172 return EOK;
[0e25780]173}
174
[8bf672d]175static int inetcfg_sroute_create(char *name, inet_naddr_t *dest,
176 inet_addr_t *router, sysarg_t *sroute_id)
177{
178 inet_sroute_t *sroute;
179
180 sroute = inet_sroute_new();
181 if (sroute == NULL) {
182 *sroute_id = 0;
183 return ENOMEM;
184 }
185
186 sroute->dest = *dest;
187 sroute->router = *router;
188 sroute->name = str_dup(name);
189 inet_sroute_add(sroute);
190
191 *sroute_id = sroute->id;
192 return EOK;
193}
194
195static int inetcfg_sroute_delete(sysarg_t sroute_id)
196{
197 inet_sroute_t *sroute;
198
199 sroute = inet_sroute_get_by_id(sroute_id);
200 if (sroute == NULL)
201 return ENOENT;
202
203 inet_sroute_remove(sroute);
204 inet_sroute_delete(sroute);
205
206 return EOK;
207}
208
209static int inetcfg_sroute_get(sysarg_t sroute_id, inet_sroute_info_t *srinfo)
210{
211 inet_sroute_t *sroute;
212
213 sroute = inet_sroute_get_by_id(sroute_id);
214 if (sroute == NULL)
215 return ENOENT;
216
217 srinfo->dest = sroute->dest;
218 srinfo->router = sroute->router;
219 srinfo->name = str_dup(sroute->name);
220
221 return EOK;
222}
223
224static int inetcfg_sroute_get_id(char *name, sysarg_t *sroute_id)
225{
226 inet_sroute_t *sroute;
227
228 sroute = inet_sroute_find_by_name(name);
229 if (sroute == NULL) {
[a1a101d]230 log_msg(LOG_DEFAULT, LVL_DEBUG, "Static route '%s' not found.", name);
[8bf672d]231 return ENOENT;
232 }
233
234 *sroute_id = sroute->id;
235 return EOK;
236}
237
[02a09ed]238static void inetcfg_addr_create_static_srv(ipc_callid_t iid,
239 ipc_call_t *icall)
[0e25780]240{
[a1a101d]241 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_addr_create_static_srv()");
[02a09ed]242
243 sysarg_t link_id = IPC_GET_ARG1(*icall);
244
245 ipc_callid_t callid;
246 size_t size;
247 if (!async_data_write_receive(&callid, &size)) {
248 async_answer_0(callid, EINVAL);
249 async_answer_0(iid, EINVAL);
250 return;
251 }
252
253 if (size != sizeof(inet_naddr_t)) {
254 async_answer_0(callid, EINVAL);
255 async_answer_0(iid, EINVAL);
256 return;
257 }
258
259 inet_naddr_t naddr;
260 int rc = async_data_write_finalize(callid, &naddr, size);
261 if (rc != EOK) {
262 async_answer_0(callid, rc);
263 async_answer_0(iid, rc);
264 return;
265 }
266
267 char *name;
[291c792]268 rc = async_data_write_accept((void **) &name, true, 0, LOC_NAME_MAXLEN,
269 0, NULL);
270 if (rc != EOK) {
[02a09ed]271 async_answer_0(iid, rc);
[291c792]272 return;
273 }
[02a09ed]274
275 sysarg_t addr_id = 0;
[291c792]276 rc = inetcfg_addr_create_static(name, &naddr, link_id, &addr_id);
277 free(name);
[02a09ed]278 async_answer_1(iid, rc, addr_id);
[0e25780]279}
280
281static void inetcfg_addr_delete_srv(ipc_callid_t callid, ipc_call_t *call)
282{
283 sysarg_t addr_id;
284 int rc;
285
[a1a101d]286 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_addr_delete_srv()");
[0e25780]287
288 addr_id = IPC_GET_ARG1(*call);
289
290 rc = inetcfg_addr_delete(addr_id);
291 async_answer_0(callid, rc);
292}
293
[02a09ed]294static void inetcfg_addr_get_srv(ipc_callid_t iid, ipc_call_t *icall)
[0e25780]295{
[a1a101d]296 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_addr_get_srv()");
[a2e3ee6]297
[02a09ed]298 sysarg_t addr_id = IPC_GET_ARG1(*icall);
[a2e3ee6]299
300 inet_addr_info_t ainfo;
301
302 inet_naddr_any(&ainfo.naddr);
[0e94b979]303 ainfo.ilink = 0;
304 ainfo.name = NULL;
[a2e3ee6]305
[02a09ed]306 int rc = inetcfg_addr_get(addr_id, &ainfo);
307 if (rc != EOK) {
308 async_answer_0(iid, rc);
309 return;
310 }
[a2e3ee6]311
[02a09ed]312 ipc_callid_t callid;
313 size_t size;
314 if (!async_data_read_receive(&callid, &size)) {
[0e94b979]315 async_answer_0(callid, EREFUSED);
[02a09ed]316 async_answer_0(iid, EREFUSED);
[0e94b979]317 return;
318 }
[a2e3ee6]319
[02a09ed]320 if (size != sizeof(inet_naddr_t)) {
321 async_answer_0(callid, EINVAL);
322 async_answer_0(iid, EINVAL);
[0e94b979]323 return;
324 }
[a2e3ee6]325
[02a09ed]326 rc = async_data_read_finalize(callid, &ainfo.naddr, size);
[a2e3ee6]327 if (rc != EOK) {
328 async_answer_0(callid, rc);
[02a09ed]329 async_answer_0(iid, rc);
330 return;
331 }
332
333 if (!async_data_read_receive(&callid, &size)) {
334 async_answer_0(callid, EREFUSED);
335 async_answer_0(iid, EREFUSED);
[a2e3ee6]336 return;
337 }
338
[02a09ed]339 rc = async_data_read_finalize(callid, ainfo.name,
340 min(size, str_size(ainfo.name)));
[0e94b979]341 free(ainfo.name);
[a2e3ee6]342
[02a09ed]343 if (rc != EOK) {
344 async_answer_0(callid, rc);
345 async_answer_0(iid, rc);
346 return;
347 }
348
349 async_answer_1(iid, (sysarg_t) rc, ainfo.ilink);
[0e25780]350}
351
[fa101c4]352static void inetcfg_addr_get_id_srv(ipc_callid_t callid, ipc_call_t *call)
353{
354 char *name;
355 sysarg_t link_id;
356 sysarg_t addr_id;
357 int rc;
358
[a1a101d]359 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_addr_get_id_srv()");
[fa101c4]360
361 link_id = IPC_GET_ARG1(*call);
362
363 rc = async_data_write_accept((void **) &name, true, 0, LOC_NAME_MAXLEN,
364 0, NULL);
365 if (rc != EOK) {
366 async_answer_0(callid, rc);
367 return;
368 }
369
370 addr_id = 0;
371 rc = inetcfg_addr_get_id(name, link_id, &addr_id);
372 free(name);
373 async_answer_1(callid, rc, addr_id);
374}
375
[0e25780]376static void inetcfg_get_addr_list_srv(ipc_callid_t callid, ipc_call_t *call)
377{
378 ipc_callid_t rcallid;
[0e94b979]379 size_t count;
[0e25780]380 size_t max_size;
381 size_t act_size;
382 size_t size;
383 sysarg_t *id_buf;
384 int rc;
385
[a1a101d]386 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_addr_list_srv()");
[0e25780]387
388 if (!async_data_read_receive(&rcallid, &max_size)) {
389 async_answer_0(rcallid, EREFUSED);
390 async_answer_0(callid, EREFUSED);
391 return;
392 }
393
[0e94b979]394 rc = inetcfg_get_addr_list(&id_buf, &count);
[0e25780]395 if (rc != EOK) {
396 async_answer_0(rcallid, rc);
397 async_answer_0(callid, rc);
398 return;
399 }
400
[0e94b979]401 act_size = count * sizeof(sysarg_t);
[0e25780]402 size = min(act_size, max_size);
403
404 sysarg_t retval = async_data_read_finalize(rcallid, id_buf, size);
405 free(id_buf);
406
407 async_answer_1(callid, retval, act_size);
408}
409
[8bf672d]410static void inetcfg_get_link_list_srv(ipc_callid_t callid, ipc_call_t *call)
411{
412 ipc_callid_t rcallid;
413 size_t max_size;
414 size_t act_size;
415 size_t size;
416 sysarg_t *id_buf;
417 int rc;
418
[a1a101d]419 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_link_list_srv()");
[8bf672d]420
421 if (!async_data_read_receive(&rcallid, &max_size)) {
422 async_answer_0(rcallid, EREFUSED);
423 async_answer_0(callid, EREFUSED);
424 return;
425 }
426
427 rc = inetcfg_get_link_list(&id_buf, &act_size);
428 if (rc != EOK) {
429 async_answer_0(rcallid, rc);
430 async_answer_0(callid, rc);
431 return;
432 }
433
434 size = min(act_size, max_size);
435
436 sysarg_t retval = async_data_read_finalize(rcallid, id_buf, size);
437 free(id_buf);
438
439 async_answer_1(callid, retval, act_size);
440}
441
442static void inetcfg_get_sroute_list_srv(ipc_callid_t callid, ipc_call_t *call)
443{
444 ipc_callid_t rcallid;
445 size_t count;
446 size_t max_size;
447 size_t act_size;
448 size_t size;
449 sysarg_t *id_buf;
450 int rc;
451
[a1a101d]452 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_sroute_list_srv()");
[8bf672d]453
454 if (!async_data_read_receive(&rcallid, &max_size)) {
455 async_answer_0(rcallid, EREFUSED);
456 async_answer_0(callid, EREFUSED);
457 return;
458 }
459
460 rc = inetcfg_get_sroute_list(&id_buf, &count);
461 if (rc != EOK) {
462 async_answer_0(rcallid, rc);
463 async_answer_0(callid, rc);
464 return;
465 }
466
467 act_size = count * sizeof(sysarg_t);
468 size = min(act_size, max_size);
469
470 sysarg_t retval = async_data_read_finalize(rcallid, id_buf, size);
471 free(id_buf);
472
473 async_answer_1(callid, retval, act_size);
474}
475
[0e25780]476static void inetcfg_link_get_srv(ipc_callid_t callid, ipc_call_t *call)
477{
[0e94b979]478 ipc_callid_t rcallid;
479 size_t max_size;
480
[0e25780]481 sysarg_t link_id;
482 inet_link_info_t linfo;
483 int rc;
484
485 link_id = IPC_GET_ARG1(*call);
[a1a101d]486 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_link_get_srv()");
[0e25780]487
[0e94b979]488 linfo.name = NULL;
489
490 if (!async_data_read_receive(&rcallid, &max_size)) {
491 async_answer_0(rcallid, EREFUSED);
492 async_answer_0(callid, EREFUSED);
493 return;
494 }
495
[0e25780]496 rc = inetcfg_link_get(link_id, &linfo);
[0e94b979]497 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)));
505 free(linfo.name);
506
[347768d]507 async_answer_1(callid, retval, linfo.def_mtu);
[0e25780]508}
509
[02a09ed]510static void inetcfg_sroute_create_srv(ipc_callid_t iid,
511 ipc_call_t *icall)
[8bf672d]512{
[a1a101d]513 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_create_srv()");
[02a09ed]514
515 ipc_callid_t callid;
516 size_t size;
517 if (!async_data_write_receive(&callid, &size)) {
518 async_answer_0(callid, EINVAL);
519 async_answer_0(iid, EINVAL);
520 return;
521 }
[a2e3ee6]522
[02a09ed]523 if (size != sizeof(inet_naddr_t)) {
524 async_answer_0(callid, EINVAL);
525 async_answer_0(iid, EINVAL);
526 return;
527 }
528
529 inet_naddr_t dest;
530 int rc = async_data_write_finalize(callid, &dest, size);
[8bf672d]531 if (rc != EOK) {
532 async_answer_0(callid, rc);
[02a09ed]533 async_answer_0(iid, rc);
534 return;
535 }
536
537 if (!async_data_write_receive(&callid, &size)) {
538 async_answer_0(callid, EINVAL);
539 async_answer_0(iid, EINVAL);
540 return;
541 }
542
543 if (size != sizeof(inet_addr_t)) {
544 async_answer_0(callid, EINVAL);
545 async_answer_0(iid, EINVAL);
[8bf672d]546 return;
547 }
[a2e3ee6]548
549 inet_addr_t router;
[02a09ed]550 rc = async_data_write_finalize(callid, &router, size);
551 if (rc != EOK) {
552 async_answer_0(callid, rc);
553 async_answer_0(iid, rc);
554 return;
555 }
[a2e3ee6]556
[02a09ed]557 char *name;
558 rc = async_data_write_accept((void **) &name, true, 0, LOC_NAME_MAXLEN,
559 0, NULL);
560 if (rc != EOK) {
561 async_answer_0(iid, rc);
562 return;
563 }
[a2e3ee6]564
565 sysarg_t sroute_id = 0;
[8bf672d]566 rc = inetcfg_sroute_create(name, &dest, &router, &sroute_id);
567 free(name);
[02a09ed]568 async_answer_1(iid, rc, sroute_id);
[8bf672d]569}
570
571static void inetcfg_sroute_delete_srv(ipc_callid_t callid, ipc_call_t *call)
572{
573 sysarg_t sroute_id;
574 int rc;
575
[a1a101d]576 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_delete_srv()");
[8bf672d]577
578 sroute_id = IPC_GET_ARG1(*call);
579
580 rc = inetcfg_sroute_delete(sroute_id);
581 async_answer_0(callid, rc);
582}
583
[02a09ed]584static void inetcfg_sroute_get_srv(ipc_callid_t iid, ipc_call_t *icall)
[0e25780]585{
[a1a101d]586 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_get_srv()");
[a2e3ee6]587
[02a09ed]588 sysarg_t sroute_id = IPC_GET_ARG1(*icall);
[a2e3ee6]589
590 inet_sroute_info_t srinfo;
591
592 inet_naddr_any(&srinfo.dest);
593 inet_addr_any(&srinfo.router);
[8bf672d]594 srinfo.name = NULL;
[a2e3ee6]595
[02a09ed]596 int rc = inetcfg_sroute_get(sroute_id, &srinfo);
597 if (rc != EOK) {
598 async_answer_0(iid, rc);
599 return;
600 }
601
602 ipc_callid_t callid;
603 size_t size;
604 if (!async_data_read_receive(&callid, &size)) {
[0e25780]605 async_answer_0(callid, EREFUSED);
[02a09ed]606 async_answer_0(iid, EREFUSED);
[0e25780]607 return;
608 }
[a2e3ee6]609
[02a09ed]610 if (size != sizeof(inet_naddr_t)) {
611 async_answer_0(callid, EINVAL);
612 async_answer_0(iid, EINVAL);
[0e25780]613 return;
614 }
[a2e3ee6]615
[02a09ed]616 rc = async_data_read_finalize(callid, &srinfo.dest, size);
[a2e3ee6]617 if (rc != EOK) {
618 async_answer_0(callid, rc);
[02a09ed]619 async_answer_0(iid, rc);
620 return;
621 }
622
623 if (!async_data_read_receive(&callid, &size)) {
624 async_answer_0(callid, EREFUSED);
625 async_answer_0(iid, EREFUSED);
626 return;
627 }
628
629 if (size != sizeof(inet_addr_t)) {
630 async_answer_0(callid, EINVAL);
631 async_answer_0(iid, EINVAL);
[a2e3ee6]632 return;
633 }
634
[02a09ed]635 rc = async_data_read_finalize(callid, &srinfo.router, size);
[a2e3ee6]636 if (rc != EOK) {
637 async_answer_0(callid, rc);
[02a09ed]638 async_answer_0(iid, rc);
639 return;
640 }
641
642 if (!async_data_read_receive(&callid, &size)) {
643 async_answer_0(callid, EREFUSED);
644 async_answer_0(iid, EREFUSED);
[a2e3ee6]645 return;
646 }
647
[02a09ed]648 rc = async_data_read_finalize(callid, srinfo.name,
649 min(size, str_size(srinfo.name)));
[8bf672d]650 free(srinfo.name);
[a2e3ee6]651
[02a09ed]652 async_answer_0(iid, (sysarg_t) rc);
[8bf672d]653}
[0e25780]654
[8bf672d]655static void inetcfg_sroute_get_id_srv(ipc_callid_t callid, ipc_call_t *call)
656{
657 char *name;
658 sysarg_t sroute_id;
659 int rc;
660
[a1a101d]661 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_sroute_get_id_srv()");
[8bf672d]662
663 rc = async_data_write_accept((void **) &name, true, 0, LOC_NAME_MAXLEN,
664 0, NULL);
665 if (rc != EOK) {
666 async_answer_0(callid, rc);
667 return;
668 }
669
670 sroute_id = 0;
671 rc = inetcfg_sroute_get_id(name, &sroute_id);
672 free(name);
673 async_answer_1(callid, rc, sroute_id);
[0e25780]674}
675
676void inet_cfg_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
677{
[a1a101d]678 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_cfg_conn()");
[0e25780]679
680 /* Accept the connection */
681 async_answer_0(iid, EOK);
682
683 while (true) {
684 ipc_call_t call;
685 ipc_callid_t callid = async_get_call(&call);
686 sysarg_t method = IPC_GET_IMETHOD(call);
687
688 if (!method) {
689 /* The other side has hung up */
690 async_answer_0(callid, EOK);
691 return;
692 }
693
694 switch (method) {
695 case INETCFG_ADDR_CREATE_STATIC:
696 inetcfg_addr_create_static_srv(callid, &call);
697 break;
698 case INETCFG_ADDR_DELETE:
699 inetcfg_addr_delete_srv(callid, &call);
700 break;
701 case INETCFG_ADDR_GET:
702 inetcfg_addr_get_srv(callid, &call);
703 break;
[fa101c4]704 case INETCFG_ADDR_GET_ID:
705 inetcfg_addr_get_id_srv(callid, &call);
706 break;
[0e25780]707 case INETCFG_GET_ADDR_LIST:
708 inetcfg_get_addr_list_srv(callid, &call);
709 break;
710 case INETCFG_GET_LINK_LIST:
711 inetcfg_get_link_list_srv(callid, &call);
712 break;
[8bf672d]713 case INETCFG_GET_SROUTE_LIST:
714 inetcfg_get_sroute_list_srv(callid, &call);
715 break;
[0e25780]716 case INETCFG_LINK_GET:
717 inetcfg_link_get_srv(callid, &call);
718 break;
[8bf672d]719 case INETCFG_SROUTE_CREATE:
720 inetcfg_sroute_create_srv(callid, &call);
721 break;
722 case INETCFG_SROUTE_DELETE:
723 inetcfg_sroute_delete_srv(callid, &call);
724 break;
725 case INETCFG_SROUTE_GET:
726 inetcfg_sroute_get_srv(callid, &call);
727 break;
728 case INETCFG_SROUTE_GET_ID:
729 inetcfg_sroute_get_id_srv(callid, &call);
730 break;
[0e25780]731 default:
732 async_answer_0(callid, EINVAL);
733 }
734 }
735}
736
737/** @}
738 */
Note: See TracBrowser for help on using the repository browser.