1

我正在尝试来自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)-> Void”的值转换为预期的参数类型“pcap_handler!”

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

谢谢

4

0 回答 0