support of the enum printf_hook

This commit is contained in:
Andreas Steffen
2009-04-20 09:32:59 +00:00
parent 4af0a77cac
commit d41071802d
10 changed files with 663 additions and 667 deletions
+1
View File
@@ -59,6 +59,7 @@ libstrongswan_la_LIBADD = -lpthread -ldl
libstrongswan_lite_la_SOURCES = \ libstrongswan_lite_la_SOURCES = \
chunk.c chunk.h \ chunk.c chunk.h \
debug.c debug.h \ debug.c debug.h \
enum.c enum.h \
printf_hook.c printf_hook.h \ printf_hook.c printf_hook.h \
settings.c settings.h \ settings.c settings.h \
utils.c utils.h \ utils.c utils.h \
+2 -2
View File
@@ -4056,11 +4056,11 @@ show_connections_status(bool all, const char *name)
if (c->dpd_action != DPD_ACTION_NONE) if (c->dpd_action != DPD_ACTION_NONE)
whack_log(RC_COMMENT whack_log(RC_COMMENT
, "\"%s\"%s: dpd_action: %s;" , "\"%s\"%s: dpd_action: %N;"
" dpd_delay: %lus; dpd_timeout: %lus;" " dpd_delay: %lus; dpd_timeout: %lus;"
, c->name , c->name
, instance , instance
, enum_show(&dpd_action_names, c->dpd_action) , dpd_action_names, c->dpd_action
, (unsigned long) c->dpd_delay , (unsigned long) c->dpd_delay
, (unsigned long) c->dpd_timeout); , (unsigned long) c->dpd_timeout);
+617 -624
View File
File diff suppressed because it is too large Load Diff
+10 -9
View File
@@ -320,7 +320,7 @@ typedef enum {
/* RFC 2459 CRL reason codes */ /* RFC 2459 CRL reason codes */
extern enum_names crl_reason_names; extern enum_name_t *crl_reason_names;
typedef enum { typedef enum {
REASON_UNSPECIFIED = 0, REASON_UNSPECIFIED = 0,
@@ -335,7 +335,7 @@ typedef enum {
/* RFC 3706 Dead Peer Detection */ /* RFC 3706 Dead Peer Detection */
extern enum_names dpd_action_names; extern enum_name_t *dpd_action_names;
typedef enum { typedef enum {
DPD_ACTION_NONE = 0, DPD_ACTION_NONE = 0,
@@ -347,7 +347,7 @@ typedef enum {
/* Timer events */ /* Timer events */
extern enum_names timer_event_names; extern enum_name_t *timer_event_names;
enum event_type { enum event_type {
EVENT_NULL, /* non-event */ EVENT_NULL, /* non-event */
@@ -798,15 +798,16 @@ typedef u_int16_t cpi_t;
extern enum_names ident_names; extern enum_names ident_names;
extern enum_names cert_type_names; extern enum_names cert_type_names;
extern enum_names cert_policy_names;
extern enum_name_t *cert_policy_names;
typedef enum certpolicy { typedef enum certpolicy {
CERT_ALWAYS_SEND = 0, /* the default */ CERT_ALWAYS_SEND = 0, /* the default */
CERT_SEND_IF_ASKED = 1, CERT_SEND_IF_ASKED = 1,
CERT_NEVER_SEND = 2, CERT_NEVER_SEND = 2,
CERT_YES_SEND = 3, /* synonym for CERT_ALWAYS_SEND */ CERT_YES_SEND = 3, /* synonym for CERT_ALWAYS_SEND */
CERT_NO_SEND = 4 /* synonym for CERT_NEVER_SEND */ CERT_NO_SEND = 4 /* synonym for CERT_NEVER_SEND */
} certpolicy_t; } certpolicy_t;
/* Policies for establishing an SA /* Policies for establishing an SA
+1 -1
View File
@@ -391,7 +391,7 @@ parse_crl_reasonCode(chunk_t object)
} }
DBG(DBG_PARSING, DBG(DBG_PARSING,
DBG_log(" '%s'", enum_name(&crl_reason_names, reason)) DBG_log(" '%N'", crl_reason_names, reason)
) )
return reason; return reason;
} }
+2 -4
View File
@@ -3573,8 +3573,7 @@ main_inR2_outI3(struct msg_digest *md)
if (RSA_auth) if (RSA_auth)
{ {
DBG(DBG_CONTROL, DBG(DBG_CONTROL,
DBG_log("our certificate policy is %s" DBG_log("our certificate policy is %N", cert_policy_names, cert_policy)
, enum_name(&cert_policy_names, cert_policy))
) )
if (mycert.type != CERT_NONE) if (mycert.type != CERT_NONE)
{ {
@@ -3988,8 +3987,7 @@ main_inI3_outR3_tail(struct msg_digest *md
if (RSA_auth) if (RSA_auth)
{ {
DBG(DBG_CONTROL, DBG(DBG_CONTROL,
DBG_log("our certificate policy is %s" DBG_log("our certificate policy is %N", cert_policy_names, cert_policy)
, enum_name(&cert_policy_names, cert_policy))
) )
if (mycert.type != CERT_NONE) if (mycert.type != CERT_NONE)
{ {
+3
View File
@@ -94,6 +94,9 @@ void library_init(char *settings)
PRINTF_HOOK_ARGTYPE_END); PRINTF_HOOK_ARGTYPE_END);
pfh->add_handler(pfh, 'B', chunk_printf_hook, pfh->add_handler(pfh, 'B', chunk_printf_hook,
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_END); PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_END);
pfh->add_handler(pfh, 'N', enum_printf_hook,
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,
PRINTF_HOOK_ARGTYPE_END);
pfh->add_handler(pfh, 'T', time_printf_hook, pfh->add_handler(pfh, 'T', time_printf_hook,
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT, PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,
PRINTF_HOOK_ARGTYPE_END); PRINTF_HOOK_ARGTYPE_END);
+2 -2
View File
@@ -746,12 +746,12 @@ void fmt_state(bool all, struct state *st, time_t n
fmt_conn_instance(c, inst); fmt_conn_instance(c, inst);
snprintf(state_buf, state_buf_len snprintf(state_buf, state_buf_len
, "#%lu: \"%s\"%s %s (%s); %s in %lds%s%s%s%s" , "#%lu: \"%s\"%s %s (%s); %N in %lds%s%s%s%s"
, st->st_serialno , st->st_serialno
, c->name, inst , c->name, inst
, enum_name(&state_names, st->st_state) , enum_name(&state_names, st->st_state)
, state_story[st->st_state - STATE_MAIN_R0] , state_story[st->st_state - STATE_MAIN_R0]
, enum_name(&timer_event_names, st->st_event->ev_type) , timer_event_names, st->st_event->ev_type
, delta , delta
, np1, np2, eo, dpd); , np1, np2, eo, dpd);
+22 -22
View File
@@ -98,11 +98,11 @@ event_schedule(enum event_type type, time_t tm, struct state *st)
DBG(DBG_CONTROL, DBG(DBG_CONTROL,
if (st == NULL) if (st == NULL)
DBG_log("inserting event %s, timeout in %lu seconds" DBG_log("inserting event %N, timeout in %lu seconds"
, enum_show(&timer_event_names, type), (unsigned long)tm); , timer_event_names, type, (unsigned long)tm);
else else
DBG_log("inserting event %s, timeout in %lu seconds for #%lu" DBG_log("inserting event %N, timeout in %lu seconds for #%lu"
, enum_show(&timer_event_names, type), (unsigned long)tm , timer_event_names, type, (unsigned long)tm
, ev->ev_state->st_serialno)); , ev->ev_state->st_serialno));
if (evlist == (struct event *) NULL if (evlist == (struct event *) NULL
@@ -122,11 +122,11 @@ event_schedule(enum event_type type, time_t tm, struct state *st)
#ifdef NEVER /* this seems to be overkill */ #ifdef NEVER /* this seems to be overkill */
DBG(DBG_CONTROL, DBG(DBG_CONTROL,
if (evt->ev_state == NULL) if (evt->ev_state == NULL)
DBG_log("event added after event %s" DBG_log("event added after event %N"
, enum_show(&timer_event_names, evt->ev_type)); , timer_event_names, evt->ev_type);
else else
DBG_log("event added after event %s for #%lu" DBG_log("event added after event %N for #%lu"
, enum_show(&timer_event_names, evt->ev_type) , timer_event_names, evt->ev_type,
, evt->ev_state->st_serialno)); , evt->ev_state->st_serialno));
#endif /* NEVER */ #endif /* NEVER */
@@ -161,9 +161,9 @@ handle_timer_event(void)
if (tm < ev->ev_time) if (tm < ev->ev_time)
{ {
DBG(DBG_CONTROL, DBG_log("called while no event expired (%lu/%lu, %s)" DBG(DBG_CONTROL, DBG_log("called while no event expired (%lu/%lu, %N)"
, (unsigned long)tm, (unsigned long)ev->ev_time , (unsigned long)tm, (unsigned long)ev->ev_time
, enum_show(&timer_event_names, type))); , timer_event_names, type));
/* This will happen if the most close-to-expire event was /* This will happen if the most close-to-expire event was
* a retransmission or cleanup, and we received a packet * a retransmission or cleanup, and we received a packet
@@ -178,8 +178,8 @@ handle_timer_event(void)
DBG(DBG_CONTROL, DBG(DBG_CONTROL,
if (evlist != (struct event *) NULL) if (evlist != (struct event *) NULL)
DBG_log("event after this is %s in %ld seconds" DBG_log("event after this is %N in %ld seconds"
, enum_show(&timer_event_names, evlist->ev_type) , timer_event_names, evlist->ev_type
, (long) (evlist->ev_time - tm))); , (long) (evlist->ev_time - tm)));
/* for state-associated events, pick up the state pointer /* for state-associated events, pick up the state pointer
@@ -428,8 +428,8 @@ handle_timer_event(void)
nat_traversal_ka_event(); nat_traversal_ka_event();
break; break;
default: default:
loglog(RC_LOG_SERIOUS, "INTERNAL ERROR: ignoring unknown expiring event %s" loglog(RC_LOG_SERIOUS, "INTERNAL ERROR: ignoring unknown expiring event %N"
, enum_show(&timer_event_names, type)); , timer_event_names, type);
} }
free(ev); free(ev);
@@ -452,12 +452,12 @@ next_event(void)
DBG(DBG_CONTROL, DBG(DBG_CONTROL,
if (evlist->ev_state == NULL) if (evlist->ev_state == NULL)
DBG_log("next event %s in %ld seconds" DBG_log("next event %N in %ld seconds"
, enum_show(&timer_event_names, evlist->ev_type) , timer_event_names, evlist->ev_type
, (long)evlist->ev_time - (long)tm); , (long)evlist->ev_time - (long)tm);
else else
DBG_log("next event %s in %ld seconds for #%lu" DBG_log("next event %N in %ld seconds for #%lu"
, enum_show(&timer_event_names, evlist->ev_type) , timer_event_names, evlist->ev_type
, (long)evlist->ev_time - (long)tm , (long)evlist->ev_time - (long)tm
, evlist->ev_state->st_serialno)); , evlist->ev_state->st_serialno));
@@ -481,8 +481,8 @@ delete_event(struct state *st)
{ {
if (*ev == NULL) if (*ev == NULL)
{ {
DBG(DBG_CONTROL, DBG_log("event %s to be deleted not found", DBG(DBG_CONTROL, DBG_log("event %N to be deleted not found",
enum_show(&timer_event_names, st->st_event->ev_type))); timer_event_names, st->st_event->ev_type));
break; break;
} }
if ((*ev) == st->st_event) if ((*ev) == st->st_event)
@@ -516,8 +516,8 @@ delete_dpd_event(struct state *st)
{ {
if (*ev == NULL) if (*ev == NULL)
{ {
DBG(DBG_CONTROL, DBG_log("event %s to be deleted not found", DBG(DBG_CONTROL, DBG_log("event %N to be deleted not found",
enum_show(&timer_event_names, st->st_dpd_event->ev_type))); timer_event_names, st->st_dpd_event->ev_type));
break; break;
} }
if ((*ev) == st->st_dpd_event) if ((*ev) == st->st_dpd_event)
+2 -2
View File
@@ -2245,9 +2245,9 @@ verify_x509cert(const x509cert_t *cert, bool strict, time_t *until)
} }
break; break;
case CERT_REVOKED: case CERT_REVOKED:
plog("certificate was revoked on %T, reason: %s" plog("certificate was revoked on %T, reason: %N"
, &revocationDate, TRUE , &revocationDate, TRUE
, enum_name(&crl_reason_names, revocationReason)); , crl_reason_names, revocationReason);
remove_x509_public_key(cert); remove_x509_public_key(cert);
return FALSE; return FALSE;
case CERT_UNKNOWN: case CERT_UNKNOWN: