提供新协议识别函数quic_protocol_identify,对外屏蔽细节
错误返回业务层的状态,导致丢包不成功
This commit is contained in:
@@ -613,21 +613,21 @@ int gquic_frame_type_stream(struct streaminfo *pstream, struct _quic_context* _c
|
||||
switch(message_tag)
|
||||
{
|
||||
case CHLO: //MTAG_CHLO;
|
||||
ret=parse_extension_tag(pstream, &_context->quic_info.client_hello, a_packet, payload, payload_len, used_len, tag_num);
|
||||
ret=parse_extension_tag(pstream, &(_context->quic_info.client_hello), a_packet, payload, payload_len, used_len, tag_num);
|
||||
if(ret>=0 && _context->call_business)
|
||||
{
|
||||
ret=quic_callPlugins(pstream, _context, (void *)(_context->quic_info.client_hello), sizeof(void *), QUIC_CLIENT_HELLO_MASK, a_packet);
|
||||
}
|
||||
break;
|
||||
case SHLO: //MTAG_SHLO;
|
||||
ret=parse_extension_tag(pstream, &_context->quic_info.server_hello, a_packet, payload, payload_len, used_len, tag_num);
|
||||
ret=parse_extension_tag(pstream, &(_context->quic_info.server_hello), a_packet, payload, payload_len, used_len, tag_num);
|
||||
if(ret>=0 && _context->call_business)
|
||||
{
|
||||
ret=quic_callPlugins(pstream, _context, (void *)(_context->quic_info.server_hello), sizeof(void *), QUIC_SERVER_HELLO_MASK, a_packet);
|
||||
}
|
||||
break;
|
||||
case REJ: //MTAG_REJ;
|
||||
ret=parse_extension_tag(pstream, &_context->quic_info.rejection, a_packet, payload, payload_len, used_len, tag_num);
|
||||
ret=parse_extension_tag(pstream, &(_context->quic_info.rejection), a_packet, payload, payload_len, used_len, tag_num);
|
||||
if(ret>=0 && _context->call_business)
|
||||
{
|
||||
ret=quic_callPlugins(pstream, _context, (void *)(_context->quic_info.rejection), sizeof(void *), QUIC_REJECTION_MASK, a_packet);
|
||||
@@ -637,7 +637,7 @@ int gquic_frame_type_stream(struct streaminfo *pstream, struct _quic_context* _c
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret>=0) ? ret : APP_STATE_GIVEME;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//frame type->stream->offset->data length
|
||||
@@ -796,6 +796,7 @@ int gquic_proc_unencrypt(struct streaminfo *pstream, struct _quic_context* _cont
|
||||
//QUIC_DATA:is quic data pcap;QUIC_TRUE:is handshake pcap;QUIC_RETURN_DROPME:not quic protocol;
|
||||
int parse_gquic_Q046(struct streaminfo *pstream, struct _quic_context* _context, void *a_packet, char * payload, int payload_len, int *used_len)
|
||||
{
|
||||
int ret=APP_STATE_GIVEME;
|
||||
unsigned char frame_type;
|
||||
unsigned short tag_num=0;
|
||||
unsigned int stream_id, message_tag;
|
||||
@@ -807,15 +808,20 @@ int parse_gquic_Q046(struct streaminfo *pstream, struct _quic_context* _context,
|
||||
|
||||
if(frame_type&IQUIC_FRAME_STREAM_HEX08)
|
||||
{
|
||||
gquic_frame_type_stream(pstream, _context, payload, payload_len, used_len, frame_type, a_packet);
|
||||
ret=gquic_frame_type_stream(pstream, _context, payload, payload_len, used_len, frame_type, a_packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0; //todo
|
||||
}
|
||||
|
||||
if(ret&APP_STATE_DROPME || ret&APP_STATE_DROPPKT)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return QUIC_RETURN_NORM;
|
||||
return APP_STATE_GIVEME;
|
||||
}
|
||||
|
||||
//cid->version->nounce->pkt num->ahn hash(12)
|
||||
@@ -854,6 +860,11 @@ int quic_process(struct streaminfo *pstream, struct _quic_context* _context, int
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(ret&APP_STATE_DROPME | ret&APP_STATE_DROPPKT)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if(_context->is_quic==TRUE)
|
||||
@@ -873,3 +884,31 @@ int quic_process(struct streaminfo *pstream, struct _quic_context* _context, int
|
||||
return APP_STATE_DROPME;;
|
||||
}
|
||||
|
||||
|
||||
int quic_protocol_identify(struct streaminfo *a_stream, void *a_packet, char *out_sni, int out_sni_len)
|
||||
{
|
||||
int ret=APP_STATE_GIVEME;
|
||||
int sni_len=0,len=0;
|
||||
void *pme=NULL;
|
||||
char *sni=NULL;
|
||||
struct _quic_context *_context=NULL;
|
||||
|
||||
quic_init_stream(&pme, a_stream->threadnum);
|
||||
_context=(struct _quic_context *)pme;
|
||||
|
||||
ret=quic_process(a_stream, _context, a_stream->threadnum, a_packet);
|
||||
if(ret!=PROT_STATE_DROPME)
|
||||
{
|
||||
if(_context->quic_info.client_hello!=NULL)
|
||||
{
|
||||
sni=(char *)(_context->quic_info.client_hello->ext_tags[_context->quic_info.client_hello->sni_idx].value);
|
||||
sni_len=_context->quic_info.client_hello->ext_tags[_context->quic_info.client_hello->sni_idx].length;
|
||||
len= sni_len>(out_sni_len-1) ? (out_sni_len-1) : sni_len;
|
||||
memcpy(out_sni, sni, len);
|
||||
}
|
||||
}
|
||||
|
||||
quic_release_stream(&pme, a_stream->threadnum);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user