/* * author:yangwei * create time:2021-8-21 * */ #include #include #include #include #include "cJSON.h" #include "quic.h" #include "MESA_prof_load.h" #include extern "C" int commit_test_result_json(cJSON *node, const char *name); static int g_result_count = 1; extern "C" unsigned char QUIC_TEST_PLUG_ENTRY(stSessionInfo *session_info, void **pme, int thread_seq, struct streaminfo *a_tcp, void *a_packet) { assert(NULL != session_info || pme != NULL); cJSON *ctx = (cJSON *)*pme; struct quic_info *quic_info=NULL; char version_str[128]={0}; unsigned int version = 0; if (session_info->session_state & SESSION_STATE_PENDING) { if (*pme == NULL) { ctx = cJSON_CreateObject(); *pme = (void *)ctx; cJSON_AddStringToObject(ctx, "Tuple4", printaddr(&a_tcp->addr, a_tcp->threadnum)); } } switch (session_info->prot_flag) { case QUIC_CLIENT_HELLO: if (session_info == NULL || session_info->app_info == NULL) { break; } quic_info = (struct quic_info *)session_info->app_info; if(quic_info->client_hello==NULL) { break; } if(quic_info->client_hello->sni!=NULL) { cJSON_AddStringToObject(ctx, "SNI", (char *)(quic_info->client_hello->sni)); } if(quic_info->client_hello->user_agent!=NULL) { cJSON_AddStringToObject(ctx, "UA", (char *)(quic_info->client_hello->user_agent)); } quic_version_int2string((unsigned int)(quic_info->quic_version), version_str, sizeof(version_str)); cJSON_AddStringToObject(ctx, "VERSION", version_str); break; case QUIC_USEING_VERSION: version = *(unsigned int *)(session_info->buf); quic_version_int2string(version, version_str, sizeof(version_str)); cJSON_AddStringToObject(ctx, "VERSION", version_str); break; default: break; } if(session_info->session_state&SESSION_STATE_CLOSE) { if(ctx) { char result_name[16]=""; sprintf(result_name,"QUIC_RESULT_%d", g_result_count); commit_test_result_json(ctx, result_name); g_result_count+=1; } *pme = NULL; return PROT_STATE_DROPME; } return PROT_STATE_GIVEME; } extern "C" int QUIC_TEST_PLUG_INIT() { return 0; } extern "C" void QUIC_TEST_PLUG_DESTROY(void) { return ; }