From 450b9eaee93d5819caaa9889a49a02f41bf48993 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Fri, 27 Nov 2020 10:52:16 +0100 Subject: [PATCH] Align XMPP & UDPEchoserver & TWAMP with latest bbf changes --- bulkdata/src/datamodel.c | 1 - twamp/src/datamodel.c | 12 ++++++------ xmpp/src/datamodel.c | 17 ++++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bulkdata/src/datamodel.c b/bulkdata/src/datamodel.c index b06a3ae80..d033471a0 100644 --- a/bulkdata/src/datamodel.c +++ b/bulkdata/src/datamodel.c @@ -114,7 +114,6 @@ static int addObjBulkDataProfile(char *refparam, struct dmctx *ctx, void *data, struct uci_section *profile, *dmmap_bulkdata; char prof_id[16], *last_inst = NULL; - check_create_dmmap_package("dmmap_bulkdata"); last_inst = get_last_instance_bbfdm("dmmap_bulkdata", "profile", "profile_instance"); snprintf(prof_id, sizeof(prof_id), "%d", last_inst ? atoi(last_inst)+1 : 1); diff --git a/twamp/src/datamodel.c b/twamp/src/datamodel.c index 5110911cc..73724ebab 100644 --- a/twamp/src/datamodel.c +++ b/twamp/src/datamodel.c @@ -55,13 +55,13 @@ struct ip_args static int addObjIPInterfaceTWAMPReflector(char *refparam, struct dmctx *ctx, void *data, char **instance) { - struct uci_section *connection; - char *value1, *last_inst, *id; + struct uci_section *connection = NULL; - last_inst = get_last_instance_with_option("twamp", "twamp_reflector", "interface", section_name(((struct ip_args *)data)->ip_sec), "twamp_inst"); - id = get_last_id("twamp", "twamp_reflector"); - dmuci_add_section("twamp", "twamp_reflector", &connection, &value1); - dmasprintf(instance, "%d", last_inst?atoi(last_inst)+1:1); + char *last_inst = get_last_instance_with_option("twamp", "twamp_reflector", "interface", section_name(((struct ip_args *)data)->ip_sec), "twamp_inst"); + char *id = get_last_id("twamp", "twamp_reflector"); + + dmuci_add_section("twamp", "twamp_reflector", &connection); + dmasprintf(instance, "%d", last_inst ? atoi(last_inst)+1 : 1); dmuci_set_value_by_section(connection, "twamp_inst", *instance); dmuci_set_value_by_section(connection, "id", id); dmuci_set_value_by_section(connection, "enable", "0"); diff --git a/xmpp/src/datamodel.c b/xmpp/src/datamodel.c index ba6365e2a..a3e0eb50c 100644 --- a/xmpp/src/datamodel.c +++ b/xmpp/src/datamodel.c @@ -25,30 +25,29 @@ LIB_MAP_OBJ tRootDynamicObj[] = { static int add_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char **instance) { - struct uci_section *xmpp_con, *xmpp_con_srv, *dmmap_xmpp; - char *con_name, *con_srv_name, *last_inst, *v, *id; + struct uci_section *xmpp_con = NULL, *xmpp_con_srv = NULL, *dmmap_xmpp = NULL; + char id[16]; - check_create_dmmap_package("dmmap_xmpp"); - last_inst = get_last_instance_bbfdm("dmmap_xmpp", "connection", "con_inst"); - dmasprintf(&id, "%d", (last_inst) ? atoi(last_inst) + 1 : 1); + char *last_inst = get_last_instance_bbfdm("dmmap_xmpp", "connection", "con_inst"); + snprintf(id, sizeof(id), "%d", (last_inst) ? atoi(last_inst) + 1 : 1); - dmuci_add_section("xmpp", "connection", &xmpp_con, &con_name); + dmuci_add_section("xmpp", "connection", &xmpp_con); dmuci_set_value_by_section(xmpp_con, "xmpp_id", id); dmuci_set_value_by_section(xmpp_con, "enable", "0"); dmuci_set_value_by_section(xmpp_con, "interval", "30"); dmuci_set_value_by_section(xmpp_con, "attempt", "16"); dmuci_set_value_by_section(xmpp_con, "serveralgorithm", "DNS-SRV"); - dmuci_add_section("xmpp", "connection_server", &xmpp_con_srv, &con_srv_name); + dmuci_add_section("xmpp", "connection_server", &xmpp_con_srv); dmuci_set_value_by_section(xmpp_con_srv, "con_id", id); dmuci_set_value_by_section(xmpp_con_srv, "enable", "0"); dmuci_set_value_by_section(xmpp_con_srv, "port", "5222"); - dmuci_add_section_bbfdm("dmmap_xmpp", "connection_server", &dmmap_xmpp, &v); + dmuci_add_section_bbfdm("dmmap_xmpp", "connection_server", &dmmap_xmpp); dmuci_set_value_by_section(dmmap_xmpp, "section_name", section_name(xmpp_con_srv)); dmuci_set_value_by_section(dmmap_xmpp, "con_srv_inst", "1"); - dmuci_add_section_bbfdm("dmmap_xmpp", "connection", &dmmap_xmpp, &v); + dmuci_add_section_bbfdm("dmmap_xmpp", "connection", &dmmap_xmpp); dmuci_set_value_by_section(dmmap_xmpp, "section_name", section_name(xmpp_con)); *instance = update_instance(last_inst, 4, dmmap_xmpp, "con_inst", "dmmap_xmpp", "connection"); return 0;