lookup function of lookip listener returns the number of matches
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user