charon-tkm: Add get_other_esa_id function to TKM kernel SAD

The function gets the ESA id for another entry associated with the same
security policy as the specified ESA.
This commit is contained in:
Adrian-Ken Rueegsegger
2015-05-04 18:07:50 +02:00
committed by Tobias Brunner
parent ded14df603
commit c7ce0d96cd
3 changed files with 103 additions and 0 deletions
+36
View File
@@ -81,6 +81,37 @@ START_TEST(test_get_esa_id_nonexistent)
}
END_TEST
START_TEST(test_get_other_esa_id)
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->insert(sad, 24, 54, addr, addr, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->get_other_esa_id(sad, 23) == 24,
"Error getting other esa id");
sad->destroy(sad);
addr->destroy(addr);
}
END_TEST
START_TEST(test_get_other_esa_id_nonexistent)
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
fail_unless(sad->get_other_esa_id(sad, 1) == 0,
"Got other esa id for nonexistent SAD entry");
fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->get_other_esa_id(sad, 23) == 0,
"Got own esa id");
sad->destroy(sad);
addr->destroy(addr);
}
END_TEST
START_TEST(test_get_dst_host)
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
@@ -151,6 +182,11 @@ Suite *make_kernel_sad_tests()
tcase_add_test(tc, test_get_esa_id_nonexistent);
suite_add_tcase(s, tc);
tc = tcase_create("get_other_esa_id");
tcase_add_test(tc, test_get_other_esa_id);
tcase_add_test(tc, test_get_other_esa_id_nonexistent);
suite_add_tcase(s, tc);
tc = tcase_create("get_dst_host");
tcase_add_test(tc, test_get_dst_host);
tcase_add_test(tc, test_get_dst_host_nonexistent);