charon-tkm: Add get_dst_host getter to SAD
This function returns the destination host of an SAD entry for given reqid, spi and protocol arguments or NULL if not found.
This commit is contained in:
committed by
Martin Willi
parent
ba8aefd5f2
commit
e12ff07c96
@@ -81,6 +81,29 @@ START_TEST(test_get_esa_id_nonexistent)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_get_dst_host)
|
||||
{
|
||||
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");
|
||||
|
||||
host_t *dst = sad->get_dst_host(sad, 54, 42, 50);
|
||||
fail_unless(addr->equals(addr, dst), "Error getting dst host");
|
||||
sad->destroy(sad);
|
||||
addr->destroy(addr);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_get_dst_host_nonexistent)
|
||||
{
|
||||
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
|
||||
fail_unless(sad->get_dst_host(sad, 1, 12, 50) == NULL,
|
||||
"Got dst for nonexistent SAD entry");
|
||||
sad->destroy(sad);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_remove)
|
||||
{
|
||||
host_t *addr = host_create_from_string("127.0.0.1", 1024);
|
||||
@@ -128,6 +151,11 @@ Suite *make_kernel_sad_tests()
|
||||
tcase_add_test(tc, test_get_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);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("remove");
|
||||
tcase_add_test(tc, test_remove);
|
||||
tcase_add_test(tc, test_remove_nonexistent);
|
||||
|
||||
Reference in New Issue
Block a user