diff options
Diffstat (limited to 'aclk/schema-wrappers')
-rw-r--r-- | aclk/schema-wrappers/alarm_stream.cc | 4 | ||||
-rw-r--r-- | aclk/schema-wrappers/capability.cc | 11 | ||||
-rw-r--r-- | aclk/schema-wrappers/capability.h | 24 | ||||
-rw-r--r-- | aclk/schema-wrappers/connection.cc | 9 | ||||
-rw-r--r-- | aclk/schema-wrappers/connection.h | 4 | ||||
-rw-r--r-- | aclk/schema-wrappers/node_creation.h | 6 | ||||
-rw-r--r-- | aclk/schema-wrappers/node_info.cc | 18 | ||||
-rw-r--r-- | aclk/schema-wrappers/node_info.h | 4 | ||||
-rw-r--r-- | aclk/schema-wrappers/schema_wrappers.h | 1 |
9 files changed, 77 insertions, 4 deletions
diff --git a/aclk/schema-wrappers/alarm_stream.cc b/aclk/schema-wrappers/alarm_stream.cc index 5868e5d6..338e512d 100644 --- a/aclk/schema-wrappers/alarm_stream.cc +++ b/aclk/schema-wrappers/alarm_stream.cc @@ -176,8 +176,10 @@ char *generate_alarm_log_entry(size_t *len, struct alarm_log_entry *data) *len = PROTO_COMPAT_MSG_SIZE(le); char *bin = (char*)mallocz(*len); - if (!le.SerializeToArray(bin, *len)) + if (!le.SerializeToArray(bin, *len)) { + freez(bin); return NULL; + } return bin; } diff --git a/aclk/schema-wrappers/capability.cc b/aclk/schema-wrappers/capability.cc new file mode 100644 index 00000000..769806f9 --- /dev/null +++ b/aclk/schema-wrappers/capability.cc @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "proto/aclk/v1/lib.pb.h" + +#include "capability.h" + +void capability_set(aclk_lib::v1::Capability *proto_capa, struct capability *c_capa) { + proto_capa->set_name(c_capa->name); + proto_capa->set_enabled(c_capa->enabled); + proto_capa->set_version(c_capa->version); +} diff --git a/aclk/schema-wrappers/capability.h b/aclk/schema-wrappers/capability.h new file mode 100644 index 00000000..9517a871 --- /dev/null +++ b/aclk/schema-wrappers/capability.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef ACLK_SCHEMA_CAPABILITY_H +#define ACLK_SCHEMA_CAPABILITY_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct capability { + const char *name; + uint32_t version; + int enabled; +}; + +#ifdef __cplusplus +} + +#include "proto/aclk/v1/lib.pb.h" + +void capability_set(aclk_lib::v1::Capability *proto_capa, struct capability *c_capa); +#endif + +#endif /* ACLK_SCHEMA_CAPABILITY_H */ diff --git a/aclk/schema-wrappers/connection.cc b/aclk/schema-wrappers/connection.cc index e3bbfe31..7520a460 100644 --- a/aclk/schema-wrappers/connection.cc +++ b/aclk/schema-wrappers/connection.cc @@ -28,6 +28,15 @@ char *generate_update_agent_connection(size_t *len, const update_agent_connectio timestamp->set_seconds(tv.tv_sec); timestamp->set_nanos(tv.tv_usec * 1000); + if (data->capabilities) { + struct capability *capa = data->capabilities; + while (capa->name) { + aclk_lib::v1::Capability *proto_capa = connupd.add_capabilities(); + capability_set(proto_capa, capa); + capa++; + } + } + *len = PROTO_COMPAT_MSG_SIZE(connupd); char *msg = (char*)malloc(*len); if (msg) diff --git a/aclk/schema-wrappers/connection.h b/aclk/schema-wrappers/connection.h index 8c223869..fcbe6bd5 100644 --- a/aclk/schema-wrappers/connection.h +++ b/aclk/schema-wrappers/connection.h @@ -3,6 +3,8 @@ #ifndef ACLK_SCHEMA_WRAPPER_CONNECTION_H #define ACLK_SCHEMA_WRAPPER_CONNECTION_H +#include "capability.h" + #ifdef __cplusplus extern "C" { #endif @@ -15,6 +17,8 @@ typedef struct { unsigned int lwt:1; + struct capability *capabilities; + // TODO in future optional fields // > 15 optional fields: // How long the system was running until connection (only applicable when reachable=true) diff --git a/aclk/schema-wrappers/node_creation.h b/aclk/schema-wrappers/node_creation.h index 71e45ef5..190ccb4d 100644 --- a/aclk/schema-wrappers/node_creation.h +++ b/aclk/schema-wrappers/node_creation.h @@ -8,9 +8,9 @@ extern "C" { #endif typedef struct { - const char* claim_id; - const char* machine_guid; - const char* hostname; + char* claim_id; + char* machine_guid; + char* hostname; int32_t hops; } node_instance_creation_t; diff --git a/aclk/schema-wrappers/node_info.cc b/aclk/schema-wrappers/node_info.cc index f6f15ffb..f6698524 100644 --- a/aclk/schema-wrappers/node_info.cc +++ b/aclk/schema-wrappers/node_info.cc @@ -94,6 +94,24 @@ char *generate_update_node_info_message(size_t *len, struct update_node_info *in ml_info->set_ml_capable(info->ml_info.ml_capable); ml_info->set_ml_enabled(info->ml_info.ml_enabled); + struct capability *capa; + if (info->node_capabilities) { + capa = info->node_capabilities; + while (capa->name) { + aclk_lib::v1::Capability *proto_capa = msg.mutable_node_info()->add_capabilities(); + capability_set(proto_capa, capa); + capa++; + } + } + if (info->node_instance_capabilities) { + capa = info->node_instance_capabilities; + while (capa->name) { + aclk_lib::v1::Capability *proto_capa = msg.mutable_node_instance_info()->add_capabilities(); + capability_set(proto_capa, capa); + capa++; + } + } + *len = PROTO_COMPAT_MSG_SIZE(msg); char *bin = (char*)malloc(*len); if (bin) diff --git a/aclk/schema-wrappers/node_info.h b/aclk/schema-wrappers/node_info.h index 41daf94c..e67f3e1d 100644 --- a/aclk/schema-wrappers/node_info.h +++ b/aclk/schema-wrappers/node_info.h @@ -6,6 +6,7 @@ #include <stdlib.h> #include "database/rrd.h" +#include "capability.h" #ifdef __cplusplus extern "C" { @@ -67,6 +68,9 @@ struct update_node_info { int child; struct machine_learning_info ml_info; + + struct capability *node_capabilities; + struct capability *node_instance_capabilities; }; char *generate_update_node_info_message(size_t *len, struct update_node_info *info); diff --git a/aclk/schema-wrappers/schema_wrappers.h b/aclk/schema-wrappers/schema_wrappers.h index a3975fca..a3248a69 100644 --- a/aclk/schema-wrappers/schema_wrappers.h +++ b/aclk/schema-wrappers/schema_wrappers.h @@ -13,5 +13,6 @@ #include "alarm_config.h" #include "alarm_stream.h" #include "node_info.h" +#include "capability.h" #endif /* SCHEMA_WRAPPERS_H */ |