I saw the following code used in the project:
while (1) { l_numPkts = pcap_next_ex( m_pcapHandle, &header, &pkt_data); //do something memcpy(dst,pkt_data,size); }
after pcap_next_ex returns, the package status will be set to TP_STATUS_KERNEL, which means that buf has been returned to the kernel. code:
switch (handle->md.tp_version) { case TPACKET_V1: h.h1->tp_status = TP_STATUS_KERNEL; ..
in some high speed environment, memory issue?
and what is the correct way to use pcap_next / pcap_next_ex?
source share