示例#1
0
        private void Parse(TemplatesV9 templates)
        {
            this._flowset = new List <FlowSet>();

            Int32 length = _bytes.Length - 20;

            Byte[] header  = new Byte[20];
            Byte[] flowset = new Byte[length];

            Array.Copy(_bytes, 0, header, 0, 20);
            Array.Copy(_bytes, 20, flowset, 0, length);

            this._header = new V9Header(header);
            byte[] reverse = flowset.Reverse().ToArray();

            int templengh = 0;

            while ((templengh + 2) < flowset.Length)
            {
                UInt16 lengths   = BitConverter.ToUInt16(reverse, flowset.Length - sizeof(Int16) - (templengh + 2));
                Byte[] bflowsets = new Byte[lengths];
                Array.Copy(flowset, templengh, bflowsets, 0, lengths);

                FlowSet flowsets = new FlowSet(bflowsets, templates);
                this._flowset.Add(flowsets);

                templengh += lengths;
            }
        }
示例#2
0
        private void Parse(TemplatesV9 templates)
        {
            byte[] reverse = this._bytes.Reverse().ToArray();
            this._template  = new SynchronizedCollection <Template>();
            this._valuebyte = new List <byte>();

            this._id     = BitConverter.ToUInt16(reverse, this._bytes.Length - sizeof(Int16) - 0);
            this._length = BitConverter.ToUInt16(reverse, this._bytes.Length - sizeof(Int16) - 2);

            if ((this._id == 0) || (this._id == 1))
            {
                if (this._id == 0)
                {
                    int cout, pastaddress, address = 6;

                    while (address < this._bytes.Length)
                    {
                        cout = BitConverter.ToUInt16(reverse, this._bytes.Length - sizeof(Int16) - address);

                        int    length    = cout * 4 + 4;
                        Byte[] btemplate = new Byte[length];
                        Array.Copy(this._bytes, address - 2, btemplate, 0, length);

                        Template template = new Template(btemplate);

                        this._template.Add(template);

                        Boolean flag = false;
                        SynchronizedCollection <Template> templs = templates.Templates;

                        for (int i = 0; i < templs.Count; i++)
                        {
                            if (template.ID == templs[i].ID)
                            {
                                flag      = true;
                                templs[i] = template;
                            }
                        }

                        if (flag)
                        {
                            templates.Templates = templs;
                        }
                        else
                        {
                            templates.Templates.Add(template);
                        }

                        pastaddress = address;
                        address     = cout * 4 + pastaddress + 4;
                    }
                }
            }
            else if (this._id > 255)
            {
                Boolean  flag   = false;
                Template templs = null;

                foreach (Template templ in templates.Templates)
                {
                    if (templ.ID == this._id)
                    {
                        templs = DeepClone(templ) as Template;
                        flag   = true;
                    }
                }

                int j = 4, z;

                if (flag)
                {
                    z = (this._length - 4) / templs.FieldLength;

                    for (int y = 0; y < z; y++)
                    {
                        foreach (Field fields in templs.Field)
                        {
                            for (int i = 0; i < fields.Length; i++, j++)
                            {
                                fields.Value.Add(this._bytes[j]);
                            }
                        }

                        this._template.Add(DeepClone(templs) as Template);

                        foreach (Field filds in templs.Field)
                        {
                            filds.Value.Clear();
                        }
                    }
                }

                if (!flag)
                {
                    for (int i = 4; i < this._bytes.Length; i++)
                    {
                        this._valuebyte.Add(this._bytes[i]);
                    }
                }
            }
        }
示例#3
0
 public FlowSet(Byte[] bytes, TemplatesV9 templates)
 {
     this._bytes = bytes;
     this.Parse(templates);
 }
示例#4
0
 public V9Packet(Byte[] bytes, TemplatesV9 templates)
 {
     this._bytes = bytes;
     this.Parse(templates);
 }