signalling: removed the old-style signalling plugin.
authorIsmo Puustinen <ismo.puustinen@intel.com>
Fri, 21 Dec 2012 13:12:37 +0000 (15:12 +0200)
committerIsmo Puustinen <ismo.puustinen@intel.com>
Fri, 21 Dec 2012 13:20:32 +0000 (15:20 +0200)
19 files changed:
configure.ac
src/Makefile.am
src/plugins/plugin-signalling.c [deleted file]
src/plugins/plugin-test.c
src/plugins/signalling/client.c [deleted file]
src/plugins/signalling/client.h [deleted file]
src/plugins/signalling/endpoint.c [deleted file]
src/plugins/signalling/endpoint.h [deleted file]
src/plugins/signalling/info.c [deleted file]
src/plugins/signalling/info.h [deleted file]
src/plugins/signalling/plugin.h [deleted file]
src/plugins/signalling/signalling-protocol.h [deleted file]
src/plugins/signalling/signalling.h [deleted file]
src/plugins/signalling/transaction.c [deleted file]
src/plugins/signalling/transaction.h [deleted file]
src/plugins/signalling/util.c [deleted file]
src/plugins/signalling/util.h [deleted file]
src/plugins/tests/Makefile.am
src/plugins/tests/signalling-client.c [deleted file]

index 1d70f42..0dc7a76 100644 (file)
@@ -372,7 +372,6 @@ AM_CONDITIONAL(DISABLED_PLUGIN_TEST,     [check_if_disabled test])
 AM_CONDITIONAL(DISABLED_PLUGIN_DBUS,     [check_if_disabled dbus])
 AM_CONDITIONAL(DISABLED_PLUGIN_GLIB,     [check_if_disabled glib])
 AM_CONDITIONAL(DISABLED_PLUGIN_CONSOLE,  [check_if_disabled console])
-AM_CONDITIONAL(DISABLED_PLUGIN_SIGNALLING, [check_if_disabled signalling])
 AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_DBUS, [check_if_disabled resource-dbus])
 AM_CONDITIONAL(DISABLED_PLUGIN_DOMAIN_CONTROL,
                [check_if_disabled domain-control])
@@ -381,7 +380,6 @@ AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,     [check_if_internal test])
 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,     [check_if_internal dbus])
 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,     [check_if_internal glib])
 AM_CONDITIONAL(BUILTIN_PLUGIN_CONSOLE,  [check_if_internal console])
-AM_CONDITIONAL(BUILTIN_PLUGIN_SIGNALLING, [check_if_internal signalling])
 AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_DBUS, [check_if_internal resource-dbus])
 AM_CONDITIONAL(BUILTIN_PLUGIN_DOMAIN_CONTROL,
                [check_if_internal domain-control])
index f388fed..f5b1a5b 100644 (file)
@@ -967,41 +967,6 @@ clean-func-infos::
        -rm plugin-console-func-info.c
 endif
 
-# signalling plugin
-SIGNALLING_PLUGIN_SOURCES = plugins/plugin-signalling.c \
-                            plugins/signalling/transaction.c \
-                            plugins/signalling/util.c \
-                            plugins/signalling/client.c \
-                            plugins/signalling/info.c \
-                            plugins/signalling/endpoint.c \
-                            plugins/signalling/plugin.h \
-                            plugins/signalling/transaction.h \
-                            plugins/signalling/util.h \
-                            plugins/signalling/client.h \
-                            plugins/signalling/info.h \
-                            plugins/signalling/endpoint.h
-SIGNALLING_PLUGIN_HEADERS = plugins/signalling/signalling.h
-SIGNALLING_PLUGIN_CFLAGS  =
-SIGNALLING_PLUGIN_LIBS    =
-SIGNALLING_PLUGINdir      = $(includedir)/murphy/plugins/signalling
-
-
-if BUILTIN_PLUGIN_SIGNALLING
-BUILTIN_PLUGINS += $(SIGNALLING_PLUGIN_SOURCES)
-BUILTIN_CFLAGS  += $(SIGNALLING_PLUGIN_CFLAGS)
-BUILTIN_LIBS    += $(SIGNALLING_PLUGIN_LIBS)
-else
-plugin_signalling_la_SOURCES = $(SIGNALLING_PLUGIN_SOURCES)
-plugin_signalling_la_HEADERS = $(SIGNALLING_PLUGIN_HEADERS)
-plugin_signalling_la_CFLAGS  = $(SIGNALLING_PLUGIN_CFLAGS) \
-                $(MURPHY_CFLAGS) $(AM_CFLAGS)
-plugin_signalling_la_LDFLAGS = -module -avoid-version
-plugin_signalling_la_LIBADD  = $(SIGNALLING_PLUGIN_LIBS)
-plugin_signalling_ladir      = $(SIGNALLING_PLUGINdir)
-
-plugin_LTLIBRARIES    += plugin-signalling.la
-endif
-
 # native resource plugin
 if BUILD_RESOURCES
 PLUGIN_RESOURCE_NATIVE_REGULAR_SOURCES =                               \
diff --git a/src/plugins/plugin-signalling.c b/src/plugins/plugin-signalling.c
deleted file mode 100644 (file)
index 7dd31e1..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-
-#include "signalling/plugin.h"
-#include "signalling/transaction.h"
-#include "signalling/client.h"
-#include "signalling/util.h"
-#include "signalling/endpoint.h"
-#include "signalling/info.h"
-
-mrp_plugin_t *signalling_plugin;
-
-enum {
-    ARG_ADDRESS /* signalling socket address, 'addr1:port;addr2:port' */
-};
-
-
-static void htbl_free_backchannel(void *key, void *object)
-{
-    MRP_UNUSED(key);
-    free_backchannel(object);
-}
-
-
-static void htbl_free_client(void *key, void *object)
-{
-    MRP_UNUSED(key);
-    free_client(object);
-}
-
-
-static void htbl_free_transaction(void *key, void *object)
-{
-    MRP_UNUSED(key);
-    free_transaction(object);
-}
-
-
-static int signalling_init(mrp_plugin_t *plugin)
-{
-    data_t *data;
-    mrp_htbl_config_t client_conf, tx_conf, backchannel_conf;
-    char *address;
-    int len = strlen(plugin->args[ARG_ADDRESS].str);
-    char buf[len+1];
-    char *tmp = buf;
-
-    signalling_info("> init()");
-
-    if ((data = mrp_allocz(sizeof(*data))) == NULL)
-        return FALSE;
-
-    data->ctx = plugin->ctx;
-
-    type_init();
-
-    client_conf.comp = mrp_string_comp;
-    client_conf.hash = mrp_string_hash;
-    client_conf.free = htbl_free_client;
-    client_conf.nbucket = 0;
-    client_conf.nentry = 10;
-
-    data->clients = mrp_htbl_create(&client_conf);
-
-    tx_conf.comp = int_comp;
-    tx_conf.hash = int_hash;
-    tx_conf.free = htbl_free_transaction;
-    tx_conf.nbucket = 0;
-    tx_conf.nentry = 5;
-
-    data->txs = mrp_htbl_create(&tx_conf);
-
-    backchannel_conf.comp = mrp_string_comp;
-    backchannel_conf.hash = mrp_string_hash;
-    backchannel_conf.free = htbl_free_backchannel;
-    backchannel_conf.nbucket = 0;
-    backchannel_conf.nentry = 5;
-
-    data->backchannels = mrp_htbl_create(&backchannel_conf);
-
-    /* parse here the address line */
-
-    mrp_list_init(&data->es);
-
-    memcpy(buf, plugin->args[ARG_ADDRESS].str, len);
-    buf[len] = '\0';
-
-    signalling_info("address config: '%s'", tmp);
-
-    do {
-        address = strtok(tmp, ";");
-        if (address) {
-            endpoint_t *e;
-            signalling_info("address: '%s'", address);
-            e = create_endpoint(address, plugin->ctx->ml);
-            if (!e) {
-                goto error;
-            }
-            clean_endpoint(e);
-            if (server_setup(e, data) < 0) {
-                goto error;
-            }
-            mrp_list_append(&data->es, &e->hook);
-        }
-        tmp = NULL;
-    } while (address);
-
-    plugin->data = data;
-    signalling_plugin = plugin;
-
-    return TRUE;
-
-error:
-    mrp_free(data);
-    signalling_error("failed to set up signalling at address '%s'.",
-            plugin->args[ARG_ADDRESS].str);
-
-    signalling_plugin = NULL;
-
-    return FALSE;
-}
-
-
-static void signalling_exit(mrp_plugin_t *plugin)
-{
-    data_t *ctx = plugin->data;
-    mrp_list_hook_t *p, *n;
-    endpoint_t *e;
-
-    signalling_info("cleaning up instance '%s'...", plugin->instance);
-
-    /* go through the client data list */
-
-    mrp_list_foreach(&ctx->es, p, n) {
-        e = mrp_list_entry(p, typeof(*e), hook);
-        mrp_list_delete(&e->hook);
-        delete_endpoint(e);
-    }
-
-    mrp_htbl_destroy(ctx->clients, TRUE);
-    mrp_htbl_destroy(ctx->txs, TRUE);
-    mrp_htbl_destroy(ctx->backchannels, TRUE);
-}
-
-
-static int boilerplate(mrp_plugin_t *plugin,
-                        const char *name, mrp_script_env_t *env)
-{
-    MRP_UNUSED(plugin);
-    MRP_UNUSED(name);
-    MRP_UNUSED(env);
-
-    return -1;
-}
-
-
-#define SIGNALLING_DESCRIPTION "A decision signalling plugin for Murphy."
-#define SIGNALLING_HELP \
-    "The signalling plugin provides one-to-many communication from Murphy\n"  \
-    "to enforcement points. The enforcement points are supposed to use\n"     \
-    "libsignalling to initialize connection to Murphy and receive events\n"   \
-    "from it."
-
-#define SIGNALLING_VERSION MRP_VERSION_INT(0, 0, 1)
-#define SIGNALLING_AUTHORS "Ismo Puustinen <ismo.puustinen@intel.com>"
-
-
-static mrp_plugin_arg_t signalling_args[] = {
-    MRP_PLUGIN_ARGIDX(ARG_ADDRESS, STRING, "address", "unxs:/tmp/murphy/signalling"),
-};
-
-MRP_EXPORTABLE(uint32_t, mrp_tx_open_signal, ())
-{
-    return _mrp_tx_open_signal();
-}
-
-MRP_EXPORTABLE(int, mrp_tx_add_domain, (uint32_t id, const char *domain))
-{
-    return _mrp_tx_add_domain(id, domain);
-}
-
-MRP_EXPORTABLE(int, mrp_tx_add_data, (uint32_t id, const char *row))
-{
-    return _mrp_tx_add_domain(id, row);
-}
-
-MRP_EXPORTABLE(void, mrp_tx_add_success_cb, (uint32_t id, mrp_tx_success_cb cb, void *data))
-{
-    _mrp_tx_add_success_cb(id, cb, data);
-}
-
-MRP_EXPORTABLE(void, mrp_tx_add_error_cb, (uint32_t id, mrp_tx_error_cb cb, void *data))
-{
-    _mrp_tx_add_error_cb(id, cb, data);
-}
-
-MRP_EXPORTABLE(int, mrp_tx_close_signal, (uint32_t id))
-{
-    return _mrp_tx_close_signal(id);
-}
-
-MRP_EXPORTABLE(void, mrp_tx_cancel_signal, (uint32_t id))
-{
-    _mrp_tx_cancel_signal(id);
-}
-
-MRP_EXPORTABLE(int, mrp_info_register, (const char *client_id, mrp_info_cb cb, void *data))
-{
-    return _mrp_info_register(client_id, cb, data);
-}
-
-MRP_EXPORTABLE(void, mrp_info_unregister, (const char *client_id))
-{
-    _mrp_info_unregister(client_id);
-}
-
-static mrp_method_descr_t exports[] = {
-    MRP_GENERIC_METHOD("mrp_tx_open_signal", mrp_tx_open_signal, boilerplate),
-    MRP_GENERIC_METHOD("mrp_tx_add_domain", mrp_tx_add_domain, boilerplate),
-    MRP_GENERIC_METHOD("mrp_tx_add_data", mrp_tx_add_data, boilerplate),
-    MRP_GENERIC_METHOD("mrp_tx_add_success_cb", mrp_tx_add_success_cb, boilerplate),
-    MRP_GENERIC_METHOD("mrp_tx_add_error_cb", mrp_tx_add_error_cb, boilerplate),
-    MRP_GENERIC_METHOD("mrp_tx_close_signal", mrp_tx_close_signal, boilerplate),
-    MRP_GENERIC_METHOD("mrp_tx_cancel_signal", mrp_tx_cancel_signal, boilerplate),
-    MRP_GENERIC_METHOD("mrp_info_register", mrp_info_register, boilerplate),
-    MRP_GENERIC_METHOD("mrp_info_unregister", mrp_info_unregister, boilerplate),
-};
-
-MURPHY_REGISTER_CORE_PLUGIN("signalling",
-        SIGNALLING_VERSION, SIGNALLING_DESCRIPTION,
-        SIGNALLING_AUTHORS, SIGNALLING_HELP, MRP_SINGLETON,
-        signalling_init, signalling_exit, signalling_args,
-        MRP_ARRAY_SIZE(signalling_args), exports, MRP_ARRAY_SIZE(exports),
-        NULL, 0, NULL);
index 80e55bf..dffb05d 100644 (file)
 #include <murphy/core/console.h>
 #include <murphy/core/event.h>
 
-#include <murphy/plugins/signalling/signalling.h>
-#include <murphy/plugins/signalling/signalling-protocol.h>
-
-
 
 typedef struct {
     mrp_event_watch_t *w;
@@ -62,12 +58,6 @@ void two_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
 void three_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
 void four_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
 void resolve_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
-void signalling_cb_1(mrp_console_t *c, void *user_data, int argc, char **argv);
-void signalling_cb_2(mrp_console_t *c, void *user_data, int argc, char **argv);
-void signalling_cb_3(mrp_console_t *c, void *user_data, int argc, char **argv);
-void signalling_info_register_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
-void signalling_info_unregister_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
-void signalling_create_ep_cb(mrp_console_t *c, void *user_data, int argc, char **argv);
 
 
 MRP_CONSOLE_GROUP(test_group, "test", NULL, NULL, {
@@ -80,31 +70,7 @@ MRP_CONSOLE_GROUP(test_group, "test", NULL, NULL, {
         MRP_TOKENIZED_CMD("four" , four_cb , TRUE,
                           "four [args]", "command 4", "description 4"),
         MRP_TOKENIZED_CMD("update" , resolve_cb , TRUE,
-                          "update <target>", "update target", "update target"),
-        MRP_TOKENIZED_CMD("signalling_1" , signalling_cb_1 , TRUE,
-                          "signalling_1 [args]", "signalling command",
-                          "Signalling test case 1"),
-        MRP_TOKENIZED_CMD("signalling_2" , signalling_cb_2 , TRUE,
-                          "signalling_2 [args]", "signalling command",
-                          "Signalling test case 2"),
-        MRP_TOKENIZED_CMD("signalling_3" , signalling_cb_3 , TRUE,
-                          "signalling_3 [args]", "signalling command",
-                          "Signalling test case 3"),
-        MRP_TOKENIZED_CMD("signalling_info_register",
-                          signalling_info_register_cb , TRUE,
-                          "signalling_info_register [args]",
-                          "signalling back channel registration command",
-                          "Signalling back channel registration"),
-        MRP_TOKENIZED_CMD("signalling_info_unregister",
-                          signalling_info_unregister_cb , TRUE,
-                          "signalling_info_unregister [args]",
-                          "signalling back channel unregistration command",
-                          "Signalling back channel unregistration"),
-        MRP_TOKENIZED_CMD("signalling_create_ep_cb",
-                          signalling_create_ep_cb, TRUE,
-                          "signalling_create_ep_cb [args]",
-                          "signalling internal EP creation command",
-                          "Create internal enforcement point for signalling")
+                          "update <target>", "update target", "update target")
 });
 
 
@@ -234,17 +200,6 @@ static int boilerplate2(mrp_plugin_t *plugin,
 MRP_IMPORTABLE(char *, method1ptr, (int arg1, char *arg2, double arg3));
 MRP_IMPORTABLE(int, method2ptr, (char *arg1, double arg2, int arg3));
 
-MRP_IMPORTABLE(uint32_t, mrp_tx_open_signal, ());
-MRP_IMPORTABLE(int, mrp_tx_add_domain, (uint32_t id, const char *domain));
-MRP_IMPORTABLE(int, mrp_tx_add_data, (uint32_t id, const char *row));
-MRP_IMPORTABLE(void, mrp_tx_add_success_cb, (uint32_t id, mrp_tx_success_cb cb, void *data));
-MRP_IMPORTABLE(void, mrp_tx_add_error_cb, (uint32_t id, mrp_tx_error_cb cb, void *data));
-MRP_IMPORTABLE(int, mrp_tx_close_signal, (uint32_t id));
-MRP_IMPORTABLE(void, mrp_tx_cancel_signal, (uint32_t id));
-
-MRP_IMPORTABLE(int, mrp_info_register, (const char *client_id, mrp_info_cb cb, void *data));
-MRP_IMPORTABLE(int, mrp_info_unregister, (const char *client_id));
-
 #if 0
 static int export_methods(mrp_plugin_t *plugin)
 {
@@ -437,270 +392,6 @@ static void unsubscribe_events(mrp_plugin_t *plugin)
 }
 
 
-static void success_cb(uint32_t tx, void *data)
-{
-    mrp_console_t *c = data;
-
-    MRP_UNUSED(c);
-
-    printf("%s(): transaction %u\n", __FUNCTION__, tx);
-}
-
-
-static void error_cb(uint32_t tx, mrp_tx_error_t err, void *data)
-{
-    mrp_console_t *c = data;
-
-    MRP_UNUSED(c);
-
-    printf("%s(): transaction %u error: %s\n", __FUNCTION__,
-           tx, (err == MRP_TX_ERROR_NACKED) ? "NACK" : "no reply");
-}
-
-
-void signalling_cb_1(mrp_console_t *c, void *user_data, int argc, char **argv)
-{
-    uint32_t tx;
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    tx = mrp_tx_open_signal();
-
-    mrp_tx_add_domain(tx, "domain1");
-
-    mrp_tx_add_data(tx, "this is a data row");
-    mrp_tx_add_data(tx, "this is another data row");
-
-    mrp_tx_add_success_cb(tx, success_cb, c);
-    mrp_tx_add_error_cb(tx, error_cb, c);
-
-    mrp_tx_close_signal(tx);
-}
-
-
-void signalling_cb_2(mrp_console_t *c, void *user_data, int argc, char **argv)
-{
-    uint32_t tx;
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    tx = mrp_tx_open_signal();
-
-    mrp_tx_add_domain(tx, "domain_nonexistent");
-
-    mrp_tx_add_data(tx, "this is a data row");
-    mrp_tx_add_data(tx, "this is another data row");
-
-    mrp_tx_add_success_cb(tx, success_cb, c);
-    mrp_tx_add_error_cb(tx, error_cb, c);
-
-    mrp_tx_close_signal(tx);
-}
-
-void signalling_cb_3(mrp_console_t *c, void *user_data, int argc, char **argv)
-{
-    uint32_t tx;
-    int ret;
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    tx = mrp_tx_open_signal();
-
-    mrp_tx_add_domain(tx, "domain1");
-
-    mrp_tx_add_data(tx, "this is a data row");
-    mrp_tx_add_data(tx, "this is another data row");
-
-    mrp_tx_add_success_cb(tx, success_cb, c);
-    mrp_tx_add_error_cb(tx, error_cb, c);
-
-    /* try cancelling the signal first */
-    mrp_tx_cancel_signal(tx);
-
-    ret = mrp_tx_close_signal(tx);
-
-    printf("%s(): tried to send a cancelled transction %u -- success %i\n",
-           __FUNCTION__, tx, ret);
-}
-
-static void info_cb(char *msg, void *data)
-{
-    mrp_console_t *c = data;
-
-    MRP_UNUSED(c);
-
-    printf("received msg '%s'\n", msg);
-}
-
-void signalling_info_register_cb(mrp_console_t *c, void *user_data,
-            int argc, char **argv)
-{
-    /* create the back channel to the test ep */
-
-    char *ep = "foobar";
-    int ret;
-
-    MRP_UNUSED(user_data);
-
-    if (argc == 1)
-        ep = argv[0];
-
-
-    ret = mrp_info_register(ep, info_cb, c);
-
-    if (ret < 0)
-        printf("Failed to register back channel to EP '%s'\n", ep);
-    else
-        printf("Registered back channel to EP '%s'\n", ep);
-}
-
-
-void signalling_info_unregister_cb(mrp_console_t *c, void *user_data,
-            int argc, char **argv)
-{
-    /* create the back channel to the test ep */
-
-    char *ep = "foobar";
-
-    MRP_UNUSED(c);
-    MRP_UNUSED(user_data);
-
-    if (argc == 1)
-        ep = argv[0];
-
-    mrp_info_unregister(ep);
-
-    printf("Unregistered back channel to EP '%s'\n", ep);
-}
-
-
-static void dump_decision(mrp_console_t *c, ep_decision_t *msg)
-{
-    uint i;
-
-    MRP_UNUSED(c);
-
-    printf("Message contents:\n");
-    for (i = 0; i < msg->n_rows; i++) {
-        printf("row %d: '%s'\n", i+1, msg->rows[i]);
-    }
-    printf("%s required.\n\n",
-                msg->reply_required ? "Reply" : "No reply");
-}
-
-
-static void recvfrom_evt(mrp_transport_t *t, void *data, uint16_t tag,
-             mrp_sockaddr_t *addr, socklen_t addrlen, void *user_data)
-{
-    mrp_console_t *c = user_data;
-
-    MRP_UNUSED(addr);
-    MRP_UNUSED(addrlen);
-
-    printf("Received message (0x%02x)\n", tag);
-
-    switch (tag) {
-        case TAG_POLICY_DECISION:
-        {
-            ep_decision_t *msg = data;
-            dump_decision(c, msg);
-
-
-            if (msg->reply_required) {
-                ep_ack_t reply;
-
-                reply.id = msg->id;
-                reply.success = EP_ACK;
-                mrp_transport_senddata(t, &reply, TAG_ACK);
-            }
-            break;
-        }
-        case TAG_ERROR:
-            printf("Server sends an error message!\n");
-            break;
-        default:
-            /* no other messages supported ATM */
-            break;
-    }
-
-    mrp_data_free(data, tag);
-}
-
-
-static void recv_evt(mrp_transport_t *t, void *data, uint16_t tag, void *user_data)
-{
-    recvfrom_evt(t, data, tag, NULL, 0, user_data);
-}
-
-
-static void closed_evt(mrp_transport_t *t, int error, void *user_data)
-{
-    MRP_UNUSED(t);
-    MRP_UNUSED(error);
-    MRP_UNUSED(user_data);
-
-    printf("Received closed event\n");
-}
-
-
-void signalling_create_ep_cb(mrp_console_t *c, void *user_data,
-            int argc, char **argv)
-{
-    mrp_transport_t *t;
-    static mrp_transport_evt_t evt;
-    int ret, flags;
-    char *domains[] = { "domain1" };
-
-    MRP_UNUSED(user_data);
-
-    ep_register_t msg;
-
-    socklen_t alen;
-    mrp_sockaddr_t addr;
-
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    evt.closed = closed_evt;
-    evt.recvdata = recv_evt;
-    evt.recvdatafrom = recvfrom_evt;
-
-    flags = MRP_TRANSPORT_REUSEADDR | MRP_TRANSPORT_MODE_CUSTOM;
-
-    t = mrp_transport_create(c->ctx->ml, "internal", &evt, c, flags);
-
-    alen = mrp_transport_resolve(NULL, "internal:signalling", &addr, sizeof(addr), NULL);
-
-    if (alen <= 0) {
-        printf("Error: resolving address failed!\n");
-        return;
-    }
-
-    ret = mrp_transport_connect(t, &addr, alen);
-    if (ret == 0) {
-        printf("Error: connect failed!\n");
-        return;
-    }
-
-    msg.ep_name = "ep_name";
-    msg.domains = domains;
-    msg.n_domains = 1;
-
-    ret = mrp_transport_senddata(t, &msg, TAG_REGISTER);
-
-    if (!ret) {
-        printf("Failed to send register message\n");
-        return;
-    }
-}
-
-
 static int test_init(mrp_plugin_t *plugin)
 {
     mrp_plugin_arg_t *args;
@@ -787,13 +478,6 @@ static mrp_method_descr_t exports[] = {
 static mrp_method_descr_t imports[] = {
     MRP_IMPORT_METHOD("method1", method1ptr),
     MRP_IMPORT_METHOD("method2", method2ptr),
-    MRP_IMPORT_METHOD("mrp_tx_open_signal", mrp_tx_open_signal),
-    MRP_IMPORT_METHOD("mrp_tx_add_domain", mrp_tx_add_domain),
-    MRP_IMPORT_METHOD("mrp_tx_add_data", mrp_tx_add_data),
-    MRP_IMPORT_METHOD("mrp_tx_add_success_cb", mrp_tx_add_success_cb),
-    MRP_IMPORT_METHOD("mrp_tx_add_error_cb", mrp_tx_add_error_cb),
-    MRP_IMPORT_METHOD("mrp_tx_close_signal", mrp_tx_close_signal),
-    MRP_IMPORT_METHOD("mrp_tx_cancel_signal", mrp_tx_cancel_signal),
 };
 
 
diff --git a/src/plugins/signalling/client.c b/src/plugins/signalling/client.c
deleted file mode 100644 (file)
index 32ff4c8..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-#include <murphy/plugins/signalling/signalling-protocol.h>
-
-#include "client.h"
-#include "transaction.h"
-#include "util.h"
-#include "endpoint.h"
-#include "signalling.h"
-#include "info.h"
-
-
-void free_client(client_t *c)
-{
-    uint i;
-
-    mrp_free(c->name);
-
-    for (i = 0; i < c->ndomains; i++) {
-        mrp_free(c->domains[i]);
-    }
-    mrp_free(c->domains);
-
-    mrp_free(c);
-}
-
-
-static void remove_client_from_transactions(client_t *c, data_t *ctx) {
-    /* TODO: Go through all transactions. Remove the client from the
-       not-answered lists. Re-allocate the client name to the other lists? */
-
-    MRP_UNUSED(c);
-    MRP_UNUSED(ctx);
-
-    return;
-}
-
-
-void deregister_and_free_client(client_t *c, data_t *ctx)
-{
-    remove_client_from_transactions(c, ctx);
-    mrp_htbl_remove(ctx->clients, c->name, 0);
-    free_client(c);
-}
-
-
-int send_policy_decision(data_t *ctx, client_t *c, transaction_t *tx)
-{
-    ep_decision_t msg;
-
-    MRP_UNUSED(ctx);
-
-    msg.id = tx->id;
-    msg.n_rows = tx->data.n_rows;
-    msg.rows = tx->data.rows;
-
-    if (tx->data.success_cb || tx->data.error_cb) {
-        signalling_info("Reply required for transaction %u", tx->id);
-        msg.reply_required = TRUE;
-    }
-    else
-        msg.reply_required = FALSE;
-
-    return mrp_transport_senddata(c->t, &msg, TAG_POLICY_DECISION);
-}
-
-
-static int handle_ack(client_t *c, data_t *ctx, ep_ack_t *data)
-{
-    signalling_info("acknowledgement message");
-
-    transaction_t *tx = get_transaction(ctx, data->id);
-
-    if (!tx) {
-        signalling_warn("no transaction with %d found, maybe already done",
-            data->id);
-        return 0;
-    }
-
-    if (!c->registered)
-        return -1;
-
-    switch(data->success) {
-        case EP_ACK:
-        {
-            uint i, found = 0;
-
-            signalling_info("received ACK from EP %s", c->name);
-
-            /* go through the not_answered array */
-            for (i = 0; i < tx->n_total; i++) {
-                if (strcmp(c->name, tx->not_answered[i]) == 0) {
-                    found = 1;
-                    tx->acked[tx->n_acked++] = tx->not_answered[i];
-                    tx->n_not_answered--;
-                }
-            }
-            if (!found) {
-                signalling_warn("spurious ACK from %s, ignoring", c->name);
-                return 0;
-            }
-
-            break;
-        }
-        case EP_NACK:
-        case EP_NOT_READY:
-        {
-            uint i, found = 0;
-
-            signalling_info("received NACK from EP %s", c->name);
-
-            for (i = 0; i < tx->n_total; i++) {
-                if (strcmp(c->name, tx->not_answered[i]) == 0) {
-                    found = 1;
-                    tx->nacked[tx->n_nacked++] = tx->not_answered[i];
-                    tx->n_not_answered--;
-
-                    /* FIXME: handle error here or wait for all EPs to answer? */
-                }
-            }
-            if (!found) {
-                signalling_error("spurious NACK from %s", c->name);
-                return 0;
-            }
-
-            break;
-        }
-        default:
-            signalling_error("unhandled ACK status!");
-            return -1;
-    }
-
-    if (tx->n_not_answered == 0) {
-        complete_transaction(ctx, tx);
-    }
-
-    return 0;
-}
-
-
-static int handle_register(client_t *c, data_t *ctx, ep_register_t *data)
-{
-    uint i;
-
-    signalling_info("register message");
-
-    signalling_info("ep name: %s", data->ep_name);
-    signalling_info("number of domains: %d", data->n_domains);
-
-    if (strcmp(data->ep_name, "") == 0) {
-        signalling_error("EP with an empty name");
-
-        /* TODO: send an error message back */
-        return -1;
-    }
-
-    if (mrp_htbl_lookup(ctx->clients, data->ep_name)) {
-        /* there already was a client of similar name */
-        signalling_error("EP '%s' already exists in db", data->ep_name);
-
-        /* TODO: send an error message back */
-        return -1;
-    }
-
-    c->name = mrp_strdup(data->ep_name);
-    c->ndomains = data->n_domains;
-    c->domains = mrp_alloc_array(char *, data->n_domains);
-
-    for (i = 0; i < data->n_domains; i++) {
-        c->domains[i] = mrp_strdup(data->domains[i]);
-        signalling_info("domain: %s", data->domains[i]);
-    }
-
-    c->registered = TRUE;
-    mrp_htbl_insert(ctx->clients, c->name, c);
-    ctx->n_clients++;
-
-    return 0;
-}
-
-
-static int handle_info(client_t *c, data_t *ctx, ep_info_t *data)
-{
-    backchannel_t *b;
-
-    signalling_info("info message from '%s'", c->name);
-
-    if (!c->registered)
-        return -1;
-
-    /* see if someone is interested in the info message */
-
-    b = mrp_htbl_lookup(ctx->backchannels, c->name);
-
-    if (b) {
-        signalling_info("found an interested party for the message");
-        b->cb(data->msg, b->data);
-    }
-
-    return 0;
-}
-
-
-static void recvfrom_evt(mrp_transport_t *t, void *data, uint16_t tag,
-             mrp_sockaddr_t *addr, socklen_t addrlen, void *user_data)
-{
-    client_t *c = (client_t *)user_data;
-    int ret = -1;
-
-    MRP_UNUSED(t);
-    MRP_UNUSED(addr);
-    MRP_UNUSED(addrlen);
-
-    signalling_info("Received message (%d)", tag);
-
-    switch(tag) {
-
-        case TAG_REGISTER:
-            ret = handle_register(c, c->u, data);
-            break;
-        case TAG_ACK:
-            ret = handle_ack(c, c->u, data);
-            break;
-        case TAG_UNREGISTER:
-            /* not supported ATM, we just wait for the close */
-            break;
-        case TAG_INFO:
-            ret = handle_info(c, c->u, data);
-            break;
-        default:
-            signalling_warn("Unhandled message type");
-            ret = 0;
-            break;
-    }
-
-    if (ret < 0) {
-        signalling_error("Malformed message");
-    }
-
-    mrp_free(data);
-}
-
-
-static void recv_evt(mrp_transport_t *t, void *data, uint16_t tag, void *user_data)
-{
-    recvfrom_evt(t, data, tag, NULL, 0, user_data);
-}
-
-
-static void closed_evt(mrp_transport_t *t, int error, void *user_data)
-{
-    client_t *c = (client_t *)user_data;
-    data_t *ctx = c->u;
-
-    if (error)
-        mrp_log_error("Connection closed with error %d (%s).", error,
-                strerror(error));
-    else {
-        mrp_log_info("Peer has closed the connection.");
-
-        mrp_transport_disconnect(t);
-        mrp_transport_destroy(t);
-        c->t = NULL;
-
-        if (ctx && c->registered)
-            deregister_and_free_client(c, ctx);
-    }
-}
-
-
-static void connection_evt(mrp_transport_t *lt, void *user_data)
-{
-    endpoint_t *e = (endpoint_t *) user_data;
-    data_t *ctx = e->user_data;
-    client_t *c;
-
-    signalling_info("Connection from peer (using %s).", e->address);
-
-    if ((c = mrp_allocz(sizeof(*c))) != NULL) {
-        c->t  = accept_connection(e, lt, c);
-        c->u = ctx;
-        c->registered = FALSE;
-
-        if (c->t != NULL) {
-            signalling_info("Connection accepted.");
-            /* TODO: maybe remove the client if no registration in some time */
-
-            return;
-        }
-
-        mrp_transport_destroy(c->t);
-        mrp_free(c);
-    }
-}
-
-int server_setup(endpoint_t *e, data_t *data)
-{
-    mrp_transport_evt_t evt;
-
-    evt.connection = connection_evt;
-    evt.closed = closed_evt;
-    evt.recvdatafrom = recvfrom_evt;
-    evt.recvdata = recv_evt;
-
-    if (start_endpoint(e, &evt, data) < 0) {
-        signalling_error("Error: couldn't set up the listening transport");
-        return -1;
-    }
-    return 0;
-}
-
-int type_init(void)
-{
-    if (!mrp_msg_register_type(&ep_register_descr) ||
-        !mrp_msg_register_type(&ep_decision_descr) ||
-        !mrp_msg_register_type(&ep_ack_descr) ||
-        !mrp_msg_register_type(&ep_info_descr)) {
-        mrp_log_error("Failed to register custom data type.");
-        return -1;
-    }
-    return 0;
-}
diff --git a/src/plugins/signalling/client.h b/src/plugins/signalling/client.h
deleted file mode 100644 (file)
index 56f1ce1..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_CLIENT_H__
-#define __MURPHY_SIGNALLING_CLIENT_H__
-
-#include <stdint.h>
-
-#include "plugin.h"
-#include "transaction.h"
-#include "endpoint.h"
-
-typedef struct {
-    char *name;
-    uint32_t ndomains;
-    char **domains;
-    mrp_transport_t *t;   /* associated transport */
-
-    bool registered;      /* if the client is registered to server */
-    endpoint_t *e; /* connection endpoint that the client is using */
-    data_t *u;
-} client_t;
-
-
-void deregister_and_free_client(client_t *c, data_t *ctx);
-int send_policy_decision(data_t *ctx, client_t *c, transaction_t *tx);
-
-void free_client(client_t *c);
-
-
-int server_setup(endpoint_t *e, data_t *data);
-int type_init(void);
-
-
-#endif /* __MURPHY_SIGNALLING_CLIENT_H__ */
diff --git a/src/plugins/signalling/endpoint.c b/src/plugins/signalling/endpoint.c
deleted file mode 100644 (file)
index 687c55b..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-
-#include "endpoint.h"
-#include "util.h"
-
-
-endpoint_t *create_endpoint(const char *address, mrp_mainloop_t *ml)
-{
-    endpoint_t *e;
-
-    e = mrp_alloc(sizeof(endpoint_t));
-
-    e->ml = ml;
-    e->address = mrp_strdup(address);
-    e->addrlen = mrp_transport_resolve(NULL, e->address,
-            &e->addr, sizeof(e->addr), &e->stype);
-
-    if (e->addrlen <= 0) {
-        signalling_error("failed to bind address %s", e->address);
-        mrp_free(e->address);
-        mrp_free(e);
-        return NULL;
-    }
-
-    if (strncmp(e->stype, "unxs", 4) == 0) {
-        e->type = TPORT_UNXS;
-        e->connection_oriented = TRUE;
-    }
-    else if (strncmp(e->stype, "dbus", 4) == 0) {
-        e->type = TPORT_DBUS;
-        e->connection_oriented = FALSE;
-    }
-    else if (strncmp(e->stype, "internal", 8) == 0) {
-        e->type = TPORT_INTERNAL;
-        e->connection_oriented = TRUE;
-    }
-    else {
-        signalling_error("not supported transport type: %s", e->stype);
-        mrp_free(e->address);
-        mrp_free(e);
-        return NULL;
-    }
-
-    mrp_list_init(&e->hook);
-    mrp_list_init(&e->clients);
-
-    return e;
-}
-
-
-int clean_endpoint(endpoint_t *e)
-{
-    switch (e->type) {
-        case TPORT_UNXS:
-        {
-            char *path = e->address + 5;
-            int len;
-
-            /* make sure that this is a real file system path */
-            len = strlen(path);
-            if (len >= 1) {
-                if (path[0] != '@') {
-                    /* TODO: stat and check the socket status */
-                    unlink(path);
-                }
-            }
-            break;
-        }
-        default:
-        break;
-    }
-    return 0;
-}
-
-
-static void recvfrom_evt(mrp_transport_t *t, void *data, uint16_t tag,
-            mrp_sockaddr_t *addr, socklen_t addrlen, void *user_data)
-{
-    endpoint_tport_t *et = user_data;
-
-    signalling_info("proxying recvfrom_evt (ep: %s) (%p, %p, %d, %p)",
-            et->e->address, t, data, tag, user_data);
-
-    if (et->e->evt.recvdatafrom) {
-        et->e->evt.recvdatafrom(t, data, tag, addr, addrlen, et->client);
-    }
-}
-
-
-static void recv_evt(mrp_transport_t *t, void *data, uint16_t tag,
-            void *user_data)
-{
-    endpoint_tport_t *et = user_data;
-
-    signalling_info("proxying recv_evt (ep: %s) (%p, %p, %d, %p)",
-            et->e->address, t, data, tag, user_data);
-
-    if (et->e->evt.recvdata) {
-        et->e->evt.recvdata(t, data, tag, et->client);
-    }
-}
-
-static void connection_evt(mrp_transport_t *lt, void *user_data)
-{
-    endpoint_t *e = user_data;
-
-    signalling_info("proxying connection_evt (ep: %s) (%p, %p)",
-            e->address, lt, user_data);
-
-    switch (e->type) {
-        case TPORT_DBUS:
-        {
-            /* start listening to name changed event to discover when the
-               client goes away? */
-
-            break;
-        }
-        default:
-        break;
-    }
-
-    if (e->evt.connection) {
-
-        e->evt.connection(lt, e);
-    }
-}
-
-static void closed_evt(mrp_transport_t *t, int error, void *user_data)
-{
-    endpoint_tport_t *et;
-
-    /* check if t is valid */
-
-    if (!t->connected) {
-
-        /* we are trying to fix the case where the connection has never been
-           accepted, meaning there is no endpoint_tport_t allocated at all. */
-        return;
-    }
-
-    et = user_data;
-
-    signalling_info("proxying closed_evt (ep: %s) (%p, %d, %p)",
-            et->e->address, t, error, user_data);
-
-    if (et->e->evt.closed) {
-        et->e->evt.closed(t, error, et->client);
-    }
-
-    mrp_list_delete(&et->hook);
-    mrp_free(et);
-}
-
-
-int start_endpoint(endpoint_t *e, mrp_transport_evt_t *evt, void *userdata)
-{
-    int flags;
-
-    memcpy(&e->evt, evt, sizeof(mrp_transport_evt_t));
-
-    e->user_data = userdata;
-
-    e->proxy_evt.connection = connection_evt;
-    e->proxy_evt.closed = closed_evt;
-    e->proxy_evt.recvdatafrom = recvfrom_evt;
-    e->proxy_evt.recvdata = recv_evt;
-
-    flags = MRP_TRANSPORT_REUSEADDR | MRP_TRANSPORT_MODE_CUSTOM;
-    e->t = mrp_transport_create(e->ml, e->stype, &e->proxy_evt, e, flags);
-
-    if (e->t == NULL) {
-        signalling_error("Error: Failed to create listening socket transport.");
-        goto error;
-    }
-
-    if (!mrp_transport_bind(e->t, &e->addr, e->addrlen)) {
-        signalling_error("Error: Failed to bind to address %s.", e->address);
-        goto error;
-    }
-
-    if (!mrp_transport_listen(e->t, 4)) {
-        signalling_error("Error: Failed to listen on server transport (%s).",
-                e->address);
-        goto error;
-    }
-
-    return 0;
-
-error:
-    return -1;
-}
-
-
-mrp_transport_t *accept_connection(endpoint_t *e, mrp_transport_t *lt,
-            void *client)
-{
-    int flags = 0;
-    endpoint_tport_t *et;
-    mrp_transport_t *t;
-
-    et = mrp_allocz(sizeof(endpoint_tport_t));
-    et->e = e;
-    et->client = client;
-    mrp_list_init(&et->hook);
-
-    switch (e->type) {
-        default:
-            flags = MRP_TRANSPORT_REUSEADDR | MRP_TRANSPORT_NONBLOCK;
-        break;
-    }
-
-    t = mrp_transport_accept(lt, et, flags);
-
-    if (!t)
-        goto error;
-
-    mrp_list_append(&e->clients, &et->hook);
-
-    return t;
-
-error:
-    mrp_free(et);
-    return NULL;
-}
-
-
-void delete_endpoint(endpoint_t *e)
-{
-    mrp_list_hook_t *p, *n;
-    endpoint_tport_t *et;
-
-    mrp_transport_disconnect(e->t);
-    mrp_transport_destroy(e->t);
-
-    /* go through the client data list and free */
-
-    mrp_list_foreach(&e->clients, p, n) {
-        et = mrp_list_entry(p, typeof(*et), hook);
-        mrp_list_delete(&et->hook);
-        mrp_free(et);
-    }
-
-    mrp_free(e->address);
-    mrp_free(e);
-}
diff --git a/src/plugins/signalling/endpoint.h b/src/plugins/signalling/endpoint.h
deleted file mode 100644 (file)
index 1e0a006..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_ENDPOINT_H__
-#define __MURPHY_SIGNALLING_ENDPOINT_H__
-
-#include <stdint.h>
-
-#include <murphy/common.h>
-
-/* The different transport types require different hacks to make them work.
-   This is a "sin bin" to handle them. */
-
-/* We don't have any security, so we don't allow any network connections etc.
-   coming from outside of the device. */
-
- typedef enum {
-    TPORT_UNKNOWN,
-    TPORT_UNXS,
-    TPORT_DBUS,
-    TPORT_INTERNAL,
-    TPORT_MAX
- } signalling_transport_t;
-
-typedef struct {
-    char *address;          /* endpoint address */
-    signalling_transport_t type;  /* endpoint type */
-    bool connection_oriented; /* if the endpoint is connection-oriented */
-
-    const char *stype;
-    mrp_sockaddr_t addr;
-    socklen_t addrlen;
-    mrp_mainloop_t *ml;
-    mrp_transport_t *t;
-
-    mrp_list_hook_t hook; /* es */
-    mrp_list_hook_t clients;
-
-    void *user_data;
-    mrp_transport_evt_t proxy_evt; /* the proxy callbacks */
-    mrp_transport_evt_t evt; /* the real callbacks to call */
-} endpoint_t;
-
-typedef struct {
-    mrp_list_hook_t hook; /* for clients */
-    endpoint_t *e;
-    void *client;
-} endpoint_tport_t;
-
-endpoint_t *create_endpoint(const char *address, mrp_mainloop_t *ml);
-
-int clean_endpoint(endpoint_t *e);
-
-int start_endpoint(endpoint_t *e, mrp_transport_evt_t *evt, void *userdata);
-
-void delete_endpoint(endpoint_t *e);
-
-mrp_transport_t *accept_connection(endpoint_t *e, mrp_transport_t *lt,
-        void *client);
-
-#endif /* __MURPHY_SIGNALLING_ENDPOINT_H__ */
diff --git a/src/plugins/signalling/info.c b/src/plugins/signalling/info.c
deleted file mode 100644 (file)
index 71c90d9..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-#include <murphy/plugins/signalling/signalling-protocol.h>
-
-#include "plugin.h"
-#include "info.h"
-
-extern mrp_plugin_t *signalling_plugin;
-
-
-void free_backchannel(backchannel_t *b)
-{
-    mrp_free(b->client_id);
-    mrp_free(b);
-}
-
-
-int _mrp_info_register(const char *client_id, mrp_info_cb cb, void *data)
-{
-    data_t *ctx = signalling_plugin->data;
-    backchannel_t *b;
-
-    b = mrp_htbl_lookup(ctx->backchannels, (void *) client_id);
-
-    if (b) {
-        /* someone is already handling this signal */
-        return -1;
-    }
-
-    b = mrp_allocz(sizeof(backchannel_t));
-
-    if (!b) {
-        return -1;
-    }
-
-    b->cb = cb;
-    b->data = data;
-
-    /* for hash table memory management */
-    b->client_id = mrp_strdup(client_id);
-
-    mrp_htbl_insert(ctx->backchannels, b->client_id, b);
-
-    return 0;
-}
-
-
-void _mrp_info_unregister(const char *client_id)
-{
-    data_t *ctx = signalling_plugin->data;
-    backchannel_t *b;
-
-    b = mrp_htbl_lookup(ctx->backchannels, (void *) client_id);
-
-    if (b) {
-        mrp_htbl_remove(ctx->backchannels, (void *) client_id, TRUE);
-    }
-}
diff --git a/src/plugins/signalling/info.h b/src/plugins/signalling/info.h
deleted file mode 100644 (file)
index 916333e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_INFO_H__
-#define __MURPHY_SIGNALLING_INFO_H__
-
-#include <stdint.h>
-
-#include <murphy/common.h>
-#include <murphy/plugins/signalling/signalling.h>
-
-#include "plugin.h"
-
-typedef struct {
-    char *client_id;
-    mrp_info_cb cb;
-    void *data;
-} backchannel_t;
-
-
-void free_backchannel(backchannel_t *b);
-
-/* exported functions */
-int _mrp_info_register(const char *client_id, mrp_info_cb cb, void *data);
-void _mrp_info_unregister(const char *client_id);
-
-#endif /* __MURPHY_SIGNALLING_INFO_H__ */
diff --git a/src/plugins/signalling/plugin.h b/src/plugins/signalling/plugin.h
deleted file mode 100644 (file)
index 735584f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_PLUGIN_H__
-#define __MURPHY_SIGNALLING_PLUGIN_H__
-
-#include <stdint.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-
-#include "endpoint.h"
-
-typedef struct {
-    mrp_context_t *ctx;       /* murphy context */
-    mrp_list_hook_t es;       /* endpoints */
-    mrp_htbl_t *txs;          /* active transactions */
-    mrp_htbl_t *clients;      /* active clients */
-    mrp_htbl_t *backchannels; /* backchannel requests */
-    int n_clients;
-    uint32_t next_id;
-} data_t;
-
-
-#endif /* __MURPHY_SIGNALLING_PLUGIN_H__ */
diff --git a/src/plugins/signalling/signalling-protocol.h b/src/plugins/signalling/signalling-protocol.h
deleted file mode 100644 (file)
index 51066cd..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_PROTOCOL_H__
-#define __MURPHY_SIGNALLING_PROTOCOL_H__
-
-#include <stdint.h>
-#include <murphy/common.h>
-
-
-#define TAG_REGISTER         0x1
-#define TAG_UNREGISTER       0x2 /* implicit with unix domain sockets */
-#define TAG_POLICY_DECISION  0x3
-#define TAG_ACK              0x4
-#define TAG_INFO             0x5
-#define TAG_ERROR            0x6
-
-/* decision status */
-
-#define EP_ACK               0x1
-#define EP_NACK              0x2
-#define EP_NOT_READY         0x3
-
-typedef struct {
-    char *ep_name;       /* EP name */
-    uint32_t n_domains;  /* number of domains */
-    char **domains;      /* array of domains */
-} ep_register_t;
-
-typedef struct {
-    uint32_t id;         /* decision id */
-    bool reply_required; /* if the EP must ACK/NACK the message */
-    uint32_t n_rows;     /* number of rows */
-    char **rows;         /* murphy-db database rows */
-} ep_decision_t;
-
-typedef struct {
-    uint32_t id;         /* decision id */
-    uint32_t success;    /* ACK/NACK/... */
-} ep_ack_t;
-
-typedef struct {
-    char *msg;
-} ep_info_t;
-
-
-MRP_DATA_DESCRIPTOR(ep_register_descr, TAG_REGISTER, ep_register_t,
-        MRP_DATA_MEMBER(ep_register_t, ep_name, MRP_MSG_FIELD_STRING),
-        MRP_DATA_MEMBER(ep_register_t, n_domains, MRP_MSG_FIELD_UINT32),
-        MRP_DATA_ARRAY_COUNT(ep_register_t, domains, n_domains,
-            MRP_MSG_FIELD_STRING));
-
-MRP_DATA_DESCRIPTOR(ep_decision_descr, TAG_POLICY_DECISION, ep_decision_t,
-        MRP_DATA_MEMBER(ep_decision_t, id, MRP_MSG_FIELD_UINT32),
-        MRP_DATA_MEMBER(ep_decision_t, reply_required, MRP_MSG_FIELD_BOOL),
-        MRP_DATA_MEMBER(ep_decision_t, n_rows, MRP_MSG_FIELD_UINT32),
-        MRP_DATA_ARRAY_COUNT(ep_decision_t, rows, n_rows,
-            MRP_MSG_FIELD_STRING));
-
-MRP_DATA_DESCRIPTOR(ep_ack_descr, TAG_ACK, ep_ack_t,
-        MRP_DATA_MEMBER(ep_ack_t, id, MRP_MSG_FIELD_UINT32),
-        MRP_DATA_MEMBER(ep_ack_t, success, MRP_MSG_FIELD_UINT32));
-
-MRP_DATA_DESCRIPTOR(ep_info_descr, TAG_INFO, ep_info_t,
-        MRP_DATA_MEMBER(ep_info_t, msg, MRP_MSG_FIELD_STRING));
-
-#endif /* __MURPHY_SIGNALLING_PROTOCOL_H__ */
diff --git a/src/plugins/signalling/signalling.h b/src/plugins/signalling/signalling.h
deleted file mode 100644 (file)
index 765c69c..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_H__
-#define __MURPHY_SIGNALLING_H__
-
-#include <stdint.h>
-#include <murphy/common.h>
-
-typedef enum {
-    MRP_TX_ERROR_UNDEFINED,
-    MRP_TX_ERROR_NOT_ANSWERED,
-    MRP_TX_ERROR_NACKED,
-    MRP_TX_ERROR_MAX
-} mrp_tx_error_t;
-
-typedef void (*mrp_tx_success_cb) (uint32_t tx, void *data);
-typedef void (*mrp_tx_error_cb) (uint32_t tx, mrp_tx_error_t err, void *data);
-typedef void (*mrp_info_cb) (char *msg, void *data);
-
-
-#if 0
-/* These functions are exported via Murphy method export interface.
- * The function definitions are commented away so that they wouldn't
- * interfere with the importing functionality.
- */
-
-
-/** Opens a new signal. Returns the assigned signal 'tx'. */
-
-uint32_t mrp_tx_open_signal();
-
-/** Adds a policy domain to the signal identified by 'tx'. */
-
-int mrp_tx_add_domain(uint32_t tx, const char *domain);
-
-/** Adds a data row to the signal identified by 'tx'. */
-
-int mrp_tx_add_data(uint32_t tx, const char *row);
-
-/** Adds a success callback to the signal identified by 'tx'. The callback
-    will be called if the signal is successfully ACKed by all enforcement
-    points registered to listen for the domains. If the success or error
-    callback isn't set, the enforcement points are not required to reply
-    to the signal.*/
-
-void mrp_tx_add_success_cb(uint32_t tx, mrp_tx_success_cb cb, void *data);
-
-/** Adds an error callback to the signal identified by 'tx'. The callback
-    will be called if the signal is NACKed or not answered to by one or more
-    enforcement points registered to listen for the domains. If the success
-    or error callback isn't set, the enforcement points are not required to
-    reply to the signal.*/
-
-void mrp_tx_add_error_cb(uint32_t tx, mrp_tx_error_cb cb, void *data);
-
-/** Closes the signal identified by 'tx' and sends it onward to the enforcement
-    points. Returns a negative value if the transaction cannot be found. */
-
-int mrp_tx_close_signal(uint32_t tx);
-
-/** Cancels a signal identified by 'tx'.*/
-
-void mrp_tx_cancel_signal(uint32_t tx);
-
-/** Register a backchannel handler for extra messages coming from the
-    enforcement point identified by 'client_id'. Returns negative value
-    if the handler was already registered. */
-
-int mrp_info_register(char *client_id, mrp_info_cb cb, void *data);
-
-/** Unregister a backchannel handler for enforcement point identified by
-    'client_id'. */
-
-void mrp_info_unregister(char *client_id);
-#endif
-
-
-#endif /* __MURPHY_SIGNALLING_H__ */
diff --git a/src/plugins/signalling/transaction.c b/src/plugins/signalling/transaction.c
deleted file mode 100644 (file)
index 9dce35a..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-#include <murphy/plugins/signalling/signalling.h>
-
-#include "plugin.h"
-#include "util.h"
-#include "client.h"
-#include "transaction.h"
-
-extern mrp_plugin_t *signalling_plugin;
-
-
-void free_transaction(transaction_t *tx)
-{
-    uint i;
-
-    if (tx->timer)
-        mrp_del_timer(tx->timer);
-
-    for (i = 0; i < tx->data.n_rows; i++) {
-        mrp_free(tx->data.rows[i]);
-    }
-    mrp_free(tx->data.rows);
-
-    for (i = 0; i < tx->data.n_domains; i++) {
-        mrp_free(tx->data.domains[i]);
-    }
-    mrp_free(tx->data.domains);
-
-    mrp_free(tx->acked);
-    mrp_free(tx->nacked);
-    mrp_free(tx->not_answered);
-
-    mrp_free(tx);
-}
-
-
-transaction_t *get_transaction(data_t *ctx, uint32_t id)
-{
-    return mrp_htbl_lookup(ctx->txs, u_to_p(id));
-}
-
-
-void put_transaction(data_t *ctx, transaction_t *tx)
-{
-    mrp_htbl_insert(ctx->txs, u_to_p(tx->id), tx);
-}
-
-
-void remove_transaction(data_t *ctx, transaction_t *tx)
-{
-    mrp_htbl_remove(ctx->txs, u_to_p(tx->id), TRUE);
-}
-
-
-static uint32_t assign_id(data_t *ctx)
-{
-    return ctx->next_id++;
-}
-
-
-static bool domain_match(client_t *c, transaction_t *tx)
-{
-    uint i, j;
-
-    for (i = 0; i < tx->data.n_domains; i++) {
-        for (j = 0; j < c->ndomains; j++) {
-            if (strcmp(tx->data.domains[i], c->domains[j]) == 0) {
-                return TRUE;
-            }
-        }
-    }
-    return FALSE;
-}
-
-
-static int is_interested(void *key, void *entry, void *user_data)
-{
-    transaction_t *tx = user_data;
-    client_t *c = entry;
-
-    MRP_UNUSED(key);
-
-    if (!tx || !c)
-        return MRP_HTBL_ITER_STOP;
-
-    if (domain_match(c, tx)) {
-        tx->not_answered[tx->n_not_answered++] = c->name;
-    }
-
-    return MRP_HTBL_ITER_MORE;
-}
-
-
-static void signalling_timeout(mrp_mainloop_t *ml, mrp_timer_t *timer,
-                             void *user_data)
-{
-    uint32_t id = p_to_u(user_data);
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    MRP_UNUSED(ml);
-    MRP_UNUSED(timer);
-
-    tx = get_transaction(ctx, id);
-
-    if (tx) {
-        complete_transaction(ctx, tx);
-    }
-}
-
-
-int fire_transaction(data_t *ctx, transaction_t *tx)
-{
-    /* TODO: make proper queuing */
-
-    uint i;
-
-    if (tx->n_not_answered == 0) {
-        /* no-one is interested in the decision */
-        complete_transaction(ctx, tx);
-        return 0;
-    }
-
-    for (i = 0; i < tx->n_not_answered; i++) {
-        client_t *c = mrp_htbl_lookup(ctx->clients, tx->not_answered[i]);
-        if (send_policy_decision(ctx, c, tx) < 0) {
-            signalling_error("Failed to send policy decision to %s", c->name);
-#if 0
-            complete_transaction(ctx, tx);
-            return -1;
-#endif
-        }
-    }
-
-    mrp_add_timer(ctx->ctx->ml, tx->timeout, signalling_timeout,
-            u_to_p(tx->id));
-
-    return 0;
-}
-
-
-void complete_transaction(data_t *ctx, transaction_t *tx)
-{
-    /* call the transaction callbacks */
-
-    if (tx->n_not_answered == 0 && tx->n_acked == tx->n_total) {
-        if (tx->data.success_cb)
-            tx->data.success_cb(tx->id, tx->data.success_data);
-    }
-    else if (tx->n_nacked > 0 ){
-        if (tx->data.error_cb)
-            tx->data.error_cb(tx->id, MRP_TX_ERROR_NACKED, tx->data.error_data);
-    }
-    else {
-        if (tx->data.error_cb)
-            tx->data.error_cb(tx->id, MRP_TX_ERROR_NOT_ANSWERED, tx->data.error_data);
-    }
-
-    /* remove the transaction from the list */
-    remove_transaction(ctx, tx);
-}
-
-
-static uint32_t mrp_tx_open_signal_with_id(uint32_t id)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = mrp_allocz(sizeof(transaction_t));
-    tx->id = id;
-    tx->data.row_array_size = 32;
-    tx->data.rows = mrp_allocz(tx->data.row_array_size);
-    tx->timeout = MRP_SiGNALLING_DEFAULT_TIMEOUT;
-
-    tx->data.domain_array_size = 8;
-    tx->data.domains = mrp_allocz(tx->data.domain_array_size);
-
-    put_transaction(ctx, tx);
-
-    return id;
-}
-
-
-uint32_t _mrp_tx_open_signal()
-{
-    data_t *ctx = signalling_plugin->data;
-
-    return mrp_tx_open_signal_with_id(assign_id(ctx));
-}
-
-
-int _mrp_tx_add_domain(uint32_t id, const char *domain)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = get_transaction(ctx, id);
-
-    if (!tx)
-        return -1;
-
-    tx->data.domains[tx->data.n_domains++] = mrp_strdup(domain);
-
-    if (tx->data.n_domains == tx->data.domain_array_size) {
-        tx->data.n_domains *= 2;
-        tx->data.domains = mrp_realloc(tx->data.domains, tx->data.n_domains);
-    }
-
-    return 0;
-}
-
-
-int _mrp_tx_add_data(uint32_t id, const char *row)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = get_transaction(ctx, id);
-
-    if (!tx)
-        return -1;
-
-    tx->data.rows[tx->data.n_rows++] = mrp_strdup(row);
-
-    if (tx->data.n_rows == tx->data.row_array_size) {
-        tx->data.n_rows *= 2;
-        tx->data.rows = mrp_realloc(tx->data.rows, tx->data.n_rows);
-    }
-
-    return 0;
-}
-
-
-void _mrp_tx_add_success_cb(uint32_t id, mrp_tx_success_cb cb, void *data)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = get_transaction(ctx, id);
-
-    if (tx) {
-        tx->data.success_cb = cb;
-        tx->data.success_data = data;
-    }
-}
-
-
-void _mrp_tx_add_error_cb(uint32_t id, mrp_tx_error_cb cb, void *data)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = get_transaction(ctx, id);
-
-    if (tx) {
-        tx->data.error_cb = cb;
-        tx->data.error_data = data;
-    }
-}
-
-
-int _mrp_tx_close_signal(uint32_t id)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = get_transaction(ctx, id);
-
-    if (tx) {
-        /* allocate the client arrays */
-
-        tx->acked = mrp_allocz_array(char *, ctx->n_clients);
-        tx->nacked = mrp_allocz_array(char *, ctx->n_clients);
-        tx->not_answered = mrp_allocz_array(char *, ctx->n_clients);
-
-        mrp_htbl_foreach(ctx->clients, is_interested, tx);
-
-        tx->n_total = tx->n_not_answered;
-        return fire_transaction(ctx, tx);
-    }
-    return -1;
-}
-
-
-void _mrp_tx_cancel_signal(uint32_t id)
-{
-    data_t *ctx = signalling_plugin->data;
-    transaction_t *tx;
-
-    tx = get_transaction(ctx, id);
-
-    if (tx) {
-        remove_transaction(ctx, tx);
-    }
-}
diff --git a/src/plugins/signalling/transaction.h b/src/plugins/signalling/transaction.h
deleted file mode 100644 (file)
index 02b117f..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_TRANSACTION_H__
-#define __MURPHY_SIGNALLING_TRANSACTION_H__
-
-#include <stdint.h>
-
-#include <murphy/common.h>
-#include <murphy/plugins/signalling/signalling.h>
-
-#include "plugin.h"
-
-#define MRP_SiGNALLING_DEFAULT_TIMEOUT 5000 /* msecs */
-
-typedef struct {
-    char **domains;
-    uint32_t n_domains;
-    uint32_t domain_array_size;
-    char **rows;
-    uint32_t n_rows;
-    uint32_t row_array_size;
-
-    mrp_tx_success_cb success_cb;
-    void *success_data;
-    mrp_tx_error_cb error_cb;
-    void *error_data;
-} transaction_data_t;
-
-/* an ongoing transaction */
-typedef struct {
-    uint32_t id;         /* The real ID. */
-    uint32_t caller_id;  /* TODO: id assigned by caller. */
-    uint32_t timeout;
-    mrp_timer_t *timer;
-
-    char **acked;
-    char **nacked;
-    char **not_answered;
-
-    uint n_acked;
-    uint n_nacked;
-    uint n_not_answered;
-
-    uint n_total;
-    transaction_data_t data;
-} transaction_t;
-
-
-int fire_transaction(data_t *ctx, transaction_t *tx);
-
-void complete_transaction(data_t *ctx, transaction_t *tx);
-
-void free_transaction(transaction_t *tx);
-transaction_t *get_transaction(data_t *ctx, uint32_t id);
-void put_transaction(data_t *ctx, transaction_t *tx);
-void remove_transaction(data_t *ctx, transaction_t *tx);
-
-/* exported functions */
-uint32_t _mrp_tx_open_signal();
-int _mrp_tx_add_domain(uint32_t id, const char *domain);
-int _mrp_tx_add_data(uint32_t id, const char *row);
-void _mrp_tx_add_success_cb(uint32_t id, mrp_tx_success_cb cb, void *data);
-void _mrp_tx_add_error_cb(uint32_t id, mrp_tx_error_cb cb, void *data);
-int _mrp_tx_close_signal(uint32_t id);
-void _mrp_tx_cancel_signal(uint32_t id);
-
-
-#endif /* __MURPHY_SIGNALLING_TRANSACTION_H__ */
diff --git a/src/plugins/signalling/util.c b/src/plugins/signalling/util.c
deleted file mode 100644 (file)
index 21fa049..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-
-#include "util.h"
-
-void *u_to_p(uint32_t u)
-{
-#ifdef __SIZEOF_POINTER__
-#if __SIZEOF_POINTER__ == 8
-    uint64_t o = u;
-#else
-    uint32_t o = u;
-#endif
-#else
-    uint32_t o = o;
-#endif
-    return (void *) o;
-}
-
-uint32_t p_to_u(const void *p)
-{
-#ifdef __SIZEOF_POINTER__
-#if __SIZEOF_POINTER__ == 8
-    uint32_t o = 0;
-    uint64_t big = (uint64_t) p;
-    o = big & 0xffffffff;
-#else
-    uint32_t o = (uint32_t) p;
-#endif
-#else
-    uint32_t o = p;
-#endif
-    return o;
-}
-
-
-int int_comp(const void *key1, const void *key2)
-{
-    return key1 != key2;
-}
-
-
-uint32_t int_hash(const void *key)
-{
-    return p_to_u(key);
-}
diff --git a/src/plugins/signalling/util.h b/src/plugins/signalling/util.h
deleted file mode 100644 (file)
index 9ad98a8..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MURPHY_SIGNALLING_UTIL_H__
-#define __MURPHY_SIGNALLING_UTIL_H__
-
-#include <stdint.h>
-
-#define signalling_info(fmt, args...)  mrp_log_info("signalling: "fmt , ## args)
-#define signalling_warn(fmt, args...)  mrp_log_warning("signalling: "fmt , ## args)
-#define signalling_error(fmt, args...) mrp_log_error("signalling: "fmt , ## args)
-
-void *u_to_p(uint32_t u);
-uint32_t p_to_u(const void *p);
-int int_comp(const void *key1, const void *key2);
-uint32_t int_hash(const void *key);
-
-#endif /* __MURPHY_SIGNALLING_UTIL_H__ */
index 791081e..b518650 100644 (file)
@@ -1,8 +1,4 @@
 AM_CFLAGS = $(WARNING_CFLAGS) -I$(top_builddir)
 
-noinst_PROGRAMS  = signalling-test
+noinst_PROGRAMS  = 
 
-# signalling test
-signalling_test_SOURCES = signalling-client.c
-signalling_test_CFLAGS  = $(AM_CFLAGS)
-signalling_test_LDADD   = ../../libmurphy-common.la
diff --git a/src/plugins/tests/signalling-client.c b/src/plugins/tests/signalling-client.c
deleted file mode 100644 (file)
index 12e25e5..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <murphy/common.h>
-#include <murphy/core.h>
-#include <murphy/plugins/signalling/signalling-protocol.h>
-
-#define _GNU_SOURCE
-#include <getopt.h>
-
-#define MAX_DOMAINS 32
-
-typedef struct {
-    mrp_transport_t *t;
-    mrp_mainloop_t *ml;
-
-    char *name;
-    char *info;
-    char *domains[MAX_DOMAINS];
-    uint n_domains;
-    bool ack;
-} client_t;
-
-
-static void dump_decision(client_t *c, ep_decision_t *msg)
-{
-    uint i;
-
-    MRP_UNUSED(c);
-
-    printf("Message contents:\n");
-    for (i = 0; i < msg->n_rows; i++) {
-        printf("row %d: '%s'\n", i+1, msg->rows[i]);
-    }
-    printf("%s required.\n\n", msg->reply_required ? "Reply" : "No reply");
-}
-
-
-static int send_info(client_t *c, char *data)
-{
-    ep_info_t msg;
-    int ret;
-
-    printf("sending info message '%s'\n", data);
-
-    msg.msg = data;
-
-    ret = mrp_transport_senddata(c->t, &msg, TAG_INFO);
-
-    if (!ret) {
-        printf("failed to send info message\n");
-    }
-
-    return ret;
-}
-
-
-static int send_registration(client_t *c)
-{
-    ep_register_t msg;
-    int ret;
-
-    msg.ep_name = c->name;
-    msg.domains = c->domains;
-    msg.n_domains = c->n_domains;
-
-    ret = mrp_transport_senddata(c->t, &msg, TAG_REGISTER);
-
-    if (!ret) {
-        printf("failed to send register message\n");
-    }
-
-    return ret;
-}
-
-
-static int send_reply(client_t *c, ep_decision_t *msg, uint32_t success)
-{
-    ep_ack_t reply;
-    int ret;
-
-    reply.id = msg->id;
-    reply.success = success;
-
-    ret = mrp_transport_senddata(c->t, &reply, TAG_ACK);
-
-    if (!ret) {
-        printf("failed to send reply\n");
-    }
-
-    return ret;
-}
-
-
-static void handle_decision(client_t *c, ep_decision_t *msg)
-{
-    printf("Handle decision\n");
-
-    dump_decision(c, msg);
-
-    if (msg->reply_required)
-        send_reply(c, msg, c->ack ? EP_ACK: EP_NACK);
-
-    /* try sending an info signal here */
-    if (c->info) {
-        send_info(c, c->info);
-    }
-}
-
-
-static void closed_evt(mrp_transport_t *t, int error, void *user_data)
-{
-    client_t *c = user_data;
-
-    MRP_UNUSED(t);
-    MRP_UNUSED(error);
-
-    printf("Received closed event\n");
-
-    mrp_mainloop_quit(c->ml, 0);
-}
-
-
-static void recvfrom_evt(mrp_transport_t *t, void *data, uint16_t tag,
-             mrp_sockaddr_t *addr, socklen_t addrlen, void *user_data)
-{
-    client_t *c = user_data;
-
-    MRP_UNUSED(addr);
-    MRP_UNUSED(addrlen);
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(t);
-
-    printf("Received message (0x%02x)\n", tag);
-
-    switch (tag) {
-        case TAG_POLICY_DECISION:
-            handle_decision(c, data);
-            break;
-        case TAG_ERROR:
-            printf("Server sends an error message!\n");
-            break;
-        default:
-            /* no other messages supported ATM */
-            break;
-    }
-
-    mrp_data_free(data, tag);
-}
-
-
-static void recv_evt(mrp_transport_t *t, void *data, uint16_t tag, void *user_data)
-{
-    recvfrom_evt(t, data, tag, NULL, 0, user_data);
-}
-
-
-static void print_usage(const char *argv0)
-{
-    printf("usage: %s -i <id> [options]\n\n"
-           "The possible options are:\n"
-           "  -n, --nack                     send NACKs instead of ACKs\n"
-           "  -d, --domain                   specify a policy domain\n"
-           "  -h, --help                     show help on usage\n",
-           argv0);
-}
-
-
-static int add_domain(client_t *c, char *domain)
-{
-     if (c->n_domains >= MAX_DOMAINS)
-        return -1;
-
-    c->domains[c->n_domains++] = mrp_strdup(domain);
-
-    return 0;
-}
-
-
-static int parse_cmdline(client_t *c, int argc, char **argv)
-{
-#   define OPTIONS "nd:i:I:h"
-    struct option options[] = {
-        { "nack"  , no_argument      , NULL, 'n' },
-        { "domain", required_argument, NULL, 'd' },
-        { "id"    , required_argument, NULL, 'i' },
-        { "info"  , required_argument, NULL, 'I' },
-        { "help"  , no_argument      , NULL, 'h' },
-        { NULL, 0, NULL, 0 }
-    };
-
-    int opt;
-
-    while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
-        switch (opt) {
-        case 'n':
-            c->ack = FALSE;
-            break;
-
-        case 'd':
-            if (add_domain(c, optarg) < 0) {
-                return FALSE;
-            }
-            break;
-
-        case 'i':
-            c->name = mrp_strdup(optarg);
-            break;
-
-        case 'I':
-            c->info = mrp_strdup(optarg);
-            break;
-
-        case 'h':
-            print_usage(argv[0]);
-            exit(0);
-            break;
-
-        default:
-            print_usage(argv[0]);
-            return FALSE;
-        }
-    }
-
-    return TRUE;
-}
-
-
-static void free_client(client_t *c)
-{
-    /* TODO: delete the transport */
-
-    for (; c->n_domains > 0; c->n_domains--)
-        mrp_free(c->domains[c->n_domains-1]);
-
-    mrp_free(c->info);
-    mrp_free(c->name);
-}
-
-
-int main(int argc, char **argv)
-{
-    socklen_t alen;
-    mrp_sockaddr_t addr;
-    int ret, flags;
-
-    client_t client;
-    static mrp_transport_evt_t evt; /* static members are initialized to zero */
-
-    client.name = NULL;
-    client.info = NULL;
-    client.n_domains = 0;
-    client.ack = TRUE;
-
-    if (!parse_cmdline(&client, argc, argv)) {
-        goto error;
-    }
-
-    if (!client.name) {
-        printf("Error: 'id' is a mandatory argument!\n");
-        print_usage(argv[0]);
-        goto error;
-    }
-
-    evt.closed = closed_evt;
-    evt.recvdatafrom = recvfrom_evt;
-    evt.recvdata = recv_evt;
-
-    if (!mrp_msg_register_type(&ep_register_descr) ||
-        !mrp_msg_register_type(&ep_decision_descr) ||
-        !mrp_msg_register_type(&ep_ack_descr) ||
-        !mrp_msg_register_type(&ep_info_descr)) {
-        printf("Error: registering data types failed!\n");
-        goto error;
-    }
-
-    client.ml = mrp_mainloop_create();
-
-    flags = MRP_TRANSPORT_REUSEADDR | MRP_TRANSPORT_MODE_CUSTOM;
-
-    client.t = mrp_transport_create(client.ml, "unxs", &evt, &client, flags);
-    if (client.t == NULL) {
-        printf("Error: creating a new transport failed!\n");
-        goto error;
-    }
-
-    alen = mrp_transport_resolve(NULL, "unxs:/tmp/murphy/signalling", &addr, sizeof(addr), NULL);
-    if (alen <= 0) {
-        printf("Error: resolving address failed!\n");
-        goto error;
-    }
-
-
-    ret = mrp_transport_connect(client.t, &addr, alen);
-    if (ret == 0) {
-        printf("Error: connect failed!\n");
-        goto error;
-    }
-
-    send_registration(&client);
-
-    mrp_mainloop_run(client.ml);
-
-    free_client(&client);
-
-    return 0;
-
-error:
-    free_client(&client);
-    return 1;
-}