Revision: 23233f8989c0
Author: Jonas Borjesson <[email protected]>
Date: Tue Aug 21 23:53:09 2012 UTC
Log: Update Issue 153
target refresh fix for tcp connection reuse case
(cherry picked from commit 76f0ebcf32e0378f48d427dd32c6129ad8a1375c)
Conflicts:
sip-servlets-impl/.classpath
sip-servlets-impl/.project
(cherry picked from commit 832b3b31b5cc3a0564b39fc5cac7a0309f06dd70)
http://code.google.com/p/sipservlets/source/detail?r=23233f8989c0
Modified:
/.gitignore
/sip-servlets-impl/.classpath
/sip-servlets-impl/.project
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/InitialRequestDispatcher.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/RequestDispatcher.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/SubsequentRequestDispatcher.java
=======================================
--- /.gitignore Mon Jun 4 09:18:04 2012 UTC
+++ /.gitignore Tue Aug 21 23:53:09 2012 UTC
@@ -6,8 +6,8 @@
classes
*.zip
# ignore eclipse files
-#.project
-#.classpath
+.project
+.classpath
.settings
.metadata
# ignore IDEA files
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/InitialRequestDispatcher.java
Tue Apr 1 12:35:32 2014 UTC
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/InitialRequestDispatcher.java
Tue Aug 21 23:53:09 2012 UTC
@@ -48,7 +48,6 @@
import javax.sip.SipException;
import javax.sip.SipProvider;
import javax.sip.address.Address;
-import javax.sip.header.ContactHeader;
import javax.sip.address.URI;
import javax.sip.header.CSeqHeader;
import javax.sip.header.Header;
@@ -454,57 +453,6 @@
}
- /**
- * NOTE! This is only a partial implementation and will only work
- * when we are acting as a UAS as per RFC 5626 Section 4.3. Sending
Non-REGISTER Requests.
- * Need to add some more logic for proxy scenarios. See RFC 5626 for
exact details.
- *
- * The purpose of this method is to examine the request in an effort
- * to determine if the logic of RFC 5626 should be applied. I.e., should
- * we create and store a "flow" for this request so that subsequent
requests
- * will use the same connection as they "arrived" on.
- *
- * @param request
- */
- private void handleSipOutbound(final SipServletRequestImpl
sipServletRequest) {
-
- // if this is not a dialog creating request, then bail out
right away
- if
(!JainSipUtils.DIALOG_CREATING_METHODS.contains(sipServletRequest.getMethod()))
{
- return;
- }
-
- final Request request = (Request)
sipServletRequest.getMessage();
- final ContactHeader contact = (ContactHeader)
request.getHeader(ContactHeader.NAME);
-
- final URI requestUri = request.getRequestURI();
-
- //
- if ((contact != null && contact.getAddress().getURI() instanceof
Parameters &&
((Parameters)contact.getAddress().getURI()).getParameter(SIP_OUTBOUND_PARAM_OB) !=
null)) {
- final String remoteHost =
sipServletRequest.getRemoteAddr();
- final int remotePort =
sipServletRequest.getRemotePort();
- final String transport =
sipServletRequest.getTransport();
- final MobicentsSipSession sipSessionImpl =
sipServletRequest.getSipSession();
-
- try {
- final javax.sip.address.SipURI flowURI =
SipFactoryImpl.addressFactory.createSipURI(null, remoteHost);
- flowURI.setPort(remotePort);
- flowURI.setTransportParam(transport);
-
- sipSessionImpl.setFlow(flowURI);
- } catch (final ParseException e) {
- logger.warn("Unable to create new flow URI from " +
remoteHost + ":"
- + remotePort + ";transport=" + transport + " due to a parse
exception");
- }
- } else if(sipServletRequest.getPoppedRouteHeader() != null &&
(requestUri instanceof javax.sip.address.SipURI &&
((javax.sip.address.SipURI)requestUri).getParameter(SIP_OUTBOUND_PARAM_OB) !=
null)) {
- // If there is a route on the request, then we are
acting as a proxy
- final javax.sip.address.SipURI poppedURI = (javax.sip.address.SipURI)
sipServletRequest.getPoppedRouteHeader().getAddress().getURI();
- String flowToken = poppedURI.getUser();
- //TODO validate flow token and information and check it against session
flow token
- // See Section 5.3
- return;
- }
- }
-
/**
* Dispatch a request outside the container
@@ -531,7 +479,7 @@
try {
forwardRequestStatefully(sipServletRequest,
SipSessionRoutingType.PREVIOUS_SESSION, SipRouteModifier.NO_ROUTE);
} catch (Exception e) {
- throw new
DispatcherException(Response.SERVER_INTERNAL_ERROR, "Unexpected Exception
while trying to forward statefully the following subsequent request " +
request, e);
+ throw new
DispatcherException(Response.SERVER_INTERNAL_ERROR, "Unexpected Exception
while trying to forward statefully the following initial request " +
request, e);
}
} else {
// the Request-URI does not point to another domain, and there is no
Route header,
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/RequestDispatcher.java
Tue Sep 13 20:23:18 2011 UTC
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/RequestDispatcher.java
Tue Aug 21 23:53:09 2012 UTC
@@ -36,8 +36,11 @@
import javax.sip.SipProvider;
import javax.sip.Transaction;
import javax.sip.TransactionUnavailableException;
+import javax.sip.address.URI;
+import javax.sip.header.ContactHeader;
import javax.sip.header.ContentTypeHeader;
import javax.sip.header.MaxForwardsHeader;
+import javax.sip.header.Parameters;
import javax.sip.header.ViaHeader;
import javax.sip.message.Request;
import javax.sip.message.Response;
@@ -282,4 +285,56 @@
dialog.sendRequest(clientTransaction);
}
}
+
+ /**
+ * NOTE! This is only a partial implementation and will only work
+ * when we are acting as a UAS as per RFC 5626 Section 4.3. Sending
Non-REGISTER Requests.
+ * Need to add some more logic for proxy scenarios. See RFC 5626 for
exact details.
+ *
+ * The purpose of this method is to examine the request in an effort
+ * to determine if the logic of RFC 5626 should be applied. I.e., should
+ * we create and store a "flow" for this request so that subsequent
requests
+ * will use the same connection as they "arrived" on.
+ *
+ * @param request
+ */
+ protected void handleSipOutbound(final SipServletRequestImpl
sipServletRequest) {
+
+ // if this is not a dialog creating request, then bail out
right away
+ if
(!JainSipUtils.DIALOG_CREATING_METHODS.contains(sipServletRequest.getMethod()))
{
+ return;
+ }
+
+ final Request request = (Request)
sipServletRequest.getMessage();
+ final ContactHeader contact = (ContactHeader)
request.getHeader(ContactHeader.NAME);
+
+ final URI requestUri = request.getRequestURI();
+
+ //
+ if ((contact != null && contact.getAddress().getURI() instanceof
Parameters &&
((Parameters)contact.getAddress().getURI()).getParameter(SIP_OUTBOUND_PARAM_OB) !=
null)) {
+ final String remoteHost =
sipServletRequest.getRemoteAddr();
+ final int remotePort =
sipServletRequest.getRemotePort();
+ final String transport =
sipServletRequest.getTransport();
+ final MobicentsSipSession sipSessionImpl =
sipServletRequest.getSipSession();
+
+ try {
+ final javax.sip.address.SipURI flowURI =
SipFactoryImpl.addressFactory.createSipURI(null, remoteHost);
+ flowURI.setPort(remotePort);
+ flowURI.setTransportParam(transport);
+
+ sipSessionImpl.setFlow(flowURI);
+ } catch (final ParseException e) {
+ logger.warn("Unable to create new flow URI from " +
remoteHost + ":"
+ + remotePort + ";transport=" + transport + " due to a parse
exception");
+ }
+ } else if(sipServletRequest.getPoppedRouteHeader() != null &&
(requestUri instanceof javax.sip.address.SipURI &&
((javax.sip.address.SipURI)requestUri).getParameter(SIP_OUTBOUND_PARAM_OB) !=
null)) {
+ // If there is a route on the request, then we are
acting as a proxy
+ final javax.sip.address.SipURI poppedURI = (javax.sip.address.SipURI)
sipServletRequest.getPoppedRouteHeader().getAddress().getURI();
+ String flowToken = poppedURI.getUser();
+ //TODO validate flow token and information and check it against session
flow token
+ // See Section 5.3
+ return;
+ }
+ }
+
}
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/SubsequentRequestDispatcher.java
Tue Apr 1 12:35:32 2014 UTC
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/SubsequentRequestDispatcher.java
Tue Aug 21 23:53:09 2012 UTC
@@ -331,6 +331,12 @@
}
}
sipSession.setRequestsPending(sipSession.getRequestsPending() + 1);
+
+ // The fastest way to figure out the transport is the
mandatory Via transport header
+ final ViaHeader via = (ViaHeader)
request.getHeader(ViaHeader.NAME);
+ sipSession.setTransport(via.getTransport());
+
+ handleSipOutbound(sipServletRequest);
}
// Issue 1714 : do the validation after lock acquisition to avoid
conccurency on CSeq validation
// if a concurrency control mode is used
--
---
You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.