- dead end implementation
[strongswan.git] / Source / charon / testcases / kernel_interface_test.c
1 /**
2 * @file kernel_interface_test.h
3 *
4 * @brief Tests for the kernel_interface_t class.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23
24 #include "kernel_interface_test.h"
25
26 #include <daemon.h>
27 #include <threads/kernel_interface.h>
28 #include <utils/allocator.h>
29 #include <utils/logger.h>
30 #include <network/host.h>
31
32
33 /*
34 * described in Header-File
35 */
36 void test_kernel_interface(protected_tester_t *tester)
37 {
38 kernel_interface_t *kernel_interface;
39 u_int32_t spi;
40 host_t *me, *other;
41 status_t status;
42
43 u_int8_t enc_key_bytes[] = {
44 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
45 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
46 };
47
48 u_int8_t inc_key_bytes[] = {
49 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
50 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
51 };
52
53 chunk_t enc_key,inc_key;
54 enc_key.ptr = enc_key_bytes;
55 enc_key.len = sizeof(enc_key_bytes);
56 inc_key.ptr = inc_key_bytes;
57 inc_key.len = sizeof(inc_key_bytes);
58
59
60
61 kernel_interface = kernel_interface_create();
62
63 me = host_create(AF_INET, "152.96.193.130", 500);
64 other = host_create(AF_INET, "152.96.193.130", 500);
65
66
67
68 status = kernel_interface->get_spi(kernel_interface, me, other, 50, TRUE, &spi);
69 tester->assert_true(tester, status == SUCCESS, "spi get");
70
71 status = kernel_interface->add_sa(kernel_interface, me, other, spi, 50, TRUE, ENCR_AES_CBC, 16, enc_key,AUTH_HMAC_MD5_96,16,inc_key,TRUE);
72 tester->assert_true(tester, status == SUCCESS, "build sa");
73
74
75 me->destroy(me);
76 other->destroy(other);
77
78 kernel_interface->destroy(kernel_interface);
79
80 }