diff --git a/lib/installer-exclude/ice4j.jar b/lib/installer-exclude/ice4j.jar
index 6b44eea42..c6e7b1372 100644
Binary files a/lib/installer-exclude/ice4j.jar and b/lib/installer-exclude/ice4j.jar differ
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index a088e6c0d..0e41386ef 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -1100,6 +1100,7 @@ impl.packetlogging.PACKET_LOGGING_CONFIG=Packet Logging
impl.packetlogging.ENABLE_DISABLE=Enable packet logging
impl.packetlogging.PACKET_LOGGING_RTP=RTP
impl.packetlogging.PACKET_LOGGING_RTP_DESCRIPTION=(stores 1 packet out of every 5000)
+impl.packetlogging.PACKET_LOGGING_ICE4J=Ice4J
impl.packetlogging.PACKET_LOGGING_DESCRIPTION=Logs debug packets of various protocols in the
log folder using pcap format (tcpdump/wireshark).
impl.packetlogging.PACKET_LOGGING_FILE_COUNT=Number of log files
impl.packetlogging.PACKET_LOGGING_FILE_SIZE=Maximum file size (in KB)
diff --git a/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java b/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java
new file mode 100644
index 000000000..c41e5ad09
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java
@@ -0,0 +1,56 @@
+package net.java.sip.communicator.impl.netaddr;
+
+import net.java.sip.communicator.service.packetlogging.*;
+import org.ice4j.stack.*;
+
+/**
+ * Logs Packets coming and going through ice4j stack.
+ * @author Damian Minkov
+ */
+public class Ice4jPacketLogger
+ implements PacketLogger
+{
+ /**
+ * Logs a incoming or outgoing packet.
+ *
+ * @param sourceAddress the source address of the packet.
+ * @param sourcePort the source port.
+ * @param destinationAddress the destination address of the packet.
+ * @param destinationPort the destination port.
+ * @param packetContent the content of the packet.
+ * @param sender whether we are sending or not the packet.
+ */
+ public void logPacket(byte[] sourceAddress,
+ int sourcePort,
+ byte[] destinationAddress,
+ int destinationPort,
+ byte[] packetContent,
+ boolean sender)
+ {
+ if(isEnabled())
+ {
+ NetaddrActivator.getPacketLogging()
+ .logPacket(
+ PacketLoggingService.ProtocolName.ICE4J,
+ sourceAddress,
+ sourcePort,
+ destinationAddress,
+ destinationPort,
+ PacketLoggingService.TransportName.UDP,
+ sender,
+ packetContent
+ );
+ }
+ }
+
+ /**
+ * Checks whether the logger is enabled.
+ * @return true if the logger is enabled, false
+ * otherwise.
+ */
+ public boolean isEnabled()
+ {
+ return NetaddrActivator.getPacketLogging()
+ .isLoggingEnabled(PacketLoggingService.ProtocolName.ICE4J);
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java b/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java
index f4cb7c9c5..b120def6c 100644
--- a/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java
+++ b/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java
@@ -6,6 +6,7 @@
*/
package net.java.sip.communicator.impl.netaddr;
+import net.java.sip.communicator.service.packetlogging.*;
import org.osgi.framework.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.netaddr.*;
@@ -28,6 +29,12 @@ public class NetaddrActivator
private NetworkAddressManagerServiceImpl networkAMS = null;
private static ConfigurationService configurationService = null;
+ /**
+ * The OSGi PacketLoggingService in
+ * {@link #bundleContext} and used for debugging.
+ */
+ private static PacketLoggingService packetLoggingService = null;
+
/**
* Creates a NetworkAddressManager, starts it, and registers it as a
* NetworkAddressManagerService.
@@ -91,6 +98,29 @@ public static ConfigurationService getConfigurationService()
return configurationService;
}
+ /**
+ * Returns a reference to the PacketLoggingService implementation
+ * currently registered in the bundle context or null if no such
+ * implementation was found.
+ *
+ * @return a reference to a PacketLoggingService implementation
+ * currently registered in the bundle context or null if no such
+ * implementation was found.
+ */
+ public static PacketLoggingService getPacketLogging()
+ {
+ if (packetLoggingService == null)
+ {
+ ServiceReference plReference
+ = bundleContext.getServiceReference(
+ PacketLoggingService.class.getName());
+
+ packetLoggingService
+ = (PacketLoggingService)bundleContext.getService(plReference);
+ }
+ return packetLoggingService;
+ }
+
/**
* Stops the Network Address Manager bundle
*
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java
index 351564352..6270df7d8 100644
--- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java
@@ -23,6 +23,7 @@
import org.ice4j.ice.*;
import org.ice4j.ice.harvest.*;
import org.ice4j.security.*;
+import org.ice4j.stack.*;
/**
* This implementation of the Network Address Manager allows you to
@@ -90,6 +91,9 @@ public class NetworkAddressManagerServiceImpl
public void start()
{
this.localHostFinderSocket = initRandomPortSocket();
+
+ // set packet logging to ice4j stack
+ StunStack.setPacketLogger(new Ice4jPacketLogger());
}
/**
@@ -569,7 +573,9 @@ public void removeNetworkConfigurationChangeListener(
*/
public Agent createIceAgent()
{
- return new Agent();
+ Agent a = new Agent();
+// a.getStunStack().
+ return a;
}
/**
diff --git a/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf b/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf
index dfc057730..2f0266b93 100644
--- a/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf
+++ b/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf
@@ -5,6 +5,7 @@ Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
System-Bundle: yes
Import-Package: net.java.sip.communicator.service.configuration,
+ net.java.sip.communicator.service.packetlogging,
net.java.sip.communicator.util,
org.osgi.framework,
javax.crypto,
diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java
index a958dd577..076ac36d7 100644
--- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java
+++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java
@@ -89,6 +89,13 @@ public class PacketLoggingActivator
private final static String PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME
= "net.java.sip.communicator.packetlogging.PACKET_LOGGING_RTP_ENABLED";
+ /**
+ * Configuration property for packet logging for
+ * ICE4J enabled/disabled.
+ */
+ private final static String PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME
+ = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ICE4J_ENABLED";
+
/**
* Configuration property for packet logging file count.
*/
@@ -121,6 +128,11 @@ public class PacketLoggingActivator
*/
private static boolean rtpLoggingEnabled = false;
+ /**
+ * Is Packet Logging Service enabled for ice4j.
+ */
+ private static boolean ice4jLoggingEnabled = false;
+
/**
* Creates a PacketLoggingServiceImpl, starts it, and registers it as a
* PacketLoggingService.
@@ -195,6 +207,9 @@ private void loadConfig()
rtpLoggingEnabled = getConfigurationService().getBoolean(
PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME, false);
+
+ ice4jLoggingEnabled = getConfigurationService().getBoolean(
+ PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, false);
}
/**
@@ -296,6 +311,16 @@ public static boolean isRTPLoggingEnabled()
return rtpLoggingEnabled;
}
+ /**
+ * Checks whether packet logging is enabled in the configuration
+ * for Ice4J.
+ * @return true if packet logging is enabled for RTP.
+ */
+ public static boolean isIce4JLoggingEnabled()
+ {
+ return ice4jLoggingEnabled;
+ }
+
/**
* Change whether packet logging is enabled and save it in configuration.
* @param enabled true if we enable it.
@@ -316,6 +341,7 @@ static void setGlobalLoggingEnabled(boolean enabled)
sipLoggingEnabled = false;
jabberLoggingEnabled = false;
rtpLoggingEnabled = false;
+ ice4jLoggingEnabled = false;
}
globalLoggingEnabled = enabled;
@@ -384,6 +410,27 @@ public static void setRTPLoggingEnabled(boolean enabled)
rtpLoggingEnabled = true;
}
+ /**
+ * Change whether packet logging for Ice4J is enabled
+ * and save it in configuration.
+ * @param enabled true if we enable it.
+ */
+ public static void setIce4JLoggingEnabled(boolean enabled)
+ {
+ if(enabled)
+ {
+ getConfigurationService().setProperty(
+ PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, Boolean.TRUE);
+ }
+ else
+ {
+ getConfigurationService().removeProperty(
+ PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME);
+ }
+
+ ice4jLoggingEnabled = true;
+ }
+
/**
* Our packet logging service instance.
*/
diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java
index e60079d44..4301f95fe 100644
--- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java
+++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java
@@ -42,6 +42,11 @@ public class PacketLoggingConfigForm
*/
private JCheckBox rtpProtocolCheckBox;
+ /**
+ * Check box to enable/disable packet debug of Ice4J.
+ */
+ private JCheckBox ice4jProtocolCheckBox;
+
/**
* The file count label.
*/
@@ -102,6 +107,10 @@ private void init()
rtpProtocolCheckBox.addActionListener(this);
rtpProtocolCheckBox.setToolTipText(rtpDescription);
+ ice4jProtocolCheckBox = new JCheckBox(
+ resources.getI18NString("impl.packetlogging.PACKET_LOGGING_ICE4J"));
+ ice4jProtocolCheckBox.addActionListener(this);
+
JPanel mainPanel = new TransparentPanel();
add(mainPanel, BorderLayout.NORTH);
@@ -138,6 +147,7 @@ private void init()
loggersButtonPanel.add(sipProtocolCheckBox);
loggersButtonPanel.add(jabberProtocolCheckBox);
loggersButtonPanel.add(rtpProtocolCheckBox);
+ loggersButtonPanel.add(ice4jProtocolCheckBox);
c.insets = new Insets(0, 20, 10, 0);
c.gridy = 2;
@@ -179,6 +189,8 @@ private void loadValues()
PacketLoggingActivator.isJabberLoggingEnabled());
rtpProtocolCheckBox.setSelected(
PacketLoggingActivator.isRTPLoggingEnabled());
+ ice4jProtocolCheckBox.setSelected(
+ PacketLoggingActivator.isIce4JLoggingEnabled());
fileCountField.setText(String.valueOf(PacketLoggingActivator
.getPacketLoggingService().getLogfileCount()));
fileSizeField.setText(String.valueOf(PacketLoggingActivator
@@ -195,6 +207,7 @@ private void updateButtonsState()
sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
+ ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
fileCountField.setEnabled(enableCheckBox.isSelected());
fileSizeField.setEnabled(enableCheckBox.isSelected());
fileSizeLabel.setEnabled(enableCheckBox.isSelected());
@@ -230,6 +243,11 @@ else if(source.equals(rtpProtocolCheckBox))
PacketLoggingActivator.setRTPLoggingEnabled(
rtpProtocolCheckBox.isSelected());
}
+ else if(source.equals(ice4jProtocolCheckBox))
+ {
+ PacketLoggingActivator.setIce4JLoggingEnabled(
+ ice4jProtocolCheckBox.isSelected());
+ }
}
/**
diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java
index 924bbdb87..e1905b486 100644
--- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java
@@ -311,6 +311,9 @@ public boolean isLoggingEnabled(ProtocolName protocol)
case RTP:
return PacketLoggingActivator.isGlobalLoggingEnabled()
&& PacketLoggingActivator.isRTPLoggingEnabled();
+ case ICE4J:
+ return PacketLoggingActivator.isGlobalLoggingEnabled()
+ && PacketLoggingActivator.isIce4JLoggingEnabled();
default:
return false;
}