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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(lookip_listener_t, lookup, void,
|
METHOD(lookip_listener_t, lookup, int,
|
||||||
private_lookip_listener_t *this, host_t *vip,
|
private_lookip_listener_t *this, host_t *vip,
|
||||||
lookip_callback_t cb, void *user)
|
lookip_callback_t cb, void *user)
|
||||||
{
|
{
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
|
int matches = 0;
|
||||||
|
|
||||||
this->lock->read_lock(this->lock);
|
this->lock->read_lock(this->lock);
|
||||||
if (vip)
|
if (vip)
|
||||||
@@ -237,6 +238,7 @@ METHOD(lookip_listener_t, lookup, void,
|
|||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
|
cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
|
||||||
|
matches ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -247,10 +249,13 @@ METHOD(lookip_listener_t, lookup, void,
|
|||||||
while (enumerator->enumerate(enumerator, &vip, &entry))
|
while (enumerator->enumerate(enumerator, &vip, &entry))
|
||||||
{
|
{
|
||||||
cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
|
cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
|
||||||
|
matches++;
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
|
|
||||||
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(lookip_listener_t, add_listener, void,
|
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 vip virtual IP to look up, NULL to get all entries
|
||||||
* @param cb callback function to invoke
|
* @param cb callback function to invoke
|
||||||
* @param user user data to pass to callback function
|
* @param user user data to pass to callback function
|
||||||
|
* @return number of matches
|
||||||
*/
|
*/
|
||||||
void (*lookup)(lookip_listener_t *this, host_t *vip,
|
int (*lookup)(lookip_listener_t *this, host_t *vip,
|
||||||
lookip_callback_t cb, void *user);
|
lookip_callback_t cb, void *user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a listener function that gets notified about virtual IP changes.
|
* Register a listener function that gets notified about virtual IP changes.
|
||||||
|
|||||||
Reference in New Issue
Block a user