]> git.ipfire.org Git - thirdparty/strongswan.git/blobdiff - src/libcharon/plugins/medcli/medcli_config.c
ike-cfg: Pass arguments as struct
[thirdparty/strongswan.git] / src / libcharon / plugins / medcli / medcli_config.c
index f3499017604773dd4738cdc349db9d1b059d8b05..be42d7d7d01c6d2ede38376c7f94a723038d5d15 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -87,9 +87,15 @@ static peer_cfg_t *build_mediation_config(private_medcli_config_t *this,
        auth_cfg_t *auth;
        ike_cfg_t *ike_cfg;
        peer_cfg_t *med_cfg;
+       ike_cfg_create_t ike = {
+               .version = IKEV2,
+               .local = "0.0.0.0",
+               .local_port = charon->socket->get_port(charon->socket, FALSE),
+               .remote_port = IKEV2_UDP_PORT,
+               .no_certreq = TRUE,
+       };
        peer_cfg_create_t peer = *defaults;
        chunk_t me, other;
-       char *address;
 
        /* query mediation server config:
         * - build ike_cfg/peer_cfg for mediation connection on-the-fly
@@ -98,14 +104,12 @@ static peer_cfg_t *build_mediation_config(private_medcli_config_t *this,
                        "SELECT Address, ClientConfig.KeyId, MediationServerConfig.KeyId "
                        "FROM MediationServerConfig JOIN ClientConfig",
                        DB_TEXT, DB_BLOB, DB_BLOB);
-       if (!e || !e->enumerate(e, &address, &me, &other))
+       if (!e || !e->enumerate(e, &ike.remote, &me, &other))
        {
                DESTROY_IF(e);
                return NULL;
        }
-       ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, "0.0.0.0",
-                                                        charon->socket->get_port(charon->socket, FALSE),
-                                                        address, IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
+       ike_cfg = ike_cfg_create(&ike);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        ike_cfg->add_proposal(ike_cfg, proposal_create_default_aead(PROTO_IKE));
 
@@ -397,6 +401,14 @@ METHOD(medcli_config_t, destroy, void,
 medcli_config_t *medcli_config_create(database_t *db)
 {
        private_medcli_config_t *this;
+       ike_cfg_create_t ike = {
+               .version = IKEV2,
+               .local = "0.0.0.0",
+               .local_port = charon->socket->get_port(charon->socket, FALSE),
+               .remote = "0.0.0.0",
+               .remote_port = IKEV2_UDP_PORT,
+               .no_certreq = TRUE,
+       };
 
        INIT(this,
                .public = {
@@ -410,10 +422,7 @@ medcli_config_t *medcli_config_create(database_t *db)
                .db = db,
                .rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200),
                .dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300),
-               .ike = ike_cfg_create(IKEV2, FALSE, FALSE, "0.0.0.0",
-                                                         charon->socket->get_port(charon->socket, FALSE),
-                                                         "0.0.0.0", IKEV2_UDP_PORT,
-                                                         FRAGMENTATION_NO, 0),
+               .ike = ike_cfg_create(&ike),
        );
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
        this->ike->add_proposal(this->ike, proposal_create_default_aead(PROTO_IKE));