summaryrefslogtreecommitdiff
path: root/src/dumm/mconsole.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
committerYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
commitb34738ed08c2227300d554b139e2495ca5da97d6 (patch)
tree62f33b52820f2e49f0e53c0f8c636312037c8054 /src/dumm/mconsole.c
parent0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff)
downloadvyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz
vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip
Imported Upstream version 4.6.4
Diffstat (limited to 'src/dumm/mconsole.c')
-rw-r--r--src/dumm/mconsole.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/dumm/mconsole.c b/src/dumm/mconsole.c
index 7d982a54c..de70b7e69 100644
--- a/src/dumm/mconsole.c
+++ b/src/dumm/mconsole.c
@@ -168,10 +168,8 @@ static void ignore(void *data, char *buf, size_t len)
{
}
-/**
- * Implementation of mconsole_t.add_iface.
- */
-static bool add_iface(private_mconsole_t *this, char *guest, char *host)
+METHOD(mconsole_t, add_iface, bool,
+ private_mconsole_t *this, char *guest, char *host)
{
int tries = 0;
@@ -186,10 +184,8 @@ static bool add_iface(private_mconsole_t *this, char *guest, char *host)
return FALSE;
}
-/**
- * Implementation of mconsole_t.del_iface.
- */
-static bool del_iface(private_mconsole_t *this, char *guest)
+METHOD(mconsole_t, del_iface, bool,
+ private_mconsole_t *this, char *guest)
{
if (request(this, NULL, NULL, "remove %s", guest) != 0)
{
@@ -198,11 +194,9 @@ static bool del_iface(private_mconsole_t *this, char *guest)
return TRUE;
}
-/**
- * Implementation of mconsole_t.exec
- */
-static int exec(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
- void *data, char *cmd)
+METHOD(mconsole_t, exec, int,
+ private_mconsole_t *this, void(*cb)(void*,char*,size_t), void *data,
+ char *cmd)
{
return request(this, cb, data, "%s", cmd);
}
@@ -223,10 +217,8 @@ static void wait_bootup(private_mconsole_t *this)
}
}
-/**
- * Implementation of mconsole_t.destroy.
- */
-static void destroy(private_mconsole_t *this)
+METHOD(mconsole_t, destroy, void,
+ private_mconsole_t *this)
{
close(this->console);
close(this->notify);
@@ -327,14 +319,17 @@ static bool setup_console(private_mconsole_t *this)
*/
mconsole_t *mconsole_create(char *notify, void(*idle)(void))
{
- private_mconsole_t *this = malloc_thing(private_mconsole_t);
-
- this->public.add_iface = (bool(*)(mconsole_t*, char *guest, char *host))add_iface;
- this->public.del_iface = (bool(*)(mconsole_t*, char *guest))del_iface;
- this->public.exec = (int(*)(mconsole_t*, void(*cb)(void*,char*,size_t), void *data, char *cmd))exec;
- this->public.destroy = (void*)destroy;
-
- this->idle = idle;
+ private_mconsole_t *this;
+
+ INIT(this,
+ .public = {
+ .add_iface = _add_iface,
+ .del_iface = _del_iface,
+ .exec = _exec,
+ .destroy = _destroy,
+ },
+ .idle = idle,
+ );
if (!wait_for_notify(this, notify))
{