aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/testcases/sa_config_test.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-12-01 18:14:22 +0000
committerMartin Willi <martin@strongswan.org>2005-12-01 18:14:22 +0000
commit257fa503864d47420e6b9e16fad70587293d7edc (patch)
treebf7740b41f72f924aa55d82df2f60317afc373f2 /Source/charon/testcases/sa_config_test.c
parent03283349a9ca4989c44e5eb6e632716c4c4b050f (diff)
downloadstrongswan-257fa503864d47420e6b9e16fad70587293d7edc.tar.bz2
strongswan-257fa503864d47420e6b9e16fad70587293d7edc.tar.xz
- added ts for both initator and responder
- ts_payload can get now ts's
Diffstat (limited to 'Source/charon/testcases/sa_config_test.c')
-rw-r--r--Source/charon/testcases/sa_config_test.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/Source/charon/testcases/sa_config_test.c b/Source/charon/testcases/sa_config_test.c
index c00a385d2..10808c119 100644
--- a/Source/charon/testcases/sa_config_test.c
+++ b/Source/charon/testcases/sa_config_test.c
@@ -27,6 +27,7 @@
#include <config/traffic_selector.h>
#include <utils/allocator.h>
#include <utils/logger.h>
+#include <encoding/payloads/ts_payload.h>
/**
@@ -39,6 +40,7 @@ void test_sa_config(tester_t *tester)
child_proposal_t prop[3], *prop_result;
size_t count;
logger_t *logger;
+ ts_payload_t *ts_payload;
u_int8_t spi[4] = {0x01,0x02,0x03,0x04};
@@ -132,21 +134,36 @@ void test_sa_config(tester_t *tester)
/* icmp request, should be discarded */
ts_request[3] = traffic_selector_create_from_string(1, TS_IPV4_ADDR_RANGE, "0.0.0.0", 0, "255.255.255.255", 65535);
- sa_config->add_traffic_selector(sa_config, ts_policy[0]);
- sa_config->add_traffic_selector(sa_config, ts_policy[1]);
- sa_config->add_traffic_selector(sa_config, ts_policy[2]);
+ sa_config->add_traffic_selector_initiator(sa_config, ts_policy[0]);
+ sa_config->add_traffic_selector_initiator(sa_config, ts_policy[1]);
+ sa_config->add_traffic_selector_initiator(sa_config, ts_policy[2]);
- count = sa_config->get_traffic_selectors(sa_config, &ts_result);
+ count = sa_config->get_traffic_selectors_initiator(sa_config, &ts_result);
tester->assert_true(tester, (count == 3), "ts get count");
ts_result[0]->destroy(ts_result[0]);
ts_result[0]->destroy(ts_result[1]);
ts_result[0]->destroy(ts_result[2]);
allocator_free(ts_result);
- count = sa_config->select_traffic_selectors(sa_config, &ts_request[0], 4, &ts_result);
+ count = sa_config->select_traffic_selectors_initiator(sa_config, &ts_request[0], 4, &ts_result);
tester->assert_true(tester, (count == 3), "ts select count");
+ /* store and restore into ts payload, tricky tricky */
+ ts_payload = ts_payload_create_from_traffic_selectors(TRUE, ts_result, count);
+
+ /* destroy */
+ ts_result[0]->destroy(ts_result[0]);
+ ts_result[0]->destroy(ts_result[1]);
+ ts_result[0]->destroy(ts_result[2]);
+ allocator_free(ts_result);
+
+ /* get them again out of the payload */
+ count = ts_payload->get_traffic_selectors(ts_payload, &ts_result);
+ ts_payload->destroy(ts_payload);
+
+
+
int i;
for (i = 0; i<count; i++)
{
@@ -178,10 +195,12 @@ void test_sa_config(tester_t *tester)
allocator_free(ta_ref.ptr);
}
+
+ /* destroy */
ts_result[0]->destroy(ts_result[0]);
- ts_result[0]->destroy(ts_result[1]);
+ ts_result[0]->destroy(ts_result[1]);
ts_result[0]->destroy(ts_result[2]);
- allocator_free(ts_result);
+ allocator_free(ts_result);
ts_policy[0]->destroy(ts_policy[0]);
ts_policy[1]->destroy(ts_policy[1]);