|
|
|
@@ -12,7 +12,6 @@
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <linux/socket.h>
|
|
|
|
#include <linux/socket.h>
|
|
|
|
//#include <linux/tcp.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
@@ -32,12 +31,13 @@
|
|
|
|
#include "kni.h"
|
|
|
|
#include "kni.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int g_kni_version_VERSION_20180710_2;
|
|
|
|
int g_kni_version_VERSION_20180711_3;
|
|
|
|
|
|
|
|
|
|
|
|
struct kni_var_comm g_kni_comminfo;
|
|
|
|
struct kni_var_comm g_kni_comminfo;
|
|
|
|
struct kni_var_struct g_kni_structinfo;
|
|
|
|
struct kni_var_struct g_kni_structinfo;
|
|
|
|
struct kni_var_maat g_kni_maatinfo;
|
|
|
|
struct kni_var_maat g_kni_maatinfo;
|
|
|
|
struct kni_fs2_info g_kni_fs2_info;
|
|
|
|
struct kni_fs2_info g_kni_fs2_info;
|
|
|
|
|
|
|
|
struct kni_switch_info g_kni_switch_info;
|
|
|
|
|
|
|
|
|
|
|
|
int g_kni_threadseq[KNI_MAX_THREADNUM];
|
|
|
|
int g_kni_threadseq[KNI_MAX_THREADNUM];
|
|
|
|
const char *g_kni_fs2_name[FS2_COLUMN_NUM] ={"RECV_PKTS","FWD_PKTS","DROP_PKTS","WRITE_PKTS","READ_PKTS","SEND_PKTS"};
|
|
|
|
const char *g_kni_fs2_name[FS2_COLUMN_NUM] ={"RECV_PKTS","FWD_PKTS","DROP_PKTS","WRITE_PKTS","READ_PKTS","SEND_PKTS"};
|
|
|
|
@@ -1124,19 +1124,25 @@ not kni_bmd:STAT_FLAG_SSL_NOBMD
|
|
|
|
***************************************************************************************/
|
|
|
|
***************************************************************************************/
|
|
|
|
int kni_judge_sni(char* sni,int sni_len,int thread_seq)
|
|
|
|
int kni_judge_sni(char* sni,int sni_len,int thread_seq)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int action=KNI_ACTION_NONE;
|
|
|
|
int state_flag=KNI_FLAG_SSL;
|
|
|
|
int state_flag=KNI_FLAG_SSL;
|
|
|
|
|
|
|
|
|
|
|
|
int string_scan_num=0;
|
|
|
|
int string_scan_num=0;
|
|
|
|
int found_pos;
|
|
|
|
int found_pos;
|
|
|
|
scan_status_t mid=NULL;
|
|
|
|
scan_status_t mid=NULL;
|
|
|
|
struct Maat_rule_t maat_result[KNI_MAX_CFGNUM];
|
|
|
|
struct Maat_rule_t maat_result;
|
|
|
|
|
|
|
|
|
|
|
|
string_scan_num=Maat_full_scan_string(g_kni_maatinfo.maat_feather,g_kni_maatinfo.tableid_snibmd,CHARSET_GBK,sni,sni_len,maat_result,&found_pos,KNI_MAX_CFGNUM,&mid,thread_seq);
|
|
|
|
string_scan_num=Maat_full_scan_string(g_kni_maatinfo.maat_feather,g_kni_maatinfo.tableid_domain,CHARSET_GBK,sni,sni_len,&maat_result,&found_pos,1,&mid,thread_seq);
|
|
|
|
Maat_clean_status(&mid);
|
|
|
|
Maat_clean_status(&mid);
|
|
|
|
|
|
|
|
|
|
|
|
if(string_scan_num>0)
|
|
|
|
if(string_scan_num>0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
state_flag=KNI_FLAG_SNIBMD;
|
|
|
|
action=abs(maat_result.action);
|
|
|
|
|
|
|
|
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_FATAL,(char*)"kni_judge_sni","action:%d",action);
|
|
|
|
|
|
|
|
if((action==KNI_ACTION_WHITELIST)||((action!=KNI_ACTION_REJECT)&&(g_kni_switch_info.maat_default_switch==0)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
state_flag=KNI_FLAG_SNIBMD;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return state_flag;
|
|
|
|
return state_flag;
|
|
|
|
@@ -1151,7 +1157,7 @@ not ssl:STAT_FLAG_NOTSSL
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
int kni_judge_ssl_bak(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
int kni_judge_ssl_bak(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// int state_flag=KNI_FLAG_SSL_HALF;
|
|
|
|
// int state_flag=KNI_FLAG_UNKNOW;
|
|
|
|
// return STAT_FLAG_SSL_NOBMD;
|
|
|
|
// return STAT_FLAG_SSL_NOBMD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1287,27 +1293,26 @@ int kni_judge_ssl_bak(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************************
|
|
|
|
/***************************************************************************************
|
|
|
|
return :state_flag
|
|
|
|
return :action
|
|
|
|
ipbmd:STAT_FLAG_IPBMD
|
|
|
|
default:ipscan_num =0 or =1,not >1
|
|
|
|
not ipbmd:STAT_FLAG_NONE
|
|
|
|
|
|
|
|
***************************************************************************************/
|
|
|
|
***************************************************************************************/
|
|
|
|
int kni_judge_ipbmd(struct ipaddr* addr,int thread_seq,int protocol)
|
|
|
|
int kni_judge_ipbmd(struct ipaddr* addr,int thread_seq,int protocol)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int state_flag=KNI_FLAG_UNKNOW;
|
|
|
|
int action=KNI_ACTION_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
int ipscan_num=0;
|
|
|
|
int ipscan_num=0;
|
|
|
|
scan_status_t mid=NULL;
|
|
|
|
scan_status_t mid=NULL;
|
|
|
|
struct Maat_rule_t maat_result[KNI_MAX_CFGNUM];
|
|
|
|
struct Maat_rule_t maat_result;
|
|
|
|
|
|
|
|
|
|
|
|
ipscan_num=Maat_scan_proto_addr(g_kni_maatinfo.maat_feather,g_kni_maatinfo.tableid_ipbmd,addr,protocol,maat_result,KNI_MAX_CFGNUM,&mid,thread_seq);
|
|
|
|
ipscan_num=Maat_scan_proto_addr(g_kni_maatinfo.maat_feather,g_kni_maatinfo.tableid_ip,addr,protocol,&maat_result,1,&mid,thread_seq);
|
|
|
|
Maat_clean_status(&mid);
|
|
|
|
Maat_clean_status(&mid);
|
|
|
|
|
|
|
|
|
|
|
|
if(ipscan_num>0)
|
|
|
|
if(ipscan_num>0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
state_flag=KNI_FLAG_IPBMD;
|
|
|
|
action=abs(maat_result.action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return state_flag;
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int kni_get_tcpinfo(struct kni_wndpro_reply_info* lastpkt_info,struct kni_tcp_hdr* tcphdr,int tcplen,struct ip* ip_hdr)
|
|
|
|
int kni_get_tcpinfo(struct kni_wndpro_reply_info* lastpkt_info,struct kni_tcp_hdr* tcphdr,int tcplen,struct ip* ip_hdr)
|
|
|
|
@@ -1389,8 +1394,10 @@ int kni_get_tcpopt(struct kni_tcp_hdr* tcphdr,int tcp_hdr_len,unsigned short* ms
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int kni_get_data(const struct streaminfo* pstream,char* data,int* datalen)
|
|
|
|
char* kni_get_data(const struct streaminfo* pstream,int* datalen)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
char* data=NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if(pstream->type==STREAM_TYPE_TCP)
|
|
|
|
if(pstream->type==STREAM_TYPE_TCP)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data=(char*)(pstream->ptcpdetail->pdata);
|
|
|
|
data=(char*)(pstream->ptcpdetail->pdata);
|
|
|
|
@@ -1407,7 +1414,7 @@ int kni_get_data(const struct streaminfo* pstream,char* data,int* datalen)
|
|
|
|
*datalen=0;
|
|
|
|
*datalen=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1457,7 +1464,7 @@ not ssl:STAT_FLAG_NOTSSL
|
|
|
|
***************************************************************************************/
|
|
|
|
***************************************************************************************/
|
|
|
|
int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// int state_flag=KNI_FLAG_SSL_HALF;
|
|
|
|
// int state_flag=KNI_FLAG_UNKNOW;
|
|
|
|
// return KNI_FLAG_SSL;
|
|
|
|
// return KNI_FLAG_SSL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1490,21 +1497,21 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
content_type=*(unsigned char*)&ssl_header[ssl_header_len];
|
|
|
|
content_type=*(unsigned char*)&ssl_header[ssl_header_len];
|
|
|
|
if(content_type!=SSL_CONTENTTYPE_HANDSHAKE)
|
|
|
|
if(content_type!=SSL_CONTENTTYPE_HANDSHAKE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ssl_header_len+=1;
|
|
|
|
ssl_header_len+=1;
|
|
|
|
|
|
|
|
|
|
|
|
version_in_header=ntohs(*(unsigned short*)&(ssl_header[ssl_header_len]));
|
|
|
|
version_in_header=ntohs(*(unsigned short*)&(ssl_header[ssl_header_len]));
|
|
|
|
if((version_in_header!=SSL_VERSION_TLS1_0)&&(version_in_header!=SSL_VERSION_TLS1_1)&&(version_in_header!=SSL_VERSION_TLS1_2))
|
|
|
|
if((version_in_header!=SSL_VERSION_TLS1_0)&&(version_in_header!=SSL_VERSION_TLS1_1)&&(version_in_header!=SSL_VERSION_TLS1_2))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ssl_header_len+=2;
|
|
|
|
ssl_header_len+=2;
|
|
|
|
|
|
|
|
|
|
|
|
len_in_header=ntohs(*(unsigned short*)&(ssl_header[ssl_header_len]));
|
|
|
|
len_in_header=ntohs(*(unsigned short*)&(ssl_header[ssl_header_len]));
|
|
|
|
if(len_in_header!=tcp_datalen-SSL_HEADER_LEN)
|
|
|
|
if(len_in_header!=tcp_datalen-SSL_HEADER_LEN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ssl_header_len+=2;
|
|
|
|
ssl_header_len+=2;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1514,7 +1521,7 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
handshark_type=*(unsigned char*)&(ssl_body[ssl_body_len]);
|
|
|
|
handshark_type=*(unsigned char*)&(ssl_body[ssl_body_len]);
|
|
|
|
if(handshark_type!=SSL_HANDSHAR_TYPE_CLIENTHELLO)
|
|
|
|
if(handshark_type!=SSL_HANDSHAR_TYPE_CLIENTHELLO)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ssl_body_len+=1;
|
|
|
|
ssl_body_len+=1;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1522,7 +1529,7 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
len_in_body=*(unsigned char*)&ssl_body[ssl_body_len+2]+256*(*(unsigned char*)&ssl_body[ssl_body_len+1])+65536*(*(unsigned char*)&ssl_body[ssl_body_len]);
|
|
|
|
len_in_body=*(unsigned char*)&ssl_body[ssl_body_len+2]+256*(*(unsigned char*)&ssl_body[ssl_body_len+1])+65536*(*(unsigned char*)&ssl_body[ssl_body_len]);
|
|
|
|
if(len_in_body!=(len_in_header-SSL_BODY_LEN))
|
|
|
|
if(len_in_body!=(len_in_header-SSL_BODY_LEN))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ssl_body_len+=3;
|
|
|
|
ssl_body_len+=3;
|
|
|
|
@@ -1530,7 +1537,7 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
version_in_body=ntohs(*(unsigned short*)&(ssl_body[ssl_body_len]));
|
|
|
|
version_in_body=ntohs(*(unsigned short*)&(ssl_body[ssl_body_len]));
|
|
|
|
if((version_in_body!=SSL_VERSION_TLS1_0)&&(version_in_body!=SSL_VERSION_TLS1_1)&&(version_in_body!=SSL_VERSION_TLS1_2))
|
|
|
|
if((version_in_body!=SSL_VERSION_TLS1_0)&&(version_in_body!=SSL_VERSION_TLS1_1)&&(version_in_body!=SSL_VERSION_TLS1_2))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ssl_body_len+=2;
|
|
|
|
ssl_body_len+=2;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1554,7 +1561,7 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
extension_len_less=ntohs(*(unsigned short*)&ssl_extention[ssl_extention_len]);
|
|
|
|
extension_len_less=ntohs(*(unsigned short*)&ssl_extention[ssl_extention_len]);
|
|
|
|
if(extension_len_less!=len_in_body-2-32-1-session_id_len-2-ciphersuite_len-1-compression_method_len-2)
|
|
|
|
if(extension_len_less!=len_in_body-2-32-1-session_id_len-2-ciphersuite_len-1-compression_method_len-2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ssl_extention_len+=2;
|
|
|
|
ssl_extention_len+=2;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1571,7 +1578,7 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
if(len_in_extension>KNI_SNI_MAXLEN)
|
|
|
|
if(len_in_extension>KNI_SNI_MAXLEN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//error
|
|
|
|
//error
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(sni,&ssl_extention[ssl_extention_len],len_in_extension);
|
|
|
|
memcpy(sni,&ssl_extention[ssl_extention_len],len_in_extension);
|
|
|
|
@@ -1587,7 +1594,7 @@ int kni_judge_ssl(char* tcp_data,int tcp_datalen,char* sni,int* sni_len)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return KNI_FLAG_SSL_HALF;
|
|
|
|
return KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int kni_judge_http(const struct streaminfo *stream)
|
|
|
|
int kni_judge_http(const struct streaminfo *stream)
|
|
|
|
@@ -1624,7 +1631,7 @@ int kni_protocol_identify_bak(const struct streaminfo* pstream,const struct ip*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((sport==443)||(dport==443))
|
|
|
|
else if((sport==443)||(dport==443))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pro_flag=KNI_FLAG_SSL_HALF;
|
|
|
|
pro_flag=KNI_FLAG_UNKNOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1640,22 +1647,14 @@ char kni_first_tcpdata(const struct streaminfo* pstream,const struct ip* ip_hdr,
|
|
|
|
char sni[KNI_MAX_BUFLEN]={0};
|
|
|
|
char sni[KNI_MAX_BUFLEN]={0};
|
|
|
|
|
|
|
|
|
|
|
|
pmeinfo->status_flag=kni_protocol_identify(pstream,data,datalen,sni,&sni_len);
|
|
|
|
pmeinfo->status_flag=kni_protocol_identify(pstream,data,datalen,sni,&sni_len);
|
|
|
|
|
|
|
|
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_DEBUG,(char*)"kni_protocol_identify","protocol:%d",pmeinfo->status_flag);
|
|
|
|
|
|
|
|
|
|
|
|
if(pmeinfo->status_flag==KNI_FLAG_SSL)
|
|
|
|
if(pmeinfo->status_flag==KNI_FLAG_SSL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pmeinfo->status_flag=kni_judge_sni(sni,sni_len,pstream->threadnum);
|
|
|
|
pmeinfo->status_flag=kni_judge_sni(sni,sni_len,pstream->threadnum);
|
|
|
|
|
|
|
|
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_DEBUG,(char*)"kni_judge_sni","status_flag:%d",pmeinfo->status_flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if(pmeinfo->status_flag==KNI_FLAG_SSL_HALF)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pmeinfo->status_flag=kni_judge_ssl(data,datalen,sni,&sni_len); //has kni:SSL_HALF;no kni:NOT_PROC
|
|
|
|
|
|
|
|
if(pmeinfo->status_flag==KNI_FLAG_SSL_HALF)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pmeinfo->status_flag=kni_judge_sni(sni,sni_len,pstream->threadnum); //SNI_BMD:NOT_PROC;or SSL
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if((pmeinfo->status_flag==KNI_FLAG_HTTP) ||(pmeinfo->status_flag==KNI_FLAG_SSL))
|
|
|
|
if((pmeinfo->status_flag==KNI_FLAG_HTTP) ||(pmeinfo->status_flag==KNI_FLAG_SSL))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1687,12 +1686,12 @@ char kni_pending_opstate(const struct streaminfo* pstream,void** pme,int thread_
|
|
|
|
struct kni_tcp_hdr* tcphdr=(struct kni_tcp_hdr*)((char*)ip_hdr+4*(ip_hdr->ip_hl));
|
|
|
|
struct kni_tcp_hdr* tcphdr=(struct kni_tcp_hdr*)((char*)ip_hdr+4*(ip_hdr->ip_hl));
|
|
|
|
|
|
|
|
|
|
|
|
ipscan_action=kni_judge_ipbmd((struct ipaddr*)&(pstream->addr),thread_seq,protocol);
|
|
|
|
ipscan_action=kni_judge_ipbmd((struct ipaddr*)&(pstream->addr),thread_seq,protocol);
|
|
|
|
if(ipscan_action==KNI_ACTION_IPBMD)
|
|
|
|
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_DEBUG,(char*)"kni_judge_ipbmd","action:%d",ipscan_action);
|
|
|
|
|
|
|
|
if((ipscan_action==KNI_ACTION_WHITELIST)||((ipscan_action!=KNI_ACTION_REJECT)&&(g_kni_switch_info.maat_default_switch==0)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pmeinfo=(struct kni_pme_info*)malloc(sizeof(struct kni_pme_info));
|
|
|
|
pmeinfo=(struct kni_pme_info*)malloc(sizeof(struct kni_pme_info));
|
|
|
|
memset(pmeinfo,0,sizeof(struct kni_pme_info));
|
|
|
|
memset(pmeinfo,0,sizeof(struct kni_pme_info));
|
|
|
|
*pme=pmeinfo;
|
|
|
|
*pme=pmeinfo;
|
|
|
|
@@ -1701,7 +1700,7 @@ char kni_pending_opstate(const struct streaminfo* pstream,void** pme,int thread_
|
|
|
|
// pmeinfo->wndsize[pstream->curdir-1]=ntohs(tcphdr->th_win);
|
|
|
|
// pmeinfo->wndsize[pstream->curdir-1]=ntohs(tcphdr->th_win);
|
|
|
|
// if((tcphdr->th_flags&TH_SYN)&&!(tcphdr->th_flags&TH_ACK)) //get wndscale and mss from tcpopt only in syn and syn/ack
|
|
|
|
// if((tcphdr->th_flags&TH_SYN)&&!(tcphdr->th_flags&TH_ACK)) //get wndscale and mss from tcpopt only in syn and syn/ack
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kni_get_data(pstream,data,&datalen);
|
|
|
|
data=kni_get_data(pstream,&datalen);
|
|
|
|
kni_get_tcpopt(tcphdr,iplen-4*(ip_hdr->ip_hl)-datalen,&(pmeinfo->mss[pstream->curdir-1]),&(pmeinfo->wnscal[pstream->curdir-1]),&(pmeinfo->sack[pstream->curdir-1]),&(pmeinfo->timestamps[pstream->curdir-1]));
|
|
|
|
kni_get_tcpopt(tcphdr,iplen-4*(ip_hdr->ip_hl)-datalen,&(pmeinfo->mss[pstream->curdir-1]),&(pmeinfo->wnscal[pstream->curdir-1]),&(pmeinfo->sack[pstream->curdir-1]),&(pmeinfo->timestamps[pstream->curdir-1]));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1741,7 +1740,7 @@ char kni_data_opstate(const struct streaminfo* pstream,void** pme,int thread_seq
|
|
|
|
struct kni_pme_info* pmeinfo=(struct kni_pme_info*)*pme;
|
|
|
|
struct kni_pme_info* pmeinfo=(struct kni_pme_info*)*pme;
|
|
|
|
struct kni_tcp_hdr* tcphdr=(struct kni_tcp_hdr*)((char*)ip_hdr+4*(ip_hdr->ip_hl));
|
|
|
|
struct kni_tcp_hdr* tcphdr=(struct kni_tcp_hdr*)((char*)ip_hdr+4*(ip_hdr->ip_hl));
|
|
|
|
|
|
|
|
|
|
|
|
kni_get_data(pstream,data,&datalen);
|
|
|
|
data=kni_get_data(pstream,&datalen);
|
|
|
|
|
|
|
|
|
|
|
|
if(pmeinfo->status_flag==KNI_FLAG_UNKNOW)
|
|
|
|
if(pmeinfo->status_flag==KNI_FLAG_UNKNOW)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1852,7 +1851,7 @@ long kni_state_htable_cb_v6(void* data,const unsigned char* key,unsigned int siz
|
|
|
|
return datainfo->state_flag;
|
|
|
|
return datainfo->state_flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
char kni_ipv6_entry(struct streaminfo *pstream,unsigned char routedir,int thread_seq,void *a_packet)
|
|
|
|
char kni_ipv6_entry(struct streaminfo *pstream,unsigned char routedir,int thread_seq,void *a_packet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ip_reverse=0;
|
|
|
|
int ip_reverse=0;
|
|
|
|
@@ -1895,7 +1894,7 @@ char kni_ipv6_entry(struct streaminfo *pstream,unsigned char routedir,int thread
|
|
|
|
return APP_STATE_DROPPKT;
|
|
|
|
return APP_STATE_DROPPKT;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
extern "C" char kni_http_entry(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,const void *a_packet)
|
|
|
|
extern "C" char kni_http_entry(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,const void *a_packet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char ret=PROT_STATE_DROPME;
|
|
|
|
char ret=PROT_STATE_DROPME;
|
|
|
|
@@ -1913,7 +1912,7 @@ int init_profile_info(int* logger_level,char* logger_filepath,int* maat_json_swi
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"thread_num",&(g_kni_comminfo.thread_num),1);
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"thread_num",&(g_kni_comminfo.thread_num),1);
|
|
|
|
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"default_switch",&(g_kni_switch_info.maat_default_switch),1);
|
|
|
|
|
|
|
|
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"logger_level",logger_level,RLOG_LV_INFO);
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"logger_level",logger_level,RLOG_LV_INFO);
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"maat_json_switch",maat_json_switch,0);
|
|
|
|
MESA_load_profile_int_def((char*)KNI_CONF_FILENAME,(char*)KNI_CONF_MODE,(char*)"maat_json_switch",maat_json_switch,0);
|
|
|
|
@@ -1960,6 +1959,7 @@ int init_kni_stat_htable()
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" char kni_init()
|
|
|
|
extern "C" char kni_init()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
int i=0;
|
|
|
|
int ret=0;
|
|
|
|
int ret=0;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2034,11 +2034,11 @@ extern "C" char kni_init()
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_kni_maatinfo.tableid_ipbmd=Maat_table_register(g_kni_maatinfo.maat_feather,KNI_TABLENAME_IPBMD);
|
|
|
|
g_kni_maatinfo.tableid_ip=Maat_table_register(g_kni_maatinfo.maat_feather,KNI_TABLENAME_IP);
|
|
|
|
g_kni_maatinfo.tableid_snibmd=Maat_table_register(g_kni_maatinfo.maat_feather,KNI_TABLENAME_SNIBMD);
|
|
|
|
g_kni_maatinfo.tableid_domain=Maat_table_register(g_kni_maatinfo.maat_feather,KNI_TABLENAME_DOMAIN);
|
|
|
|
if((g_kni_maatinfo.tableid_ipbmd<0)||(g_kni_maatinfo.tableid_snibmd<0))
|
|
|
|
if((g_kni_maatinfo.tableid_ip<0)||(g_kni_maatinfo.tableid_domain<0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_FATAL,KNI_MODULE_INIT,"Maat_table_register() error!ip_tableid:%d,sni_tableid:%d,action:%s",g_kni_maatinfo.tableid_ipbmd,g_kni_maatinfo.tableid_snibmd,KNI_ACTION_EXIT);
|
|
|
|
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_FATAL,KNI_MODULE_INIT,"Maat_table_register() error!ip_tableid:%d,sni_tableid:%d,action:%s",g_kni_maatinfo.tableid_ip,g_kni_maatinfo.tableid_domain,KNI_ACTION_EXIT);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|