从Swift 3调用pcap_loop

时间:2017-01-23 14:39:31

标签: swift swift3 libpcap unsafe swift3.0.2

我在https://github.com/dfrencham/swiftPCap

尝试此代码
  pcap_loop(pcapSession, numberOfPackets,
        {
            (args: UnsafeMutablePointer<u_char>,
             pkthdr:UnsafePointer<pcap_pkthdr>,
             packet: UnsafePointer<u_char>) ->Void in
                    // lets handle the result using a call to a singleton 
                    // we can keep state this way, and not have to
                    // tool around by passing pointers to UnsafePointers
                    // and dereferencing later
                    let pa = PacketAnalyser.sharedInstance
                    pa.Process()
        },
        nil)

现在是Swift 3,我无法使用以下错误进行编译 无法转换类型'的值(UnsafeMutablePointer,UnsafePointer,UnsafePointer) - &gt; Void'到预期的参数类型'pcap_handler!'

不确定如何继续,几乎是一个从Swift引用C代码的新手。我已阅读文档,但没有太多运气。

由于

0 个答案:

没有答案