* assigned to the dialog. Forgive the sins of B2BUA's that like to record route ACK's
*/
if (dialog != null && sipProvider != dialog.getSipProvider()) {
Contact contact = dialog.getMyContactHeader();
if (contact != null) {
SipUri contactUri = (SipUri) (contact.getAddress().getURI());
String ipAddress = contactUri.getHost();
int contactPort = contactUri.getPort();
String contactTransport = contactUri.getTransportParam();
if (contactTransport == null)
contactTransport = "udp";
if (contactPort == -1) {
if (contactTransport.equals("udp") || contactTransport.equals("tcp"))
contactPort = 5060;
else
contactPort = 5061;
}
// Check if the dialog contact is the same as the provider on
// which we got the request. Otherwise, dont assign this
// dialog to the request.
if (ipAddress != null
&& (!ipAddress.equals(listeningPoint.getIPAddress()) || contactPort != listeningPoint
.getPort())) {
if (sipStack.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
sipStack.getStackLogger().logDebug(
"nulling dialog -- listening point mismatch! " + contactPort
+ " lp port = " + listeningPoint.getPort());
}
dialog = null;
}
}
}
/*
* RFC 3261 8.2.2.2 Merged requests: If the request has no tag in the To header field, the
* UAS core MUST check the request against ongoing transactions. If the From tag, Call-ID,
* and CSeq exactly match those associated with an ongoing transaction, but the request
* does not match that transaction (based on the matching rules in Section 17.2.3), the
* UAS core SHOULD generate a 482 (Loop Detected) response and pass it to the server
* transaction. This support is only enabled when the stack has been instructed to
* function with Automatic Dialog Support.
*/
if ( sipProvider.isDialogErrorsAutomaticallyHandled()
&& sipRequest.getToTag() == null) {
if ( sipStack
.findMergedTransaction(sipRequest)) {
this.sendLoopDetectedResponse(sipRequest, transaction);
return;
}
}
if (sipStack.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
sipStack.getStackLogger().logDebug("dialogId = " + dialogId);
sipStack.getStackLogger().logDebug("dialog = " + dialog);
}
/*
* RFC 3261 Section 16.4 If the first value in the Route header field indicates this
* proxy,the proxy MUST remove that value from the request .
*/
// If the message is being processed
// by a Proxy, then the proxy will take care of stripping the
// Route header. If the request is being processed by an
// endpoint, then the stack strips off the route header.
if (sipRequest.getHeader(Route.NAME) != null && transaction.getDialog() != null) {
RouteList routes = sipRequest.getRouteHeaders();
Route route = (Route) routes.getFirst();
SipUri uri = (SipUri) route.getAddress().getURI();
int port;
if (uri.getHostPort().hasPort()) {
port = uri.getHostPort().getPort();
} else {
if (listeningPoint.getTransport().equalsIgnoreCase("TLS"))
port = 5061;
else
port = 5060;
}
String host = uri.getHost();
if ((host.equals(listeningPoint.getIPAddress()) || host
.equalsIgnoreCase(listeningPoint.getSentBy()))
&& port == listeningPoint.getPort()) {
if (routes.size() == 1)
sipRequest.removeHeader(Route.NAME);