private PCAP_NEXT_EX_STATE ReadNextInternal(out PcapHeader p, out System.Byte[] packet_data, out IntPtr pkthdr, out IntPtr pktdata) { pcap_pkthdr pcap_pkthdr; pkthdr = IntPtr.Zero; pktdata = IntPtr.Zero; p = null; packet_data = null; #if MONO return(PCAP_NEXT_EX_STATE.ERROR); #else if (pcap_t.ToInt32() == 0) { errbuf = new StringBuilder("No adapter is currently open"); return(PCAP_NEXT_EX_STATE.ERROR); } int i = pcap_next_ex(pcap_t, ref pkthdr, ref pktdata); if (i == 1) { pcap_pkthdr = ((pcap_pkthdr)(Marshal.PtrToStructure(pkthdr, typeof(pcap_pkthdr)))); p = new PcapHeader(); p.CaptureLength = pcap_pkthdr.caplen; p.PacketLength = pcap_pkthdr.len; p.Timeval = pcap_pkthdr.ts; packet_data = new Byte[((System.UInt32)(p.PacketLength))]; Marshal.Copy(pktdata, packet_data, 0, p.PacketLength); return(PCAP_NEXT_EX_STATE.SUCCESS); } else if (i == 0) { return(PCAP_NEXT_EX_STATE.TIMEOUT); } else if (i == -1) { return(PCAP_NEXT_EX_STATE.ERROR); } else if (i == -2) { return(PCAP_NEXT_EX_STATE.EOF); } else { return(PCAP_NEXT_EX_STATE.UNKNOWN); } #endif }
public virtual PCAP_NEXT_EX_STATE ReadNextInternal(out PcapHeader p, out System.Byte[] packet_data) { IntPtr i; return(ReadNextInternal(out p, out packet_data, out i, out i)); }