diff mbox series

[RFC,3/5] hwsim: use dbus.c module

Message ID 20230630191812.2884637-4-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series Initial refactor for hwsim frame processing | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood June 30, 2023, 7:18 p.m. UTC
Use the dbus module from IWD and remove duplicated code.
---
 Makefile.am   |  5 ++++-
 tools/hwsim.c | 24 +++---------------------
 2 files changed, 7 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 2fb03aa9..fcdd342a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -405,8 +405,11 @@  tools_hwsim_SOURCES = tools/hwsim.c src/mpdu.h \
 					src/storage.h src/storage.c \
 					src/common.h src/common.c \
 					src/band.h src/band.c \
-					src/crypto.h src/crypto.c
+					src/crypto.h src/crypto.c \
+					src/dbus.h src/dbus.c
+
 tools_hwsim_LDADD = $(ell_ldadd)
+tools_hwsim_CFLAGS = -DDBUS_SERVICE=\"net.connman.hwsim\"
 
 if DBUS_POLICY
 dist_dbus_data_DATA += tools/hwsim-dbus.conf
diff --git a/tools/hwsim.c b/tools/hwsim.c
index 5cb28624..402b3622 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -45,6 +45,7 @@ 
 #include "src/crypto.h"
 #include "src/nl80211util.h"
 #include "src/nl80211cmd.h"
+#include "src/dbus.h"
 
 #define HWSIM_SERVICE "net.connman.hwsim"
 
@@ -541,27 +542,6 @@  static const char *interface_get_path(const struct interface_info_rec *rec)
 	return path;
 }
 
-static struct l_dbus_message *dbus_error_failed(struct l_dbus_message *msg)
-{
-	return l_dbus_message_new_error(msg, HWSIM_SERVICE ".Failed",
-					"Operation failed");
-}
-
-static struct l_dbus_message *dbus_error_invalid_args(
-						struct l_dbus_message *msg)
-{
-	return l_dbus_message_new_error(msg, HWSIM_SERVICE ".InvalidArgs",
-					"Argument type is wrong");
-}
-
-static void dbus_pending_reply(struct l_dbus_message **msg,
-				struct l_dbus_message *reply)
-{
-	l_dbus_send(dbus, reply);
-	l_dbus_message_unref(*msg);
-	*msg = NULL;
-}
-
 static const char *rule_get_path(struct hwsim_rule *rule)
 {
 	static char path[16];
@@ -2867,6 +2847,8 @@  static bool setup_dbus_hwsim(void)
 		return false;
 	}
 
+	dbus_init(dbus);
+
 	if (!l_dbus_register_interface(dbus, HWSIM_RADIO_MANAGER_INTERFACE,
 					setup_radio_manager_interface,
 					NULL, false)) {