internal static PacketOrByteArraySegment ParseEncapsulatedBytes(ByteArraySegment payload, FlagsRadioTapField flagsField) { var payloadPacketOrData = new PacketOrByteArraySegment(); MacFrame frame = null; if (flagsField != null) { bool fcsPresent = ((flagsField.Flags & RadioTapFlags.FcsIncludedInFrame) == RadioTapFlags.FcsIncludedInFrame); if (fcsPresent) { frame = MacFrame.ParsePacketWithFcs(payload); } else { frame = MacFrame.ParsePacket(payload); } } else { frame = MacFrame.ParsePacket(payload); } if (frame == null) { payloadPacketOrData.TheByteArraySegment = payload; } else { payloadPacketOrData.ThePacket = frame; } return(payloadPacketOrData); }
/// <summary> /// Used by the Ieee80211PpiPacket constructor. /// </summary> /// <param name="header"> /// A <see cref="ByteArraySegment"/> /// </param> /// <param name="commonField"> /// The <see cref="PpiCommon"/> object in the PPI packet or null if not available /// </param> /// <returns> /// A <see cref="PacketOrByteArraySegment"/> /// </returns> internal static PacketOrByteArraySegment ParseEncapsulatedBytes(ByteArraySegment header, PpiCommon commonField) { // slice off the payload var payload = header.EncapsulatedBytes(); var payloadPacketOrData = new PacketOrByteArraySegment(); MacFrame frame = null; if (commonField != null) { bool fcsPresent = ((commonField.Flags & PpiCommon.CommonFlags.FcsIncludedInFrame) == PpiCommon.CommonFlags.FcsIncludedInFrame); if (fcsPresent) { frame = MacFrame.ParsePacketWithFcs(payload); } else { frame = MacFrame.ParsePacket(payload); } } else { frame = MacFrame.ParsePacket(payload); } if (frame == null) { payloadPacketOrData.TheByteArraySegment = payload; } else { payloadPacketOrData.ThePacket = frame; } return(payloadPacketOrData); }