final cosmetics in PB-TNC debug output

This commit is contained in:
Andreas Steffen
2010-12-12 10:17:43 +01:00
parent 54eb669dd5
commit 41216e6518
2 changed files with 30 additions and 31 deletions
@@ -129,7 +129,7 @@ METHOD(pb_tnc_batch_t, get_encoding, chunk_t,
METHOD(pb_tnc_batch_t, add_msg, void, METHOD(pb_tnc_batch_t, add_msg, void,
private_pb_tnc_batch_t *this, pb_tnc_msg_t* msg) private_pb_tnc_batch_t *this, pb_tnc_msg_t* msg)
{ {
DBG2(DBG_TNC, "adding %N Message", pb_tnc_msg_type_names, DBG2(DBG_TNC, "adding %N message", pb_tnc_msg_type_names,
msg->get_type(msg)); msg->get_type(msg));
this->messages->insert_last(this->messages, msg); this->messages->insert_last(this->messages, msg);
} }
@@ -219,7 +219,7 @@ static status_t process_batch_header(private_pb_tnc_batch_t *this,
/* Version */ /* Version */
if (version != PB_TNC_VERSION) if (version != PB_TNC_VERSION)
{ {
DBG1(DBG_TNC, "unsupported TNCCS Batch Version 0x%01x", version); DBG1(DBG_TNC, "unsupported TNCCS batch version 0x%01x", version);
msg = pb_error_msg_create(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create(TRUE, IETF_VENDOR_ID,
PB_ERROR_VERSION_NOT_SUPPORTED); PB_ERROR_VERSION_NOT_SUPPORTED);
err_msg = (pb_error_msg_t*)msg; err_msg = (pb_error_msg_t*)msg;
@@ -231,8 +231,8 @@ static status_t process_batch_header(private_pb_tnc_batch_t *this,
directionality = (flags & PB_TNC_BATCH_FLAG_D) != PB_TNC_BATCH_FLAG_NONE; directionality = (flags & PB_TNC_BATCH_FLAG_D) != PB_TNC_BATCH_FLAG_NONE;
if (directionality == this->is_server) if (directionality == this->is_server)
{ {
DBG1(DBG_TNC, "wrong Directionality: Batch is from a PB %s", DBG1(DBG_TNC, "wrong Directionality: batch is from a PB %s",
directionality ? "Server" : "Client"); directionality ? "server" : "client");
msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID,
PB_ERROR_INVALID_PARAMETER, 1); PB_ERROR_INVALID_PARAMETER, 1);
goto fatal; goto fatal;
@@ -242,7 +242,7 @@ static status_t process_batch_header(private_pb_tnc_batch_t *this,
this->type = type & 0x0F; this->type = type & 0x0F;
if (this->type > PB_BATCH_ROOF) if (this->type > PB_BATCH_ROOF)
{ {
DBG1(DBG_TNC, "unknown PB-TNC Batch Type: %d", this->type); DBG1(DBG_TNC, "unknown PB-TNC batch type: %d", this->type);
msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID,
PB_ERROR_INVALID_PARAMETER, 3); PB_ERROR_INVALID_PARAMETER, 3);
goto fatal; goto fatal;
@@ -250,7 +250,7 @@ static status_t process_batch_header(private_pb_tnc_batch_t *this,
if (!state_machine->receive_batch(state_machine, this->type)) if (!state_machine->receive_batch(state_machine, this->type))
{ {
DBG1(DBG_TNC, "unexpected PB-TNC Batch Type: %N", DBG1(DBG_TNC, "unexpected PB-TNC batch type: %N",
pb_tnc_batch_type_names, this->type); pb_tnc_batch_type_names, this->type);
msg = pb_error_msg_create(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create(TRUE, IETF_VENDOR_ID,
PB_ERROR_UNEXPECTED_BATCH_TYPE); PB_ERROR_UNEXPECTED_BATCH_TYPE);
@@ -324,7 +324,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
if (msg_type == PB_TNC_RESERVED_MSG_TYPE) if (msg_type == PB_TNC_RESERVED_MSG_TYPE)
{ {
DBG1(DBG_TNC, "PB-TNC Message Type 0x%08x is reserved", DBG1(DBG_TNC, "PB-TNC message Type 0x%08x is reserved",
PB_TNC_RESERVED_MSG_TYPE); PB_TNC_RESERVED_MSG_TYPE);
msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID,
PB_ERROR_INVALID_PARAMETER, this->offset + 4); PB_ERROR_INVALID_PARAMETER, this->offset + 4);
@@ -345,7 +345,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
if (noskip_flag) if (noskip_flag)
{ {
DBG1(DBG_TNC, "reject PB-TNC Message (Vendor ID 0x%06x / " DBG1(DBG_TNC, "reject PB-TNC message (Vendor ID 0x%06x / "
"Type 0x%08x)", vendor_id, msg_type); "Type 0x%08x)", vendor_id, msg_type);
msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID,
PB_ERROR_UNSUPPORTED_MANDATORY_MSG, this->offset); PB_ERROR_UNSUPPORTED_MANDATORY_MSG, this->offset);
@@ -353,7 +353,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
} }
else else
{ {
DBG1(DBG_TNC, "ignore PB-TNC Message (Vendor ID 0x%06x / " DBG1(DBG_TNC, "ignore PB-TNC message (Vendor ID 0x%06x / "
"Type 0x%08x)", vendor_id, msg_type); "Type 0x%08x)", vendor_id, msg_type);
this->offset += msg_len; this->offset += msg_len;
return SUCCESS; return SUCCESS;
@@ -364,7 +364,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
if (pb_tnc_msg_infos[msg_type].has_noskip_flag != TRUE_OR_FALSE && if (pb_tnc_msg_infos[msg_type].has_noskip_flag != TRUE_OR_FALSE &&
pb_tnc_msg_infos[msg_type].has_noskip_flag != noskip_flag) pb_tnc_msg_infos[msg_type].has_noskip_flag != noskip_flag)
{ {
DBG1(DBG_TNC, "%N Message must%s have NOSKIP flag set", DBG1(DBG_TNC, "%N message must%s have NOSKIP flag set",
pb_tnc_msg_type_names, msg_type, pb_tnc_msg_type_names, msg_type,
pb_tnc_msg_infos[msg_type].has_noskip_flag ? "" : " not"); pb_tnc_msg_infos[msg_type].has_noskip_flag ? "" : " not");
msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID,
@@ -376,7 +376,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
(pb_tnc_msg_infos[msg_type].exact_size && (pb_tnc_msg_infos[msg_type].exact_size &&
msg_len != pb_tnc_msg_infos[msg_type].min_size)) msg_len != pb_tnc_msg_infos[msg_type].min_size))
{ {
DBG1(DBG_TNC, "%N Message length must be %s %u bytes but is %u bytes", DBG1(DBG_TNC, "%N message length must be %s %u bytes but is %u bytes",
pb_tnc_msg_type_names, msg_type, pb_tnc_msg_type_names, msg_type,
pb_tnc_msg_infos[msg_type].exact_size ? "exactly" : "at least", pb_tnc_msg_infos[msg_type].exact_size ? "exactly" : "at least",
pb_tnc_msg_infos[msg_type].min_size, msg_len); pb_tnc_msg_infos[msg_type].min_size, msg_len);
@@ -391,7 +391,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
{ {
if (this->is_server) if (this->is_server)
{ {
DBG1(DBG_TNC,"reject %N Message received from a PB-TNC Client", DBG1(DBG_TNC,"reject %N message received from a PB-TNC client",
pb_tnc_msg_type_names, msg_type); pb_tnc_msg_type_names, msg_type);
msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID, msg = pb_error_msg_create_with_offset(TRUE, IETF_VENDOR_ID,
PB_ERROR_INVALID_PARAMETER, this->offset); PB_ERROR_INVALID_PARAMETER, this->offset);
@@ -399,17 +399,16 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
} }
else else
{ {
DBG1(DBG_TNC,"ignore %N Message not received within RESULT batch", DBG1(DBG_TNC,"ignore %N message not received within RESULT batch",
pb_tnc_msg_type_names, msg_type); pb_tnc_msg_type_names, msg_type);
this->offset += msg_len; this->offset += msg_len;
return SUCCESS; return SUCCESS;
} }
} }
DBG2(DBG_TNC, "processing %N Message (%u bytes)", pb_tnc_msg_type_names, DBG2(DBG_TNC, "processing %N message (%u bytes)", pb_tnc_msg_type_names,
msg_type, msg_len); msg_type, msg_len);
data.len = msg_len; data.len = msg_len;
DBG3(DBG_TNC, "%B", &data);
msg_value = chunk_skip(data, PB_TNC_HEADER_SIZE); msg_value = chunk_skip(data, PB_TNC_HEADER_SIZE);
pb_tnc_msg = pb_tnc_msg_create_from_data(msg_type, msg_value); pb_tnc_msg = pb_tnc_msg_create_from_data(msg_type, msg_value);
@@ -444,7 +443,7 @@ METHOD(pb_tnc_batch_t, process, status_t,
{ {
return FAILED; return FAILED;
} }
DBG1(DBG_TNC, "processing PB-TNC %N Batch", pb_tnc_batch_type_names, DBG1(DBG_TNC, "processing PB-TNC %N batch", pb_tnc_batch_type_names,
this->type); this->type);
while (this->offset < this->encoding.len) while (this->offset < this->encoding.len)
{ {
@@ -510,7 +509,7 @@ pb_tnc_batch_t* pb_tnc_batch_create(bool is_server, pb_tnc_batch_type_t type)
.errors = linked_list_create(), .errors = linked_list_create(),
); );
DBG2(DBG_TNC, "creating PB-TNC %N Batch", pb_tnc_batch_type_names, type); DBG2(DBG_TNC, "creating PB-TNC %N batch", pb_tnc_batch_type_names, type);
return &this->public; return &this->public;
} }
+14 -14
View File
@@ -164,7 +164,7 @@ static void handle_msg(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
assess_msg = (pb_assessment_result_msg_t*)msg; assess_msg = (pb_assessment_result_msg_t*)msg;
result = assess_msg->get_assessment_result(assess_msg); result = assess_msg->get_assessment_result(assess_msg);
DBG1(DBG_TNC, "assessment result is '%N'", DBG1(DBG_TNC, "PB-TNC assessment result is '%N'",
evaluation_result_names, result); evaluation_result_names, result);
break; break;
} }
@@ -175,7 +175,7 @@ static void handle_msg(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
rec_msg = (pb_access_recommendation_msg_t*)msg; rec_msg = (pb_access_recommendation_msg_t*)msg;
rec = rec_msg->get_access_recommendation(rec_msg); rec = rec_msg->get_access_recommendation(rec_msg);
DBG1(DBG_TNC, "access recommendation is '%N'", DBG1(DBG_TNC, "PB-TNC access recommendation is '%N'",
pb_access_recommendation_code_names, rec); pb_access_recommendation_code_names, rec);
break; break;
} }
@@ -271,13 +271,13 @@ static void handle_msg(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
} }
/** /**
* Build a CRETRY or SRETRY Batch * Build a CRETRY or SRETRY batch
*/ */
static void build_retry_batch(private_tnccs_20_t *this) static void build_retry_batch(private_tnccs_20_t *this)
{ {
if (this->batch) if (this->batch)
{ {
DBG1(DBG_TNC, "cancelling PB-TNC %N Batch", DBG1(DBG_TNC, "cancelling PB-TNC %N batch",
pb_tnc_batch_type_names, this->batch->get_type(this->batch)); pb_tnc_batch_type_names, this->batch->get_type(this->batch));
this->batch->destroy(this->batch); this->batch->destroy(this->batch);
} }
@@ -308,7 +308,7 @@ METHOD(tls_t, process, status_t,
} }
data = chunk_create(buf, buflen); data = chunk_create(buf, buflen);
DBG1(DBG_TNC, "received TNCCS Batch (%u bytes) for Connection ID %u", DBG1(DBG_TNC, "received TNCCS batch (%u bytes) for connection ID %u",
data.len, this->connection_id); data.len, this->connection_id);
DBG3(DBG_TNC, "%B", &data); DBG3(DBG_TNC, "%B", &data);
batch = pb_tnc_batch_create_from_data(this->is_server, data); batch = pb_tnc_batch_create_from_data(this->is_server, data);
@@ -325,7 +325,7 @@ METHOD(tls_t, process, status_t,
if (batch_type == PB_BATCH_CRETRY) if (batch_type == PB_BATCH_CRETRY)
{ {
/* Send an SRETRY Batch in response */ /* Send an SRETRY batch in response */
this->mutex->lock(this->mutex); this->mutex->lock(this->mutex);
build_retry_batch(this); build_retry_batch(this);
this->mutex->unlock(this->mutex); this->mutex->unlock(this->mutex);
@@ -346,7 +346,7 @@ METHOD(tls_t, process, status_t,
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
/* received an empty CLOSE Batch from PB-TNC Client */ /* received an empty CLOSE batch from PB-TNC client */
if (this->is_server && batch_type == PB_BATCH_CLOSE && empty) if (this->is_server && batch_type == PB_BATCH_CLOSE && empty)
{ {
batch->destroy(batch); batch->destroy(batch);
@@ -379,7 +379,7 @@ METHOD(tls_t, process, status_t,
this->mutex->lock(this->mutex); this->mutex->lock(this->mutex);
if (this->batch) if (this->batch)
{ {
DBG1(DBG_TNC, "cancelling PB-TNC %N Batch", DBG1(DBG_TNC, "cancelling PB-TNC %N batch",
pb_tnc_batch_type_names, this->batch->get_type(this->batch)); pb_tnc_batch_type_names, this->batch->get_type(this->batch));
this->batch->destroy(this->batch); this->batch->destroy(this->batch);
} }
@@ -406,7 +406,7 @@ METHOD(tls_t, process, status_t,
} }
/** /**
* Build a RESULT Batch if a final recommendation is available * Build a RESULT batch if a final recommendation is available
*/ */
static void check_and_build_recommendation(private_tnccs_20_t *this) static void check_and_build_recommendation(private_tnccs_20_t *this)
{ {
@@ -464,7 +464,7 @@ METHOD(tls_t, build, status_t,
return FAILED; return FAILED;
} }
/* Create PB-TNC Language Preference Message */ /* Create PB-TNC Language Preference message */
pref_lang = charon->imcs->get_preferred_language(charon->imcs); pref_lang = charon->imcs->get_preferred_language(charon->imcs);
msg = pb_language_preference_msg_create(chunk_create(pref_lang, msg = pb_language_preference_msg_create(chunk_create(pref_lang,
strlen(pref_lang))); strlen(pref_lang)));
@@ -515,7 +515,7 @@ METHOD(tls_t, build, status_t,
/** /**
* if the DECIDED state has been reached and no CRETRY is under way * if the DECIDED state has been reached and no CRETRY is under way
* or if a CLOSE batch with error messages has been received, * or if a CLOSE batch with error messages has been received,
* reply with an empty CLOSE batch. * a PB-TNC client replies with an empty CLOSE batch.
*/ */
if (state == PB_STATE_DECIDED || state == PB_STATE_END) if (state == PB_STATE_DECIDED || state == PB_STATE_END)
{ {
@@ -535,7 +535,7 @@ METHOD(tls_t, build, status_t,
{ {
this->batch->build(this->batch); this->batch->build(this->batch);
data = this->batch->get_encoding(this->batch); data = this->batch->get_encoding(this->batch);
DBG1(DBG_TNC, "sending PB-TNC %N Batch (%d bytes) for Connection ID %u", DBG1(DBG_TNC, "sending PB-TNC %N batch (%d bytes) for connection ID %u",
pb_tnc_batch_type_names, batch_type, data.len, pb_tnc_batch_type_names, batch_type, data.len,
this->connection_id); this->connection_id);
DBG3(DBG_TNC, "%B", &data); DBG3(DBG_TNC, "%B", &data);
@@ -547,7 +547,7 @@ METHOD(tls_t, build, status_t,
} }
else else
{ {
DBG1(DBG_TNC, "cancelling unexpected PB-TNC Batch Type: %N", DBG1(DBG_TNC, "cancelling unexpected PB-TNC batch type: %N",
pb_tnc_batch_type_names, batch_type); pb_tnc_batch_type_names, batch_type);
status = INVALID_STATE; status = INVALID_STATE;
} }
@@ -557,7 +557,7 @@ METHOD(tls_t, build, status_t,
} }
else else
{ {
DBG1(DBG_TNC, "no TNCCS Batch to send"); DBG1(DBG_TNC, "no TNCCS batch to send");
status = INVALID_STATE; status = INVALID_STATE;
} }
this->mutex->unlock(this->mutex); this->mutex->unlock(this->mutex);