[5559712] | 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 <async.h>
|
---|
| 30 | #include <ipc/sysman.h>
|
---|
| 31 | #include <sysman/broker.h>
|
---|
| 32 | #include <sysman/sysman.h>
|
---|
| 33 | #include <str.h>
|
---|
| 34 |
|
---|
| 35 | int sysman_broker_register(void)
|
---|
| 36 | {
|
---|
| 37 | async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_BROKER);
|
---|
| 38 |
|
---|
| 39 | int rc = async_req_0_0(exch, SYSMAN_BROKER_REGISTER);
|
---|
| 40 | sysman_exchange_end(exch);
|
---|
| 41 |
|
---|
| 42 | return rc;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | void sysman_ipc_forwarded(task_id_t caller, const char *dst_unit_name)
|
---|
| 46 | {
|
---|
| 47 | async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_BROKER);
|
---|
| 48 |
|
---|
| 49 | aid_t req = async_send_1(exch, SYSMAN_BROKER_IPC_FWD, caller, NULL);
|
---|
| 50 | (void)async_data_write_start(exch, dst_unit_name, str_size(dst_unit_name));
|
---|
| 51 | sysman_exchange_end(exch);
|
---|
| 52 |
|
---|
| 53 | async_forget(req);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | void sysman_main_exposee_added(const char *unit_name, task_id_t caller)
|
---|
| 57 | {
|
---|
| 58 | async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_BROKER);
|
---|
| 59 |
|
---|
| 60 | aid_t req = async_send_1(exch, SYSMAN_BROKER_MAIN_EXP_ADDED, caller, NULL);
|
---|
| 61 | (void)async_data_write_start(exch, unit_name, str_size(unit_name));
|
---|
| 62 | sysman_exchange_end(exch);
|
---|
| 63 |
|
---|
| 64 | async_forget(req);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | void sysman_exposee_added(const char *exposee)
|
---|
| 68 | {
|
---|
| 69 | async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_BROKER);
|
---|
| 70 |
|
---|
| 71 | aid_t req = async_send_0(exch, SYSMAN_BROKER_EXP_ADDED, NULL);
|
---|
| 72 | (void)async_data_write_start(exch, exposee, str_size(exposee));
|
---|
| 73 | sysman_exchange_end(exch);
|
---|
| 74 |
|
---|
| 75 | async_forget(req);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | void sysman_exposee_removed(const char *exposee)
|
---|
| 79 | {
|
---|
| 80 | async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_BROKER);
|
---|
| 81 |
|
---|
| 82 | aid_t req = async_send_0(exch, SYSMAN_BROKER_EXP_REMOVED, NULL);
|
---|
| 83 | (void)async_data_write_start(exch, exposee, str_size(exposee));
|
---|
| 84 | sysman_exchange_end(exch);
|
---|
| 85 |
|
---|
| 86 | async_forget(req);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 |
|
---|