summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-01 04:57:18 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-01 04:57:41 +0800
commitce7190d462b78085c39e3d92e2c3f81f09954cbd (patch)
tree710d7e0a9450fa81bfbcfc81325e47cab993f0dc
parentcee698ac9ad97f43c36b7e0cf45bd2824cd218e4 (diff)
sccp: Add test case for GTI...
-rw-r--r--tests/sccp/sccp_test.c87
1 files changed, 82 insertions, 5 deletions
diff --git a/tests/sccp/sccp_test.c b/tests/sccp/sccp_test.c
index 6ddf2fc..f10caea 100644
--- a/tests/sccp/sccp_test.c
+++ b/tests/sccp/sccp_test.c
@@ -108,6 +108,43 @@ static const uint8_t bssmap_release_complete[] = {
0x05, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03
};
+/* message with a SCCP global title */
+static const uint8_t tcap_global_title[] = {
+ 0x09,
+ 0x81, 0x03, 0x0d, 0x18, 0x0a, 0x12, 0x07, 0x00,
+ 0x12, 0x04, 0x53, 0x84, 0x09, 0x00, 0x17, 0x0b,
+ 0x12, 0x06, 0x00, 0x12, 0x04, 0x44, 0x87, 0x20,
+ 0x00, 0x20, 0x65, 0x9a, 0x65, 0x81, 0x97, 0x48,
+ 0x04, 0x26, 0x00, 0x01, 0x98, 0x49, 0x04, 0x51,
+ 0x01, 0x03, 0xdf, 0x6c, 0x81, 0x88, 0xa1, 0x81,
+ 0x85, 0x02, 0x01, 0x44, 0x02, 0x01, 0x07, 0x30,
+ 0x80, 0xa7, 0x80, 0xa0, 0x80, 0x04, 0x01, 0x2b,
+ 0x30, 0x80, 0x30, 0x12, 0x83, 0x01, 0x10, 0x84,
+ 0x01, 0x07, 0x85, 0x07, 0x91, 0x44, 0x57, 0x76,
+ 0x67, 0x16, 0x97, 0x86, 0x01, 0x20, 0x30, 0x06,
+ 0x82, 0x01, 0x18, 0x84, 0x01, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0xa3, 0x06, 0x04, 0x01, 0x42, 0x84,
+ 0x01, 0x05, 0xa3, 0x06, 0x04, 0x01, 0x51, 0x84,
+ 0x01, 0x05, 0xa3, 0x06, 0x04, 0x01, 0x31, 0x84,
+ 0x01, 0x05, 0xa3, 0x09, 0x04, 0x01, 0x12, 0x84,
+ 0x01, 0x05, 0x82, 0x01, 0x02, 0xa3, 0x09, 0x04,
+ 0x01, 0x11, 0x84, 0x01, 0x05, 0x81, 0x01, 0x01,
+ 0xa3, 0x06, 0x04, 0x01, 0x14, 0x84, 0x01, 0x00,
+ 0xa3, 0x0b, 0x04, 0x01, 0x41, 0x84, 0x01, 0x04,
+ 0x30, 0x03, 0x83, 0x01, 0x10, 0xa3, 0x0b, 0x04,
+ 0x01, 0x41, 0x84, 0x01, 0x04, 0x30, 0x03, 0x82,
+ 0x01, 0x18, 0x00, 0x00, 0x00, 0x00
+};
+
+static const uint8_t tcap_global_dst_gti[] = {
+ 0x00, 0x12, 0x04, 0x53, 0x84, 0x09, 0x00, 0x17,
+};
+
+static const uint8_t tcap_global_src_gti[] = {
+ 0x00, 0x12, 0x04, 0x44, 0x87, 0x20, 0x00, 0x20, 0x65,
+};
+
+
struct test_data {
int length;
const uint8_t *data;
@@ -256,6 +293,12 @@ struct sccp_parse_header_result {
struct sccp_source_reference src_ref;
struct sccp_source_reference dst_ref;
+ /* global title len */
+ int src_gti_len;
+ const uint8_t *src_gti_data;
+ int dst_gti_len;
+ const uint8_t *dst_gti_data;
+
/* the input */
const uint8_t *input;
int input_len;
@@ -307,6 +350,18 @@ static const struct sccp_parse_header_result parse_result[] = {
.input = proto_err,
.input_len = sizeof(proto_err),
},
+ {
+ .msg_type = SCCP_MSG_TYPE_UDT,
+ .input = tcap_global_title,
+ .input_len = sizeof(tcap_global_title),
+ .wanted_len = 154,
+ .dst_ssn = SCCP_SSN_VLR,
+ .dst_gti_data = tcap_global_dst_gti,
+ .dst_gti_len = 8,
+ .src_ssn = SCCP_SSN_HLR,
+ .src_gti_data = tcap_global_src_gti,
+ .src_gti_len = 9,
+ },
};
@@ -778,7 +833,7 @@ static void test_sccp_parsing(void)
FAIL("Failed to sccp parse test: %d\n", current_test);
} else {
if (parse_result[current_test].wanted_len != result.data_len) {
- FAIL("Unexpected data length.\n");
+ FAIL("Unexpected data length. Got: %d\n", result.data_len);
}
if (parse_result[current_test].has_src_ref) {
@@ -797,12 +852,34 @@ static void test_sccp_parsing(void)
}
}
- if (parse_result[current_test].src_ssn != -1) {
- FAIL("Not implemented.\n");
+ if (parse_result[current_test].src_ssn != -1 &&
+ parse_result[current_test].src_ssn != result.calling.ssn) {
+ FAIL("Calling SSN is wrong..\n");
+ }
+
+ if (parse_result[current_test].dst_ssn != -1 &&
+ parse_result[current_test].dst_ssn != result.called.ssn) {
+ FAIL("Called SSN is wrong..\n");
+ }
+
+ if (parse_result[current_test].src_gti_len != result.calling.gti_len) {
+ FAIL("GTI length is wrong: %d\n", result.calling.gti_len);
+ }
+
+ if (parse_result[current_test].dst_gti_len != result.called.gti_len) {
+ FAIL("GTI length is wrong: %d\n", result.called.gti_len);
+ }
+
+ if (memcmp(&parse_result[current_test].dst_gti_data[0],
+ result.called.gti_data, result.called.gti_len) != 0) {
+ FAIL("GTI data is wrong: %d '%s'\n",
+ result.called.gti_len,
+ hexdump(result.called.gti_data, result.called.gti_len));
}
- if (parse_result[current_test].dst_ssn != -1) {
- FAIL("Not implemented.\n");
+ if (memcmp(&parse_result[current_test].src_gti_data[0],
+ result.calling.gti_data, result.calling.gti_len) != 0) {
+ FAIL("GTI data is wrong: %d\n", result.calling.gti_len);
}
}