Implement the listener_t interface in the Android plugin to track the status of an SA.

This commit is contained in:
Tobias Brunner
2010-06-24 14:30:05 +02:00
parent 94ec9adc10
commit 8b775e99ea
2 changed files with 47 additions and 2 deletions
@@ -36,9 +36,9 @@ struct private_android_service_t {
android_service_t public; android_service_t public;
/** /**
* listener to track progress * current IKE_SA
*/ */
listener_t listener; ike_sa_t *ike_sa;
/** /**
* job that handles requests from the Android control socket * job that handles requests from the Android control socket
@@ -80,6 +80,36 @@ static void send_status(private_android_service_t *this, u_char code)
send(this->control, &code, 1, 0); send(this->control, &code, 1, 0);
} }
METHOD(listener_t, ike_updown, bool,
private_android_service_t *this, ike_sa_t *ike_sa, bool up)
{
return TRUE;
}
METHOD(listener_t, child_state_change, bool,
private_android_service_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
child_sa_state_t state)
{
return TRUE;
}
METHOD(listener_t, child_updown, bool,
private_android_service_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
bool up)
{
return TRUE;
}
METHOD(listener_t, ike_rekey, bool,
private_android_service_t *this, ike_sa_t *old, ike_sa_t *new)
{
if (this->ike_sa == old)
{
this->ike_sa = new;
}
return TRUE;
}
/** /**
* Read a string argument from the Android control socket * Read a string argument from the Android control socket
*/ */
@@ -245,6 +275,7 @@ static job_requeue_t initiate(private_android_service_t *this)
METHOD(android_service_t, destroy, void, METHOD(android_service_t, destroy, void,
private_android_service_t *this) private_android_service_t *this)
{ {
charon->bus->remove_listener(charon->bus, &this->public.listener);
close(this->control); close(this->control);
free(this); free(this);
} }
@@ -258,6 +289,12 @@ android_service_t *android_service_create(android_creds_t *creds)
INIT(this, INIT(this,
.public = { .public = {
.listener = {
.ike_updown = _ike_updown,
.child_state_change = _child_state_change,
.child_updown = _child_updown,
.ike_rekey = _ike_rekey,
},
.destroy = _destroy, .destroy = _destroy,
}, },
.creds = creds, .creds = creds,
@@ -280,6 +317,7 @@ android_service_t *android_service_create(android_creds_t *creds)
return NULL; return NULL;
} }
charon->bus->add_listener(charon->bus, &this->public.listener);
this->job = callback_job_create((callback_job_cb_t)initiate, this, this->job = callback_job_create((callback_job_cb_t)initiate, this,
NULL, NULL); NULL, NULL);
charon->processor->queue_job(charon->processor, (job_t*)this->job); charon->processor->queue_job(charon->processor, (job_t*)this->job);
@@ -23,6 +23,8 @@
typedef struct android_service_t android_service_t; typedef struct android_service_t android_service_t;
#include <bus/listeners/listener.h>
#include "android_creds.h" #include "android_creds.h"
/** /**
@@ -30,6 +32,11 @@ typedef struct android_service_t android_service_t;
*/ */
struct android_service_t { struct android_service_t {
/**
* Implements listener_t.
*/
listener_t listener;
/** /**
* Destroy a android_service_t. * Destroy a android_service_t.
*/ */