protected override void WriteBody(byte[] buf, ref int offset) { buf[offset++] = 0; buf[offset++] = 0; buf[offset++] = ErrorClass; buf[offset++] = ErrorNumber; NetBinaryUtil.Write(ReasonPhrase, buf, ref offset); }
protected override void WriteBody(byte[] buf, ref int offset) { buf[offset++] = 0; buf[offset++] = (byte)(m_EndPoint.AddressFamily == AddressFamily.InterNetwork ? 1 : 2); var port = (ushort)((ushort)m_EndPoint.Port ^ (ushort)(StunMessage.MagicCookie >> 16)); NetBinaryUtil.Write(port, buf, ref offset); for (int i = 0; i < m_AddressBytes.Length; i++) { s_Buffer[i] = (byte)(m_AddressBytes[i] ^ buf[i + 4]); } NetBinaryUtil.Write(s_Buffer, m_AddressBytes.Length, buf, ref offset); }
public void Write(ref byte[] buf, ref int offset) { var totalSize = 4 + GetPaddedLength() + offset; if (buf.Length < totalSize) { System.Array.Resize(ref buf, System.Math.Max(buf.Length * 2, totalSize)); } NetBinaryUtil.Write((ushort)Type, buf, ref offset); NetBinaryUtil.Write((ushort)GetLength(), buf, ref offset); WriteBody(buf, ref offset); offset += GetPadOffset(GetLength()); }
protected override void WriteBody(byte[] buf, ref int offset) { int flag = 0; if (ChangeIP) { flag |= 4; } if (ChangePort) { flag |= 2; } s_Buffer[3] = (byte)flag; NetBinaryUtil.Write(s_Buffer, buf, ref offset); }
public int Write(ref byte[] buf) { int offset = 0; NetBinaryUtil.Write((ushort)MessageType, buf, ref offset); int attributesLength = 0; foreach (var attribute in Attributes) { attributesLength += StunAttribute.HeaderSize + attribute.GetPaddedLength(); } NetBinaryUtil.Write((ushort)attributesLength, buf, ref offset); NetBinaryUtil.Write(MagicCookie, buf, ref offset); NetBinaryUtil.Write(TransactionId, TransactionIdSize, buf, ref offset); foreach (var attribute in Attributes) { attribute.Write(ref buf, ref offset); } return(offset); }
protected override void WriteBody(byte[] buf, ref int offset) { NetBinaryUtil.Write(Text, buf, ref offset); }