aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/charon/parser.c10
-rw-r--r--Source/charon/payloads/payload.c3
-rw-r--r--Source/charon/testcases/parser_test.c47
-rw-r--r--Source/charon/testcases/parser_test.h2
-rw-r--r--Source/charon/testcases/testcases.c7
5 files changed, 69 insertions, 0 deletions
diff --git a/Source/charon/parser.c b/Source/charon/parser.c
index fc034c5b6..541ef2c3f 100644
--- a/Source/charon/parser.c
+++ b/Source/charon/parser.c
@@ -750,6 +750,16 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
break;
}
+ case NOTIFICATION_DATA:
+ {
+ size_t notify_length = payload_length - 8 - spi_size;
+ if (this->parse_chunk(this, rule_number, output + rule->offset, notify_length) != SUCCESS)
+ {
+ pld->destroy(pld);
+ return PARSE_ERROR;
+ }
+ break;
+ }
default:
{
this->logger->log(this->logger, ERROR, " no rule to parse rule %d %s (%d)", rule_number, mapping_find(encoding_type_t_mappings, rule->type), rule->type);
diff --git a/Source/charon/payloads/payload.c b/Source/charon/payloads/payload.c
index f04413849..90e8cc976 100644
--- a/Source/charon/payloads/payload.c
+++ b/Source/charon/payloads/payload.c
@@ -28,6 +28,7 @@
#include "sa_payload.h"
#include "nonce_payload.h"
#include "ke_payload.h"
+#include "notify_payload.h"
@@ -82,6 +83,8 @@ payload_t *payload_create(payload_type_t type)
return (payload_t*)nonce_payload_create();
case KEY_EXCHANGE:
return (payload_t*)ke_payload_create();
+ case NOTIFY:
+ return (payload_t*)notify_payload_create();
default:
return NULL;
}
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**)&notify_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);
+}
diff --git a/Source/charon/testcases/parser_test.h b/Source/charon/testcases/parser_test.h
index 6a36f6659..52c7ee7a0 100644
--- a/Source/charon/testcases/parser_test.h
+++ b/Source/charon/testcases/parser_test.h
@@ -33,4 +33,6 @@ void test_parser_with_nonce_payload(tester_t *tester);
void test_parser_with_ke_payload(tester_t *tester);
+void test_parser_with_notify_payload(tester_t *tester);
+
#endif /*PARSER_TEST_H_*/
diff --git a/Source/charon/testcases/testcases.c b/Source/charon/testcases/testcases.c
index a1549fd14..7576080c4 100644
--- a/Source/charon/testcases/testcases.c
+++ b/Source/charon/testcases/testcases.c
@@ -152,6 +152,11 @@ test_t parser_test3 = {test_parser_with_nonce_payload, "Parser: nonce payload"};
*/
test_t parser_test4 = {test_parser_with_ke_payload, "Parser: key exchange payload"};
+/**
+ * Parser test for ike notify payload
+ */
+test_t parser_test5 = {test_parser_with_notify_payload, "Parser: notify payload"};
+
/**
* Test for packet_t
@@ -208,6 +213,8 @@ logger_manager_t *global_logger_manager;
&parser_test1,
&parser_test2,
&parser_test3,
+ &parser_test4,
+ &parser_test5,
&generator_test3,
&generator_test4,
&generator_test5,