- works quite well now with ipsec.conf & ipsec starter
This commit is contained in:
@@ -115,6 +115,28 @@ static bool equals (private_identification_t *this,private_identification_t *oth
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of identification_t.belongs_to.
|
||||
*/
|
||||
static bool belongs_to(private_identification_t *this, private_identification_t *other)
|
||||
{
|
||||
if (this->public.equals(&this->public, &other->public))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (this->type == other->type && this->type == ID_IPV4_ADDR)
|
||||
{
|
||||
/* is this %any (0.0.0.0)?*/
|
||||
if (*((u_int32_t*)this->encoded.ptr) == 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
/* TODO: Do we need subnet support? */
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of identification_t.clone.
|
||||
*/
|
||||
@@ -150,6 +172,7 @@ static private_identification_t *identification_create()
|
||||
private_identification_t *this = allocator_alloc_thing(private_identification_t);
|
||||
|
||||
this->public.equals = (bool (*) (identification_t*,identification_t*))equals;
|
||||
this->public.belongs_to = (bool (*) (identification_t*,identification_t*))belongs_to;
|
||||
this->public.get_encoding = (chunk_t (*) (identification_t*))get_encoding;
|
||||
this->public.get_type = (id_type_t (*) (identification_t*))get_type;
|
||||
this->public.get_string = (char* (*) (identification_t*))get_string;
|
||||
|
||||
@@ -152,6 +152,20 @@ struct identification_t {
|
||||
*/
|
||||
bool (*equals) (identification_t *this,identification_t *other);
|
||||
|
||||
/**
|
||||
* @brief Check if an ID belongs to a wildcard ID.
|
||||
*
|
||||
* An identification_t may contain wildcards, such as
|
||||
* *@strongswan.org. This call checks if a given ID
|
||||
* (e.g. [email protected]) belongs to a such wildcard
|
||||
* ID. Returns TRUE if IDs are identical.
|
||||
*
|
||||
* @param this the ID containing a wildcard
|
||||
* @param other the ID without wildcard
|
||||
* @return TRUE if other belongs to this
|
||||
*/
|
||||
bool (*belongs_to) (identification_t *this, identification_t *other);
|
||||
|
||||
/**
|
||||
* @brief Clone a identification_t instance.
|
||||
*
|
||||
|
||||
@@ -178,6 +178,7 @@ static void log_bytes(private_logger_t *this, logger_level_t loglevel, char *lab
|
||||
if ((this->level & loglevel) == loglevel)
|
||||
{
|
||||
char buffer[MAX_LOG];
|
||||
char ascii_buffer[17];
|
||||
char *format;
|
||||
char *buffer_pos;
|
||||
char *bytes_pos, *bytes_roof;
|
||||
@@ -207,6 +208,7 @@ static void log_bytes(private_logger_t *this, logger_level_t loglevel, char *lab
|
||||
bytes_pos = bytes;
|
||||
bytes_roof = bytes + len;
|
||||
buffer_pos = buffer;
|
||||
memset(ascii_buffer, 0, 17);
|
||||
|
||||
for (i = 1; bytes_pos < bytes_roof; i++)
|
||||
{
|
||||
@@ -219,30 +221,34 @@ static void log_bytes(private_logger_t *this, logger_level_t loglevel, char *lab
|
||||
buffer_pos = buffer;
|
||||
if (this->output == NULL)
|
||||
{
|
||||
syslog(LOG_INFO, "[=>] [%5d ] %s", line_start, buffer);
|
||||
syslog(LOG_INFO, "[=>] [%5d ] %s %s", line_start, buffer, ascii_buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(this->output, "[=>] [%5d ] %s\n", line_start, buffer);
|
||||
fprintf(this->output, "[=>] [%5d ] %s %s\n", line_start, buffer, ascii_buffer);
|
||||
}
|
||||
memset(ascii_buffer, 0, 16);
|
||||
line_start += 16;
|
||||
}
|
||||
else if ((i % 8) == 0)
|
||||
{
|
||||
*buffer_pos++ = ' ';
|
||||
*buffer_pos++ = ' ';
|
||||
*buffer_pos++ = ' ';
|
||||
}
|
||||
else if ((i % 4) == 0)
|
||||
{
|
||||
*buffer_pos++ = ' ';
|
||||
*buffer_pos++ = ' ';
|
||||
// *buffer_pos++ = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
*buffer_pos++ = ' ';
|
||||
}
|
||||
|
||||
if (*bytes_pos > 31 && *bytes_pos < 127)
|
||||
{
|
||||
ascii_buffer[(i % 16)] = *bytes_pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
ascii_buffer[(i % 16)] = '*';
|
||||
}
|
||||
|
||||
bytes_pos++;
|
||||
}
|
||||
|
||||
@@ -252,11 +258,11 @@ static void log_bytes(private_logger_t *this, logger_level_t loglevel, char *lab
|
||||
buffer_pos = buffer;
|
||||
if (this->output == NULL)
|
||||
{
|
||||
syslog(LOG_INFO, "[=>] [%5d ] %s", line_start, buffer);
|
||||
syslog(LOG_INFO, "[=>] [%5d ] %s %16s", line_start, buffer, ascii_buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(this->output, "[=>] [%5d ] %s\n", line_start, buffer);
|
||||
fprintf(this->output, "[=>] [%5d ] %s %16s\n", line_start, buffer, ascii_buffer);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
Reference in New Issue
Block a user