- rewrite of logger_manager, uses now one instance per context

- cleanups for logger here and there
- removed critical flag check in payload verification (conformance to IKEv2)
- so thats and theres everywere... ;-)
This commit is contained in:
Martin Willi
2006-03-23 15:25:43 +00:00
parent 3264ce50b9
commit dec598220b
59 changed files with 461 additions and 762 deletions
@@ -116,11 +116,6 @@ encoding_rule_t auth_payload_encodings[] = {
*/
static status_t verify(private_auth_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if ((this->auth_method == 0) ||
((this->auth_method >= 4) && (this->auth_method <= 200)))
{
@@ -129,11 +129,6 @@ encoding_rule_t cert_payload_encodings[] = {
*/
static status_t verify(private_cert_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if ((this->cert_encoding == 0) ||
((this->cert_encoding >= 14) && (this->cert_encoding <= 200)))
{
@@ -109,11 +109,6 @@ encoding_rule_t certreq_payload_encodings[] = {
*/
static status_t verify(private_certreq_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if ((this->cert_encoding == 0) ||
((this->cert_encoding >= 14) && (this->cert_encoding <= 200)))
{
@@ -139,12 +139,6 @@ static status_t verify(private_cp_payload_t *this)
{
status_t status = SUCCESS;
iterator_t *iterator;
if (this->critical)
{
/* critical bit set! */
return FAILED;
}
iterator = this->attributes->create_iterator(this->attributes,TRUE);
@@ -121,11 +121,6 @@ encoding_rule_t delete_payload_encodings[] = {
*/
static status_t verify(private_delete_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if ((this->protocol_id == 0) ||
(this->protocol_id > 3))
{
@@ -136,7 +131,7 @@ static status_t verify(private_delete_payload_t *this)
{
return FAILED;
}
if ((this->protocol_id == IKE) && (this->spis.len != 0))
if ((this->protocol_id == PROTO_IKE) && (this->spis.len != 0))
{
/* IKE deletion has no spi assigned! */
return FAILED;
@@ -318,7 +313,7 @@ delete_payload_t *delete_payload_create()
this->critical = FALSE;
this->next_payload = NO_PAYLOAD;
this->payload_length =DELETE_PAYLOAD_HEADER_LENGTH;
this->protocol_id = UNDEFINED_PROTOCOL_ID;
this->protocol_id = PROTO_NONE;
this->spi_size = 0;
this->spi_count = 0;
this->spis = CHUNK_INITIALIZER;
@@ -101,11 +101,6 @@ encoding_rule_t eap_payload_encodings[] = {
*/
static status_t verify(private_eap_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
return SUCCESS;
}
@@ -638,7 +638,6 @@ static void destroy(private_encryption_payload_t *this)
current_payload->destroy(current_payload);
}
this->payloads->destroy(this->payloads);
charon->logger_manager->destroy_logger(charon->logger_manager, this->logger);
allocator_free(this->encrypted.ptr);
allocator_free(this->decrypted.ptr);
allocator_free(this);
@@ -677,10 +676,10 @@ encryption_payload_t *encryption_payload_create()
this->compute_length = compute_length;
this->generate = generate;
this->parse = parse;
this->logger = charon->logger_manager->create_logger(charon->logger_manager, ENCRYPTION_PAYLOAD, NULL);
this->logger = charon->logger_manager->get_logger(charon->logger_manager, ENCRYPTION_PAYLOAD);
/* set default values of the fields */
this->critical = TRUE;
this->critical = FALSE;
this->next_payload = NO_PAYLOAD;
this->payload_length = ENCRYPTION_PAYLOAD_HEADER_LENGTH;
this->encrypted = CHUNK_INITIALIZER;
@@ -119,11 +119,6 @@ encoding_rule_t id_payload_encodings[] = {
*/
static status_t verify(private_id_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if ((this->id_type == 0) ||
(this->id_type == 4) ||
((this->id_type >= 6) && (this->id_type <= 8)) ||
@@ -123,12 +123,6 @@ encoding_rule_t ke_payload_encodings[] = {
*/
static status_t verify(private_ke_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
/* dh group is not verified in here */
return SUCCESS;
}
@@ -111,11 +111,6 @@ encoding_rule_t nonce_payload_encodings[] = {
*/
static status_t verify(private_nonce_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if ((this->nonce.len < 16) || ((this->nonce.len > 256)))
{
/* nonce length is wrong */
@@ -25,6 +25,7 @@
#include "notify_payload.h"
#include <daemon.h>
#include <encoding/payloads/encodings.h>
#include <utils/allocator.h>
@@ -104,6 +105,11 @@ struct private_notify_payload_t {
*/
chunk_t notification_data;
/**
* Assigned logger
*/
logger_t *logger;
/**
* @brief Computes the length of this payload.
*
@@ -169,11 +175,6 @@ encoding_rule_t notify_payload_encodings[] = {
*/
static status_t verify(private_notify_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if (this->protocol_id > 3)
{
/* reserved for future use */
@@ -191,9 +192,20 @@ static status_t verify(private_notify_payload_t *this)
return FAILED;
}
dh_group = ntohs(*((u_int16_t*)this->notification_data.ptr));
if (dh_group < MODP_1024_BIT || dh_group > MODP_8192_BIT)
switch (dh_group)
{
return FAILED;
case MODP_768_BIT:
case MODP_1024_BIT:
case MODP_1536_BIT:
case MODP_2048_BIT:
case MODP_3072_BIT:
case MODP_4096_BIT:
case MODP_6144_BIT:
case MODP_8192_BIT:
break;
default:
this->logger->log(this->logger, ERROR, "Bad DH group (%d)", dh_group);
return FAILED;
}
}
return SUCCESS;
@@ -402,7 +414,7 @@ notify_payload_t *notify_payload_create()
this->compute_length = compute_length;
/* set default values of the fields */
this->critical = NOTIFY_PAYLOAD_CRITICAL_FLAG;
this->critical = FALSE;
this->next_payload = NO_PAYLOAD;
this->payload_length = NOTIFY_PAYLOAD_HEADER_LENGTH;
this->protocol_id = 0;
@@ -412,6 +424,7 @@ notify_payload_t *notify_payload_create()
this->spi_size = 0;
this->notification_data.ptr = NULL;
this->notification_data.len = 0;
this->logger = charon->logger_manager->get_logger(charon->logger_manager, PAYLOAD);
return (&(this->public));
}
@@ -29,13 +29,6 @@
#include <encoding/payloads/proposal_substructure.h>
#include <utils/linked_list.h>
/**
* Critical flag must not be set.
*
* @ingroup payloads
*/
#define NOTIFY_PAYLOAD_CRITICAL_FLAG FALSE;
/**
* Notify payload length in bytes without any spi and notification data.
*
@@ -620,7 +620,7 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
iterator->destroy(iterator);
/* take over general infos */
this->spi_size = proto == IKE ? 8 : 4;
this->spi_size = proto == PROTO_IKE ? 8 : 4;
this->spi.len = this->spi_size;
this->spi.ptr = allocator_alloc(this->spi_size);
*((u_int32_t*)this->spi.ptr) = proposal->get_spi(proposal, proto);
+2 -8
View File
@@ -118,12 +118,6 @@ static status_t verify(private_sa_payload_t *this)
status_t status = SUCCESS;
iterator_t *iterator;
bool first = TRUE;
if (this->critical)
{
/* critical bit set! */
return FAILED;
}
/* check proposal numbering */
iterator = this->proposals->create_iterator(this->proposals,TRUE);
@@ -269,7 +263,7 @@ static void add_proposal(private_sa_payload_t *this, proposal_t *proposal)
proposal->get_protocols(proposal, proto);
for (i = 0; i<2; i++)
{
if (proto[i] != UNDEFINED_PROTOCOL_ID)
if (proto[i] != PROTO_NONE)
{
substructure = proposal_substructure_create_from_proposal(proposal, proto[i]);
add_proposal_substructure(this, substructure);
@@ -356,7 +350,7 @@ sa_payload_t *sa_payload_create()
this->compute_length = compute_length;
/* set default values of the fields */
this->critical = SA_PAYLOAD_CRITICAL_FLAG;
this->critical = FALSE;
this->next_payload = NO_PAYLOAD;
this->payload_length = SA_PAYLOAD_HEADER_LENGTH;
@@ -28,13 +28,6 @@
#include <encoding/payloads/proposal_substructure.h>
#include <utils/linked_list.h>
/**
* Critical flag must not be set.
*
* @ingroup payloads
*/
#define SA_PAYLOAD_CRITICAL_FLAG FALSE;
/**
* SA_PAYLOAD length in bytes without any proposal substructure.
*
@@ -130,11 +130,6 @@ static status_t verify(private_ts_payload_t *this)
iterator_t *iterator;
status_t status = SUCCESS;
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
if (this->number_of_traffic_selectors != (this->traffic_selectors->get_count(this->traffic_selectors)))
{
/* must be the same */
@@ -102,12 +102,6 @@ encoding_rule_t vendor_id_payload_encodings[] = {
*/
static status_t verify(private_vendor_id_payload_t *this)
{
if (this->critical)
{
/* critical bit is set! */
return FAILED;
}
return SUCCESS;
}