/// <summary> /// Writes the chunk into a byte array. /// </summary> /// <param name="buffer">The byte array.</param> /// <param name="offset">The offset at which to start writing the chunk.</param> /// <returns>The number of bytes written.</returns> protected override int ToBuffer(byte[] buffer, int offset, out int dataLength) { dataLength = 0; int start = offset; offset += NetworkHelpers.CopyTo(this.CumulativeTSNAck, buffer, offset); offset += NetworkHelpers.CopyTo(this.AdvertisedReceiverWindowCredit, buffer, offset); offset += NetworkHelpers.CopyTo((ushort)(this.GapAckBlocks == null ? 0 : this.GapAckBlocks.Count), buffer, offset); offset += NetworkHelpers.CopyTo((ushort)(this.DuplicateTSNs == null ? 0 : this.DuplicateTSNs.Count), buffer, offset); if (this.GapAckBlocks != null && this.GapAckBlocks.Any()) { foreach (var block in this.GapAckBlocks) { offset += NetworkHelpers.CopyTo(block.GapAckBlockStart, buffer, offset); offset += NetworkHelpers.CopyTo(block.GapAckBlockEnd, buffer, offset); } } if (this.DuplicateTSNs != null && this.DuplicateTSNs.Any()) { foreach (var dtsn in this.DuplicateTSNs) { offset += NetworkHelpers.CopyTo(dtsn, buffer, offset); } } return(offset - start); }
/// <summary> /// Writes the chunk parameter into a byte array. /// </summary> /// <param name="buffer">the byte array.</param> /// <param name="offset">The Offset at which to start writing the chunk parameter.</param> /// <returns>The number of bytes written.</returns> public int ToArray(byte[] buffer, int offset) { int start = offset; offset += NetworkHelpers.CopyTo((ushort)this.Type, buffer, offset); offset += NetworkHelpers.CopyTo(this.Length, buffer, offset); offset += NetworkHelpers.CopyTo(this.Value, buffer, offset); return(offset - start); }
/// <summary> /// Writes the common header into a byte array at a given offset. /// </summary> /// <param name="buffer">The byte array</param> /// <param name="offset">The offset.</param> /// <returns>The number of bytes written to the byte array.</returns> public int ToArray(byte[] buffer, int offset) { int start = offset; offset += NetworkHelpers.CopyTo(this.SourcePort, buffer, offset); offset += NetworkHelpers.CopyTo(this.DestinationPort, buffer, offset); offset += NetworkHelpers.CopyTo(this.VerificationTag, buffer, offset); offset += NetworkHelpers.CopyTo(this.Checksum, buffer, offset); return(offset - start); }
/// <summary> /// Writes the common header into a byte array at a given offset. /// </summary> /// <param name="buffer">The byte array</param> /// <param name="offset">The offset.</param> /// <returns>The number of bytes written to the byte array.</returns> public int ToArray(byte[] buffer, int offset) { int start = offset; offset += NetworkHelpers.CopyTo(this.SrcPort, buffer, offset); offset += NetworkHelpers.CopyTo(this.DstPort, buffer, offset); offset += NetworkHelpers.CopyTo(this.VerTag, buffer, offset); offset += NetworkHelpers.CopyTo(this.Chksum, buffer, offset); return(offset - start); }
/// <summary> /// Writes the chunk into a byte array. /// </summary> /// <param name="buffer">The byte array.</param> /// <param name="offset">The offset at which to start writing the chunk.</param> /// <returns>The number of bytes written.</returns> protected override int ToBuffer(byte[] buffer, int offset, out int dataLength) { dataLength = 0; if (this.Type == ChunkType.Shutdown) { offset += NetworkHelpers.CopyTo(this.CumulativeTSNAck, buffer, offset); return(4); } return(0); }
/// <summary> /// Writes the chunk into a byte array. /// </summary> /// <param name="buffer">The byte array.</param> /// <param name="offset">The offset at which to start writing the chunk.</param> /// <returns>The number of bytes written.</returns> protected override int ToBuffer(byte[] buffer, int offset, out int dataLength) { dataLength = this.UserData.Count; int start = offset; offset += NetworkHelpers.CopyTo(this.TSN, buffer, offset); offset += NetworkHelpers.CopyTo(this.StreamId, buffer, offset); offset += NetworkHelpers.CopyTo(this.StreamSeqNo, buffer, offset); offset += NetworkHelpers.CopyTo(this.PayloadProtocolId, buffer, offset); offset += NetworkHelpers.CopyTo(this.UserData, buffer, offset); return(offset - start); }
/// <summary> /// Outputs the chunk into a byte array. /// </summary> /// <param name="buffer">The byte array.</param> /// <param name="offset">The offset into the array to start writing the chunk.</param> /// <returns>The length of the chunk.</returns> public int ToArray(byte[] buffer, int offset) { int start = offset; this.Length = (ushort)this.CalculateLength(out int bufferSize); offset += NetworkHelpers.CopyTo((byte)this.Type, buffer, offset); offset += NetworkHelpers.CopyTo(this.Flags, buffer, offset); offset += NetworkHelpers.CopyTo(this.Length, buffer, offset); offset += this.ToBuffer(buffer, offset, out int dataLength); return(offset - start); }
/// <summary> /// Writes the chunk into a byte array. /// </summary> /// <param name="buffer">The byte array.</param> /// <param name="offset">The offset at which to start writing the chunk.</param> /// <returns>The number of bytes written.</returns> protected override int ToBuffer(byte[] buffer, int offset, out int dataLength) { dataLength = 0; offset += NetworkHelpers.CopyTo(this.InitiateTag, buffer, offset); offset += NetworkHelpers.CopyTo(this.AdvertisedReceiverWindowCredit, buffer, offset); offset += NetworkHelpers.CopyTo(this.OutboundStreams, buffer, offset); offset += NetworkHelpers.CopyTo(this.InboundStreams, buffer, offset); offset += NetworkHelpers.CopyTo(this.InitialTSN, buffer, offset); int paramsLength = 0; if (this.Parameters != null && this.Parameters.Any()) { foreach (var parm in this.Parameters) { offset += parm.ToArray(buffer, offset); paramsLength += parm.Length; } } return(16 + paramsLength); }
/// <summary> /// Writes the data to a byte array. /// </summary> /// <param name="buffer">The byte array</param> /// <param name="offset">The offset at which to write the data.</param> /// <returns>The number of bytes written.</returns> protected override int ToBuffer(byte[] buffer, int offset) { offset += NetworkHelpers.CopyTo(this.StreamId, buffer, offset); offset += NetworkHelpers.CopyTo(this.Reserved, buffer, offset); return(4); }
protected override int ToBuffer(byte[] buffer, int offset, out int dataLength) { dataLength = 0; offset += NetworkHelpers.CopyTo(this.Cookie, buffer, offset, false); return(this.Cookie.Length); }