streamlined pluto alg_info debug output

This commit is contained in:
Andreas Steffen
2009-05-19 10:02:25 +02:00
parent 4491d66692
commit a57820c59b
5 changed files with 35 additions and 79 deletions
+21 -28
View File
@@ -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)
+2 -2
View File
@@ -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)
+4 -23
View File
@@ -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)
);
}
}
/**
+6 -24
View File
@@ -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 */
+2 -2
View File
@@ -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);