/// <summary> ///Creates a Generic Stream object with user supplied callbacks. This is the most complex way of using ///a GenericStream and will require the user to implement more of the functionality normally handled by ///the standard callbacks. In particular Marker Support will require the user to make their transfer ///method "rewindable" for up to 100MB of previously transferred data. See API Guide: FPStream_CreateGenericStream ///See API Guide: FPStream_CreateGenericStream /// ///@param direction Indicator for the type of GenericStream that is to be created i.e. input to /// Centera or output from Centera. ///@param userCBS Callbacks provided by the user. Typically the derived class will only /// require to override PopulateBuffer and / or ProcessReturnedData. ///@param userData An IntPtr which can be used to reference a user object that may be required /// when working with the input or output data buffer. /// </summary> public FPGenericStream(StreamDirection direction, FPStreamCallbacks userCBS, IntPtr userData) { prepare = new FPCallback(userCBS.PrepareBuffer); complete = new FPCallback(userCBS.BlockTransferred); mark = new FPCallback(userCBS.SetMark); reset = new FPCallback(userCBS.ResetMark); close = new FPCallback(userCBS.TransferComplete); if (direction == StreamDirection.InputToCentera) { theStream = SDK.FPStream_CreateGenericStream(prepare, complete, mark, reset, close, userData); } else { theStream = SDK.FPStream_CreateGenericStream(null, complete, mark, reset, close, userData); } AddObject(theStream, this); userCBS.StreamRef = theStream; userStream = userCBS.userStream; unsafe { theInfo = SDK.FPStream_GetInfo(theStream); theInfo->mAtEOF = 0; theInfo->mStreamLen = -1; theInfo->mTransferLen = 0; theInfo->mStreamPos = 0; theInfo->mMarkerPos = 0; theInfo->mBuffer = null; theInfo->mReadFlag = (byte)direction; } }
/// <summary> /// Process any JSON source file paths. /// </summary> /// <param name="currentNode"> /// The current json node. /// </param> private void ProcessJsonFilePaths(JToken currentNode, StreamDirection direction) { if (currentNode != null) { if (currentNode.Type == JTokenType.Property) { var prop = currentNode as JProperty; // Attempt to process any source.path nodes to correct to the original source location. if (prop.Name == "path" && prop.Parent.Path.EndsWith("source")) { string sourceValue = prop.Value.ToString(); prop.Value = JValue.CreateString(ApplyPathUpdate(sourceValue, direction)); } } foreach (var child in currentNode.Children()) { if (child.HasValues) { ProcessJsonFilePaths(child, direction); } } } }
private FPWideFilenameStream(string filename, StreamDirection direction, FileMode mode) : base(File.Open(filename, mode), direction, new IntPtr()) { if (direction == StreamDirection.InputToCentera) { StreamLen = userStream.Length; } }
/// <summary> ///Create a Stream using a buffer to write to (StreamType.InputToCentera) ///or read from (StreamType.OutputFromCentera) the Centera. ///See API Guide: FPStream_CreateBufferForInput, FPStream_CreateBufferForOutput /// ///@param streamBuffer The buffer that the Stream will read from (for INPUT to the Centera) /// or write to (for OUTPUT from the Centera). ///@param bufferSize The size of the buffer. ///@param streamDirection The StreamDirection enum indicating input or output. /// </summary> public FPStream(IntPtr streamBuffer, int bufferSize, StreamDirection streamDirection) { this.theStream = streamDirection == StreamDirection.InputToCentera ? Native.Stream.CreateBufferForInput(streamBuffer, bufferSize) : Native.Stream.CreateBufferForOutput(streamBuffer, bufferSize); this.AddObject(this.theStream, this); }
/// <summary> /// Default constructor. /// </summary> /// <param name="sourceStream"> /// The source stream to write to. /// </param> /// <param name="direction"> /// The direction events are sent. /// </param> /// <param name="modifiers"> /// The Json modifiers to execute. /// </param> public PathRenameStream(Stream sourceStream, StreamDirection direction, IList <IJsonModifier> modifiers) { SourceStream = sourceStream; Direction = direction; if (modifiers != null) { Modifiers = modifiers; } }
/// <summary> /// Create a new <see cref="ProgressStream"/> that wraps the specified inner <see cref="Stream"/>. /// </summary> /// <param name="innerStream"> /// The inner stream. /// </param> /// <param name="streamDirection"> /// The direction in which the stream's data is expected to flow. /// </param> /// <param name="ownsStream"> /// Should the <see cref="ProgressStream"/> close the inner stream when it is closed? /// </param> public ProgressStream(Stream innerStream, StreamDirection streamDirection, bool ownsStream) : this(innerStream, streamDirection, ownsStream, DefaultSink.Int64()) { if (_innerStream.CanSeek) { _sink.Total = _innerStream.Length; // AF: What about position? } }
public static extern IntPtr pa_simple_new( string?server, //const char * server string name, //const char * name StreamDirection direction, // pa_stream_direction_t dir, string?dev, // const char * dev, string streamName, //const char * stream_name, IntPtr sampleSpec, // pointer to struct SampleSpec IntPtr channelMap, // Channel Map use pass IntPtr.Zero for now IntPtr bufferAttributes, // Playback and record buffer metrics, pass IntPtr.Zero for now ref int error);
/// <inheritdoc /> public void ProcessJson(JToken message, StreamDirection direction) { if (message != null) { var command = message.SelectToken("$.command")?.Value <string>(); if (command == "setBreakpoints") { var type = message.SelectToken("$.type")?.Value <string>(); if (type == "request") { // Request var sequence = message.SelectToken("$.seq").Value <int>(); lock (dictLock) { breakpointDictionary[sequence] = message; } } else { // Response var request_seq = message.SelectToken("$.request_seq").Value <int>(); JToken requestEvent; if (breakpointDictionary.TryGetValue(request_seq, out requestEvent)) { // Overwrite the body.breakpoints with arguments.breakpoints. var requestBreakpoints = requestEvent.SelectToken("$.arguments.breakpoints"); var respBreakpoints = message.SelectToken("$.body.breakpoints"); if (requestBreakpoints != null && respBreakpoints != null) { var reqParent = requestBreakpoints as JContainer; var respParent = respBreakpoints as JContainer; if (reqParent != null && respParent != null) { // Meger breakpoint line data. respParent.Merge(reqParent, new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Merge }); } } } lock (dictLock) { breakpointDictionary.Remove(request_seq); } } } } }
/// <summary> ///Create a Stream using a buffer to write to (StreamType.InputToCentera) ///or read from (StreamType.OutputFromCentera) the Centera. ///See API Guide: FPStream_CreateBufferForInput, FPStream_CreateBufferForOutput /// ///@param streamBuffer The buffer that the Stream will read from (for INPUT to the Centera) /// or write to (for OUTPUT from the Centera). ///@param bufferSize The size of the buffer. ///@param streamDirection The StreamDirection enum indicating input or output. /// </summary> public FPStream(IntPtr streamBuffer, int bufferSize, StreamDirection streamDirection) { if (streamDirection == StreamDirection.InputToCentera) { theStream = Native.Stream.CreateBufferForInput(streamBuffer, (long)bufferSize); } else { theStream = Native.Stream.CreateBufferForOutput(streamBuffer, (long)bufferSize); } AddObject(theStream, this); }
private Dictionary <Type, List <Type> > TypeDependencies(StreamDirection direction) { var typeDependencies = new Dictionary <Type, List <Type> >(); //Build up dictionary of new GSA schema types and keywords - to be used to construct dependencies based on these new types var layerSchemaDict = layerKeywordTypes[Initialiser.AppResources.Settings.TargetLayer]; var layerSchemaTypes = layerSchemaDict.Keys; var layerSchemaKeywords = layerSchemaDict.Values; var layerKwDependencies = layerSchemaTypes.ToDictionary(t => layerSchemaDict[t], t => GsaRecord.GetReferencedKeywords(t).Where(kw => layerSchemaKeywords.Contains(kw)).ToList()); foreach (var oldT in oldSchemaTypes) { var oldTKeyword = ((string)oldT.GetAttribute <GSAObject>("GSAKeyword")).Split('.').First(); if (!string.IsNullOrEmpty(oldTKeyword) && !layerKwDependencies.Keys.Any(k => k.GetStringValue().Equals(oldTKeyword, StringComparison.InvariantCultureIgnoreCase))) { continue; } if (!typeDependencies.ContainsKey(oldT)) { typeDependencies.Add(oldT, new List <Type>()); } var attVal = oldT.GetAttribute <GSAObject>(((direction == StreamDirection.Receive) ? "Write" : "Read") + "Prerequisite"); var prereqs = (attVal != null) ? ((Type[])attVal).ToList() : new List <Type>(); var isAnalylsisLayer = (Initialiser.AppResources.Settings.TargetLayer == GSATargetLayer.Analysis); foreach (var tPrereq in prereqs) { //Remove version for comparison with keyword enum var kwPrereq = ((string)tPrereq.GetAttribute <GSAObject>("GSAKeyword")).Split('.').First(); if (layerKwDependencies.Keys.Any(k => k.GetStringValue().Equals(kwPrereq, StringComparison.InvariantCultureIgnoreCase)) || (tPrereq.Name.Contains("Result") && isAnalylsisLayer)) { typeDependencies[oldT].Add(tPrereq); } } } return(typeDependencies); }
public PulseAudioSimple(StreamDirection streamDirection, string streamName) { SampleSpec sampleSpec; sampleSpec.channels = 1; sampleSpec.format = SampleFormat.PA_SAMPLE_S16LE; sampleSpec.rate = 8000; IntPtr sampleSpecPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sampleSpec)); Marshal.StructureToPtr(sampleSpec, sampleSpecPtr, true); BufferAttributes bufferAttributes = new BufferAttributes(); if (streamDirection == StreamDirection.Playback) { bufferAttributes.maxlength = uint.MaxValue; bufferAttributes.tlength = 160 * 2; bufferAttributes.prebuf = uint.MaxValue; bufferAttributes.minreq = uint.MaxValue; bufferAttributes.fragsize = uint.MaxValue; } if (streamDirection == StreamDirection.Record) { bufferAttributes.maxlength = 160 * 12; bufferAttributes.tlength = 160 * 2; bufferAttributes.prebuf = 160 * 12; bufferAttributes.minreq = 160 * 2; bufferAttributes.fragsize = 160 * 2; } IntPtr bufferAttributesPtr = Marshal.AllocHGlobal(Marshal.SizeOf(bufferAttributes)); Marshal.StructureToPtr(bufferAttributes, bufferAttributesPtr, true); int error = 0; _paSimple = PulseAudioNativeMethods.pa_simple_new(null, "Ropu", streamDirection, null, streamName, sampleSpecPtr, IntPtr.Zero, bufferAttributesPtr, ref error); if (error != 0) { throw new Exception($"Failed to initalize pulse audio with error {error}"); } }
/// <summary> /// Create a new <see cref="ProgressStream"/> that wraps the specified inner <see cref="Stream"/>. /// </summary> /// <param name="innerStream"> /// The inner stream. /// </param> /// <param name="streamDirection"> /// The direction in which the stream's data is expected to flow. /// </param> /// <param name="ownsStream"> /// Should the <see cref="ProgressStream"/> close the inner stream when it is closed? /// </param> /// <param name="sink"> /// The sink used to report stream progress. /// </param> public ProgressStream(Stream innerStream, StreamDirection streamDirection, bool ownsStream, IProgressSink <long> sink) { if (innerStream == null) { throw new ArgumentNullException(nameof(innerStream)); } if (innerStream is ProgressStream) { throw new InvalidOperationException("Wrapping a ProgressStream2 in another ProgressStream2 is not currently supported."); } if (streamDirection == StreamDirection.Unknown) { throw new ArgumentOutOfRangeException(nameof(streamDirection), streamDirection, $"Invalid stream direction: '{streamDirection}'."); } _innerStream = innerStream; _streamDirection = streamDirection; _sink = sink; }
/// <summary> /// Modify the path to the desired mapping format. /// </summary> /// <param name="sourcePath"> /// The path to the source file. /// </param> /// <returns> /// The updated path if a file is located elsewhere. /// </returns> private string ApplyPathUpdate(string sourcePath, StreamDirection direction) { var resultPath = sourcePath; foreach (var path in PathMappings) { if (sourcePath.StartsWith(path.Key, StringComparison.CurrentCultureIgnoreCase)) { // Replace the path. resultPath = path.Value + resultPath.Substring(path.Key.Length); if (DebugStream != null) { DebugStream.WriteLine("*** Replaced Path({2}): {0} -> {1}", path.Key, path.Value, direction); DebugStream.WriteLine("*** Source Path: {0}", sourcePath); DebugStream.WriteLine("*** Target Path: {0}", resultPath); } break; } } return(resultPath); }
/// <summary> /// Configure the modifiers to run. /// </summary> /// <returns> /// The list of modifiers to execute. /// </returns> private IList <IJsonModifier> ConfigureModifiers(PassthroughSettings settings, StreamDirection direction) { // Configure the modifiers; var modifiers = new List <IJsonModifier>(); if (settings.UseLegacySourceFolders) { if (direction == StreamDirection.ToClient) { modifiers.Add(new LegacySourcePathRenameModifier(settings.GetLegacySourceFolders(), DebugLog)); } else { // Flip the modifier for host mapping. modifiers.Add(new LegacySourcePathRenameModifier(settings.GetLegacySourceFolders().ToDictionary((pair) => pair.Value, (pair) => pair.Key), DebugLog)); } } if (settings.UseLegacyBreakpointFix) { modifiers.Add(new LegacyBreakpointModifier()); } return(modifiers); }
private TransactionNode ExtractTNSData(PacketStream stream, StreamDirection direction) { TransactionNode node; OracleTransactionType type; List<PacketSlice> slices = new List<PacketSlice>(); Int16 pLen = 0; int packetType; try { pLen = stream.PeekInt16(); stream.ReadBytes(2, slices); stream.ReadBytes(2); //skip checksum packetType = stream.ReadByte(); type = (OracleTransactionType)packetType; stream.ReadByte(); //skip the reserved byte } catch (Exception e) { logger.AddMessage(e.Message); return null; } switch (type) { case OracleTransactionType.CONNECT: try { node = new TransactionNode("Connect"); node.AddField("Packet Size", pLen, "Packet Size", slices); Int16 headerChecksum = stream.ReadInt16(); Int16 version = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Version", version, "Version", slices); Int16 compatVersion = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Version (compatible)", compatVersion, "Compatible Version", slices); Int16 serviceOptions = stream.ReadInt16(); Int16 sessionDataUnitSize = stream.ReadInt16(); Int16 maxTxDataUnitSize = stream.ReadInt16(); Int16 NTProtCharacteristics = stream.ReadInt16(); Int16 lineTurnValue = stream.ReadInt16(); Int16 valueOfOneInHW = stream.ReadInt16(); Int16 ctDataLen = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Data Length", ctDataLen, "The length of the connect datastring.", slices); Int16 ctDataOffset = stream.ReadInt16(); Int16 maxRecCtData = stream.ReadInt16(); Int16 ctFlagsA = stream.ReadInt16(); Int16 ctFlagsB = stream.ReadInt16(); Int32 traceItemA = stream.ReadInt32(); Int32 traceItemB = stream.ReadInt32(); Int64 traceID = stream.ReadInt64(); stream.ReadInt64(); byte[] ctData = stream.PeekBytes(ctDataLen); string connectData = StaticUtils.DecodeASCII(ctData); stream.ReadBytes(ctDataLen, slices); node.AddField("Connect data", connectData, "Connect data", slices); try { Match match = Regex.Match(connectData, "\\(PROTOCOL=(?<proto>\\w{2,})\\)\\(HOST=(?<host>[.\\w]{7,})\\)\\(PORT=(?<port>\\d{2,})\\)\\).*SERVICE_NAME=(?<sid>[.\\w]{1,})\\)"); string proto = match.Groups["proto"].Value; string host = match.Groups["host"].Value; string newPort = match.Groups["port"].Value; string sid = match.Groups["sid"].Value; TransactionNode cInfoNode = new TransactionNode("Connection Info"); cInfoNode.AddField("Protocol", proto, "Protocol", slices); cInfoNode.AddField("Host", host, "Server being connected to", slices); cInfoNode.AddField("Port", newPort, "Port", slices); cInfoNode.AddField("Service", sid, "Service", slices); node.AddChild(cInfoNode); } catch (ArgumentException) { } return node; } catch (Exception e) { logger.AddMessage(e.Message); return null; } case OracleTransactionType.ACCEPT: node = new TransactionNode("Accept"); node.AddField("Packet Size", pLen, "Packet Size", slices); try { Int16 headerChecksum = stream.ReadInt16(); Int16 version = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Version", version, "Version", slices); Int16 serviceOptions = stream.ReadInt16(); Int16 sessionDataUnitSize = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Session Data Unit Size", sessionDataUnitSize, "Session Data Unit Size", slices); Int16 maxTxDataUnitSize = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Max Tx Unit Size", maxTxDataUnitSize, "Maximum Transmission Data Unit Size", slices); Int16 valueOfOneInHW = stream.ReadInt16(); Int16 acceptDataLength = stream.ReadInt16(); Int16 dataOffset = stream.ReadInt16(); int connectFlagsA = stream.ReadByte(); int connectFlagsB = stream.ReadByte(); stream.ReadBytes(pLen - 24); //read out empty bytes } catch (Exception e) { logger.AddMessage(e.Message); return null; } return node; case OracleTransactionType.REDIRECT: node = new TransactionNode("Redirect"); node.AddField("Packet Size", pLen, "Packet Size", slices); try { Int16 headerChecksum = stream.ReadInt16(); Int16 redirLen = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Redirection Data Length", redirLen, "Length of the redirection data string", slices); byte[] redirData = stream.PeekBytes(redirLen); string sRedir = StaticUtils.DecodeASCII(redirData); stream.ReadBytes(redirLen, slices); node.AddField("Redirection Data", sRedir, "Redirection data", slices); //get the redirected port string newPort = null; string proto = null; string host = null; try { Match match = Regex.Match(sRedir, "\\(PROTOCOL=(?<proto>\\w{2,})\\)\\(HOST=(?<host>[.\\w]{7,})\\)\\(PORT=(?<port>\\d{2,})\\)\\)"); proto = match.Groups["proto"].Value; host = match.Groups["host"].Value; newPort = match.Groups["port"].Value; } catch (ArgumentException) { // Syntax error in the regular expression } if(!newPort.Equals("")) redirPort = Int32.Parse(newPort); TransactionNode redirInfo = new TransactionNode("Redirection Info"); redirInfo.AddField("Protocol", proto, "Protocol used", slices); redirInfo.AddField("Host", host, "Host", slices); redirInfo.AddField("Port", newPort, "Port", slices); node.AddChild(redirInfo); } catch (Exception e) { logger.AddMessage(e.Message); return null; } return node; case OracleTransactionType.DATA: string label; if (direction == StreamDirection.IN) label = "Response"; else label = "Request"; node = new TransactionNode("Data - "+label ); node.AddField("Packet Size", pLen, "Packet Size", slices); try { Int16 headerChecksum = stream.ReadInt16(); Int16 dataFlags = stream.ReadInt16(); int payLoadLength = pLen - 10; byte[] payLoad = stream.PeekBytes(payLoadLength); string sPayload = StaticUtils.DecodeASCII(payLoad); stream.ReadBytes(payLoadLength, slices); node.AddField("Data", sPayload, "Data", slices); } catch (Exception e) { logger.AddMessage(e.Message); return null; } return node; default: logger.AddMessage(String.Format("Packet dissection not implemented [TransactionType={0}]", type)); return null; } }
/// <summary> ///Creates a Generic Stream object using the standard callbacks. A Stream derived class is still used for transfer ///but the user supplies the direction required (supports bi-directional streams). ///See API Guide: FPStream_CreateGenericStream /// ///@param userStream Instance of an object derived from the Stream class. This object /// is used by the calling application to transfer the data to the Generic /// Stream. Note: The derived Stream class should implement the Seek functionality /// is this is used to provide Marker Support for the SDK. ///@param direction The direction of the stream. ///@param userData An IntPtr which can be used to reference a user object that may be required /// when working with the input or output data buffer. /// </summary> public FPGenericStream(Stream userStream, StreamDirection direction, IntPtr userData) : this(direction, new FPStreamCallbacks(userStream), userData) { }
private void OnStreamDirectionChanged(uint streamid, StreamDirection streamdirection, StreamPendingFlags pendingflags) { Logger.Debug("Conversation::OnStreamDirectionChanged called"); }
/// <summary> ///Creates a Generic Stream object with user supplied callbacks. A Stream derived class is still used for transfer. ///but the user supplies the direction required (supports bi-directional streams). ///See API Guide: FPStream_CreateGenericStream /// ///@param userStream Instance of an object derived from the Stream class. This object /// is used by the calling application to transfer the data to the Generic /// Stream. Note: The derived Stream class should implement the Seek functionality is /// this is used to provide Marker Support for the SDK. ///@param direction The direction of the stream. ///@param userCBS Callbacks provided by the user. Typically the derived class will only /// require to override PopulateBuffer and / or ProcessReturnedData. ///@param userData An IntPtr which can be used to reference a user object that may be required /// when working with the input or output data buffer. /// </summary> public FPGenericStream(Stream userStream, StreamDirection direction, FPStreamCallbacks userCBS, IntPtr userData) : this(direction, userCBS, userData) { }
private TransactionNode ExtractTNSData(PacketStream stream, StreamDirection direction) { TransactionNode node; OracleTransactionType type; List <PacketSlice> slices = new List <PacketSlice>(); Int16 pLen = 0; int packetType; try { pLen = stream.PeekInt16(); stream.ReadBytes(2, slices); stream.ReadBytes(2); //skip checksum packetType = stream.ReadByte(); type = (OracleTransactionType)packetType; stream.ReadByte(); //skip the reserved byte } catch (Exception e) { logger.AddMessage(e.Message); return(null); } switch (type) { case OracleTransactionType.CONNECT: try { node = new TransactionNode("Connect"); node.AddField("Packet Size", pLen, "Packet Size", slices); Int16 headerChecksum = stream.ReadInt16(); Int16 version = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Version", version, "Version", slices); Int16 compatVersion = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Version (compatible)", compatVersion, "Compatible Version", slices); Int16 serviceOptions = stream.ReadInt16(); Int16 sessionDataUnitSize = stream.ReadInt16(); Int16 maxTxDataUnitSize = stream.ReadInt16(); Int16 NTProtCharacteristics = stream.ReadInt16(); Int16 lineTurnValue = stream.ReadInt16(); Int16 valueOfOneInHW = stream.ReadInt16(); Int16 ctDataLen = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Data Length", ctDataLen, "The length of the connect datastring.", slices); Int16 ctDataOffset = stream.ReadInt16(); Int16 maxRecCtData = stream.ReadInt16(); Int16 ctFlagsA = stream.ReadInt16(); Int16 ctFlagsB = stream.ReadInt16(); Int32 traceItemA = stream.ReadInt32(); Int32 traceItemB = stream.ReadInt32(); Int64 traceID = stream.ReadInt64(); stream.ReadInt64(); byte[] ctData = stream.PeekBytes(ctDataLen); string connectData = StaticUtils.DecodeASCII(ctData); stream.ReadBytes(ctDataLen, slices); node.AddField("Connect data", connectData, "Connect data", slices); try { Match match = Regex.Match(connectData, "\\(PROTOCOL=(?<proto>\\w{2,})\\)\\(HOST=(?<host>[.\\w]{7,})\\)\\(PORT=(?<port>\\d{2,})\\)\\).*SERVICE_NAME=(?<sid>[.\\w]{1,})\\)"); string proto = match.Groups["proto"].Value; string host = match.Groups["host"].Value; string newPort = match.Groups["port"].Value; string sid = match.Groups["sid"].Value; TransactionNode cInfoNode = new TransactionNode("Connection Info"); cInfoNode.AddField("Protocol", proto, "Protocol", slices); cInfoNode.AddField("Host", host, "Server being connected to", slices); cInfoNode.AddField("Port", newPort, "Port", slices); cInfoNode.AddField("Service", sid, "Service", slices); node.AddChild(cInfoNode); } catch (ArgumentException) { } return(node); } catch (Exception e) { logger.AddMessage(e.Message); return(null); } case OracleTransactionType.ACCEPT: node = new TransactionNode("Accept"); node.AddField("Packet Size", pLen, "Packet Size", slices); try { Int16 headerChecksum = stream.ReadInt16(); Int16 version = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Version", version, "Version", slices); Int16 serviceOptions = stream.ReadInt16(); Int16 sessionDataUnitSize = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Session Data Unit Size", sessionDataUnitSize, "Session Data Unit Size", slices); Int16 maxTxDataUnitSize = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Max Tx Unit Size", maxTxDataUnitSize, "Maximum Transmission Data Unit Size", slices); Int16 valueOfOneInHW = stream.ReadInt16(); Int16 acceptDataLength = stream.ReadInt16(); Int16 dataOffset = stream.ReadInt16(); int connectFlagsA = stream.ReadByte(); int connectFlagsB = stream.ReadByte(); stream.ReadBytes(pLen - 24); //read out empty bytes } catch (Exception e) { logger.AddMessage(e.Message); return(null); } return(node); case OracleTransactionType.REDIRECT: node = new TransactionNode("Redirect"); node.AddField("Packet Size", pLen, "Packet Size", slices); try { Int16 headerChecksum = stream.ReadInt16(); Int16 redirLen = stream.PeekInt16(); stream.ReadBytes(2, slices); node.AddField("Redirection Data Length", redirLen, "Length of the redirection data string", slices); byte[] redirData = stream.PeekBytes(redirLen); string sRedir = StaticUtils.DecodeASCII(redirData); stream.ReadBytes(redirLen, slices); node.AddField("Redirection Data", sRedir, "Redirection data", slices); //get the redirected port string newPort = null; string proto = null; string host = null; try { Match match = Regex.Match(sRedir, "\\(PROTOCOL=(?<proto>\\w{2,})\\)\\(HOST=(?<host>[.\\w]{7,})\\)\\(PORT=(?<port>\\d{2,})\\)\\)"); proto = match.Groups["proto"].Value; host = match.Groups["host"].Value; newPort = match.Groups["port"].Value; } catch (ArgumentException) { // Syntax error in the regular expression } if (!newPort.Equals("")) { redirPort = Int32.Parse(newPort); } TransactionNode redirInfo = new TransactionNode("Redirection Info"); redirInfo.AddField("Protocol", proto, "Protocol used", slices); redirInfo.AddField("Host", host, "Host", slices); redirInfo.AddField("Port", newPort, "Port", slices); node.AddChild(redirInfo); } catch (Exception e) { logger.AddMessage(e.Message); return(null); } return(node); case OracleTransactionType.DATA: string label; if (direction == StreamDirection.IN) { label = "Response"; } else { label = "Request"; } node = new TransactionNode("Data - " + label); node.AddField("Packet Size", pLen, "Packet Size", slices); try { Int16 headerChecksum = stream.ReadInt16(); Int16 dataFlags = stream.ReadInt16(); int payLoadLength = pLen - 10; byte[] payLoad = stream.PeekBytes(payLoadLength); string sPayload = StaticUtils.DecodeASCII(payLoad); stream.ReadBytes(payLoadLength, slices); node.AddField("Data", sPayload, "Data", slices); } catch (Exception e) { logger.AddMessage(e.Message); return(null); } return(node); default: logger.AddMessage(String.Format("Packet dissection not implemented [TransactionType={0}]", type)); return(null); } }
/////////////////////////////////////////////////////////////////////////////////////////////// private void TranslateEndOfLine( StreamDirection direction, ByteList inputList, ref ByteList outputList ) { // // NOTE: We require the underlying stream to be valid because we use it to // perform the configured end-of-line transformations. // if (stream != null) { // // NOTE: Is the input list valid? // if (inputList != null) { // // NOTE: How many bytes are in the list? // int inputCount = inputList.Count; if (inputCount > 0) { // // NOTE: Copy the input list to the input buffer because the underlying // stream transform works on buffers, not lists. // byte[] inputBuffer = inputList.ToArray(); // // NOTE: Allocate an output buffer of equal length to the input buffer // because the underlying stream transform works on buffers, not // lists. // byte[] outputBuffer = new byte[inputCount]; // // NOTE: Use the underlying stream to perform the actual end-of-line // transformations via the buffers we have prepared. If the stream // direction is neither Input only nor Output only, we do nothing. // int outputCount = Count.Invalid; if (direction == StreamDirection.Output) { outputCount = stream.TranslateOutputEndOfLine( inputBuffer, outputBuffer, 0, inputCount); } else if (direction == StreamDirection.Input) { outputCount = stream.TranslateInputEndOfLine( inputBuffer, outputBuffer, 0, inputCount); } // // NOTE: Did we transform anything? // if (outputCount != Count.Invalid) { // // NOTE: Finally, set the caller's output list to the contents of the // resulting [transformed] output buffer. We have to manually // copy the bytes into the resulting output list because we may // not need all the bytes in the output buffer. // outputList = new ByteList(outputCount); for (int outputIndex = 0; outputIndex < outputCount; outputIndex++) { outputList.Add(outputBuffer[outputIndex]); } } } else { // // NOTE: Garbage in, garbage out. Empty list to empty list. // outputList = new ByteList(); } } else { // // NOTE: Garbage in, garbage out. Null list to null list. // outputList = null; } } }
internal TypeDependencyData(StreamDirection dir, GSATargetLayer layer) { this.Direction = dir; this.Layer = layer; this.Dependencies = new Dictionary <Type, List <Type> >(); }
/// <inheritdoc /> public void ProcessJson(JToken message, StreamDirection direction) { ProcessJsonFilePaths(message, direction); }
public NetworkReader(Stream stream, StreamDirection dir) : base(stream) { direction = dir; }
/// <summary> /// Create a new <see cref="ProgressStream"/> that wraps the specified inner <see cref="Stream"/>. /// </summary> /// <param name="innerStream"> /// The inner stream. /// </param> /// <param name="streamDirection"> /// The direction in which the stream's data is expected to flow. /// </param> public ProgressStream(Stream innerStream, StreamDirection streamDirection) : this(innerStream, streamDirection, true) { }
public IOStream(string name, StreamDirection direction) { Direction = direction; StreamName = name; }
public DirectedStream(StreamDirection direction, Stream baseStream) { this.direction = direction; this.baseStream = baseStream; }