亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? probe_main.c

?? LInux BootLoader的說明文檔
?? C
字號:
#include "probe_main.h"
#include "queue.h"
#include "node_operate.h"
#include "http.h"
#include "inet.h"
//#include "include/pcap.h"
#include <pcap.h>
pthread_mutex_t print_m;
u_int32_t print_num = 0;
u_int32_t free_num = 0;
u_int32_t out_buf = 0 ;
u_int32_t total = 0;

#define RULE "action (store and sample) ((port 80 or port 21 or port 8080 or port 4430 or port 4510 or port 4200 or port 1201 or port 8000\
or port 53 or port 443 or port 5190 or port 143 or port 5559 or port 7200 or port 1863 or port 1521 or port 110 or port 25 or port 1433\
or port 23 or port 3724 or port 5200 or port 5050 or port 5101 or port 9090 or port 5631 or port 5632 or port 2000 or port 2002) and tcp)\
 or ((port 1511 or port 9191 or port 1813) and udp)"

void *probe_capture(probe_all_t  *all_info)
{
	int i = 0;
	int res = 0;
	pcap_t *pd;
	char		errbuf[PCAP_ERRBUF_SIZE];
	struct pcap_pkthdr  bh;
	const  u_char	*packet = NULL;
	struct bpf_program *program;

	
	if((pd = pcap_open_live( "eth1", 1518, 1, 1000, errbuf)) == NULL)
	{
		printf("pcap_open_live: %s\n", errbuf);
		exit(0);
	}

	while(all_info->pthread[i] != NULL)
	{
		all_info->pthread[i]->pd = pd;
		i++;
	}

	//combrio_delflag(pcap_t * p, unsigned int headerType);


	if(pcap_compile( pd, &program, RULE, 0,  0) < 0)
	{
		printf("pcap_compile is error, exit the program \n");
		exit(0);
	}

	if( pcap_setfilter( pd, &program) < 0 )
	{
		printf("pcap_setfilter is error, exit the program \n");
		exit(0);
	}
	
	for(;;)
	{
	//	printf("total   %d   \n" , total);
	//	pthread_mutex_lock(&print_m);
	//	printf("out buffer  %d \n" , out_buf);
	//	pthread_mutex_unlock(&print_m);
		
	//	printf("in free  %d \n" , free_num);
	//	printf("in buffer  %d \n" , print_num);
		
		packet = pcap_next(pd, &bh );	/* Get next packet */
		if(packet == NULL || res < 0)
		{
			continue;					/* 有可能出現 */
		}
	//	printf("pcap_next\n\n");

		//packet_dispatch(all_info->pthread,  all_info->port , packet , bh.len, bh.ts.tv_sec , bh.handle);    /*數據報分發*/
		packet_dispatch(all_info->pthread, all_info->port, packet, bh.len, bh.ts.tv_sec, bh.handle);
	}

	pcap_close(pd);
	return;
}

/*
int comm_connect_admin(pthread_infor_t  *pthread)
{
	packet_t * packet = NULL;
	connect_node_head hash_table[MB];
	connect_node * node = NULL;
	void * module_pt = NULL;
	u_int8_t direct = 0;
	u_int8_t ret = 0; 
	
	while(1)
	{	
		packet = pbuffer_get_packet( &(pthread->pbuf) );
		if(packet != NULL)
		{
			printf(" ######  %d    %d   ####   %s  ###  \n" , packet->dport, packet->sport, pthread->name);
			
			node = compare_node( hash_table,  packet);
			if(node == NULL)
			{
				if(insert_node(hash_table, packet) == -1)
				{
					free(packet);
					continue;
				}
			}

			if(node->sport == packet->sport) 
				direct = 0;
			else 
				direct = 1;
			
			if(node->state == UNCONFIRM)
			{
				if((ret = pthread->functions.judge(pthread , module_pt , node , packet , direct)) == NEEDED)
					node->state = CONFIRM;
				else if( ret == UNNEEDED)
				{
					node->state = UNNEEDED;
				}
				else
				{
					if((node->counter ++) > MAX_COMPARE)
						node->state = UNNEEDED;
				}
			}
			else if(node->state == CONFIRM && packet->app_len > 0)
			{
				pthread->functions.audit_packet(pthread , module_pt , node , packet,  direct);
			}

			if(packet->protocol_type == TCP && ( TCP_FLAG_FIN(packet->trans_data) ||TCP_FLAG_RST(packet->trans_data)) )
			{
				pthread->functions.connect_destroy( pthread , module_pt , node );
				remove_node(hash_table, node, packet);
			}
		
			free(packet);
		}
	}
	return -1;
}


int consult_connect_admin(pthread_infor_t  *pthread)
{
	packet_t * packet = NULL;
	connect_node * consult_node = NULL;
	connect_node * node = NULL;
	void * module_pt = NULL;
	u_int8_t direct = 0;
	u_int8_t ret = 0; 
	
	connect_node_head consult_hash_table[4096];
	connect_node_head hash_table[MB];
	
	
	while(1)
	{	
		packet = pbuffer_get_packet( &(pthread->pbuf) );
		if(packet != NULL)
		{
			printf(" ######  %d    %d   ####   %s  ###  \n" , packet->dport, packet->sport, pthread->name);

			
			
			node = compare_node( hash_table,  packet);
			if(node == NULL)
			{
				if(insert_node(hash_table, packet) == -1)
				{
					free(packet);
					continue;
				}
			}

			direct = (node->sport == packet->sport) ? 0:1;
			if(node->state == UNCONFIRM)
			{
				if((ret = pthread->functions.judge(pthread , module_pt , node , packet , direct)) == NEEDED)
					node->state = CONFIRM;
				else if( ret == UNNEEDED)
				{
					node->state = UNNEEDED;
				}
				else
				{
					if((node->counter ++) > MAX_COMPARE)
						node->state = UNNEEDED;
				}
			}
			else if(node->state == CONFIRM && packet->app_len > 0)
			{
				pthread->functions.audit_packet(pthread , module_pt , node , packet,  direct);
			}

			if(packet->protocol_type == TCP && ( TCP_FLAG_FIN(packet->trans_data) ||TCP_FLAG_RST(packet->trans_data)) )
			{
				pthread->functions.connect_destroy( pthread , module_pt , node );
				remove_node(hash_table, node, packet);
			}
		
			free(packet);
		}
	}
	return -1;
}
*/
void function( pthread_infor_t  *pthread )
{
	packet_t * packet = NULL;
	//connect_node_head hash_table[MB];
	connect_node * node = NULL;
	void * module_pt = NULL;
	u_int8_t direct = 0;
	u_int8_t ret = 0; 
//	printf("+++++++++   %s   %x    ++++++++++++\n" , pthread->name ,hash_table);
//	memset(hash_table , 0 , MB * sizeof(connect_node_head));
	int i = 0;
/*	for(i = 0 ; i < MB ; i ++)
	{
		if(hash_table[i].first != NULL || hash_table[i].tail != NULL)
			printf("NO NONONNONONNOONONONONONONONOONONONONONO\n\n");
	}*/
	module_pt  = pthread->functions.init();
	while(1)
	{	
		ret = kfifo_get( pthread->fifo, &packet, 4) ;
		if(packet != NULL)
		{
		//	printf(" ######  %d    %d   ####   %s  ###  \n" , packet->dport, packet->sport, pthread->name);
			
		//	node = compare_node( hash_table,  packet);
		//	if(node == NULL)
		//	{
		//		if((node = insert_node(hash_table, packet)) == NULL)
		//		{
		//			free(packet);
		//			continue;
		//		}
		//	}

			direct = (node->sport == packet->sport) ? 0:1;
			
		//	if(node->state == UNCONFIRM)
		//	{
				if((ret = pthread->functions.judge(pthread , module_pt , node , packet , direct)) == NEEDED)
		//			node->state = CONFIRM;
		//		else if( ret == UNNEEDED)
		//		{
		//			node->state = UNNEEDED;
		//		}
		//		else
		//		{
		//			if((node->counter ++) > MAX_COMPARE)
		//				node->state = UNNEEDED;
		//		}
		//	}
		//	else if(node->state == CONFIRM && packet->app_len > 0)
		//	{
				pthread->functions.audit_packet(pthread , module_pt , node , packet,  direct);
		//	}

		//	if(packet->protocol_type == TCP && ( TCP_FLAG_FIN(packet->trans_data) ||TCP_FLAG_RST(packet->trans_data)) )
		//	{
				pthread->functions.connect_destroy( pthread , module_pt , node );
			//	remove_node(hash_table, node, packet);
		//	}


			
			free(packet);
			packet = NULL;
		}
		else
			usleep(10);
	//	pthread_mutex_lock(&print_m);
	//	out_buf ++;
//		pthread_mutex_unlock(&print_m);
		//printf("  buffer          %d        \n  " , print_num);
	
	}	
	return ;
}


int startup_pthread( pthread_infor_t  *pthread[] )
{
	int i = 0;
	int ret = 0;
	while(pthread[i] != NULL)
	{
		ret = pthread_create(&(pthread[i]->tid) , NULL, function, pthread[i]);
		printf("******  %d  ****** %u ***\n", ret , pthread[i]->tid);
		i ++;
	}

	return 0;
}


int register_port_func(pthread_infor_t  *pthread[] , port_array_t  *port_a)
{
	int i = 0;
	int j = 0;
	int n = 0;

	int m= 0;
	for(m = 0 ; m < 17 ; m ++)
	{	
		printf("QQQQQQQQQQ  %d  DDDDDDDDDD\n\n" , (*(pthread+m))->port[0]);
	}
	memset(port_a , 0 , 65535*sizeof(port_array_t))	;
	while( pthread[i] != NULL)
	{
//for( n=0; n<1000 ; n ++)
//	printf("########  %x   #########\n\n" ,port[n] );
//	for(j= 0 ; j < strlen(pthread[i]->port) ; j++)
		j = 0;
		while( pthread[i]->port[1][j] != 0 )
		{
			if(pthread[i]->port[0][j] == TCP_TYPE )
			{
				if(  port_a[ pthread[i]->port[1][j] ].tailt == NULL )
				{
					if((port_a[ pthread[i]->port[1][j] ].headt = malloc(sizeof(port_t)) ) != NULL)
					{
						port_a[ pthread[i]->port[1][j] ].headt->fifo = pthread[i]->fifo ;
						port_a[ pthread[i]->port[1][j] ].headt->next = NULL ;
						port_a[ pthread[i]->port[1][j] ].tailt = port_a[ pthread[i]->port[1][j] ].headt;
					}
					else
						return -1;
				}
				else
				{
					if((port_a[ pthread[i]->port[1][j] ].tailt->next = malloc(sizeof(port_t)) ) != NULL)
					{
						port_t  *tmp = port_a[ pthread[i]->port[1][j] ].tailt->next ;
						tmp->fifo = pthread[i]->fifo;
						tmp->next = NULL ;
						port_a[ pthread[i]->port[1][j] ].tailt = tmp;
					}
					else
						return -1;
				}
			}
			else
			{
				if(  port_a[ pthread[i]->port[1][j] ].tailu == NULL )
				{
					if((port_a[ pthread[i]->port[1][j] ].headu = malloc(sizeof(port_t)) ) != NULL)
					{
						port_a[ pthread[i]->port[1][j] ].headu->fifo = pthread[i]->fifo ;
						port_a[ pthread[i]->port[1][j] ].headu->next = NULL ;
						port_a[ pthread[i]->port[1][j] ].tailu = port_a[ pthread[i]->port[1][j] ].headu;
					}
					else
						return -1;
				}
				else
				{
					if((port_a[ pthread[i]->port[1][j] ].tailt->next = malloc(sizeof(port_t)) ) != NULL)
					{
						port_t  *tmp = port_a[ pthread[i]->port[1][j] ].tailu->next ;
						tmp->fifo =pthread[i]->fifo ;
						tmp->next = NULL ;
						port_a[ pthread[i]->port[1][j] ].tailu = tmp;
					}
					else
						return -1;
				}
			}
			j++;
		}
		i++;
	}	

	for(i = 0 ; i < 65535 ; i++)
	{
		if( port_a[i].headt != NULL)
			printf("@@@@@   %d  ******** %x  ****\n", i ,port_a[i].tailt->fifo);
	}
	return 0;
}



int 	init_all(probe_infor_t * probe , pthread_infor_t  *pthread[] ) 
{
	/*將xml里的信息分別讀入到這兩個結構中*/

	int   i = 0;
	/*測試*/
	memset(probe , 0 , sizeof(probe_infor_t));
	memset(pthread , 0 , 64*sizeof(pthread_infor_t *));
	memcpy(probe->device , "eth1" , 4);
//21 , 8000 , 1863, 443 , 25 , 110 , 1201 ,53 , 8080 , 5222 , 5190 , 143 , 1521 , 1433 , 5050 , 5101}; 
	u_int16_t ports[18] = { 80, 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80}; 
	static u_int8_t  * name[18] = {"HTTP" , "FTP" , "QQ" , "MSN" , "HTTPS" , "SMTP" , "POP3" , "CGA" , "DNS", "8080" , "Gtalk" , "ICQ" ,
							    "IMAP" , "ORCLE" , "SQLSERVER" , "YMSG" , "YMSG"};
	for(i = 0 ; i < 17; i ++)
	{
		pthread_infor_t *tmp ;
		tmp = malloc(sizeof(pthread_infor_t)) ;
		memset(tmp , 0 , sizeof(pthread_infor_t));
		tmp->port[0][0] = TCP_TYPE;
		tmp->port[1][0] = ports[i];
		printf("&&&&&&&&   %d   &&&&&&&&\n\n " , ports[i]);
		tmp->fifo = kfifo_alloc(1024*16);
		tmp->functions.init = http_init;
		tmp->functions.judge = http_judge;
		tmp->functions.audit_packet = http_audit_packet;
		tmp->functions.connect_destroy = http_connect_destroy;
		tmp->functions.consult_audit_packet = http_consult_audit_packet;
		tmp->functions.consult_connect_destroy = http_consult_connect_destroy;
		strcpy( tmp->name , name[i] ); 
		pthread[i] =  tmp ;
	}



	return 0;
	/**/
}



int probe_main(int argc , char **argv)
{
	pthread_t cid;
	probe_infor_t  probe;
	pthread_infor_t   * pthread[64] ;
	port_array_t  port[65535];
	probe_all_t all_info;

	all_info.pthread = pthread;
	all_info.port = port;
	pthread_mutex_init(&print_m , NULL) ;
	/*初始化線程信息,從xml 文件讀取線程配置文件*/
	if(init_all(&probe , pthread) < 0)
	{
		printf("獲取配置文件信息出錯\n");
		exit(0);
	}

	if(register_port_func( pthread,  port)<0)
	{
		printf("注冊模塊端口和函數出錯\n");
		exit(0);
	}

/*   啟動線程*/

	startup_pthread(pthread);

	pthread_create(&cid , NULL , probe_capture ,  &all_info);

	pthread_join(cid , NULL);
	//clean_all();

}




int main(int argc, char **argv)
{
	/*添加守護進城*/
	probe_main(argc , argv);
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
√…a在线天堂一区| 国产一区二区三区久久悠悠色av| 日韩成人免费电影| 成人久久18免费网站麻豆| 欧美美女激情18p| 日本一区二区三区四区| 免费高清不卡av| 欧美吻胸吃奶大尺度电影 | 欧美性大战久久久久久久蜜臀| 欧美成人a视频| 亚洲午夜视频在线观看| www.亚洲国产| 欧美精品一区二区三区在线| 亚洲一区二区五区| 成人激情av网| 久久久www免费人成精品| 亚洲.国产.中文慕字在线| 夫妻av一区二区| 亚洲精品一区二区三区四区高清| 亚洲午夜在线电影| 91精品1区2区| 亚洲精品网站在线观看| av亚洲精华国产精华精华| 久久女同精品一区二区| 日韩成人dvd| 91精品国产欧美一区二区18 | 亚洲香肠在线观看| 91国偷自产一区二区三区观看 | 欧美日韩大陆在线| 香蕉加勒比综合久久| 欧美在线免费观看视频| 亚洲欧美偷拍卡通变态| 不卡av免费在线观看| 欧美激情资源网| 懂色av一区二区夜夜嗨| 久久久久国色av免费看影院| 韩国中文字幕2020精品| 精品国产亚洲在线| 日本午夜精品视频在线观看| 在线成人av网站| 免费观看30秒视频久久| 欧美精品一区在线观看| 国产成人综合在线播放| 欧美国产激情一区二区三区蜜月 | 麻豆精品在线观看| 91精品国产91久久久久久一区二区| 午夜影视日本亚洲欧洲精品| 欧美日韩电影一区| 麻豆免费精品视频| 国产亚洲制服色| 99久久久无码国产精品| 亚洲精品国产精华液| 欧美精品在线一区二区三区| 午夜精品一区二区三区三上悠亚| 在线成人av网站| 国内精品久久久久影院一蜜桃| 国产欧美视频一区二区三区| 成人精品国产福利| 亚洲午夜精品久久久久久久久| 欧美一区日本一区韩国一区| 久久国产麻豆精品| 中文字幕亚洲区| 欧美四级电影在线观看| 精东粉嫩av免费一区二区三区| 国产三级精品三级在线专区| 一本久道中文字幕精品亚洲嫩| 五月天欧美精品| 国产精品天天看| 欧美狂野另类xxxxoooo| 成人一级片网址| 日韩一区精品字幕| 欧美韩国日本一区| 欧美少妇bbb| 国产乱码字幕精品高清av| 一区二区在线观看免费视频播放| 91精品国产色综合久久不卡电影 | av一区二区三区四区| 亚洲大片精品永久免费| 国产清纯白嫩初高生在线观看91 | 午夜av区久久| 国产精品久久一级| 日韩欧美久久久| 色成人在线视频| 国产精品资源在线观看| 亚洲国产精品久久不卡毛片| 2024国产精品| 欧美一区二区三区视频免费播放| jizzjizzjizz欧美| 国产精品一区二区你懂的| 午夜精品久久久久久久99水蜜桃 | 久久久亚洲精品一区二区三区| 在线观看视频91| av亚洲精华国产精华精华| 日本美女一区二区三区视频| 亚洲欧洲日韩在线| 国产日韩成人精品| 欧美一区二区成人| 欧美手机在线视频| 91在线视频18| 成人一区二区在线观看| 精品一区二区精品| 麻豆视频观看网址久久| 爽好久久久欧美精品| 尤物在线观看一区| 亚洲欧美成aⅴ人在线观看| 欧美极品少妇xxxxⅹ高跟鞋| 久久这里只精品最新地址| 日韩美女一区二区三区四区| 欧美精品日韩精品| 欧美精品黑人性xxxx| 欧美日韩一区小说| 欧美日韩国产高清一区| 精品视频一区二区不卡| 欧美视频一区二区三区在线观看| 91在线视频免费91| 色婷婷国产精品| 91麻豆视频网站| 在线观看三级视频欧美| 91黄色免费版| 欧美猛男超大videosgay| 欧美日韩一区二区电影| 欧洲av一区二区嗯嗯嗯啊| 色拍拍在线精品视频8848| 91久久一区二区| 欧美日韩一级黄| 日韩欧美不卡在线观看视频| 久久亚洲一区二区三区四区| 欧美精品一区二区高清在线观看| 精品国产一区二区三区久久久蜜月 | 欧美精品丝袜久久久中文字幕| 欧美美女bb生活片| 欧美电影免费观看高清完整版在线观看| 91精品国产欧美一区二区18| 精品日韩一区二区三区| 国产精品无人区| 尤物av一区二区| 蜜桃av一区二区三区电影| 狠狠色丁香婷婷综合| 国产成人综合亚洲91猫咪| 99久久久精品| 91麻豆精品国产自产在线 | 国产三级欧美三级| 18涩涩午夜精品.www| 五月天国产精品| 国产久卡久卡久卡久卡视频精品| 成人一级黄色片| 欧美日韩三级一区二区| 精品美女在线观看| 国产精品国产三级国产普通话三级| 亚洲欧美日韩综合aⅴ视频| 欧美日韩中文字幕精品| 看电影不卡的网站| 国产乱一区二区| 在线精品视频免费观看| 欧美精品免费视频| 国产蜜臀av在线一区二区三区| 一色桃子久久精品亚洲| 蜜桃一区二区三区在线观看| 成人av免费观看| 欧美电影在线免费观看| 国产精品网站在线| 久久精品久久综合| 日本道精品一区二区三区| 欧美videos大乳护士334| 亚洲三级在线免费观看| 捆绑调教一区二区三区| 91浏览器入口在线观看| 2021国产精品久久精品| 五月激情综合色| 91亚洲国产成人精品一区二三| 欧美成人video| 三级亚洲高清视频| 色美美综合视频| 国产欧美日韩另类视频免费观看| 日韩高清不卡一区| 欧美在线短视频| 中文字幕日韩一区| 国产91丝袜在线观看| 欧美一级免费观看| 亚洲成a人片在线观看中文| 懂色一区二区三区免费观看| 欧美大胆人体bbbb| 污片在线观看一区二区| 欧美自拍丝袜亚洲| 亚洲欧美日韩久久| 成人av在线网| 欧美激情在线免费观看| 国产在线不卡视频| 26uuu国产日韩综合| 麻豆精品一区二区综合av| 在线观看av一区二区| 亚洲日本在线天堂| 一本大道av一区二区在线播放| 欧美激情资源网| 不卡一区中文字幕| √…a在线天堂一区| 色综合久久中文字幕| 亚洲激情网站免费观看| a亚洲天堂av| 最新国产成人在线观看|