source: mainline/uspace/srv/net/nconfsrv/nconfsrv.c@ 3bbd921

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

gradually introduce async ports, initial phase

The initial phase is to reimplement the traditional async client connections as an untyped fallback port. This creates the possibility to introduce ports typed by interface type gradually in later changesets.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2013 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 nconfsrv
30 * @{
31 */
32/**
33 * @file
34 * @brief Network configuration Service
35 */
36
37#include <adt/list.h>
38#include <async.h>
39#include <errno.h>
40#include <fibril_synch.h>
41#include <inet/dhcp.h>
42#include <inet/inetcfg.h>
43#include <io/log.h>
44#include <ipc/inet.h>
45#include <ipc/services.h>
46#include <loc.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <sys/types.h>
50#include <task.h>
51#include "iplink.h"
52#include "nconfsrv.h"
53
54#define NAME "nconfsrv"
55
56static void ncs_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
57
58static int ncs_init(void)
59{
60 service_id_t sid;
61 int rc;
62
63 log_msg(LOG_DEFAULT, LVL_DEBUG, "ncs_init()");
64
65 rc = inetcfg_init();
66 if (rc != EOK) {
67 log_msg(LOG_DEFAULT, LVL_ERROR, "Error contacting inet "
68 "configuration service.");
69 return EIO;
70 }
71
72 rc = dhcp_init();
73 if (rc != EOK) {
74 log_msg(LOG_DEFAULT, LVL_ERROR, "Error contacting dhcp "
75 "configuration service.");
76 return EIO;
77 }
78
79 async_set_fallback_port_handler(ncs_client_conn, NULL);
80
81 rc = loc_server_register(NAME);
82 if (rc != EOK) {
83 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server (%d).", rc);
84 return EEXIST;
85 }
86
87 rc = loc_service_register(SERVICE_NAME_NETCONF, &sid);
88 if (rc != EOK) {
89 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc);
90 return EEXIST;
91 }
92
93 rc = ncs_link_discovery_start();
94 if (rc != EOK)
95 return EEXIST;
96
97 return EOK;
98}
99
100static void ncs_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
101{
102 async_answer_0(iid, ENOTSUP);
103}
104
105int main(int argc, char *argv[])
106{
107 int rc;
108
109 printf(NAME ": HelenOS Network configuration service\n");
110
111 if (log_init(NAME) != EOK) {
112 printf(NAME ": Failed to initialize logging.\n");
113 return 1;
114 }
115
116 rc = ncs_init();
117 if (rc != EOK)
118 return 1;
119
120 printf(NAME ": Accepting connections.\n");
121 task_retval(0);
122 async_manager();
123
124 /* Not reached */
125 return 0;
126}
127
128/** @}
129 */
Note: See TracBrowser for help on using the repository browser.