source: mainline/uspace/srv/ns/ns.c@ e0e7eba

Last change on this file since e0e7eba was e0e7eba, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago

taskman: Remove remainings from NS
Conflicts:

uspace/lib/c/include/ipc/ns.h
uspace/srv/ns/ns.c
uspace/srv/ns/task.c
uspace/srv/ns/task.h

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[babe786]1/*
[df4ed85]2 * Copyright (c) 2006 Ondrej Palkovsky
[babe786]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
[231a60a]29/** @addtogroup ns
[ce5bcb4]30 * @{
[1fcfc94]31 */
[ce5bcb4]32
[babe786]33/**
[1fcfc94]34 * @file ns.c
35 * @brief Naming service for HelenOS IPC.
[babe786]36 */
37
[7b616e2]38#include <abi/ipc/methods.h>
39#include <async.h>
[40313e4]40#include <ipc/ns.h>
[6a8ce16]41#include <ipc/services.h>
[2133e02]42#include <abi/ipc/interfaces.h>
[40313e4]43#include <stdio.h>
[69cdeec]44#include <errno.h>
[40313e4]45#include "ns.h"
46#include "service.h"
[bfd1546]47
[984a9ba]48static void ns_connection(ipc_call_t *icall, void *arg)
[69cdeec]49{
[7b616e2]50 ipc_call_t call;
51 iface_t iface;
52 service_t service;
53
[fafb8e5]54 iface = ipc_get_arg1(icall);
55 service = ipc_get_arg2(icall);
[7b616e2]56 if (service != 0) {
57 /*
58 * Client requests to be connected to a service.
59 */
[0a8f070]60 ns_service_forward(service, iface, icall);
[7b616e2]61 return;
62 }
[a35b458]63
[beb83c1]64 async_accept_0(icall);
[7b616e2]65
[1fcfc94]66 while (true) {
[9b1baac]67 ns_pending_conn_process();
[a35b458]68
[984a9ba]69 async_get_call(&call);
[fafb8e5]70 if (!ipc_get_imethod(&call))
[7b616e2]71 break;
[a35b458]72
[40313e4]73 task_id_t id;
[b7fd2a0]74 errno_t retval;
[a35b458]75
[6a8ce16]76 service_t service;
[a35b458]77
[fafb8e5]78 switch (ipc_get_imethod(&call)) {
[7b616e2]79 case NS_REGISTER:
[fafb8e5]80 service = ipc_get_arg1(&call);
81 iface = ipc_get_arg2(&call);
[a35b458]82
[babe786]83 /*
[043dcc27]84 * Server requests service registration.
[babe786]85 */
[0a8f070]86 retval = ns_service_register(service, iface);
[a35b458]87
[9b1baac]88 break;
89 case NS_REGISTER_BROKER:
[fafb8e5]90 service = ipc_get_arg1(&call);
[9b1baac]91 retval = ns_service_register_broker(service);
[11eae82]92 break;
[40313e4]93 case NS_PING:
94 retval = EOK;
95 break;
[69cdeec]96 default:
[9b1baac]97 printf("%s: Method not supported (%" PRIun ")\n",
[fafb8e5]98 NAME, ipc_get_imethod(&call));
[7b616e2]99 retval = ENOTSUP;
[69cdeec]100 break;
101 }
[a35b458]102
[984a9ba]103 async_answer_0(&call, retval);
[69cdeec]104 }
[7b616e2]105
106 (void) ns_task_disconnect(&call);
[889cdb1]107 async_answer_0(&call, EOK);
[7b616e2]108}
109
110int main(int argc, char **argv)
111{
112 printf("%s: HelenOS IPC Naming Service\n", NAME);
[a35b458]113
[9b1baac]114 errno_t rc = ns_service_init();
[7b616e2]115 if (rc != EOK)
116 return rc;
[a35b458]117
[7b616e2]118 async_set_fallback_port_handler(ns_connection, NULL);
[a35b458]119
[7b616e2]120 printf("%s: Accepting connections\n", NAME);
121 async_manager();
[a35b458]122
[e623197]123 /* Not reached */
124 return 0;
[69cdeec]125}
[babe786]126
[1fcfc94]127/**
[ce5bcb4]128 * @}
129 */
Note: See TracBrowser for help on using the repository browser.