I'm doing some Network capture with Network.Pcap
(pcap) and plan to do some inspection using Net.PacketParsing
(network-house). To do so, it looks like i have to put my packet parsing in either
Pcap.Callback :: PktHdr -> Ptr Word8 -> IO ()
or
Pcap.CallbackBS :: PktHdr -> ByteString -> IO ().
And work on the packet as either a 'Ptr Word8' or 'ByteString'. On the packet parsing side, I have:
Net.Packet.toInPack :: UArray Int Word8 -> InPacket
to get to the InPacket
type that's needed for the parsing. So, what's left for me is to convert the 'Ptr' or 'ByteString' to 'UArray'--either purely or in IO. I suppose I can unpack the ByteString
to [Word8]
, and from there to the UArray
, but there seems like there must be a better way.
I'm also concerned about my choice of libraries. I've used network-house in the past and found it quite nice, but it is getting old and uses UArray, which itself seems a little archaic. So suggestions for a better starting point are welcome.