summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhelanfeng <[email protected]>2024-11-11 11:38:47 +0800
committerhelanfeng <[email protected]>2024-11-11 11:46:23 +0800
commitffebf0e2d4e8d8069b14948156d47e01ace6a6f0 (patch)
tree6825318e95db4e85877d45747e5dcc5d46d80684 /test
parentd0a868591470a4a9d71a65a5d540058e72c8d92c (diff)
dtls adapt stellar 2.0
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/decoders/dtls/CMakeLists.txt68
-rw-r--r--test/decoders/dtls/dtls_test_plug.c289
-rw-r--r--test/decoders/dtls/gtest_dtls.h16
-rw-r--r--test/decoders/dtls/plus_test_main.cpp149
-rw-r--r--test/decoders/dtls/test_config/dtls_config.toml2
-rw-r--r--test/decoders/dtls/test_config/log.toml4
-rw-r--r--test/decoders/dtls/test_config/spec.toml9
-rw-r--r--test/decoders/dtls/test_expect/1_dtls_with_sni.json24
-rw-r--r--test/decoders/dtls/test_expect/2_dtls_with_stun.json15
-rw-r--r--test/decoders/dtls/test_expect/3_dtls_only_client_hello_with_sni.json12
-rw-r--r--test/decoders/dtls/test_expect/4_dtls_only_client_hello.json10
-rw-r--r--test/decoders/dtls/test_expect/5_dtls_handshake.json16
-rw-r--r--test/decoders/dtls/test_expect/6_dtls_application.json5
-rw-r--r--test/decoders/dtls/test_expect/7_sni_len_is_0.json10
-rw-r--r--test/decoders/dtls/test_pcap/1_dtls_with_sni.pcapbin0 -> 6889 bytes
-rw-r--r--test/decoders/dtls/test_pcap/2_dtls_with_stun.pcapbin0 -> 625418 bytes
-rw-r--r--test/decoders/dtls/test_pcap/3_dtls_only_client_hello_with_sni.pcapbin0 -> 19244 bytes
-rw-r--r--test/decoders/dtls/test_pcap/4_dtls_only_client_hello.pcapbin0 -> 2205 bytes
-rw-r--r--test/decoders/dtls/test_pcap/5_dtls_handshake.pcapbin0 -> 5113 bytes
-rw-r--r--test/decoders/dtls/test_pcap/6_dtls_application.pcapbin0 -> 99468 bytes
-rw-r--r--test/decoders/dtls/test_pcap/7_sni_len_is_0.pcapbin0 -> 234 bytes
22 files changed, 631 insertions, 1 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 11d1abc..155f792 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -6,4 +6,5 @@ add_subdirectory(lpi_plus)
#add_subdirectory(decoders/socks)
#add_subdirectory(decoders/stratum)
#add_subdirectory(decoders/session_flags)
-add_subdirectory(monitor) \ No newline at end of file
+add_subdirectory(monitor)
+add_subdirectory(decoders/dtls)
diff --git a/test/decoders/dtls/CMakeLists.txt b/test/decoders/dtls/CMakeLists.txt
new file mode 100644
index 0000000..3a05044
--- /dev/null
+++ b/test/decoders/dtls/CMakeLists.txt
@@ -0,0 +1,68 @@
+add_executable(dtls_test_main dtls_test_plug.c plus_test_main.cpp
+ ${PROJECT_SOURCE_DIR}/decoders/dtls/dtls_plugin.c
+ ${PROJECT_SOURCE_DIR}/decoders/dtls/dtls_map.c
+ ${PROJECT_SOURCE_DIR}/decoders/dtls/dtls_parse.c)
+
+target_include_directories(dtls_test_main PRIVATE ${CMAKE_SOURCE_DIR}/deps/)
+target_include_directories(dtls_test_main PRIVATE ${CMAKE_SOURCE_DIR}/decoders/)
+
+target_link_libraries(
+ dtls_test_main PRIVATE stellar_lib cjson-static dtls
+ dl "-rdynamic"
+ gtest gmock
+)
+
+set(TEST_NAME dtls_test)
+set(TEST_RUN_DIR ${CMAKE_BINARY_DIR}/test/decoders/dtls)
+set(SAPP_DEVEL_DIR ${TEST_RUN_DIR}/lib)
+set(TEST_MAIN dtls_test_main)
+
+include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${CMAKE_SOURCE_DIR}/test)
+include_directories(/usr/local/include/cjson)
+include_directories(/opt/tsg/framework/include/stellar)
+include_directories(/opt/MESA/include/MESA)
+include_directories(/opt/tsg/stellar/include/)
+
+add_definitions(-rdynamic)
+link_directories(${SAPP_DEVEL_DIR})
+
+add_test(NAME ${TEST_NAME}.SETUP COMMAND sh -c "
+ mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/conf &&
+ mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/plugin &&
+ mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/log &&
+ mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tsgconf &&
+ mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/pcap &&
+ cp ${CMAKE_SOURCE_DIR}/conf/stellar.toml ${CMAKE_CURRENT_BINARY_DIR}/conf/ &&
+ cat ${CMAKE_CURRENT_SOURCE_DIR}/test_config/spec.toml >> ${CMAKE_CURRENT_BINARY_DIR}/conf/stellar.toml &&
+ cp ${CMAKE_CURRENT_SOURCE_DIR}/test_config/dtls_config.toml ${CMAKE_CURRENT_BINARY_DIR}/tsgconf/ &&
+ tomlq -t -i '.packet_io.pcap_path=\"./pcap/test.pcap\"' ${CMAKE_CURRENT_BINARY_DIR}/conf/stellar.toml &&
+ tomlq -t -i '.packet_io.mode=\"pcapfile\"' ${CMAKE_CURRENT_BINARY_DIR}/conf/stellar.toml
+ ")
+
+set_tests_properties(${TEST_NAME}.SETUP PROPERTIES FIXTURES_SETUP TestFixture)
+
+set(TEST_PCAP_DIR ${PROJECT_SOURCE_DIR}/test/decoders/dtls/test_pcap)
+set(TEST_EXPECTED_DIR ${PROJECT_SOURCE_DIR}/test/decoders/dtls/test_expect)
+
+# run tests
+add_test(NAME ${TEST_NAME}.1 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/1_dtls_with_sni.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/1_dtls_with_sni.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME ${TEST_NAME}.2 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/2_dtls_with_stun.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/2_dtls_with_stun.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME ${TEST_NAME}.3 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/3_dtls_only_client_hello_with_sni.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/3_dtls_only_client_hello_with_sni.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME ${TEST_NAME}.4 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/4_dtls_only_client_hello.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/4_dtls_only_client_hello.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME ${TEST_NAME}.5 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/5_dtls_handshake.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/5_dtls_handshake.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME ${TEST_NAME}.6 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/6_dtls_application.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/6_dtls_application.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME ${TEST_NAME}.7 COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/7_sni_len_is_0.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_EXPECTED_DIR}/7_sni_len_is_0.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+
+
+set_tests_properties(${TEST_NAME}.1
+ ${TEST_NAME}.2
+ ${TEST_NAME}.3
+ ${TEST_NAME}.4
+ ${TEST_NAME}.5
+ ${TEST_NAME}.6
+ ${TEST_NAME}.7
+ PROPERTIES FIXTURES_REQUIRED ${TEST_NAME}.SETUP
+ )
+
+include(GoogleTest)
diff --git a/test/decoders/dtls/dtls_test_plug.c b/test/decoders/dtls/dtls_test_plug.c
new file mode 100644
index 0000000..fa1a9ca
--- /dev/null
+++ b/test/decoders/dtls/dtls_test_plug.c
@@ -0,0 +1,289 @@
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <assert.h>
+#include <string.h>
+
+#include "cjson/cJSON.h"
+#include "stellar/dtls.h"
+#include "gtest_dtls.h"
+
+#include "stellar/stellar.h"
+#include "stellar/session.h"
+#include "stellar/mq.h"
+#include "stellar/exdata.h"
+#include "stellar/utils.h"
+
+#define UNUSED(x) ((void)(x))
+
+struct dtls_test_sess_exdata
+{
+ int application_flag;
+};
+
+#ifdef __cplusplus
+extern "C" int commit_test_result_json(cJSON *node, const char *name);
+#endif
+static int g_exdata_index=-1;
+cJSON *g_result_json=NULL;
+
+int stellar_test_result_setup()
+{
+ if(g_result_json!=NULL)return -1;
+ g_result_json=cJSON_CreateObject();
+ return 0;
+}
+
+char *stellar_test_result_json_export()
+{
+ if(g_result_json==NULL)return NULL;
+ return cJSON_Print(g_result_json);
+}
+
+void stellar_test_result_cleanup()
+{
+ if(g_result_json)cJSON_Delete(g_result_json);
+}
+
+static void dtls_record_client_hello(struct dtls_handshake *chello, cJSON *log)
+{
+ if (chello->version != NULL) {
+ cJSON_AddStringToObject(log, "client_hello_version", chello->version);
+ }
+
+ if (chello->random != NULL && chello->random_sz > 0) {
+ size_t readable_random_sz=0;
+ char *readable_random=dtls_get_readable_random(chello->random, chello->random_sz, &readable_random_sz);
+ if (readable_random != NULL) {
+ cJSON_AddStringToObject(log, "client_hello_random", readable_random);
+ free(readable_random);
+ }
+ }
+
+ if (chello->dtls_session_id != NULL && chello->dtls_session_id_sz > 0) {
+ size_t readable_session_sz=0;
+ char *readable_session=dtls_get_readable_session(chello->dtls_session_id, chello->dtls_session_id_sz, &readable_session_sz);
+ if (readable_session != NULL) {
+ cJSON_AddStringToObject(log, "client_hello_session", readable_session);
+ free(readable_session);
+ }
+ }
+
+ if (chello->cookie != NULL && chello->cookie_sz > 0) {
+ size_t readable_cookie_sz=0;
+ char *readable_cookie=dtls_get_readable_cookie(chello->cookie, chello->cookie_sz, &readable_cookie_sz);
+ if (readable_cookie != NULL) {
+ cJSON_AddStringToObject(log, "client_hello_cookie", readable_cookie);
+ free(readable_cookie);
+ }
+ }
+
+ char **cipher_suites=NULL;
+ size_t n_cipher_suites=0;
+ dtls_get_readable_cipher_suites(chello, (const char ***)&cipher_suites, &n_cipher_suites);
+ cJSON *cipher_suites_array=cJSON_CreateArray();
+ for (size_t i=0; i < n_cipher_suites; i++) {
+ cJSON_AddItemToArray(cipher_suites_array, cJSON_CreateString(cipher_suites[i]));
+ }
+ cJSON_AddItemToObject(log, "client_hello_cipher_suites", cipher_suites_array);
+ free(cipher_suites);
+
+ char **compression_methods=NULL;
+ size_t n_compression_methods=0;
+ dtls_get_readable_compression_methods(chello, (const char ***)&compression_methods, &n_compression_methods);
+ cJSON *compression_methods_array=cJSON_CreateArray();
+ for (size_t i=0; i < n_compression_methods; i++) {
+ cJSON_AddItemToArray(compression_methods_array, cJSON_CreateString(compression_methods[i]));
+ }
+ cJSON_AddItemToObject(log, "client_hello_compression_methods", compression_methods_array);
+ free(compression_methods);
+ if(chello->extensions!=NULL) {
+ cJSON *extensions_array=cJSON_CreateArray();
+ for(size_t i=0; i < utarray_len(chello->extensions); i++) {
+ struct dtls_handshake_extension *ext=(struct dtls_handshake_extension *)utarray_eltptr(chello->extensions, i);
+ cJSON_AddItemToArray(extensions_array, cJSON_CreateString(dtls_get_extension_name(ext->type)));
+ }
+ cJSON_AddItemToObject(log, "client_hello_extensions", extensions_array);
+ }
+
+ if (chello->sni != NULL && chello->sni_sz > 0) {
+ char sni_str[512]={0};
+ memcpy(sni_str, chello->sni, chello->sni_sz);
+ sni_str[chello->sni_sz]='\0';
+ cJSON_AddStringToObject(log, "client_hello_sni", sni_str);
+ }
+ return ;
+}
+
+static void dtls_record_server_hello(struct dtls_handshake *shello, cJSON *log)
+{
+ if (shello->version != NULL) {
+ cJSON_AddStringToObject(log, "server_hello_version", shello->version);
+ }
+
+ if (shello->random != NULL && shello->random_sz > 0) {
+ size_t readable_random_sz=0;
+ char *readable_random=dtls_get_readable_random(shello->random, shello->random_sz, &readable_random_sz);
+ if (readable_random != NULL) {
+ cJSON_AddStringToObject(log, "server_hello_random", readable_random);
+ free(readable_random);
+ }
+ }
+
+ if (shello->dtls_session_id != NULL && shello->dtls_session_id_sz > 0) {
+ size_t readable_session_sz=0;
+ char *readable_session=dtls_get_readable_session(shello->dtls_session_id, shello->dtls_session_id_sz, &readable_session_sz);
+ if (readable_session != NULL) {
+ cJSON_AddStringToObject(log, "server_hello_session", readable_session);
+ free(readable_session);
+ }
+ }
+
+ if (shello->cookie != NULL && shello->cookie_sz > 0) {
+ size_t readable_cookie_sz=0;
+ char *readable_cookie=dtls_get_readable_cookie(shello->cookie, shello->cookie_sz, &readable_cookie_sz);
+ if (readable_cookie != NULL) {
+ cJSON_AddStringToObject(log, "server_hello_cookie", readable_cookie);
+ free(readable_cookie);
+ }
+ }
+
+ char **cipher_suites=NULL;
+ size_t n_cipher_suites=0;
+ dtls_get_readable_cipher_suites(shello, (const char ***)&cipher_suites, &n_cipher_suites);
+ cJSON *cipher_suites_array=cJSON_CreateArray();
+ for (size_t i=0; i < n_cipher_suites; i++) {
+ cJSON_AddItemToArray(cipher_suites_array, cJSON_CreateString(cipher_suites[i]));
+ }
+ cJSON_AddItemToObject(log, "server_hello_cipher_suites", cipher_suites_array);
+ free(cipher_suites);
+
+ char **compression_methods=NULL;
+ size_t n_compression_methods=0;
+ dtls_get_readable_compression_methods(shello, (const char ***)&compression_methods, &n_compression_methods);
+ cJSON *compression_methods_array=cJSON_CreateArray();
+ for (size_t i=0; i < n_compression_methods; i++) {
+ cJSON_AddItemToArray(compression_methods_array, cJSON_CreateString(compression_methods[i]));
+ }
+ cJSON_AddItemToObject(log, "server_hello_compression_methods", compression_methods_array);
+ free(compression_methods);
+
+ if(shello->extensions!=NULL) {
+ cJSON *extensions_array=cJSON_CreateArray();
+ for(size_t i=0; i < utarray_len(shello->extensions); i++) {
+ struct dtls_handshake_extension *ext=(struct dtls_handshake_extension *)utarray_eltptr(shello->extensions, i);
+ cJSON_AddItemToArray(extensions_array, cJSON_CreateString(dtls_get_extension_name(ext->type)));
+ }
+ cJSON_AddItemToObject(log, "server_hello_extensions", extensions_array);
+ }
+ return;
+}
+
+static void dtls_record_hello_verify_req(struct dtls_hello_verify_request *dtls_hvr, cJSON *log)
+{
+ if (dtls_hvr->cookie != NULL && dtls_hvr->cookie_sz > 0) {
+ size_t readable_cookie_sz=0;
+ char *readable_cookie=dtls_get_readable_cookie(dtls_hvr->cookie, dtls_hvr->cookie_sz, &readable_cookie_sz);
+ if (readable_cookie != NULL) {
+ cJSON_AddStringToObject(log, "hello_verify_cookie", readable_cookie);
+ free(readable_cookie);
+ }
+ }
+ return;
+}
+
+struct dtls_test_sess_exdata *dtls_test_session_exdata_new()
+{
+ struct dtls_test_sess_exdata *sess_exdata=CALLOC(struct dtls_test_sess_exdata, 1);
+ sess_exdata->application_flag=0;
+ return sess_exdata;
+}
+
+void dtls_test_session_exdata_free(int idx __attribute__((unused)), void *ex_ptr, void *arg __attribute__((unused)))
+{
+ struct dtls_test_sess_exdata *sess_exdata=(struct dtls_test_sess_exdata *)ex_ptr;
+ free(sess_exdata);
+}
+
+void dtls_client_hello_callback(struct session *sess, struct dtls_handshake *chello, void *args)
+{
+ UNUSED(args);
+ struct dtls_test_sess_exdata *sess_exdata=(struct dtls_test_sess_exdata *)session_get_exdata(sess, g_exdata_index);
+ if(sess_exdata==NULL) {
+ sess_exdata=dtls_test_session_exdata_new();
+ session_set_exdata(sess, g_exdata_index, (void*)sess_exdata);
+ }
+ dtls_record_client_hello(chello, g_result_json);
+ return;
+}
+
+void dtls_server_hello_callback(struct session *sess, struct dtls_handshake *shello, void *args)
+{
+ UNUSED(args);
+ struct dtls_test_sess_exdata *sess_exdata=(struct dtls_test_sess_exdata *)session_get_exdata(sess, g_exdata_index);
+ if(sess_exdata==NULL) {
+ sess_exdata=dtls_test_session_exdata_new();
+ session_set_exdata(sess, g_exdata_index, (void*)sess_exdata);
+ }
+ dtls_record_server_hello(shello, g_result_json);
+ return;
+}
+
+void dtls_hello_verify_request_callback(struct session *sess, struct dtls_hello_verify_request *dtls_hvr, void *args)
+{
+ UNUSED(args);
+ struct dtls_test_sess_exdata *sess_exdata=(struct dtls_test_sess_exdata *)session_get_exdata(sess, g_exdata_index);
+ if(sess_exdata==NULL) {
+ sess_exdata=dtls_test_session_exdata_new();
+ session_set_exdata(sess, g_exdata_index, (void*)sess_exdata);
+ }
+ dtls_record_hello_verify_req(dtls_hvr, g_result_json);
+ return;
+}
+
+void dtls_application_data_callback(struct session *sess,
+ const char *application_data, size_t application_data_sz, int offset,
+ int is_finished,
+ void *args)
+{
+ UNUSED(args);
+ UNUSED(application_data);
+ UNUSED(application_data_sz);
+
+ struct dtls_test_sess_exdata *sess_exdata=(struct dtls_test_sess_exdata *)session_get_exdata(sess, g_exdata_index);
+ if(sess_exdata==NULL) {
+ sess_exdata=dtls_test_session_exdata_new();
+ session_set_exdata(sess, g_exdata_index, (void*)sess_exdata);
+ }
+
+ if(offset==0) {
+ cJSON_AddNumberToObject(g_result_json, "application_data_start", 1);
+ }
+ // dtls_record_application_data(application_data, application_data_sz, g_result_json);
+ if(is_finished) {
+ cJSON_AddNumberToObject(g_result_json, "sum_application_data_sz", offset+application_data_sz);
+ cJSON_AddStringToObject(g_result_json, "test_result:", session_get0_readable_addr(sess));
+ }
+ return;
+}
+
+struct stellar_module *dtls_decoder_test_init(struct stellar_module_manager *mod_mgr)
+{
+ struct dtls_decoder *dtls_decoder=module_to_dtls_decoder(stellar_module_manager_get_module(mod_mgr, DTLS_MODULE_NAME));
+ dtls_subscribe(dtls_decoder,
+ dtls_client_hello_callback,
+ dtls_server_hello_callback,
+ dtls_hello_verify_request_callback,
+ dtls_application_data_callback,
+ NULL);
+ struct session_manager *sess_mgr=stellar_module_get_session_manager(mod_mgr);
+ g_exdata_index=session_manager_new_session_exdata_index(sess_mgr, "DTLS_TEST_PLUG", dtls_test_session_exdata_free, NULL);
+ return stellar_module_new("TEST_DTLS", NULL);
+}
+
+void dtls_decoder_test_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
+{
+ (void)(mod_mgr);
+ stellar_module_free(mod);
+ printf("dtls_decoder_test_exit OK!\n");
+}
diff --git a/test/decoders/dtls/gtest_dtls.h b/test/decoders/dtls/gtest_dtls.h
new file mode 100644
index 0000000..014a1d4
--- /dev/null
+++ b/test/decoders/dtls/gtest_dtls.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+int stellar_test_result_setup();
+
+char *stellar_test_result_json_export();
+
+void stellar_test_result_cleanup();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/test/decoders/dtls/plus_test_main.cpp b/test/decoders/dtls/plus_test_main.cpp
new file mode 100644
index 0000000..fe27169
--- /dev/null
+++ b/test/decoders/dtls/plus_test_main.cpp
@@ -0,0 +1,149 @@
+/*
+ * author:yangwei
+ * create time:2021-8-21
+ *
+ */
+
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <assert.h>
+
+#include <gtest/gtest.h>
+
+#include "stellar/stellar.h"
+
+#include "cJSON.h"
+#include "gtest_dtls.h"
+
+
+struct gtest_json_result
+{
+ cJSON *test_json_root;
+ cJSON *expect_json_root;
+ int result_count;
+};
+
+static struct gtest_json_result *gtest_result_new(const char *expect_json_path)
+{
+ struct gtest_json_result *para = (struct gtest_json_result *)calloc(1, sizeof(struct gtest_json_result));
+ if(expect_json_path==NULL)
+ {
+ para->expect_json_root=cJSON_CreateArray();
+ return para;
+ }
+
+ FILE *file = fopen(expect_json_path, "rb");
+ if(file)
+ {
+ fseek(file, 0, SEEK_END);
+ long filesize = ftell(file);
+ rewind(file);
+ char *buffer = (char *)calloc(filesize + 1, 1);
+ fread(buffer, 1, filesize, file);
+
+ para->expect_json_root=cJSON_Parse(buffer);
+
+ free(buffer);
+ fclose(file);
+ }
+ para->result_count=1;//count start from 1
+ return para;
+}
+
+static int gtest_result_compare(struct gtest_json_result *para)
+{
+ if(cJSON_GetArraySize(para->test_json_root)!=cJSON_GetArraySize(para->expect_json_root))
+ {
+ char *load_json_str = cJSON_Print(para->expect_json_root);
+ printf("LOAD Raw:\n%s\n", load_json_str);
+ free(load_json_str);
+ char *result_json_str = cJSON_Print(para->test_json_root);
+ printf("TEST Raw:\n%s\n", result_json_str);
+ free(result_json_str);
+ return -1;
+ }
+ int compare_ret = cJSON_Compare(para->expect_json_root, para->test_json_root, 0);
+ if (compare_ret != 1)
+ {
+ char *load_json_str = cJSON_Print(para->expect_json_root);
+ printf("LOAD Raw:\n%s\n", load_json_str);
+ free(load_json_str);
+ char *result_json_str = cJSON_Print(para->test_json_root);
+ printf("TEST Raw:\n%s\n", result_json_str);
+ free(result_json_str);
+
+ cJSON *t_load = para->expect_json_root->child, *t_test = para->test_json_root->child;
+ while (t_load != NULL)
+ {
+ // print first diff item, then return;
+ if(1 != cJSON_Compare(t_load, t_test, 0))
+ {
+ load_json_str = cJSON_Print(t_load);
+ printf("LOAD Diff:\n%s\n", load_json_str);
+ free(load_json_str);
+ result_json_str = cJSON_Print(t_test);
+ printf("TEST Diff:\n%s\n", result_json_str);
+ free(result_json_str);
+ return -1;
+ }
+ t_load = t_load->next;
+ t_test = t_test->next;
+
+ }
+ }
+ return compare_ret;
+}
+
+static void gtest_result_free(struct gtest_json_result *para)
+{
+ if(para)
+ {
+ if(para->test_json_root)cJSON_Delete(para->test_json_root);
+ if(para->expect_json_root)cJSON_Delete(para->expect_json_root);
+ free(para);
+ }
+ return;
+}
+
+
+/**********************************************
+ * GTEST MAIN *
+ **********************************************/
+
+int main(int argc, char ** argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+
+ //EXPECT_EQ(argc, 2);
+
+ printf("Usage: ./[gtest_main] [/path/to/expect_json]\n");
+
+ char *expect_json_path=argv[1];
+ struct gtest_json_result *g_test_para = gtest_result_new(expect_json_path);
+
+ struct stellar *st=stellar_new("./conf/stellar.toml");
+
+ stellar_test_result_setup();
+
+ EXPECT_TRUE(st!=NULL);
+ stellar_run(st);
+
+ stellar_free(st);
+
+ char *test_result_json=stellar_test_result_json_export();
+ g_test_para->test_json_root=cJSON_Parse(test_result_json);
+ free(test_result_json);
+
+
+ EXPECT_TRUE(g_test_para->expect_json_root != NULL && g_test_para->test_json_root != NULL);
+ EXPECT_EQ(gtest_result_compare(g_test_para), 1);
+
+ gtest_result_free(g_test_para);
+
+ stellar_test_result_cleanup();
+
+ return ::testing::Test::HasFailure() ? 1 : 0;
+} \ No newline at end of file
diff --git a/test/decoders/dtls/test_config/dtls_config.toml b/test/decoders/dtls/test_config/dtls_config.toml
new file mode 100644
index 0000000..e265561
--- /dev/null
+++ b/test/decoders/dtls/test_config/dtls_config.toml
@@ -0,0 +1,2 @@
+[DTLS]
+STUN_MAX_NUM_BEFORE_DTLS=10
diff --git a/test/decoders/dtls/test_config/log.toml b/test/decoders/dtls/test_config/log.toml
new file mode 100644
index 0000000..56f6700
--- /dev/null
+++ b/test/decoders/dtls/test_config/log.toml
@@ -0,0 +1,4 @@
+[log]
+output = "stderr" # stderr, file
+file = "log/stellar.log"
+level = "INFO" # TRACE, DEBUG, INFO, WARN, ERROR, FATAL
diff --git a/test/decoders/dtls/test_config/spec.toml b/test/decoders/dtls/test_config/spec.toml
new file mode 100644
index 0000000..9475f16
--- /dev/null
+++ b/test/decoders/dtls/test_config/spec.toml
@@ -0,0 +1,9 @@
+[[module]]
+path = ""
+init = "dtls_decoder_init"
+exit = "dtls_decoder_exit"
+
+[[module]]
+path = ""
+init = "dtls_decoder_test_init"
+exit = "dtls_decoder_test_exit"
diff --git a/test/decoders/dtls/test_expect/1_dtls_with_sni.json b/test/decoders/dtls/test_expect/1_dtls_with_sni.json
new file mode 100644
index 0000000..5b7a2a7
--- /dev/null
+++ b/test/decoders/dtls/test_expect/1_dtls_with_sni.json
@@ -0,0 +1,24 @@
+{
+ "client_hello_version": "DTLS 1.2",
+ "client_hello_random": "5232942859319aa17d80f1464c5289b7b319daceb475ae52de9edc66",
+ "client_hello_cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"],
+ "client_hello_compression_methods": ["No Compression"],
+ "client_hello_extensions": ["server_name", "ec_point_formats", "supported_groups", "session_ticket", "encrypt_then_mac", "extended_master_secret", "signature_algorithms"],
+ "client_hello_sni": "localhost",
+ "hello_verify_cookie": "bd60f75173e9b21151c9efc8cdbe7103f7dc60cf",
+ "client_hello_version": "DTLS 1.2",
+ "client_hello_random": "5232942859319aa17d80f1464c5289b7b319daceb475ae52de9edc66",
+ "client_hello_cookie": "bd60f75173e9b21151c9efc8cdbe7103f7dc60cf",
+ "client_hello_cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"],
+ "client_hello_compression_methods": ["No Compression"],
+ "client_hello_extensions": ["server_name", "ec_point_formats", "supported_groups", "session_ticket", "encrypt_then_mac", "extended_master_secret", "signature_algorithms"],
+ "client_hello_sni": "localhost",
+ "server_hello_version": "DTLS 1.2",
+ "server_hello_random": "441522da2a04eb14899e7380449e8177e0c496e6068262c938c1bf56",
+ "server_hello_cipher_suites": ["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"],
+ "server_hello_compression_methods": ["No Compression"],
+ "server_hello_extensions": ["renegotiation_info", "ec_point_formats", "session_ticket", "extended_master_secret"],
+ "application_data_start": 1,
+ "sum_application_data_sz": 1240,
+ "test_result:": "192.168.44.32:39336-192.168.40.131:23232-17-0"
+} \ No newline at end of file
diff --git a/test/decoders/dtls/test_expect/2_dtls_with_stun.json b/test/decoders/dtls/test_expect/2_dtls_with_stun.json
new file mode 100644
index 0000000..ee7a17d
--- /dev/null
+++ b/test/decoders/dtls/test_expect/2_dtls_with_stun.json
@@ -0,0 +1,15 @@
+{
+ "client_hello_version": "DTLS 1.2",
+ "client_hello_random": "28b86a6258e0b1e34e3d2a202abe5ea325d433dd292ea5617fab4ef6",
+ "client_hello_cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA"],
+ "client_hello_compression_methods": ["No Compression"],
+ "client_hello_extensions": ["extended_master_secret", "renegotiation_info", "supported_groups", "ec_point_formats", "session_ticket", "signature_algorithms", "use_srtp"],
+ "server_hello_version": "DTLS 1.2",
+ "server_hello_random": "552aae89251d01db53e8f0e4aac9f86ac727ae930a19533746dab647",
+ "server_hello_cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"],
+ "server_hello_compression_methods": ["No Compression"],
+ "server_hello_extensions": ["extended_master_secret", "renegotiation_info", "ec_point_formats", "session_ticket", "use_srtp"],
+ "application_data_start": 1,
+ "sum_application_data_sz": 559520,
+ "test_result:": "192.168.56.33:56076-117.167.196.106:27357-17-0"
+}
diff --git a/test/decoders/dtls/test_expect/3_dtls_only_client_hello_with_sni.json b/test/decoders/dtls/test_expect/3_dtls_only_client_hello_with_sni.json
new file mode 100644
index 0000000..ff6bb23
--- /dev/null
+++ b/test/decoders/dtls/test_expect/3_dtls_only_client_hello_with_sni.json
@@ -0,0 +1,12 @@
+{
+ "client_hello_version": "DTLS 1.2",
+ "client_hello_random": "df0d3180ffd530c7d44d094db12b465f233f5bf8c133089c0d578124",
+ "client_hello_session": "8cba667e103463687b30404c208935082e4163d87ae2a7b0ff512772ffb5da61",
+ "client_hello_cipher_suites": ["TLS_RSA_WITH_AES_128_GCM_SHA256"],
+ "client_hello_compression_methods": ["No Compression"],
+ "client_hello_extensions": ["server_name", "encrypt_then_mac", "signature_algorithms"],
+ "client_hello_sni": "hangzhou.ciscovnp.com",
+ "application_data_start": 1,
+ "sum_application_data_sz": 13179,
+ "test_result:": "10.90.141.219:54122-106.14.18.226:443-17-0"
+}
diff --git a/test/decoders/dtls/test_expect/4_dtls_only_client_hello.json b/test/decoders/dtls/test_expect/4_dtls_only_client_hello.json
new file mode 100644
index 0000000..f498991
--- /dev/null
+++ b/test/decoders/dtls/test_expect/4_dtls_only_client_hello.json
@@ -0,0 +1,10 @@
+{
+ "client_hello_version": "DTLS 1.2",
+ "client_hello_random": "49e10a63f95831939b35743f27838d4a8995ec97cc1d5213165abe0c",
+ "client_hello_cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_3DES_EDE_CBC_SHA"],
+ "client_hello_compression_methods": ["No Compression"],
+ "client_hello_extensions": ["extended_master_secret", "renegotiation_info", "supported_groups", "ec_point_formats", "session_ticket", "signature_algorithms", "use_srtp"],
+ "application_data_start": 1,
+ "sum_application_data_sz": 296,
+ "test_result:": "10.92.137.247:63120-223.64.32.252:18407-17-0"
+}
diff --git a/test/decoders/dtls/test_expect/5_dtls_handshake.json b/test/decoders/dtls/test_expect/5_dtls_handshake.json
new file mode 100644
index 0000000..815317f
--- /dev/null
+++ b/test/decoders/dtls/test_expect/5_dtls_handshake.json
@@ -0,0 +1,16 @@
+{
+ "client_hello_version": "DTLS 1.2",
+ "client_hello_random": "925f63b620435bc6db90781d3d7ca1d679e5d7108840fb64070e8913",
+ "client_hello_cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8", "TLS_ECDHE_ECDSA_WITH_AES_256_CCM", "TLS_DHE_RSA_WITH_AES_256_CCM_8", "TLS_DHE_RSA_WITH_AES_256_CCM", "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384", "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384", "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8", "TLS_ECDHE_ECDSA_WITH_AES_128_CCM", "TLS_DHE_RSA_WITH_AES_128_CCM_8", "TLS_DHE_RSA_WITH_AES_128_CCM", "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256", "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256", "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384", "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256", "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_SEED_CBC_SHA", "TLS_DHE_DSS_WITH_SEED_CBC_SHA", "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_256_CCM_8", "TLS_RSA_WITH_AES_256_CCM", "TLS_RSA_WITH_ARIA_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_128_CCM_8", "TLS_RSA_WITH_AES_128_CCM", "TLS_RSA_WITH_ARIA_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_SEED_CBC_SHA", "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"],
+ "client_hello_compression_methods": ["No Compression"],
+ "client_hello_extensions": ["ec_point_formats", "supported_groups", "session_ticket", "encrypt_then_mac", "extended_master_secret", "signature_algorithms"],
+ "hello_verify_cookie": "e7e2f98229b2bf3a37f4c87696cad99e561e4223",
+ "server_hello_version": "DTLS 1.2",
+ "server_hello_random": "b187772b16c369f9fa0ba019514fe954ce1eee2bffd19cd0d4bd72c7",
+ "server_hello_cipher_suites": ["TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"],
+ "server_hello_compression_methods": ["No Compression"],
+ "server_hello_extensions": ["renegotiation_info", "ec_point_formats", "session_ticket", "extended_master_secret"],
+ "application_data_start": 1,
+ "sum_application_data_sz": 76,
+ "test_result:": "10.88.221.238:42982-123.60.18.122:3478-17-0"
+} \ No newline at end of file
diff --git a/test/decoders/dtls/test_expect/6_dtls_application.json b/test/decoders/dtls/test_expect/6_dtls_application.json
new file mode 100644
index 0000000..cb9b9f4
--- /dev/null
+++ b/test/decoders/dtls/test_expect/6_dtls_application.json
@@ -0,0 +1,5 @@
+{
+ "application_data_start": 1,
+ "sum_application_data_sz": 92344,
+ "test_result:": "192.168.64.38:58756-180.213.87.11:7517-17-0"
+} \ No newline at end of file
diff --git a/test/decoders/dtls/test_expect/7_sni_len_is_0.json b/test/decoders/dtls/test_expect/7_sni_len_is_0.json
new file mode 100644
index 0000000..e5be75d
--- /dev/null
+++ b/test/decoders/dtls/test_expect/7_sni_len_is_0.json
@@ -0,0 +1,10 @@
+{
+ "server_hello_version": "DTLS 1.2",
+ "server_hello_random": "a3941a47f9b6421c1eacb5c19818f599990c7e08f5c2d37809676926",
+ "server_hello_cipher_suites": ["TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"],
+ "server_hello_compression_methods": ["No Compression"],
+ "server_hello_extensions": ["renegotiation_info", "server_name", "ec_point_formats", "session_ticket"],
+ "application_data_start": 1,
+ "sum_application_data_sz": 0,
+ "test_result:": "10.126.166.84:64247-165.225.117.2:443-17-0"
+} \ No newline at end of file
diff --git a/test/decoders/dtls/test_pcap/1_dtls_with_sni.pcap b/test/decoders/dtls/test_pcap/1_dtls_with_sni.pcap
new file mode 100644
index 0000000..4fa6ce4
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/1_dtls_with_sni.pcap
Binary files differ
diff --git a/test/decoders/dtls/test_pcap/2_dtls_with_stun.pcap b/test/decoders/dtls/test_pcap/2_dtls_with_stun.pcap
new file mode 100644
index 0000000..e062219
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/2_dtls_with_stun.pcap
Binary files differ
diff --git a/test/decoders/dtls/test_pcap/3_dtls_only_client_hello_with_sni.pcap b/test/decoders/dtls/test_pcap/3_dtls_only_client_hello_with_sni.pcap
new file mode 100644
index 0000000..31118b9
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/3_dtls_only_client_hello_with_sni.pcap
Binary files differ
diff --git a/test/decoders/dtls/test_pcap/4_dtls_only_client_hello.pcap b/test/decoders/dtls/test_pcap/4_dtls_only_client_hello.pcap
new file mode 100644
index 0000000..97e563d
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/4_dtls_only_client_hello.pcap
Binary files differ
diff --git a/test/decoders/dtls/test_pcap/5_dtls_handshake.pcap b/test/decoders/dtls/test_pcap/5_dtls_handshake.pcap
new file mode 100644
index 0000000..801e760
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/5_dtls_handshake.pcap
Binary files differ
diff --git a/test/decoders/dtls/test_pcap/6_dtls_application.pcap b/test/decoders/dtls/test_pcap/6_dtls_application.pcap
new file mode 100644
index 0000000..604c254
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/6_dtls_application.pcap
Binary files differ
diff --git a/test/decoders/dtls/test_pcap/7_sni_len_is_0.pcap b/test/decoders/dtls/test_pcap/7_sni_len_is_0.pcap
new file mode 100644
index 0000000..ba2f9c7
--- /dev/null
+++ b/test/decoders/dtls/test_pcap/7_sni_len_is_0.pcap
Binary files differ