- applied andreas's patch

- logger output improvements
  - testin gupdates
  - and a lot more
This commit is contained in:
Martin Willi
2006-05-18 06:02:28 +00:00
parent 1e93135408
commit b5e1560659
151 changed files with 348 additions and 203 deletions
+11 -13
View File
@@ -77,21 +77,17 @@ static socklen_t *get_sockaddr_len(private_host_t *this)
}
/**
* Implementation of host_t.is_default_route.
* Implementation of host_t.is_anyaddr.
*/
static bool is_default_route (private_host_t *this)
static bool is_anyaddr(private_host_t *this)
{
switch (this->family)
{
case AF_INET:
{
static u_int8_t default_route[4] = {0x00,0x00,0x00,0x00};
static u_int8_t default_route[4] = {0x00, 0x00, 0x00, 0x00};
if (memcmp(default_route,&(this->address4.sin_addr.s_addr),4) == 0)
{
return TRUE;
}
return FALSE;
return !memcmp(default_route, &(this->address4.sin_addr.s_addr), 4);
}
default:
{
@@ -114,10 +110,12 @@ static char *get_address(private_host_t *this)
/* we need to clone it, since inet_ntoa overwrites
* internal buffer on subsequent calls
*/
free(this->string);
string = inet_ntoa(this->address4.sin_addr);
this->string = malloc(strlen(string)+1);
strcpy(this->string, string);
if (this->string == NULL)
{
string = is_anyaddr(this)? "%any" : inet_ntoa(this->address4.sin_addr);
this->string = malloc(strlen(string)+1);
strcpy(this->string, string);
}
return this->string;
}
default:
@@ -275,7 +273,7 @@ static private_host_t *host_create_empty(void)
this->public.get_port = (u_int16_t (*) (host_t *))get_port;
this->public.ip_equals = (bool (*) (host_t *,host_t *)) ip_equals;
this->public.equals = (bool (*) (host_t *,host_t *)) equals;
this->public.is_default_route = (bool (*) (host_t *)) is_default_route;
this->public.is_anyaddr = (bool (*) (host_t *)) is_anyaddr;
this->public.destroy = (void (*) (host_t*))destroy;
this->string = NULL;
+1 -1
View File
@@ -126,7 +126,7 @@ struct host_t {
* - TRUE if host has IP 0.0.0.0 for default route
* - FALSE otherwise
*/
bool (*is_default_route) (host_t *this);
bool (*is_anyaddr) (host_t *this);
/**
* @brief get the address of this host as chunk_t
+5 -5
View File
@@ -122,9 +122,9 @@ static void prepend_prefix(private_logger_t *this, log_level_t loglevel, const c
if (this->log_thread_id)
{
snprintf(thread_id, sizeof(thread_id), " @%d", (int)pthread_self());
snprintf(thread_id, sizeof(thread_id), "%06d", (int)pthread_self());
}
snprintf(buffer, MAX_LOG, "[%c%c:%s]%s %s", log_type, log_details, this->name, thread_id, string);
snprintf(buffer, MAX_LOG, "%s[%c%c:%s] %s", thread_id, log_type, log_details, this->name, string);
}
/**
@@ -200,7 +200,7 @@ static void log_bytes(private_logger_t *this, log_level_t loglevel, const char *
if (this->log_thread_id)
{
snprintf(thread_id, sizeof(thread_id), " @%d", (int)pthread_self());
snprintf(thread_id, sizeof(thread_id), "%06d", (int)pthread_self());
}
/* since me can't do multi-line output to syslog,
@@ -244,11 +244,11 @@ static void log_bytes(private_logger_t *this, log_level_t loglevel, const char *
if (this->output == NULL)
{
syslog(get_priority(loglevel), "[ :%5d]%s %s %s", line_start, thread_id, buffer, ascii_buffer);
syslog(get_priority(loglevel), "%s[ :%5d] %s %s", thread_id, line_start, buffer, ascii_buffer);
}
else
{
fprintf(this->output, "[ :%5d]%s %s %s\n", line_start, thread_id, buffer, ascii_buffer);
fprintf(this->output, "%s[ :%5d] %s %s\n", thread_id, line_start, buffer, ascii_buffer);
}
buffer_pos = buffer;
line_start += MAX_BYTES;
+8 -8
View File
@@ -66,14 +66,14 @@ struct {
{ "SAMGR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* IKE_SA_MANAGER */
{ "CHDSA", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* CHILD_SA */
{ "MESSG", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* MESSAGE */
{ "TPOOL", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* THREAD_POOL */
{ "TPOOL", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* THREAD_POOL */
{ "WORKR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* WORKER */
{ "SCHED", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* SCHEDULER */
{ "SENDR", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* SENDER */
{ "RECVR", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* RECEIVER */
{ "SOCKT", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* SOCKET */
{ "TESTR", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* TESTER */
{ "DAEMN", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* DAEMON */
{ "SCHED", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* SCHEDULER */
{ "SENDR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* SENDER */
{ "RECVR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* RECEIVER */
{ "SOCKT", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* SOCKET */
{ "TESTR", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* TESTER */
{ "DAEMN", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* DAEMON */
{ "CONFG", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* CONFIG */
{ "ENCPL", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* ENCRYPTION_PAYLOAD */
{ "PAYLD", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* PAYLOAD */
@@ -81,7 +81,7 @@ struct {
{ "DEREC", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* DER_ENCODER */
{ "ASN_1", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* ASN1 */
{ "XFRM ", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* XFRM */
{ "LEAKD", ERROR|CONTROL|AUDIT|LEVEL0, FALSE}, /* LEAK_DETECT */
{ "LEAKD", ERROR|CONTROL|AUDIT|LEVEL0, TRUE }, /* LEAK_DETECT */
};