- fixes
authorMartin Willi <martin@strongswan.org>
Fri, 2 Dec 2005 16:09:04 +0000 (16:09 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 2 Dec 2005 16:09:04 +0000 (16:09 -0000)
Source/charon/config/configuration_manager.c
Source/charon/daemon.c
Source/charon/encoding/message.c
Source/charon/encoding/payloads/encryption_payload.c
Source/charon/network/host.c
Source/charon/sa/states/ike_auth_requested.c
Source/charon/utils/logger_manager.c

index 58a831c..3669fac 100644 (file)
@@ -166,8 +166,8 @@ static void load_default_config (private_configuration_manager_t *this)
        sa_config_t *sa_config1, *sa_config2, *sa_config3;
        traffic_selector_t *ts;
        
-       init_config1 = init_config_create("152.96.193.130","152.96.193.131",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
-       init_config2 = init_config_create("152.96.193.131","152.96.193.130",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
+       init_config1 = init_config_create("0.0.0.0","152.96.193.131",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
+       init_config2 = init_config_create("0.0.0.0","152.96.193.130",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
        init_config3 = init_config_create("0.0.0.0","127.0.0.1",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
        ts = traffic_selector_create_from_string(1, TS_IPV4_ADDR_RANGE, "0.0.0.0", 0, "255.255.255.255", 65535);
        
@@ -254,6 +254,9 @@ static status_t get_init_config_for_host (private_configuration_manager_t *this,
        
        iterator = this->configurations->create_iterator(this->configurations,TRUE);
        
+       this->logger->log(this->logger, CONTROL|MORE, "getting config for hosts %s - %s", 
+                                               my_host->get_address(my_host), other_host->get_address(other_host));
+       
        while (iterator->has_next(iterator))
        {
                configuration_entry_t *entry;
@@ -268,9 +271,12 @@ static status_t get_init_config_for_host (private_configuration_manager_t *this,
                /* first check if ip is equal */
                if(config_other_host->ip_is_equal(config_other_host,other_host))
                {
+                       this->logger->log(this->logger, CONTROL|MOST, "config entry with remote host %s", 
+                                               config_other_host->get_address(config_other_host));
                        /* could be right one, check my_host for default route*/
                        if (config_my_host->is_default_route(config_my_host))
                        {
+                               printf("is default route\n");
                                *init_config = entry->init_config;
                                status = SUCCESS;
                                break;
index 08b759f..649f0b4 100644 (file)
@@ -156,7 +156,7 @@ static void kill_daemon(private_daemon_t *this, char *reason)
 static void build_test_jobs(private_daemon_t *this)
 {
        int i;
-       for(i = 0; i<1; i++)
+       for(i = 0; i<0; i++)
        {
                initiate_ike_sa_job_t *initiate_job;
                initiate_job = initiate_ike_sa_job_create("pinflb30");
index a6d2375..7fea8ae 100644 (file)
@@ -147,7 +147,7 @@ static supported_payload_entry_t supported_ike_auth_r_payloads[] =
 {
        {NOTIFY,0,1,TRUE,TRUE},
        {CERTIFICATE,0,1,TRUE,FALSE},
-       {ID_RESPONDER,0,1,TRUE,FALSE},
+       {ID_RESPONDER,1,1,TRUE,FALSE},
        {AUTHENTICATION,1,1,TRUE,FALSE},
        {SECURITY_ASSOCIATION,1,1,TRUE,FALSE},
        {TRAFFIC_SELECTOR_INITIATOR,1,1,TRUE,FALSE},
index 7ea2904..9f16a66 100644 (file)
@@ -353,6 +353,7 @@ static status_t decrypt(private_encryption_payload_t *this)
        
        /* get IV */
        iv.len = this->crypter->get_block_size(this->crypter);
+       
        iv.ptr = this->encrypted.ptr;
        
        /* point concatenated to data + padding + padding_length*/
@@ -394,7 +395,6 @@ static status_t decrypt(private_encryption_payload_t *this)
        
        /* free padding */
        this->decrypted.ptr = allocator_realloc(this->decrypted.ptr, this->decrypted.len);
-       
        this->logger->log(this->logger, CONTROL|MOST, "decryption successful, trying to parse content");
        return (this->parse(this));
 }
index 95a4537..8208586 100644 (file)
@@ -42,6 +42,11 @@ struct private_host_t {
        int family;
        
        /**
+        * string representation of host
+        */
+       char *string;
+       
+       /**
         * low-lewel structure, wich stores the address
         */
        sockaddr_t address;
@@ -78,16 +83,15 @@ static bool is_default_route (private_host_t *this)
        {
                case AF_INET: 
                {
-                       int i;
-                       for (i = 0; i < 4;i++)
+                       static u_int8_t default_route[4] = {0x00,0x00,0x00,0x00};
+                       struct sockaddr_in *sin = (struct sockaddr_in*)&(this->address);
+                       printf("host address: %ul\n", sin->sin_addr.s_addr);
+                       
+                       if (memcmp(default_route,&(sin->sin_addr.s_addr),4) == 0)
                        {
-                               struct sockaddr_in *sin = (struct sockaddr_in*)&(this->address);
-                               if (*((&sin->sin_addr.s_addr) + i) != 0)
-                               {
-                                       return FALSE;
-                               }
+                               return TRUE;
                        }
-                       return TRUE;
+                       return FALSE;
                }
                default:
                {
@@ -106,8 +110,13 @@ static char *get_address(private_host_t *this)
        {
                case AF_INET: 
                {
+                       char *string;
                        struct sockaddr_in *sin = (struct sockaddr_in*)&(this->address);
-                       return inet_ntoa(sin->sin_addr);
+                       allocator_free(this->string);
+                       string = inet_ntoa(sin->sin_addr);
+                       this->string = allocator_alloc(strlen(string)+1);
+                       strcpy(this->string, string);
+                       return this->string;
                }
                default:
                {
@@ -161,13 +170,6 @@ static u_int16_t get_port(private_host_t *this)
        }
 }
 
-/**
- * Implements host_t.destroy
- */
-static void destroy(private_host_t *this)
-{
-       allocator_free(this);
-}
 
 /**
  * Implements host_t.clone.
@@ -175,8 +177,14 @@ static void destroy(private_host_t *this)
 static private_host_t *clone(private_host_t *this)
 {
        private_host_t *new = allocator_alloc_thing(private_host_t);
+       
                
        memcpy(new, this, sizeof(private_host_t));
+       if (this->string)
+       {
+               new->string = allocator_alloc(strlen(this->string)+1);
+               strcpy(new->string, this->string);
+       }
        return new;
 }
 
@@ -203,6 +211,14 @@ static bool ip_is_equal(private_host_t *this, private_host_t *other)
        return FALSE;
 }
 
+/**
+ * Implements host_t.destroy
+ */
+static void destroy(private_host_t *this)
+{
+       allocator_free(this->string);
+       allocator_free(this);
+}
 
 /**
  * Creates an empty host_t object 
@@ -221,6 +237,8 @@ static private_host_t *host_create_empty()
        this->public.is_default_route = (bool (*) (host_t *)) is_default_route;
        this->public.destroy = (void (*) (host_t*))destroy;
        
+       this->string = NULL;
+       
        return this;
 }
 
index 723550d..e432421 100644 (file)
@@ -259,24 +259,21 @@ static status_t process_idr_payload(private_ike_auth_requested_t *this, id_paylo
 {
        identification_t *other_id, *configured_other_id;
        
-       /* idr is optional */
-       if (idr_payload)
+       other_id = idr_payload->get_identification(idr_payload);
+
+       configured_other_id = this->sa_config->get_other_id(this->sa_config);
+       if (configured_other_id)
        {
-               other_id = idr_payload->get_identification(idr_payload);
-       
-               configured_other_id = this->sa_config->get_other_id(this->sa_config);
-               if (configured_other_id)
+               if (!other_id->equals(other_id, configured_other_id))
                {
-                       if (!other_id->equals(other_id, configured_other_id))
-                       {
-                               this->logger->log(this->logger, ERROR, "IKE_AUTH reply didn't contain requested id");
-                               return FAILED;  
-                       }
+                       other_id->destroy(other_id);
+                       this->logger->log(this->logger, ERROR, "IKE_AUTH reply didn't contain requested id");
+                       return FAILED;  
                }
-               
-               other_id->destroy(other_id);
-               /* TODO do we have to store other_id  somewhere ? */
        }
+       
+       other_id->destroy(other_id);
+       /* TODO do we have to store other_id  somewhere ? */
        return SUCCESS;
 }
 
index 8c19e9d..631f8f1 100644 (file)
@@ -151,6 +151,7 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t
                case MESSAGE:
                case ENCRYPTION_PAYLOAD:
                case WORKER:
+               case CONFIGURATION_MANAGER:
                        logger_level |= ALL;
                case PARSER:
                case GENERATOR:
@@ -160,13 +161,11 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t
                case RECEIVER:
                case SOCKET:
                case DAEMON:
-               case CONFIGURATION_MANAGER:
                        log_thread_ids = FALSE;
                        logger_level |= ERROR|CONTROL;
                        break;
        }
        
-       
        /* reduce to global definiton of loglevel */
        logger_level &= this->public.get_logger_level(&(this->public),context);