91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

調鎖調了蠻多時間.單線程序抓包,三個緩沖區, 默認三個線程進行處理.由于為了盡量保證包的順序,三個線程同時只從一個緩沖區取數據

資源截圖

代碼片段和文件信息

/*?
?*?=====================================================================================
?*
?*???????Filename:??FlowClassThread.c
?*
?*????Description:??Class?Packet?
?*
?*????????Version:??1.0
?*????????Created:??04/30/2009?08:51:46?AM
?*???????Revision:??none
?*???????Compiler:??gcc
?*
?*?????????Author:??WengJian?Lv?
?*????????Company:??GreeNet
?*
?*?=====================================================================================
?*/
#include?“test.h“?
?
?void?*?FlowClassThread(PktMemC?*pktmemc_buf)
{
????int?temp;
int?count?=?0;
????u_char??packet[1550];
????u_char??*tmp_packet;?/*just?for?readable*/
????/**/
????while(1)
????{
??????pthread_mutex_lock(&(pktmemc_buf->m_pktbuf->pktbufglobal_m));/**/
??????pthread_mutex_lock(&(pktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pktbufhead_m));
??????temp=pktmemc_buf->m_pktbuf->ocurrentbuf;
??????if(pktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pkt_num==0)
??????{?/*free?the?lock*/
????????pktmemc_buf->m_pktbuf->ocurrentbuf?=?(pktmemc_buf->m_pktbuf->ocurrentbuf+1)?%?PKT_BUFlink_HEADNUM;
????????//tmp_packet?=?pktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pkt_buf_c;
????????//tmp_packet?=?pktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pkt_buf_h;
????????pthread_mutex_unlock(&(pktmemc_buf->m_pktbuf->pktbufglobal_m));
????????pthread_mutex_unlock(&(pktmemc_buf->m_pktbuf->pktbuf_array[temp].pktbufhead_m));?
count++;
if(count>10)
{
printf(“the?Class?Thread?Count?is?%d\n“count);
sleep(1);
count=0;
}

????????continue;
??????}
??????
??????
??????/*
??????release?pktbufglobal_mso?the?capture?thread?could?quickly?capture?the?packet
??????*/
??????pthread_mutex_unlock(&(pktmemc_buf->m_pktbuf->pktbufglobal_m));
??????tmp_packet?=?pktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pkt_buf_c;
??????memcpy(packettmp_packet2+*((u_short*)(tmp_packet)));
??????tmp_packet?=?tmp_packet?+?1550;
??????pktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pkt_num--;
??printf(“the?%d?pool?has?only?%d‘s?packet\n“pktmemc_buf->m_pktbuf->ocurrentbufpktmemc_buf->m_pktbuf->pktbuf_array[pktmemc_buf->m_pktbuf->ocurrentbuf].pkt_num);
?????//sleep();
??pthread_mutex_unlock(&(pktmemc_buf->m_pktbuf->pktbuf_array[temp].pktbufhead_m));
??????
??????/*class?the?packet?in?below*/
??????switch(pktmemc_buf->methods)
??????{
??????case?1:
?????? ??ClassBySsDdP(pktmemc_buf(u_char*)packet);
?????? ??break;
??????case?2:
????????
???????? break;
??????case?3:
????????
???????? break;
????????
????????default:
???????? break;
??????}
????}???
}




void?ClassBySsDdP(PktMemC?*pktmemc_bufu_char?*packet)
{
ip_header??*ih;
udp_header?*uh;
tcp_header?*th;???
int?ip_len;
int?ip_hlen;
int?i;
int?tcpflag?=?0;
int?udpflag?=?0;

ih??????=?(ip_header?*)?(packet?+16);

評論

共有 條評論