]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
lookup function of lookip listener returns the number of matches
authorMartin Willi <martin@revosec.ch>
Tue, 9 Oct 2012 09:05:19 +0000 (11:05 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 24 Oct 2012 09:43:34 +0000 (11:43 +0200)
src/libcharon/plugins/lookip/lookip_listener.c
src/libcharon/plugins/lookip/lookip_listener.h

index 9be4e09eabb613ae3321afa01a8c0f805041dbfb..91d1235ecebd4c48e796b0fd8398e19aa10667cf 100644 (file)
@@ -224,11 +224,12 @@ METHOD(listener_t, ike_updown, bool,
        return TRUE;
 }
 
-METHOD(lookip_listener_t, lookup, void,
+METHOD(lookip_listener_t, lookup, int,
        private_lookip_listener_t *this, host_t *vip,
        lookip_callback_t cb, void *user)
 {
        entry_t *entry;
+       int matches = 0;
 
        this->lock->read_lock(this->lock);
        if (vip)
@@ -237,6 +238,7 @@ METHOD(lookip_listener_t, lookup, void,
                if (entry)
                {
                        cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
+                       matches ++;
                }
        }
        else
@@ -247,10 +249,13 @@ METHOD(lookip_listener_t, lookup, void,
                while (enumerator->enumerate(enumerator, &vip, &entry))
                {
                        cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
+                       matches++;
                }
                enumerator->destroy(enumerator);
        }
        this->lock->unlock(this->lock);
+
+       return matches;
 }
 
 METHOD(lookip_listener_t, add_listener, void,
index 63378fbb84071abe41f32996fc9e28ae055b7e67..8d1278a5f33f9a9d37affde3540b20cbf1121af9 100644 (file)
@@ -58,9 +58,10 @@ struct lookip_listener_t {
         * @param vip           virtual IP to look up, NULL to get all entries
         * @param cb            callback function to invoke
         * @param user          user data to pass to callback function
+        * @return                      number of matches
         */
-       void (*lookup)(lookip_listener_t *this, host_t *vip,
-                                  lookip_callback_t cb, void *user);
+       int (*lookup)(lookip_listener_t *this, host_t *vip,
+                                 lookip_callback_t cb, void *user);
 
        /**
         * Register a listener function that gets notified about virtual IP changes.