Exposes the "logPacketToPcap" method, because it is used in Jitsi.
This commit is contained in:
parent
3355481bf8
commit
bd3f6c663f
@ -89,44 +89,6 @@ public class DelegatingDatagramSocket
|
|||||||
|| ((numOfPacket % 5000) == 0);
|
|| ((numOfPacket % 5000) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a packet (STUN/TURN or RTP) to the pcap file.
|
|
||||||
*
|
|
||||||
* @param p the <tt>DatagramPacket</tt> 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 <tt>DatagramSocket</tt> to which this
|
* The <tt>DatagramSocket</tt> to which this
|
||||||
* <tt>DelegatingDatagramSocket</tt> delegates its calls.
|
* <tt>DelegatingDatagramSocket</tt> delegates its calls.
|
||||||
@ -698,7 +660,13 @@ public class DelegatingDatagramSocket
|
|||||||
|
|
||||||
if (StunDatagramPacketFilter.isStunPacket(p)
|
if (StunDatagramPacketFilter.isStunPacket(p)
|
||||||
|| logNonStun(++nbReceivedPackets))
|
|| logNonStun(++nbReceivedPackets))
|
||||||
logPacketToPcap(p, false, getLocalAddress(), getLocalPort());
|
{
|
||||||
|
StunStack.logPacketToPcap(
|
||||||
|
p,
|
||||||
|
false,
|
||||||
|
getLocalAddress(),
|
||||||
|
getLocalPort());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -767,7 +735,13 @@ public class DelegatingDatagramSocket
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (logNonStun(++nbSentPackets))
|
if (logNonStun(++nbSentPackets))
|
||||||
logPacketToPcap(p, true, getLocalAddress(), getLocalPort());
|
{
|
||||||
|
StunStack.logPacketToPcap(
|
||||||
|
p,
|
||||||
|
true,
|
||||||
|
getLocalAddress(),
|
||||||
|
getLocalPort());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Else, the delegate socket will encapsulate the packet.
|
// Else, the delegate socket will encapsulate the packet.
|
||||||
else
|
else
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.ice4j.socket;
|
package org.ice4j.socket;
|
||||||
|
|
||||||
|
import org.ice4j.stack.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
@ -570,10 +572,13 @@ public class DelegatingSocket
|
|||||||
|
|
||||||
if (StunDatagramPacketFilter.isStunPacket(p)
|
if (StunDatagramPacketFilter.isStunPacket(p)
|
||||||
|| DelegatingDatagramSocket.logNonStun(++nbReceivedPackets))
|
|| DelegatingDatagramSocket.logNonStun(++nbReceivedPackets))
|
||||||
DelegatingDatagramSocket.logPacketToPcap(
|
{
|
||||||
p,
|
StunStack.logPacketToPcap(
|
||||||
false,
|
p,
|
||||||
localAddress.getAddress(), localAddress.getPort());
|
false,
|
||||||
|
localAddress.getAddress(),
|
||||||
|
localAddress.getPort());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,10 +662,13 @@ public class DelegatingSocket
|
|||||||
= (InetSocketAddress) super.getLocalSocketAddress();
|
= (InetSocketAddress) super.getLocalSocketAddress();
|
||||||
|
|
||||||
if (DelegatingDatagramSocket.logNonStun(++nbSentPackets))
|
if (DelegatingDatagramSocket.logNonStun(++nbSentPackets))
|
||||||
DelegatingDatagramSocket.logPacketToPcap(
|
{
|
||||||
p,
|
StunStack.logPacketToPcap(
|
||||||
true,
|
p,
|
||||||
localAddress.getAddress(), localAddress.getPort());
|
true,
|
||||||
|
localAddress.getAddress(),
|
||||||
|
localAddress.getPort());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1579,4 +1579,40 @@ public class StunStack
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a specific <tt>DatagramPacket</tt> using the packet logger of the
|
||||||
|
* <tt>StunStack</tt>.
|
||||||
|
*
|
||||||
|
* @param p The <tt>DatagramPacket</tt> to log.
|
||||||
|
* @param isSent <tt>true</tt> if the packet is sent, or <tt>false</tt>
|
||||||
|
* if the packet is received.
|
||||||
|
* @param interfaceAddress The <tt>InetAddress</tt> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user