Replaced usages of CHARON_*_PORT with calls to get_port().
authorTobias Brunner <tobias@strongswan.org>
Fri, 20 Apr 2012 08:59:14 +0000 (10:59 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 Aug 2012 13:12:25 +0000 (15:12 +0200)
14 files changed:
src/charon-nm/nm/nm_service.c
src/libcharon/plugins/android/android_service.c
src/libcharon/plugins/ha/ha_tunnel.c
src/libcharon/plugins/load_tester/load_tester_config.c
src/libcharon/plugins/maemo/maemo_service.c
src/libcharon/plugins/medcli/medcli_config.c
src/libcharon/plugins/medsrv/medsrv_config.c
src/libcharon/plugins/sql/sql_config.c
src/libcharon/plugins/stroke/stroke_config.c
src/libcharon/plugins/uci/uci_config.c
src/libcharon/processing/jobs/migrate_job.c
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ikev1/tasks/informational.c
src/libcharon/sa/ikev2/tasks/ike_mobike.c

index affe281..ccfa210 100644 (file)
@@ -497,7 +497,8 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
        /**
         * Set up configurations
         */
-       ike_cfg = ike_cfg_create(TRUE, encap, "0.0.0.0", FALSE, CHARON_UDP_PORT,
+       ike_cfg = ike_cfg_create(TRUE, encap, "0.0.0.0", FALSE,
+                                                        charon->socket->get_port(charon->socket, FALSE),
                                                        (char*)address, FALSE, IKEV2_UDP_PORT);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        peer_cfg = peer_cfg_create(priv->name, IKEV2, ike_cfg,
index c5553f2..f2d8ddc 100644 (file)
@@ -264,7 +264,8 @@ static job_requeue_t initiate(private_android_service_t *this)
                this->creds->set_username_password(this->creds, user, password);
        }
 
-       ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", FALSE, CHARON_UDP_PORT,
+       ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", FALSE,
+                                                        charon->socket->get_port(charon->socket, FALSE),
                                                         hostname, FALSE, IKEV2_UDP_PORT);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
 
index 200733c..ad458ca 100644 (file)
@@ -203,7 +203,8 @@ static void setup_tunnel(private_ha_tunnel_t *this,
        lib->credmgr->add_set(lib->credmgr, &this->creds.public);
 
        /* create config and backend */
-       ike_cfg = ike_cfg_create(FALSE, FALSE, local, FALSE, CHARON_UDP_PORT,
+       ike_cfg = ike_cfg_create(FALSE, FALSE, local, FALSE,
+                                                        charon->socket->get_port(charon->socket, FALSE),
                                                         remote, FALSE, IKEV2_UDP_PORT);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        peer_cfg = peer_cfg_create("ha", IKEV2, ike_cfg, CERT_NEVER_SEND,
index 2e02fb5..f5da8b8 100644 (file)
@@ -257,7 +257,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
        else
        {
                ike_cfg = ike_cfg_create(FALSE, FALSE,
-                                                                this->local, FALSE, CHARON_UDP_PORT,
+                                                                this->local, FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                                 this->remote, FALSE, IKEV2_UDP_PORT);
        }
        ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
index 9f1f169..f638a81 100644 (file)
@@ -323,7 +323,8 @@ static gboolean initiate_connection(private_maemo_service_t *this,
                                                                NULL);
        }
 
-       ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", FALSE, CHARON_UDP_PORT,
+       ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", FALSE,
+                                                        charon->socket->get_port(charon->socket, FALSE),
                                                         hostname, FALSE, IKEV2_UDP_PORT);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
 
index 6b28f75..829c8f0 100644 (file)
@@ -119,7 +119,7 @@ METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
                return NULL;
        }
        ike_cfg = ike_cfg_create(FALSE, FALSE,
-                                                        "0.0.0.0", FALSE, CHARON_UDP_PORT,
+                                                        "0.0.0.0", FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                         address, FALSE, IKEV2_UDP_PORT);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        med_cfg = peer_cfg_create(
@@ -396,7 +396,7 @@ medcli_config_t *medcli_config_create(database_t *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(FALSE, FALSE,
-                                                         "0.0.0.0", FALSE, CHARON_UDP_PORT,
+                                                         "0.0.0.0", FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                          "0.0.0.0", FALSE, IKEV2_UDP_PORT),
        );
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
index b19847b..ebc142d 100644 (file)
@@ -141,7 +141,7 @@ medsrv_config_t *medsrv_config_create(database_t *db)
                .rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200),
                .dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300),
                .ike = ike_cfg_create(FALSE, FALSE,
-                                                         "0.0.0.0", FALSE, CHARON_UDP_PORT,
+                                                         "0.0.0.0", FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                          "0.0.0.0", FALSE, IKEV2_UDP_PORT),
        );
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
index 28b493e..8900771 100644 (file)
@@ -259,7 +259,7 @@ static ike_cfg_t *build_ike_cfg(private_sql_config_t *this, enumerator_t *e,
                ike_cfg_t *ike_cfg;
 
                ike_cfg = ike_cfg_create(certreq, force_encap,
-                                                                local, FALSE, CHARON_UDP_PORT,
+                                                                local, FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                                 remote, FALSE, IKEV2_UDP_PORT);
                add_ike_proposals(this, ike_cfg, id);
                return ike_cfg;
index 83f04bd..bf93f2c 100644 (file)
@@ -226,7 +226,8 @@ static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg
                }
        }
        ikeport = msg->add_conn.me.ikeport;
-       ikeport = (ikeport == IKEV2_UDP_PORT) ? CHARON_UDP_PORT : ikeport;
+       ikeport = (ikeport == IKEV2_UDP_PORT) ?
+                          charon->socket->get_port(charon->socket, FALSE) : ikeport;
        ike_cfg = ike_cfg_create(msg->add_conn.other.sendcert != CERT_NEVER_SEND,
                                                         msg->add_conn.force_encap,
                                                         msg->add_conn.me.address,
index 9dc0cfc..5b698b8 100644 (file)
@@ -169,7 +169,7 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
        {
                DESTROY_IF(this->peer_cfg);
                ike_cfg = ike_cfg_create(FALSE, FALSE,
-                                                                local_addr, FALSE, CHARON_UDP_PORT,
+                                                                local_addr, FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                                 remote_addr, FALSE, IKEV2_UDP_PORT);
                ike_cfg->add_proposal(ike_cfg, create_proposal(ike_proposal, PROTO_IKE));
                this->peer_cfg = peer_cfg_create(
@@ -267,7 +267,7 @@ METHOD(enumerator_t, ike_enumerator_enumerate, bool,
        {
                DESTROY_IF(this->ike_cfg);
                this->ike_cfg = ike_cfg_create(FALSE, FALSE,
-                                                                          local_addr, FALSE, CHARON_UDP_PORT,
+                                                                          local_addr, FALSE, charon->socket->get_port(charon->socket, FALSE),
                                                                           remote_addr, FALSE, IKEV2_UDP_PORT);
                this->ike_cfg->add_proposal(this->ike_cfg,
                                                                        create_proposal(ike_proposal, PROTO_IKE));
index 6e5b4af..57f3449 100644 (file)
@@ -97,7 +97,7 @@ METHOD(job_t, execute, job_requeue_t,
                ike_sa->set_kmaddress(ike_sa, this->local, this->remote);
 
                host = this->local->clone(this->local);
-               host->set_port(host, CHARON_UDP_PORT);
+               host->set_port(host, charon->socket->get_port(charon->socket, FALSE));
                ike_sa->set_my_host(ike_sa, host);
 
                host = this->remote->clone(this->remote);
index 755e5d7..d9e4ca5 100644 (file)
@@ -845,9 +845,11 @@ METHOD(ike_sa_t, float_ports, void,
           private_ike_sa_t *this)
 {
        /* do not switch if we have a custom port from MOBIKE/NAT */
-       if (this->my_host->get_port(this->my_host) == CHARON_UDP_PORT)
+       if (this->my_host->get_port(this->my_host) ==
+                       charon->socket->get_port(charon->socket, FALSE))
        {
-               this->my_host->set_port(this->my_host, CHARON_NATT_PORT);
+               this->my_host->set_port(this->my_host,
+                                                               charon->socket->get_port(charon->socket, TRUE));
        }
        if (this->other_host->get_port(this->other_host) == IKEV2_UDP_PORT)
        {
@@ -1054,7 +1056,7 @@ static void resolve_hosts(private_ike_sa_t *this)
        if (this->local_host)
        {
                host = this->local_host->clone(this->local_host);
-               host->set_port(host, CHARON_UDP_PORT);
+               host->set_port(host, charon->socket->get_port(charon->socket, FALSE));
        }
        else
        {
@@ -2239,7 +2241,8 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
        }
 
        this->task_manager = task_manager_create(&this->public);
-       this->my_host->set_port(this->my_host, CHARON_UDP_PORT);
+       this->my_host->set_port(this->my_host,
+                                                       charon->socket->get_port(charon->socket, FALSE));
 
        if (!this->task_manager || !this->keymat)
        {
index eee716c..bda1d2a 100644 (file)
@@ -116,7 +116,8 @@ METHOD(task_t, process_r, status_t,
                                                         notify_type_names, type, redirect);
                                                /* Cisco boxes reject the first message from 4500 */
                                                me = this->ike_sa->get_my_host(this->ike_sa);
-                                               me->set_port(me, CHARON_UDP_PORT);
+                                               me->set_port(me, charon->socket->get_port(
+                                                                                                               charon->socket, FALSE));
                                                this->ike_sa->set_other_host(this->ike_sa, redirect);
                                                this->ike_sa->reauth(this->ike_sa);
                                                enumerator->destroy(enumerator);
index 388b45c..133bc29 100644 (file)
@@ -277,9 +277,13 @@ static void apply_port(host_t *host, host_t *old, u_int16_t port, bool local)
        {
                port = old->get_port(old);
        }
-       else if (port == (local ? CHARON_UDP_PORT : IKEV2_UDP_PORT))
+       else if (local && port == charon->socket->get_port(charon->socket, FALSE))
        {
-               port = (local ? CHARON_NATT_PORT : IKEV2_NATT_PORT);
+               port = charon->socket->get_port(charon->socket, TRUE);
+       }
+       else if (!local && port == IKEV2_UDP_PORT)
+       {
+               port = IKEV2_NATT_PORT;
        }
        host->set_port(host, port);
 }