Add a DSCP configuration value to IKE configs
authorMartin Willi <martin@revosec.ch>
Wed, 6 Feb 2013 13:57:15 +0000 (14:57 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 6 Feb 2013 14:20:32 +0000 (15:20 +0100)
14 files changed:
src/charon-nm/nm/nm_service.c
src/conftest/config.c
src/frontends/android/jni/libandroidbridge/backend/android_service.c
src/libcharon/config/ike_cfg.c
src/libcharon/config/ike_cfg.h
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

index eb18749..b96ab41 100644 (file)
@@ -501,7 +501,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
        ike_cfg = ike_cfg_create(IKEV2, TRUE, encap, "0.0.0.0", FALSE,
                                                         charon->socket->get_port(charon->socket, FALSE),
                                                        (char*)address, FALSE, IKEV2_UDP_PORT,
-                                                        FRAGMENTATION_NO);
+                                                        FRAGMENTATION_NO, 0);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        peer_cfg = peer_cfg_create(priv->name, ike_cfg,
                                        CERT_SEND_IF_ASKED, UNIQUE_REPLACE, 1, /* keyingtries */
@@ -718,4 +718,3 @@ NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds,
        }
        return plugin;
 }
-
index ae0d934..10b773d 100644 (file)
@@ -107,7 +107,7 @@ static ike_cfg_t *load_ike_config(private_config_t *this,
                settings->get_int(settings, "configs.%s.lport", 500, config),
                settings->get_str(settings, "configs.%s.rhost", "%any", config), FALSE,
                settings->get_int(settings, "configs.%s.rport", 500, config),
-               FRAGMENTATION_NO);
+               FRAGMENTATION_NO, 0);
        token = settings->get_str(settings, "configs.%s.proposal", NULL, config);
        if (token)
        {
index cce5ff0..2f13be9 100644 (file)
@@ -472,7 +472,7 @@ static job_requeue_t initiate(private_android_service_t *this)
        ike_cfg = ike_cfg_create(IKEV2, TRUE, TRUE, "0.0.0.0", FALSE,
                                                         charon->socket->get_port(charon->socket, FALSE),
                                                         this->gateway, FALSE, IKEV2_UDP_PORT,
-                                                        FRAGMENTATION_NO);
+                                                        FRAGMENTATION_NO, 0);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
 
        peer_cfg = peer_cfg_create("android", ike_cfg, CERT_SEND_IF_ASKED,
index 5e5fbba..54a054e 100644 (file)
@@ -95,6 +95,11 @@ struct private_ike_cfg_t {
        fragmentation_t fragmentation;
 
        /**
+        * DSCP value to use on sent IKE packets
+        */
+       u_int8_t dscp;
+
+       /**
         * List of proposals to use
         */
        linked_list_t *proposals;
@@ -156,6 +161,12 @@ METHOD(ike_cfg_t, get_other_port, u_int16_t,
        return this->other_port;
 }
 
+METHOD(ike_cfg_t, get_dscp, u_int8_t,
+       private_ike_cfg_t *this)
+{
+       return this->dscp;
+}
+
 METHOD(ike_cfg_t, add_proposal, void,
        private_ike_cfg_t *this, proposal_t *proposal)
 {
@@ -312,7 +323,7 @@ METHOD(ike_cfg_t, destroy, void,
 ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
                                                  char *me, bool my_allow_any, u_int16_t my_port,
                                                  char *other, bool other_allow_any, u_int16_t other_port,
-                                                 fragmentation_t fragmentation)
+                                                 fragmentation_t fragmentation, u_int8_t dscp)
 {
        private_ike_cfg_t *this;
 
@@ -326,6 +337,7 @@ ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
                        .get_other_addr = _get_other_addr,
                        .get_my_port = _get_my_port,
                        .get_other_port = _get_other_port,
+                       .get_dscp = _get_dscp,
                        .add_proposal = _add_proposal,
                        .get_proposals = _get_proposals,
                        .select_proposal = _select_proposal,
@@ -345,6 +357,7 @@ ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
                .other_allow_any = other_allow_any,
                .my_port = my_port,
                .other_port = other_port,
+               .dscp = dscp,
                .proposals = linked_list_create(),
        );
 
index 5a7fae1..719ceb9 100644 (file)
@@ -108,6 +108,13 @@ struct ike_cfg_t {
        u_int16_t (*get_other_port)(ike_cfg_t *this);
 
        /**
+        * Get the DSCP value to use for IKE packets send from connections.
+        *
+        * @return                              DSCP value
+        */
+       u_int8_t (*get_dscp)(ike_cfg_t *this);
+
+       /**
         * Adds a proposal to the list.
         *
         * The first added proposal has the highest priority, the last
@@ -205,11 +212,12 @@ struct ike_cfg_t {
  * @param other_allow_any      allow override of remote address by any address
  * @param other_port           IKE port to use as dest, 500 uses IKEv2 port floating
  * @param fragmentation                use IKEv1 fragmentation
+ * @param dscp                         DSCP value to send IKE packets with
  * @return                                     ike_cfg_t object.
  */
 ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
                                                  char *me, bool my_allow_any, u_int16_t my_port,
                                                  char *other, bool other_allow_any, u_int16_t other_port,
-                                                 fragmentation_t fragmentation);
+                                                 fragmentation_t fragmentation, u_int8_t dscp);
 
 #endif /** IKE_CFG_H_ @}*/
index 6af35e5..9b9bcc3 100644 (file)
@@ -266,7 +266,8 @@ static job_requeue_t initiate(private_android_service_t *this)
 
        ike_cfg = ike_cfg_create(IKEV2, TRUE, FALSE, "0.0.0.0", FALSE,
                                                         charon->socket->get_port(charon->socket, FALSE),
-                                                        hostname, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO);
+                                                        hostname, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO,
+                                                        0);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
 
        peer_cfg = peer_cfg_create("android", ike_cfg, CERT_SEND_IF_ASKED,
@@ -386,4 +387,3 @@ android_service_t *android_service_create(android_creds_t *creds)
 
        return &this->public;
 }
-
index 130c86e..e6a09a7 100644 (file)
@@ -205,7 +205,7 @@ static void setup_tunnel(private_ha_tunnel_t *this,
        /* create config and backend */
        ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE, local, FALSE,
                                                         charon->socket->get_port(charon->socket, FALSE),
-                                                        remote, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO);
+                                                        remote, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        peer_cfg = peer_cfg_create("ha", ike_cfg, CERT_NEVER_SEND,
                                                UNIQUE_KEEP, 0, 86400, 0, 7200, 3600, FALSE, FALSE, 30,
@@ -288,4 +288,3 @@ ha_tunnel_t *ha_tunnel_create(char *local, char *remote, char *secret)
 
        return &this->public;
 }
-
index c6288c5..1879465 100644 (file)
@@ -491,7 +491,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
                ike_cfg = ike_cfg_create(this->version, TRUE, FALSE,
                                                                 local, FALSE, this->port + num - 1,
                                                                 remote, FALSE, IKEV2_NATT_PORT,
-                                                                FRAGMENTATION_NO);
+                                                                FRAGMENTATION_NO, 0);
        }
        else
        {
@@ -499,7 +499,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
                                                                 local, FALSE,
                                                                 charon->socket->get_port(charon->socket, FALSE),
                                                                 remote, FALSE, IKEV2_UDP_PORT,
-                                                                FRAGMENTATION_NO);
+                                                                FRAGMENTATION_NO, 0);
        }
        ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
        peer_cfg = peer_cfg_create("load-test", ike_cfg,
index 806e4cd..d7539c2 100644 (file)
@@ -325,7 +325,8 @@ static gboolean initiate_connection(private_maemo_service_t *this,
 
        ike_cfg = ike_cfg_create(IKEV2, TRUE, FALSE, "0.0.0.0", FALSE,
                                                         charon->socket->get_port(charon->socket, FALSE),
-                                                        hostname, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO);
+                                                        hostname, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO,
+                                                        0);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
 
        peer_cfg = peer_cfg_create(this->current, ike_cfg,
@@ -524,4 +525,3 @@ maemo_service_t *maemo_service_create()
 
        return &this->public;
 }
-
index 4be3dea..d3bd29a 100644 (file)
@@ -105,7 +105,7 @@ METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
        ike_cfg = ike_cfg_create(IKEV2, FALSE, FALSE,
                                                         "0.0.0.0", FALSE,
                                                         charon->socket->get_port(charon->socket, FALSE),
-                                                        address, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO);
+                                                        address, FALSE, IKEV2_UDP_PORT, FRAGMENTATION_NO, 0);
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        med_cfg = peer_cfg_create(
                "mediation", ike_cfg,
@@ -381,7 +381,7 @@ medcli_config_t *medcli_config_create(database_t *db)
                                                          "0.0.0.0", FALSE,
                                                          charon->socket->get_port(charon->socket, FALSE),
                                                          "0.0.0.0", FALSE, IKEV2_UDP_PORT,
-                                                         FRAGMENTATION_NO),
+                                                         FRAGMENTATION_NO, 0),
        );
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
 
@@ -389,4 +389,3 @@ medcli_config_t *medcli_config_create(database_t *db)
 
        return &this->public;
 }
-
index be14380..0633922 100644 (file)
@@ -143,10 +143,9 @@ medsrv_config_t *medsrv_config_create(database_t *db)
                                                          "0.0.0.0", FALSE,
                                                          charon->socket->get_port(charon->socket, FALSE),
                                                          "0.0.0.0", FALSE, IKEV2_UDP_PORT,
-                                                         FRAGMENTATION_NO),
+                                                         FRAGMENTATION_NO, 0),
        );
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
 
        return &this->public;
 }
-
index 37bd866..c3471a0 100644 (file)
@@ -262,7 +262,7 @@ static ike_cfg_t *build_ike_cfg(private_sql_config_t *this, enumerator_t *e,
                                                                 local, FALSE,
                                                                 charon->socket->get_port(charon->socket, FALSE),
                                                                 remote, FALSE, IKEV2_UDP_PORT,
-                                                                FRAGMENTATION_NO);
+                                                                FRAGMENTATION_NO, 0);
                add_ike_proposals(this, ike_cfg, id);
                return ike_cfg;
        }
@@ -620,4 +620,3 @@ sql_config_t *sql_config_create(database_t *db)
 
        return &this->public;
 }
-
index 9f6124d..0f40356 100644 (file)
@@ -234,7 +234,8 @@ static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg
                                                         msg->add_conn.other.address,
                                                         msg->add_conn.other.allow_any,
                                                         msg->add_conn.other.ikeport,
-                                                        msg->add_conn.fragmentation);
+                                                        msg->add_conn.fragmentation,
+                                                        0);
        add_proposals(this, msg->add_conn.algorithms.ike, ike_cfg, NULL);
        return ike_cfg;
 }
index de0bf91..4d317b6 100644 (file)
@@ -156,7 +156,7 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
                                                                 local_addr, FALSE,
                                                                 charon->socket->get_port(charon->socket, FALSE),
                                                                 remote_addr, FALSE, IKEV2_UDP_PORT,
-                                                                FRAGMENTATION_NO);
+                                                                FRAGMENTATION_NO, 0);
                ike_cfg->add_proposal(ike_cfg, create_proposal(ike_proposal, PROTO_IKE));
                this->peer_cfg = peer_cfg_create(
                                        name, ike_cfg, CERT_SEND_IF_ASKED, UNIQUE_NO,
@@ -255,7 +255,7 @@ METHOD(enumerator_t, ike_enumerator_enumerate, bool,
                                                                local_addr, FALSE,
                                                                charon->socket->get_port(charon->socket, FALSE),
                                                                remote_addr, FALSE, IKEV2_UDP_PORT,
-                                                               FRAGMENTATION_NO);
+                                                               FRAGMENTATION_NO, 0);
                this->ike_cfg->add_proposal(this->ike_cfg,
                                                                        create_proposal(ike_proposal, PROTO_IKE));
 
@@ -343,4 +343,3 @@ uci_config_t *uci_config_create(uci_parser_t *parser)
 
        return &this->public;
 }
-