* Forgive the sins of B2BUA's that like to record route ACK's
*/
if (dialog != null && sipProvider != dialog.getSipProvider()) {
final 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 (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
logger.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 (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
logger.logDebug("dialogId = " + dialogId);
logger.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) {
final RouteList routes = sipRequest.getRouteHeaders();
final Route route = (Route) routes.getFirst();
final SipUri uri = (SipUri) route.getAddress().getURI();
final HostPort hostPort = uri.getHostPort();
int port;
if (hostPort.hasPort()) {
port = hostPort.getPort();
} else {
if (listeningPoint.getTransport().equalsIgnoreCase(