public void Clear() { _schema = null; Path.Clear(); Fragments.Clear(); UsedVariables.Clear(); UnusedVariables.Clear(); DeclaredVariables.Clear(); Errors.Clear(); }
internal void Release() { foreach (var f in Fragments) { ReleaseFragment(f); } Fragments.Clear(); GenericPool <Message> .Release(this); }
public void ClearFragment() { try { Fragments.Clear(); FragmentNames.Clear(); NotifyDataSetChanged(); } catch (Exception e) { Console.WriteLine(e); } }
public void ClaerFragment() { try { Fragments.Clear(); FragmentNames.Clear(); NotifyDataSetChanged(); } catch (Exception exception) { Crashes.TrackError(exception); } }
public void ClaerFragment() { try { Fragments.Clear(); FragmentNames.Clear(); NotifyDataSetChanged(); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
public void Clear() { _schema = null; Path.Clear(); Variables.Clear(); Fragments.Clear(); UsedVariables.Clear(); UnusedVariables.Clear(); DeclaredVariables.Clear(); Names.Clear(); Types.Clear(); Directives.Clear(); OutputFields.Clear(); InputFields.Clear(); Errors.Clear(); IsInError = false; }
/// <summary> /// This returns the next complete payload. This involves defragmenting any fragments /// </summary> /// <returns>byte array containing the IP payload.</returns> public unsafe byte[] GetNextIPPayload() { if (Fragments.Count == 0) { return(null); } List <byte[]> nextFragments; // optimize single packet processing if (Fragments.Count == 1) { nextFragments = Fragments; } else { nextFragments = Fragments.OrderBy(x => Utility.ntohs(BitConverter.ToUInt16(x, 4))) // identification .ThenBy(x => Utility.ntohs(BitConverter.ToUInt16(x, 6)) & 0x1fff) // fragment offset .ToList(); } ushort currentId = 0; ushort fragmentOffset = 0; byte[] payload = null; for (int i = 0; i < nextFragments.Count; i++) { fixed(byte *ptr = nextFragments[i]) { IPv4Header ip4Header = *(IPv4Header *)ptr; // every new ID resets the internal state - we dont need to return in order. if (currentId != ip4Header.Id) { currentId = ip4Header.Id; payload = null; fragmentOffset = 0; } // skip for now if the offset is incorrect, the correct packet may come soon. if (ip4Header.FragmentOffset == fragmentOffset) { int fragmentDataSize; // correction for fragmented packet // note: ip4Header.length may be zero if using hardwre offloading to network card. if (ip4Header.Length == 0 && ip4Header.Id != 0) { fragmentDataSize = nextFragments[i].Length - ip4Header.HeaderLength; } else { fragmentDataSize = ip4Header.Length - ip4Header.HeaderLength; } // resize payload array if (payload == null) { payload = new byte[fragmentDataSize]; } // if this is a fragment, prepare array to accept it and record last fragment time. if (ip4Header.FragmentOffset > 0) { LastIPFragmentTimestamp = DateTime.Now; Array.Resize(ref payload, payload.Length + fragmentDataSize); } // copy packet into payload Array.Copy(nextFragments[i], ip4Header.HeaderLength, payload, fragmentOffset, fragmentDataSize); // add data offset fragmentOffset += (ushort)fragmentDataSize; // return payload if this is the final fragment if ((ip4Header.Flags & (byte)IPFlags.MF) == 0) { // purge current fragments if (Fragments.Count == 1) // optimize single packet processing { Fragments.Clear(); } else { // remove in reverse order to prevent IEnumerable issues. for (int j = Fragments.Count - 1; j >= 0; j--) { if (Utility.ntohs((ushort)BitConverter.ToUInt16(Fragments[j], 4)) == currentId) { Fragments.RemoveAt(j); } else if (Utility.ntohs(BitConverter.ToUInt16(Fragments[j], 4)) < currentId - 99) { //Trace.WriteLine("IP: Old fragment purged. Current ID: [" + currentId.ToString("X4") + "], Old ID: + [" + //IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(Fragments[j], 4)) + "] " + Utility.ByteArrayToHexString(Fragments[j], 0, 50)); Fragments.RemoveAt(j); } } } return(payload); } } } } return(null); }
public void Unpack(BinaryReader reader) { var bytesRemaining = reader.BytesRemaining(); log.DebugFormat("Unpack bytes: {0}", bytesRemaining); log.Assert(bytesRemaining >= PacketHeaderSize, "Packet size too small"); log.Assert(bytesRemaining <= MaxPacketSize, "Packet size too big"); SeqID = reader.ReadUInt32(); Header = (PacketHeaderFlags)reader.ReadUInt32(); Checksum = reader.ReadUInt32(); RecId = reader.ReadUInt16(); Interval = reader.ReadUInt16(); DataLen = reader.ReadUInt16(); Iteration = reader.ReadUInt16(); log.DebugFormat("SeqID: {0}, Header: {1}, Checksum {2}, RecId: {3}, Interval {4}, DataLen: {5}, Iteration: {6}", SeqID, Header, Checksum, RecId, Interval, DataLen, Iteration); bytesRemaining = reader.BytesRemaining(); #if NETWORKVALIDATION log.Assert(bytesRemaining == DataLen, "Size of reader " + DataLen + " does not equal packet length: " + bytesRemaining); #endif if ((Header & PacketHeaderFlags.ServerSwitch) != 0) { ServerSwitchData.Unpack(reader); } if ((Header & PacketHeaderFlags.Referral) != 0) { ReferralData.Unpack(reader); } if ((Header & PacketHeaderFlags.NegativeAck) != 0) { NegativeAckData.Unpack(reader); } if ((Header & PacketHeaderFlags.EmptyAck) != 0) { EmptyAckData.Unpack(reader); } if ((Header & PacketHeaderFlags.PositiveAck) != 0) { PositiveAckData.Unpack(reader); } if ((Header & PacketHeaderFlags.LoginRequest) != 0) { LoginRequestData.Unpack(reader); } if ((Header & PacketHeaderFlags.ServerSwitchRequest) != 0) { ServerSwitchRequestData.Unpack(reader); } if ((Header & PacketHeaderFlags.ConnectRequest) != 0) { ConnectRequestData.Unpack(reader); } if ((Header & PacketHeaderFlags.ConnectResponse) != 0) { ConnectResponseData.Unpack(reader); } if ((Header & PacketHeaderFlags.NetError) != 0) { NetErrorData.Unpack(reader); } if ((Header & PacketHeaderFlags.CloseConnection) != 0) { CloseConnectionData.Unpack(reader); } if ((Header & PacketHeaderFlags.CICMDCommand) != 0) { CicmdData.Unpack(reader); } if ((Header & PacketHeaderFlags.TimeSync) != 0) { TimeSyncData.Unpack(reader); } if ((Header & PacketHeaderFlags.EchoRequest) != 0) { EchoRequestData.Unpack(reader); } if ((Header & PacketHeaderFlags.EchoResponse) != 0) { EchoResponseData.Unpack(reader); } if ((Header & PacketHeaderFlags.Flow) != 0) { FlowData.Unpack(reader); } if ((Header & PacketHeaderFlags.BlobFragments) != 0) { log.Debug("Reading Blob Fragments"); Fragments.Clear(); bytesRemaining = reader.BytesRemaining(); uint fragNum = 0; while (bytesRemaining >= 16) { log.DebugFormat("Bytes Remaining: {0}", bytesRemaining); BlobFrag newItem = new BlobFrag(reader); #if NETWORKDEBUG newItem.NetworkPacketNum = NetworkPacketNum; newItem.NetworkFragmentNum = ++fragNum; #endif Fragments.Add(newItem); bytesRemaining = reader.BytesRemaining(); } #if NETWORKVALIDATION log.Assert(bytesRemaining == 0, "Bytes still remaining in packet: " + bytesRemaining); #endif } }