| 1 | /*
|
|---|
| 2 | * Copyright (c) 2015 Michal Koutny
|
|---|
| 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 | #include <errno.h>
|
|---|
| 30 | #include <ipc/sysman.h>
|
|---|
| 31 |
|
|---|
| 32 | #include "connection_broker.h"
|
|---|
| 33 | #include "log.h"
|
|---|
| 34 |
|
|---|
| 35 | static void sysman_broker_register(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 36 | {
|
|---|
| 37 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
|---|
| 38 | async_answer_0(iid, EOK);
|
|---|
| 39 | /* TODO implement
|
|---|
| 40 | * What exactly? Similar behavior that has locsrv with servers,
|
|---|
| 41 | * so that subsequent calls can be assigned to broker. Still that
|
|---|
| 42 | * makes sense only when brokers will somehow scope unit/exposee
|
|---|
| 43 | * names. Why I wanted this registration?
|
|---|
| 44 | */
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | static void sysman_ipc_forwarded(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 48 | {
|
|---|
| 49 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
|---|
| 50 | async_answer_0(iid, ENOTSUP);
|
|---|
| 51 | // TODO implement
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | static void sysman_main_exposee_added(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 55 | {
|
|---|
| 56 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
|---|
| 57 | async_answer_0(iid, ENOTSUP);
|
|---|
| 58 | // TODO implement
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | static void sysman_exposee_added(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 62 | {
|
|---|
| 63 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
|---|
| 64 | async_answer_0(iid, ENOTSUP);
|
|---|
| 65 | // TODO implement
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | static void sysman_exposee_removed(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 69 | {
|
|---|
| 70 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
|---|
| 71 | async_answer_0(iid, ENOTSUP);
|
|---|
| 72 | // TODO implement
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | void sysman_connection_broker(ipc_callid_t iid, ipc_call_t *icall)
|
|---|
| 76 | {
|
|---|
| 77 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
|---|
| 78 | /* First, accept connection */
|
|---|
| 79 | async_answer_0(iid, EOK);
|
|---|
| 80 |
|
|---|
| 81 | while (true) {
|
|---|
| 82 | ipc_call_t call;
|
|---|
| 83 | ipc_callid_t callid = async_get_call(&call);
|
|---|
| 84 |
|
|---|
| 85 | if (!IPC_GET_IMETHOD(call)) {
|
|---|
| 86 | /* Client disconnected */
|
|---|
| 87 | break;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | switch (IPC_GET_IMETHOD(call)) {
|
|---|
| 91 | case SYSMAN_BROKER_REGISTER:
|
|---|
| 92 | sysman_broker_register(callid, &call);
|
|---|
| 93 | break;
|
|---|
| 94 | case SYSMAN_BROKER_IPC_FWD:
|
|---|
| 95 | sysman_ipc_forwarded(callid, &call);
|
|---|
| 96 | break;
|
|---|
| 97 | case SYSMAN_BROKER_MAIN_EXP_ADDED:
|
|---|
| 98 | sysman_main_exposee_added(callid, &call);
|
|---|
| 99 | break;
|
|---|
| 100 | case SYSMAN_BROKER_EXP_ADDED:
|
|---|
| 101 | sysman_exposee_added(callid, &call);
|
|---|
| 102 | break;
|
|---|
| 103 | case SYSMAN_BROKER_EXP_REMOVED:
|
|---|
| 104 | sysman_exposee_removed(callid, &call);
|
|---|
| 105 | break;
|
|---|
| 106 | default:
|
|---|
| 107 | async_answer_0(callid, ENOENT);
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|