public void HandleCapture(byte[] buffer, int offset, int length) { TimeSpan timeOffset = DateTime.UtcNow - _connectedAt; MemoryStream stream = PrepareSendFrame(RPCAP_VERSION, RPCAP_MSG_PACKET, 0); NetworkWriter writer = new NetworkWriter(stream); uint seconds = (uint)Math.Floor(timeOffset.TotalSeconds); uint microseconds = (uint)((timeOffset.Ticks % TimeSpan.TicksPerSecond) / 10L); int bytesToTransmit = Math.Min(_snapLength, length); writer.WriteUnsigned32(seconds); writer.WriteUnsigned32(microseconds); writer.WriteUnsigned32((uint)bytesToTransmit); writer.WriteUnsigned32((uint)length); writer.WriteUnsigned32(_packetNumber++); stream.Write(buffer, offset, bytesToTransmit); CompleteSendFrame(stream); }
void HandleOpenRequest(byte[] data) { string deviceName = Encoding.UTF8.GetString(data); MemoryStream stream = PrepareSendFrame(RPCAP_VERSION, RPCAP_MSG_OPEN_REPLY, 0); NetworkWriter writer = new NetworkWriter(stream); uint linkType = DLT_EN10MB; uint offsetFromUtc = 0; writer.WriteUnsigned32(linkType); writer.WriteUnsigned32(offsetFromUtc); CompleteSendFrame(stream); }