From: Tobias Brunner Date: Wed, 17 Jun 2020 16:39:44 +0000 (+0200) Subject: unit-tests: Support multiple proposals in exchange tests X-Git-Tag: 6.0.0rc1~56^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37c56affa14b21aac207128fa41d2f01c7dab79b;p=thirdparty%2Fstrongswan.git unit-tests: Support multiple proposals in exchange tests --- diff --git a/src/libcharon/tests/utils/exchange_test_helper.c b/src/libcharon/tests/utils/exchange_test_helper.c index 8c57c88778..23f1132c06 100644 --- a/src/libcharon/tests/utils/exchange_test_helper.c +++ b/src/libcharon/tests/utils/exchange_test_helper.c @@ -98,21 +98,27 @@ static ike_cfg_t *create_ike_cfg(bool initiator, exchange_test_sa_conf_t *conf) .remote = "127.0.0.1", .remote_port = IKEV2_UDP_PORT, }; + enumerator_t *enumerator; ike_cfg_t *ike_cfg; - char *proposal = NULL; + char *proposals = NULL, *proposal; if (conf) { ike.childless = initiator ? conf->initiator.childless : conf->responder.childless; - proposal = initiator ? conf->initiator.ike : conf->responder.ike; + proposals = initiator ? conf->initiator.ike : conf->responder.ike; } ike_cfg = ike_cfg_create(&ike); - if (proposal) + if (proposals) { - ike_cfg->add_proposal(ike_cfg, + enumerator = enumerator_create_token(proposals, ",", ""); + while (enumerator->enumerate(enumerator, &proposal)) + { + ike_cfg->add_proposal(ike_cfg, proposal_create_from_string(PROTO_IKE, proposal)); + } + enumerator->destroy(enumerator); } else { @@ -124,21 +130,27 @@ static ike_cfg_t *create_ike_cfg(bool initiator, exchange_test_sa_conf_t *conf) static child_cfg_t *create_child_cfg(bool initiator, exchange_test_sa_conf_t *conf) { + enumerator_t *enumerator; child_cfg_t *child_cfg; child_cfg_create_t child = { .mode = MODE_TUNNEL, }; - char *proposal = NULL; + char *proposals = NULL, *proposal; child_cfg = child_cfg_create(initiator ? "init" : "resp", &child); if (conf) { - proposal = initiator ? conf->initiator.esp : conf->responder.esp; + proposals = initiator ? conf->initiator.esp : conf->responder.esp; } - if (proposal) + if (proposals) { - child_cfg->add_proposal(child_cfg, + enumerator = enumerator_create_token(proposals, ",", ""); + while (enumerator->enumerate(enumerator, &proposal)) + { + child_cfg->add_proposal(child_cfg, proposal_create_from_string(PROTO_ESP, proposal)); + } + enumerator->destroy(enumerator); } else {