Revision: 29d74d612ce6
Author: vralev <vralev@8e71dc83-d81e-6649-80f2-80b843a9b2be>
Date: Fri Jul 13 05:08:46 2012
Log: Update Issue 7
Backporting to ts1
JSIP-416
Fix SipStackExt::getLocalAddressForTcpDst and
SipStackExt::getLocalAddressForTlsDst do not work with NIO by Alexander
Saveliev, Avistar
git-svn-id:
https://svn.java.net/svn/jsip~svn/branches/JAIN-SIP-NIO-year-2012@2130
8e71dc83-d81e-6649-80f2-80b843a9b2be
(cherry picked from commit 218743d33c2e4f202e09911e416085290b6a9204)
http://code.google.com/p/jain-sip/source/detail?r=29d74d612ce6
Modified:
/src/gov/nist/javax/sip/stack/SIPTransactionStack.java
=======================================
--- /src/gov/nist/javax/sip/stack/SIPTransactionStack.java Fri Apr 13
08:43:43 2012
+++ /src/gov/nist/javax/sip/stack/SIPTransactionStack.java Fri Jul 13
05:08:46 2012
@@ -612,6 +612,18 @@
*/
public SocketAddress getLocalAddressForTcpDst(InetAddress dst, int
dstPort,
InetAddress localAddress, int localPort) throws IOException {
+ if (getMessageProcessorFactory() instanceof
NioMessageProcessorFactory) {
+ // First find the TLS message processor
+ MessageProcessor[] processors = getMessageProcessors();
+ for (MessageProcessor processor : processors){
+ if ("TCP".equals(processor.getTransport())) {
+ NioTcpMessageChannel msgChannel =
+ (NioTcpMessageChannel)
processor.createMessageChannel(dst, dstPort);
+ return
msgChannel.socketChannel.socket().getLocalSocketAddress();
+ }
+ }
+ return null;
+ }
return this.ioHandler.getLocalAddressForTcpDst(
dst, dstPort, localAddress, localPort);
}
@@ -637,25 +649,25 @@
int dstPort, InetAddress localAddress) throws IOException {
// First find the TLS message processor
- TLSMessageProcessor tlsProcessor = null;
MessageProcessor[] processors = getMessageProcessors();
for (MessageProcessor processor : processors){
if(processor instanceof TLSMessageProcessor){
- tlsProcessor = (TLSMessageProcessor)processor;
- break;
+ // Here we don't create the channel but if the channel is
already
+ // existing will be returned
+ TLSMessageChannel msgChannel =
+ (TLSMessageChannel)
processor.createMessageChannel(dst, dstPort);
+
+ return this.ioHandler.getLocalAddressForTlsDst(
+ dst, dstPort, localAddress, msgChannel);
+ } else if(processor instanceof NioTlsMessageProcessor) {
+ NioTlsMessageChannel msgChannel =
+ (NioTlsMessageChannel)
processor.createMessageChannel(dst, dstPort);
+ return
msgChannel.socketChannel.socket().getLocalSocketAddress();
}
}
- if(tlsProcessor == null)
- return null;
-
- // Here we don't create the channel but if the channel is already
- // existing will be returned
- TLSMessageChannel msgChannel =
- (TLSMessageChannel)tlsProcessor.createMessageChannel(dst,
dstPort);
-
- return this.ioHandler.getLocalAddressForTlsDst(
- dst, dstPort, localAddress, msgChannel);
+ return null;
+
}
/**