Lookip plugin additionally reports the IKE_SA unique identifier
This commit is contained in:
parent
f0d4756eb0
commit
2685020ace
|
@ -78,7 +78,7 @@ static int send_request(int fd, int type, char *vip)
|
|||
static int receive(int fd, int block, int loop)
|
||||
{
|
||||
lookip_response_t resp;
|
||||
char *label;
|
||||
char *label, name[32];
|
||||
int res;
|
||||
|
||||
do
|
||||
|
@ -120,8 +120,9 @@ static int receive(int fd, int block, int loop)
|
|||
resp.id[sizeof(resp.id) - 1] = '\0';
|
||||
resp.name[sizeof(resp.name) - 1] = '\0';
|
||||
|
||||
snprintf(name, sizeof(name), "%s[%u]", resp.name, resp.unique_id);
|
||||
printf("%-12s %16s %16s %20s %s\n",
|
||||
label, resp.vip, resp.ip, resp.name, resp.id);
|
||||
label, resp.vip, resp.ip, name, resp.id);
|
||||
}
|
||||
while (loop);
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ typedef struct {
|
|||
identification_t *id;
|
||||
/** associated connection name */
|
||||
char *name;
|
||||
/** IKE_SA unique identifier */
|
||||
u_int unique_id;
|
||||
} entry_t;
|
||||
|
||||
/**
|
||||
|
@ -106,7 +108,7 @@ static bool equals(host_t *a, host_t *b)
|
|||
static bool notify_up(listener_entry_t *listener, entry_t *entry)
|
||||
{
|
||||
if (!listener->cb(listener->user, TRUE, entry->vip, entry->other,
|
||||
entry->id, entry->name))
|
||||
entry->id, entry->name, entry->unique_id))
|
||||
{
|
||||
free(listener);
|
||||
return TRUE;
|
||||
|
@ -120,7 +122,7 @@ static bool notify_up(listener_entry_t *listener, entry_t *entry)
|
|||
static bool notify_down(listener_entry_t *listener, entry_t *entry)
|
||||
{
|
||||
if (!listener->cb(listener->user, FALSE, entry->vip, entry->other,
|
||||
entry->id, entry->name))
|
||||
entry->id, entry->name, entry->unique_id))
|
||||
{
|
||||
free(listener);
|
||||
return TRUE;
|
||||
|
@ -149,6 +151,7 @@ static void add_entry(private_lookip_listener_t *this, ike_sa_t *ike_sa)
|
|||
.other = other->clone(other),
|
||||
.id = id->clone(id),
|
||||
.name = strdup(ike_sa->get_name(ike_sa)),
|
||||
.unique_id = ike_sa->get_unique_id(ike_sa),
|
||||
);
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
|
@ -237,7 +240,8 @@ METHOD(lookip_listener_t, lookup, int,
|
|||
entry = this->entries->get(this->entries, vip);
|
||||
if (entry)
|
||||
{
|
||||
cb(user, TRUE, entry->vip, entry->other, entry->id, entry->name);
|
||||
cb(user, TRUE, entry->vip, entry->other, entry->id,
|
||||
entry->name, entry->unique_id);
|
||||
matches ++;
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +252,8 @@ METHOD(lookip_listener_t, lookup, int,
|
|||
enumerator = this->entries->create_enumerator(this->entries);
|
||||
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, entry->unique_id);
|
||||
matches++;
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
|
|
@ -34,10 +34,12 @@ typedef struct lookip_listener_t lookip_listener_t;
|
|||
* @param other peer external IP
|
||||
* @param id peer identity
|
||||
* @param name associated connection name
|
||||
* @param unique_id unique IKE_SA identifier
|
||||
* @return TRUE to receive more results, FALSE to cancel
|
||||
*/
|
||||
typedef bool (*lookip_callback_t)(void *user, bool up, host_t *vip,
|
||||
host_t *other, identification_t *id, char *name);
|
||||
host_t *other, identification_t *id,
|
||||
char *name, u_int unique_id);
|
||||
|
||||
/**
|
||||
* Listener collecting virtual IPs.
|
||||
|
|
|
@ -87,8 +87,10 @@ struct lookip_response_t {
|
|||
char ip[40];
|
||||
/** null terminated peer identity */
|
||||
char id[128];
|
||||
/** null connection name */
|
||||
char name[44];
|
||||
/** null terminated connection name */
|
||||
char name[40];
|
||||
/** unique connection id */
|
||||
unsigned int unique_id;
|
||||
};
|
||||
|
||||
#endif /** LOOKIP_MSG_H_ @}*/
|
||||
|
|
|
@ -135,7 +135,8 @@ static void entry_destroy(entry_t *this)
|
|||
* Callback function for listener
|
||||
*/
|
||||
static bool listener_cb(entry_t *entry, bool up, host_t *vip,
|
||||
host_t *other, identification_t *id, char *name)
|
||||
host_t *other, identification_t *id,
|
||||
char *name, u_int unique_id)
|
||||
{
|
||||
lookip_response_t resp = {
|
||||
.type = entry->type,
|
||||
|
|
Loading…
Reference in New Issue