Esempio n. 1
0
        public void ReadCapFile(string FilePath)
        {
            StringBuilder errbuf = new StringBuilder(PCAP_ERRBUF_SIZE);
            PcapHandle = pcap_open_offline(FilePath, errbuf);

            // handle error
            if (PcapHandle == IntPtr.Zero)
            {
                throw new Exception("Unable to open offline adapter: " + errbuf.ToString());
            }

            pcap_handler Callback = new pcap_handler(PacketHandler);

            int ret = pcap_dispatch(PcapHandle, -1 /* -1 = infinite */, Callback, IntPtr.Zero);
        }
Esempio n. 2
0
        public void ReadCapFile(string FilePath)
        {
            StringBuilder errbuf = new StringBuilder(PCAP_ERRBUF_SIZE);

            PcapHandle = pcap_open_offline(FilePath, errbuf);

            // handle error
            if (PcapHandle == IntPtr.Zero)
            {
                throw new Exception("Unable to open offline adapter: " + errbuf.ToString());
            }

            pcap_handler Callback = new pcap_handler(PacketHandler);

            int ret = pcap_dispatch(PcapHandle, -1 /* -1 = infinite */, Callback, IntPtr.Zero);
        }
Esempio n. 3
0
 internal extern static int pcap_dispatch(IntPtr /* pcap_t* */ adaptHandle, int count, pcap_handler callback, IntPtr ptr);
 internal static extern int pcap_dispatch(IntPtr /* pcap_t* */ adaptHandle, int count, pcap_handler callback, IntPtr ptr);
Esempio n. 5
0
 /// <summary>
 /// Read packets until cnt packets are processed or an error occurs.
 /// </summary>
 internal static int pcap_dispatch(IntPtr /* pcap_t* */ adaptHandle, int count, pcap_handler callback, IntPtr ptr)
 {
     return(UseWindows ? Windows.pcap_dispatch(adaptHandle, count, callback, ptr) : Unix.pcap_dispatch(adaptHandle, count, callback, ptr));
 }
Esempio n. 6
0
 internal static extern int pcap_loop(
     [In] IntPtr p,
     [In] int cnt,
     [In][MarshalAs(UnmanagedType.FunctionPtr)] pcap_handler callback,
     [In] IntPtr user);