diff options
author | Martin Willi <martin@strongswan.org> | 2005-11-15 16:18:02 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2005-11-15 16:18:02 +0000 |
commit | cb4f26c5fe8b8f0d285bf1c7b1f3378059c90923 (patch) | |
tree | fa3858d4fb4d7f469852103cb3e9ef72d4c836a2 /Source/charon/testcases/parser_test.c | |
parent | 2a489f333ddebc8f9b29cb8a767625c4eb379486 (diff) | |
download | strongswan-cb4f26c5fe8b8f0d285bf1c7b1f3378059c90923.tar.bz2 strongswan-cb4f26c5fe8b8f0d285bf1c7b1f3378059c90923.tar.xz |
- parsing notify messge
- tested
Diffstat (limited to 'Source/charon/testcases/parser_test.c')
-rw-r--r-- | Source/charon/testcases/parser_test.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/charon/testcases/parser_test.c b/Source/charon/testcases/parser_test.c index 27b552338..bf5cc41d6 100644 --- a/Source/charon/testcases/parser_test.c +++ b/Source/charon/testcases/parser_test.c @@ -32,6 +32,7 @@ #include "../payloads/sa_payload.h" #include "../payloads/nonce_payload.h" #include "../payloads/ke_payload.h" +#include "../payloads/notify_payload.h" extern logger_manager_t *global_logger_manager; @@ -258,3 +259,49 @@ void test_parser_with_ke_payload(tester_t *tester) tester->assert_false(tester,(memcmp(ke_bytes + 8, result.ptr, result.len)), "parsed key data"); ke_payload->destroy(ke_payload); } + + +/* + * Described in Header + */ +void test_parser_with_notify_payload(tester_t *tester) +{ + parser_t *parser; + notify_payload_t *notify_payload; + status_t status; + chunk_t notify_chunk, result; + + u_int8_t notify_bytes[] = { + 0x00,0x00,0x00,0x1C, /* payload header */ + 0x03,0x04,0x00,0x01, + 0x01,0x02,0x03,0x03, /* spi */ + 0x04,0x05,0x06,0x07, /* noti dati */ + 0x08,0x09,0x0A,0x2B, + 0x0C,0x0D,0x0E,0x0F, + 0x0C,0x0D,0x0E,0x0F + }; + + notify_chunk.ptr = notify_bytes; + notify_chunk.len = sizeof(notify_bytes); + + parser = parser_create(notify_chunk); + tester->assert_true(tester,(parser != NULL), "parser create check"); + status = parser->parse_payload(parser, NOTIFY, (payload_t**)¬ify_payload); + tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); + tester->assert_true(tester,(parser->destroy(parser) == SUCCESS), "parser destroy call check"); + + if (status != SUCCESS) + { + return; + } + tester->assert_true(tester,(notify_payload->get_protocol_id(notify_payload) == 3), "Protocol id"); + tester->assert_true(tester,(notify_payload->get_notify_message_type(notify_payload) == 1), "notify message type"); + + result = notify_payload->get_spi(notify_payload); + tester->assert_false(tester,(memcmp(notify_bytes + 8, result.ptr, result.len)), "parsed spi"); + + result = notify_payload->get_notification_data(notify_payload); + tester->assert_false(tester,(memcmp(notify_bytes + 12, result.ptr, result.len)), "parsed notification data"); + + notify_payload->destroy(notify_payload); +} |