Makes jain-sip bind on ::0 rather than 0.0.0.0 so that it would also listen for incoming IPv6 packets. (Was working before but is currently failing on Mac OS X).This resolves the "Port Unreachable" replies we

were getting in some cases.
Adds a method that allows to determine whether the local host has IPv6 in order to only use the above where appropriate.
Updates jain-sip-ri to 1.2.95 so that it would include support for address scope zones in IPv6 addresses.
Adds the possibility to set log levels for jain-sip through our own logging.properties file by setting a level to the gov.nist packages.
cusax-fix
Emil Ivov 17 years ago
parent bcada6b6cc
commit 0b06b480a1

@ -450,7 +450,7 @@
</target>
<target name="prepare-single-test"
depends="identify-test"
depends="identify-test"
if="test.name.known">
<!--internal-target- prepare to run a single Service Impl Compatibility Kit -->
<!-- extract the simple Test class name...
@ -574,7 +574,7 @@
</junitreport>
</target>
<target name="run-simple-tests"
depends="prepare-all-tests,prepare-local-accounts,deploy-os-specific-bundles"
description="runs selected non-felix tests under junit.">
@ -647,7 +647,7 @@
value="${lib}/logging.properties"/>
<sysproperty key="java.net.preferIPv6Addresses"
value="false"/>
value="true"/>
<!--sysproperty key="net.java.sip.communicator.SC_HOME_DIR_LOCATION"
value="${user.home}/schome"/-->
@ -655,7 +655,7 @@
<!-- Setting properties necessary for dependencies on native libs.-->
<sysproperty key="java.library.path"
path="${ld.library.path}:${path}:${dyld.library.path}"/>
<sysproperty key="jna.library.path"
<sysproperty key="jna.library.path"
path="${ld.library.path}:${path}:${dyld.library.path}"/>
<!-- pass l10n properties from ant call for
@ -788,7 +788,7 @@
bundle-audionotifier,bundle-plugin-branding,
bundle-systray,bundle-browserlauncher,bundle-gibberish,
bundle-gibberish-slick,bundle-plugin-gibberishaccregwizz,
bundle-plugin-call-history-form,
bundle-plugin-call-history-form,
bundle-rss, bundle-rss-slick,bundle-plugin-rssaccregwizz,
bundle-zeroconf,bundle-plugin-zeroconfaccregwizz,bundle-plugin-whiteboard,
bundle-irc,bundle-plugin-ircaccregwizz,
@ -963,10 +963,10 @@
prefix="resources/images/impl/media"/>
<zipfileset src="${lib.win.noinst}/jmf.jar" prefix=""/>
<zipfileset src="${lib.win.noinst}/sound.jar" prefix=""/>
<zipfileset src="${lib.noinst}/nist-sdp-1.0.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jain-sdp.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jspeex.jar" prefix=""/>
<zipfileset src="${lib.noinst}/fmj.jar" prefix=""/>
<zipfileset src="${lib.noinst}/fmj.jar" prefix=""/>
<zipfileset src="${lib.noinst}/lti-civil-no_s_w_t.jar" prefix=""/>
</jar>
@ -983,10 +983,10 @@
<zipfileset dir="${resources}/images/impl/media"
prefix="resources/images/impl/media"/>
<zipfileset src="${lib.lin.noinst}/jmf.jar" prefix=""/>
<zipfileset src="${lib.noinst}/nist-sdp-1.0.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jain-sdp.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jspeex.jar" prefix=""/>
<zipfileset src="${lib.noinst}/fmj.jar" prefix=""/>
<zipfileset src="${lib.noinst}/fmj.jar" prefix=""/>
<zipfileset src="${lib.noinst}/lti-civil-no_s_w_t.jar" prefix=""/>
</jar>
@ -1003,10 +1003,10 @@
<zipfileset dir="${resources}/images/impl/media"
prefix="resources/images/impl/media"/>
<zipfileset src="${lib.mac.noinst}/jmf.jar" prefix=""/>
<zipfileset src="${lib.noinst}/nist-sdp-1.0.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jain-sdp.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jspeex.jar" prefix=""/>
<zipfileset src="${lib.noinst}/fmj.jar" prefix=""/>
<zipfileset src="${lib.noinst}/fmj.jar" prefix=""/>
<zipfileset src="${lib.noinst}/lti-civil-no_s_w_t.jar" prefix=""/>
</jar>
@ -1098,8 +1098,8 @@ javax.swing.event, javax.swing.border"/>
manifest="${src}/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/impl/protocol/sip"
prefix="net/java/sip/communicator/impl/protocol/sip"/>
<zipfileset src="${lib.noinst}/jain-sip-ri-1.2.92.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jain-sip-api-1.2.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jain-sip-ri.jar" prefix=""/>
<zipfileset src="${lib.noinst}/jain-sip-api.jar" prefix=""/>
<zipfileset src="${lib.noinst}/concurrent.jar" prefix=""/>
<zipfileset src="${lib.noinst}/log4j-1.2.8.jar" prefix=""/>
</jar>
@ -1416,7 +1416,7 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/plugin/sipaccregwizz"/>
</jar>
</target>
<!-- BUNDLE-PLUGIN-GIBBERISHACCREGWIZZ -->
<target name="bundle-plugin-gibberishaccregwizz">
<!-- Creates a bundle for the plugin Gibberish Account Registration
@ -1939,8 +1939,8 @@ javax.swing.event, javax.swing.border"/>
<manifest>
<attribute name="Export-Package" value="gnu.java.zrtp,gnu.java.zrtp.packets,gnu.java.zrtp.utils,gnu.java.zrtp.zidfile"/>
<attribute name="Import-Package" value=" org.bouncycastle.crypto,org.bouncycastle.crypto.digests,org.bouncycastle.crypto.macs,
org.bouncycastle.crypto.params,org.bouncycastle.crypto.engines,org.bouncycastle.crypto.agreement,
org.bouncycastle.crypto.generators,org.bouncycastle.crypto.modes "/>
org.bouncycastle.crypto.params,org.bouncycastle.crypto.engines,org.bouncycastle.crypto.agreement,
org.bouncycastle.crypto.generators,org.bouncycastle.crypto.modes "/>
<attribute name="Bundle-Name" value="ZRTP4J"/>
<attribute name="Bundle-Description" value="ZRTP for Java library."/>
<attribute name="Bundle-Version" value="1.4.3"/>

@ -15,8 +15,8 @@
<classpathentry kind="lib" path="lib/installer-exclude/dnsjava-2.0.3.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/izpack-shortcut-link.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-api-1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-ri-1.2.92.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-api.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-ri.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jcalendar-1.3.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jdic_misc.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jdom.jar"/>
@ -35,7 +35,7 @@
<classpathentry kind="lib" path="lib/installer-exclude/laf-widget.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/log4j-1.2.8.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/lti-civil-no_s_w_t.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/nist-sdp-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sdp.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/pircbot.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/profiler4j-1.0-beta3-SC.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/rome-0.9.jar"/>

@ -494,7 +494,7 @@ public boolean stopStreaming()
private boolean stopSendStreaming()
{
boolean stoppedAtLeastOneStream = false;
RTPManager audioRtpManager = getAudioRtpManager();
if ((audioRtpManager != null)
&& stopSendStreaming(audioRtpManager))
@ -2046,7 +2046,8 @@ private void allocateMediaPorts(InetAddress intendedDestination)
// Get our local address for the intended destination.
// Use this address to bind our local RTP sockets
InetAddress inAddrLocal = netAddressManager.getLocalHost(intendedDestination);
InetAddress inAddrLocal
= netAddressManager.getLocalHost(intendedDestination);
//check the number of times that we'd have to retry binding to local
//ports before giving up.
@ -2151,9 +2152,9 @@ private void initializeRtpManager(RTPManager rtpManager,
// - if no other audio session was started before then this will
// become
// ZRTP Master session
// - only the ZRTP master sessions start in "auto-sensing" mode
// - only the ZRTP master sessions start in "auto-sensing" mode
// to immediately catch ZRTP communication from other client
// - after the master session has completed its key negotiation
// - after the master session has completed its key negotiation
// it will start other media sessions (see SCCallback)
if (rtpManager.equals(audioRtpManager))
{
@ -3295,7 +3296,7 @@ public void dispose()
/**
* Sets a <tt>SessionCreatorCallback</tt> that will listen for
* security events.
*
*
* @param securityCallBack the <tt>SessionCreatorCallback</tt> to
* set
*/
@ -3308,7 +3309,7 @@ public void setSessionCreatorCallback(
/**
* Returns the <tt>SessionCreatorCallback</tt> which listens for
* security events.
*
*
* @return the <tt>SessionCreatorCallback</tt> which listens for
* security events
*/

@ -71,6 +71,11 @@ public void start(BundleContext context)
"net.java.sip.communicator.impl.media.MediaConfigurationPanel",
getClass().getClassLoader(), "plugin.mediaconfig.PLUGIN_ICON",
"impl.media.configform.TITLE"), null);
//we use the nist-sdp stack to make parse sdp and we need to set the
//following property to make sure that it would accept java generated
//IPv6 addresses that contain address scope zones.
System.setProperty("gov.nist.core.STRIP_ADDR_SCOPES", "true");
}
/**

@ -1528,6 +1528,7 @@ public Address getOurSipAddress(SipURI intendedDestination)
}
catch (ParseException exc)
{
logger.trace("Failed to create our SIP AOR address", exc);
// this should never happen since we are using InetAddresses
// everywhere so parsing could hardly go wrong.
throw new IllegalArgumentException(

@ -7,11 +7,16 @@
package net.java.sip.communicator.impl.protocol.sip;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.LogManager;
import net.java.sip.communicator.util.Logger;
/**
* The properties used at the creation of the JAIN-SIP stack.
*
* @author Sebastien Mazy
* @author Emil Ivov
*/
public class SipStackProperties
extends Properties
@ -109,7 +114,7 @@ public class SipStackProperties
* A String indicating the default debug level for the jain-sip-ri (must be
* log4j compatible).
*/
private static final String NSPVALUE_TRACE_LEVEL = "ERROR";
private static final String NSPVALUE_DEFAULT_TRACE_LEVEL = "ERROR";
/**
* The name of the property under which jain-sip will know if it must
@ -196,9 +201,6 @@ public SipStackProperties()
this.setProperty(NSPNAME_CACHE_CLIENT_CONNECTIONS,
NSPVALUE_CACHE_CLIENT_CONNECTIONS);
// Log level
this.setProperty(NSPNAME_TRACE_LEVEL, NSPVALUE_TRACE_LEVEL);
// deliver unsolicited NOTIFY
this.setProperty(NSPNAME_DELIVER_UNSOLICITED_NOTIFY,
NSPVALUE_DELIVER_UNSOLICITED_NOTIFY);
@ -212,5 +214,51 @@ public SipStackProperties()
// our ProxyRouter will send the message to the outbound proxy
this.setProperty(NSPNAME_ROUTER_PATH,
NSPVALUE_ROUTER_PATH);
//make sure that jain-sip would accept java generated addresses
//containing address scope zones
System.setProperty("gov.nist.core.STRIP_ADDR_SCOPES", "true");
//set stack log (trace) level properties according to parameters
//set in logging.properties for the gov.nist packages
String logLevel
= LogManager.getLogManager().getProperty("gov.nist.level");
String jainSipTraceLevel = null;
//if this is a java logging level - convert it to a NIST level
if (logLevel == null)
{
jainSipTraceLevel = NSPVALUE_DEFAULT_TRACE_LEVEL;
}
else if (logLevel.equals(Level.FINEST.getName()))
{
jainSipTraceLevel = "TRACE";
}
else if (logLevel.equals(Level.FINER.getName()))
{
jainSipTraceLevel = "DEBUG";
}
else if (logLevel.equals(Level.FINE.getName()))
{
jainSipTraceLevel = "INFO";
}
else if (logLevel.equals(Level.WARNING.getName())
|| logLevel.equals(Level.SEVERE.getName()))
{
jainSipTraceLevel = "ERROR";
}
else if (logLevel.equals(Level.OFF))
{
jainSipTraceLevel = "OFF";
}
else
{
//doesn't look like a java logging level, so we just supposed the
//string was a jain-sip level and pass it directly
jainSipTraceLevel = logLevel;
}
this.setProperty(NSPNAME_TRACE_LEVEL, jainSipTraceLevel);
}
}

@ -23,10 +23,21 @@ public class NetworkUtils
{
private static final Logger logger
= Logger.getLogger(NetworkUtils.class);
/**
* A string containing the "any" local address for IPv6.
*/
public static final String IN6_ADDR_ANY = "::0";
/**
* A string containing the "any" local address for IPv4.
*/
public static final String IN4_ADDR_ANY = "0.0.0.0";
/**
* A string containing the "any" local address.
*/
public static final String IN_ADDR_ANY = "0.0.0.0";
public static final String IN_ADDR_ANY = determineAnyAddress();
/**
* The maximum int value that could correspond to a port nubmer.
@ -390,4 +401,46 @@ public static InetAddress getInetAddress(String hostAddress)
return InetAddress.getByName(hostAddress);
}
}
/**
* Tries to determine if this host supports IPv6 addresses (i.e. has at
* least one IPv6 address) and returns IN6_ADDR_ANY or IN4_ADDR_ANY
* accordingly. This method is only used to initialize IN_ADDR_ANY so that
* it could be used when binding sockets. The reason we need it is because
* on mac (contrary to lin or win) binding a socket on 0.0.0.0 would make
* it deaf to IPv6 traffic. Binding on ::0 does the trick but that would
* fail on hosts that have no IPv6 support. Using the result of this method
* provides an easy way to bind sockets in cases where we simply want any
* IP packets coming on the port we are listening on (regardless of IP
* version).
*
* @return IN6_ADDR_ANY or IN4_ADDR_ANY if this host supports or not IPv6.
*/
private static String determineAnyAddress()
{
Enumeration<NetworkInterface> ifaces;
try
{
ifaces = NetworkInterface.getNetworkInterfaces();
}
catch (SocketException e)
{
logger.debug("Couldn't retrieve local interfaces.", e);
return IN4_ADDR_ANY;
}
while(ifaces.hasMoreElements())
{
Enumeration<InetAddress> addrs
= ifaces.nextElement().getInetAddresses();
while (addrs.hasMoreElements())
{
if(addrs.nextElement() instanceof Inet6Address)
return IN6_ADDR_ANY;
}
}
return IN4_ADDR_ANY;
}
}

Loading…
Cancel
Save