All kernel listener hooks are optional.
authorTobias Brunner <tobias@strongswan.org>
Tue, 6 Jul 2010 14:09:06 +0000 (16:09 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 2 Sep 2010 17:01:23 +0000 (19:01 +0200)
src/libcharon/kernel/kernel_interface.c
src/libcharon/kernel/kernel_listener.h

index 98ec37c..fffde68 100644 (file)
@@ -376,7 +376,8 @@ METHOD(kernel_interface_t, acquire, void,
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &listener))
        {
-               if (!listener->acquire(listener, reqid, src_ts, dst_ts))
+               if (listener->acquire &&
+                       !listener->acquire(listener, reqid, src_ts, dst_ts))
                {
                        this->listeners->remove_at(this->listeners, enumerator);
                }
@@ -395,7 +396,8 @@ METHOD(kernel_interface_t, expire, void,
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &listener))
        {
-               if (!listener->expire(listener, reqid, protocol, spi, hard))
+               if (listener->expire &&
+                       !listener->expire(listener, reqid, protocol, spi, hard))
                {
                        this->listeners->remove_at(this->listeners, enumerator);
                }
@@ -414,7 +416,8 @@ METHOD(kernel_interface_t, mapping, void,
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &listener))
        {
-               if (!listener->mapping(listener, reqid, spi, remote))
+               if (listener->mapping &&
+                       !listener->mapping(listener, reqid, spi, remote))
                {
                        this->listeners->remove_at(this->listeners, enumerator);
                }
@@ -434,7 +437,8 @@ METHOD(kernel_interface_t, migrate, void,
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &listener))
        {
-               if (!listener->migrate(listener, reqid, src_ts, dst_ts, direction,
+               if (listener->migrate &&
+                       !listener->migrate(listener, reqid, src_ts, dst_ts, direction,
                                                           local, remote))
                {
                        this->listeners->remove_at(this->listeners, enumerator);
@@ -446,7 +450,7 @@ METHOD(kernel_interface_t, migrate, void,
 
 static bool call_roam(kernel_listener_t *listener, bool *roam)
 {
-       return !listener->roam(listener, *roam);
+       return listener->roam && !listener->roam(listener, *roam);
 }
 
 METHOD(kernel_interface_t, roam, void,
index e0a911a..b69bed6 100644 (file)
@@ -29,6 +29,8 @@ typedef struct kernel_listener_t kernel_listener_t;
 
 /**
  * Interface for components interested in kernel events.
+ *
+ * All hooks are optional.
  */
 struct kernel_listener_t {