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)
if (entry)
{
cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
+ matches ++;
}
}
else
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,
* @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.