private static bool ShouldLogPacket(StackConsts.HCI_PacketType t, int originalLen, out int snapShotLen) { if (t == StackConsts.HCI_PacketType.HCICommandPacket || t == StackConsts.HCI_PacketType.HCIEventPacket) { snapShotLen = originalLen; return(true); } if (t == StackConsts.HCI_PacketType.HCIACLDataPacket) { const int MaxSnap = 300; //----32; snapShotLen = Math.Min(MaxSnap, originalLen); return(true); } snapShotLen = -1; return(false); }
void WritePacketToPcap(Stream dst, DateTime dt, StackConsts.HCI_PacketType h4PacketType, byte[] packet, int snapShotLen, int originalLen, bool directionIsSent) { Debug.Assert(snapShotLen <= originalLen); const int SizeOfH4Header = 1; const int SizeOfPHdr = 4; int optionalSizeOfPHdr = (WithPhdr ? SizeOfPHdr : 0); WritePcapPacketHeader(dst, dt, snapShotLen + SizeOfH4Header + optionalSizeOfPHdr, originalLen + SizeOfH4Header + optionalSizeOfPHdr); if (WithPhdr) { WritePhdr(dst, directionIsSent); } dst.WriteByte((byte)h4PacketType); dst.Write(packet, 0, snapShotLen); }
private void WriteToRawFile(Stream dst, Boolean PacketSent, IntPtr pHCIPacket, Structs.HCI_Packet hciPacket, StackConsts.HCI_PacketType t, byte[] data, int snapShotLen, int originalLen) { dst.WriteByte(PacketSent ? (byte)1 : (byte)0); dst.WriteByte((byte)t); Stream_WriteInt32(dst, snapShotLen); Stream_WriteInt32(dst, snapShotLen); var count = 1 + 1 + 4 + 4; // dst.Write(data, 0, snapShotLen); count += snapShotLen; // var over16 = count % 16; if (over16 != 0) { dst.Write(PadTemplate, 0, 16 - over16); } }