public void Open(string name) { byte[] err = new byte[256]; fixed(byte *pErr = &err[0]) { handle = LibPcap.pcap_open(name, 68, 0, 0, null, pErr); if (handle == null) { throw new LibPcapException(Encoding.ASCII.GetString(err)); } } }
public Packet Next() { pcap_pkthdr *header = null; byte * data = null; int result = LibPcap.pcap_next_ex(handle, ref header, ref data); if (result == 1) { return(new Packet(ref *header, data)); } else if (result == 0) { return(null); } else if (result == -2) { throw new EndOfStreamException(); } else { throw new LibPcapException("error"); } }
public void Close() { LibPcap.pcap_close(handle); }