void sipTransport2_SIPResponseOutTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint toEndPoint, SIPResponse sipResponse) { Console.WriteLine("Response Sent: " + localEndPoint.ToString() + "<-" + toEndPoint.ToString() + "\r\n" + sipResponse.ToString()); }
public void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse) { FireProxyLogEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.Error, "App Server received a SIP response from " + remoteEndPoint + " that did not match an existing transaction.\n" + sipResponse.ToString(), null)); }
void sipTransport1_SIPResponseInTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint fromEndPoint, SIPResponse sipResponse) { Console.WriteLine("Response Received: " + localEndPoint.ToString() + "<-" + fromEndPoint.ToString() + "\r\n" + sipResponse.ToString()); }
public void SendInternal(SIPEndPoint receivedFromEP, SIPEndPoint receivedOnEP, SIPResponse sipResponse, SIPEndPoint localSIPEndPoint) { try { sipResponse.Header.ProxyReceivedFrom = receivedFromEP.ToString(); sipResponse.Header.ProxyReceivedOn = receivedOnEP.ToString(); sipResponse.LocalSIPEndPoint = localSIPEndPoint; m_sipTransport.SendResponse(sipResponse); } catch (Exception excp) { logger.Error("Exception SIPResponse SendInternal. " + excp.Message); logger.Error(sipResponse.ToString()); throw; } }
/// <summary> /// This method is the equivalent to the same named method for sending SIP requests. The two methods are used to allow the Proxy to /// deliver requests to external SIP agents with only a SINGLE Via header due to a small number of providers rejecting requests with /// more than one Via header. /// </summary> /// <param name="receivedFromEP">The socket the response was received from.</param> /// <param name="receivedOnEP">The proxy socket the response was received on.</param> /// <param name="sipResponse">The response being forwarded.</param> /// <param name="localSIPEndPoint">The proxy socket to forward the request from.</param> /// <param name="dstSIPEndPoint">The internal destination socket to forward the response to.</param> /// <param name="proxyBranch">The branch parameter from the top Via header that needs to be reused when forwarding the response.</param> public void SendTransparent(SIPEndPoint receivedFromEP, SIPEndPoint receivedOnEP, SIPResponse sipResponse, SIPEndPoint localSIPEndPoint, SIPEndPoint dstSIPEndPoint, string proxyBranch) { try { sipResponse.Header.ProxyReceivedFrom = receivedFromEP.ToString(); sipResponse.Header.ProxyReceivedOn = receivedOnEP.ToString(); sipResponse.Header.Vias.PushViaHeader(new SIPViaHeader(dstSIPEndPoint, proxyBranch)); sipResponse.LocalSIPEndPoint = localSIPEndPoint; m_sipTransport.SendResponse(sipResponse); } catch (Exception excp) { logger.Error("Exception SIPResponse SendInternal. " + excp.Message); logger.Error(sipResponse.ToString()); throw; } }
private void SendResponse(SIPChannel sipChannel, SIPEndPoint dstEndPoint, SIPResponse sipResponse) { try { if (dstEndPoint != null && dstEndPoint.Address.Equals(BlackholeAddress)) { // Ignore packet, it's destined for the blackhole. return; } if (m_sipChannels.Count == 0) { throw new ApplicationException("No channels are configured in the SIP transport layer. The response could not be sent."); } sipResponse.Header.ContentLength = (sipResponse.Body.NotNullOrBlank()) ? Encoding.UTF8.GetByteCount(sipResponse.Body) : 0; sipChannel.Send(dstEndPoint.GetIPEndPoint(), Encoding.UTF8.GetBytes(sipResponse.ToString())); if (SIPRequestOutTraceEvent != null) { FireSIPResponseOutTraceEvent(sipChannel.SIPChannelEndPoint, dstEndPoint, sipResponse); } } catch (ApplicationException appExcp) { logger.Warn("ApplicationException SIPTransport SendResponse. " + appExcp.Message); } }
public virtual void SendFinalResponse(SIPResponse finalResponse) { m_transactionFinalResponse = finalResponse; UpdateTransactionState(SIPTransactionStatesEnum.Completed); string viaAddress = finalResponse.Header.Vias.TopViaHeader.ReceivedFromAddress; if (TransactionType == SIPTransactionTypesEnum.Invite) { FireTransactionTraceMessage("Send Final Response Reliable " + LocalSIPEndPoint.ToString() + "->" + viaAddress + m_crLF + finalResponse.ToString()); m_sipTransport.SendSIPReliable(this); } else { FireTransactionTraceMessage("Send Final Response " + LocalSIPEndPoint.ToString() + "->" + viaAddress + m_crLF + finalResponse.ToString()); m_sipTransport.SendResponse(finalResponse); } }
public virtual void SendInformationalResponse(SIPResponse sipResponse) { FireTransactionTraceMessage("Send Info Response " + LocalSIPEndPoint.ToString() + "->" + this.RemoteEndPoint + m_crLF + sipResponse.ToString()); if (sipResponse.StatusCode == 100) { UpdateTransactionState(SIPTransactionStatesEnum.Trying); } else if (sipResponse.StatusCode > 100 && sipResponse.StatusCode <= 199) { UpdateTransactionState(SIPTransactionStatesEnum.Proceeding); } m_sipTransport.SendResponse(sipResponse); }
private static void SIPResponseOutTraceEvent(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse) { logger.DebugFormat("RESPONSE OUT {0}->{1}", localSIPEndPoint.ToString(), remoteEndPoint.ToString()); logger.Debug(sipResponse.ToString()); }
public void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse) { if (TransactionState == SIPTransactionStatesEnum.Completed || TransactionState == SIPTransactionStatesEnum.Confirmed) { FireTransactionTraceMessage("Received Duplicate Response " + localSIPEndPoint.ToString() + "<-" + remoteEndPoint + m_crLF + sipResponse.ToString()); if (sipResponse.Header.CSeqMethod == SIPMethodsEnum.INVITE) { if (sipResponse.StatusCode >= 100 && sipResponse.StatusCode <= 199) { // Ignore info response on completed transaction. } else { ResendAckRequest(); } } if (TransactionDuplicateResponse != null) { TransactionDuplicateResponse(localSIPEndPoint, remoteEndPoint, this, sipResponse); } } else { FireTransactionTraceMessage("Received Response " + localSIPEndPoint.ToString() + "<-" + remoteEndPoint + m_crLF + sipResponse.ToString()); if (sipResponse.StatusCode >= 100 && sipResponse.StatusCode <= 199) { UpdateTransactionState(SIPTransactionStatesEnum.Proceeding); TransactionInformationResponseReceived(localSIPEndPoint, remoteEndPoint, this, sipResponse); } else { m_transactionFinalResponse = sipResponse; UpdateTransactionState(SIPTransactionStatesEnum.Completed); TransactionFinalResponseReceived(localSIPEndPoint, remoteEndPoint, this, sipResponse); } } }
public virtual void SendFinalResponse(SIPResponse finalResponse) { m_transactionFinalResponse = finalResponse; UpdateTransactionState(SIPTransactionStatesEnum.Completed); string viaAddress = finalResponse.Header.Vias.TopViaHeader.ReceivedFromAddress; if (TransactionType == SIPTransactionTypesEnum.Invite) { FireTransactionTraceMessage("Send Final Response Reliable " + LocalSIPEndPoint.ToString() + "->" + viaAddress + m_crLF + finalResponse.ToString()); m_sipTransport.SendSIPReliable(this); } else { FireTransactionTraceMessage("Send Final Response " + LocalSIPEndPoint.ToString() + "->" + viaAddress + m_crLF + finalResponse.ToString()); m_sipTransport.SendResponse(finalResponse); } }
void transport_SIPResponseInTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint fromEndPoint, SIPResponse sipResponse) { Console.WriteLine("Response In: " + localEndPoint + "<-" + fromEndPoint.ToString() + "\n" + sipResponse.ToString()); }
void transport_SIPResponseOutTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint toEndPoint, SIPResponse sipResponse) { Console.WriteLine("Response Out: " + localEndPoint + "->" + toEndPoint.ToString() + "\n" + sipResponse.ToString()); }
public virtual void SendInformationalResponse(SIPResponse sipResponse) { FireTransactionTraceMessage("Send Info Response " + LocalSIPEndPoint.ToString() + "->" + this.RemoteEndPoint + m_crLF + sipResponse.ToString()); if (sipResponse.StatusCode == 100) { UpdateTransactionState(SIPTransactionStatesEnum.Trying); } else if (sipResponse.StatusCode > 100 && sipResponse.StatusCode <= 199) { UpdateTransactionState(SIPTransactionStatesEnum.Proceeding); } m_sipTransport.SendResponse(sipResponse); }
/// <summary> /// From RFC3261: Stateless Proxy Response Processing: /// /// When a response arrives at a stateless proxy, the proxy MUST inspect the sent-by value in the first /// (topmost) Via header field value. If that address matches the proxy, (it equals a value this proxy has /// inserted into previous requests) the proxy MUST remove that header field value from the response and /// forward the result to the location indicated in the next Via header field value. The proxy MUST NOT add /// to, modify, or remove the message body. Unless specified otherwise, the proxy MUST NOT remove /// any other header field values. If the address does not match the proxy, the message MUST be silently discarded. /// </summary> private void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse) { try { // Used in the proxy monitor messages only, plays no part in response processing. string fromUser = (sipResponse.Header.From != null) ? sipResponse.Header.From.FromURI.User : null; string toUser = (sipResponse.Header.To != null) ? sipResponse.Header.To.ToURI.User : null; string summaryStr = "resp " + sipResponse.Header.CSeqMethod + " from=" + fromUser + ", to=" + toUser + ", " + remoteEndPoint.ToString(); SIPViaHeader topVia = sipResponse.Header.Vias.PopTopViaHeader(); SIPEndPoint outSocket = localSIPEndPoint; // If the second Via header on the response was also set by this proxy it means the request was originally received and forwarded // on different sockets. To get the response to travel the same path in reverse it must be forwarded from the proxy socket indicated // by the second top Via. if (sipResponse.Header.Vias.Length > 1) { SIPViaHeader nextTopVia = sipResponse.Header.Vias.TopViaHeader; SIPEndPoint nextTopViaSIPEndPoint = SIPEndPoint.ParseSIPEndPoint(nextTopVia.Transport + ":" + nextTopVia.ReceivedFromAddress); //if (!(PublicIPAddress != null && nextTopVia.ReceivedFromIPAddress != null && nextTopVia.ReceivedFromIPAddress != PublicIPAddress.ToString()) // && // (m_sipTransport.IsLocalSIPEndPoint(nextTopViaSIPEndPoint) || (PublicIPAddress != null && nextTopVia.ReceivedFromIPAddress == PublicIPAddress.ToString()))) if(m_sipTransport.IsLocalSIPEndPoint(nextTopViaSIPEndPoint)) { sipResponse.Header.Vias.PopTopViaHeader(); outSocket = nextTopViaSIPEndPoint; } } bool isFromAppServer = (m_sipCallDispatcherFile != null) ? m_sipCallDispatcherFile.IsAppServerEndPoint(remoteEndPoint) : false; lock (this) { m_compiledScript.DefaultScope.RemoveVariable("sys"); m_compiledScript.DefaultScope.RemoveVariable("isreq"); m_compiledScript.DefaultScope.RemoveVariable("localEndPoint"); m_compiledScript.DefaultScope.RemoveVariable("outSocket"); m_compiledScript.DefaultScope.RemoveVariable("resp"); m_compiledScript.DefaultScope.RemoveVariable("remoteEndPoint"); m_compiledScript.DefaultScope.RemoveVariable("summary"); m_compiledScript.DefaultScope.RemoveVariable("sipMethod"); m_compiledScript.DefaultScope.RemoveVariable("topVia"); m_compiledScript.DefaultScope.RemoveVariable("IsFromAppServer"); m_compiledScript.DefaultScope.SetVariable("sys", m_proxyScriptFacade); m_compiledScript.DefaultScope.SetVariable("isreq", false); m_compiledScript.DefaultScope.SetVariable("localEndPoint", localSIPEndPoint); m_compiledScript.DefaultScope.SetVariable("outSocket", outSocket); m_compiledScript.DefaultScope.SetVariable("resp", sipResponse); m_compiledScript.DefaultScope.SetVariable("remoteEndPoint", remoteEndPoint); m_compiledScript.DefaultScope.SetVariable("summary", summaryStr); m_compiledScript.DefaultScope.SetVariable("sipMethod", sipResponse.Header.CSeqMethod.ToString()); m_compiledScript.DefaultScope.SetVariable("topVia", topVia); m_compiledScript.DefaultScope.SetVariable("IsFromAppServer", isFromAppServer); m_compiledScript.Execute(); } //if (responseStopwatch.ElapsedMilliseconds > 20) //{ // logger.Debug("GotResponse processing time=" + responseStopwatch.ElapsedMilliseconds + "ms, script time=" + scriptStopwatch.ElapsedMilliseconds + "ms."); //} } catch (Exception excp) { string respExcpError = "Exception SIPProxyCore GotResponse. " + excp.Message; logger.Error(respExcpError + "\n" + sipResponse.ToString()); SIPMonitorEvent respExcpEvent = new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.SIPProxy, SIPMonitorEventTypesEnum.Error, respExcpError, localSIPEndPoint, remoteEndPoint, null); SendMonitorEvent(respExcpEvent); throw excp; } }
void transport_SIPResponseOutTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint toEndPoint, SIPResponse sipResponse) { Console.WriteLine("Response Out: " + localEndPoint + "->" + toEndPoint.ToString() + "\n" + sipResponse.ToString()); }
private void SendResponse(SIPChannel sipChannel, SIPResponse sipResponse) { if (m_sipChannels.Count == 0) { throw new ApplicationException("No channels are configured in the SIP transport layer. The response could not be sent."); } SIPViaHeader topVia = sipResponse.Header.Vias.TopViaHeader; SIPDNSLookupResult lookupResult = GetHostEndPoint(topVia.ReceivedFromAddress, false); if (lookupResult.LookupError != null) { throw new ApplicationException("Could not resolve destination for response.\n" + sipResponse.ToString()); } else if (lookupResult.Pending) { // Ignore this response transmission and wait for the transaction retransmit mechanism to try again when DNS will have hopefully resolved the end point. return; } else { SIPEndPoint dstEndPoint = lookupResult.GetSIPEndPoint(); if (dstEndPoint != null && dstEndPoint.Address.Equals(BlackholeAddress)) { // Ignore packet, it's destined for the blackhole. return; } else if (dstEndPoint != null) { SendResponse(sipChannel, new SIPEndPoint(topVia.Transport, dstEndPoint.GetIPEndPoint()), sipResponse); } else { throw new ApplicationException("SendResponse could not send a response as no end point was resolved.\n" + sipResponse.ToString()); } } }
void transport_SIPResponseInTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint fromEndPoint, SIPResponse sipResponse) { Console.WriteLine("Response In: " + localEndPoint + "<-" + fromEndPoint.ToString() + "\n" + sipResponse.ToString()); }
private void LogSIPResponseOut(SIPEndPoint localSIPEndPoint, SIPEndPoint endPoint, SIPResponse sipResponse) { string message = "App Svr Sent: " + localSIPEndPoint.ToString() + "->" + endPoint.ToString() + "\r\n" + sipResponse.ToString(); //logger.Debug("as: response out " + sipResponse.Header.CSeqMethod + " " + localSIPEndPoint.ToString() + "->" + endPoint.ToString() + ", callid=" + sipResponse.Header.CallId + "."); string fromUser = (sipResponse.Header.From != null && sipResponse.Header.From.FromURI != null) ? sipResponse.Header.From.FromURI.User : "******"; FireSIPMonitorEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.FullSIPTrace, message, fromUser, localSIPEndPoint, endPoint)); }
public void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse) { if (TransactionState == SIPTransactionStatesEnum.Completed || TransactionState == SIPTransactionStatesEnum.Confirmed) { FireTransactionTraceMessage("Received Duplicate Response " + localSIPEndPoint.ToString() + "<-" + remoteEndPoint + m_crLF + sipResponse.ToString()); if (sipResponse.Header.CSeqMethod == SIPMethodsEnum.INVITE) { if (sipResponse.StatusCode >= 100 && sipResponse.StatusCode <= 199) { // Ignore info response on completed transaction. } else { ResendAckRequest(); } } if (TransactionDuplicateResponse != null) { TransactionDuplicateResponse(localSIPEndPoint, remoteEndPoint, this, sipResponse); } } else { FireTransactionTraceMessage("Received Response " + localSIPEndPoint.ToString() + "<-" + remoteEndPoint + m_crLF + sipResponse.ToString()); if (sipResponse.StatusCode >= 100 && sipResponse.StatusCode <= 199) { UpdateTransactionState(SIPTransactionStatesEnum.Proceeding); TransactionInformationResponseReceived(localSIPEndPoint, remoteEndPoint, this, sipResponse); } else { m_transactionFinalResponse = sipResponse; UpdateTransactionState(SIPTransactionStatesEnum.Completed); TransactionFinalResponseReceived(localSIPEndPoint, remoteEndPoint, this, sipResponse); } } }