From 1561b71a2225af737db9f091204247ab4e141abb Mon Sep 17 00:00:00 2001
From: Vivek Kumar Dutta <vivek.dutta@iopsys.eu>
Date: Mon, 24 Mar 2025 16:36:59 +0530
Subject: [PATCH] Fix Remote protocol option

---
 bbf_plugin/syslog.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/bbf_plugin/syslog.c b/bbf_plugin/syslog.c
index 0937600..7671793 100644
--- a/bbf_plugin/syslog.c
+++ b/bbf_plugin/syslog.c
@@ -884,9 +884,10 @@ static int set_SyslogActionLogRemote_Address(char *refparam, struct dmctx *ctx,
 
 static int get_SyslogActionLogRemote_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
+	struct uci_section *r = (struct uci_section *)(((struct action_data *)((struct dm_data *)data)->additional_data)->remote_section);
 	char *proto;
 
-	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
+	dmuci_get_value_by_section_string(r, "proto", &proto);
 	if (DM_STRCMP(proto, "tls") == 0) {
 		*value = "TLS";
 	} else if (DM_STRCMP(proto, "tcp") == 0) {
@@ -900,6 +901,7 @@ static int get_SyslogActionLogRemote_Protocol(char *refparam, struct dmctx *ctx,
 
 static int set_SyslogActionLogRemote_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
 {
+	struct uci_section *r = (struct uci_section *)(((struct action_data *)((struct dm_data *)data)->additional_data)->remote_section);
 	switch (action)	{
 		case VALUECHECK:
 			if (bbfdm_validate_string(ctx, value, -1, -1, Protocol, NULL))
@@ -907,11 +909,11 @@ static int set_SyslogActionLogRemote_Protocol(char *refparam, struct dmctx *ctx,
 			break;
 		case VALUESET:
 			if (strcmp("TCP", value) == 0)
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "tcp");
+				dmuci_set_value_by_section(r, "proto", "tcp");
 			else if (strcmp("UDP", value) == 0)
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "udp");
+				dmuci_set_value_by_section(r, "proto", "udp");
 			else if (strcmp("TLS", value) == 0)
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "tls");
+				dmuci_set_value_by_section(r, "proto", "tls");
 			break;
 	}
 
-- 
GitLab