summaryrefslogtreecommitdiff
path: root/broccoli/src
diff options
context:
space:
mode:
authorRobin Krahl <guskraro@student.gu.se>2017-10-04 14:51:12 +0200
committerAndreas Lindhé <andreas@lindhe.io>2017-10-09 12:14:35 +0200
commita0095ef4c4ef74d3726e58dea5f04cb55f2a6a20 (patch)
tree234c7fb0d8d6cb23d32a3d3db1de3d79e1793f3b /broccoli/src
parentc0c910535b03a7565dd57e2f8dddecf0ad6714df (diff)
downloadmidbro-a0095ef4c4ef74d3726e58dea5f04cb55f2a6a20.tar.gz
midbro-a0095ef4c4ef74d3726e58dea5f04cb55f2a6a20.tar.bz2
broevent: Combine the pasad-parsed script with midbro
Diffstat (limited to 'broccoli/src')
-rw-r--r--broccoli/src/broevent.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/broccoli/src/broevent.c b/broccoli/src/broevent.c
index 3813270..8a74881 100644
--- a/broccoli/src/broevent.c
+++ b/broccoli/src/broevent.c
@@ -9,13 +9,29 @@ char *port_default = "47760";
Fifo_q * q;
static void
-bro_response(BroConn *conn, void *data, uint64* registers, uint64* uid)
+pasad_register_received(BroConn *conn, void *data, BroRecord *record)
{
- add_to_queue(q,create_sensor_object(*registers,*uid));
- //printf("Received value %"PRIu64" from uid=%"PRIu64"\n",*registers,*uid);
+ int type = BRO_TYPE_COUNT;
+ uint64 *address = NULL;
+ uint64 *value = NULL;
- conn = NULL;
- data = NULL;
+ // TODO: handle regtype
+ address = bro_record_get_named_val(record, "address", &type);
+ if (!address) {
+ // TODO: handle error
+ return;
+ }
+ value = bro_record_get_named_val(record, "register", &type);
+ if (!value) {
+ // TODO: handle error
+ return;
+ }
+
+ printf("Received value %"PRIu64" from uid=%"PRIu64"\n",*value,*address);
+
+ add_to_queue(q, create_sensor_object(*value, *address));
+
+ printf("Added to queue.\n");
}
void *
@@ -36,7 +52,8 @@ bro_event_listener(void * args)
bro_debug_calltrace = 0;
bro_debug_messages = 0;
- bro_event_registry_add(bc, "response",(BroEventFunc) bro_response, NULL);
+ bro_event_registry_add(bc, "pasad_register_received",
+ (BroEventFunc) pasad_register_received, NULL);
if (! bro_conn_connect(bc))
{