Example #1
0
        public void AddFragment(IPv4Fragment fragment)
        {
            if (FragmentHead_ == null)
            {
                FragmentHead_ = fragment;
            }
            else if (fragment.Offset < FragmentHead_.Offset)
            {
                fragment.Next = FragmentHead_;
                FragmentHead_ = fragment;
            }
            else
            {
                IPv4Fragment temp = FragmentHead_;
                IPv4Fragment last = temp.Next;

                while (temp != null && fragment.Offset > temp.Offset)
                {
                    last = temp;
                    temp = temp.Next;
                }

                last.Next     = fragment;
                fragment.Next = temp;
            }

            TestComplete();
        }
Example #2
0
        // TODO("Code TestComplete()")
        private void TestComplete()
        {
            bool         done     = false;
            IPv4Fragment fragment = FragmentHead_;
            int          current  = 0;

            while (fragment != null)
            {
                if (fragment.Next != null)
                {
                    if (fragment.Offset == current)
                    {
                        fragment = fragment.Next;
                        current += fragment.Length;
                    }
                    else
                    {
                        fragment = null;
                    }
                }
                else
                {
                    if (fragment.Offset == current && fragment.MoreFlag == false)
                    {
                        fragment = null;
                        done     = true;
                    }
                    else
                    {
                        fragment = null;
                    }
                }
            }

            if (done)
            {
                CombineData();
            }
            this.Complete_ = done;
        }
Example #3
0
        private void CombineData()
        {
            int          length = 0;
            int          offset = 0;
            IPv4Fragment temp   = FragmentHead_;

            while (temp != null)
            {
                length += temp.Length;
                temp    = temp.Next;
            }

            Data_   = new byte[length];
            Length_ = length;
            temp    = FragmentHead_;

            while (temp != null)
            {
                Array.Copy(temp.Data, 0, this.Data_, offset, temp.Length);
                offset += temp.Length;
                temp    = temp.Next;
            }
        }