public IpProtocol(byte[] packetBuffer) { BigEndianConverter endianConverter = new BigEndianConverter(); if (packetBuffer == null) throw new ArgumentException("Incoming Packet is null."); if (packetBuffer.Length < 20) throw new ArgumentException("Incomplete IP Header"); int version = (packetBuffer[0] & 0xF0) >> 4; int headerLength = (packetBuffer[0] & 0x0F) * 4; if ((packetBuffer[0] & 0x0F) < 5) throw new ArgumentException("Smaller then 5"); Precedence precedence = (Precedence)((packetBuffer[1] & 0xE0) >> 5); Delay delay = (Delay)((packetBuffer[1] & 0x10) >> 4); Throughput throughput = (Throughput)((packetBuffer[1] & 0x08) >> 3); Reliability reliability = (Reliability)((packetBuffer[1] & 0x04) >> 2); int totalLength = (packetBuffer[2] * 256) + packetBuffer[3]; int identification = (packetBuffer[4] * 256) + packetBuffer[5]; int timeToLive = packetBuffer[8]; Protocol protocol = (Protocol)packetBuffer[9]; ushort checksum = endianConverter.ToUInt16(packetBuffer, 10); string sourceAddress = String.Format("{0}.{1}.{2}.{3}", packetBuffer[12], packetBuffer[13], packetBuffer[14], packetBuffer[15]); string destinationAddress = String.Format("{0}.{1}.{2}.{3}", packetBuffer[16], packetBuffer[17], packetBuffer[18], packetBuffer[19]); byte[] payload = new byte[packetBuffer.Length - headerLength]; Array.Copy(packetBuffer, headerLength, payload, 0, payload.Length); DateTime packetTime = System.DateTime.Now; // add all these to the properties m_protocolProperties.Add("Version", version); m_protocolProperties.Add("HeaderLength", headerLength); m_protocolProperties.Add("Precedence", precedence); m_protocolProperties.Add("Delay", delay); m_protocolProperties.Add("Throughput", throughput); m_protocolProperties.Add("Reliability", reliability); m_protocolProperties.Add("TotalLength", totalLength); m_protocolProperties.Add("Identification", identification); m_protocolProperties.Add("TimeToLive", timeToLive); m_protocolProperties.Add("Protocol", protocol); m_protocolProperties.Add("Checksum", checksum); m_protocolProperties.Add("SourceAddress", sourceAddress); m_protocolProperties.Add("DestinationAddress", destinationAddress); m_protocolProperties.Add("Payload", payload); m_protocolProperties.Add("PacketTime", packetTime); m_protocolProperties.Add("PacketPayload", packetBuffer); }
public override void ProcessData(byte[] bufferData) { BigEndianConverter endianConverter = new BigEndianConverter(); byte type = bufferData[0]; byte code = bufferData[1]; int checksum = endianConverter.ToUInt16(bufferData, 2); m_protocolProperties.Add("Type", type); m_protocolProperties.Add("Code", code); m_protocolProperties.Add("Checksum", checksum); m_protocolProperties.Add("Payload", bufferData); }
public override void ProcessData(byte[] bufferData) { // The UDP protocol uses big-endian. BigEndianConverter endianConverter = new BigEndianConverter(); // Read the header information int sourcePort = endianConverter.ToUInt16(bufferData, 0); int destinationPort = endianConverter.ToUInt16(bufferData, 2); int length = endianConverter.ToUInt16(bufferData, 4); int checksum = endianConverter.ToUInt16(bufferData, 6); byte[] payload = new byte[length - 8]; // Copy the buffer Array.Copy(bufferData, 8, payload, 0, length - 8); // Add the properties m_protocolProperties.Add("SourcePort", sourcePort); m_protocolProperties.Add("DestinationPort", destinationPort); m_protocolProperties.Add("Length", length); m_protocolProperties.Add("Checksum", checksum); m_protocolProperties.Add("Payload", payload); }
public void SerializeBody(ReusableMemoryStream stream, object extra, Basics.ApiVersion version) { BigEndianConverter.Write(stream, RequiredAcks); BigEndianConverter.Write(stream, Timeout); Basics.WriteArray(stream, TopicsData, extra, version); }
public long ReadVersion() { var buffer = m_buffer.Array; return(BigEndianConverter.GetInt64(buffer, Offset.Version)); }
public void Serialize(ReusableMemoryStream stream, object _, Basics.ApiVersion __) { BigEndianConverter.Write(stream, Partition); BigEndianConverter.Write(stream, FetchOffset); BigEndianConverter.Write(stream, MaxBytes); }
public override void Parse(TimeSpan timeOffset, int mediaId, ArraySegment <byte> byteSegment, bool markerBit) { Debug.Assert(byteSegment.Array != null, "byteSegment.Array != null"); if (byteSegment.Count < JpegHeaderSize) { throw new MediaPayloadParserException("Input data size is smaller than JPEG header size"); } if (_previousTimeOffset != timeOffset && _frameStream.Position != 0) { _frameStream.Position = 0; } _previousTimeOffset = timeOffset; int offset = byteSegment.Offset + 1; int fragmentOffset = BigEndianConverter.ReadUInt24(byteSegment.Array, offset); offset += 3; int type = byteSegment.Array[offset++]; int q = byteSegment.Array[offset++]; int width = byteSegment.Array[offset++] * 8; int height = byteSegment.Array[offset++] * 8; int dri = 0; if (type > 63) { dri = BigEndianConverter.ReadUInt16(byteSegment.Array, offset); offset += 4; } if (fragmentOffset == 0) { if (_frameStream.Position != 0) { GenerateFrame(timeOffset, mediaId); } bool quantizationTablesChanged = false; if (q > 127) { int mbz = byteSegment.Array[offset]; if (mbz == 0) { _hasExternalQuantizationTable = true; int quantizationTablesLength = BigEndianConverter.ReadUInt16(byteSegment.Array, offset + 2); offset += 4; if (!ArrayUtils.IsBytesEquals(byteSegment.Array, offset, quantizationTablesLength, _quantizationTables, 0, _quantizationTablesLength)) { if (_quantizationTables.Length < quantizationTablesLength) { _quantizationTables = new byte[quantizationTablesLength]; } Buffer.BlockCopy(byteSegment.Array, offset, _quantizationTables, 0, quantizationTablesLength); _quantizationTablesLength = quantizationTablesLength; quantizationTablesChanged = true; } offset += quantizationTablesLength; } } if (quantizationTablesChanged || _currentType != type || _currentQ != q || _currentFrameWidth != width || _currentFrameHeight != height || _currentDri != dri) { _currentType = type; _currentQ = q; _currentFrameWidth = width; _currentFrameHeight = height; _currentDri = dri; ReInitializeJpegHeader(); } _frameStream.Write(_jpegHeaderBytesSegment.Array, _jpegHeaderBytesSegment.Offset, _jpegHeaderBytesSegment.Count); } if (fragmentOffset != 0 && _frameStream.Position == 0) { return; } int dataSize = byteSegment.Offset + byteSegment.Count - offset; if (dataSize < 0) { throw new MediaPayloadParserException($"Invalid payload size: {dataSize}"); } _frameStream.Write(byteSegment.Array, offset, dataSize); }
public FatHeader(byte[] buffer) { NumberOfArchitectures = BigEndianConverter.ToUInt32(buffer, 4); }
private static void Write(MemoryStream stream, PartitionData partition) { BigEndianConverter.Write(stream, partition.Partition); Write(stream, partition.Messages); }
public void Deserialize(ReusableMemoryStream stream, object noextra = null) { ErrorCode = (ErrorCode)BigEndianConverter.ReadInt16(stream); TopicName = Basics.DeserializeString(stream); Partitions = Basics.DeserializeArray <PartitionMeta>(stream); }
public void Deserialize(ReusableMemoryStream stream, object _, Basics.ApiVersion __) { ErrorCode = (ErrorCode)BigEndianConverter.ReadInt16(stream); }
public void Serialize(ReusableMemoryStream stream, object _, Basics.ApiVersion __) { BigEndianConverter.Write(stream, (short)ErrorCode); }
internal async Task CorrelateResponseLoop(TcpClient client, CancellationToken cancel) { try { _cancellation = cancel; _log.Debug("Starting reading loop from socket. {0}", _id); _etw.CorrelationStart(); var buff = new byte[16 * 1024]; while (client.Connected && !cancel.IsCancellationRequested) { try { // read message size //var buff = new byte[4]; _etw.CorrelationReadingMessageSize(); await ReadBuffer(client, buff, 4, cancel); if (cancel.IsCancellationRequested) { _log.Debug("Stopped reading from {0} because cancell requested", _id); return; } var size = BigEndianConverter.ToInt32(buff); _etw.CorrelationReadMessageSize(size); // TODO: size sanity check. What is the reasonable max size? //var body = new byte[size]; if (size > buff.Length) { buff = new byte[size]; } await ReadBuffer(client, buff, size, cancel); _etw.CorrelationReadBody(size); try { int correlationId = -1; // TODO: check read==size && read > 4 correlationId = BigEndianConverter.ToInt32(buff); _etw.CorrelationReceivedCorrelationId(correlationId); // find correlated action Action <byte[], int, Exception> handler; // TODO: if correlation id is not found, there is a chance of corrupt // connection. Maybe recycle the connection? if (!_corelationTable.TryRemove(correlationId, out handler)) { _log.Error("Unknown correlationId: " + correlationId); continue; } _etw.CorrelationExecutingHandler(); handler(buff, size, null); _etw.CorrelationExecutedHandler(); } catch (Exception ex) { var error = string.Format("Error with handling message. Message bytes:\n{0}\n", FormatBytes(buff, size)); _etw.CorrelationError(ex.Message + " " + error); _log.Error(ex, error); throw; } } catch (SocketException e) { // shorter version of socket exception, without stack trace dump _log.Info("CorrelationLoop socket exception. {0}. {1}", e.Message, _id); throw; } catch (ObjectDisposedException) { _log.Debug("CorrelationLoop socket exception. Object disposed. {0}", _id); throw; } catch (IOException) { _log.Info("CorrelationLoop IO exception. {0}", _id); throw; } catch (Exception e) { _log.Error(e, "CorrelateResponseLoop error. {0}", _id); throw; } } _log.Debug("Finished reading loop from socket. {0}", _id); EtwTrace.Log.CorrelationComplete(); } catch (Exception e) { _corelationTable.Values.ForEach(c => c(null, 0, e)); if (_onError != null && !cancel.IsCancellationRequested) // don't call back OnError if we were told to cancel { _onError(e); } if (!cancel.IsCancellationRequested) { throw; } } finally { _log.Debug("Finishing CorrelationLoop. Calling back error to clear waiters."); _corelationTable.Values.ForEach(c => c(null, 0, new CorrelationLoopException("Correlation loop closed. Request will never get a response.") { IsRequestedClose = cancel.IsCancellationRequested })); _log.Debug("Finished CorrelationLoop."); } }
public void ProcessCurrentBuffer(byte[] currentBuffer, StateObject state) { Socket clientSocket = state.ClientSocket; if (state.ConnectionBuffer.Length == 0) { state.ConnectionBuffer = currentBuffer; } else { byte[] oldConnectionBuffer = state.ConnectionBuffer; state.ConnectionBuffer = new byte[oldConnectionBuffer.Length + currentBuffer.Length]; Array.Copy(oldConnectionBuffer, state.ConnectionBuffer, oldConnectionBuffer.Length); Array.Copy(currentBuffer, 0, state.ConnectionBuffer, oldConnectionBuffer.Length, currentBuffer.Length); } // we now have all SMB message bytes received so far in state.ConnectionBuffer int bytesLeftInBuffer = state.ConnectionBuffer.Length; while (bytesLeftInBuffer >= 4) { // The packet is either Direct TCP transport packet (which is an NBT Session Message // Packet) or an NBT packet. int bufferOffset = state.ConnectionBuffer.Length - bytesLeftInBuffer; byte flags = ByteReader.ReadByte(state.ConnectionBuffer, bufferOffset + 1); int trailerLength = (flags & 0x01) << 16 | BigEndianConverter.ToUInt16(state.ConnectionBuffer, bufferOffset + 2); int packetLength = 4 + trailerLength; if (flags > 0x01) { #if DEBUG Log("[{0}] Invalid NBT flags", DateTime.Now.ToString("HH:mm:ss:ffff")); #endif state.ClientSocket.Close(); return; } if (packetLength > bytesLeftInBuffer) { break; } else { byte[] packetBytes = new byte[packetLength]; Array.Copy(state.ConnectionBuffer, bufferOffset, packetBytes, 0, packetLength); ProcessPacket(packetBytes, state); bytesLeftInBuffer -= packetLength; if (!clientSocket.Connected) { // Do not continue to process the buffer if the other side closed the connection return; } } } if (bytesLeftInBuffer > 0) { byte[] newReceiveBuffer = new byte[bytesLeftInBuffer]; Array.Copy(state.ConnectionBuffer, state.ConnectionBuffer.Length - bytesLeftInBuffer, newReceiveBuffer, 0, bytesLeftInBuffer); state.ConnectionBuffer = newReceiveBuffer; } else { state.ConnectionBuffer = new byte[0]; } }
private async Task ListenLoop() { TcpClient client = null; try { client = await _listener.AcceptTcpClientAsync(); while (!_cancel.IsCancellationRequested) { if (_mode == SimulationMode.SendError) { throw new SocketException((int)SocketError.ConnectionAborted); } var stream = client.GetStream(); var buffer = new byte[4]; int read = 0; while (read != buffer.Length) { read += await stream.ReadAsync(buffer, read, buffer.Length - read, _cancel.Token).ConfigureAwait(false); } if (_mode == SimulationMode.ReceiveError) { throw new SocketException((int)SocketError.ConnectionAborted); } int size = BigEndianConverter.ToInt32(buffer); buffer = new byte[size]; read = 0; while (read != buffer.Length) { read += await stream.ReadAsync(buffer, read, buffer.Length - read, _cancel.Token).ConfigureAwait(false); } if (buffer[4] == 0) { continue; } var sbuffer = new byte[4 + size - 1]; int correlation = BigEndianConverter.ToInt32(buffer); if (_mode == SimulationMode.CorrelationIdError) { correlation -= 723; } BigEndianConverter.Write(sbuffer, size - 1); BigEndianConverter.Write(sbuffer, correlation, 4); Array.Copy(buffer, 5, sbuffer, 8, buffer.Length - 5); await stream.WriteAsync(sbuffer, 0, sbuffer.Length, _cancel.Token).ConfigureAwait(false); } #if NET_CORE client.Dispose(); // Same behavior as Close() called Dispose() internally #else client.Close(); #endif } catch { if (client != null) #if NET_CORE { client.Dispose(); // Same behavior as Close() called Dispose() internally } #else { client.Close(); } #endif _listener.Stop(); } }
public LoginRequestPDU(byte[] buffer) : base(buffer) { Transit = Final; // the Transit bit replaces the Final bit Continue = (OpCodeSpecificHeader[0] & 0x40) != 0; CurrentStage = (byte)((OpCodeSpecificHeader[0] & 0x0C) >> 2); NextStage = (byte)(OpCodeSpecificHeader[0] & 0x03); VersionMax = OpCodeSpecificHeader[1]; VersionMin = OpCodeSpecificHeader[2]; ISID = (ulong)BigEndianConverter.ToUInt32(LUNOrOpCodeSpecific, 0) << 16 | BigEndianConverter.ToUInt16(LUNOrOpCodeSpecific, 4); TSIH = BigEndianConverter.ToUInt16(LUNOrOpCodeSpecific, 6); CID = BigEndianConverter.ToUInt16(OpCodeSpecific, 0); CmdSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 4); ExpStatSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 8); string parametersString = Encoding.ASCII.GetString(Data); LoginParameters = KeyValuePairUtils.GetKeyValuePairList(parametersString); }
public static DynamicDiskPartitionerResumeRecord FromBytes(byte[] buffer) { string signature = ByteReader.ReadAnsiString(buffer, 0, 8); byte recordRevision = ByteReader.ReadByte(buffer, 8); DynamicDiskPartitionerOperation operation = (DynamicDiskPartitionerOperation)BigEndianConverter.ToUInt16(buffer, 9); if (signature == ValidSignature && recordRevision == 1) { if (operation == DynamicDiskPartitionerOperation.AddDiskToArray) { return(new AddDiskOperationResumeRecord(buffer)); } else if (operation == DynamicDiskPartitionerOperation.MoveExtent) { return(new MoveExtentOperationResumeRecord(buffer)); } } return(null); }
// Used only in tests public void Serialize(ReusableMemoryStream stream, object noextra = null) { BigEndianConverter.Write(stream, (short)ErrorCode); Basics.SerializeString(stream, TopicName); Basics.WriteArray(stream, Partitions); }
public static uint GetRequiredAllocationLength(byte[] buffer) { uint listLength = BigEndianConverter.ToUInt32(buffer, 0); return(8 + listLength); }
public static bool IsCodeDirectory(byte[] buffer, int offset) { uint magic = BigEndianConverter.ToUInt32(buffer, offset + 0); return(magic == Signature); }
// Deserialize a message set to a sequence of messages. // This handles the "partial message allowed at end of message set" from Kafka brokers // and compressed message sets (the method recursively calls itself in this case and // flatten the result). The returned enumeration must be enumerated for deserialization // effectiveley occuring. // // A message set can contain a mix of v0 and v1 messages. // In the case of compressed messages, offsets are returned differently by brokers. // Messages inside compressed message v0 will have absolute offsets assigned. // Messages inside compressed message v1 will have relative offset assigned, starting // from 0. The wrapping compressed message itself is assigned the absolute offset of the last // message in the set. That means in this case we can only assign offsets after having decompressing // all messages. Lazy deserialization won't be so lazy anymore... private static IEnumerable <ResponseMessage> LazyDeserializeMessageSet(ReusableMemoryStream stream, int messageSetSize, Deserializers deserializers) { var remainingMessageSetBytes = messageSetSize; while (remainingMessageSetBytes > 0) { const int offsetSize = 8; const int msgsizeSize = 4; if (remainingMessageSetBytes < offsetSize + msgsizeSize) { // This is a partial message => skip to the end of the message set. // TODO: unit test this stream.Position += remainingMessageSetBytes; yield break; } var offset = BigEndianConverter.ReadInt64(stream); var messageSize = BigEndianConverter.ReadInt32(stream); remainingMessageSetBytes -= offsetSize + msgsizeSize; if (remainingMessageSetBytes < messageSize) { // This is a partial message => skip to the end of the message set. stream.Position += remainingMessageSetBytes; yield break; } // Message body var crc = BigEndianConverter.ReadInt32(stream); var crcStartPos = stream.Position; // crc is computed from this position var magic = stream.ReadByte(); if ((uint)magic > 1) { throw new UnsupportedMagicByteVersion((byte)magic); } var attributes = stream.ReadByte(); long timestamp = 0; if (magic == 1) { timestamp = BigEndianConverter.ReadInt64(stream); } // Check for compression var codec = (CompressionCodec)(attributes & 3); // Lowest 2 bits if (codec == CompressionCodec.None) { var msg = new ResponseMessage { Offset = offset, Message = new Message { Key = Basics.DeserializeByteArray(stream, deserializers.Item1), Value = Basics.DeserializeByteArray(stream, deserializers.Item2), TimeStamp = timestamp } }; CheckCrc(crc, stream, crcStartPos); yield return(msg); } else { // Key is null, read/check/skip if (BigEndianConverter.ReadInt32(stream) != -1) { throw new InvalidDataException("Compressed messages key should be null"); } // Uncompress var compressedLength = BigEndianConverter.ReadInt32(stream); var dataPos = stream.Position; stream.Position += compressedLength; CheckCrc(crc, stream, crcStartPos); using (var uncompressedStream = stream.Pool.Reserve()) { Uncompress(uncompressedStream, stream.GetBuffer(), (int)dataPos, compressedLength, codec); // Deserialize recursively if (magic == 0) // v0 message { foreach (var m in LazyDeserializeMessageSet(uncompressedStream, (int)uncompressedStream.Length, deserializers)) { // Flatten yield return(m); } } else // v1 message, we have to assign the absolute offsets { var innerMsgs = ResponseMessageListPool.Reserve(); // We need to deserialize all messages first, because the wrapper offset is the // offset of the last messe in the set, so wee need to know how many messages there are // before assigning offsets. innerMsgs.AddRange(LazyDeserializeMessageSet(uncompressedStream, (int)uncompressedStream.Length, deserializers)); var baseOffset = offset - innerMsgs.Count + 1; foreach (var msg in innerMsgs) { yield return (new ResponseMessage { Offset = msg.Offset + baseOffset, Message = msg.Message }); } ResponseMessageListPool.Release(innerMsgs); } } } remainingMessageSetBytes -= messageSize; } }
internal static bool IsFatHeader(byte[] buffer) { uint magic = BigEndianConverter.ToUInt32(buffer, 0); return(magic == FatSignature); }
public SessionPacket(byte[] buffer, int offset) { Type = (SessionPacketTypeName)ByteReader.ReadByte(buffer, offset + 0); TrailerLength = ByteReader.ReadByte(buffer, offset + 1) << 16 | BigEndianConverter.ToUInt16(buffer, offset + 2); Trailer = ByteReader.ReadBytes(buffer, offset + 4, TrailerLength); }
protected override void ReadOperationParameters(byte[] buffer, int offset) { VolumeGuid = BigEndianConverter.ToGuid(buffer, offset + 0); NumberOfCommittedSectors = BigEndianConverter.ToUInt64(buffer, offset + 16); }
public static int GetSessionPacketLength(byte[] buffer, int offset) { int trailerLength = ByteReader.ReadByte(buffer, offset + 1) << 16 | BigEndianConverter.ToUInt16(buffer, offset + 2); return(4 + trailerLength); }
// Used only in tests public void Deserialize(ReusableMemoryStream stream, object _, Basics.ApiVersion __) { Partition = BigEndianConverter.ReadInt32(stream); FetchOffset = BigEndianConverter.ReadInt64(stream); MaxBytes = BigEndianConverter.ReadInt32(stream); }
public SessionRetargetResponsePacket(byte[] buffer, int offset) : base(buffer, offset) { IPAddress = BigEndianConverter.ToUInt32(Trailer, offset + 0); Port = BigEndianConverter.ToUInt16(Trailer, offset + 4); }
public long ReadIncrement() { var buffer = m_buffer.Array; return(BigEndianConverter.GetInt64(buffer, Offset.EndOfHeader)); }
public static void WriteUInt24(byte[] buffer, int offset, uint value) { byte[] bytes = BigEndianConverter.GetBytes(value); Array.Copy(bytes, 1, buffer, offset, 3); }
public byte[] GetBytes() { byte[] buffer = new byte[96]; buffer[0] |= (byte)(PeripheralQualifier << 5); buffer[0] |= (byte)(PeripheralQualifier & 0x1F); if (RMB) { buffer[1] |= 0x80; } buffer[2] = Version; if (NormACA) { buffer[3] |= 0x20; } if (HiSup) { buffer[3] |= 0x10; } buffer[3] |= (byte)(ResponseDataFormat & 0x0F); buffer[4] = AdditionalLength; if (SCCS) { buffer[5] |= 0x80; } if (ACC) { buffer[5] |= 0x40; } buffer[5] |= (byte)((TPGS & 0x03) << 4); if (ThirdPartyCopy) { buffer[5] |= 0x08; } if (Protect) { buffer[5] |= 0x01; } if (EncServ) { buffer[6] |= 0x40; } if (VS1) { buffer[6] |= 0x20; } if (MultiP) { buffer[6] |= 0x10; } if (MChngr) { buffer[6] |= 0x08; } if (Addr16) { buffer[6] |= 0x01; } if (WBus16) { buffer[7] |= 0x20; } if (Sync) { buffer[7] |= 0x10; } if (CmdQue) { buffer[7] |= 0x02; } if (VS2) { buffer[7] |= 0x01; } Array.Copy(ASCIIEncoding.ASCII.GetBytes(VendorIdentification), 0, buffer, 8, Math.Min(VendorIdentification.Length, 8)); Array.Copy(ASCIIEncoding.ASCII.GetBytes(ProductIdentification), 0, buffer, 16, Math.Min(ProductIdentification.Length, 16)); Array.Copy(ASCIIEncoding.ASCII.GetBytes(ProductRevisionLevel), 0, buffer, 32, 4); Array.Copy(BigEndianConverter.GetBytes(DriveSerialNumber), 0, buffer, 36, 8); buffer[56] |= (byte)((Clocking & 0x03) << 2); if (QAS) { buffer[56] |= 0x02; } if (IUS) { buffer[56] |= 0x01; } for (int index = 0; index < 8; index++) { ushort versionDescriptor = 0; if (index < VersionDescriptors.Count) { versionDescriptor = VersionDescriptors[index]; } BigEndianWriter.WriteUInt16(buffer, 58 + index * 2, versionDescriptor); } return(buffer); }
public void Deserialize(ReusableMemoryStream stream, object noextra = null) { Id = BigEndianConverter.ReadInt32(stream); Host = Basics.DeserializeString(stream); Port = BigEndianConverter.ReadInt32(stream); }
// Used only in tests public void Serialize(ReusableMemoryStream stream, object noextra = null) { BigEndianConverter.Write(stream, Id); Basics.SerializeString(stream, Host); BigEndianConverter.Write(stream, Port); }
public ReadCapacity10Parameter(byte[] buffer) { ReturnedLBA = BigEndianConverter.ToUInt32(buffer, 0); BlockLengthInBytes = BigEndianConverter.ToUInt32(buffer, 4); }