fixed a bug introduced in [3973]
[strongswan.git] / src / charon / config / child_cfg.c
index 510d9a6..33dd73c 100644 (file)
@@ -1,4 +1,5 @@
 /*
 /*
+ * Copyright (C) 2008 Tobias Brunner
  * Copyright (C) 2005-2007 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
  * Copyright (C) 2005-2007 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
@@ -34,6 +35,15 @@ ENUM(action_names, ACTION_NONE, ACTION_RESTART,
        "ACTION_RESTART",
 );
 
        "ACTION_RESTART",
 );
 
+ENUM_BEGIN(ipcomp_transform_names, IPCOMP_NONE, IPCOMP_NONE, 
+       "IPCOMP_NONE");
+ENUM_NEXT(ipcomp_transform_names, IPCOMP_OUI, IPCOMP_LZJH, IPCOMP_NONE,
+       "IPCOMP_OUI",
+       "IPCOMP_DEFLATE",
+       "IPCOMP_LZS",
+       "IPCOMP_LZJH");
+ENUM_END(ipcomp_transform_names, IPCOMP_LZJH);
+
 typedef struct private_child_cfg_t private_child_cfg_t;
 
 /**
 typedef struct private_child_cfg_t private_child_cfg_t;
 
 /**
@@ -87,9 +97,14 @@ struct private_child_cfg_t {
        mode_t mode;
        
        /**
        mode_t mode;
        
        /**
-        * action to take on DPD/passive close
+        * action to take on DPD
         */
         */
-       action_t action;
+       action_t dpd_action;
+       
+       /**
+        * action to take on CHILD_SA close
+        */
+       action_t close_action;
        
        /**
         * Time before an SA gets invalid
        
        /**
         * Time before an SA gets invalid
@@ -106,6 +121,11 @@ struct private_child_cfg_t {
         * substracted from rekeytime.
         */
        u_int32_t jitter;
         * substracted from rekeytime.
         */
        u_int32_t jitter;
+       
+       /**
+        * enable IPComp
+        */
+       bool use_ipcomp;
 };
 
 /**
 };
 
 /**
@@ -357,11 +377,19 @@ static mode_t get_mode(private_child_cfg_t *this)
 }
 
 /**
 }
 
 /**
- * Implementation of child_cfg_t.get_action
+ * Implementation of child_cfg_t.get_dpd_action
+ */
+static action_t get_dpd_action(private_child_cfg_t *this)
+{
+       return this->dpd_action;
+}
+
+/**
+ * Implementation of child_cfg_t.get_close_action
  */
  */
-static action_t get_action(private_child_cfg_t *this)
+static action_t get_close_action(private_child_cfg_t *this)
 {
 {
-       return this->action;
+       return this->close_action;
 }
 
 /**
 }
 
 /**
@@ -386,11 +414,20 @@ static diffie_hellman_group_t get_dh_group(private_child_cfg_t *this)
 }
 
 /**
 }
 
 /**
+ * Implementation of child_cfg_t.use_ipcomp.
+ */
+static bool use_ipcomp(private_child_cfg_t *this)
+{
+       return this->use_ipcomp;
+}
+
+/**
  * Implementation of child_cfg_t.get_name
  */
  * Implementation of child_cfg_t.get_name
  */
-static void get_ref(private_child_cfg_t *this)
+static child_cfg_t* get_ref(private_child_cfg_t *this)
 {
        ref_get(&this->refcount);
 {
        ref_get(&this->refcount);
+       return &this->public;
 }
 
 /**
 }
 
 /**
@@ -418,7 +455,7 @@ static void destroy(private_child_cfg_t *this)
 child_cfg_t *child_cfg_create(char *name, u_int32_t lifetime,
                                                          u_int32_t rekeytime, u_int32_t jitter,
                                                          char *updown, bool hostaccess, mode_t mode,
 child_cfg_t *child_cfg_create(char *name, u_int32_t lifetime,
                                                          u_int32_t rekeytime, u_int32_t jitter,
                                                          char *updown, bool hostaccess, mode_t mode,
-                                                         action_t action)
+                                                         action_t dpd_action, action_t close_action, bool ipcomp)
 {
        private_child_cfg_t *this = malloc_thing(private_child_cfg_t);
 
 {
        private_child_cfg_t *this = malloc_thing(private_child_cfg_t);
 
@@ -431,10 +468,12 @@ child_cfg_t *child_cfg_create(char *name, u_int32_t lifetime,
        this->public.get_updown = (char* (*) (child_cfg_t*))get_updown;
        this->public.get_hostaccess = (bool (*) (child_cfg_t*))get_hostaccess;
        this->public.get_mode = (mode_t (*) (child_cfg_t *))get_mode;
        this->public.get_updown = (char* (*) (child_cfg_t*))get_updown;
        this->public.get_hostaccess = (bool (*) (child_cfg_t*))get_hostaccess;
        this->public.get_mode = (mode_t (*) (child_cfg_t *))get_mode;
-       this->public.get_action = (action_t (*) (child_cfg_t *))get_action;
+       this->public.get_dpd_action = (action_t (*) (child_cfg_t *))get_dpd_action;
+       this->public.get_close_action = (action_t (*) (child_cfg_t *))get_close_action;
        this->public.get_lifetime = (u_int32_t (*) (child_cfg_t *,bool))get_lifetime;
        this->public.get_dh_group = (diffie_hellman_group_t(*)(child_cfg_t*)) get_dh_group;
        this->public.get_lifetime = (u_int32_t (*) (child_cfg_t *,bool))get_lifetime;
        this->public.get_dh_group = (diffie_hellman_group_t(*)(child_cfg_t*)) get_dh_group;
-       this->public.get_ref = (void (*) (child_cfg_t*))get_ref;
+       this->public.use_ipcomp = (bool (*) (child_cfg_t *))use_ipcomp;
+       this->public.get_ref = (child_cfg_t* (*) (child_cfg_t*))get_ref;
        this->public.destroy = (void (*) (child_cfg_t*))destroy;
        
        this->name = strdup(name);
        this->public.destroy = (void (*) (child_cfg_t*))destroy;
        
        this->name = strdup(name);
@@ -444,7 +483,9 @@ child_cfg_t *child_cfg_create(char *name, u_int32_t lifetime,
        this->updown = updown ? strdup(updown) : NULL;
        this->hostaccess = hostaccess;
        this->mode = mode;
        this->updown = updown ? strdup(updown) : NULL;
        this->hostaccess = hostaccess;
        this->mode = mode;
-       this->action = action;
+       this->dpd_action = dpd_action;
+       this->close_action = close_action;
+       this->use_ipcomp = ipcomp; 
        this->refcount = 1;
        this->proposals = linked_list_create();
        this->my_ts = linked_list_create();
        this->refcount = 1;
        this->proposals = linked_list_create();
        this->my_ts = linked_list_create();