From 8b775e99eaddda50d2cfb61e1fb301d0c883abe9 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 24 Jun 2010 14:00:39 +0200 Subject: [PATCH] Implement the listener_t interface in the Android plugin to track the status of an SA. --- src/libcharon/plugins/android/android_service.c | 42 +++++++++++++++++++++++-- src/libcharon/plugins/android/android_service.h | 7 +++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/libcharon/plugins/android/android_service.c b/src/libcharon/plugins/android/android_service.c index 6afcc4c..4214d53 100644 --- a/src/libcharon/plugins/android/android_service.c +++ b/src/libcharon/plugins/android/android_service.c @@ -36,9 +36,9 @@ struct private_android_service_t { 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 @@ -80,6 +80,36 @@ static void send_status(private_android_service_t *this, u_char code) 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 */ @@ -245,6 +275,7 @@ static job_requeue_t initiate(private_android_service_t *this) METHOD(android_service_t, destroy, void, private_android_service_t *this) { + charon->bus->remove_listener(charon->bus, &this->public.listener); close(this->control); free(this); } @@ -258,6 +289,12 @@ android_service_t *android_service_create(android_creds_t *creds) INIT(this, .public = { + .listener = { + .ike_updown = _ike_updown, + .child_state_change = _child_state_change, + .child_updown = _child_updown, + .ike_rekey = _ike_rekey, + }, .destroy = _destroy, }, .creds = creds, @@ -280,6 +317,7 @@ android_service_t *android_service_create(android_creds_t *creds) return NULL; } + charon->bus->add_listener(charon->bus, &this->public.listener); this->job = callback_job_create((callback_job_cb_t)initiate, this, NULL, NULL); charon->processor->queue_job(charon->processor, (job_t*)this->job); diff --git a/src/libcharon/plugins/android/android_service.h b/src/libcharon/plugins/android/android_service.h index 1257efa..d096d6c 100644 --- a/src/libcharon/plugins/android/android_service.h +++ b/src/libcharon/plugins/android/android_service.h @@ -23,6 +23,8 @@ typedef struct android_service_t android_service_t; +#include + #include "android_creds.h" /** @@ -31,6 +33,11 @@ typedef struct android_service_t android_service_t; struct android_service_t { /** + * Implements listener_t. + */ + listener_t listener; + + /** * Destroy a android_service_t. */ void (*destroy)(android_service_t *this); -- 2.7.4