Esempio n. 1
0
 public StunMessage5389()
 {
     Attributes      = Array.Empty <Attribute>();
     StunMessageType = StunMessageType.BindingRequest;
     MagicCookie     = 0x2112A442;
     TransactionId   = BitUtils.GetRandomBytes(12).ToArray();
 }
Esempio n. 2
0
        public IEnumerable <byte> ToBytes()
        {
            var res = new List <byte>();

            res.AddRange(Convert.ToUInt16(Type).ToBe());
            res.AddRange(Length.ToBe());
            res.AddRange(Value.Bytes);

            var n = (4 - res.Count % 4) % 4;             // 填充的字节数

            res.AddRange(BitUtils.GetRandomBytes(n));

            return(res);
        }