review code; 代码调整
This commit is contained in:
@@ -9,41 +9,222 @@
|
||||
#include "gquic_process.h"
|
||||
#include <stdio.h>
|
||||
#include <MESA/stream_inc/stream_base.h>
|
||||
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
|
||||
struct quic_param_t g_quic_param;
|
||||
const char *g_quic_proto_conffile="./conf/quic/main.conf";
|
||||
const char *g_quic_regionname_conffile="./conf/quic/quic.conf";
|
||||
|
||||
|
||||
int QUIC_INIT(void)
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define GIT_VERSION_CATTER(v) __attribute__((__used__)) const char * GIT_VERSION_##v = NULL
|
||||
#define GIT_VERSION_EXPEND(v) GIT_VERSION_CATTER(v)
|
||||
|
||||
/* VERSION TAG */
|
||||
#ifdef GIT_VERSION
|
||||
GIT_VERSION_EXPEND(GIT_VERSION);
|
||||
#else
|
||||
static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
|
||||
#endif
|
||||
#undef GIT_VERSION_CATTER
|
||||
#undef GIT_VERSION_EXPEND
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
const char QUIC_VERSION_20200522=0;
|
||||
|
||||
|
||||
int quic_init_stream(void **pme, int thread_seq)
|
||||
{
|
||||
struct quic_stream *a_quic_stream=(struct quic_stream *)*pme;
|
||||
|
||||
a_quic_stream=(struct quic_stream *)dictator_malloc(thread_seq, sizeof(struct quic_stream));
|
||||
memset(a_quic_stream,0,sizeof(struct quic_stream));
|
||||
|
||||
a_quic_stream->output_region_flag = g_quic_param.quic_interested_region_flag;
|
||||
a_quic_stream->output_region_mask = QUIC_INTEREST_KEY_MASK;
|
||||
|
||||
a_quic_stream->is_quic_stream = QUIC_FALSE;
|
||||
a_quic_stream->version_cfm = QUIC_FALSE;
|
||||
a_quic_stream->version = 0;
|
||||
a_quic_stream->link_state = QUIC_FALSE;
|
||||
a_quic_stream->fin_flag = QUIC_FALSE;
|
||||
a_quic_stream->business = (struct quic_business_info *)dictator_malloc(thread_seq,sizeof(struct quic_business_info));
|
||||
a_quic_stream->business->param = NULL;
|
||||
a_quic_stream->business->return_value = PROT_STATE_GIVEME;
|
||||
|
||||
*pme = (void*)a_quic_stream;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quic_release_clientHello(int thread_seq, struct quic_client_hello* st_client_hello)
|
||||
{
|
||||
if(st_client_hello!=NULL)
|
||||
{
|
||||
if(st_client_hello->ext_tags!=NULL)
|
||||
{
|
||||
quic_release_exts(thread_seq, st_client_hello->ext_tags, st_client_hello->ext_tag_num);
|
||||
dictator_free(thread_seq, st_client_hello->ext_tags);
|
||||
st_client_hello->ext_tags = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void quic_release_exts(int thread_seq, quic_tlv_t** ext_tags, UINT16 ext_tag_num)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
if(ext_tags!=NULL)
|
||||
{
|
||||
for(i=0; i<ext_tag_num; i++)
|
||||
{
|
||||
if(ext_tags[i] != NULL)
|
||||
{
|
||||
if(ext_tags[i]->ptr_value != NULL)
|
||||
{
|
||||
dictator_free(thread_seq, ext_tags[i]->ptr_value);
|
||||
ext_tags[i]->ptr_value = NULL;
|
||||
}
|
||||
|
||||
dictator_free(thread_seq, ext_tags[i]);
|
||||
ext_tags[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
dictator_free(thread_seq, ext_tags);
|
||||
ext_tags=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void quic_release_stream(struct streaminfo *a_tcp, void** pme, int thread_seq)
|
||||
{
|
||||
struct quic_stream *a_quic_stream = (struct quic_stream *)*pme;
|
||||
if(NULL!=a_quic_stream)
|
||||
{
|
||||
a_quic_stream->fin_flag = QUIC_TRUE;
|
||||
|
||||
if(NULL!=a_quic_stream->business)
|
||||
{
|
||||
if(a_quic_stream->business->param!=NULL)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->business->param);
|
||||
a_quic_stream->business->param = NULL;
|
||||
}
|
||||
dictator_free(thread_seq,a_quic_stream->business);
|
||||
a_quic_stream->business = NULL;
|
||||
}
|
||||
if(NULL!=a_quic_stream->cert_chain.ptr_value)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->cert_chain.ptr_value);
|
||||
a_quic_stream->cert_chain.ptr_value = NULL;
|
||||
}
|
||||
if(NULL!=a_quic_stream->common_cert.ptr_value)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->common_cert.ptr_value);
|
||||
a_quic_stream->common_cert.ptr_value = NULL;
|
||||
}
|
||||
if(NULL!=a_quic_stream->cached_cert.ptr_value)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->cached_cert.ptr_value);
|
||||
a_quic_stream->cached_cert.ptr_value = NULL;
|
||||
}
|
||||
|
||||
quic_release_exts(thread_seq, a_quic_stream->st_client_hello.ext_tags, a_quic_stream->st_client_hello.ext_tag_num);
|
||||
quic_release_exts(thread_seq, a_quic_stream->st_server_hello.ext_tags, a_quic_stream->st_server_hello.ext_tag_num);
|
||||
|
||||
dictator_free(thread_seq,a_quic_stream);
|
||||
a_quic_stream = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
extern "C" int QUIC_INIT(void)
|
||||
{
|
||||
int ret=0,level=30;
|
||||
char log_path[1024]={0};
|
||||
FILE *fp=NULL;
|
||||
char buf[2048]={0};
|
||||
int region_id=0;
|
||||
char region_name[REGION_NAME_LEN]={0};
|
||||
|
||||
memset(&g_quic_param,0,sizeof(struct quic_param_t));
|
||||
strcat(g_quic_param.quic_conf_filename, "./conf/quic/quic.conf");
|
||||
if(0!=readconf(g_quic_param.quic_conf_filename)){
|
||||
|
||||
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "LOG_LEVEL", &level, RLOG_LV_FATAL);
|
||||
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "LOG_PATH", log_path, sizeof(log_path), "./log/quic/quic");
|
||||
|
||||
g_quic_param.logger=MESA_create_runtime_log_handle(log_path, level);
|
||||
if(g_quic_param.logger==NULL)
|
||||
{
|
||||
printf("MESA_create_runtime_log_handle failed, level: %d log_path: %s", level, log_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(((fp = fopen(g_quic_regionname_conffile, "r"))!=NULL))
|
||||
{
|
||||
while(fgets(buf, sizeof(buf), fp))
|
||||
{
|
||||
ret = sscanf(buf, "%d\t%s", ®ion_id, region_name);
|
||||
if(2>ret)
|
||||
{
|
||||
fclose(fp);
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, region_line: %s", g_quic_regionname_conffile, buf);
|
||||
return -1;
|
||||
}
|
||||
if(region_id>MAX_REGION_NUM)
|
||||
{
|
||||
fclose(fp);
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, bigger than MAX_REGION_NUM, region_line: %s", g_quic_regionname_conffile, buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(g_quic_param.quic_conf_regionname[region_id], region_name, strlen(region_name));
|
||||
g_quic_param.quic_region_cnt++;
|
||||
memset(region_name, 0, sizeof(region_name));
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Open %s error, Please check %s", g_quic_regionname_conffile, g_quic_regionname_conffile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}/*QUICINIT*/
|
||||
|
||||
void QUIC_DESTROY(void)
|
||||
extern "C" void QUIC_DESTROY(void)
|
||||
{
|
||||
return ;
|
||||
}/*QUICDESTROY*/
|
||||
|
||||
void QUIC_GETPLUGID(unsigned short plugid)
|
||||
extern "C" void QUIC_GETPLUGID(unsigned short plugid)
|
||||
{
|
||||
g_quic_param.quic_plugid = plugid;
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_GETPLUGID", "quic_plugid: %d", plugid);
|
||||
}
|
||||
|
||||
void QUIC_PROT_FUNSTAT(unsigned long long protflag)
|
||||
extern "C" void QUIC_PROT_FUNSTAT(unsigned long long protflag)
|
||||
{
|
||||
if(0==protflag){
|
||||
return;
|
||||
}
|
||||
g_quic_param.quic_interested_region_flag = protflag;
|
||||
g_quic_param.quic_interested_region_flag=protflag;
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_PROT_FUNSTAT", "interested_region_flag: %llu", g_quic_param.quic_interested_region_flag);
|
||||
return;
|
||||
}/*PROT_FUNSTAT*/
|
||||
|
||||
unsigned long long quic_getRegionID(char *string, int str_len,const char g_string[MAX_REGION_NUM][REGION_NAME_LEN])
|
||||
extern "C" unsigned long long quic_getRegionID(char *string, int str_len,const char g_string[MAX_REGION_NUM][REGION_NAME_LEN])
|
||||
{
|
||||
unsigned long long i=0;
|
||||
for(i=0;i<g_quic_param.quic_region_cnt;i++)
|
||||
@@ -56,7 +237,7 @@ unsigned long long quic_getRegionID(char *string, int str_len,const char g_strin
|
||||
return 0;
|
||||
}
|
||||
|
||||
long long QUIC_FLAG_CHANGE(char* flag_str)
|
||||
extern "C" long long QUIC_FLAG_CHANGE(char* flag_str)
|
||||
{
|
||||
if(flag_str==NULL) return -1;
|
||||
long long protflag = 0;
|
||||
@@ -83,350 +264,63 @@ long long QUIC_FLAG_CHANGE(char* flag_str)
|
||||
region_id = quic_getRegionID(region_name, strlen(region_name), g_quic_param.quic_conf_regionname);
|
||||
if(-1==region_id)
|
||||
{
|
||||
#ifdef PRINTF
|
||||
printf( "quic.so : PROT_CHANGE %s read %s error\n", flag_str, region_name);
|
||||
#endif
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_FLAG_CHANGE", "Read %s error, flag_str: %d", region_name, flag_str);
|
||||
return -1;
|
||||
}
|
||||
protflag |= ((long long)1)<<region_id;
|
||||
memset(region_name, 0, REGION_NAME_LEN);
|
||||
}
|
||||
|
||||
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_FLAG_CHANGE", "protflag: %llu", protflag);
|
||||
return protflag;
|
||||
}
|
||||
|
||||
char QUIC_ENTRY(struct streaminfo *pstream, void**pme, int thread_seq, void *a_pcaket)
|
||||
extern "C" char QUIC_ENTRY(struct streaminfo *pstream, void**pme, int thread_seq, void *a_packet)
|
||||
{
|
||||
uint8_t return_val=0;
|
||||
switch(quic_doWithInsterestedRegion(pstream))
|
||||
{
|
||||
case APP_STATE_DROPME:
|
||||
struct quic_stream *a_quic_stream=(struct quic_stream *)*pme;
|
||||
|
||||
if(g_quic_param.quic_interested_region_flag<QUIC_KEY)
|
||||
{
|
||||
MESA_handle_runtime_log(g_quic_param.logger,
|
||||
RLOG_LV_FATAL,
|
||||
"QUIC_INSTEREST",
|
||||
"No business register QUIC, interested_region_flag: %llu QUIC_KEY: %d",
|
||||
g_quic_param.quic_interested_region_flag,
|
||||
QUIC_KEY,
|
||||
printaddr(&pstream->addr, thread_seq));
|
||||
return APP_STATE_DROPME;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
struct quic_stream* a_quic_stream = NULL;
|
||||
|
||||
if(*pme==NULL)
|
||||
{
|
||||
quic_init_stream(pme, thread_seq);
|
||||
a_quic_stream=(struct quic_stream *)*pme;
|
||||
}
|
||||
|
||||
switch(pstream->opstate)
|
||||
{
|
||||
case OP_STATE_PENDING:
|
||||
return_val = quic_init_stream(pstream, pme, thread_seq);
|
||||
if(return_val < 0){
|
||||
#ifdef PRINTF
|
||||
printf("initQuicStream error\n");
|
||||
#endif
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
case OP_STATE_DATA:
|
||||
return_val = quic_analyseStream(pstream, pme, thread_seq, a_pcaket);
|
||||
if(return_val == QUIC_RETURN_DROPME){
|
||||
quic_release_stream(pstream, pme, thread_seq, a_pcaket);
|
||||
*pme = NULL;
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_STATE_CLOSE:
|
||||
a_quic_stream = (struct quic_stream *)*pme;
|
||||
if(a_quic_stream!=NULL)
|
||||
{
|
||||
a_quic_stream->fin_flag = QUIC_TRUE;
|
||||
}
|
||||
return_val = quic_analyseStream(pstream, pme, thread_seq, a_pcaket);
|
||||
if(a_quic_stream!=NULL)
|
||||
{
|
||||
quic_release_stream(pstream, pme, thread_seq, a_pcaket);
|
||||
*pme = NULL;
|
||||
}
|
||||
case OP_STATE_PENDING:
|
||||
case OP_STATE_DATA:
|
||||
return_val=gquic_process(pstream, a_quic_stream, thread_seq, a_packet);
|
||||
break;
|
||||
case OP_STATE_CLOSE:
|
||||
a_quic_stream->fin_flag=QUIC_TRUE;
|
||||
return_val=gquic_process(pstream, a_quic_stream, thread_seq, a_packet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(return_val==QUIC_RETURN_DROPME || pstream->opstate==OP_STATE_CLOSE)
|
||||
{
|
||||
quic_release_stream(pstream, pme, thread_seq);
|
||||
*pme=NULL;
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
return APP_STATE_GIVEME;
|
||||
|
||||
return APP_STATE_GIVEME;
|
||||
}/*QUICNIT*/
|
||||
|
||||
|
||||
void quic_init_clientHello(struct quic_client_hello* stClientHello, UINT32 tag_num, int thread_seq)
|
||||
{
|
||||
if(stClientHello==NULL) return ;
|
||||
|
||||
if(tag_num == 0){
|
||||
}else{
|
||||
(stClientHello->ext_tags) = (quic_tlv_t **)dictator_malloc(thread_seq,tag_num*sizeof(quic_tlv_t*));
|
||||
int i=0;
|
||||
for(i=0;i<tag_num;i++)
|
||||
{
|
||||
stClientHello->ext_tags[i] = (quic_tlv_t *)dictator_malloc(thread_seq, sizeof(quic_tlv_t) );
|
||||
memset(stClientHello->ext_tags[i], 0, sizeof(quic_tlv_t));
|
||||
stClientHello->ext_tags[i]->ptr_value = (char *)dictator_malloc(thread_seq, sizeof(char)*MAX_TAG_VALUE_LEN);
|
||||
stClientHello->ext_tags[i]->length = 0;
|
||||
stClientHello->ext_tags[i]->type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// stClientHello->ext_tag_len = 0;
|
||||
stClientHello->ext_tag_num = tag_num;
|
||||
memset(stClientHello->server_name, 0, SERVER_NAME_LEN);
|
||||
memset(stClientHello->user_agent, 0, SERVER_NAME_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
//void quic_init_clientHello(struct quic_client_hello* stClientHello, UINT32 tag_num, int thread_seq)
|
||||
//{
|
||||
// if(stClientHello==NULL) return ;
|
||||
// stClientHello->session.ptr_value = NULL;
|
||||
// stClientHello->session.length = 0;
|
||||
// stClientHello->ciphersuits.ptr_value = NULL;
|
||||
// stClientHello->ciphersuits.length = 0;
|
||||
// stClientHello->com_method.ptr_value = NULL;
|
||||
// stClientHello->com_method.length = 0;
|
||||
// memset(&stClientHello->random, 0, RANDOM_LEN);
|
||||
// (stClientHello->ext_tags) = (struct quic_tlv_t **)dictator_malloc(thread_seq,tag_num*sizeof(struct quic_tlv_t*));
|
||||
//
|
||||
// int i=0;
|
||||
// for(i=0;i<tag_num;i++)
|
||||
// {
|
||||
// stClientHello->ext_tags[i] = (struct quic_tlv_t *)dictator_malloc(thread_seq, sizeof(struct quic_tlv_t) );
|
||||
// memset(stClientHello->ext_tags[i], 0, sizeof(struct quic_tlv_t));
|
||||
// stClientHello->ext_tags[i]->ptr_value = (char *)dictator_malloc(thread_seq, sizeof(char)*MAX_TAG_VALUE_LEN);
|
||||
// stClientHello->ext_tags[i]->length = 0;
|
||||
// stClientHello->ext_tags[i]->type = 0;
|
||||
// }
|
||||
// stClientHello->ext_tag_len = 0;
|
||||
// stClientHello->ext_tag_num = tag_num;
|
||||
// memset(&stClientHello->server_name, 0, sizeof(stClientHello->server_name));
|
||||
// memset(&stClientHello->user_agent, 0, sizeof(stClientHello->user_agent));
|
||||
// return;
|
||||
//}
|
||||
|
||||
void quic_init_serverHello(struct quic_server_hello* stServerHello, UINT32 tag_num, int thread_seq)
|
||||
{
|
||||
if(stServerHello==NULL) return ;
|
||||
// stServerHello->session.ptr_value = NULL;
|
||||
// stServerHello->session.length = 0;
|
||||
// memset(&stServerHello->random, 0, RANDOM_LEN);
|
||||
if(tag_num == 0){
|
||||
}else{
|
||||
(stServerHello->ext_tags) = (quic_tlv_t **)dictator_malloc(thread_seq,tag_num*sizeof(quic_tlv_t*));
|
||||
int i=0;
|
||||
for(i=0;i<tag_num;i++)
|
||||
{
|
||||
// stServerHello->ext_tags[i] = (struct quic_tlv_t *)dictator_malloc(thread_seq, sizeof(quic_tlv_t)*20);
|
||||
stServerHello->ext_tags[i] = (quic_tlv_t *)dictator_malloc(thread_seq, sizeof(quic_tlv_t));
|
||||
memset(stServerHello->ext_tags[i], 0, sizeof(quic_tlv_t));
|
||||
stServerHello->ext_tags[i]->ptr_value = (char *)dictator_malloc(thread_seq, sizeof(char)*MAX_TAG_VALUE_LEN);
|
||||
stServerHello->ext_tags[i]->length = 0;
|
||||
stServerHello->ext_tags[i]->type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
stServerHello->ext_tag_num = tag_num;
|
||||
return;
|
||||
}
|
||||
|
||||
int quic_init_stream(struct streaminfo *pstream, void **pme, int thread_seq){
|
||||
|
||||
struct quic_stream *a_quic_stream = (struct quic_stream *)*pme;
|
||||
if(NULL != a_quic_stream)
|
||||
return -1;
|
||||
a_quic_stream = (struct quic_stream *)dictator_malloc(thread_seq, sizeof(struct quic_stream));
|
||||
memset(a_quic_stream,0,sizeof(struct quic_stream));
|
||||
if (NULL == a_quic_stream)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
a_quic_stream->output_region_flag = g_quic_param.quic_interested_region_flag;
|
||||
a_quic_stream->output_region_mask = QUIC_INTEREST_KEY_MASK;
|
||||
// a_quic_stream->type = UNKNOWN_QUIC_TYPE;
|
||||
// a_quic_stream->handshake_type = UNKNOWN_HANDSHAKE_TYPE;
|
||||
a_quic_stream->is_quic_stream = QUIC_FALSE;
|
||||
a_quic_stream->version_cfm = QUIC_FALSE;
|
||||
a_quic_stream->version = 0;
|
||||
a_quic_stream->link_state = QUIC_FALSE;
|
||||
a_quic_stream->fin_flag = QUIC_FALSE;
|
||||
// a_quic_stream->p_output_buffer = (struct quic_tlv_t*)dictator_malloc(thread_seq, sizeof(struct quic_tlv_t));
|
||||
// a_quic_stream->p_output_buffer->length = 0;
|
||||
// a_quic_stream->p_output_buffer->ptr_value = 0;
|
||||
a_quic_stream->business = (struct quic_business_info *)dictator_malloc(thread_seq,sizeof(struct quic_business_info));
|
||||
a_quic_stream->business->param = NULL;
|
||||
a_quic_stream->business->return_value = PROT_STATE_GIVEME;
|
||||
|
||||
*pme = (void*)a_quic_stream;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quic_release_clientHello(int thread_seq, struct quic_client_hello* st_client_hello)
|
||||
{
|
||||
if(st_client_hello==NULL) return ;
|
||||
// if(st_client_hello->random.ptr_value!=NULL)
|
||||
// {
|
||||
// dictator_free(thread_seq,st_client_hello->random.ptr_value);
|
||||
// st_client_hello->random.ptr_value = NULL;
|
||||
// }
|
||||
// if(st_client_hello->session.ptr_value!=NULL)
|
||||
// {
|
||||
// dictator_free(thread_seq,st_client_hello->session.ptr_value);
|
||||
// st_client_hello->session.ptr_value = NULL;
|
||||
// }
|
||||
// if(st_client_hello->ciphersuits.ptr_value!=NULL)
|
||||
// {
|
||||
// dictator_free(thread_seq,st_client_hello->ciphersuits.ptr_value);
|
||||
// st_client_hello->ciphersuits.ptr_value = NULL;
|
||||
// }
|
||||
// if(st_client_hello->com_method.ptr_value!=NULL)
|
||||
// {
|
||||
// dictator_free(thread_seq,st_client_hello->com_method.ptr_value);
|
||||
// st_client_hello->com_method.ptr_value = NULL;
|
||||
// }
|
||||
if(st_client_hello->ext_tags != NULL){
|
||||
quic_release_exts(thread_seq, st_client_hello->ext_tags, st_client_hello->ext_tag_num);
|
||||
dictator_free(thread_seq, st_client_hello->ext_tags);
|
||||
st_client_hello->ext_tags = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void quic_release_serverHello(int thread_seq,struct quic_server_hello* st_server_hello)
|
||||
{
|
||||
if(st_server_hello==NULL) return ;
|
||||
// if(st_server_hello->session.ptr_value!=NULL)
|
||||
// {
|
||||
// dictator_free(thread_seq,st_server_hello->session.ptr_value);
|
||||
// st_server_hello->session.ptr_value = NULL;
|
||||
// }
|
||||
if(st_server_hello->ext_tags != NULL){
|
||||
quic_release_exts(thread_seq, st_server_hello->ext_tags, st_server_hello->ext_tag_num);
|
||||
dictator_free(thread_seq, st_server_hello->ext_tags);
|
||||
st_server_hello->ext_tags = NULL;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
void quic_release_exts(int thread_seq, quic_tlv_t** ext_tags, UINT16 ext_tag_num){
|
||||
if(ext_tags == NULL) return;
|
||||
int i = 0;
|
||||
for(i = 0; i < ext_tag_num; i++){
|
||||
if(ext_tags[i] != NULL){
|
||||
if(ext_tags[i]->ptr_value != NULL){
|
||||
dictator_free(thread_seq, ext_tags[i]->ptr_value);
|
||||
ext_tags[i]->ptr_value = NULL;
|
||||
}
|
||||
dictator_free(thread_seq, ext_tags[i]);
|
||||
ext_tags[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void quic_release_stream(struct streaminfo *a_tcp, void** pme, int thread_seq,void *a_packet)
|
||||
{
|
||||
struct quic_stream *a_quic_stream = (struct quic_stream *)*pme;
|
||||
if(NULL == a_quic_stream) return;
|
||||
a_quic_stream->fin_flag = QUIC_TRUE;
|
||||
// if(NULL != a_quic_stream->p_output_buffer)
|
||||
// {
|
||||
// if(a_quic_stream->p_output_buffer->ptr_value!=NULL)
|
||||
// {
|
||||
// dictator_free(thread_seq,a_quic_stream->p_output_buffer->ptr_value);
|
||||
// a_quic_stream->p_output_buffer->ptr_value = NULL;
|
||||
// }
|
||||
// dictator_free(thread_seq,a_quic_stream->p_output_buffer);
|
||||
// a_quic_stream->p_output_buffer = NULL;
|
||||
// }
|
||||
if(NULL != a_quic_stream->business)
|
||||
{
|
||||
if(a_quic_stream->business->param !=NULL){
|
||||
dictator_free(thread_seq,a_quic_stream->business->param);
|
||||
a_quic_stream->business->param = NULL;
|
||||
}
|
||||
dictator_free(thread_seq,a_quic_stream->business);
|
||||
a_quic_stream->business = NULL;
|
||||
}
|
||||
if(NULL != a_quic_stream->cert_chain.ptr_value)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->cert_chain.ptr_value);
|
||||
a_quic_stream->cert_chain.ptr_value = NULL;
|
||||
}
|
||||
if(NULL != a_quic_stream->common_cert.ptr_value)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->common_cert.ptr_value);
|
||||
a_quic_stream->common_cert.ptr_value = NULL;
|
||||
}
|
||||
if(NULL != a_quic_stream->cached_cert.ptr_value)
|
||||
{
|
||||
dictator_free(thread_seq,a_quic_stream->cached_cert.ptr_value);
|
||||
a_quic_stream->cached_cert.ptr_value = NULL;
|
||||
}
|
||||
quic_release_serverHello(thread_seq, &a_quic_stream->st_server_hello);
|
||||
quic_release_clientHello(thread_seq, &a_quic_stream->st_client_hello);
|
||||
|
||||
dictator_free(thread_seq,a_quic_stream);
|
||||
a_quic_stream = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UINT8 quic_analyseStream(struct streaminfo *pstream, void** pme, int thread_seq, void *a_packet){
|
||||
struct quic_stream* a_quic_stream = (struct quic_stream *)*pme;
|
||||
if(a_quic_stream == NULL){
|
||||
return QUIC_RETURN_DROPME;
|
||||
}
|
||||
UINT8 return_val = QUIC_RETURN_NORM;
|
||||
struct udpdetail *udp_detail = (struct udpdetail *) pstream->pdetail;
|
||||
if(udp_detail->datalen <= 0){
|
||||
return QUIC_RETURN_NORM;
|
||||
}
|
||||
|
||||
char* g_data_t = (char *)udp_detail->pdata;
|
||||
UINT32 g_len_t = udp_detail->datalen;
|
||||
|
||||
if(!a_quic_stream->is_quic_stream){
|
||||
if(g_len_t <= GQUIC_HEADER_LEN){
|
||||
return QUIC_RETURN_DROPME;
|
||||
}
|
||||
if(g_len_t > GQUIC_HEADER_LEN){
|
||||
return_val = gquic_process(pstream, a_quic_stream, a_quic_stream->output_region_flag, thread_seq, a_packet, g_data_t, g_len_t);
|
||||
}
|
||||
}else if(a_quic_stream->is_quic_stream){
|
||||
if(g_len_t > GQUIC_HEADER_LEN){
|
||||
gquic_process(pstream, a_quic_stream, a_quic_stream->output_region_flag, thread_seq, a_packet, g_data_t, g_len_t);
|
||||
}
|
||||
return QUIC_RETURN_NORM;
|
||||
}
|
||||
return return_val;
|
||||
}
|
||||
|
||||
|
||||
int quic_getLinkState(struct quic_stream *a_quic_stream)
|
||||
{
|
||||
UCHAR state = 0;
|
||||
if(QUIC_FALSE==(a_quic_stream)->link_state)
|
||||
{
|
||||
if(QUIC_TRUE==(a_quic_stream)->fin_flag)
|
||||
state = SESSION_STATE_CLOSE | SESSION_STATE_PENDING;
|
||||
else
|
||||
state = SESSION_STATE_PENDING;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(QUIC_TRUE==(a_quic_stream)->fin_flag)
|
||||
{
|
||||
state = SESSION_STATE_CLOSE;
|
||||
}
|
||||
else
|
||||
state = SESSION_STATE_DATA;
|
||||
}
|
||||
(a_quic_stream)->link_state = QUIC_TRUE;
|
||||
return state;
|
||||
}
|
||||
|
||||
UCHAR quic_doWithInsterestedRegion(struct streaminfo *pstream)
|
||||
{
|
||||
/*ҵ<><D2B5><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>*/
|
||||
if(g_quic_param.quic_interested_region_flag < QUIC_KEY){
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
return QUIC_RETURN_NORM;
|
||||
}/*ssl_doWithInsterestedRegion*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user