diff options
author | Martin Willi <martin@revosec.ch> | 2012-11-29 09:53:10 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-11-29 10:00:45 +0100 |
commit | 2685020ace15117f9c272beec87f621d600fb01d (patch) | |
tree | 0235b634dbe1f3f7d6d4aad569b1dc02ec65ac4b | |
parent | f0d4756eb0452fc2c71ce834c648ea62878dc8b9 (diff) | |
download | strongswan-2685020ace15117f9c272beec87f621d600fb01d.tar.bz2 strongswan-2685020ace15117f9c272beec87f621d600fb01d.tar.xz |
Lookip plugin additionally reports the IKE_SA unique identifier
-rw-r--r-- | src/libcharon/plugins/lookip/lookip.c | 5 | ||||
-rw-r--r-- | src/libcharon/plugins/lookip/lookip_listener.c | 13 | ||||
-rw-r--r-- | src/libcharon/plugins/lookip/lookip_listener.h | 4 | ||||
-rw-r--r-- | src/libcharon/plugins/lookip/lookip_msg.h | 6 | ||||
-rw-r--r-- | src/libcharon/plugins/lookip/lookip_socket.c | 3 |
5 files changed, 21 insertions, 10 deletions
diff --git a/src/libcharon/plugins/lookip/lookip.c b/src/libcharon/plugins/lookip/lookip.c index 98c1379eb..d5d8d0a63 100644 --- a/src/libcharon/plugins/lookip/lookip.c +++ b/src/libcharon/plugins/lookip/lookip.c @@ -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); diff --git a/src/libcharon/plugins/lookip/lookip_listener.c b/src/libcharon/plugins/lookip/lookip_listener.c index d2388f6b5..3a67eae08 100644 --- a/src/libcharon/plugins/lookip/lookip_listener.c +++ b/src/libcharon/plugins/lookip/lookip_listener.c @@ -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); diff --git a/src/libcharon/plugins/lookip/lookip_listener.h b/src/libcharon/plugins/lookip/lookip_listener.h index 8d1278a5f..56f74ed48 100644 --- a/src/libcharon/plugins/lookip/lookip_listener.h +++ b/src/libcharon/plugins/lookip/lookip_listener.h @@ -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. diff --git a/src/libcharon/plugins/lookip/lookip_msg.h b/src/libcharon/plugins/lookip/lookip_msg.h index 337d1c49f..d5789c29f 100644 --- a/src/libcharon/plugins/lookip/lookip_msg.h +++ b/src/libcharon/plugins/lookip/lookip_msg.h @@ -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_ @}*/ diff --git a/src/libcharon/plugins/lookip/lookip_socket.c b/src/libcharon/plugins/lookip/lookip_socket.c index dc1a80b83..a326aae71 100644 --- a/src/libcharon/plugins/lookip/lookip_socket.c +++ b/src/libcharon/plugins/lookip/lookip_socket.c @@ -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, |