Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 05/11] agent: utilize IWD_MODULE
Date: Fri, 11 Oct 2019 10:24:11 -0700	[thread overview]
Message-ID: <20191011172417.23328-5-prestwoj@gmail.com> (raw)
In-Reply-To: <20191011172417.23328-1-prestwoj@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2799 bytes --]

Converts agent into an IWD module. This removes the dbus dependency
on agent. Since dbus is initialized very early we can assume
dbus_get_bus is going to return a valid object.
---
 src/agent.c | 19 ++++++++++++-------
 src/agent.h |  2 --
 src/dbus.c  |  3 +--
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/agent.c b/src/agent.c
index 2c04c546..3a266746 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -29,6 +29,7 @@
 #include <ell/ell.h>
 #include "src/dbus.h"
 #include "src/agent.h"
+#include "src/iwd.h"
 
 static unsigned int next_request_id = 0;
 
@@ -619,8 +620,10 @@ static bool release_agent(void *data, void *user_data)
 	return true;
 }
 
-bool agent_init(struct l_dbus *dbus)
+static int agent_init(void)
 {
+	struct l_dbus *dbus = dbus_get_bus();
+
 	agents = l_queue_new();
 
 	if (!l_dbus_register_interface(dbus, IWD_AGENT_MANAGER_INTERFACE,
@@ -628,7 +631,7 @@ bool agent_init(struct l_dbus *dbus)
 						NULL, false)) {
 		l_info("Unable to register %s interface",
 				IWD_AGENT_MANAGER_INTERFACE);
-		return false;
+		return -EIO;
 	}
 
 	if (!l_dbus_object_add_interface(dbus, IWD_AGENT_MANAGER_PATH,
@@ -637,24 +640,26 @@ bool agent_init(struct l_dbus *dbus)
 		l_info("Unable to register the agent manager object on '%s'",
 				IWD_AGENT_MANAGER_PATH);
 		l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE);
-		return false;
+		return -EIO;
 	}
 
-	return true;
+	return 0;
 }
 
-bool agent_exit(struct l_dbus *dbus)
+static void agent_exit(void)
 {
+	struct l_dbus *dbus = dbus_get_bus();
+
 	l_dbus_unregister_object(dbus, IWD_AGENT_MANAGER_PATH);
 	l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE);
 
 	l_queue_destroy(agents, agent_free);
 	agents = NULL;
-
-	return true;
 }
 
 void agent_shutdown(void)
 {
 	l_queue_foreach_remove(agents, release_agent, NULL);
 }
+
+IWD_MODULE(agent, agent_init, agent_exit);
diff --git a/src/agent.h b/src/agent.h
index f4dcd46b..e9f78c39 100644
--- a/src/agent.h
+++ b/src/agent.h
@@ -37,8 +37,6 @@ typedef void (*agent_request_user_name_passwd_func_t) (enum agent_result result,
 					void *user_data);
 typedef void (*agent_request_destroy_func_t)(void *user_data);
 
-bool agent_init(struct l_dbus *dbus);
-bool agent_exit(struct l_dbus *dbus);
 void agent_shutdown(void);
 
 unsigned int agent_request_passphrase(const char *path,
diff --git a/src/dbus.c b/src/dbus.c
index 5bc32c26..43dfb567 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -210,12 +210,11 @@ struct l_dbus *dbus_get_bus(void)
 bool dbus_init(struct l_dbus *dbus)
 {
 	g_dbus = dbus;
-	return agent_init(dbus);
+	return true;
 }
 
 void dbus_exit(void)
 {
-	agent_exit(g_dbus);
 	g_dbus = NULL;
 }
 
-- 
2.17.1

  parent reply	other threads:[~2019-10-11 17:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 17:24 [PATCH 01/11] main: move module init into nl80211_appeared James Prestwood
2019-10-11 17:24 ` [PATCH 02/11] netdev: utilize IWD_MODULE James Prestwood
2019-10-11 17:24 ` [PATCH 03/11] eapol: " James Prestwood
2019-10-11 17:24 ` [PATCH 04/11] anqp: " James Prestwood
2019-10-11 17:24 ` James Prestwood [this message]
2019-10-11 18:53   ` [PATCH 05/11] agent: " Denis Kenzior
2019-10-11 17:24 ` [PATCH 06/11] manager: " James Prestwood
2019-10-11 18:57   ` Denis Kenzior
2019-10-11 17:24 ` [PATCH 07/11] wiphy: " James Prestwood
2019-10-11 17:24 ` [PATCH 08/11] eap: remove mtu argument from eap_init James Prestwood
2019-10-11 17:24 ` [PATCH 09/11] wired: update with new eap_init James Prestwood
2019-10-11 17:24 ` [PATCH 10/11] unit: update wsc/eapol " James Prestwood
2019-10-11 17:24 ` [PATCH 11/11] eap: utilize IWD_MODULE James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191011172417.23328-5-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox