I'm using the library Network.Pcap
, and it has the function toBS
toBS :: (PktHdr, Ptr Word8) -> IO (PktHdr, B.ByteString)
toBS (hdr, ptr) = do
let len = hdrCaptureLength hdr
s <- B.create (fromIntegral len) $ \p -> B.memcpy p ptr (fromIntegral len)
return (hdr, s)
Right now I am unpacking the ByteString which gives me the [Word8]
I want. I'
m looking for a way to avoid having to unpack the ByteString
, and get the [Word8]
directly.
(1) Does this function exist? (2) If not, could I get some advice on how to proceed?
I'm not familiar with those libraries, but can't you just do this?