Support an "any" IKE version for both IKEv1 or IKEv2
authorMartin Willi <martin@revosec.ch>
Sat, 17 Dec 2011 11:48:14 +0000 (12:48 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:25 +0000 (17:31 +0100)
src/libcharon/config/peer_cfg.h
src/libcharon/plugins/stroke/stroke_config.c
src/libcharon/plugins/stroke/stroke_socket.c
src/libcharon/sa/keymat.c
src/libcharon/sa/task_manager.c
src/starter/confread.h
src/starter/starterstroke.c
src/stroke/stroke.c
src/stroke/stroke_msg.h

index 33309d1..f191561 100644 (file)
@@ -43,6 +43,8 @@ typedef struct peer_cfg_t peer_cfg_t;
  * IKE version.
  */
 enum ike_version_t {
+       /** any version */
+       IKE_ANY = 0,
        /** IKE version 1 */
        IKEV1 = 1,
        /** IKE version 2 */
index c4b218d..08339a4 100644 (file)
@@ -686,7 +686,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
         * the pool name as the connection name, which the attribute provider
         * uses to serve pool addresses. */
        peer_cfg = peer_cfg_create(msg->add_conn.name,
-               msg->add_conn.ikev2 ? IKEV2 : IKEV1, ike_cfg,
+               msg->add_conn.version, ike_cfg,
                msg->add_conn.me.sendcert, unique,
                msg->add_conn.rekey.tries, rekey, reauth, jitter, over,
                msg->add_conn.mobike, msg->add_conn.dpd.delay,
index 7a14be0..21d15af 100644 (file)
@@ -197,7 +197,7 @@ static void stroke_add_conn(private_stroke_socket_t *this, stroke_msg_t *msg)
        DBG2(DBG_CFG, "  mediation=%s", msg->add_conn.ikeme.mediation ? "yes" : "no");
        DBG2(DBG_CFG, "  mediated_by=%s", msg->add_conn.ikeme.mediated_by);
        DBG2(DBG_CFG, "  me_peerid=%s", msg->add_conn.ikeme.peerid);
-       DBG2(DBG_CFG, "  keyexchange=%s", msg->add_conn.ikev2 ? "ikev2" : "ikev1");
+       DBG2(DBG_CFG, "  keyexchange=ikev%u", msg->add_conn.version);
 
        this->config->add(this->config, msg);
        this->attribute->add_pool(this->attribute, msg);
index 2fa4423..f132822 100644 (file)
@@ -28,8 +28,9 @@ keymat_t *keymat_create(ike_version_t version, bool initiator)
                        return &keymat_v1_create(initiator)->keymat;
                case IKEV2:
                        return &keymat_v2_create(initiator)->keymat;
+               default:
+                       return NULL;
        }
-       return NULL;
 }
 
 /**
index eea2320..3538087 100644 (file)
@@ -28,6 +28,8 @@ task_manager_t *task_manager_create(ike_sa_t *ike_sa)
                        return &task_manager_v1_create(ike_sa)->task_manager;
                case IKEV2:
                        return &task_manager_v2_create(ike_sa)->task_manager;
+               default:
+                       return NULL;
        }
-       return NULL;
 }
+
index 988b8ed..47bd846 100644 (file)
@@ -39,9 +39,10 @@ typedef enum {
 } starter_state_t;
 
 typedef enum {
-               KEY_EXCHANGE_IKE,
-               KEY_EXCHANGE_IKEV1,
-               KEY_EXCHANGE_IKEV2
+               /* shared with ike_version_t */
+               KEY_EXCHANGE_IKE = 0,
+               KEY_EXCHANGE_IKEV1 = 1,
+               KEY_EXCHANGE_IKEV2 = 2,
 } keyexchange_t;
 
 typedef enum {
index 628d632..c4d9fa2 100644 (file)
@@ -196,7 +196,7 @@ int starter_stroke_add_conn(starter_config_t *cfg, starter_conn_t *conn)
        memset(&msg, 0, sizeof(msg));
        msg.type = STR_ADD_CONN;
        msg.length = offsetof(stroke_msg_t, buffer);
-       msg.add_conn.ikev2 = conn->keyexchange != KEY_EXCHANGE_IKEV1;
+       msg.add_conn.version = conn->keyexchange;
        msg.add_conn.name = push_string(&msg, connection_name(conn));
 
        /* PUBKEY is preferred to PSK and EAP */
index a27c374..697115a 100644 (file)
@@ -138,7 +138,7 @@ static int add_connection(char *name,
        msg.type = STR_ADD_CONN;
 
        msg.add_conn.name = push_string(&msg, name);
-       msg.add_conn.ikev2 = 1;
+       msg.add_conn.version = 2;
        msg.add_conn.auth_method = 2;
        msg.add_conn.mode = 1;
        msg.add_conn.mobike = 1;
index 3350d76..af566b9 100644 (file)
@@ -239,7 +239,7 @@ struct stroke_msg_t {
                /* data for STR_ADD_CONN */
                struct {
                        char *name;
-                       int ikev2;
+                       int version;
                        /* next three are deprecated, use stroke_end_t.auth instead */
                        int auth_method;
                        u_int32_t eap_type;