示例#1
0
        public void ParseBindingRequestWithIceControlledAttribute()
        {
            var buffer = new byte[]
            {
                0x00, 0x01, 0x00, 0x50, 0x21, 0x12, 0xa4, 0x42, 0x0c, 0x66, 0x64, 0x5a, 0xf7, 0xe9, 0xe6, 0x57,
                0x3f, 0x53, 0x2b, 0x33, 0x00, 0x24, 0x00, 0x04, 0x6e, 0x7f, 0xff, 0xff, 0x80, 0x29, 0x00, 0x08,
                0x27, 0xff, 0x2a, 0x17, 0x1b, 0x88, 0x8f, 0xfe, 0x80, 0x22, 0x00, 0x08, 0x6c, 0x69, 0x62, 0x6a,
                0x75, 0x69, 0x63, 0x65, 0x00, 0x06, 0x00, 0x09, 0x4e, 0x4f, 0x43, 0x47, 0x3a, 0x6b, 0x57, 0x55,
                0x48, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x14, 0x23, 0x7e, 0x24, 0x6c, 0x44, 0x12, 0xbc, 0x43,
                0xfc, 0x63, 0x01, 0xf4, 0xda, 0x36, 0x73, 0xdf, 0x84, 0xb8, 0x23, 0xd6, 0x80, 0x28, 0x00, 0x04,
                0x07, 0x8a, 0x49, 0x2e
            };

            var stunReq = STUNMessage.ParseSTUNMessage(buffer, buffer.Length);

            Assert.NotNull(stunReq);
            Assert.Equal(1853882367U,
                         NetConvert.ParseUInt32(stunReq.Attributes.Single(x => x.AttributeType == STUNAttributeTypesEnum.Priority).Value, 0));
            Assert.Equal(8, stunReq.Attributes.Single(x => x.AttributeType == STUNAttributeTypesEnum.IceControlled).PaddedLength);
            Assert.Equal(0x27ff2a171b888ffeU,
                         NetConvert.ParseUInt64(stunReq.Attributes.Single(x => x.AttributeType == STUNAttributeTypesEnum.IceControlled).Value, 0));
        }