aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-11-27 09:34:38 +0100
committerMartin Willi <martin@strongswan.org>2009-11-30 09:27:14 +0100
commitfb1ae8da5211e758299f028c3fcd06dbb60670b7 (patch)
treed9e3c6ea1d8489ca2879467b934a511d4235ed70 /src
parentc56d958243fa3fb4dbd26a89c36ce2c4367ebbe2 (diff)
downloadstrongswan-fb1ae8da5211e758299f028c3fcd06dbb60670b7.tar.bz2
strongswan-fb1ae8da5211e758299f028c3fcd06dbb60670b7.tar.xz
Added a get_sa() method to the bus, allowing a thread to lookup its IKE_SA
Diffstat (limited to 'src')
-rw-r--r--src/charon/bus/bus.c9
-rw-r--r--src/charon/bus/bus.h10
2 files changed, 19 insertions, 0 deletions
diff --git a/src/charon/bus/bus.c b/src/charon/bus/bus.c
index 7075586e1..6a72f4a9a 100644
--- a/src/charon/bus/bus.c
+++ b/src/charon/bus/bus.c
@@ -244,6 +244,14 @@ static void set_sa(private_bus_t *this, ike_sa_t *ike_sa)
}
/**
+ * Implementation of bus_t.get_sa
+ */
+static ike_sa_t* get_sa(private_bus_t *this)
+{
+ return pthread_getspecific(this->thread_sa);
+}
+
+/**
* data associated to a signal, passed to callback
*/
typedef struct {
@@ -744,6 +752,7 @@ bus_t *bus_create()
this->public.remove_listener = (void(*)(bus_t*,listener_t*))remove_listener;
this->public.listen = (void(*)(bus_t*, listener_t *listener, job_t *job))listen_;
this->public.set_sa = (void(*)(bus_t*,ike_sa_t*))set_sa;
+ this->public.get_sa = (ike_sa_t*(*)(bus_t*))get_sa;
this->public.log = (void(*)(bus_t*,debug_t,level_t,char*,...))log_;
this->public.vlog = (void(*)(bus_t*,debug_t,level_t,char*,va_list))vlog;
this->public.alert = (void(*)(bus_t*, alert_t alert, ...))alert;
diff --git a/src/charon/bus/bus.h b/src/charon/bus/bus.h
index 7270c5c67..86d1e270a 100644
--- a/src/charon/bus/bus.h
+++ b/src/charon/bus/bus.h
@@ -191,6 +191,16 @@ struct bus_t {
void (*set_sa) (bus_t *this, ike_sa_t *ike_sa);
/**
+ * Get the IKE_SA the calling thread is currently using.
+ *
+ * If a thread currently does not know what IKE_SA it is processing,
+ * it can call get_sa() to look up the SA set during checkout via set_sa().
+ *
+ * @return registered ike_sa, NULL if none registered
+ */
+ ike_sa_t* (*get_sa)(bus_t *this);
+
+ /**
* Send a log message to the bus.
*
* The signal specifies the type of the event occured. The format string