Beispiel #1
0
        public byte[] GetBytes(STUNMessage parentmessage, bool bDwordAlign)
        {
            byte[] bAttribute = m_objParsedAttribute.GetBytes(parentmessage);
            int    nLength    = bAttribute.Length + 4;

            if (bDwordAlign == true)
            {
                while ((nLength % 4) != 0)
                {
                    nLength++;
                }
            }

            m_bValue    = new byte[nLength];
            Length      = (ushort)bAttribute.Length;
            m_bValue[0] = (byte)(((int)m_objParsedAttribute.Type & 0xFF00) >> 8);
            m_bValue[1] = (byte)(((int)m_objParsedAttribute.Type & 0x00FF) >> 0);

            m_bValue[2] = (byte)(((int)Length & 0xFF00) >> 8);
            m_bValue[3] = (byte)(((int)Length & 0x00FF) >> 0);

            Array.Copy(bAttribute, 0, m_bValue, 4, bAttribute.Length);

            return(m_bValue);
        }