aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2019-11-13 17:05:06 +0100
committerJose Bollo <jose.bollo@iot.bzh>2019-11-20 09:30:07 +0100
commit2243df148acbb5efa1a62aa23da99d87600023aa (patch)
tree1f78d21a69ec6c41c45e65e6eb08a10a8afd8737
parent5026e71d56ed5240ea39e114204686c5dc62c76e (diff)
afb-api-dbus: Fix broken broadcast in dbus apis
Probably because of conditional compiling, afb-api-dbus was broken since introduction of uuid and hops in broadcats. This change fixes this issue. Bug-AGL: SPEC-2969 Change-Id: I9a0fd8552f5f61d6eafa1ed83f6e09e6474378ff Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-api-dbus.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c
index 139c6472..31606be6 100644
--- a/src/afb-api-dbus.c
+++ b/src/afb-api-dbus.c
@@ -368,15 +368,19 @@ static int api_dbus_client_on_broadcast_event(sd_bus_message *m, void *userdata,
{
struct json_object *object;
const char *event, *data;
+ const unsigned char *uuid;
+ size_t szuuid;
+ uint8_t hop;
enum json_tokener_error jerr;
- int rc = sd_bus_message_read(m, "ss", &event, &data);
+
+ int rc = sd_bus_message_read(m, "ssayy", &event, &data, &uuid, &szuuid, &hop);
if (rc < 0)
ERROR("unreadable broadcasted event");
else {
object = json_tokener_parse_verbose(data, &jerr);
if (jerr != json_tokener_success)
object = json_object_new_string(data);
- afb_evt_broadcast(event, object);
+ afb_evt_rebroadcast(event, object, uuid, hop);
}
return 1;
}
@@ -635,7 +639,7 @@ error:
static void afb_api_dbus_server_event_add(void *closure, const char *event, int eventid);
static void afb_api_dbus_server_event_remove(void *closure, const char *event, int eventid);
static void afb_api_dbus_server_event_push(void *closure, const char *event, int eventid, struct json_object *object);
-static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const char *uuid);
+static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop);
/* the interface for events broadcasting */
static const struct afb_evt_itf evt_broadcast_itf = {
@@ -917,14 +921,15 @@ static void afb_api_dbus_server_event_push(void *closure, const char *event, int
json_object_put(object);
}
-static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const char *uuid)
+static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop)
{
int rc;
struct api_dbus *api;
api = closure;
rc = sd_bus_emit_signal(api->sdbus, api->path, api->name, "broadcast",
- "ss", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE));
+ "ssayy", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE),
+ uuid, UUID_BINARY_LENGTH, hop);
if (rc < 0)
ERROR("error while broadcasting event %s", event);
json_object_put(object);