aboutsummaryrefslogtreecommitdiffstats
path: root/src/pluto/kernel.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-08-16 19:07:30 +0200
committerTobias Brunner <tobias@strongswan.org>2010-09-02 19:04:24 +0200
commit76467e030ce660570888f75c3888856e903b4eab (patch)
treec80de1034aa7bd6813c1f3ebdf630ed26bb552ae /src/pluto/kernel.c
parenta0cbce9e7c092a93adea1bc2ff4dcb602cc2a184 (diff)
downloadstrongswan-76467e030ce660570888f75c3888856e903b4eab.tar.bz2
strongswan-76467e030ce660570888f75c3888856e903b4eab.tar.xz
pluto: Handle changed NAT mappings via libhydra's kernel interface.
Diffstat (limited to 'src/pluto/kernel.c')
-rw-r--r--src/pluto/kernel.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/pluto/kernel.c b/src/pluto/kernel.c
index 5918f99d5..b384407c6 100644
--- a/src/pluto/kernel.c
+++ b/src/pluto/kernel.c
@@ -1738,6 +1738,11 @@ failed:
}
/**
+ * Handler for kernel events (called by thread-pool thread)
+ */
+kernel_listener_t *kernel_handler;
+
+/**
* Data for acquire events
*/
typedef struct {
@@ -1756,11 +1761,6 @@ void handle_acquire(acquire_data_t *this)
"%acquire");
}
-/**
- * Handler for kernel events (called by thread-pool thread)
- */
-kernel_listener_t *kernel_handler;
-
METHOD(kernel_listener_t, acquire, bool,
kernel_listener_t *this, u_int32_t reqid,
traffic_selector_t *src_ts, traffic_selector_t *dst_ts)
@@ -1789,6 +1789,41 @@ METHOD(kernel_listener_t, acquire, bool,
return TRUE;
}
+/**
+ * Data for mapping events
+ */
+typedef struct {
+ /** reqid, spi of affected SA */
+ u_int32_t reqid, spi;
+ /** new endpont */
+ ip_address new_end;
+} mapping_data_t;
+
+/**
+ * Callback for mapping events (called by main thread)
+ */
+void handle_mapping(mapping_data_t *this)
+{
+ process_nat_t_new_mapping(this->reqid, this->spi, &this->new_end);
+}
+
+
+METHOD(kernel_listener_t, mapping, bool,
+ kernel_listener_t *this, u_int32_t reqid, u_int32_t spi, host_t *remote)
+{
+ mapping_data_t *data;
+ DBG(DBG_CONTROL,
+ DBG_log("creating mapping event for SA with SPI %.8x and reqid {%u}",
+ spi, reqid));
+ INIT(data,
+ .reqid = reqid,
+ .spi = spi,
+ .new_end = *(ip_address*)remote->get_sockaddr(remote),
+ );
+ pluto->events->queue(pluto->events, (void*)handle_mapping, data, free);
+ return TRUE;
+}
+
void init_kernel(void)
{
/* register SA types that we can negotiate */
@@ -1797,6 +1832,7 @@ void init_kernel(void)
INIT(kernel_handler,
.acquire = _acquire,
+ .mapping = _mapping,
);
hydra->kernel_interface->add_listener(hydra->kernel_interface,
kernel_handler);