// if resourceName contains an @ and the string behind the @ is different from the current OverlayName the ForwardingOptionsType.destinationOverlay is set public bool AddDestinationOverlay(string resourceName) { String destinationOverlay = null; if (m_ReloadConfig.OverlayName == null) return false; else if (!resourceName.Contains(m_ReloadConfig.OverlayName) && resourceName.Contains("@")) { destinationOverlay = resourceName.Substring(resourceName.IndexOf("@") + 1); } else if (resourceName != null) { destinationOverlay = resourceName; //TODO: remove? } else return false; if (forwarding_header.fw_options == null) { forwarding_header.fw_options = new List<ForwardingOption>(); } ForwardingOption option; byte[] bytes; //destinationOverlay option = new ForwardingOption(); option.fwo_type = ForwardingOptionsType.destinationOverlay; bytes = System.Text.Encoding.Unicode.GetBytes(destinationOverlay); // TODO: Unicode for sure? option.bytes = bytes; option.length = (UInt16)bytes.Length; forwarding_header.fw_options.Add(option); option = new ForwardingOption(); option.fwo_type = ForwardingOptionsType.sourceOverlay; bytes = System.Text.Encoding.Unicode.GetBytes(m_ReloadConfig.OverlayName); // TODO: Unicode for sure? option.bytes = bytes; option.length = (UInt16)bytes.Length; //forwarding_header.fw_options.Add(option); return true; //TODO: }
public List<ForwardingOption> ReadOptionList(BinaryReader reader, int Length) { List<ForwardingOption> option_list = new List<ForwardingOption>(); if (Length != 0) { int counted_bytes = Length; while (counted_bytes > 3) { ForwardingOption forw_opt = new ForwardingOption(); forw_opt.fwo_type = (ForwardingOptionsType)reader.ReadByte(); counted_bytes--; forw_opt.flags = reader.ReadByte(); counted_bytes--; forw_opt.length = (UInt16)System.Net.IPAddress.NetworkToHostOrder(reader.ReadInt16()); counted_bytes = counted_bytes - 2; forw_opt.bytes = reader.ReadBytes(forw_opt.length); counted_bytes = counted_bytes - forw_opt.length; option_list.Add(forw_opt); } if (counted_bytes != 0) { m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, "invalid length within ForwardingOptions"); } } return option_list; }
//Proprietary //--Joscha //Reverse and set the ForwardingOptionsType.sourceOverlay and ForwardingOptionsType.destinationOverlay to recmsg public void addOverlayForwardingOptions(ReloadMessage recmsg) { if (recmsg.forwarding_header.via_list != null) { foreach (Destination destx in recmsg.forwarding_header.via_list) m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_INFO, String.Format("addOverlayForwardingOptions Via={0} ", destx.ToString())); } if (recmsg.forwarding_header.destination_list != null) { foreach (Destination desty in recmsg.forwarding_header.destination_list) m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_INFO, String.Format("addOverlayForwardingOptions Dest={0} ", desty.ToString())); } if (recmsg.forwarding_header.fw_options != null) { this.forwarding_header.fw_options = new List<ForwardingOption>(); foreach (ForwardingOption option in recmsg.forwarding_header.fw_options) { if (option.fwo_type == ForwardingOptionsType.sourceOverlay) { string source_overlay = System.Text.Encoding.Unicode.GetString(option.bytes); ForwardingOption answerOption = new ForwardingOption(); answerOption.fwo_type = ForwardingOptionsType.destinationOverlay; byte[] bytes = System.Text.Encoding.Unicode.GetBytes(source_overlay); // TODO: Unicode for sure? answerOption.bytes = bytes; answerOption.length = (UInt16)bytes.Length; this.forwarding_header.fw_options.Add(answerOption); //if the message is stored by the GateWay itself the storeanswer has to be processed by the Gateway again //if (m_ReloadConfig.ThisMachine is GWMachine) // recmsg.LastHopNodeId = m_ReloadConfig.ThisMachine.Topology.Id; } if (option.fwo_type == ForwardingOptionsType.destinationOverlay) { string destination_overlay = System.Text.Encoding.Unicode.GetString(option.bytes); ForwardingOption answerOption = new ForwardingOption(); answerOption.fwo_type = ForwardingOptionsType.sourceOverlay; byte[] bytes = System.Text.Encoding.Unicode.GetBytes(destination_overlay); // TODO: Unicode for sure? answerOption.bytes = bytes; answerOption.length = (UInt16)bytes.Length; this.forwarding_header.fw_options.Add(answerOption); //if the message is stored by the GateWay itself the storeanswer has to be processed by the Gateway again //if (m_ReloadConfig.ThisMachine is GWMachine) // recmsg.LastHopNodeId = m_ReloadConfig.ThisMachine.Topology.Id; } } } }