diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-05-19 10:02:17 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-05-19 10:02:25 +0200 |
commit | a57820c59b5f138daf492422f0a1ce2181317ed0 (patch) | |
tree | 9deb9d634b51f7b0afb3cec36a0d292c3f63cacb | |
parent | 4491d66692a5737a94647b58f452a8f8df66809d (diff) | |
download | strongswan-a57820c59b5f138daf492422f0a1ce2181317ed0.tar.bz2 strongswan-a57820c59b5f138daf492422f0a1ce2181317ed0.tar.xz |
streamlined pluto alg_info debug output
-rw-r--r-- | src/pluto/alg_info.c | 49 | ||||
-rw-r--r-- | src/pluto/connections.c | 4 | ||||
-rw-r--r-- | src/pluto/ike_alg.c | 27 | ||||
-rw-r--r-- | src/pluto/kernel_alg.c | 30 | ||||
-rw-r--r-- | src/pluto/spdb.c | 4 |
5 files changed, 35 insertions, 79 deletions
diff --git a/src/pluto/alg_info.c b/src/pluto/alg_info.c index a39c3fba0..1ca7d4e7d 100644 --- a/src/pluto/alg_info.c +++ b/src/pluto/alg_info.c @@ -131,8 +131,10 @@ static void __alg_info_esp_add(struct alg_info_esp *alg_info, int ealg_id, alg_info->alg_info_cnt++; DBG(DBG_CRYPT, - DBG_log("__alg_info_esp_add() ealg=%d aalg=%d cnt=%d" - , ealg_id, aalg_id, alg_info->alg_info_cnt) + DBG_log("esp alg added: %s_%d/%s, cnt=%d", + enum_show(&esp_transformid_names, ealg_id), ek_bits, + enum_show(&auth_alg_names, aalg_id), + alg_info->alg_info_cnt) ) } @@ -198,9 +200,11 @@ static void __alg_info_ike_add (struct alg_info_ike *alg_info, int ealg_id, alg_info->alg_info_cnt++; DBG(DBG_CRYPT, - DBG_log("__alg_info_ike_add() ealg=%d aalg=%d modp_id=%d, cnt=%d" - , ealg_id, aalg_id, modp_id - , alg_info->alg_info_cnt) + DBG_log("ikg alg added: %s_%d/%s/s, cnt=%d", + enum_show(&oakley_enc_names, ealg_id), ek_bits, + enum_show(&oakley_hash_names, aalg_id), + enum_show(&oakley_group_names, modp_id), + alg_info->alg_info_cnt) ) } @@ -390,7 +394,7 @@ static status_t alg_info_parse_str(struct alg_info *alg_info, char *alg_str) struct alg_info_esp *alg_info_esp_create_from_str(char *alg_str) { struct alg_info_esp *alg_info_esp; - char esp_buf[256]; + char esp_buf[BUF_LEN]; char *pfs_name; status_t status = SUCCESS; /* @@ -475,10 +479,6 @@ alg_info_addref(struct alg_info *alg_info) if (alg_info != NULL) { alg_info->ref_cnt++; - DBG(DBG_CRYPT, - DBG_log("alg_info_addref() alg_info->ref_cnt=%d" - , alg_info->ref_cnt) - ) } } @@ -491,15 +491,8 @@ alg_info_delref(struct alg_info **alg_info_p) { passert(alg_info->ref_cnt != 0); alg_info->ref_cnt--; - DBG(DBG_CRYPT, - DBG_log("alg_info_delref() alg_info->ref_cnt=%d" - , alg_info->ref_cnt) - ) if (alg_info->ref_cnt == 0) { - DBG(DBG_CRYPT, - DBG_log("alg_info_delref() freeing alg_info") - ) alg_info_free(alg_info); } *alg_info_p = NULL; @@ -523,10 +516,10 @@ alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info) ALG_INFO_ESP_FOREACH(alg_info_esp, esp_info, cnt) { - np = snprintf(ptr, buflen, "%d_%03d-%d, " - , esp_info->esp_ealg_id - , (int)esp_info->esp_ealg_keylen - , esp_info->esp_aalg_id); + np = snprintf(ptr, buflen, "%s_%d/%s, ", + enum_show(&esp_transformid_names, esp_info->esp_ealg_id), + (int)esp_info->esp_ealg_keylen, + enum_show(&auth_alg_names, esp_info->esp_aalg_id)); ptr += np; buflen -= np; if (buflen < 0) @@ -534,8 +527,8 @@ alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info) } if (alg_info_esp->esp_pfsgroup) { - np = snprintf(ptr, buflen, "; pfsgroup=%d; " - , alg_info_esp->esp_pfsgroup); + np = snprintf(ptr, buflen, "; pfsgroup=%s; ", + enum_show(&oakley_group_names, alg_info_esp->esp_pfsgroup)); ptr += np; buflen -= np; if (buflen < 0) @@ -547,11 +540,11 @@ alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info) case PROTO_ISAKMP: ALG_INFO_IKE_FOREACH((struct alg_info_ike *)alg_info, ike_info, cnt) { - np = snprintf(ptr, buflen, "%d_%03d-%d-%d, " - , ike_info->ike_ealg - , (int)ike_info->ike_eklen - , ike_info->ike_halg - , ike_info->ike_modp); + np = snprintf(ptr, buflen, "%s_%d/%s/%s, ", + enum_show(&oakley_enc_names, ike_info->ike_ealg), + (int)ike_info->ike_eklen, + enum_show(&oakley_hash_names, ike_info->ike_halg), + enum_show(&oakley_group_names, ike_info->ike_modp)); ptr += np; buflen -= np; if (buflen < 0) diff --git a/src/pluto/connections.c b/src/pluto/connections.c index b7185977f..d2c7a519e 100644 --- a/src/pluto/connections.c +++ b/src/pluto/connections.c @@ -991,7 +991,7 @@ add_connection(const whack_message_t *wm) c->alg_info_esp= alg_info_esp_create_from_str(wm->esp? wm->esp : ""); DBG(DBG_CRYPT|DBG_CONTROL, - static char buf[256]="<NULL>"; + static char buf[BUF_LEN]="<NULL>"; if (c->alg_info_esp) alg_info_snprint(buf, sizeof(buf) @@ -1018,7 +1018,7 @@ add_connection(const whack_message_t *wm) c->alg_info_ike= alg_info_ike_create_from_str(wm->ike? wm->ike : ""); DBG(DBG_CRYPT|DBG_CONTROL, - static char buf[256]="<NULL>"; + static char buf[BUF_LEN]="<NULL>"; if (c->alg_info_ike) alg_info_snprint(buf, sizeof(buf) diff --git a/src/pluto/ike_alg.c b/src/pluto/ike_alg.c index 7922d54b2..1b9974418 100644 --- a/src/pluto/ike_alg.c +++ b/src/pluto/ike_alg.c @@ -374,32 +374,12 @@ void ike_alg_list(void) */ void ike_alg_show_connection(struct connection *c, const char *instance) { - char buf[BUF_LEN]; - struct state *st; + struct state *st = state_with_serialno(c->newest_isakmp_sa); - if (c->alg_info_ike) - { - alg_info_snprint(buf, sizeof(buf)-1, (struct alg_info *)c->alg_info_ike); - whack_log(RC_COMMENT - , "\"%s\"%s: IKE algorithms wanted: %s" - , c->name - , instance - , buf - ); - - alg_info_snprint_ike(buf, sizeof(buf)-1, c->alg_info_ike); - whack_log(RC_COMMENT - , "\"%s\"%s: IKE algorithms found: %s" - , c->name - , instance - , buf - ); - } - - st = state_with_serialno(c->newest_isakmp_sa); if (st) + { whack_log(RC_COMMENT - , "\"%s\"%s: IKE algorithm newest: %s-%d/%s/%s" + , "\"%s\"%s: IKE proposal: %s_%d/%s/%s" , c->name , instance , enum_show(&oakley_enc_names, st->st_oakley.encrypt) @@ -407,6 +387,7 @@ void ike_alg_show_connection(struct connection *c, const char *instance) , enum_show(&oakley_hash_names, st->st_oakley.hash) , enum_show(&oakley_group_names, st->st_oakley.group->group) ); + } } /** diff --git a/src/pluto/kernel_alg.c b/src/pluto/kernel_alg.c index eefc0182b..80f24019b 100644 --- a/src/pluto/kernel_alg.c +++ b/src/pluto/kernel_alg.c @@ -486,31 +486,12 @@ void kernel_alg_list(void) void kernel_alg_show_connection(struct connection *c, const char *instance) { - char buf[256]; - struct state *st; + struct state *st = state_with_serialno(c->newest_ipsec_sa); - if (c->alg_info_esp) - { - alg_info_snprint(buf, sizeof(buf), (struct alg_info *)c->alg_info_esp); - whack_log(RC_COMMENT - , "\"%s\"%s: ESP algorithms wanted: %s" - , c->name - , instance - , buf); - } - if (c->alg_info_esp) - { - alg_info_snprint_esp(buf, sizeof(buf), c->alg_info_esp); - whack_log(RC_COMMENT - , "\"%s\"%s: ESP algorithms loaded: %s" - , c->name - , instance - , buf); - } - st = state_with_serialno(c->newest_ipsec_sa); if (st && st->st_esp.present) + { whack_log(RC_COMMENT - , "\"%s\"%s: ESP algorithm newest: %s-%d/%s/%s" + , "\"%s\"%s: ESP proposal: %s_%d/%s/%s" , c->name , instance , enum_show(&esp_transformid_names, st->st_esp.attrs.transid) @@ -518,11 +499,12 @@ kernel_alg_show_connection(struct connection *c, const char *instance) , enum_show(&auth_alg_names, st->st_esp.attrs.auth) , c->policy & POLICY_PFS ? c->alg_info_esp->esp_pfsgroup ? - enum_show(&oakley_group_names, - c->alg_info_esp->esp_pfsgroup) + enum_show(&oakley_group_names, + c->alg_info_esp->esp_pfsgroup) : "<Phase1>" : "<N/A>" ); + } } #endif /* NO_PLUTO */ diff --git a/src/pluto/spdb.c b/src/pluto/spdb.c index 6bcc3f117..3b4027160 100644 --- a/src/pluto/spdb.c +++ b/src/pluto/spdb.c @@ -318,7 +318,7 @@ out_sa(pb_stream *outs DBG(DBG_CONTROL | DBG_CRYPT, if (st->st_connection->alg_info_esp) { - static char buf[256]=""; + static char buf[BUF_LEN]=""; alg_info_snprint(buf, sizeof (buf), (struct alg_info *)st->st_connection->alg_info_esp); @@ -342,7 +342,7 @@ out_sa(pb_stream *outs DBG(DBG_CONTROL | DBG_CRYPT, if (st->st_connection->alg_info_ike) { - static char buf[256]=""; + static char buf[BUF_LEN]=""; alg_info_snprint(buf, sizeof (buf), (struct alg_info *)st->st_connection->alg_info_ike); |