Closed dls314 closed 7 years ago
Just to let you know that I have very little knowledge regarding those 'low-level' protocols and Pcap.Net in general. And never worked with raw sockets.
But here is what I would do, first I'd probably rip off all of the Clash of Clans related code in the NetworkManagerAsync
class. Methods such as SendMessage
and ProcessReceive
contains a lot of that crappy stuff. Then create an interface or an abstract ProtocolProcessor
class and PacketProcessor
class to replace those Clash of Clans stuff. You might not need the ProtocolProcessor
since your goal is to feed captured packets into it right?
Those 2 classes will provide extra flexibility to the NetworkManagerAsync
as you can replace and modify the packet and protocol handling easily. For example you might want to create an IPv4ProtocolProcessor
and an IPv4PacketProcessor
to handle IPv4.
To keep track of how much data has been written or read, it sets the SocketAsyncEventArgs.UserToken
's value to a MessageReceiveToken
or MessageSendToken
instance which gets reset after each read or write. So you might need a custom token for each different protocols.
It would probably require a lot of work to fix all of my shit, but hey what do I know.
Also Pcap.Net is a great library, you could easily feed the byte[] Packet.Buffer
property into the MessageBufferManager
's buffer which is a single huge buffer, each instance of the SocketAsyncEventArgs
takes a segment of it to send and receive.
And sorry for the crappy explanation.
That explanation rocked. Now to find time to work on it.
Great, glad I could help. =]
Anyone have any thoughts about this?
My thought is to create an upward facing plugin interface from parts of NetworkManagerAsync, but I'd like to hear any thoughts about any approaches.
My goal is to feed in captured packets as from https://github.com/PcapDotNet/Pcap.Net