summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorliumengyan <[email protected]>2020-05-12 12:18:02 +0800
committerliumengyan <[email protected]>2020-05-12 12:18:02 +0800
commitc0ed0eb78f3e05bc1a30d314169ae296720196c6 (patch)
tree520e2149c83bacced4cb3a303aa73967d215e1f5 /test
first add
Diffstat (limited to 'test')
-rw-r--r--test/Makefile61
-rw-r--r--test/dpkt_plug_gquic.cpp118
-rw-r--r--test/dpkt_plug_gquic.h25
-rw-r--r--test/dpkt_plug_gquic.inf13
-rw-r--r--test/gquic.h99
5 files changed, 316 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..124fb04
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,61 @@
+CC = gcc
+CCC = g++
+
+INCLUDES += -I/opt/MESA/include/
+LIB = -L./opt/MESA/lib/ -lpthread
+CFLAGS = -g3 -Wall -fPIC
+CFLAGS += $(INCLUDES)
+
+TARGET = dpkt_plug_gquic.so
+INF = dpkt_plug_gquic.inf
+INSTALL_TARGET=$(TARGET)
+LIB_FILE = $(wildcard ../lib/*.a)
+SOURCES = $(wildcard *.cpp)
+OBJECTS = $(SOURCES:.cpp=.o)
+DEPS = $(SOURCES:.cpp=.d)
+
+INF=dpkt_plug_gquic.inf
+INSTALL_TARGET=dpkt_plug_gquic.so
+# $(CONF)
+INSTALL_DIR=/home/mesasoft/sapp/plug/business/dpkt_plug_gquic/
+
+all:$(TARGET)
+$(TARGET):$(OBJECTS) $(LIB_FILE)
+ $(CCC) -shared $(CFLAGS) $(OBJECTS) $(LIB) -o $@
+ mkdir -p $(INSTALL_DIR)
+ cp -r $(INSTALL_TARGET) $(INF) $(INSTALL_DIR) -f
+# cp $(TARGET) ../bin/
+
+.c.o:
+%.d:%.c
+ $(CCC) $< -MM $(INCLUDES) > $@
+
+%.o:%.cpp
+ $(CCC) -c -o $@ $(CFLAGS) $< $(INCLUDES)
+
+-include $(DEPS)
+
+clean :
+ rm -f $(OBJECTS) $(DEPS) $(TARGET)
+
+PLUGIN_PATH=./plug/business
+CONFLIST_NAME=conflist_business.inf
+PLUGIN_DIR_NAME=dpkt_plug_gquic
+PLUGIN_INF_NAME=dpkt_plug_gquic.inf
+PAPP_PATH=/home/dk/gitFile/ceiec/sapp
+
+TARGET_DIR=$(PAPP_PATH)/$(PLUGIN_PATH)/$(PLUGIN_DIR_NAME)/
+INSERT_FILE=$(PAPP_PATH)/$(PLUGIN_PATH)/$(CONFLIST_NAME)
+INSERT_CONTENT=$(PLUGIN_PATH)/$(PLUGIN_DIR_NAME)/$(PLUGIN_INF_NAME)
+install:
+ mkdir -p $(TARGET_DIR)
+ cp -r ../bin/*.inf $(TARGET_DIR)
+ cp -r ../bin/*.so $(TARGET_DIR)
+ cp -r ../bin/*.conf $(TARGET_DIR)
+ @ret=`cat $(INSERT_FILE)|grep $(INSERT_CONTENT)|wc -l`;if [ $$ret -eq 0 ];then echo $(INSERT_CONTENT) >>$(INSERT_FILE);fi
+
+CONF_DIR=$(PAPP_PATH)/conf/
+conf:
+ mkdir -p $(CONF_DIR)
+ cp -r ../bin/quic $(CONF_DIR)
+
diff --git a/test/dpkt_plug_gquic.cpp b/test/dpkt_plug_gquic.cpp
new file mode 100644
index 0000000..276f978
--- /dev/null
+++ b/test/dpkt_plug_gquic.cpp
@@ -0,0 +1,118 @@
+
+#include "dpkt_plug_gquic.h"
+
+#include <stdio.h>
+#include <dlfcn.h>
+#include "gquic.h"
+
+
+void a_ntoa( unsigned int in, char *buffer)
+{
+ unsigned char *bytes = (unsigned char *) &in;
+ int i = snprintf( buffer, 15, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3] );
+}
+
+int DPKT_GQUIC_INIT()
+{
+ int plugid = DK_PLUGID_GQUIC;
+ return plugid;
+}
+
+void DPKT_GQUIC_DESTROY()
+{
+ return;
+}
+
+
+char DPKT_GQUIC_ENTRY(stSessionInfo* session_info, void **pme, int _thread_num, struct streaminfo *pstream, void *a_packet)
+{
+ int thread_num = pstream->threadnum;
+
+ if(session_info->session_state & SESSION_STATE_CLOSE)
+ {
+ return PROT_STATE_GIVEME;
+ }
+
+ if(session_info->app_info ==NULL)
+ {
+ return PROT_STATE_GIVEME;
+ }
+
+ if(session_info->prot_flag == QUIC_CLIENT_HELLO){
+ printf("DPKT_QUIC_ENTRY\tQUIC_CLIENT_HELLO\n");
+ struct quic_stream *quic = (struct quic_stream*)session_info->app_info;
+ if(quic){
+ struct quic_client_hello client_hello = quic->st_client_hello;
+
+ printf("BUSINESS PLUG:QUIC_CLIENT_HELLO ext_tag_num=%d--------------------\n",client_hello.ext_tag_num);
+ if(quic->version){
+ printf("BUSINESS PLUG:QUIC_CLIENT_HELLO version=%d--------------------\n",quic->version);
+
+ }
+ if(client_hello.server_name){
+ printf("BUSINESS PLUG:QUIC_CLIENT_HELLO server_name=%s--------------------\n",client_hello.server_name);
+
+ }
+ if(client_hello.user_agent){
+ printf("BUSINESS PLUG:QUIC_CLIENT_HELLO user_agent=%s--------------------\n",client_hello.user_agent);
+ }
+ }
+ }
+
+
+ int i = 0, j = 0;
+ if(session_info->prot_flag == QUIC_VERSION){
+ printf("DPKT_QUIC_ENTRY\tQUIC_VERSION\n");
+ struct quic_stream *quic = (struct quic_stream*)session_info->app_info;
+ if(quic){
+ printf("version:%d\n",quic->version);
+ }
+ }
+
+ if(session_info->prot_flag == QUIC_SERVER_HELLO){
+ printf("DPKT_QUIC_ENTRY\tQUIC_SERVER_HELLO\n");
+ struct quic_stream *quic = (struct quic_stream*)session_info->app_info;
+ struct quic_server_hello server_hello = quic->st_server_hello;
+ printf("BUSINESS PLUG:QUIC_SERVER_HELLO ext_tag_num=%d--------------------\n",server_hello.ext_tag_num);
+ }
+
+ if(session_info->prot_flag == QUIC_CACHED_CERT){
+ printf("DPKT_QUIC_ENTRY\tQUIC_CACHED_CERT\n");
+ struct quic_stream *quic = (struct quic_stream*)session_info->app_info;
+ quic_tlv_t cached_cert = quic->cached_cert;
+ printf("--------------------BUSINESS PLUG:QUIC_CACHED_CERT cached_cert_length=%d--------------------\n",cached_cert.length);
+ for(i = 0; i < cached_cert.length; i++){
+ printf("%02X",((unsigned char*)cached_cert.ptr_value)[i]);
+ }
+ printf("----------------------------------------\n");
+ }
+
+ if(session_info->prot_flag == QUIC_COMM_CERT){
+ printf("DPKT_QUIC_ENTRY\tQUIC_COMM_CERT\n");
+ struct quic_stream *quic = (struct quic_stream*)session_info->app_info;
+ quic_tlv_t comm_cert = quic->common_cert;
+ printf("--------------------BUSINESS PLUG:QUIC_COMM_CERT common_cert_length=%d--------------------\n",comm_cert.length);
+ for(i = 0; i < comm_cert.length; i++){
+ printf("%02X",((unsigned char*)comm_cert.ptr_value)[i]);
+ }
+ printf("--------------------T--------------------\n");
+ }
+
+ if(session_info->prot_flag == QUIC_CERT_CHAIN){
+ printf("DPKT_QUIC_ENTRY\tQUIC_CERT_CHAIN\n");
+ struct quic_stream *quic = (struct quic_stream*)session_info->app_info;
+ quic_tlv_t cert_chain = quic->cert_chain;
+ printf("--------------------BUSINESS PLUG:QUIC_CERT_CHAIN cert_chain_length=%d--------------------\n",cert_chain.length);
+ for(i = 0; i < cert_chain.length; i++){
+ printf("%02X",((unsigned char*)cert_chain.ptr_value)[i]);
+ }
+ printf("----------------------------------------\n");
+ }
+
+
+ return PROT_STATE_GIVEME;
+
+}
+
+
+
diff --git a/test/dpkt_plug_gquic.h b/test/dpkt_plug_gquic.h
new file mode 100644
index 0000000..867f143
--- /dev/null
+++ b/test/dpkt_plug_gquic.h
@@ -0,0 +1,25 @@
+/*
+ * dk_plug_quic.h
+ *
+ * Created on:
+ * Author: root
+ */
+
+#ifndef SRC_DPKT_PLUG_QUIC_H_
+#define SRC_DPKT_PLUG_QUIC_H_
+
+#include "stream.h"
+
+#define DK_PLUGID_GQUIC 1003
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int DPKT_GQUIC_INIT();
+void DPKT_GQUIC_DESTROY();
+char DPKT_GQUIC_ENTRY(stSessionInfo* session_info, void **pme, int _thread_num, struct streaminfo *pstream, void *a_packet);
+
+#ifdef __cplusplus
+ }
+#endif
+#endif /* SRC_DPKT_PLUG_QUIC_H_ */
diff --git a/test/dpkt_plug_gquic.inf b/test/dpkt_plug_gquic.inf
new file mode 100644
index 0000000..cb2c2c4
--- /dev/null
+++ b/test/dpkt_plug_gquic.inf
@@ -0,0 +1,13 @@
+[PLUGINFO]
+PLUGNAME=dpkt_plug_gquic
+SO_PATH=./plug/business/dpkt_plug_gquic/dpkt_plug_gquic.so
+INIT_FUNC=DPKT_GQUIC_INIT
+DESTROY_FUNC=DPKT_GQUIC_DESTROY
+
+[QUIC]
+#FUNC_FLAG=QUIC_CLIENT_HELLO,QUIC_SERVER_HELLO,QUIC_CACHED_CERT,QUIC_COMM_CERT,QUIC_CERT_CHAIN,QUIC_VERSION,QUIC_APPLICATION_DATA
+
+FUNC_FLAG=QUIC_CLIENT_HELLO
+FUNC_NAME=DPKT_GQUIC_ENTRY
+
+
diff --git a/test/gquic.h b/test/gquic.h
new file mode 100644
index 0000000..bb50c77
--- /dev/null
+++ b/test/gquic.h
@@ -0,0 +1,99 @@
+/*
+ * quic.h
+ *
+ * Created on: 2019-4-4
+ * Author: root
+ */
+
+#ifndef SRC_GQUIC_H_
+#define SRC_GQUIC_H_
+
+
+
+#include <MESA/stream.h>
+#define MAX_EXTENSION_NUM 128
+#define MAX_TAG_VALUE_LEN 257
+#define SERVER_NAME_LEN 64
+//add in 20191207
+#define USER_AGENT_LEN 256
+#define RANDOM_LEN 32
+#define QUIC_VERSION_LEN 4
+
+
+#define QUIC_INTEREST_KEY (1<<QUIC_INTEREST_KEY_MASK)
+#define QUIC_CLIENT_HELLO (1<<QUIC_CLIENT_HELLO_MASK)
+#define QUIC_SERVER_HELLO (1<<QUIC_SERVER_HELLO_MASK)
+#define QUIC_CACHED_CERT (1<<QUIC_CACHED_CERT_MASK)
+#define QUIC_COMM_CERT (1<<QUIC_COMM_CERT_MASK)
+#define QUIC_CERT_CHAIN (1<<QUIC_CERT_CHAIN_MASK)
+#define QUIC_APPLICATION_DATA (1<<QUIC_APPLICATION_DATA_MASK)
+#define QUIC_VERSION (1<<QUIC_VERSION_MASK)
+
+
+enum quic_interested_region {
+ QUIC_INTEREST_KEY_MASK = 0,
+ QUIC_CLIENT_HELLO_MASK,
+ QUIC_SERVER_HELLO_MASK,
+ QUIC_CACHED_CERT_MASK,
+ QUIC_COMM_CERT_MASK,
+ QUIC_CERT_CHAIN_MASK,
+ QUIC_APPLICATION_DATA_MASK,
+ QUIC_VERSION_MASK
+};
+
+
+typedef struct quic_tlv{
+ unsigned int type;
+ unsigned int length;
+ void *ptr_value;
+}quic_tlv_t;
+
+struct quic_business_info
+{
+ void* param;
+ uint8_t return_value;
+};
+
+struct quic_client_hello {
+ int server_name_len;
+ char server_name[SERVER_NAME_LEN];
+ int user_agent_len;
+ char user_agent[USER_AGENT_LEN];
+ uint16_t ext_tag_num; //number of extensions or tags
+ quic_tlv_t** ext_tags; //extensions or tags
+};
+
+struct quic_server_hello {
+ /*include random,session,ciphersuit,compress_method...*/
+ uint16_t ext_tag_num; //number of extensions or tags
+ quic_tlv_t** ext_tags; //extensions or tags
+};
+
+
+struct quic_stream {
+ unsigned char link_state;
+ uint8_t version_cfm;
+ uint32_t version;
+ uint8_t fin_flag;
+ uint8_t is_quic_stream;
+ uint64_t gquic_cID;
+ struct quic_client_hello st_client_hello;
+ struct quic_server_hello st_server_hello;
+ struct quic_tlv cert_chain;
+ struct quic_tlv cached_cert;
+ struct quic_tlv common_cert;
+ struct quic_business_info* business;
+ enum quic_interested_region output_region_mask;
+ uint64_t output_region_flag;
+};
+
+//struct st_quic_client_hello* quic_get_clienthello(void* app_info);
+//struct st_quic_server_hello* quic_get_serverhello(void* app_info);
+//uint32_t quic_get_version(void* app_info);
+//quic_tlv_t* quic_get_cert_chain(void* app_info);
+//quic_tlv_t* quic_get_cached_cert(void* app_info);
+//quic_tlv_t* quic_get_common_cert(void* app_info);
+//void* quic_get_application_data(void* app_info);
+
+
+#endif /* SRC_GQUIC_H_ */