private bool NegotiateNTLanManagerDialect() { if (m_transport == SMBTransportType.NetBiosOverTCP) { SessionRequestPacket sessionRequest = new SessionRequestPacket(); sessionRequest.CalledName = NetBiosUtils.GetMSNetBiosName("*SMBSERVER", NetBiosSuffix.FileServiceService);; sessionRequest.CallingName = NetBiosUtils.GetMSNetBiosName(Environment.MachineName, NetBiosSuffix.WorkstationService); TrySendPacket(m_clientSocket, sessionRequest); } NegotiateRequest request = new NegotiateRequest(); request.Dialects.Add(NTLanManagerDialect); TrySendMessage(m_clientSocket, request); SMB1Message reply = WaitForMessage(CommandName.SMB_COM_NEGOTIATE); if (reply == null) { return(false); } if (reply.Commands[0] is NegotiateResponse) { NegotiateResponse response = (NegotiateResponse)reply.Commands[0]; return(true); } else if (reply.Commands[0] is NegotiateResponseExtended) { NegotiateResponseExtended response = (NegotiateResponseExtended)reply.Commands[0]; return(true); } else { return(false); } }
private bool NegotiateDialect() { NegotiateRequest request = new NegotiateRequest(); request.SecurityMode = SecurityMode.SigningEnabled; request.ClientGuid = Guid.NewGuid(); request.ClientStartTime = DateTime.Now; request.Dialects.Add(SMB2Dialect.SMB202); request.Dialects.Add(SMB2Dialect.SMB210); TrySendCommand(request); NegotiateResponse response = WaitForCommand(SMB2CommandName.Negotiate) as NegotiateResponse; if (response != null && response.Header.Status == NTStatus.STATUS_SUCCESS) { m_dialect = response.DialectRevision; m_signingRequired = (response.SecurityMode & SecurityMode.SigningRequired) > 0; m_maxTransactSize = Math.Min(response.MaxTransactSize, ClientMaxTransactSize); m_maxReadSize = Math.Min(response.MaxReadSize, ClientMaxReadSize); m_maxWriteSize = Math.Min(response.MaxWriteSize, ClientMaxWriteSize); m_securityBlob = response.SecurityBuffer; return(true); } return(false); }
internal static NegotiateResponse GetNegotiateResponse(SMB1Header header, NegotiateRequest request, GSSProvider securityProvider, ConnectionState state) { NegotiateResponse response = new NegotiateResponse(); response.DialectIndex = (ushort)request.Dialects.IndexOf(SMBServer.NTLanManagerDialect); response.SecurityMode = SecurityMode.UserSecurityMode | SecurityMode.EncryptPasswords; response.MaxMpxCount = 50; response.MaxNumberVcs = 1; response.MaxBufferSize = 16644; response.MaxRawSize = 65536; response.Capabilities = ServerCapabilities.Unicode | ServerCapabilities.LargeFiles | ServerCapabilities.NTSMB | ServerCapabilities.NTStatusCode | ServerCapabilities.NTFind | ServerCapabilities.LargeRead | ServerCapabilities.LargeWrite; response.SystemTime = DateTime.UtcNow; response.ServerTimeZone = (short)-TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes; NegotiateMessage negotiateMessage = CreateNegotiateMessage(); ChallengeMessage challengeMessage; NTStatus status = securityProvider.GetNTLMChallengeMessage(out state.AuthenticationContext, negotiateMessage, out challengeMessage); if (status == NTStatus.SEC_I_CONTINUE_NEEDED) { response.Challenge = challengeMessage.ServerChallenge; } response.DomainName = String.Empty; response.ServerName = String.Empty; return(response); }
internal static SMB2Command GetNegotiateResponse(NegotiateRequest request, GSSProvider securityProvider, ConnectionState state, Guid serverGuid, DateTime serverStartTime) { NegotiateResponse response = new NegotiateResponse(); if (request.Dialects.Contains(SMB2Dialect.SMB210)) { state.Dialect = SMBDialect.SMB210; response.DialectRevision = SMB2Dialect.SMB210; } else if (request.Dialects.Contains(SMB2Dialect.SMB202)) { state.Dialect = SMBDialect.SMB202; response.DialectRevision = SMB2Dialect.SMB202; } else { return(new ErrorResponse(request.CommandName, NTStatus.STATUS_NOT_SUPPORTED)); } response.SecurityMode = SecurityMode.SigningEnabled; response.ServerGuid = serverGuid; response.MaxTransactSize = 65536; response.MaxReadSize = 65536; response.MaxWriteSize = 65536; response.SystemTime = DateTime.Now; response.ServerStartTime = serverStartTime; response.SecurityBuffer = securityProvider.GetSPNEGOTokenInitBytes(); return(response); }
// Special case - SMB2 client initially connecting using SMB1 internal static SMB2Command GetNegotiateResponse(List <string> smb2Dialects, GSSProvider securityProvider, ConnectionState state, Guid serverGuid, DateTime serverStartTime) { NegotiateResponse response = new NegotiateResponse(); response.Header.Credits = 1; if (smb2Dialects.Contains(SMB2xxxDialect)) { response.DialectRevision = SMB2Dialect.SMB2xx; } else if (smb2Dialects.Contains(SMB2002Dialect)) { state.Dialect = SMBDialect.SMB202; response.DialectRevision = SMB2Dialect.SMB202; } else { throw new ArgumentException("SMB2 dialect is not present"); } response.SecurityMode = SecurityMode.SigningEnabled; response.ServerGuid = serverGuid; response.MaxTransactSize = 65536; response.MaxReadSize = 65536; response.MaxWriteSize = 65536; response.SystemTime = DateTime.Now; response.ServerStartTime = serverStartTime; response.SecurityBuffer = securityProvider.GetSPNEGOTokenInitBytes(); return(response); }
static byte[] GenerateNewOrderSingle() { // This byte array is used for encoding and decoding, this is what you would send on the wire or save to disk var byteBuffer = new byte[4096]; // You need to "wrap" the array with a DirectBuffer, this class is used by the generated code to read and write efficiently to the underlying byte array var directBuffer = new DirectBuffer(byteBuffer); int bufferOffset = 0; var MessageHeader = new SbeFIX.MessageHeader(); var sno = new NegotiateResponse(); // Before encoding a message we need to create a SBE header which specify what we are going to encode (this will allow the decoder to detect that it's an encoded 'car' object) // We will probably simplify this part soon, so the header gets applied automatically, but for now it's manual MessageHeader.Wrap(directBuffer, bufferOffset, NegotiateResponse.SchemaVersion); // position the MessageHeader on the DirectBuffer, at the correct position MessageHeader.BlockLength = NegotiateResponse.BlockLength; // size that a car takes on the wire MessageHeader.SchemaId = NegotiateResponse.SchemaId; MessageHeader.TemplateId = NegotiateResponse.TemplateId; // identifier for the car object (SBE template ID) MessageHeader.Version = NegotiateResponse.SchemaVersion; // this can be overriden if we want to support different versions of the car object (advanced functionality) // Now that we have encoded the header in the byte array we can encode the car object itself bufferOffset += SbeFIX.MessageHeader.Size; int carLength = NewOrderSingleExample.Encode(sno, directBuffer, bufferOffset); var byteBuffer2 = new byte[carLength]; directBuffer.GetBytes(0, byteBuffer2, 0, carLength); return(byteBuffer2); }
private bool NegotiateDialect(bool forceExtendedSecurity) { if (m_transport == SMBTransportType.NetBiosOverTCP) { SessionRequestPacket sessionRequest = new SessionRequestPacket(); sessionRequest.CalledName = NetBiosUtils.GetMSNetBiosName("*SMBSERVER", NetBiosSuffix.FileServiceService);; sessionRequest.CallingName = NetBiosUtils.GetMSNetBiosName(Environment.MachineName, NetBiosSuffix.WorkstationService); TrySendPacket(m_clientSocket, sessionRequest); } NegotiateRequest request = new NegotiateRequest(); request.Dialects.Add(NTLanManagerDialect); TrySendMessage(request); SMB1Message reply = WaitForMessage(CommandName.SMB_COM_NEGOTIATE); if (reply == null) { return(false); } if (reply.Commands[0] is NegotiateResponse && !forceExtendedSecurity) { NegotiateResponse response = (NegotiateResponse)reply.Commands[0]; m_unicode = ((response.Capabilities & Capabilities.Unicode) > 0); m_largeFiles = ((response.Capabilities & Capabilities.LargeFiles) > 0); bool ntSMB = ((response.Capabilities & Capabilities.NTSMB) > 0); bool rpc = ((response.Capabilities & Capabilities.RpcRemoteApi) > 0); bool ntStatusCode = ((response.Capabilities & Capabilities.NTStatusCode) > 0); m_infoLevelPassthrough = ((response.Capabilities & Capabilities.InfoLevelPassthrough) > 0); m_largeRead = ((response.Capabilities & Capabilities.LargeRead) > 0); m_largeWrite = ((response.Capabilities & Capabilities.LargeWrite) > 0); m_serverMaxBufferSize = response.MaxBufferSize; m_maxMpxCount = Math.Min(response.MaxMpxCount, ClientMaxMpxCount); m_serverChallenge = response.Challenge; return(ntSMB && rpc && ntStatusCode); } else if (reply.Commands[0] is NegotiateResponseExtended) { NegotiateResponseExtended response = (NegotiateResponseExtended)reply.Commands[0]; m_unicode = ((response.Capabilities & Capabilities.Unicode) > 0); m_largeFiles = ((response.Capabilities & Capabilities.LargeFiles) > 0); bool ntSMB = ((response.Capabilities & Capabilities.NTSMB) > 0); bool rpc = ((response.Capabilities & Capabilities.RpcRemoteApi) > 0); bool ntStatusCode = ((response.Capabilities & Capabilities.NTStatusCode) > 0); m_infoLevelPassthrough = ((response.Capabilities & Capabilities.InfoLevelPassthrough) > 0); m_largeRead = ((response.Capabilities & Capabilities.LargeRead) > 0); m_largeWrite = ((response.Capabilities & Capabilities.LargeWrite) > 0); m_serverMaxBufferSize = response.MaxBufferSize; m_maxMpxCount = Math.Min(response.MaxMpxCount, ClientMaxMpxCount); m_securityBlob = response.SecurityBlob; return(ntSMB && rpc && ntStatusCode); } else { return(false); } }
protected NegotiateResponse GetNegotiationResponse(string response, out NegotiateResponse negotiateResponse) { if (String.IsNullOrEmpty(response)) { return(negotiateResponse = null); } negotiateResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <NegotiateResponse>(response); return(negotiateResponse); }
private bool NegotiateDialect(bool forceExtendedSecurity) { NegotiateRequest request = new NegotiateRequest(); request.Dialects.Add(NTLanManagerDialect); TrySendMessage(request); SMB1Message reply = WaitForMessage(CommandName.SMB_COM_NEGOTIATE); if (reply == null) { return(false); } if (reply.Commands[0] is NegotiateResponse && !forceExtendedSecurity) { NegotiateResponse response = (NegotiateResponse)reply.Commands[0]; Domainname = response.DomainName; Hostname = response.ServerName; m_unicode = ((response.Capabilities & Capabilities.Unicode) > 0); m_largeFiles = ((response.Capabilities & Capabilities.LargeFiles) > 0); bool ntSMB = ((response.Capabilities & Capabilities.NTSMB) > 0); bool rpc = ((response.Capabilities & Capabilities.RpcRemoteApi) > 0); bool ntStatusCode = ((response.Capabilities & Capabilities.NTStatusCode) > 0); m_infoLevelPassthrough = ((response.Capabilities & Capabilities.InfoLevelPassthrough) > 0); m_largeRead = ((response.Capabilities & Capabilities.LargeRead) > 0); m_largeWrite = ((response.Capabilities & Capabilities.LargeWrite) > 0); m_serverMaxBufferSize = response.MaxBufferSize; m_maxMpxCount = Math.Min(response.MaxMpxCount, ClientMaxMpxCount); m_serverChallenge = response.Challenge; return(ntSMB && rpc && ntStatusCode); } else if (reply.Commands[0] is NegotiateResponseExtended) { NegotiateResponseExtended response = (NegotiateResponseExtended)reply.Commands[0]; m_unicode = ((response.Capabilities & Capabilities.Unicode) > 0); m_largeFiles = ((response.Capabilities & Capabilities.LargeFiles) > 0); bool ntSMB = ((response.Capabilities & Capabilities.NTSMB) > 0); bool rpc = ((response.Capabilities & Capabilities.RpcRemoteApi) > 0); bool ntStatusCode = ((response.Capabilities & Capabilities.NTStatusCode) > 0); m_infoLevelPassthrough = ((response.Capabilities & Capabilities.InfoLevelPassthrough) > 0); m_largeRead = ((response.Capabilities & Capabilities.LargeRead) > 0); m_largeWrite = ((response.Capabilities & Capabilities.LargeWrite) > 0); m_serverMaxBufferSize = response.MaxBufferSize; m_maxMpxCount = Math.Min(response.MaxMpxCount, ClientMaxMpxCount); m_securityBlob = response.SecurityBlob; return(ntSMB && rpc && ntStatusCode); } else { return(false); } }
internal static SMB2Command GetNegotiateResponse(NegotiateRequest request, GSSProvider securityProvider, ConnectionState state, SMBTransportType transportType, Guid serverGuid, DateTime serverStartTime, bool enableSMB3) { NegotiateResponse response = new NegotiateResponse(); if (enableSMB3 && request.Dialects.Contains(SMB2Dialect.SMB300)) { state.Dialect = SMBDialect.SMB300; response.DialectRevision = SMB2Dialect.SMB300; } else if (request.Dialects.Contains(SMB2Dialect.SMB210)) { state.Dialect = SMBDialect.SMB210; response.DialectRevision = SMB2Dialect.SMB210; } else if (request.Dialects.Contains(SMB2Dialect.SMB202)) { state.Dialect = SMBDialect.SMB202; response.DialectRevision = SMB2Dialect.SMB202; } else { state.LogToServer(Severity.Verbose, "Negotiate failure: None of the requested SMB2 dialects is supported"); return(new ErrorResponse(request.CommandName, NTStatus.STATUS_NOT_SUPPORTED)); } response.SecurityMode = SecurityMode.SigningEnabled; response.ServerGuid = serverGuid; if (state.Dialect != SMBDialect.SMB202 && transportType == SMBTransportType.DirectTCPTransport) { response.Capabilities = Capabilities.LargeMTU; response.MaxTransactSize = ServerMaxTransactSizeLargeMTU; response.MaxReadSize = ServerMaxReadSizeLargeMTU; response.MaxWriteSize = ServerMaxWriteSizeLargeMTU; // [MS-SMB2] 3.3.5.2 Receiving Any Message - If the length of the message exceeds Connection.MaxTransactSize + 256, the server MUST disconnect the connection. int maxPacketSize = SessionPacket.HeaderLength + (int)ServerMaxTransactSizeLargeMTU + 256; if (maxPacketSize > state.ReceiveBuffer.Buffer.Length) { state.ReceiveBuffer.IncreaseBufferSize(maxPacketSize); } } else { response.MaxTransactSize = ServerMaxTransactSize; response.MaxReadSize = ServerMaxReadSize; response.MaxWriteSize = ServerMaxWriteSize; } response.SystemTime = DateTime.Now; response.ServerStartTime = serverStartTime; response.SecurityBuffer = securityProvider.GetSPNEGOTokenInitBytes(); return(response); }
// Special case - SMB2 client initially connecting using SMB1 internal static SMB2Command GetNegotiateResponse(List <string> smb2Dialects, GSSProvider securityProvider, ConnectionState state, SMBTransportType transportType, Guid serverGuid, DateTime serverStartTime) { NegotiateResponse response = new NegotiateResponse(); response.Header.Credits = 1; if (smb2Dialects.Contains(SMB2xxxDialect)) { response.DialectRevision = SMB2Dialect.SMB2xx; } else if (smb2Dialects.Contains(SMB2002Dialect)) { state.Dialect = SMBDialect.SMB202; response.DialectRevision = SMB2Dialect.SMB202; } else { throw new ArgumentException("SMB2 dialect is not present"); } response.SecurityMode = SecurityMode.SigningEnabled; response.ServerGuid = serverGuid; if (state.Dialect != SMBDialect.SMB202 && transportType == SMBTransportType.DirectTCPTransport) { response.Capabilities = Capabilities.LargeMTU; response.MaxTransactSize = ServerMaxTransactSizeLargeMTU; response.MaxReadSize = ServerMaxReadSizeLargeMTU; response.MaxWriteSize = ServerMaxWriteSizeLargeMTU; // [MS-SMB2] 3.3.5.2 Receiving Any Message - If the length of the message exceeds Connection.MaxTransactSize + 256, the server MUST disconnect the connection. int maxPacketSize = SessionPacket.HeaderLength + (int)ServerMaxTransactSizeLargeMTU + 256; if (maxPacketSize > state.ReceiveBuffer.Buffer.Length) { state.ReceiveBuffer.IncreaseBufferSize(maxPacketSize); } } else { response.MaxTransactSize = ServerMaxTransactSize; response.MaxReadSize = ServerMaxReadSize; response.MaxWriteSize = ServerMaxWriteSize; } response.SystemTime = DateTime.Now; response.ServerStartTime = serverStartTime; response.SecurityBuffer = securityProvider.GetSPNEGOTokenInitBytes(); return(response); }
public static SMB2Body CreateSMB2Body(byte[] vs, int offset, ESMB2Command eSMB2Command, SMB2HeaderFlags smb2HeaderFlags, NTStateType ntState) { SMB2Body sMB2Body = null; if (smb2HeaderFlags.HasFlag(SMB2HeaderFlags.ServerToRedir)) { if (ntState == NTStateType.Success || ntState == NTStateType.MoreProcessingRequired || ntState == NTStateType.LogonFailure) { switch (eSMB2Command) { case ESMB2Command.NEGOTIATE: sMB2Body = NegotiateResponse.Parser(vs, offset); break; case ESMB2Command.SESSION_SETUP: sMB2Body = SessionSetupResponse.Parser(vs, offset); break; case ESMB2Command.TREE_CONNECT: sMB2Body = TreeConnectResponse.Parser(vs, offset); break; case ESMB2Command.LOGOFF: case ESMB2Command.TREE_DISCONNECT: sMB2Body = LogoffAndTreeDisconnect.Parser(vs, offset); break; case ESMB2Command.CREATE: sMB2Body = CreateResponse.Parser(vs, offset); break; case ESMB2Command.CLOSE: sMB2Body = CloseResponse.Parser(vs, offset); break; case ESMB2Command.WRITE: sMB2Body = WriteResponse.Parser(vs, offset); break; case ESMB2Command.READ: sMB2Body = ReadResponse.Parser(vs, offset); break; case ESMB2Command.IOCTL: sMB2Body = IOCTLResponse.Parser(vs, offset); break; default: throw new Exception("UnKnow SMB2 Command"); } } else { sMB2Body = ErrorResponse.Parser(vs, offset); } } else { throw new NotImplementedException(); } return(sMB2Body); }
private Task <NegotiateResponse> ProcessNegotiationRequest(HostContext context) { // Total amount of time without a keep alive before the client should attempt to reconnect in seconds. var keepAliveTimeout = _configurationManager.KeepAliveTimeout(); string connectionId = Guid.NewGuid().ToString("d"); string connectionToken = connectionId + ':' + GetUserIdentity(context); var response = new NegotiateResponse(context.Request.LocalPath.Replace("/negotiate", ""), ProtectedData.Protect(connectionToken, Purposes.ConnectionToken), connectionId, keepAliveTimeout?.TotalSeconds, _configurationManager.DisconnectTimeout.TotalSeconds, _configurationManager.ConnectionTimeout.TotalSeconds, _transportManager.SupportsTransport(WebSocketsTransportName) && context.Environment.SupportsWebSockets(), _protocolResolver.Resolve(context.Request).ToString(), _configurationManager.TransportConnectTimeout.TotalSeconds, _configurationManager.LongPollDelay.TotalSeconds); return(SendJsonResponse(context, JsonSerializer.Stringify(response)).ContinueWith(t => response)); }
public Task <NegotiateResponse> Negotiate(IConnection connection) { var _reqeust = WebRequest.Create(connection.Url + GetUrl(ConnectionType.Connect)); NegotiateResponse negotiateResponse = null; using (HttpWebResponse resp = (HttpWebResponse)_reqeust.GetResponse()) { HttpStatusCode status = resp.StatusCode; if (status == HttpStatusCode.OK) { Stream respStream = resp.GetResponseStream(); using (StreamReader sr = new StreamReader(respStream)) { GetNegotiationResponse(sr.ReadToEnd(), out negotiateResponse); } } } if (negotiateResponse == null) { throw new Exception("Connect Error"); } return(Task.FromResult(negotiateResponse)); }
private void ProcessPacket(SessionPacket packet, ConnectionState state) { if (packet is SessionMessagePacket) { SMB2Command command; try { command = SMB2Command.ReadResponse(packet.Trailer, 0); } catch (Exception ex) { Log("Invalid SMB2 response: " + ex.Message); state.ClientSocket.Close(); m_isConnected = false; return; } m_availableCredits += command.Header.Credits; if (m_transport == SMBTransportType.DirectTCPTransport && command is NegotiateResponse) { NegotiateResponse negotiateResponse = (NegotiateResponse)command; if ((negotiateResponse.Capabilities & Capabilities.LargeMTU) > 0) { // [MS-SMB2] 3.2.5.1 Receiving Any Message - If the message size received exceeds Connection.MaxTransactSize, the client MUST disconnect the connection. // Note: Windows clients do not enforce the MaxTransactSize value, we add 256 bytes. int maxPacketSize = SessionPacket.HeaderLength + (int)Math.Min(negotiateResponse.MaxTransactSize, ClientMaxTransactSize) + 256; if (maxPacketSize > state.ReceiveBuffer.Buffer.Length) { state.ReceiveBuffer.IncreaseBufferSize(maxPacketSize); } } } // [MS-SMB2] 3.2.5.1.2 - If the MessageId is 0xFFFFFFFFFFFFFFFF, this is not a reply to a previous request, // and the client MUST NOT attempt to locate the request, but instead process it as follows: // If the command field in the SMB2 header is SMB2 OPLOCK_BREAK, it MUST be processed as specified in 3.2.5.19. // Otherwise, the response MUST be discarded as invalid. if (command.Header.MessageID != 0xFFFFFFFFFFFFFFFF || command.Header.Command == SMB2CommandName.OplockBreak) { lock (m_incomingQueueLock) { m_incomingQueue.Add(command); m_incomingQueueEventHandle.Set(); } } } else if ((packet is PositiveSessionResponsePacket || packet is NegativeSessionResponsePacket) && m_transport == SMBTransportType.NetBiosOverTCP) { m_sessionResponsePacket = packet; m_sessionResponseEventHandle.Set(); } else if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP) { // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer } else { Log("Inappropriate NetBIOS session packet"); state.ClientSocket.Close(); } }
static void Main(string[] args) { TcpListener server = null; try { // Set the TcpListener on port 13000. Int32 port = 13000; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); // TcpListener server = new TcpListener(port); server = new TcpListener(localAddr, port); // Start listening for client requests. server.Start(); // Buffer for reading data Byte[] bytes = new Byte[256]; // Enter the listening loop. while (true) { Console.Write("Waiting for a connection... "); // Perform a blocking call to accept requests. // You could also user server.AcceptSocket() here. TcpClient client = server.AcceptTcpClient(); Console.WriteLine("Connected!"); // Get a stream object for reading and writing NetworkStream stream = client.GetStream(); int i; // Loop to receive all the data sent by the client. while ((i = stream.Read(bytes, 0, bytes.Length)) != 0) { var byteBuffer = new byte[4096]; // You need to "wrap" the array with a DirectBuffer, this class is used by the generated code to read and write efficiently to the underlying byte array var directBuffer = new DirectBuffer(bytes); int bufferOffset = 0; const short SchemaVersion = 0; string type = "qatsbeengine"; switch (type) { #region car case "car": var MessageHeader = new Sbe.MessageHeader(); var Car = new Sbe.Car(); // position the MessageHeader object at the beginning of the array MessageHeader.Wrap(directBuffer, bufferOffset, SchemaVersion); Console.WriteLine("MessageHeader.BlockLength=" + MessageHeader.BlockLength); Console.WriteLine("MessageHeader.TemplateId=" + MessageHeader.TemplateId); Console.WriteLine("MessageHeader.SchemaId=" + MessageHeader.SchemaId); Console.WriteLine("MessageHeader.Version=" + MessageHeader.Version); // Extract info from the header // In a real app you would use that to lookup the applicable flyweight to decode this type of message based on templateId and version. int actingBlockLength = MessageHeader.BlockLength; int actingVersion = MessageHeader.Version; bufferOffset += Sbe.MessageHeader.Size; // now we decode the message CarExample.Decode(Car, directBuffer, bufferOffset, actingBlockLength, actingVersion); break; #endregion case "fix": var MessageHeaderFix = new SbeFIX.MessageHeader(); var sno = new NegotiateResponse(); // position the MessageHeader object at the beginning of the array MessageHeaderFix.Wrap(directBuffer, bufferOffset, SchemaVersion); Console.WriteLine("MessageHeader.BlockLength=" + MessageHeaderFix.BlockLength); Console.WriteLine("MessageHeader.TemplateId=" + MessageHeaderFix.TemplateId); Console.WriteLine("MessageHeader.SchemaId=" + MessageHeaderFix.SchemaId); Console.WriteLine("MessageHeader.Version=" + MessageHeaderFix.Version); // Extract info from the header // In a real app you would use that to lookup the applicable flyweight to decode this type of message based on templateId and version. int actingBlockLengthFix = MessageHeaderFix.BlockLength; int actingVersionFix = MessageHeaderFix.Version; bufferOffset += SbeFIX.MessageHeader.Size; // now we decode the message NewOrderSingleExample.Decode(sno, directBuffer, bufferOffset, actingBlockLengthFix, actingVersionFix); break; case "qatsbeengine": try { SbeReflectionWrapper _Wrapper = new SBEReflection.SbeReflectionWrapper(); SbeLoader.Load(@"C:\Users\Akio\source\repos\POC_SBE\packages\sbe-tool.1.17.0\tools\fixp-entrypoint-messages-1.2.xml"); Console.WriteLine(_Wrapper.DecodeSBEMessageQATEngine(bytes)); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "reflection": try { SbeReflectionWrapper _Wrapper = new SBEReflection.SbeReflectionWrapper(@"C:\Users\Akio\source\repos\POC_SBE\fixp-entrypoint-messages-1.2\bin\Debug\fixp-entrypoint-messages-1.2.dll"); SbeLoader.Load(@"C:\Users\Akio\source\repos\POC_SBE\packages\sbe-tool.1.17.0\tools\fixp-entrypoint-messages-1.2.xml"); Console.WriteLine(_Wrapper.DecodeSBEMessage(bytes)); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; } } // Shutdown and end connection client.Close(); } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. server.Stop(); } Console.WriteLine("\nHit enter to continue..."); Console.Read(); }