diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-03-11 22:15:03 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-03-11 22:15:03 +0100 |
commit | 85901329b0794b136b96bf745f4ab1572806fc89 (patch) | |
tree | f23da7e97cae727f39d825f0fef8348cffb238e4 /src/net/java/sip/communicator/impl/packetlogging | |
parent | 3db2e44f186c59429901b2c899e139ea60117a55 (diff) | |
parent | cf5da997da8820b4050f5b87ee9440a0ede36d1f (diff) | |
download | jitsi-master.zip jitsi-master.tar.gz jitsi-master.tar.bz2 |
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'src/net/java/sip/communicator/impl/packetlogging')
3 files changed, 50 insertions, 21 deletions
diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java index b26b11a..978c74c 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java @@ -60,6 +60,10 @@ public class PacketLoggingConfigurationImpl configService.getBoolean( PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, isIce4JLoggingEnabled())); + super.setArbitraryLoggingEnabled( + configService.getBoolean( + PACKET_LOGGING_ARBITRARY_ENABLED_PROPERTY_NAME, + isArbitraryLoggingEnabled())); super.setLimit( configService.getLong( PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME, diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java index 788e8db..1e459f1 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java @@ -20,6 +20,7 @@ package net.java.sip.communicator.impl.packetlogging; import java.io.*; import java.util.*; +import com.google.common.collect.*; import net.java.sip.communicator.util.*; import org.jitsi.service.fileaccess.*; @@ -41,6 +42,14 @@ public class PacketLoggingServiceImpl = Logger.getLogger(PacketLoggingServiceImpl.class); /** + * The max size of the <tt>EvictingQueue</tt> that the saver thread + * is using. + * + * TODO this needs to be configurable eventually. + */ + private static final int EVICTING_QUEUE_MAX_SIZE = 1000; + + /** * The OutputStream we are currently writing to. */ private FileOutputStream outputStream = null; @@ -62,10 +71,17 @@ public class PacketLoggingServiceImpl new byte[]{ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x08, (byte)0x00 + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }; + /** IEEE 802.3 EtherType for IPv4 */ + private final static byte[] ipv4EtherType = + new byte[] { 0x08, 0x00 }; + + /** IEEE 802.3 EtherType for IPv6 */ + private final static byte[] ipv6EtherType = + new byte[] { (byte)0x86, (byte)0xdd }; + /** * The fake ipv4 header we use as template. */ @@ -313,22 +329,22 @@ public class PacketLoggingServiceImpl { switch(protocol) { - case SIP: - return cfg.isSipLoggingEnabled(); - case JABBER: - return cfg.isJabberLoggingEnabled(); - case RTP: - return cfg.isRTPLoggingEnabled(); - case ICE4J: - return cfg.isIce4JLoggingEnabled(); - default: - /* - * It may seem like it was unnecessary to invoke - * getConfiguration and isGlobalLoggingEnabled prior to - * checking that the specified protocol is supported but, - * actually, there are no other ProtocolName values. - */ - return false; + case SIP: + return cfg.isSipLoggingEnabled(); + case JABBER: + return cfg.isJabberLoggingEnabled(); + case RTP: + return cfg.isRTPLoggingEnabled(); + case ICE4J: + return cfg.isIce4JLoggingEnabled(); + case ARBITRARY: + return cfg.isArbitraryLoggingEnabled(); + default: + // It may seem like it was unnecessary to invoke + // getConfiguration and isGlobalLoggingEnabled prior to checking + // that the specified protocol is supported but, actually, there + // are no other ProtocolName values. + return false; } } else @@ -553,6 +569,7 @@ public class PacketLoggingServiceImpl int tsSec = (int)(current/1000); int tsUsec = (int)((current%1000) * 1000); int feakHeaderLen = fakeEthernetHeader.length + + (isIPv4 ? ipv4EtherType : ipv6EtherType).length + ipHeader.length + transportHeader.length; int inclLen = packet.packetLength + feakHeaderLen; int origLen = inclLen; @@ -577,6 +594,7 @@ public class PacketLoggingServiceImpl addInt(origLen); outputStream.write(fakeEthernetHeader); + outputStream.write(isIPv4 ? ipv4EtherType : ipv6EtherType); outputStream.write(ipHeader); outputStream.write(transportHeader); outputStream.write( @@ -767,7 +785,8 @@ public class PacketLoggingServiceImpl /** * List of packets queued to be written in the file. */ - private final List<Packet> pktsToSave = new ArrayList<Packet>(); + private final EvictingQueue<Packet> pktsToSave + = EvictingQueue.create(EVICTING_QUEUE_MAX_SIZE); /** * Initializes a new <tt>SaverThread</tt>. @@ -803,7 +822,7 @@ public class PacketLoggingServiceImpl continue; } - pktToSave = pktsToSave.remove(0); + pktToSave = pktsToSave.poll(); } if(pktToSave != null) @@ -842,6 +861,11 @@ public class PacketLoggingServiceImpl */ public synchronized void queuePacket(Packet packet) { + if (EVICTING_QUEUE_MAX_SIZE - pktsToSave.size() == 0) + { + logger.warn("Queue is full, packets are being evicted."); + } + pktsToSave.add(packet); notifyAll(); } diff --git a/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf b/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf index 374294f..2099f02 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf +++ b/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf @@ -16,4 +16,5 @@ Import-Package: org.osgi.framework, javax.swing, javax.swing.border, javax.swing.event, - javax.swing.text + javax.swing.text, + com.google.common.collect |