private string URIanalysis(string sipURI) { string ForwardUrl = ""; try { if (sipURI.StartsWith("+")) { ReloadConfigResolve res = new ReloadConfigResolve(myManager.m_ReloadConfig); ForwardUrl = res.ResolveNaptr(sipURI); if (ForwardUrl == null) { myManager.m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_WARNING, "DNS Enum fallback to sip uri analysis"); ForwardUrl = sipURI; ForwardUrl = ForwardUrl.TrimStart(' '); ForwardUrl = ForwardUrl.Replace(" ", ""); ForwardUrl = "sip:" + ForwardUrl + "@" + myManager.m_ReloadConfig.OverlayName; } } else if (sipURI.StartsWith("sip:")) { ForwardUrl = sipURI; } else { throw new ArgumentException("Unsupported URI format! Must start with, e.g., +49 or sip:"); } } catch (Exception e) { myManager.m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, e.Message); } return ForwardUrl; }
/// <summary> /// This method gathers all Kinds that will be sent withon one single request. /// @precondition: The storing data MUST have the same Resource Name. /// @precondition: The the command MUST be the same. (e.g., ONLY store | fetch) /// </summary> /// <param name="command">Store | Fetch</param> /// <param name="codePoint">The Identifier for the Usage to be performed</param> /// <param name="type">Some Usages define differents types (see sip usage). Place here that value in Usage spec.</param> /// <param name="arguments">argument[0] Resource Name /// /// If SIP Registration: args[1] = uri | contact prefs /// If DisCo Registration: args[1] TODO /// If Access List: args[1] = kinId /// args[2] = from_user /// args[3] = to_user /// args[4] = allow_delegation</param> public void GatherCommands(string command, Usage_Code_Point codePoint, int type, params object[] arguments) { IUsage usage = null; StoredDataSpecifier specifier = null; /* Check plausibility of user commands */ if (m_ReloadConfig.CommandQueuePort.ItemCount > 0 && command != (string)m_ReloadConfig.CommandQueuePort.Test()) { throw new ArgumentException(String.Format( "Your command {0} is not the same as previews command {1}.", command, (string)m_ReloadConfig.CommandQueuePort.Test())); } /* Process store command */ if (command.Equals("Store")) { StoreKindData kindData; usage = m_UsageManager.CreateUsage(codePoint, type, arguments); kindData = new StoreKindData(usage.KindId, 0, // mok! TODO generation management new StoredData(usage.Encapsulate(true))); gatheredStoreDatas.Add(kindData); } /* Process fetch command */ if (command.Equals("Fetch")) { string[] str_arguments = arguments.Select(item => (string)item).ToArray(); UInt32 kind = UsageManager.CreateUsage(codePoint, null, null).KindId; // To further garantee SIP Usage with Telefonenumbers if (codePoint == Usage_Code_Point.SIP_REGISTRATION && str_arguments[0].StartsWith("+")) { string FetchUrl = ""; ReloadConfigResolve res = new ReloadConfigResolve(m_ReloadConfig); FetchUrl = res.ResolveNaptr(str_arguments[0]); if (FetchUrl == null) { ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_WARNING, "DNS Enum fallback to sip uri analysis"); FetchUrl = str_arguments[0]; FetchUrl = FetchUrl.TrimStart(' '); FetchUrl = FetchUrl.Replace(" ", ""); FetchUrl = "sip:" + FetchUrl + "@" + m_ReloadConfig.OverlayName; } arguments[0] = FetchUrl; } specifier = m_UsageManager.createSpecifier(kind, str_arguments); gatheredSpecifiers.Add(specifier); } }
public void GatherCommandsInQueue(string command, Usage_Code_Point codePoint, int type, NodeId viaGateway, bool CommandFinished = false, params object[] arguments) //TODO: combine to one single method { IUsage usage = null; StoredDataSpecifier specifier = null; if (command.Equals("Store")) { StoreKindData kindData; usage = m_UsageManager.CreateUsage(codePoint, type, arguments); //foreach (UInt32 kindId in usage.Kinds) TODO: { //kindData = new StoreKindData(kindId, 0, new StoredData(usage.Encapsulate(kindId, true))); kindData = new StoreKindData(usage.KindId, 0, new StoredData(usage.Encapsulate(true))); gatheredStoreDatas.Add(kindData); //m_ReloadConfig.GatheringList.Add(kindData); } if (CommandFinished == true) { if (viaGateway != null) storeViaGateway.Add(gatheredStoreDatas, viaGateway); gatheredStoreDatasQueue.Post(gatheredStoreDatas); gatheredStoreDatas = new List<StoreKindData>(); } } if (command.Equals("Fetch")) { //UInt32[] kinds = UsageManager.CreateUsage(codePoint, null, null).Kinds; TODO: cleanup UInt32 kind = UsageManager.CreateUsage(codePoint, null, null).KindId; // To further garantee SIP Usage with Telefonenumbers if (codePoint == Usage_Code_Point.SIP_REGISTRATION && arguments[0].ToString().StartsWith("+")) { string FetchUrl = ""; ReloadConfigResolve res = new ReloadConfigResolve(m_ReloadConfig); FetchUrl = res.ResolveNaptr(arguments[0].ToString()); if (FetchUrl == null) { ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_WARNING, "DNS Enum fallback to sip uri analysis"); FetchUrl = arguments[0].ToString(); FetchUrl = FetchUrl.TrimStart(' '); FetchUrl = FetchUrl.Replace(" ", ""); FetchUrl = "sip:" + FetchUrl + "@" + m_ReloadConfig.OverlayName; arguments[0] = FetchUrl; } } //foreach (UInt32 kindId in kinds) TODO: cleanup { specifier = m_UsageManager.createSpecifier(kind, arguments); gatheredSpecifiers.Add(specifier); } if (CommandFinished == true) { if (viaGateway != null) fetchViaGateway.Add(gatheredSpecifiers, viaGateway); gatheredSpecifiersQueue.Post(gatheredSpecifiers); gatheredSpecifiers = new List<StoredDataSpecifier>(); } } }
public void SimpleNodeIdRequest() { try { if (EnrollmentserverAvailable) { HttpWebRequest httpWebPost; /* get node id */ if (m_ReloadConfig.IMSI != null && m_ReloadConfig.IMSI != "") httpWebPost = (HttpWebRequest)WebRequest.Create(new Uri(EnrollmentUrl + "?type=imsi&IMSI=" + m_ReloadConfig.IMSI)); else httpWebPost = (HttpWebRequest)WebRequest.Create(new Uri(EnrollmentUrl + "?type=vnode")); /* As of RELOAD draft, use POST */ httpWebPost.Method = "POST"; #if !WINDOWS_PHONE // Additional HttpWebRequest parameters are not supported httpWebPost.Timeout = ReloadGlobals.WEB_REQUEST_TIMEOUT; #endif HttpWebResponse httpPostResponse = null; //Send Web-Request and receive a Web-Response httpPostResponse = (HttpWebResponse)httpWebPost.GetResponse(); //Translate data from the Web-Response to a string Stream dataStream2 = httpPostResponse.GetResponseStream(); TextReader tr_xml2 = new StreamReader(dataStream2, Encoding.UTF8); string response = tr_xml2.ReadToEnd(); string[] words = response.Split(':', ',', '/', '@'); if (m_ReloadConfig.IMSI != null && m_ReloadConfig.IMSI != "") { m_ReloadConfig.E64_Number = words[1]; ReloadConfigResolve res = new ReloadConfigResolve(m_ReloadConfig); m_ReloadConfig.SipUri = res.ResolveNaptr(m_ReloadConfig.E64_Number); if (m_ReloadConfig.SipUri == null) { m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_WARNING, "DNS Enum fallback to sip uri analysis"); m_ReloadConfig.SipUri = m_ReloadConfig.E64_Number; m_ReloadConfig.SipUri = m_ReloadConfig.SipUri.TrimStart(' '); m_ReloadConfig.SipUri = m_ReloadConfig.SipUri.Replace(" ", ""); m_ReloadConfig.SipUri = m_ReloadConfig.SipUri + "@" + m_ReloadConfig.OverlayName; } m_ReloadConfig.LocalNodeID = new NodeId(HexStringConverter.ToByteArray(words[7])); m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_TOPO, String.Format("Enrollment Server assigned: NodeId = '{0}' SipUri = '{1}' ", m_ReloadConfig.LocalNodeID, m_ReloadConfig.SipUri)); } else { m_ReloadConfig.LocalNodeID = new NodeId(HexStringConverter.ToByteArray(words[4])); m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_TOPO, String.Format("Enrollment Server assigned: NodeId = '{0}'", m_ReloadConfig.LocalNodeID)); } } } catch (Exception ex) { m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, "SimpleNodeIdRequest: " + ex.Message); } }