diff --git a/src/org/ice4j/socket/DelegatingDatagramSocket.java b/src/org/ice4j/socket/DelegatingDatagramSocket.java
index 160a900..aee2ab2 100644
--- a/src/org/ice4j/socket/DelegatingDatagramSocket.java
+++ b/src/org/ice4j/socket/DelegatingDatagramSocket.java
@@ -89,44 +89,6 @@ public class DelegatingDatagramSocket
|| ((numOfPacket % 5000) == 0);
}
- /**
- * Logs a packet (STUN/TURN or RTP) to the pcap file.
- *
- * @param p the DatagramPacket received/sent.
- * @param isSent True if this packet is sent. False if this packet is
- * received.
- * @param interfaceAddress The InetAddress bind by this socket to the local
- * interface (0.0.0.0 or ::0 is the socket is not bound).
- * @param interfacePort The port bind by this socket to the local interface.
- */
- static void logPacketToPcap(
- DatagramPacket p,
- boolean isSent,
- InetAddress interfaceAddress,
- int interfacePort)
- {
- // The interfaceAddress may be null if the socket is closed before this
- // packet has been logged. In this case, this packet is not logged.
- if (interfaceAddress != null)
- {
- InetAddress[] addr = {interfaceAddress, p.getAddress()};
- int[] port = {interfacePort, p.getPort()};
- int fromIndex = isSent ? 0 : 1;
- int toIndex = isSent ? 1 : 0;
-
- if(StunStack.isPacketLoggerEnabled())
- {
- StunStack.getPacketLogger().logPacket(
- addr[fromIndex].getAddress(),
- port[fromIndex],
- addr[toIndex].getAddress(),
- port[toIndex],
- p.getData(),
- isSent);
- }
- }
- }
-
/**
* The DatagramSocket to which this
* DelegatingDatagramSocket delegates its calls.
@@ -698,7 +660,13 @@ public class DelegatingDatagramSocket
if (StunDatagramPacketFilter.isStunPacket(p)
|| logNonStun(++nbReceivedPackets))
- logPacketToPcap(p, false, getLocalAddress(), getLocalPort());
+ {
+ StunStack.logPacketToPcap(
+ p,
+ false,
+ getLocalAddress(),
+ getLocalPort());
+ }
}
else
{
@@ -767,7 +735,13 @@ public class DelegatingDatagramSocket
}
if (logNonStun(++nbSentPackets))
- logPacketToPcap(p, true, getLocalAddress(), getLocalPort());
+ {
+ StunStack.logPacketToPcap(
+ p,
+ true,
+ getLocalAddress(),
+ getLocalPort());
+ }
}
// Else, the delegate socket will encapsulate the packet.
else
diff --git a/src/org/ice4j/socket/DelegatingSocket.java b/src/org/ice4j/socket/DelegatingSocket.java
index 909ea53..4a7e912 100644
--- a/src/org/ice4j/socket/DelegatingSocket.java
+++ b/src/org/ice4j/socket/DelegatingSocket.java
@@ -6,6 +6,8 @@
*/
package org.ice4j.socket;
+import org.ice4j.stack.*;
+
import java.io.*;
import java.net.*;
import java.nio.*;
@@ -570,10 +572,13 @@ public class DelegatingSocket
if (StunDatagramPacketFilter.isStunPacket(p)
|| DelegatingDatagramSocket.logNonStun(++nbReceivedPackets))
- DelegatingDatagramSocket.logPacketToPcap(
- p,
- false,
- localAddress.getAddress(), localAddress.getPort());
+ {
+ StunStack.logPacketToPcap(
+ p,
+ false,
+ localAddress.getAddress(),
+ localAddress.getPort());
+ }
}
}
@@ -657,10 +662,13 @@ public class DelegatingSocket
= (InetSocketAddress) super.getLocalSocketAddress();
if (DelegatingDatagramSocket.logNonStun(++nbSentPackets))
- DelegatingDatagramSocket.logPacketToPcap(
- p,
- true,
- localAddress.getAddress(), localAddress.getPort());
+ {
+ StunStack.logPacketToPcap(
+ p,
+ true,
+ localAddress.getAddress(),
+ localAddress.getPort());
+ }
}
}
diff --git a/src/org/ice4j/stack/StunStack.java b/src/org/ice4j/stack/StunStack.java
index 580e976..370fbcc 100644
--- a/src/org/ice4j/stack/StunStack.java
+++ b/src/org/ice4j/stack/StunStack.java
@@ -1579,4 +1579,40 @@ public class StunStack
return null;
}
}
+
+ /**
+ * Logs a specific DatagramPacket using the packet logger of the
+ * StunStack.
+ *
+ * @param p The DatagramPacket to log.
+ * @param isSent true if the packet is sent, or false
+ * if the packet is received.
+ * @param interfaceAddress The InetAddress to use as source (if
+ * the packet was sent) or destination (if the packet was received).
+ * @param interfacePort The port to use as source (if the packet was sent)
+ * or destination (if the packet was received).
+ */
+ public static void logPacketToPcap(
+ DatagramPacket p,
+ boolean isSent,
+ InetAddress interfaceAddress,
+ int interfacePort)
+ {
+ if (interfaceAddress != null && isPacketLoggerEnabled())
+ {
+ InetAddress[] addr = {interfaceAddress, p.getAddress()};
+ int[] port = {interfacePort, p.getPort()};
+ int fromIndex = isSent ? 0 : 1;
+ int toIndex = isSent ? 1 : 0;
+
+ getPacketLogger().logPacket(
+ addr[fromIndex].getAddress(),
+ port[fromIndex],
+ addr[toIndex].getAddress(),
+ port[toIndex],
+ p.getData(),
+ isSent);
+ }
+ }
+
}