From 5255c03037737fc58839e519adf6e595e0f778ef Mon Sep 17 00:00:00 2001 From: Vincent Perot Date: Tue, 3 Jun 2014 17:37:09 -0400 Subject: [PATCH] tmf: Initial commit of Pcap Parser This commit is the first step toward adding pcap-reading abilities to TMF. It only adds the parser, and as such it is completely independent from TMF. The parser supports four protocols (Ethernet, IPv4, TCP, UDP) and both microsecond and nanosecond pcap files. Change-Id: I334571c06a44cec99f9e37011fbfaa27b6a414e3 Signed-off-by: Vincent Perot Reviewed-on: https://git.eclipse.org/r/27887 Reviewed-by: Alexandre Montplaisir Tested-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- .../.classpath | 7 + .../.project | 34 + .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.core.runtime.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 393 ++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 56 ++ .../.settings/org.eclipse.pde.api.tools.prefs | 97 +++ .../.settings/org.eclipse.pde.prefs | 32 + .../META-INF/MANIFEST.MF | 14 + .../about.html | 28 + .../build.properties | 20 + .../plugin.properties | 15 + .../pom.xml | 46 ++ .../linuxtools/pcap/core/tests/AllTests.java | 27 + org.eclipse.linuxtools.pcap.core/.classpath | 7 + org.eclipse.linuxtools.pcap.core/.project | 34 + .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.core.runtime.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 393 ++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 56 ++ .../.settings/org.eclipse.pde.api.tools.prefs | 97 +++ .../.settings/org.eclipse.pde.prefs | 32 + .../META-INF/MANIFEST.MF | 27 + org.eclipse.linuxtools.pcap.core/about.html | 28 + .../build.properties | 21 + .../plugin.properties | 16 + org.eclipse.linuxtools.pcap.core/pom.xml | 36 + .../internal/pcap/core/Activator.java | 138 ++++ .../internal/pcap/core/package-info.java | 14 + .../pcap/core/endpoint/ProtocolEndpoint.java | 82 ++ .../core/endpoint/ProtocolEndpointPair.java | 96 +++ .../pcap/core/endpoint/package-info.java | 14 + .../pcap/core/filter/IPacketFilter.java | 33 + .../core/filter/PacketFilterByProtocol.java | 52 ++ .../pcap/core/filter/package-info.java | 14 + .../pcap/core/packet/BadPacketException.java | 68 ++ .../linuxtools/pcap/core/packet/Packet.java | 298 ++++++++ .../pcap/core/packet/PacketUniqueID.java | 93 +++ .../pcap/core/packet/package-info.java | 14 + .../pcap/core/protocol/Protocol.java | 154 ++++ .../pcap/core/protocol/ProtocolValues.java | 51 ++ .../ethernet2/EthernetIIEndpoint.java | 98 +++ .../protocol/ethernet2/EthernetIIPacket.java | 306 ++++++++ .../protocol/ethernet2/EthernetIIValues.java | 39 + .../core/protocol/ethernet2/package-info.java | 14 + .../pcap/core/protocol/ipv4/IPv4Endpoint.java | 98 +++ .../pcap/core/protocol/ipv4/IPv4Packet.java | 635 ++++++++++++++++ .../pcap/core/protocol/ipv4/IPv4Values.java | 33 + .../pcap/core/protocol/ipv4/package-info.java | 14 + .../pcap/core/protocol/package-info.java | 14 + .../pcap/core/protocol/pcap/PcapEndpoint.java | 71 ++ .../pcap/core/protocol/pcap/PcapPacket.java | 372 +++++++++ .../pcap/core/protocol/pcap/package-info.java | 14 + .../pcap/core/protocol/tcp/TCPEndpoint.java | 97 +++ .../pcap/core/protocol/tcp/TCPPacket.java | 707 ++++++++++++++++++ .../pcap/core/protocol/tcp/TCPValues.java | 30 + .../pcap/core/protocol/tcp/package-info.java | 14 + .../pcap/core/protocol/udp/UDPEndpoint.java | 96 +++ .../pcap/core/protocol/udp/UDPPacket.java | 301 ++++++++ .../pcap/core/protocol/udp/package-info.java | 14 + .../protocol/unknown/UnknownEndpoint.java | 56 ++ .../core/protocol/unknown/UnknownPacket.java | 213 ++++++ .../core/protocol/unknown/package-info.java | 14 + .../pcap/core/stream/PacketStream.java | 149 ++++ .../pcap/core/stream/PacketStreamBuilder.java | 181 +++++ .../pcap/core/stream/package-info.java | 14 + .../pcap/core/trace/BadPcapFileException.java | 64 ++ .../linuxtools/pcap/core/trace/PcapFile.java | 407 ++++++++++ .../pcap/core/trace/PcapFileValues.java | 45 ++ .../pcap/core/trace/package-info.java | 14 + .../pcap/core/util/ConversionHelper.java | 206 +++++ .../pcap/core/util/EthertypeHelper.java | 82 ++ .../core/util/IPProtocolNumberHelper.java | 81 ++ .../pcap/core/util/LinkTypeHelper.java | 79 ++ .../pcap/core/util/PcapTimestampScale.java | 26 + .../pcap/core/util/package-info.java | 14 + 76 files changed, 7257 insertions(+) create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.classpath create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.project create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.resources.prefs create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs create mode 100644 org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.prefs create mode 100644 org.eclipse.linuxtools.pcap.core.tests/META-INF/MANIFEST.MF create mode 100644 org.eclipse.linuxtools.pcap.core.tests/about.html create mode 100644 org.eclipse.linuxtools.pcap.core.tests/build.properties create mode 100644 org.eclipse.linuxtools.pcap.core.tests/plugin.properties create mode 100644 org.eclipse.linuxtools.pcap.core.tests/pom.xml create mode 100644 org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllTests.java create mode 100644 org.eclipse.linuxtools.pcap.core/.classpath create mode 100644 org.eclipse.linuxtools.pcap.core/.project create mode 100644 org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.resources.prefs create mode 100644 org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.runtime.prefs create mode 100644 org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.core.prefs create mode 100644 org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.ui.prefs create mode 100644 org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.api.tools.prefs create mode 100644 org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.prefs create mode 100644 org.eclipse.linuxtools.pcap.core/META-INF/MANIFEST.MF create mode 100644 org.eclipse.linuxtools.pcap.core/about.html create mode 100644 org.eclipse.linuxtools.pcap.core/build.properties create mode 100644 org.eclipse.linuxtools.pcap.core/plugin.properties create mode 100644 org.eclipse.linuxtools.pcap.core/pom.xml create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpointPair.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/IPacketFilter.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/PacketFilterByProtocol.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/BadPacketException.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/Packet.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/PacketUniqueID.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/Protocol.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ProtocolValues.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIPacket.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIValues.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Endpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Packet.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Values.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapEndpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapPacket.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPEndpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPPacket.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPValues.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPEndpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPPacket.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownEndpoint.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownPacket.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStream.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStreamBuilder.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/BadPcapFileException.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFile.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFileValues.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/package-info.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/ConversionHelper.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/EthertypeHelper.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/IPProtocolNumberHelper.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/LinkTypeHelper.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/PcapTimestampScale.java create mode 100644 org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/package-info.java diff --git a/org.eclipse.linuxtools.pcap.core.tests/.classpath b/org.eclipse.linuxtools.pcap.core.tests/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.eclipse.linuxtools.pcap.core.tests/.project b/org.eclipse.linuxtools.pcap.core.tests/.project new file mode 100644 index 0000000000..c0c7873e17 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.project @@ -0,0 +1,34 @@ + + + org.eclipse.linuxtools.pcap.core.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..5a0ad22d2a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..8cf4cd486e --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,393 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=error +org.eclipse.jdt.core.compiler.problem.deadCode=error +org.eclipse.jdt.core.compiler.problem.deprecation=error +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=error +org.eclipse.jdt.core.compiler.problem.emptyStatement=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=error +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=error +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=enabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=error +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error +org.eclipse.jdt.core.compiler.problem.potentialNullReference=error +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=error +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=error +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=error +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=error +org.eclipse.jdt.core.compiler.problem.unusedLocal=error +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=error +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error +org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=0 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=250 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..4fd0c7006a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,56 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_tmf-style +formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=false +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=false +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000000..acc3abd47c --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,97 @@ +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +API_USE_SCAN_FIELD_SEVERITY=Error +API_USE_SCAN_METHOD_SEVERITY=Error +API_USE_SCAN_TYPE_SEVERITY=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_JAVADOC_TAG=Warning +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Warning +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +MISSING_EE_DESCRIPTIONS=Ignore +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Warning +automatically_removed_unused_problem_filters=false +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Error +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.prefs b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..62cfa90dee --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.prefs @@ -0,0 +1,32 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=2 +compilers.p.build.java.compiler=2 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=2 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=2 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +eclipse.preferences.version=1 diff --git a/org.eclipse.linuxtools.pcap.core.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.pcap.core.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..b8e5f94d92 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-Vendor: %Bundle-Vendor +Bundle-Version: 3.0.0.qualifier +Bundle-Localization: plugin +Bundle-SymbolicName: org.eclipse.linuxtools.pcap.core.tests;singleton:=true +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Require-Bundle: org.junit;bundle-version="4.0.0", + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.linuxtools.pcap.core;bundle-version="3.0.0" +Export-Package: org.eclipse.linuxtools.pcap.core.tests diff --git a/org.eclipse.linuxtools.pcap.core.tests/about.html b/org.eclipse.linuxtools.pcap.core.tests/about.html new file mode 100644 index 0000000000..c258ef55d8 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 5, 2006

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core.tests/build.properties b/org.eclipse.linuxtools.pcap.core.tests/build.properties new file mode 100644 index 0000000000..2ccaf4558e --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/build.properties @@ -0,0 +1,20 @@ +############################################################################### +# Copyright (c) 2014 Ericsson +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Ericsson - Initial API and implementation +############################################################################### + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.properties +src.includes = about.html +additional.bundles = org.eclipse.jdt.annotation +jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation diff --git a/org.eclipse.linuxtools.pcap.core.tests/plugin.properties b/org.eclipse.linuxtools.pcap.core.tests/plugin.properties new file mode 100644 index 0000000000..2839a98dc9 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/plugin.properties @@ -0,0 +1,15 @@ +############################################################################### +# Copyright (c) 2014 Ericsson +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Ericsson - Initial API and implementation +############################################################################### + +#Properties file for org.eclipse.linuxtools.pcap.core.tests +Bundle-Vendor = Eclipse Linux Tools +Bundle-Name = Linux Tools Pcap Parser Core Tests Plug-in diff --git a/org.eclipse.linuxtools.pcap.core.tests/pom.xml b/org.eclipse.linuxtools.pcap.core.tests/pom.xml new file mode 100644 index 0000000000..3a8e772357 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/pom.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + + linuxtools-lttng-parent + org.eclipse.linuxtools.lttng + 3.0.0-SNAPSHOT + + + org.eclipse.linuxtools.pcap.core.tests + 1.0.0-SNAPSHOT + eclipse-test-plugin + + Linux Tools Pcap Parser Core Tests Plug-in + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + org.eclipse.linuxtools.pcap.core.tests + org.eclipse.linuxtools.pcap.core.tests.AllTests + false + false + org.eclipse.platform.ide + + + + + + org.eclipse.linuxtools.pcap + diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllTests.java new file mode 100644 index 0000000000..59db68ffe1 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllTests.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Montplaisir - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Master test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + //example: StateSystemPushPopTest.class, +}) +public class AllTests { + +} diff --git a/org.eclipse.linuxtools.pcap.core/.classpath b/org.eclipse.linuxtools.pcap.core/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.eclipse.linuxtools.pcap.core/.project b/org.eclipse.linuxtools.pcap.core/.project new file mode 100644 index 0000000000..965bfb79ae --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.project @@ -0,0 +1,34 @@ + + + org.eclipse.linuxtools.pcap.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.resources.prefs b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..5a0ad22d2a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..b2b3622179 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,393 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=error +org.eclipse.jdt.core.compiler.problem.deadCode=error +org.eclipse.jdt.core.compiler.problem.deprecation=error +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=error +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=error +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=enabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=error +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error +org.eclipse.jdt.core.compiler.problem.potentialNullReference=error +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=error +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=error +org.eclipse.jdt.core.compiler.problem.unusedLocal=error +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=error +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error +org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=0 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=250 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..4fd0c7006a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,56 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_tmf-style +formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=false +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=false +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.api.tools.prefs b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000000..acc3abd47c --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,97 @@ +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +API_USE_SCAN_FIELD_SEVERITY=Error +API_USE_SCAN_METHOD_SEVERITY=Error +API_USE_SCAN_TYPE_SEVERITY=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_JAVADOC_TAG=Warning +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Warning +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +MISSING_EE_DESCRIPTIONS=Ignore +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Warning +automatically_removed_unused_problem_filters=false +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Error +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.prefs b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..97b4320800 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.prefs @@ -0,0 +1,32 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=2 +compilers.p.build.java.compiler=2 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=1 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=2 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +eclipse.preferences.version=1 diff --git a/org.eclipse.linuxtools.pcap.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.pcap.core/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..66f9735156 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/META-INF/MANIFEST.MF @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-Vendor: %Bundle-Vendor +Bundle-Version: 3.0.0.qualifier +Bundle-Localization: plugin +Bundle-SymbolicName: org.eclipse.linuxtools.pcap.core;singleton:=true +Bundle-Activator: org.eclipse.linuxtools.internal.pcap.core.Activator +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.resources +Export-Package: org.eclipse.linuxtools.internal.pcap.core;x-friends:="org.eclipse.linuxtools.pcap.core.tests", + org.eclipse.linuxtools.pcap.core.endpoint, + org.eclipse.linuxtools.pcap.core.filter, + org.eclipse.linuxtools.pcap.core.packet, + org.eclipse.linuxtools.pcap.core.protocol, + org.eclipse.linuxtools.pcap.core.protocol.ethernet2, + org.eclipse.linuxtools.pcap.core.protocol.ipv4, + org.eclipse.linuxtools.pcap.core.protocol.pcap, + org.eclipse.linuxtools.pcap.core.protocol.tcp, + org.eclipse.linuxtools.pcap.core.protocol.udp, + org.eclipse.linuxtools.pcap.core.protocol.unknown, + org.eclipse.linuxtools.pcap.core.stream, + org.eclipse.linuxtools.pcap.core.trace, + org.eclipse.linuxtools.pcap.core.util +Import-Package: com.google.common.collect diff --git a/org.eclipse.linuxtools.pcap.core/about.html b/org.eclipse.linuxtools.pcap.core/about.html new file mode 100644 index 0000000000..28737f60b7 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 5, 2006

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/build.properties b/org.eclipse.linuxtools.pcap.core/build.properties new file mode 100644 index 0000000000..857bf1e800 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/build.properties @@ -0,0 +1,21 @@ +############################################################################### +# Copyright (c) 2014 Ericsson +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Ericsson - Initial API and implementation +############################################################################### + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + plugin.properties,\ + about.html,\ + . +src.includes = about.html +additional.bundles = org.eclipse.jdt.annotation +jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation diff --git a/org.eclipse.linuxtools.pcap.core/plugin.properties b/org.eclipse.linuxtools.pcap.core/plugin.properties new file mode 100644 index 0000000000..0a4f9c25f1 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/plugin.properties @@ -0,0 +1,16 @@ +############################################################################### +# Copyright (c) 2014 Ericsson +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Ericsson - Initial API and implementation +############################################################################### + +#Properties file for org.eclipse.linuxtools.pcap.core +Bundle-Vendor = Eclipse Linux Tools +Bundle-Name = Linux Tools Pcap Parser Core Plug-in + diff --git a/org.eclipse.linuxtools.pcap.core/pom.xml b/org.eclipse.linuxtools.pcap.core/pom.xml new file mode 100644 index 0000000000..0aad5da2b0 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + + linuxtools-lttng-parent + org.eclipse.linuxtools.lttng + 3.0.0-SNAPSHOT + + + org.eclipse.linuxtools.pcap.core + 1.0.0-SNAPSHOT + eclipse-plugin + + Linux Tools Pcap Parser Core Plug-in + + + + + org.eclipse.tycho + tycho-source-plugin + + + + + org.eclipse.linuxtools.pcap + diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java new file mode 100644 index 0000000000..885adc1726 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.internal.pcap.core; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.annotation.Nullable; +import org.osgi.framework.BundleContext; + +/** + * Activator + *

+ * The activator class controls the plug-in life cycle + */ +public final class Activator extends Plugin { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + /** + * The plug-in ID + */ + public static final String PLUGIN_ID = "org.eclipse.linuxtools.pcap.core"; //$NON-NLS-1$ + + /** + * The shared instance + */ + private static @Nullable Activator plugin; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * The constructor + */ + public Activator() { + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static @Nullable Activator getDefault() { + return plugin; + } + + // ------------------------------------------------------------------------ + // Operators + // ------------------------------------------------------------------------ + + @Override + public void start(@Nullable BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(@Nullable BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Logs a message with severity INFO in the runtime log of the plug-in. + * + * @param message A message to log + */ + public void logInfo(String message) { + getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message)); + } + + /** + * Logs a message and exception with severity INFO in the runtime log of the plug-in. + * + * @param message A message to log + * @param exception A exception to log + */ + public void logInfo(String message, Throwable exception) { + getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception)); + } + + /** + * Logs a message and exception with severity WARNING in the runtime log of the plug-in. + * + * @param message A message to log + */ + public void logWarning(String message) { + getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message)); + } + + /** + * Logs a message and exception with severity WARNING in the runtime log of the plug-in. + * + * @param message A message to log + * @param exception A exception to log + */ + public void logWarning(String message, Throwable exception) { + getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception)); + } + + /** + * Logs a message and exception with severity ERROR in the runtime log of the plug-in. + * + * @param message A message to log + */ + public void logError(String message) { + getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message)); + } + + /** + * Logs a message and exception with severity ERROR in the runtime log of the plug-in. + * + * @param message A message to log + * @param exception A exception to log + */ + public void logError(String message, Throwable exception) { + getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception)); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java new file mode 100644 index 0000000000..495502c7f8 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.internal.pcap.core; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpoint.java new file mode 100644 index 0000000000..cabb7c2065 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpoint.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.endpoint; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.Packet; + +/** + * Abstract class that represents an endpoint. An endpoint is an address where a + * packet is received or sent. Therefore, it is protocol dependent. For + * instance, an Ethernet II endpoint is the MAC address. An Ipv4 endpoint is the + * combination of the MAC address and the IP address. This is useful for + * building packet streams. + * + * @author Vincent Perot + */ +public abstract class ProtocolEndpoint { + + /** + * Empty string for child classes. + */ + protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + /** + * The encapsulating endpoint. Much like packets, endpoints are + * encapsulated. The higher the layer of the packet protocol is, the more + * parents an endpoint will have. + */ + private final @Nullable ProtocolEndpoint fParentEndpoint; + + /** + * Constructor of the {@link ProtocolEndpoint} class. It takes a packet to + * get its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public ProtocolEndpoint(Packet packet, boolean isSourceEndpoint) { + @Nullable Packet parentPacket = packet.getParentPacket(); + if (parentPacket == null) { + fParentEndpoint = null; + } else { + fParentEndpoint = isSourceEndpoint ? + parentPacket.getSourceEndpoint() : + parentPacket.getDestinationEndpoint(); + } + } + + /** + * Getter method that returns the parent endpoint. + * + * @return The parent endpoint. + */ + public @Nullable ProtocolEndpoint getParentEndpoint() { + return fParentEndpoint; + } + + @Override + public abstract int hashCode(); + + @Override + public abstract boolean equals(@Nullable Object obj); + + @Override + public abstract String toString(); + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpointPair.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpointPair.java new file mode 100644 index 0000000000..9f8826c23e --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/ProtocolEndpointPair.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.endpoint; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.Packet; + +/** + * Class that represents a pair of endpoints. This is used to find a packet + * stream between to endpoints. + * + * @author Vincent Perot + */ +public class ProtocolEndpointPair { + + private final ProtocolEndpoint fEndpointA; + private final ProtocolEndpoint fEndpointB; + + /** + * Constructor of the class {@link ProtocolEndpointPair}. It constructs a + * {@link ProtocolEndpointPair} object from a packet. + * + * @param packet + * The packet that contains the endpoints. + */ + public ProtocolEndpointPair(Packet packet) { + fEndpointA = packet.getSourceEndpoint(); + fEndpointB = packet.getDestinationEndpoint(); + } + + /** + * Getter method that returns the first endpoint of the pair. + * + * @return The first endpoint. + */ + public ProtocolEndpoint getFirstEndpoint() { + return fEndpointA; + } + + /** + * Getter method that returns the second endpoint of the pair. + * + * @return The second endpoint. + */ + public ProtocolEndpoint getSecondEndpoint() { + return fEndpointB; + } + + /** + * Constructor of the class {@link ProtocolEndpointPair}. It constructs a + * {@link ProtocolEndpointPair} object from two endpoints. + * + * @param endpointA + * The first endpoint. + * @param endpointB + * The second endpoint. + */ + public ProtocolEndpointPair(ProtocolEndpoint endpointA, ProtocolEndpoint endpointB) { + fEndpointA = endpointA; + fEndpointB = endpointB; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + fEndpointA.hashCode() * fEndpointB.hashCode(); + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + + if (this == obj) { + return true; + } + if (!(obj instanceof ProtocolEndpointPair)) { + return false; + } + ProtocolEndpointPair other = (ProtocolEndpointPair) obj; + + return (this.fEndpointA.equals(other.fEndpointA) && this.fEndpointB.equals(other.fEndpointB)) || + (this.fEndpointA.equals(other.fEndpointB) && this.fEndpointB.equals(other.fEndpointA)); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/package-info.java new file mode 100644 index 0000000000..a6748c1dda --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/endpoint/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.endpoint; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/IPacketFilter.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/IPacketFilter.java new file mode 100644 index 0000000000..80115eabc6 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/IPacketFilter.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.filter; + +import org.eclipse.linuxtools.pcap.core.packet.Packet; + +/** + * Interface used to filter the packets. + * + * @author Vincent Perot + */ +public interface IPacketFilter { + + /** + * Accept a packet or not. + * + * @param packet + * the packet to accept or not + * + * @return The decision regarding the packet. + */ + boolean accepts(Packet packet); +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/PacketFilterByProtocol.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/PacketFilterByProtocol.java new file mode 100644 index 0000000000..e3b5729fba --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/PacketFilterByProtocol.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.filter; + +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; + +/** + * Class used to filter the packets by protocol. This is used, for instance, to + * build the packet streams. + * + * @author Vincent Perot + */ +public class PacketFilterByProtocol implements IPacketFilter { + + private final Protocol fProtocol; + + /** + * Constructor of the PacketFilterByProtocol class. + * + * @param protocol + * The protocol that the incoming packets must contain. + */ + public PacketFilterByProtocol(Protocol protocol) { + fProtocol = protocol; + } + + @Override + public boolean accepts(Packet packet) { + return packet.hasProtocol(fProtocol); + } + + /** + * Getter method for the protocol of this filter. + * + * @return The protocol of this filter. + */ + public Protocol getProtocol() { + return fProtocol; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/package-info.java new file mode 100644 index 0000000000..b5af5d5dd7 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/filter/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.filter; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/BadPacketException.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/BadPacketException.java new file mode 100644 index 0000000000..83836f2763 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/BadPacketException.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.packet; + +/** + * Exception that is thrown when Packet is erroneous. This is different than an + * invalid packet. An invalid packet contains bad fields (such as bad checksum) + * and does not throw exceptions while an erroneous packet is a packet that is + * impossible to obtain. For instance, an erroneous packet can be smaller than + * the minimum required size. Erroneous packets throw BadPacketExceptions. + * + * @author Vincent Perot + */ +public class BadPacketException extends Exception { + + private static final long serialVersionUID = 7071588720009577619L; + + /** + * Default constructor with no message. + */ + public BadPacketException() { + super(); + } + + /** + * Constructor with an attached message. + * + * @param message + * The message attached to this exception + */ + public BadPacketException(String message) { + super(message); + } + + /** + * Re-throw an exception into this type. + * + * @param e + * The previous Exception we caught + */ + public BadPacketException(Exception e) { + super(e); + } + + /** + * Constructor with an attached message and re-throw an exception into this + * type. + * + * @param message + * The message attached to this exception + * @param exception + * The previous Exception caught + */ + public BadPacketException(String message, Throwable exception) { + super(message, exception); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/Packet.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/Packet.java new file mode 100644 index 0000000000..edc0820eaa --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/Packet.java @@ -0,0 +1,298 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.packet; + +import java.nio.ByteBuffer; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.ipv4.IPv4Packet; +import org.eclipse.linuxtools.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; + +// TODO For all packets, make checks on dimension. +// TODO maybe add a invalid packet type? + +/** + * Abstract class that implements the methods that are common to every packets. + * + * @author Vincent Perot + */ +public abstract class Packet { + + /** Empty string */ + protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + /** The Pcap File to which this packet belong */ + private final PcapFile fPcapFile; + + /** The parent packet of this packet */ + private final @Nullable Packet fParentPacket; + + /** The protocol that this packet uses */ + private final Protocol fProtocol; + + /** + * Constructor of the Packet Class. + * + * @param file + * The file to which this packet belongs. + * @param parent + * The parent packet of this packet. + * @param protocol + * The protocol of the packet. + */ + public Packet(PcapFile file, @Nullable Packet parent, Protocol protocol) { + fPcapFile = file; + fParentPacket = parent; + fProtocol = protocol; + } + + /** + * Getter method for the Pcap File that contains this packet. + * + * @return The Pcap File. + */ + public PcapFile getPcapFile() { + return fPcapFile; + } + + /** + * Method that returns the parent (encapsulating) packet of this packet. + * This method returns null if the packet is a Pcap Packet (highest level of + * encapsulation). + * + * @return The parent packet. + */ + public @Nullable Packet getParentPacket() { + return fParentPacket; + } + + /** + * Method that returns the child (encapsulated) packet of this packet. This + * method returns null if the packet is at the lowest level of + * encapsulation. + * + * @return The child packet. + */ + public abstract @Nullable Packet getChildPacket(); + + /** + * Getter method for the protocol of the packet. + * + * @return The protocol of the packet. + */ + public Protocol getProtocol() { + return fProtocol; + } + + /** + * Getter method for the payload of the packet. Returns null if there is no + * payload. + * + * @return the payload of the packet. + */ + public abstract @Nullable ByteBuffer getPayload(); + + /** + * Method that looks for the packet that respects the specified protocol. It + * will go through all the layers of encapsulation and return the wanted + * packet, or null if the protocol is not present. + * + * @param protocol + * The specified protocol. + * @return The packet that respects the protocol. + */ + public final @Nullable Packet getPacket(Protocol protocol) { + + Packet wantedPacket = this; + + while (wantedPacket != null) { + if (wantedPacket.getProtocol() == protocol) { + return wantedPacket; + } + wantedPacket = wantedPacket.getParentPacket(); + } + wantedPacket = this.getChildPacket(); + + while (wantedPacket != null) { + if (wantedPacket.getProtocol() == protocol) { + return wantedPacket; + } + wantedPacket = wantedPacket.getChildPacket(); + } + + return null; + } + + /** + * Method that looks if the protocol is contained in the packet, or in one + * of the encapsulating/encapsulated packet. It will go through all the + * layers of encapsulation and return true if it finds the specified + * protocol, and false otherwise. * + * + * @param protocol + * The specified protocol. + * @return The presence of the protocol. + */ + public final boolean hasProtocol(Protocol protocol) { + + // TODO Verify inputs + Packet wantedPacket = this; + + while (wantedPacket != null) { + if (wantedPacket.getProtocol() == protocol) { + return true; + } + wantedPacket = wantedPacket.getParentPacket(); + } + wantedPacket = this.getChildPacket(); + + while (wantedPacket != null) { + if (wantedPacket.getProtocol() == protocol) { + return true; + } + wantedPacket = wantedPacket.getChildPacket(); + } + + return false; + } + + /** + * Method that returns the most encapsulated packet possible. If the global + * packet contains the protocol Unknown, it will stop at the packet just + * before this protocol. This is because the {@link UnknownPacket} can be + * considered as plain payload. + * + * @return The most encapsulated packet. + */ + public Packet getMostEcapsulatedPacket() { + @NonNull + Packet packet = this; + while (packet.getProtocol() != Protocol.UNKNOWN) { + Packet childPacket = packet.getChildPacket(); + if (childPacket == null || childPacket.getProtocol() == Protocol.UNKNOWN) { + break; + } + packet = childPacket; + } + return packet; + } + + /** + * Method that look at the validity of the different fields (such as + * checksum). This is protocol dependent and is used to identify bad + * packets. + * + * @return The validity of the packet. + */ + public abstract boolean validate(); + + /** + * Internal method that is used to find the child packet. This is protocol + * dependent and must be implemented by each packet class. + * + * @return The child packet. + * @throws BadPacketException + * Thrown when the packet is erroneous. + */ + protected abstract @Nullable Packet findChildPacket() throws BadPacketException; + + /** + * This method returns the source endpoint of this packet. The endpoint is + * equivalent to the address of this packet, and is protocol dependent. For + * instance, a UDP endpoint is the combination of the MAC address, the IP + * address and the port number. + * + * @return The source endpoint of this packet. + */ + public abstract ProtocolEndpoint getSourceEndpoint(); + + /** + * This method returns the destination endpoint of this packet. The endpoint + * is equivalent to the address of this packet, and is protocol dependent. + * For instance, a UDP endpoint is the combination of the MAC address, the + * IP address and the port number. + * + * @return The destination endpoint of this packet. + */ + public abstract ProtocolEndpoint getDestinationEndpoint(); + + /** + * Method that returns all the fields of the packet as a Map. All child classes of {@link Packet} must implement this method. + * + * @return All the packet fields as a map. + */ + public abstract Map getFields(); + + /** + * Method that returns a short summary of the local packet, such as the most + * useful information. + * + * For instance, a possible summary string of an {@link IPv4Packet} can be: + * "Src: 192.168.0.1, Dst: 192.168.1.12". + * + * @return A short summary of the local packet, as a string. + */ + public abstract String getLocalSummaryString(); + + /** + * Method that returns the local meaning of a packet, based on its fields. + * + * For instance, a possible signification of an ARP packet can be: + * "Who has 192.168.1.12? Tell 192.168.0.1". + * + * @return The local meaning of the packet, as a string. + */ + protected abstract String getSignificationString(); + + /** + * Method that returns the global meaning of the packet. As such, it will + * look for the most relevant packet and display its signification. + * + * For instance, a possible signification of an ARP packet can be: + * "Who has 192.168.1.12? Tell 192.168.0.1". + * + * @return The meaning of the global packet, as a string. + */ + public final String getGlobalSummaryString() { + Packet packet = this.getMostEcapsulatedPacket(); + return packet.getSignificationString(); + } + + @Override + public abstract boolean equals(@Nullable Object obj); + + @Override + public abstract int hashCode(); + + /** + * Method that is used by child packet classes to verify if a bit is set. + * + * @param value + * the byte containing the flags. + * @param bit + * the bit index. + * @return Whether the bit is set or not. + */ + protected static final boolean isBitSet(byte value, int bit) { + if (bit < 0 || bit > 7) { + throw new IllegalArgumentException("The byte index is not valid!"); //$NON-NLS-1$ + } + return ((value >>> bit & 0b1) == 0b1); + } +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/PacketUniqueID.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/PacketUniqueID.java new file mode 100644 index 0000000000..5ce9f4571b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/PacketUniqueID.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.packet; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.pcap.PcapPacket; + +/** + * Class that represents a Packet ID. Using the information contained in this + * class, it is possible to retrieve a packet. This allows to tremendously + * reduce memory usage of packet streams while keeping good performance. + * + * @author Vincent Perot + */ +public class PacketUniqueID { + + private final String fPath; + private final long fIndex; + + /** + * Constructor. It builds the packet ID from a packet. + * + * @param packet + * The packet to build the ID from. + */ + public PacketUniqueID(Packet packet) { + fPath = packet.getPcapFile().getPath(); + PcapPacket pcapPacket = (PcapPacket) packet.getPacket(Protocol.PCAP); + fIndex = (pcapPacket == null ? -1 : pcapPacket.getIndex()); + } + + /** + * Getter method that returns the file path of the packet. + * + * @return The file path. + */ + public String getPath() { + return fPath; + } + + /** + * Getter method that returns the index within the file of the packet. + * + * @return The packet index. + */ + public long getIndex() { + return fIndex; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (fIndex ^ (fIndex >>> 32)); + result = prime * result + fPath.hashCode(); + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + PacketUniqueID other = (PacketUniqueID) obj; + if (fIndex != other.fIndex) { + return false; + } + if (fPath != other.fPath) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/package-info.java new file mode 100644 index 0000000000..5a173764d3 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/packet/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.packet; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/Protocol.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/Protocol.java new file mode 100644 index 0000000000..18c88b63a3 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/Protocol.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Enumeration used for describing the different known protocols. + * + * @author Vincent Perot + */ +public enum Protocol { + + // Layer 0 + /** + * The Pcap Protocol is not a real protocol but is used as an helper to + * generate Pcap packets. + */ + PCAP("Packet Capture", "pcap", ProtocolValues.LAYER_0, false), //$NON-NLS-1$ //$NON-NLS-2$ + + // Layer 1 + // Should always be empty. + + // Layer 2 + /** + * The description of the Ethernet II Protocol. + */ + ETHERNET_II("Ethernet II", "eth", ProtocolValues.LAYER_2, true), //$NON-NLS-1$ //$NON-NLS-2$ + + // Layer 3 + /** + * The description of the Internet Protocol Version 4. + */ + IPV4("Internet Protocol Version 4", "ipv4", ProtocolValues.LAYER_3, true), //$NON-NLS-1$ //$NON-NLS-2$ + + // Layer 4 + /** + * The description of the Transmission Control Protocol. + */ + TCP("Transmission Control Protocol", "tcp", ProtocolValues.LAYER_4, true), //$NON-NLS-1$ //$NON-NLS-2$ + /** + * The description of the User Datagram Protocol. + */ + UDP("User Datagram Protocol", "udp", ProtocolValues.LAYER_4, true), //$NON-NLS-1$ //$NON-NLS-2$ + + // Layer 5 + + // Layer 6 + + // Layer 7 + /** + * This protocol is used as an helper if the protocol of a packet is not + * recognized. Since all its data goes into payload, it can also be seen as + * a "payload packet". This is considered to be on layer 7 since its always + * the most encapsulated packet if present. + */ + UNKNOWN("Payload", "???", ProtocolValues.LAYER_7, false); //$NON-NLS-1$ //$NON-NLS-2$ + + // Fields + private final String fName; + private final String fShortName; + private final int fLayer; + private final boolean fSupportsStream; + + private Protocol(String name, String shortName, int layer, boolean supportsStream) { + fName = name; + fShortName = shortName; + fLayer = layer; + fSupportsStream = supportsStream; + } + + /** + * Getter method for the long name of the protocol. + * + * @return The long name of the protocol, as a string. + */ + public String getName() { + return fName; + } + + /** + * Getter method for the short name of the protocol. + * + * @return The short name of the protocol, as a string. + */ + public String getShortName() { + return fShortName; + } + + /** + * Getter method for the OSI layer of the protocol. + * + * @return The layer of the protocol. + */ + public int getLayer() { + return fLayer; + } + + /** + * Getter method that indicates if the protocol supports streams. + * + * @return Whether the protocol supports streams or not. + */ + public boolean supportsStream() { + return fSupportsStream; + } + + // TODO make an immutable list that holds this data instead of computing it + // everytime. + + /** + * Method that returns a list of all the protocols included in a certain OSI + * layer. + * + * @param layer + * The layer of the protocols. + * @return The protocols on that layer. + */ + public static List getProtocolsOnLayer(int layer) { + + if (layer > ProtocolValues.LAYER_7 || layer < ProtocolValues.LAYER_0) { + throw new IllegalArgumentException("The layer is invalid."); //$NON-NLS-1$ + } + + List protocolsOnLayer = new ArrayList<>(); + for (Protocol p : Protocol.values()) { + if (p.getLayer() == layer) { + protocolsOnLayer.add(p); + } + } + return protocolsOnLayer; + } + + /** + * Method that returns all the protocol defined. + * + * @return A list containing all the protocols. + */ + public static List getAllProtocols() { + return new ArrayList<>(Arrays.asList(Protocol.values())); + } +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ProtocolValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ProtocolValues.java new file mode 100644 index 0000000000..95d4e9b1e5 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ProtocolValues.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol; + +/** + * Interface that lists constants related to protocols/layers. + * + * See http://en.wikipedia.org/wiki/OSI_model#Description_of_OSI_layers. + * + * @author Vincent Perot + */ +public interface ProtocolValues { + + /** + * Layer 0. This layer is not an OSI layer but is used as an helper to store + * the pseudo-protocol PCAP. + */ + int LAYER_0 = 0; + + /** Layer 1 of the OSI model */ + int LAYER_1 = 1; + + /** Layer 2 of the OSI model */ + int LAYER_2 = 2; + + /** Layer 3 of the OSI model */ + int LAYER_3 = 3; + + /** Layer 4 of the OSI model */ + int LAYER_4 = 4; + + /** Layer 5 of the OSI model */ + int LAYER_5 = 5; + + /** Layer 6 of the OSI model */ + int LAYER_6 = 6; + + /** Layer 7 of the OSI model */ + int LAYER_7 = 7; + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java new file mode 100644 index 0000000000..e2fb07ff75 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.ethernet2; + +import java.util.Arrays; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; + +/** + * Class that extends the {@link ProtocolEndpoint} class. It represents the + * endpoint at an Ethernet II level. + * + * @author Vincent Perot + */ +public class EthernetIIEndpoint extends ProtocolEndpoint { + + private final byte[] fMacAddress; + + /** + * Constructor of the {@link EthernetIIEndpoint} class. It takes a packet to + * get its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public EthernetIIEndpoint(EthernetIIPacket packet, boolean isSourceEndpoint) { + super(packet, isSourceEndpoint); + fMacAddress = isSourceEndpoint ? packet.getSourceMacAddress() : packet.getDestinationMacAddress(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + result = 0; + } else { + result = endpoint.hashCode(); + } + result = prime * result + Arrays.hashCode(fMacAddress); + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof EthernetIIEndpoint)) { + return false; + } + + EthernetIIEndpoint other = (EthernetIIEndpoint) obj; + + // Check on layer + boolean localEquals = Arrays.equals(fMacAddress, other.fMacAddress); + if (!localEquals) { + return false; + } + + // Check above layers. + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint != null) { + return endpoint.equals(other.getParentEndpoint()); + } + return true; + } + + @Override + public String toString() { + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + return ConversionHelper.toMacAddress(fMacAddress); + } + return (endpoint.toString() == EMPTY_STRING ? + ConversionHelper.toMacAddress(fMacAddress) : + endpoint.toString() + '/' + ConversionHelper.toMacAddress(fMacAddress)); + + } +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIPacket.java new file mode 100644 index 0000000000..45a07a5215 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIPacket.java @@ -0,0 +1,306 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.ethernet2; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.ipv4.IPv4Packet; +import org.eclipse.linuxtools.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.pcap.core.util.EthertypeHelper; + +import com.google.common.collect.ImmutableMap; + +/** + * Class that represents an Ethernet II packet. This should be called an + * Ethernet frame, but in order to keep the nomenclature consistent, this is + * called a packet. + * + * @author Vincent Perot + */ +public class EthernetIIPacket extends Packet { + + private final @Nullable Packet fChildPacket; + private final @Nullable ByteBuffer fPayload; + + private final byte[] fSourceMacAddress; + private final byte[] fDestinationMacAddress; + private final int fType; + + private @Nullable EthernetIIEndpoint fSourceEndpoint; + private @Nullable EthernetIIEndpoint fDestinationEndpoint; + + private @Nullable ImmutableMap fFields; + + /** + * Constructor of the Ethernet Packet class. + * + * @param file + * The file that contains this packet. + * @param parent + * The parent packet of this packet (the encapsulating packet). + * @param packet + * The entire packet (header and payload). + * @throws BadPacketException + * Thrown when the packet is erroneous. + */ + public EthernetIIPacket(PcapFile file, @Nullable Packet parent, ByteBuffer packet) throws BadPacketException { + super(file, parent, Protocol.ETHERNET_II); + + if (packet.array().length <= EthernetIIValues.ETHERNET_II_MIN_SIZE) { + throw new BadPacketException("An Ethernet II packet can't be smaller than 14 bytes."); //$NON-NLS-1$ + } + + // The endpoints are lazy loaded. They are defined in the get*Endpoint() + // methods. + fSourceEndpoint = null; + fDestinationEndpoint = null; + + fFields = null; + + fDestinationMacAddress = new byte[EthernetIIValues.MAC_ADDRESS_SIZE]; + fSourceMacAddress = new byte[EthernetIIValues.MAC_ADDRESS_SIZE]; + packet.order(ByteOrder.BIG_ENDIAN); + packet.position(0); + packet.get(fDestinationMacAddress); + packet.get(fSourceMacAddress); + fType = ConversionHelper.unsignedShortToInt(packet.getShort()); + + // Get payload if it exists. + if (packet.array().length - packet.position() > 0) { + byte[] array = new byte[packet.array().length - packet.position()]; + packet.get(array); + ByteBuffer payload = ByteBuffer.wrap(array); + if (payload != null) { + payload.order(ByteOrder.BIG_ENDIAN); + payload.position(0); + } + fPayload = payload; + + } else { + fPayload = null; + } + + // Find child + fChildPacket = findChildPacket(); + + } + + @Override + public @Nullable Packet getChildPacket() { + return fChildPacket; + } + + @Override + public @Nullable ByteBuffer getPayload() { + return fPayload; + } + + /** + * Getter method for the source MAC Address. + * + * @return The source MAC address. + */ + public byte[] getSourceMacAddress() { + return fSourceMacAddress; + } + + /** + * Getter method for the destination MAC Address. + * + * @return The destination MAC address. + */ + public byte[] getDestinationMacAddress() { + return fDestinationMacAddress; + } + + /** + * Getter method for Ethertype. See + * http://standards.ieee.org/develop/regauth/ethertype/eth.txt + * + * @return The Ethertype. This is used to determine the child packet.. + */ + public int getEthertype() { + return fType; + } + + @Override + protected @Nullable Packet findChildPacket() throws BadPacketException { + // TODO Add more protocols. + ByteBuffer payload = fPayload; + if (payload == null) { + return null; + } + switch (fType) { + case EthertypeHelper.ETHERTYPE_IPV4: + return new IPv4Packet(getPcapFile(), this, payload); + default: + return new UnknownPacket(getPcapFile(), this, payload); + } + } + + @Override + public String toString() { + String string = getProtocol().getName() + ", Source: " + ConversionHelper.toMacAddress(fSourceMacAddress) + //$NON-NLS-1$ + ", Destination: " + ConversionHelper.toMacAddress(fDestinationMacAddress) + ", Type: " + //$NON-NLS-1$ //$NON-NLS-2$ + EthertypeHelper.toEtherType(fType) + "\n"; //$NON-NLS-1$ + final Packet child = fChildPacket; + if (child != null) { + return string + child.toString(); + } + return string; + } + + @Override + public boolean validate() { + // Not yet implemented. ATM, we consider that all packets are valid. + // This is the case for all packets. + // TODO Implement it. + return true; + } + + @Override + public EthernetIIEndpoint getSourceEndpoint() { + @Nullable EthernetIIEndpoint endpoint = fSourceEndpoint; + if (endpoint == null) { + endpoint = new EthernetIIEndpoint(this, true); + } + fSourceEndpoint = endpoint; + return fSourceEndpoint; + } + + @Override + public EthernetIIEndpoint getDestinationEndpoint() { + @Nullable EthernetIIEndpoint endpoint = fDestinationEndpoint; + + if (endpoint == null) { + endpoint = new EthernetIIEndpoint(this, false); + } + fDestinationEndpoint = endpoint; + return fDestinationEndpoint; + } + + @Override + public Map getFields() { + ImmutableMap map = fFields; + if (map == null) { + @SuppressWarnings("null") + @NonNull ImmutableMap newMap = ImmutableMap. builder() + .put("Source MAC Address", ConversionHelper.toMacAddress(fSourceMacAddress)) //$NON-NLS-1$ + .put("Destination MAC Address", ConversionHelper.toMacAddress(fDestinationMacAddress)) //$NON-NLS-1$ + .put("Ethertype", String.valueOf(EthertypeHelper.toEtherType(fType))) //$NON-NLS-1$ + .build(); + fFields = newMap; + return newMap; + } + return map; + } + + @Override + public String getLocalSummaryString() { + return "Src: " + ConversionHelper.toMacAddress(fSourceMacAddress) + " , Dst: " + ConversionHelper.toMacAddress(fDestinationMacAddress); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected String getSignificationString() { + return "Source MAC: " + ConversionHelper.toMacAddress(fSourceMacAddress) + " , Destination MAC: " + ConversionHelper.toMacAddress(fDestinationMacAddress); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + final Packet child = fChildPacket; + if (child != null) { + result = prime * result + child.hashCode(); + } else { + result = prime * result; + } + result = prime * result + Arrays.hashCode(fDestinationMacAddress); + final ByteBuffer payload = fPayload; + if (payload != null) { + result = prime * result + payload.hashCode(); + } else { + result = prime * result; + } + result = prime * result + Arrays.hashCode(fSourceMacAddress); + result = prime * result + fType; + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EthernetIIPacket other = (EthernetIIPacket) obj; + if (fChildPacket == null) { + if (other.fChildPacket != null) { + return false; + } + } else { + final Packet child = fChildPacket; + if (child != null) { + if (!child.equals(other.fChildPacket)) { + return false; + } + } else { + if (other.fChildPacket != null) { + return false; + } + } + } + if (!Arrays.equals(fDestinationMacAddress, other.fDestinationMacAddress)) { + return false; + } + if (fPayload == null) { + if (other.fPayload != null) { + return false; + } + } else { + final ByteBuffer payload = fPayload; + if (payload != null) { + if (!payload.equals(other.fPayload)) { + return false; + } + } else { + if (other.fPayload != null) { + return false; + } + } + } + if (!Arrays.equals(fSourceMacAddress, other.fSourceMacAddress)) { + return false; + } + if (fType != other.fType) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIValues.java new file mode 100644 index 0000000000..983123f784 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/EthernetIIValues.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.ethernet2; + +/** + * Interface that lists constants related to Ethernet II. + * + * See http://en.wikipedia.org/wiki/Ethernet_frame#Ethernet_II. + * + * @author Vincent Perot + */ +public interface EthernetIIValues { + + /** Size in bytes of a MAC address */ + int MAC_ADDRESS_SIZE = 6; + + /** Size in bytes of the ethertype field */ + int ETHERTYPE_SIZE = 4; + + /** Size in bytes of the CRC checksum */ + int CRC_CHECKSUM_SIZE = 4; + + /** Maximum size in bytes of a entire Ethernet II Frame */ + int ETHERNET_II_MAX_SIZE = 1518; + + /** Minimum size in bytes of a entire Ethernet II Frame */ + int ETHERNET_II_MIN_SIZE = 14; + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/package-info.java new file mode 100644 index 0000000000..fae76edd63 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ethernet2/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol.ethernet2; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Endpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Endpoint.java new file mode 100644 index 0000000000..96cde6f4fe --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Endpoint.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.ipv4; + +import java.util.Arrays; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; + +/** + * Class that extends the {@link ProtocolEndpoint} class. It represents the + * endpoint at an IPv4 level. + * + * @author Vincent Perot + */ +public class IPv4Endpoint extends ProtocolEndpoint { + + private final byte[] fIPAddress; + + /** + * Constructor of the {@link IPv4Endpoint} class. It takes a packet to get + * its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public IPv4Endpoint(IPv4Packet packet, boolean isSourceEndpoint) { + super(packet, isSourceEndpoint); + fIPAddress = isSourceEndpoint ? packet.getSourceIpAddress() : packet.getDestinationIpAddress(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + result = 0; + } else { + result = endpoint.hashCode(); + } + + result = prime * result + Arrays.hashCode(fIPAddress); + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof IPv4Endpoint)) { + return false; + } + + IPv4Endpoint other = (IPv4Endpoint) obj; + + // Check on layer + boolean localEquals = Arrays.equals(fIPAddress, other.fIPAddress); + if (!localEquals) { + return false; + } + + // Check above layers. + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint != null) { + return endpoint.equals(other.getParentEndpoint()); + } + return true; + } + + @Override + public String toString() { + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + return ConversionHelper.toIpAddress(fIPAddress); + } + return endpoint.toString() + '/' + ConversionHelper.toIpAddress(fIPAddress); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Packet.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Packet.java new file mode 100644 index 0000000000..a19209e2d1 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Packet.java @@ -0,0 +1,635 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.ipv4; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.tcp.TCPPacket; +import org.eclipse.linuxtools.pcap.core.protocol.udp.UDPPacket; +import org.eclipse.linuxtools.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.pcap.core.util.IPProtocolNumberHelper; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; + +/** + * Class that represents an Ethernet II packet. + * + * @author Vincent Perot + */ +public class IPv4Packet extends Packet { + + private final @Nullable Packet fChildPacket; + private final @Nullable ByteBuffer fPayload; + + private final int fVersion; + private final int fInternetHeaderLength; // in 4 bytes blocks + private final int fDSCP; + private final int fExplicitCongestionNotification; + private final int fTotalLength; // in bytes + private final int fIdentification; + private final boolean fReservedFlag; + private final boolean fDontFragmentFlag; + private final boolean fMoreFragmentFlag; + private final int fFragmentOffset; + private final int fTimeToLive; + private final int fIpDatagramProtocol; + private final int fHeaderChecksum; + private final byte[] fSourceIpAddress; + private final byte[] fDestinationIpAddress; + private final @Nullable byte[] fOptions; + + private @Nullable IPv4Endpoint fSourceEndpoint; + private @Nullable IPv4Endpoint fDestinationEndpoint; + + private @Nullable ImmutableMap fFields; + + // TODO Interpret options. See + // http://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml + + /** + * Constructor of the IPv4 Packet class. + * + * @param file + * The file that contains this packet. + * @param parent + * The parent packet of this packet (the encapsulating packet). + * @param packet + * The entire packet (header and payload). + * @throws BadPacketException + * Thrown when the packet is erroneous. + */ + public IPv4Packet(PcapFile file, @Nullable Packet parent, ByteBuffer packet) throws BadPacketException { + super(file, parent, Protocol.IPV4); + + // The endpoints are lazy loaded. They are defined in the get*Endpoint() + // methods. + fSourceEndpoint = null; + fDestinationEndpoint = null; + + fFields = null; + + packet.order(ByteOrder.BIG_ENDIAN); + packet.position(0); + + byte storage = packet.get(); + fVersion = ((storage & 0xF0) >> 4) & 0x000000FF; + fInternetHeaderLength = storage & 0x0F; + + storage = packet.get(); + fDSCP = ((storage & 0b11111100) >> 2) & 0x000000FF; + fExplicitCongestionNotification = storage & 0b00000011; + + fTotalLength = ConversionHelper.unsignedShortToInt(packet.getShort()); + fIdentification = ConversionHelper.unsignedShortToInt(packet.getShort()); + + storage = packet.get(); + fReservedFlag = isBitSet(storage, 7); + fDontFragmentFlag = isBitSet(storage, 6); + fMoreFragmentFlag = isBitSet(storage, 5); + fFragmentOffset = ((storage & 0b00011111) << 8) | packet.get(); + + fTimeToLive = ConversionHelper.unsignedByteToInt(packet.get()); + fIpDatagramProtocol = ConversionHelper.unsignedByteToInt(packet.get()); + fHeaderChecksum = ConversionHelper.unsignedShortToInt(packet.getShort()); + + fSourceIpAddress = new byte[IPv4Values.IP_ADDRESS_SIZE]; + fDestinationIpAddress = new byte[IPv4Values.IP_ADDRESS_SIZE]; + packet.get(fSourceIpAddress); + packet.get(fDestinationIpAddress); + + // Get options if there are any + if (fInternetHeaderLength > IPv4Values.DEFAULT_HEADER_LENGTH) { + fOptions = new byte[(fInternetHeaderLength - IPv4Values.DEFAULT_HEADER_LENGTH) * IPv4Values.BLOCK_SIZE]; + packet.get(fOptions); + } else { + fOptions = null; + } + + // Get payload if any. + if (packet.array().length - packet.position() > 0) { + byte[] array = new byte[packet.array().length - packet.position()]; + packet.get(array); + ByteBuffer payload = ByteBuffer.wrap(array); + payload.order(ByteOrder.BIG_ENDIAN); + payload.position(0); + fPayload = payload; + } else { + fPayload = null; + } + + // Find child + fChildPacket = findChildPacket(); + + } + + @Override + public @Nullable Packet getChildPacket() { + return fChildPacket; + } + + @Override + public @Nullable ByteBuffer getPayload() { + return fPayload; + } + + /** + * {@inheritDoc} + * + * See http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers + */ + @Override + protected @Nullable Packet findChildPacket() throws BadPacketException { + // TODO Implement more protocols + ByteBuffer payload = fPayload; + if (payload == null) { + return null; + } + + switch (fIpDatagramProtocol) { + case IPProtocolNumberHelper.PROTOCOL_NUMBER_TCP: + return new TCPPacket(getPcapFile(), this, payload); + case IPProtocolNumberHelper.PROTOCOL_NUMBER_UDP: + return new UDPPacket(getPcapFile(), this, payload); + default: + return new UnknownPacket(getPcapFile(), this, payload); + } + + } + + @Override + public String toString() { + // Generate flagString + // This is very ugly. + String flagString = null; + + if (fReservedFlag && fDontFragmentFlag && fMoreFragmentFlag) { // 111 + flagString = "Flags: 0x07 (Invalid)"; //$NON-NLS-1$ + } else if (fReservedFlag && fDontFragmentFlag && !fMoreFragmentFlag) { // 110 + flagString = "Flags: 0x06 (Invalid)"; //$NON-NLS-1$ + } else if (fReservedFlag && !fDontFragmentFlag && fMoreFragmentFlag) { // 101 + flagString = "Flags: 0x05 (Invalid)"; //$NON-NLS-1$ + } else if (fReservedFlag && !fDontFragmentFlag && !fMoreFragmentFlag) { // 100 + flagString = "Flags: 0x04 (Invalid)"; //$NON-NLS-1$ + } else if (!fReservedFlag && fDontFragmentFlag && fMoreFragmentFlag) { // 011 + flagString = "Flags: 0x03 (Invalid)"; //$NON-NLS-1$ + } else if (!fReservedFlag && fDontFragmentFlag && !fMoreFragmentFlag) { // 010 + flagString = "Flags: 0x02 (Don't fragment)"; //$NON-NLS-1$ + } else if (!fReservedFlag && !fDontFragmentFlag && fMoreFragmentFlag) { // 001 + flagString = "Flags: 0x01 (More fragments)"; //$NON-NLS-1$ + } else if (!fReservedFlag && !fDontFragmentFlag && !fMoreFragmentFlag) { // 000 + flagString = "Flags: 0x00 (Don't have more fragments)"; //$NON-NLS-1$ + } + + flagString += ", Fragment Offset: " + fFragmentOffset; //$NON-NLS-1$ + + // Generate checksum string + // TODO calculate the expected checksum from packet + String checksumString = "Header Checksum: " + String.format("%s%04x", "0x", fHeaderChecksum); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + String string = getProtocol().getName() + ", Source: " + ConversionHelper.toIpAddress(fSourceIpAddress) + ", Destination: " + ConversionHelper.toIpAddress(fDestinationIpAddress) + //$NON-NLS-1$ //$NON-NLS-2$ + "\nVersion: " + fVersion + ", Identification: " + String.format("%s%04x", "0x", fIdentification) + ", Header Length: " + getHeaderLength() + " bytes, Total Length: " + getTotalLength() + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + " bytes\nDifferentiated Services Code Point: " + String.format("%s%02x", "0x", fDSCP) + "; Explicit Congestion Notification: " + String.format("%s%02x", "0x", fExplicitCongestionNotification) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + + "\n" + flagString + "\nTime to live: " + fTimeToLive + //$NON-NLS-1$ //$NON-NLS-2$ + "\nProtocol: " + fIpDatagramProtocol + "\n" //$NON-NLS-1$ //$NON-NLS-2$ + + checksumString + "\n"; //$NON-NLS-1$ + final Packet child = fChildPacket; + if (child != null) { + return string + child.toString(); + } + return string; + } + + /** + * Getter method that returns the version of the IP protocol used. This + * should always be set to 4 as IPv6 has its own class. + * + * @return The version of the IP used. + */ + public int getVersion() { + return fVersion; + } + + /** + * Getter method that returns the header length in bytes. In the IPv4 + * packet, this is specified in 4-bytes data block. By default, this method + * returns 20 if there are no options present. Otherwise, it will return a + * higher number. + * + * @return The header length in bytes. + */ + public int getHeaderLength() { + return fInternetHeaderLength * IPv4Values.BLOCK_SIZE; + } + + /** + * Getter method that returns the Differentiated Services Code Point (a.k.a. + * the Type of Service). This is useful for some technologies that require + * real-time data exchange. + * + * @return The DSCP + */ + public int getDSCP() { + return fDSCP; + } + + /** + * Getter method that returns the Explicit Congestion Notification (ECN). + * This allows end-to-end communication without dropping packets. + * + * @return The ECN. + */ + public int getExplicitCongestionNotification() { + return fExplicitCongestionNotification; + } + + /** + * Getter method to retrieve the length of the entire packet, in bytes. This + * number is according to the packet, and might not be true if the packet is + * erroneous. + * + * @return The total length (packet and payload) in bytes. + */ + public int getTotalLength() { + return fTotalLength; + } + + /** + * Getter method to retrieve the Identification. This is a field that is + * used to uniquely identify the packets, thus allowing the reconstruction + * of fragmented IP packets. + * + * @return The packet identification. + */ + public int getIdentification() { + return fIdentification; + } + + /** + * Getter method that returns the state of the Reserved flag. This must + * always be zero. + * + * @return The state of the Reserved flag. + */ + public boolean getReservedFlag() { + return fReservedFlag; + } + + /** + * Getter method that indicates if the packet can be fragmented or not. + * + * @return Whether the packet can be fragmented or not. + */ + public boolean getDontFragmentFlag() { + return fDontFragmentFlag; + } + + /** + * Getter method that indicates if the packet has more fragments or not. + * + * @return Whether the packet has more fragments or not. + */ + public boolean getHasMoreFragment() { + return fMoreFragmentFlag; + } + + /** + * Getter method that specify the offset of a particular fragment relative + * to the original unfragmented packet, in 8-bytes blocks. * + * + * @return The fragment offset. + */ + public int getFragmentOffset() { + return fFragmentOffset; + } + + /** + * Getter method that returns the time to live in seconds. In practice, this + * is a hop count. This is used to prevent packets from persisting. + * + * @return The time left to live for the packet. + */ + public int getTimeToLive() { + return fTimeToLive; + } + + /** + * Getter method that returns the encapsulated protocol. + * + * See http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers + * + * @return The encapsulated protocol. + */ + public int getIpDatagramProtocol() { + return fIpDatagramProtocol; + } + + /** + * Getter method that returns the checksum, according to the packet. This + * checksum might be wrong if the packet is erroneous. + * + * @return The header checksum. + */ + public int getHeaderChecksum() { + return fHeaderChecksum; + } + + /** + * Getter method that returns the source IP address. + * + * @return The source IP address, as a byte array in big-endian. + */ + public byte[] getSourceIpAddress() { + return fSourceIpAddress; + } + + /** + * Getter method that returns the destination IP address. + * + * @return The destination IP address, as a byte array in big-endian. + */ + public byte[] getDestinationIpAddress() { + return fDestinationIpAddress; + } + + /** + * Getter method that returns the options. This method returns null if no + * options are present. + * + * @return The options of the packet. + */ + public @Nullable byte[] getOptions() { + final byte[] options = fOptions; + if (options == null) { + return null; + } + return Arrays.copyOf(options, options.length); + } + + @Override + public boolean validate() { + // Not yet implemented. ATM, we consider that all packets are valid. + // This is the case for all packets. + // TODO Implement it. + return true; + } + + @Override + public IPv4Endpoint getSourceEndpoint() { + @Nullable + IPv4Endpoint endpoint = fSourceEndpoint; + if (endpoint == null) { + endpoint = new IPv4Endpoint(this, true); + } + fSourceEndpoint = endpoint; + return fSourceEndpoint; + } + + @Override + public IPv4Endpoint getDestinationEndpoint() { + @Nullable + IPv4Endpoint endpoint = fDestinationEndpoint; + + if (endpoint == null) { + endpoint = new IPv4Endpoint(this, false); + } + fDestinationEndpoint = endpoint; + return fDestinationEndpoint; + } + + @Override + public Map getFields() { + ImmutableMap map = fFields; + if (map == null) { + Builder builder = ImmutableMap. builder() + .put("Version", String.valueOf(fVersion)) //$NON-NLS-1$ + .put("Header Length", String.valueOf(getHeaderLength()) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ + .put("Differentiated Services Field", String.format("%s%02x", "0x", fDSCP)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .put("Explicit Congestion Notification", String.format("%s%02x", "0x", fExplicitCongestionNotification)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .put("Total Length", String.valueOf(fTotalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ + .put("Identification", String.format("%s%04x", "0x", fIdentification)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .put("Don't Fragment Flag", String.valueOf(fDontFragmentFlag)) //$NON-NLS-1$ + .put("More Fragment Flag", String.valueOf(fMoreFragmentFlag)) //$NON-NLS-1$ + .put("Fragment Offset", String.valueOf(fFragmentOffset)) //$NON-NLS-1$ + .put("Time to live", String.valueOf(fTimeToLive)) //$NON-NLS-1$ + .put("Protocol", IPProtocolNumberHelper.toString(fIpDatagramProtocol) + " (" + String.valueOf(fIpDatagramProtocol) + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .put("Checksum", String.format("%s%04x", "0x", fHeaderChecksum)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .put("Source IP Address", ConversionHelper.toIpAddress(fSourceIpAddress)) //$NON-NLS-1$ + .put("Destination IP Address", ConversionHelper.toIpAddress(fDestinationIpAddress)); //$NON-NLS-1$ + byte[] options = fOptions; + if (options == null) { + builder.put("Options", EMPTY_STRING); //$NON-NLS-1$ + } else { + builder.put("Options", ConversionHelper.bytesToHex(options, true)); //$NON-NLS-1$ + + } + @SuppressWarnings("null") + @NonNull + ImmutableMap newMap = builder.build(); + fFields = newMap; + return newMap; + } + return map; + } + + @Override + public String getLocalSummaryString() { + return "Src: " + ConversionHelper.toIpAddress(fSourceIpAddress) + " , Dst: " + ConversionHelper.toIpAddress(fDestinationIpAddress); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected String getSignificationString() { + StringBuilder sb = new StringBuilder(); + sb.append(ConversionHelper.toIpAddress(fSourceIpAddress)) + .append(" > ") //$NON-NLS-1$ + .append(ConversionHelper.toIpAddress(fDestinationIpAddress)); + + String flags = generateFlagString(); + if (!(flags.equals(""))) { //$NON-NLS-1$ + sb.append(' ') + .append('[') + .append(flags) + .append(']'); + } + sb.append(" Id=") //$NON-NLS-1$ + .append(fIdentification); + + final ByteBuffer payload = fPayload; + if (payload != null) { + sb.append(" Len=") //$NON-NLS-1$ + .append(payload.array().length); + } else { + sb.append(" Len=0"); //$NON-NLS-1$ + } + String string = sb.toString(); + if (string == null) { + return EMPTY_STRING; + } + return string; + } + + private String generateFlagString() { + StringBuilder sb = new StringBuilder(); + boolean start = true; + + if (fDontFragmentFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("DF"); //$NON-NLS-1$ + start = false; + } + if (fMoreFragmentFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("MF"); //$NON-NLS-1$ + start = false; + } + String string = sb.toString(); + if (string == null) { + return EMPTY_STRING; + } + return string; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + final Packet child = fChildPacket; + if (child != null) { + result = prime * result + child.hashCode(); + } else { + result = prime * result; + } + result = prime * result + fDSCP; + result = prime * result + Arrays.hashCode(fDestinationIpAddress); + result = prime * result + (fDontFragmentFlag ? 1231 : 1237); + result = prime * result + fExplicitCongestionNotification; + result = prime * result + fFragmentOffset; + result = prime * result + fHeaderChecksum; + result = prime * result + fIdentification; + result = prime * result + fInternetHeaderLength; + result = prime * result + fIpDatagramProtocol; + result = prime * result + (fMoreFragmentFlag ? 1231 : 1237); + result = prime * result + Arrays.hashCode(fOptions); + final ByteBuffer payload = fPayload; + if (payload != null) { + result = prime * result + payload.hashCode(); + } else { + result = prime * result; + } + result = prime * result + (fReservedFlag ? 1231 : 1237); + result = prime * result + Arrays.hashCode(fSourceIpAddress); + result = prime * result + fTimeToLive; + result = prime * result + fTotalLength; + result = prime * result + fVersion; + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + IPv4Packet other = (IPv4Packet) obj; + final Packet child = fChildPacket; + if (child != null) { + if (!child.equals(other.fChildPacket)) { + return false; + } + } else { + if (other.fChildPacket != null) { + return false; + } + } + + if (fDSCP != other.fDSCP) { + return false; + } + if (!Arrays.equals(fDestinationIpAddress, other.fDestinationIpAddress)) { + return false; + } + if (fDontFragmentFlag != other.fDontFragmentFlag) { + return false; + } + if (fExplicitCongestionNotification != other.fExplicitCongestionNotification) { + return false; + } + if (fFragmentOffset != other.fFragmentOffset) { + return false; + } + if (fHeaderChecksum != other.fHeaderChecksum) { + return false; + } + if (fIdentification != other.fIdentification) { + return false; + } + if (fInternetHeaderLength != other.fInternetHeaderLength) { + return false; + } + if (fIpDatagramProtocol != other.fIpDatagramProtocol) { + return false; + } + if (fMoreFragmentFlag != other.fMoreFragmentFlag) { + return false; + } + if (!Arrays.equals(fOptions, other.fOptions)) { + return false; + } + final ByteBuffer payload = fPayload; + if (payload != null) { + if (!payload.equals(other.fPayload)) { + return false; + } + } else { + if (other.fPayload != null) { + return false; + } + } + if (fReservedFlag != other.fReservedFlag) { + return false; + } + if (!Arrays.equals(fSourceIpAddress, other.fSourceIpAddress)) { + return false; + } + if (fTimeToLive != other.fTimeToLive) { + return false; + } + if (fTotalLength != other.fTotalLength) { + return false; + } + if (fVersion != other.fVersion) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Values.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Values.java new file mode 100644 index 0000000000..e6a34aa278 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/IPv4Values.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.ipv4; + +/** + * Interface that lists constants related to Internet Protocol v4. + * + * See http://en.wikipedia.org/wiki/IPv4#Packet_structure. + * + * @author Vincent Perot + */ +public interface IPv4Values { + + /** Size in bytes of an IP address */ + int IP_ADDRESS_SIZE = 4; + + /** Size in bytes of a default IPv4 packet header */ + int DEFAULT_HEADER_LENGTH = 5; + + /** Size in bytes of a block of data. Used to convert data block to bytes */ + int BLOCK_SIZE = 4; + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/package-info.java new file mode 100644 index 0000000000..554b3312ac --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/ipv4/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol.ipv4; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/package-info.java new file mode 100644 index 0000000000..65e3e7a387 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapEndpoint.java new file mode 100644 index 0000000000..ac906686a5 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapEndpoint.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.pcap; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; + +/** + * Class that extends the {@link ProtocolEndpoint} class. It represents the endpoint at + * a Pcap level. + * + * @author Vincent Perot + */ +public class PcapEndpoint extends ProtocolEndpoint { + + /** + * Constructor of the {@link PcapEndpoint} class. It takes a packet to get + * its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public PcapEndpoint(PcapPacket packet, boolean isSourceEndpoint) { + super(packet, isSourceEndpoint); + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public String toString() { + return EMPTY_STRING; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof PcapEndpoint)) { + return false; + } + + PcapEndpoint other = (PcapEndpoint) obj; + + // Check above layers. + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint != null) { + return endpoint.equals(other.getParentEndpoint()); + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapPacket.java new file mode 100644 index 0000000000..6be21cdc93 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/PcapPacket.java @@ -0,0 +1,372 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.pcap; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.ethernet2.EthernetIIPacket; +import org.eclipse.linuxtools.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.trace.PcapFileValues; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.pcap.core.util.LinkTypeHelper; +import org.eclipse.linuxtools.pcap.core.util.PcapTimestampScale; + +import com.google.common.collect.ImmutableMap; + +/** + * Class that represents a Pcap packet. This is the highest level of + * encapsulation. + * + * @author Vincent Perot + */ +public class PcapPacket extends Packet { + + private static final int TIMESTAMP_MICROSECOND_MAX = 1000000; + private static final int TIMESTAMP_NANOSECOND_MAX = 1000000000; + + private final @Nullable Packet fChildPacket; + private final @Nullable ByteBuffer fPayload; + + private final long fTimestamp; // In microseconds + private final long fIncludedLength; + private final long fOriginalLength; + private final long fPacketIndex; + + private @Nullable PcapEndpoint fSourceEndpoint; + private @Nullable PcapEndpoint fDestinationEndpoint; + + private @Nullable ImmutableMap fFields; + + /** + * Constructor of the Pcap Packet class. + * + * @param file + * The file that contains this packet. + * @param parent + * The parent packet of this packet (the encapsulating packet). + * @param header + * The header of the packet. + * @param payload + * The payload of this packet. + * @param index + * The index of the packet in the file. + * @throws BadPacketException + * Thrown when the Packet is erroneous. + */ + public PcapPacket(PcapFile file, @Nullable Packet parent, ByteBuffer header, @Nullable ByteBuffer payload, long index) throws BadPacketException { + super(file, parent, Protocol.PCAP); + + if (header.array().length < PcapFileValues.PACKET_HEADER_SIZE) { + fChildPacket = null; + throw new BadPacketException("The Pcap packet header is too small."); //$NON-NLS-1$ + } + + // The endpoints are lazy loaded. They are defined in the get*Endpoint() + // methods. + fSourceEndpoint = null; + fDestinationEndpoint = null; + + fFields = null; + + fPacketIndex = index; + + // PcapPacket header in File endian + header.order(getPcapFile().getByteOrder()); + header.position(0); + long timestampMostSignificant = ConversionHelper.unsignedIntToLong(header.getInt()); + long timestampLeastSignificant = ConversionHelper.unsignedIntToLong(header.getInt()); + + switch (getTimestampScale()) { + case MICROSECOND: + if (timestampLeastSignificant > TIMESTAMP_MICROSECOND_MAX) { + fChildPacket = null; + throw new BadPacketException("The timestamp is erroneous."); //$NON-NLS-1$ + } + fTimestamp = TIMESTAMP_MICROSECOND_MAX * timestampMostSignificant + timestampLeastSignificant; + break; + case NANOSECOND: + if (timestampLeastSignificant > TIMESTAMP_NANOSECOND_MAX) { + fChildPacket = null; + throw new BadPacketException("The timestamp is erroneous."); //$NON-NLS-1$ + } + fTimestamp = TIMESTAMP_NANOSECOND_MAX * timestampMostSignificant + timestampLeastSignificant; + break; + default: + throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$ + } + + fIncludedLength = ConversionHelper.unsignedIntToLong(header.getInt()); + fOriginalLength = ConversionHelper.unsignedIntToLong(header.getInt()); + + // Set up payload + final ByteBuffer pcapPacket = payload; + if (pcapPacket == null) { + fChildPacket = null; + fPayload = null; + return; + } + + pcapPacket.order(ByteOrder.BIG_ENDIAN); + pcapPacket.position(0); + fPayload = pcapPacket; + + // Find Child Packet + fChildPacket = findChildPacket(); + + } + + @Override + public @Nullable Packet getChildPacket() { + return fChildPacket; + } + + @Override + public @Nullable ByteBuffer getPayload() { + return fPayload; + } + + /** + * Getter method that returns the timestamp of this packet, in microseconds/nanoseconds + * relative to epoch. + * + * @return The timestamp of the packet. + */ + public long getTimestamp() { + return fTimestamp; + } + + /** + * Getter method that returns the length in bytes of the packet that was + * included in the {@link PcapFile}. + * + * @return The included length of the packet. + */ + public long getIncludedLength() { + return fIncludedLength; + } + + /** + * Getter method that returns the original length in bytes of the packet. + * + * @return The included length of the packet. + */ + public long getOriginalLength() { + return fOriginalLength; + } + + /** + * Method that indicates if this packet was truncated at capture time. + * + * @return Whether the packet is truncated or not. + */ + public boolean isTruncated() { + return fIncludedLength != fOriginalLength; + } + + /** + * Getter method that returns the index of the packet. + * + * @return The index of the packet. + */ + public long getIndex() { + return fPacketIndex; + } + + @Override + public String toString() { + // TODO Decide if first capture is 0 or 1. Right now, it is 0. + String string = getProtocol().getName() + " " + fPacketIndex + //$NON-NLS-1$ + ": " + fOriginalLength + " bytes on wire, " + //$NON-NLS-1$ //$NON-NLS-2$ + fIncludedLength + " bytes captured.\nArrival time: " + //$NON-NLS-1$ + ConversionHelper.toGMTTime(fTimestamp, getTimestampScale()) + "\n"; //$NON-NLS-1$ + + final Packet child = fChildPacket; + if (child != null) { + return string + child.toString(); + } + return string; + } + + /** + * {@inheritDoc} + * + * See http://www.tcpdump.org/linktypes.html + */ + @Override + protected @Nullable Packet findChildPacket() throws BadPacketException { + @Nullable + ByteBuffer payload = fPayload; + if (payload == null) { + return null; + } + + switch ((int) getPcapFile().getDataLinkType()) { + case LinkTypeHelper.LINKTYPE_ETHERNET: + return new EthernetIIPacket(getPcapFile(), this, payload); + default: // TODO add more protocols + return new UnknownPacket(getPcapFile(), this, payload); + } + } + + @Override + public boolean validate() { + // Not yet implemented. ATM, we consider that all packets are valid. + // This is the case for all packets. + // TODO Implement it. + return true; + } + + @Override + public PcapEndpoint getSourceEndpoint() { + @Nullable PcapEndpoint endpoint = fSourceEndpoint; + if (endpoint == null) { + endpoint = new PcapEndpoint(this, true); + } + fSourceEndpoint = endpoint; + return fSourceEndpoint; + } + + @Override + public PcapEndpoint getDestinationEndpoint() { + @Nullable + PcapEndpoint endpoint = fDestinationEndpoint; + + if (endpoint == null) { + endpoint = new PcapEndpoint(this, false); + } + fDestinationEndpoint = endpoint; + return fDestinationEndpoint; + } + + // TODO handle plural form correctly + // TODO microsec + @Override + public Map getFields() { + ImmutableMap map = fFields; + if (map == null) { + @SuppressWarnings("null") + @NonNull ImmutableMap newMap = ImmutableMap. builder() + .put("Frame", String.valueOf(fPacketIndex)) //$NON-NLS-1$ + .put("Frame Length", String.valueOf(fOriginalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ + .put("Capture Length", String.valueOf(fIncludedLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ + .put("Capture Time", ConversionHelper.toGMTTime(fTimestamp, getTimestampScale())) //$NON-NLS-1$ + .build(); + fFields = newMap; + return newMap; + } + return map; + } + + @Override + public String getLocalSummaryString() { + return "Frame " + fPacketIndex + ": " + fOriginalLength + " bytes on wire, " + fIncludedLength + " bytes captured"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + } + + @Override + protected String getSignificationString() { + return "New Frame: " + fOriginalLength + " bytes on wire"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + Packet child = fChildPacket; + if (child == null) { + result = prime * result; + } else { + result = prime * result + child.hashCode(); + } + + result = prime * result + (int) (fIncludedLength ^ (fIncludedLength >>> 32)); + result = prime * result + (int) (fOriginalLength ^ (fOriginalLength >>> 32)); + result = prime * result + (int) (fPacketIndex ^ (fPacketIndex >>> 32)); + + ByteBuffer payload = fPayload; + if (payload == null) { + result = prime * result; + } else { + result = prime * result + payload.hashCode(); + } + + result = prime * result + (int) (fTimestamp ^ (fTimestamp >>> 32)); + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + PcapPacket other = (PcapPacket) obj; + final Packet child = fChildPacket; + if (child != null) { + if (!child.equals(other.fChildPacket)) { + return false; + } + } else { + if (other.fChildPacket != null) { + return false; + } + } + + if (fIncludedLength != other.fIncludedLength) { + return false; + } + if (fOriginalLength != other.fOriginalLength) { + return false; + } + if (fPacketIndex != other.fPacketIndex) { + return false; + } + final ByteBuffer payload = fPayload; + if (payload != null) { + if (!payload.equals(other.fPayload)) { + return false; + } + } else { + if (other.fPayload != null) { + return false; + } + } + + if (fTimestamp != other.fTimestamp) { + return false; + } + return true; + } + + /** + * Getter method that returns the Timestamp precision of the packet. + * + * @return the Timestamp precision. + */ + public PcapTimestampScale getTimestampScale() { + return getPcapFile().getTimestampPrecision(); + } +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/package-info.java new file mode 100644 index 0000000000..6a7e0bd39e --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/pcap/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol.pcap; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPEndpoint.java new file mode 100644 index 0000000000..d9ab72e3a8 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPEndpoint.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.tcp; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; + +/** + * Class that extends the {@link ProtocolEndpoint} class. It represents the + * endpoint at a TCP level. + * + * @author Vincent Perot + */ +public class TCPEndpoint extends ProtocolEndpoint { + + private final int fPort; + + /** + * Constructor of the {@link TCPEndpoint} class. It takes a packet to get + * its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public TCPEndpoint(TCPPacket packet, boolean isSourceEndpoint) { + super(packet, isSourceEndpoint); + fPort = isSourceEndpoint ? packet.getSourcePort() : packet.getDestinationPort(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + result = 0; + } else { + result = endpoint.hashCode(); + } + result = prime * result + fPort; + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof TCPEndpoint)) { + return false; + } + + TCPEndpoint other = (TCPEndpoint) obj; + + // Check on layer + boolean localEquals = (fPort == other.fPort); + if (!localEquals) { + return false; + } + + // Check above layers. + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint != null) { + return endpoint.equals(other.getParentEndpoint()); + } + return true; + } + + @Override + public String toString() { + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + @SuppressWarnings("null") + @NonNull + String ret = String.valueOf(fPort); + return ret; + } + return endpoint.toString() + '/' + fPort; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPPacket.java new file mode 100644 index 0000000000..c57baf9fe9 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPPacket.java @@ -0,0 +1,707 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.tcp; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; + +/** + * Class that represents a TCP packet. + * + * @author Vincent Perot + */ +public class TCPPacket extends Packet { + + private final @Nullable Packet fChildPacket; + private final @Nullable ByteBuffer fPayload; + + private final int fSourcePort; + private final int fDestinationPort; + private final long fSequenceNumber; + private final long fAcknowledgmentNumber; + private final int fDataOffset; // in 4 bytes block + private final byte fReservedField; + private final boolean fNSFlag; + private final boolean fCWRFlag; + private final boolean fECEFlag; + private final boolean fURGFlag; + private final boolean fACKFlag; + private final boolean fPSHFlag; + private final boolean fRSTFlag; + private final boolean fSYNFlag; + private final boolean fFINFlag; + private final int fWindowSize; + private final int fChecksum; + private final int fUrgentPointer; + private final @Nullable byte[] fOptions; // TODO Interpret options. + + private @Nullable TCPEndpoint fSourceEndpoint; + private @Nullable TCPEndpoint fDestinationEndpoint; + + private @Nullable ImmutableMap fFields; + + /** + * Constructor of the TCP Packet class. + * + * @param file + * The file that contains this packet. + * @param parent + * The parent packet of this packet (the encapsulating packet). + * @param packet + * The entire packet (header and payload). + * @throws BadPacketException + * Thrown when the packet is erroneous. + */ + public TCPPacket(PcapFile file, @Nullable Packet parent, ByteBuffer packet) throws BadPacketException { + super(file, parent, Protocol.TCP); + + // The endpoints are lazy loaded. They are defined in the get*Endpoint() + // methods. + fSourceEndpoint = null; + fDestinationEndpoint = null; + + fFields = null; + + packet.order(ByteOrder.BIG_ENDIAN); + packet.position(0); + + fSourcePort = ConversionHelper.unsignedShortToInt(packet.getShort()); + fDestinationPort = ConversionHelper.unsignedShortToInt(packet.getShort()); + fSequenceNumber = ConversionHelper.unsignedIntToLong(packet.getInt()); + fAcknowledgmentNumber = ConversionHelper.unsignedIntToLong(packet.getInt()); + + byte storage = packet.get(); + fDataOffset = ((storage & 0b11110000) >>> 4) & 0x000000FF; + fReservedField = (byte) ((storage & 0b00001110) >>> 1); + fNSFlag = isBitSet(storage, 0); + + storage = packet.get(); + fCWRFlag = isBitSet(storage, 7); + fECEFlag = isBitSet(storage, 6); + fURGFlag = isBitSet(storage, 5); + fACKFlag = isBitSet(storage, 4); + fPSHFlag = isBitSet(storage, 3); + fRSTFlag = isBitSet(storage, 2); + fSYNFlag = isBitSet(storage, 1); + fFINFlag = isBitSet(storage, 0); + + fWindowSize = ConversionHelper.unsignedShortToInt(packet.getShort()); + fChecksum = ConversionHelper.unsignedShortToInt(packet.getShort()); + fUrgentPointer = ConversionHelper.unsignedShortToInt(packet.getShort()); + + // Get options if any + if (fDataOffset > TCPValues.DEFAULT_HEADER_LENGTH) { + fOptions = new byte[(fDataOffset - TCPValues.DEFAULT_HEADER_LENGTH) * TCPValues.BLOCK_SIZE]; + packet.get(fOptions); + } else { + fOptions = null; + } + + // Get payload if any. + if (packet.array().length - packet.position() > 0) { + byte[] array = new byte[packet.array().length - packet.position()]; + packet.get(array); + ByteBuffer payload = ByteBuffer.wrap(array); + payload.order(ByteOrder.BIG_ENDIAN); + payload.position(0); + fPayload = payload; + } else { + fPayload = null; + } + + // find child packet + fChildPacket = findChildPacket(); + + } + + @Override + public @Nullable Packet getChildPacket() { + return fChildPacket; + } + + @Override + public @Nullable ByteBuffer getPayload() { + return fPayload; + } + + /** + * {@inheritDoc} + * + * See http://www.iana.org/assignments/service-names-port-numbers/service- + * names-port-numbers.xhtml or + * http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers + */ + @Override + protected @Nullable Packet findChildPacket() throws BadPacketException { + // TODO implement further protocols and update this + ByteBuffer payload = fPayload; + if (payload == null) { + return null; + } + + return new UnknownPacket(getPcapFile(), this, payload); + } + + @Override + public String toString() { + final ByteBuffer payload = fPayload; + int length = 0; + if (payload != null) { + length = payload.array().length; + } + + String flagString = ""; // TODO Finish it. Im just too lazy. //$NON-NLS-1$ + String string = getProtocol().getName() + ", Source Port: " + fSourcePort + ", Destination Port: " + fDestinationPort + //$NON-NLS-1$ //$NON-NLS-2$ + "\nSequence Number: " + fSequenceNumber + ", Acknowledgment Number: " + fAcknowledgmentNumber + //$NON-NLS-1$ //$NON-NLS-2$ + "\nHeader length: " + fDataOffset * TCPValues.BLOCK_SIZE + " bytes, Data length: " + length + //$NON-NLS-1$ //$NON-NLS-2$ + "\n" + flagString + "Window size value: " + fWindowSize + ", Urgent Pointer: " + String.format("%s%04x", "0x", fUrgentPointer) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "\nChecksum: " + String.format("%s%04x", "0x", fChecksum) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + final Packet child = fChildPacket; + if (child != null) { + return string + child.toString(); + } + return string; + } + + /** + * Getter method that returns the TCP Source Port. + * + * @return The source Port. + */ + public int getSourcePort() { + return fSourcePort; + } + + /** + * Getter method that returns the TCP Destination Port. + * + * @return The destination Port. + */ + public int getDestinationPort() { + return fDestinationPort; + } + + /** + * Getter method that returns the Sequence Number. The sequence number has a + * dual role: + *

    + *
  • If the SYN flag is set (1), then this is the initial sequence number. + * The sequence number of the actual first data byte and the acknowledged + * number in the corresponding ACK are then this sequence number plus 1.
  • + *
  • If the SYN flag is clear (0), then this is the accumulated sequence + * number of the first data byte of this segment for the current session.
  • + *
+ * + * Source: http://en.wikipedia.org/wiki/Transmission_Control_Protocol + * + * @return The Sequence Number. + */ + public long getSequenceNumber() { + return fSequenceNumber; + } + + /** + * Getter method that returns the Acknowledgment Number. + * + * If the ACK flag is set then the value of this field is the next sequence + * number that the receiver is expecting. This acknowledges receipt of all + * prior bytes (if any). The first ACK sent by each end acknowledges the + * other end's initial sequence number itself, but no data. + * + * Source: http://en.wikipedia.org/wiki/Transmission_Control_Protocol + * + * @return The Acknowledgment Number. + */ + public long getAcknowledgmentNumber() { + return fAcknowledgmentNumber; + } + + /** + * Getter method that returns the size of the TCP header in 4 bytes data + * block. The minimum size is 5 words and the maximum is 15 words. + * + * @return The Data Offset. + */ + public int getDataOffset() { + return fDataOffset; + } + + /** + * Getter method that returns the Reserved field. This field is for future + * use and should always be zero. In this library, it is used as a mean to + * verify the validity of a TCP packet. + * + * @return The Reserved Field. + */ + public byte getReservedField() { + return fReservedField; + } + + /** + * Getter method that returns the state of the NS flag. + * + * @return The state of the NS flag. + */ + public boolean isNSFlagSet() { + return fNSFlag; + } + + /** + * Getter method that returns the state of the CWR flag. + * + * @return The state of the CWR flag. + */ + public boolean isCongestionWindowReducedFlagSet() { + return fCWRFlag; + } + + /** + * Getter method that returns the state of the ECE flag. + * + * @return The state of the ECE flag. + */ + public boolean isECNEchoFlagSet() { + return fECEFlag; + } + + /** + * Getter method that returns the state of the URG flag. + * + * @return The state of the URG flag. + */ + public boolean isUrgentFlagSet() { + return fURGFlag; + } + + /** + * Getter method that returns the state of the ACK flag. + * + * @return The state of the ACK flag. + */ + public boolean isAcknowledgeFlagSet() { + return fACKFlag; + } + + /** + * Getter method that returns the state of the PSH flag. + * + * @return The state of the PSH flag. + */ + public boolean isPushFlagSet() { + return fPSHFlag; + } + + /** + * Getter method that returns the state of the RST flag. + * + * @return The state of the RST flag. + */ + public boolean isResetFlagSet() { + return fRSTFlag; + } + + /** + * Getter method that returns the state of the SYN flag. + * + * @return The state of the SYN flag. + */ + public boolean isSynchronizationFlagSet() { + return fSYNFlag; + } + + /** + * Getter method that returns the state of the FIN flag. + * + * @return The state of the FIN flag. + */ + public boolean isFinalFlagSet() { + return fFINFlag; + } + + /** + * Getter method that returns the size of the windows, in windows size unit + * (by default, bytes), that the sender of this packet is willing to + * receive. + * + * @return The Window Size. + */ + public int getWindowSize() { + return fWindowSize; + } + + /** + * Getter method that returns the checksum of this packet. This checksum may + * be wrong if the packet is erroneous. + * + * @return The data and header checksum. + */ + public int getChecksum() { + return fChecksum; + } + + /** + * Getter method that returns the Urgent Pointer. If the URG flag is set, + * this field is an offset from the sequence number indicating the last + * urgent data byte. + * + * @return The Urgent Pointer. + */ + public int getUrgentPointer() { + return fUrgentPointer; + } + + /** + * Getter method that returns the options. This method returns null if no + * options are present. + * + * @return The options of the packet. + */ + public @Nullable byte[] getOptions() { + byte[] options = fOptions; + if (options == null) { + return null; + } + return Arrays.copyOf(options, options.length); + } + + @Override + public boolean validate() { + // Not yet implemented. ATM, we consider that all packets are valid. + // This is the case for all packets. + // TODO Implement it. + return true; + } + + @Override + public TCPEndpoint getSourceEndpoint() { + @Nullable + TCPEndpoint endpoint = fSourceEndpoint; + if (endpoint == null) { + endpoint = new TCPEndpoint(this, true); + } + fSourceEndpoint = endpoint; + return fSourceEndpoint; + } + + @Override + public TCPEndpoint getDestinationEndpoint() { + @Nullable + TCPEndpoint endpoint = fDestinationEndpoint; + + if (endpoint == null) { + endpoint = new TCPEndpoint(this, false); + } + fDestinationEndpoint = endpoint; + return fDestinationEndpoint; + } + + @Override + public Map getFields() { + ImmutableMap map = fFields; + if (map == null) { + Builder builder = ImmutableMap. builder() + .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$ + .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$ + .put("Sequence Number", String.valueOf(fSequenceNumber)) //$NON-NLS-1$ + .put("Acknowledgement Number", String.valueOf(fAcknowledgmentNumber)) //$NON-NLS-1$ + .put("Length", String.valueOf(fDataOffset * TCPValues.BLOCK_SIZE) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ + .put("ECN-Nonce Flag", String.valueOf(fNSFlag)) //$NON-NLS-1$ + .put("Congestion Window Reduced Flag", String.valueOf(fCWRFlag)) //$NON-NLS-1$ + .put("ECN-Echo Flag", String.valueOf(fECEFlag)) //$NON-NLS-1$ + .put("Urgent Flag", String.valueOf(fURGFlag)) //$NON-NLS-1$ + .put("ACK Flag", String.valueOf(fACKFlag)) //$NON-NLS-1$ + .put("PSH Flag", String.valueOf(fPSHFlag)) //$NON-NLS-1$ + .put("RST Flag", String.valueOf(fRSTFlag)) //$NON-NLS-1$ + .put("SYN Flag", String.valueOf(fSYNFlag)) //$NON-NLS-1$ + .put("FIN Flag", String.valueOf(fFINFlag)) //$NON-NLS-1$ + .put("Window Size Value", String.valueOf(fWindowSize)) //$NON-NLS-1$ + .put("Checksum", String.format("%s%04x", "0x", fChecksum)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .put("Urgent Pointer", String.format("%s%04x", "0x", fUrgentPointer)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + byte[] options = fOptions; + if (options == null) { + builder.put("Options", EMPTY_STRING); //$NON-NLS-1$ + } else { + builder.put("Options", ConversionHelper.bytesToHex(options, true)); //$NON-NLS-1$ + + } + @SuppressWarnings("null") + @NonNull ImmutableMap newMap = builder.build(); + fFields = newMap; + return newMap; + } + return map; + } + + @Override + public String getLocalSummaryString() { + return "Src Port: " + fSourcePort + ", Dst Port: " + fDestinationPort + //$NON-NLS-1$ //$NON-NLS-2$ + ", Seq: " + fSequenceNumber + ", Ack: " + fAcknowledgmentNumber + //$NON-NLS-1$ //$NON-NLS-2$ + ", Len: " + (fDataOffset * TCPValues.BLOCK_SIZE); //$NON-NLS-1$ } + } + + @Override + protected String getSignificationString() { + StringBuilder sb = new StringBuilder(); + sb.append(fSourcePort) + .append(" > ") //$NON-NLS-1$ + .append(fDestinationPort); + + if (!(generateFlagString().equals(EMPTY_STRING))) { + sb.append(' ') + .append('[') + .append(generateFlagString()) + .append(']'); + } + sb.append(" Seq=") //$NON-NLS-1$ + .append(fSequenceNumber); + + if (fACKFlag) { + sb.append(" Ack=") //$NON-NLS-1$ + .append(fAcknowledgmentNumber); + } + + final ByteBuffer payload = fPayload; + if (payload != null) { + sb.append(" Len=") //$NON-NLS-1$ + .append(payload.array().length); + } else { + sb.append(" Len=0"); //$NON-NLS-1$ + } + + String string = sb.toString(); + if (string == null) { + return EMPTY_STRING; + } + return string; + } + + private String generateFlagString() { + StringBuilder sb = new StringBuilder(); + boolean start = true; + + if (fSYNFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("SYN"); //$NON-NLS-1$ + start = false; + } + if (fACKFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("ACK"); //$NON-NLS-1$ + start = false; + } + if (fFINFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("FIN"); //$NON-NLS-1$ + start = false; + } + if (fRSTFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("RST"); //$NON-NLS-1$ + start = false; + } + if (fPSHFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("PSH"); //$NON-NLS-1$ + start = false; + } + if (fURGFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("URG"); //$NON-NLS-1$ + start = false; + } + if (fNSFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("NS"); //$NON-NLS-1$ + start = false; + } + if (fCWRFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("CWR"); //$NON-NLS-1$ + start = false; + } + if (fECEFlag) { + if (!start) { + sb.append(", "); //$NON-NLS-1$ + } + sb.append("ECE"); //$NON-NLS-1$ + start = false; + } + String string = sb.toString(); + if (string == null) { + return EMPTY_STRING; + } + return string; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (fACKFlag ? 1231 : 1237); + result = prime * result + (int) (fAcknowledgmentNumber ^ (fAcknowledgmentNumber >>> 32)); + result = prime * result + (fCWRFlag ? 1231 : 1237); + result = prime * result + fChecksum; + final Packet child = fChildPacket; + if (child != null) { + result = prime * result + child.hashCode(); + } else { + result = prime * result; + } + result = prime * result + fDataOffset; + result = prime * result + fDestinationPort; + result = prime * result + (fECEFlag ? 1231 : 1237); + result = prime * result + (fFINFlag ? 1231 : 1237); + result = prime * result + (fNSFlag ? 1231 : 1237); + result = prime * result + Arrays.hashCode(fOptions); + result = prime * result + (fPSHFlag ? 1231 : 1237); + final ByteBuffer payload = fPayload; + if (payload != null) { + result = prime * result + payload.hashCode(); + } else { + result = prime * result; + } + result = prime * result + (fRSTFlag ? 1231 : 1237); + result = prime * result + fReservedField; + result = prime * result + (fSYNFlag ? 1231 : 1237); + result = prime * result + (int) (fSequenceNumber ^ (fSequenceNumber >>> 32)); + result = prime * result + fSourcePort; + result = prime * result + (fURGFlag ? 1231 : 1237); + result = prime * result + fUrgentPointer; + result = prime * result + fWindowSize; + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TCPPacket other = (TCPPacket) obj; + if (fACKFlag != other.fACKFlag) { + return false; + } + if (fAcknowledgmentNumber != other.fAcknowledgmentNumber) { + return false; + } + if (fCWRFlag != other.fCWRFlag) { + return false; + } + if (fChecksum != other.fChecksum) { + return false; + } + final Packet child = fChildPacket; + if (child != null) { + if (!child.equals(other.fChildPacket)) { + return false; + } + } else { + if (other.fChildPacket != null) { + return false; + } + } + + if (fDataOffset != other.fDataOffset) { + return false; + } + if (fDestinationPort != other.fDestinationPort) { + return false; + } + if (fECEFlag != other.fECEFlag) { + return false; + } + if (fFINFlag != other.fFINFlag) { + return false; + } + if (fNSFlag != other.fNSFlag) { + return false; + } + if (!Arrays.equals(fOptions, other.fOptions)) { + return false; + } + if (fPSHFlag != other.fPSHFlag) { + return false; + } + final ByteBuffer fPayload2 = fPayload; + if (fPayload2 != null) { + if (!fPayload2.equals(other.fPayload)) { + return false; + } + } else { + if (other.fPayload != null) { + return false; + } + } + if (fRSTFlag != other.fRSTFlag) { + return false; + } + if (fReservedField != other.fReservedField) { + return false; + } + if (fSYNFlag != other.fSYNFlag) { + return false; + } + if (fSequenceNumber != other.fSequenceNumber) { + return false; + } + if (fSourcePort != other.fSourcePort) { + return false; + } + if (fURGFlag != other.fURGFlag) { + return false; + } + if (fUrgentPointer != other.fUrgentPointer) { + return false; + } + if (fWindowSize != other.fWindowSize) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPValues.java new file mode 100644 index 0000000000..b00db9a6e1 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/TCPValues.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.tcp; + +/** + * Interface that lists constants related to TCP. + * + * See http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure. + * + * @author Vincent Perot + */ +public interface TCPValues { + + /** Size in bytes of a default TCP packet header */ + int DEFAULT_HEADER_LENGTH = 5; + + /** Size in bytes of a block of data. Used to convert data block to bytes. */ + int BLOCK_SIZE = 4; + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/package-info.java new file mode 100644 index 0000000000..3ebf52510b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/tcp/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol.tcp; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPEndpoint.java new file mode 100644 index 0000000000..a7f7fae66b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPEndpoint.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.udp; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; + +/** + * Class that extends the ProtocolEndpoint class. It represents the endpoint at + * an UDP level. + * + * @author Vincent Perot + */ +public class UDPEndpoint extends ProtocolEndpoint { + + private final int fPort; + + /** + * Constructor of the {@link UDPEndpoint} class. It takes a packet to get + * its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public UDPEndpoint(UDPPacket packet, boolean isSourceEndpoint) { + super(packet, isSourceEndpoint); + fPort = isSourceEndpoint ? packet.getSourcePort() : packet.getDestinationPort(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + result = 0; + } else { + result = endpoint.hashCode(); + } + result = prime * result + fPort; + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof UDPEndpoint)) { + return false; + } + + UDPEndpoint other = (UDPEndpoint) obj; + + // Check on layer + boolean localEquals = (fPort == other.fPort); + if (!localEquals) { + return false; + } + + // Check above layers. + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint != null) { + return endpoint.equals(other.getParentEndpoint()); + } + return true; + } + + @Override + public String toString() { + ProtocolEndpoint endpoint = getParentEndpoint(); + if (endpoint == null) { + @SuppressWarnings("null") + @NonNull String ret = String.valueOf(fPort); + return ret; + } + return endpoint.toString() + '/' + fPort; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPPacket.java new file mode 100644 index 0000000000..df1b614c21 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/UDPPacket.java @@ -0,0 +1,301 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.udp; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; + +import com.google.common.collect.ImmutableMap; + +/** + * Class that represents a UDP packet. + * + * @author Vincent Perot + */ +public class UDPPacket extends Packet { + + private final @Nullable Packet fChildPacket; + private final @Nullable ByteBuffer fPayload; + + private final int fSourcePort; + private final int fDestinationPort; + private final int fTotalLength; + private final int fChecksum; + + private @Nullable UDPEndpoint fSourceEndpoint; + private @Nullable UDPEndpoint fDestinationEndpoint; + + private @Nullable ImmutableMap fFields; + + /** + * Constructor of the UDP Packet class. + * + * @param file + * The file that contains this packet. + * @param parent + * The parent packet of this packet (the encapsulating packet). + * @param packet + * The entire packet (header and payload). + * @throws BadPacketException + * Thrown when the packet is erroneous. + */ + public UDPPacket(PcapFile file, @Nullable Packet parent, ByteBuffer packet) throws BadPacketException { + super(file, parent, Protocol.UDP); + + // The endpoints are lazy loaded. They are defined in the get*Endpoint() + // methods. + fSourceEndpoint = null; + fDestinationEndpoint = null; + + fFields = null; + + packet.order(ByteOrder.BIG_ENDIAN); + packet.position(0); + + fSourcePort = ConversionHelper.unsignedShortToInt(packet.getShort()); + fDestinationPort = ConversionHelper.unsignedShortToInt(packet.getShort()); + fTotalLength = ConversionHelper.unsignedShortToInt(packet.getShort()); + fChecksum = ConversionHelper.unsignedShortToInt(packet.getShort()); + + if (packet.array().length - packet.position() > 0) { + byte[] array = new byte[packet.array().length - packet.position()]; + packet.get(array); + + ByteBuffer payload = ByteBuffer.wrap(array); + payload.order(ByteOrder.BIG_ENDIAN); + payload.position(0); + fPayload = payload; + } else { + fPayload = null; + } + + // Find child + fChildPacket = findChildPacket(); + + } + + @Override + public @Nullable Packet getChildPacket() { + return fChildPacket; + } + + @Override + public @Nullable ByteBuffer getPayload() { + return fPayload; + } + + /** + * {@inheritDoc} + * + * See http://www.iana.org/assignments/service-names-port-numbers/service- + * names-port-numbers.xhtml or + * http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers + */ + @Override + protected @Nullable Packet findChildPacket() throws BadPacketException { + // TODO implement further protocols and update this + ByteBuffer payload = fPayload; + if (payload == null) { + return null; + } + + return new UnknownPacket(getPcapFile(), this, payload); + } + + @Override + public String toString() { + String string = getProtocol().getName() + ", Source Port: " + fSourcePort + ", Destination Port: " + fDestinationPort + //$NON-NLS-1$ //$NON-NLS-2$ + ", Length: " + fTotalLength + ", Checksum: " + fChecksum + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + final Packet child = fChildPacket; + if (child != null) { + return string + child.toString(); + } + return string; + } + + /** + * Getter method that returns the UDP Source Port. + * + * @return The source Port. + */ + public int getSourcePort() { + return fSourcePort; + } + + /** + * Getter method that returns the UDP Destination Port. + * + * @return The destination Port. + */ + public int getDestinationPort() { + return fDestinationPort; + } + + /** + * Getter method that returns the total length of the packet in bytes. The + * values it can take go from 8 to 65,515. + * + * @return The total length of the packet in bytes. + */ + public int getTotalLength() { + return fTotalLength; + } + + /** + * Getter method that returns the checksum (on header and payload). If the + * transmitter does not use this field, it is set to zero. This checksum + * might be wrong if the packet is erroneous. + * + * @return The checksum received from the packet. + */ + public int getChecksum() { + return fChecksum; + } + + @Override + public boolean validate() { + // Not yet implemented. ATM, we consider that all packets are valid. + // This is the case for all packets. + // TODO Implement it. + return true; + } + + @Override + public UDPEndpoint getSourceEndpoint() { + @Nullable + UDPEndpoint endpoint = fSourceEndpoint; + if (endpoint == null) { + endpoint = new UDPEndpoint(this, true); + } + fSourceEndpoint = endpoint; + return fSourceEndpoint; + } + + @Override + public UDPEndpoint getDestinationEndpoint() { + @Nullable UDPEndpoint endpoint = fDestinationEndpoint; + if (endpoint == null) { + endpoint = new UDPEndpoint(this, false); + } + fDestinationEndpoint = endpoint; + return fDestinationEndpoint; + } + + @Override + public Map getFields() { + ImmutableMap map = fFields; + if (map == null) { + @SuppressWarnings("null") + @NonNull ImmutableMap newMap = ImmutableMap. builder() + .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$ + .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$ + .put("Length", String.valueOf(fTotalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ + .put("Checksum", String.format("%s%04x", "0x", fChecksum)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .build(); + fFields = newMap; + return newMap; + } + return map; + } + + @Override + public String getLocalSummaryString() { + return "Src Port: " + fSourcePort + ", Dst Port: " + fDestinationPort; //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected String getSignificationString() { + return "Source Port: " + fSourcePort + ", Destination Port: " + fDestinationPort; //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + fChecksum; + final Packet child = fChildPacket; + if (child != null) { + result = prime * result + child.hashCode(); + } else { + result = prime * result; + } + result = prime * result + fDestinationPort; + final ByteBuffer payload = fPayload; + if (payload != null) { + result = prime * result + payload.hashCode(); + } else { + result = prime * result; + } + result = prime * result + fSourcePort; + result = prime * result + fTotalLength; + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + UDPPacket other = (UDPPacket) obj; + if (fChecksum != other.fChecksum) { + return false; + } + final Packet child = fChildPacket; + if (child != null) { + if (!child.equals(other.fChildPacket)) { + return false; + } + } else { + if (other.fChildPacket != null) { + return false; + } + } + if (fDestinationPort != other.fDestinationPort) { + return false; + } + final ByteBuffer payload = fPayload; + if (payload != null) { + if (!payload.equals(other.fPayload)) { + return false; + } + } else { + if (other.fPayload != null) { + return false; + } + } + if (fSourcePort != other.fSourcePort) { + return false; + } + if (fTotalLength != other.fTotalLength) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/package-info.java new file mode 100644 index 0000000000..d88e4a1bfe --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/udp/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol.udp; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownEndpoint.java new file mode 100644 index 0000000000..d94c676da5 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownEndpoint.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.unknown; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; + +/** + * Class that extends the {@link ProtocolEndpoint} class. It represents the + * endpoint for a protocol that is unknown. + * + * @author Vincent Perot + */ +public class UnknownEndpoint extends ProtocolEndpoint { + + /** + * Constructor of the {@link UnknownEndpoint} class. It takes a packet to + * get its endpoint. Since every packet has two endpoints (source and + * destination), the isSourceEndpoint parameter is used to specify which + * endpoint to take. + * + * @param packet + * The packet that contains the endpoints. + * @param isSourceEndpoint + * Whether to take the source or the destination endpoint of the + * packet. + */ + public UnknownEndpoint(UnknownPacket packet, boolean isSourceEndpoint) { + super(packet, isSourceEndpoint); + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public String toString() { + return EMPTY_STRING; + } + + @Override + public boolean equals(@Nullable Object obj) { + return false; + } +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownPacket.java new file mode 100644 index 0000000000..c247c5a06f --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/UnknownPacket.java @@ -0,0 +1,213 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.protocol.unknown; + +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; + +/** + * Class that represents an Unknown packet. It is possible to get such a packet + * if the protocol has not been implemented in this library or if the parent + * packet was invalid (in certain cases only). The header of such a packet is + * inexistent. + * + * @author Vincent Perot + */ +public class UnknownPacket extends Packet { + + private final @Nullable Packet fChildPacket; + private final ByteBuffer fPayload; + + private @Nullable UnknownEndpoint fSourceEndpoint; + private @Nullable UnknownEndpoint fDestinationEndpoint; + + private @Nullable ImmutableMap fFields; + + /** + * Constructor of an Unknown Packet object. + * + * @param file + * The file to which this packet belongs. + * @param parent + * The parent packet of this packet. + * @param packet + * The entire packet (header and payload). + */ + public UnknownPacket(PcapFile file, @Nullable Packet parent, ByteBuffer packet) { + super(file, parent, Protocol.UNKNOWN); + + // The endpoints are lazy loaded. They are defined in the get*Endpoint() + // methods. + fSourceEndpoint = null; + fDestinationEndpoint = null; + + fFields = null; + + // Header is not used. All data go into payload. + fPayload = packet; + + fChildPacket = findChildPacket(); + } + + @Override + public @Nullable Packet getChildPacket() { + return fChildPacket; + } + + @Override + public @Nullable ByteBuffer getPayload() { + return fPayload; + } + + @Override + protected @Nullable Packet findChildPacket() { + return null; + } + + @Override + public String toString() { + @SuppressWarnings("null") + @NonNull byte[] array = fPayload.array(); + String string = "Payload: " + ConversionHelper.bytesToHex(array, true); //$NON-NLS-1$ + final Packet child = fChildPacket; + if (child != null) { + return string + child.toString(); + } + return string; + } + + @Override + public boolean validate() { + // Not yet implemented. ATM, we consider that all packets are valid. + // This is the case for all packets. + // TODO Implement it. + return true; + } + + @Override + public UnknownEndpoint getSourceEndpoint() { + @Nullable UnknownEndpoint endpoint = fSourceEndpoint; + if (endpoint == null) { + endpoint = new UnknownEndpoint(this, true); + } + fSourceEndpoint = endpoint; + return fSourceEndpoint; + } + + @Override + public UnknownEndpoint getDestinationEndpoint() { + @Nullable UnknownEndpoint endpoint = fDestinationEndpoint; + if (endpoint == null) { + endpoint = new UnknownEndpoint(this, false); + } + fDestinationEndpoint = endpoint; + return fDestinationEndpoint; + } + + @Override + public Map getFields() { + ImmutableMap map = fFields; + if (map == null) { + @SuppressWarnings("null") + @NonNull byte[] array = fPayload.array(); + + Builder builder = ImmutableMap. builder() + .put("Binary", ConversionHelper.bytesToHex(array, true)); //$NON-NLS-1$ + try { + String s = new String(array, "UTF-8"); //$NON-NLS-1$ + builder.put("Character", s); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + // Do nothing. The string won't be added to the map anyway. + } + @SuppressWarnings("null") + @NonNull ImmutableMap newMap = builder.build(); + fFields = newMap; + return newMap; + } + return map; + } + + @Override + public String getLocalSummaryString() { + return "Len: " + fPayload.array().length + " bytes"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected String getSignificationString() { + return "Data: " + fPayload.array().length + " bytes"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + public Packet getMostEcapsulatedPacket() { + Packet packet = this.getParentPacket(); + if (packet == null) { + return this; + } + return packet; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + final Packet child = fChildPacket; + if (child != null) { + result = prime * result + ((fChildPacket == null) ? 0 : child.hashCode()); + } else { + result = prime * result; + } + result = prime * result + fPayload.hashCode(); + return result; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + UnknownPacket other = (UnknownPacket) obj; + final Packet child = fChildPacket; + if (child != null) { + if (!child.equals(other.fChildPacket)) { + return false; + } + } else { + if (other.fChildPacket != null) { + return false; + } + } + + if (!fPayload.equals(other.fPayload)) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/package-info.java new file mode 100644 index 0000000000..424f88930b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/protocol/unknown/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.protocol.unknown; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStream.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStream.java new file mode 100644 index 0000000000..fb7c25174d --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStream.java @@ -0,0 +1,149 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.stream; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpointPair; +import org.eclipse.linuxtools.pcap.core.packet.PacketUniqueID; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.pcap.PcapPacket; + +// TODO decide if default modifier a good idea. This allows only the +// stream builder to call that method (and any class that is added to this +// package). This effectively makes the stream read-only. + +/** + * Class that represents a packet stream, which is a collection of packets that + * share the same endpoints. The endpoints of a packet are protocol-dependent. + * For example, a TCP stream is a collection of packets that share the same MAC + * address, IP address, and Port couple. + * + * @author Vincent Perot + */ +public class PacketStream { + + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + private final List fListIndex; + private final Protocol fProtocol; + private final int fId; + private final ProtocolEndpointPair fEndpointPair; + + /** + * Constructor of a packet stream. + * + * @param protocol + * The protocol of the packets of the stream. This is needed + * because the definition of a stream is protocol-dependent. + * @param id + * The id of this stream. + * @param endpointPair + * The common endpoints of the packets in this stream. + */ + PacketStream(Protocol protocol, int id, ProtocolEndpointPair endpointPair) { + fProtocol = protocol; + fListIndex = new ArrayList<>(); + fId = id; + fEndpointPair = endpointPair; + } + + /** + * Add a packet unique ID to the stream. + * + * @param packet + * The packet unique ID that must be added. + */ + synchronized void add(PcapPacket packet) { + fListIndex.add(new PacketUniqueID(packet)); + } + + /** + * Get a packet unique ID in file from the stream. + * + * @param index + * The index in the stream of the packet to be retrieved. + * @return The retrieved packet unique ID. + */ + public synchronized PacketUniqueID get(int index) { + PacketUniqueID id = fListIndex.get(index); + if (id == null) { + throw new IllegalStateException("PacketUniqueID is null!"); //$NON-NLS-1$ + } + return id; + } + + /** + * Get the Protocol of this stream. + * + * @return The protocol of this stream. + */ + public Protocol getProtocol() { + return fProtocol; + } + + /** + * Method that returns the non-unique ID of this stream. + * + * @return the non-unique ID of this stream. + */ + public int getID() { + return fId; + } + + /** + * Method that returns the unique ID of this stream. + * + * @return the unique ID of this stream. + */ + public String getUniqueID() { + return fProtocol.getShortName() + '.' + fId; + } + + /** + * Method that returns the endpoint pair of the stream. + * + * @return The endpoint pair of the stream. + */ + public ProtocolEndpointPair getEndpointPair() { + return fEndpointPair; + } + + // TODO return also the endpoint set. + @Override + public synchronized String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Stream " + getUniqueID() + ", Number of Packets: " + fListIndex.size() + "\n"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + + for (int i = 0; i < fListIndex.size(); i++) { + sb.append(fListIndex.get(i) + ", "); //$NON-NLS-1$ + } + + String string = sb.toString(); + if (string == null) { + return EMPTY_STRING; + } + return string; + + } + + /** + * Method that returns the number of packets in the stream. + * + * @return The number of packets in the stream. + */ + public synchronized int size() { + return fListIndex.size(); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStreamBuilder.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStreamBuilder.java new file mode 100644 index 0000000000..1048e695c7 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/PacketStreamBuilder.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.stream; + +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.pcap.core.endpoint.ProtocolEndpointPair; +import org.eclipse.linuxtools.pcap.core.filter.IPacketFilter; +import org.eclipse.linuxtools.pcap.core.filter.PacketFilterByProtocol; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.packet.Packet; +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; +import org.eclipse.linuxtools.pcap.core.protocol.pcap.PcapPacket; +import org.eclipse.linuxtools.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.pcap.core.trace.PcapFile; + +/** + * Class that parse an entire pcap file to build the different streams. + * + * @author Vincent Perot + */ +public class PacketStreamBuilder { + + private final IPacketFilter fPacketFilter; + private final Protocol fProtocol; + + private final Map fStreams; + private final Map fIDs; + private int fCurrentId; + + /** + * Main constructor. + * + * @param protocol + * The protocol of the builder. + */ + public PacketStreamBuilder(Protocol protocol) { + fCurrentId = 0; + fProtocol = protocol; + fPacketFilter = new PacketFilterByProtocol(protocol); + fStreams = new HashMap<>(); + fIDs = new HashMap<>(); + } + + /** + * Method that returns a particular stream based on its ID. + * + * @param id + * The ID of the stream. + * @return The stream that has the specified ID. + */ + public synchronized @Nullable PacketStream getStream(int id) { + return fStreams.get(id); + } + + /** + * Method that returns a particular stream based on its endpoints. It + * returns null if no corresponding stream is found. + * + * @param endpointA + * The first endpoint of the stream. + * @param endpointB + * The second endpoint of the stream. + * + * @return The stream that has the specified endpoints. Return Null if no + * stream is found between the two endpoints. + */ + public synchronized @Nullable PacketStream getStream(ProtocolEndpoint endpointA, ProtocolEndpoint endpointB) { + ProtocolEndpointPair set = new ProtocolEndpointPair(endpointA, endpointB); + int id = fIDs.get(set); + return fStreams.get(id); + } + + /** + * Method that returns all the streams at the specified protocol level. + * + * @return The streams as a list. + */ + public synchronized Iterable getStreams() { + Iterable iterable = new LinkedList<>(fStreams.values()); + return iterable; + } + + /** + * Method that is called when the filter accepts a packet. This methods add + * the packet to a stream based on its characteristics. + * + * @param packet + * The packet to be added. + */ + public synchronized void addPacketToStream(PcapPacket packet) { + if (fPacketFilter.accepts(packet)) { + @Nullable Packet newPacket = packet.getPacket(fProtocol); + if (newPacket == null) { + return; + } + ProtocolEndpointPair endpointSet = new ProtocolEndpointPair(newPacket); + if (!fIDs.containsKey(endpointSet)) { + fIDs.put(endpointSet, fCurrentId); + fStreams.put(fCurrentId, new PacketStream(fProtocol, fCurrentId, endpointSet)); + fStreams.get(fCurrentId).add(packet); + fCurrentId++; + } else { + Integer id = fIDs.get(endpointSet); + fStreams.get(id).add(packet); + } + } + return; + } + + /** + * Getter method for the protocol of the stream builder. + * + * @return The protocol. + */ + public Protocol getProtocol() { + return fProtocol; + } + + /** + * Method that clears the builder. + */ + public void clear() { + fStreams.clear(); + fIDs.clear(); + fCurrentId = 0; + } + + /** + * Method that returns the number of streams built. + * + * @return The number of streams built. + */ + public synchronized int getNbStreams() { + return fStreams.size(); + } + + /** + * Method that parse an entire file and build the streams contained in the + * file. + * + * @param file + * The file path. + * @throws IOException + * When an IO error occurs. + * @throws BadPcapFileException + * When the PcapFile is not valid. + */ + public void parsePcapFile(String file) throws IOException, BadPcapFileException { + try (PcapFile pcapFile = new PcapFile(file);) { + while (pcapFile.hasNextPacket()) { // not eof + PcapPacket packet; + try { + packet = pcapFile.parseNextPacket(); + if (packet == null) { + return; + } + addPacketToStream(packet); + } catch (BadPacketException e) { + // Ignore packet. Do nothing. + } + } + } + + } +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/package-info.java new file mode 100644 index 0000000000..2cc0a8fa0a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/stream/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.stream; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/BadPcapFileException.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/BadPcapFileException.java new file mode 100644 index 0000000000..8515ca07b4 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/BadPcapFileException.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.trace; + +/** + * Exception that is thrown when the Pcap file is not valid. + * + * @author Vincent Perot + */ +public class BadPcapFileException extends Exception { + + private static final long serialVersionUID = 8228512814116052260L; + + /** + * Default constructor with no message. + */ + public BadPcapFileException() { + super(); + } + + /** + * Constructor with an attached message. + * + * @param message + * The message attached to this exception + */ + public BadPcapFileException(String message) { + super(message); + } + + /** + * Re-throw an exception into this type. + * + * @param e + * The previous Exception we caught + */ + public BadPcapFileException(Exception e) { + super(e); + } + + /** + * Constructor with an attached message and re-throw an exception into this + * type. + * + * @param message + * The message attached to this exception + * @param exception + * The previous Exception caught + */ + public BadPcapFileException(String message, Throwable exception) { + super(message, exception); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFile.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFile.java new file mode 100644 index 0000000000..9cb97f9d46 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFile.java @@ -0,0 +1,407 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.trace; + +import java.io.Closeable; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.FileChannel; +import java.util.TreeMap; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.pcap.core.protocol.pcap.PcapPacket; +import org.eclipse.linuxtools.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.pcap.core.util.PcapTimestampScale; + +/** + * Class that allows the interaction with a pcap file. + * + * @author Vincent Perot + */ +public class PcapFile implements Closeable { + + // TODO add pcapng support. + // TODO Make parsing faster by buffering the data. + + private final String fPcapFilePath; + private final ByteOrder fByteOrder; + private final FileChannel fFileChannel; + private final FileInputStream fFileInputStream; + private final PcapTimestampScale fTimestampPrecision; + + private final int fMajorVersion; + private final int fMinorVersion; + private final long fTimeAccuracy; + private final long fTimeZoneCorrection; + private final long fSnapshotLength; + private final long fDataLinkType; + + private final TreeMap fFileIndex; + + private long fCurrentRank; + private long fTotalNumberPackets; + + /** + * Constructor of the PcapFile Class. + * + * @param filePath + * The path to the pcap file. + * + * @throws BadPcapFileException + * Thrown if the Pcap File is not valid. + * @throws IOException + * Thrown if there is an IO error while reading the file. + */ + public PcapFile(String filePath) throws BadPcapFileException, IOException { + + fFileIndex = new TreeMap<>(); + fCurrentRank = 0; + fTotalNumberPackets = -1; + fPcapFilePath = filePath; + + // Check file validity + File pcapFile = new File(fPcapFilePath); + if ((!fPcapFilePath.endsWith(".cap") && !fPcapFilePath.endsWith(".pcap")) || //$NON-NLS-1$ //$NON-NLS-2$ + !pcapFile.exists() || !pcapFile.isFile() || pcapFile.length() < PcapFileValues.GLOBAL_HEADER_SIZE) { + throw new BadPcapFileException("Bad Pcap File."); //$NON-NLS-1$ + } + + if (!pcapFile.canRead()) { + throw new IOException("File is not readable."); //$NON-NLS-1$ + } + + // File is not empty. Try to open. + fFileInputStream = new FileInputStream(fPcapFilePath); + + @SuppressWarnings("null") + @NonNull FileChannel fileChannel = fFileInputStream.getChannel(); + fFileChannel = fileChannel; + + // Parse the global header. + // Read the magic number (4 bytes) from the input stream + // and determine the mode (big endian or little endian) + ByteBuffer globalHeader = ByteBuffer.allocate(PcapFileValues.GLOBAL_HEADER_SIZE); + globalHeader.clear(); + fFileChannel.read(globalHeader); + globalHeader.flip(); + int magicNumber = globalHeader.getInt(); + + @SuppressWarnings("null") + @NonNull ByteOrder be = ByteOrder.BIG_ENDIAN; + @SuppressWarnings("null") + @NonNull ByteOrder le = ByteOrder.LITTLE_ENDIAN; + + switch (magicNumber) { + case PcapFileValues.MAGIC_BIG_ENDIAN_MICRO: // file is big endian + fByteOrder = be; + fTimestampPrecision = PcapTimestampScale.MICROSECOND; + System.out.println(); + break; + case PcapFileValues.MAGIC_LITTLE_ENDIAN_MICRO: // file is little endian + fByteOrder = le; + fTimestampPrecision = PcapTimestampScale.MICROSECOND; + break; + case PcapFileValues.MAGIC_BIG_ENDIAN_NANO: // file is big endian + fByteOrder = be; + fTimestampPrecision = PcapTimestampScale.NANOSECOND; + break; + case PcapFileValues.MAGIC_LITTLE_ENDIAN_NANO: // file is little endian + fByteOrder = le; + fTimestampPrecision = PcapTimestampScale.NANOSECOND; + break; + default: + this.close(); + throw new BadPcapFileException(String.format("%08x", magicNumber) + " is not a known magic number."); //$NON-NLS-1$ //$NON-NLS-2$ + } + + // Put the rest of the buffer in file endian. + globalHeader.order(fByteOrder); + + // Initialization of global header fields. + fMajorVersion = ConversionHelper.unsignedShortToInt(globalHeader.getShort()); + fMinorVersion = ConversionHelper.unsignedShortToInt(globalHeader.getShort()); + fTimeAccuracy = ConversionHelper.unsignedIntToLong(globalHeader.getInt()); + fTimeZoneCorrection = ConversionHelper.unsignedIntToLong(globalHeader.getInt()); + fSnapshotLength = ConversionHelper.unsignedIntToLong(globalHeader.getInt()); + fDataLinkType = ConversionHelper.unsignedIntToLong(globalHeader.getInt()); + + fFileIndex.put(fCurrentRank, fFileChannel.position()); + + } + + /** + * Method that allows the parsing of a packet at the current position. + * + * @return The parsed Pcap Packet. + * @throws IOException + * Thrown when there is an error while reading the file. + * @throws BadPcapFileException + * Thrown when a packet header is invalid. + * @throws BadPacketException + * Thrown when the packet is erroneous. + */ + public synchronized @Nullable PcapPacket parseNextPacket() throws IOException, BadPcapFileException, BadPacketException { + + // Parse the packet header + if (fFileChannel.size() - fFileChannel.position() == 0) { + return null; + } + if (fFileChannel.size() - fFileChannel.position() < PcapFileValues.PACKET_HEADER_SIZE) { + throw new BadPcapFileException("A pcap header is invalid."); //$NON-NLS-1$ + } + + ByteBuffer pcapPacketHeader = ByteBuffer.allocate(PcapFileValues.PACKET_HEADER_SIZE); + pcapPacketHeader.clear(); + pcapPacketHeader.order(fByteOrder); + + fFileChannel.read(pcapPacketHeader); + + pcapPacketHeader.flip(); + pcapPacketHeader.position(PcapFileValues.INCLUDED_LENGTH_POSITION); + long includedPacketLength = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getInt()); + + if (fFileChannel.size() - fFileChannel.position() < includedPacketLength) { + throw new BadPcapFileException("A packet header is invalid."); //$NON-NLS-1$ + } + + if (includedPacketLength > Integer.MAX_VALUE) { + throw new BadPacketException("Packets that are bigger than 2^31-1 bytes are not supported."); //$NON-NLS-1$ + } + + ByteBuffer pcapPacketData = ByteBuffer.allocate((int) includedPacketLength); + pcapPacketData.clear(); + pcapPacketHeader.order(ByteOrder.BIG_ENDIAN); // Not really needed. + fFileChannel.read(pcapPacketData); + + pcapPacketData.flip(); + + fFileIndex.put(++fCurrentRank, fFileChannel.position()); + + return new PcapPacket(this, null, pcapPacketHeader, pcapPacketData, fCurrentRank - 1); + + } + + /** + * Method that allows to skip a packet at the current position. + * + * @throws IOException + * Thrown when there is an error while reading the file. + * @throws BadPcapFileException + * Thrown when a packet header is invalid. + */ + public synchronized void skipNextPacket() throws IOException, BadPcapFileException { + + // Parse the packet header + if (fFileChannel.size() - fFileChannel.position() == 0) { + return; + } + if (fFileChannel.size() - fFileChannel.position() < PcapFileValues.PACKET_HEADER_SIZE) { + throw new BadPcapFileException("A pcap header is invalid."); //$NON-NLS-1$ + } + + ByteBuffer pcapPacketHeader = ByteBuffer.allocate(PcapFileValues.PACKET_HEADER_SIZE); + pcapPacketHeader.clear(); + pcapPacketHeader.order(fByteOrder); + + fFileChannel.read(pcapPacketHeader); + + pcapPacketHeader.flip(); + pcapPacketHeader.position(PcapFileValues.INCLUDED_LENGTH_POSITION); + long includedPacketLength = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getInt()); + + if (fFileChannel.size() - fFileChannel.position() < includedPacketLength) { + throw new BadPcapFileException("A packet header is invalid."); //$NON-NLS-1$ + } + + fFileChannel.position(fFileChannel.position() + includedPacketLength); + + fFileIndex.put(++fCurrentRank, fFileChannel.position()); + + } + + /** + * Method that moves the position to the specified rank. + * + * @param rank + * The rank of the packet. + * + * @throws IOException + * Thrown when there is an error while reading the file. + * @throws BadPcapFileException + * Thrown when a packet header is invalid. + */ + public synchronized void seekPacket(long rank) throws IOException, BadPcapFileException { + + // Verify argument + if (rank < 0) { + throw new IllegalArgumentException(); + } + + Long positionInBytes = fFileIndex.get(rank); + + if (positionInBytes != null) { + // Index is known. Move to position. + fFileChannel.position(positionInBytes.longValue()); + fCurrentRank = rank; + } else { + // Index is unknown. Find the corresponding position. + // Find closest index + fCurrentRank = fFileIndex.floorKey(rank); + // skip until wanted packet is found + do { + skipNextPacket(); + } while (fCurrentRank != rank && hasNextPacket()); + } + } + + /** + * Method that indicates if there are packets remaining to read. It is an + * end of file indicator. + * + * @return Whether the pcap still has packets or not. + * @throws IOException + * If some IO error occurs. + */ + public synchronized boolean hasNextPacket() throws IOException { + return ((fFileChannel.size() - fFileChannel.position()) > 0); + } + + /** + * Getter method for the Byte Order of the file. + * + * @return The byte Order of the file. + */ + public ByteOrder getByteOrder() { + return fByteOrder; + } + + /** + * Getter method for the Major Version of the file. + * + * @return The Major Version of the file. + */ + public int getMajorVersion() { + return fMajorVersion; + } + + /** + * Getter method for the Minor Version of the file. + * + * @return The Minor Version of the file. + */ + public int getMinorVersion() { + return fMinorVersion; + } + + /** + * Getter method for the time accuracy of the file. + * + * @return The time accuracy of the file. + */ + public long getTimeAccuracy() { + return fTimeAccuracy; + } + + /** + * Getter method for the time zone correction of the file. + * + * @return The time zone correction of the file. + */ + public long getTimeZoneCorrection() { + return fTimeZoneCorrection; + } + + /** + * Getter method for the snapshot length of the file. + * + * @return The snapshot length of the file. + */ + public long getSnapLength() { + return fSnapshotLength; + } + + /** + * Getter method for the datalink type of the file. This parameter is used + * to determine higher-level protocols (Ethernet, WLAN, SLL). + * + * @return The datalink type of the file. + */ + public long getDataLinkType() { + return fDataLinkType; + } + + /** + * Getter method for the path of the file. + * + * @return The path of the file. + */ + public String getPath() { + return fPcapFilePath; + } + + /** + * Method that returns the total number of packets in the file. + * + * @return The total number of packets. + * @throws IOException + * Thrown when some IO error occurs. + * @throws BadPcapFileException + * Thrown when a packet header is invalid. + */ + public synchronized long getTotalNbPackets() throws IOException, BadPcapFileException { + if (fTotalNumberPackets == -1) { + long rank = fCurrentRank; + fCurrentRank = fFileIndex.floorKey(rank); + + // skip until end of file. + while (hasNextPacket()) { + skipNextPacket(); + } + fTotalNumberPackets = fCurrentRank; + fCurrentRank = rank; + seekPacket(rank); + } + return fTotalNumberPackets; + } + + /** + * Getter method that returns the current rank in the file (the packet + * number). + * + * @return The current rank. + */ + public synchronized long getCurrentRank() { + return fCurrentRank; + } + + /** + * Getter method that returns the timestamp precision of the file. + * + * @return The the timestamp precision of the file. + */ + public PcapTimestampScale getTimestampPrecision() { + return fTimestampPrecision; + } + + @Override + public void close() throws IOException { + fFileChannel.close(); + fFileInputStream.close(); + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFileValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFileValues.java new file mode 100644 index 0000000000..1b5a39f18b --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/PcapFileValues.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.trace; + +/** + * Interface that lists constants related to a Pcap File. + * + * See http://wiki.wireshark.org/Development/LibpcapFileFormat. + * + * @author Vincent Perot + */ +public interface PcapFileValues { + + /** Number used to determine the endianness and precision of the file */ + int MAGIC_BIG_ENDIAN_MICRO = 0xa1b2c3d4; + + /** Number used to determine the endianness and precision of the file */ + int MAGIC_LITTLE_ENDIAN_MICRO = 0xd4c3b2a1; + + /** Number used to determine the endianness and precision of the file */ + int MAGIC_BIG_ENDIAN_NANO = 0xa1b23c4d; + + /** Number used to determine the endianness and precision of the file */ + int MAGIC_LITTLE_ENDIAN_NANO = 0x4d3cb2a1; + + /** Size in bytes of a Pcap file global header */ + int GLOBAL_HEADER_SIZE = 24; + + /** Size in bytes of a Pcap packet header */ + int PACKET_HEADER_SIZE = 16; + + /** Position in bytes in the packet header of the packet's length */ + int INCLUDED_LENGTH_POSITION = 8; + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/package-info.java new file mode 100644 index 0000000000..1e6b655f8e --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/trace/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.trace; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/ConversionHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/ConversionHelper.java new file mode 100644 index 0000000000..0d1057d72a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/ConversionHelper.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.util; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.eclipse.linuxtools.pcap.core.protocol.ethernet2.EthernetIIValues; +import org.eclipse.linuxtools.pcap.core.protocol.ipv4.IPv4Values; + +/** + * Class for helping with the conversion of data. + * + * @author Vincent Perot + */ +public final class ConversionHelper { + + + @SuppressWarnings("null") + private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray(); //$NON-NLS-1$ + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + private static final String DEFAULT_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$ + private static final DateFormat DATE_FORMATTER = new SimpleDateFormat(DEFAULT_TIME_PATTERN); + + private ConversionHelper() { + } + + /** + * Generate an integer from an unsigned byte. + * + * @param n + * the unsigned byte. + * @return the integer representing the unsigned value. + */ + public static int unsignedByteToInt(byte n) { + return n & 0x000000FF; + } + + /** + * Generate an integer from an unsigned short. + * + * @param n + * the unsigned short. + * @return the integer representing the unsigned value. + */ + public static int unsignedShortToInt(short n) { + return n & 0x0000FFFF; + } + + /** + * Generate a long from an unsigned integer. + * + * @param n + * the unsigned integer. + * @return the long representing the unsigned value. + */ + public static long unsignedIntToLong(int n) { + return n & 0x00000000FFFFFFFFL; + } + + /** + * Generate an hex number from a byte array. + * + * @param bytes + * The array of bytes. + * @param spaced + * Whether there must be a space between each byte or not. + * @return the hex as a string. + */ + public static String bytesToHex(byte[] bytes, boolean spaced) { + // No need to check for character encoding since bytes represents a + // number. + + if (bytes.length == 0) { + return EMPTY_STRING; + } + + char[] hexChars = spaced ? new char[bytes.length * 3 - 1] : new char[bytes.length * 2]; + int delta = spaced ? 3 : 2; + char separator = ' '; + + for (int j = 0; j < bytes.length; j++) { + + int v = bytes[j] & 0xFF; + hexChars[j * delta] = HEX_ARRAY[v >>> 4]; + hexChars[j * delta + 1] = HEX_ARRAY[v & 0x0F]; + + if (spaced && (j != bytes.length - 1)) { + hexChars[j * delta + 2] = separator; + } + } + return new String(hexChars); + } + + // TODO Add little endian support + /** + * Generate a string representing the MAC address. + * + * @param mac + * The MAC address as a byte array. + * @return The string representing the MAC address. + */ + public static String toMacAddress(byte[] mac) { + + if (mac.length != EthernetIIValues.MAC_ADDRESS_SIZE) { + throw new IllegalArgumentException(); + } + char separator = ':'; + return String.format("%02x", mac[0]) + separator + //$NON-NLS-1$ + String.format("%02x", mac[1]) + separator + //$NON-NLS-1$ + String.format("%02x", mac[2]) + separator + //$NON-NLS-1$ + String.format("%02x", mac[3]) + separator + //$NON-NLS-1$ + String.format("%02x", mac[4]) + separator + //$NON-NLS-1$ + String.format("%02x", mac[5]); //$NON-NLS-1$ + + } + + // TODO Add little endian support + /** + * Generate a string representing the IP address. + * + * @param ip + * The IP address as a byte array. + * @return The string representing the IP address. + */ + public static String toIpAddress(byte[] ip) { + + if (ip.length != IPv4Values.IP_ADDRESS_SIZE) { + throw new IllegalArgumentException(); + } + char separator = '.'; + return Integer.toString(ip[0] & 0xFF) + separator + + Integer.toString(ip[1] & 0xFF) + separator + + Integer.toString(ip[2] & 0xFF) + separator + + Integer.toString(ip[3] & 0xFF); + + } + + // TODO support non GMT time. + + /** + * Convert a timestamp into a date. + * + * @param ts + * The timestamp. It represents the time since Epoch in + * microseconds. + * @param scale + * The scale of the timestamp. + * @return The date as a string. + */ + public static String toGMTTime(long ts, PcapTimestampScale scale) { + long timestamp; + switch (scale) { + case MICROSECOND: + timestamp = ts * 1000; + break; + case NANOSECOND: + timestamp = ts; + break; + default: + throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$ + } + return format(timestamp); + } + + /** + * Format the timestamp to a string. + * + * @param value + * the timestamp value to format (in ns) + * @return the formatted timestamp + */ + private static String format(long value) { + // Split the timestamp value into its sub-components + long date = value / 1000000; // milliseconds since epoch + long cs = Math.abs((value % 1000000) / 1000); // microseconds + long ns = Math.abs(value % 1000); // nanoseconds + + Date dateObject = new Date(date); + + StringBuilder sb = new StringBuilder(DATE_FORMATTER.format(dateObject)); + sb.append('.') + .append(String.format("%03d", cs)) //$NON-NLS-1$ + .append('.') + .append(String.format("%03d", ns)); //$NON-NLS-1$ + + String string = sb.toString(); + if (string == null) { + return EMPTY_STRING; + } + return string; + + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/EthertypeHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/EthertypeHelper.java new file mode 100644 index 0000000000..d6a379fd7a --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/EthertypeHelper.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.util; + +// TODO finish this +// TODO maybe match it to protocol instead of string. + +/** + * Helper that is used to help mapping a certain ethertype to a particular + * protocol (i.e. IPv4). This is used when finding the child packet of an + * Ethernet packet, for instance. + * + * See http://en.wikipedia.org/wiki/EtherType + * + * @author Vincent Perot + */ +public final class EthertypeHelper { + + /** EtherType IPv4 */ + public static final int ETHERTYPE_IPV4 = 0x0800; + + /** EtherType ARP */ + public static final int ETHERTYPE_ARP = 0x0806; + + /** EtherType Wake-On-LAN */ + public static final int ETHERTYPE_WAKE_ON_LAN = 0x0842; + + /** EtherType TRILL */ + public static final int ETHERTYPE_TRILL = 0x22F3; + + /** EtherType DECnet Phase IV */ + public static final int ETHERTYPE_DECNET_PHASE_IV = 0x6003; + + private EthertypeHelper() {} + + /** + * Method that matches the ethertype as a number, to a protocol as a string. + * + * @param ethertype + * The Ethertype as an int. + * @return The protocol as a string. + */ + public static String toString(int ethertype) { + switch (ethertype) { + case ETHERTYPE_IPV4: + return "Internet Protocol Version 4"; //$NON-NLS-1$ + case ETHERTYPE_ARP: + return "Address Resolution Protocol"; //$NON-NLS-1$ + case ETHERTYPE_WAKE_ON_LAN: + return "Wake-on-LAN"; //$NON-NLS-1$ + case ETHERTYPE_TRILL: + return "IETF TRILL Protocol"; //$NON-NLS-1$ + case ETHERTYPE_DECNET_PHASE_IV: + return "DECnet Phase IV"; //$NON-NLS-1$ + default: + return "Unknown"; //$NON-NLS-1$ + } + } + + /** + * Convert an ethertype (int) into its string representation. This allows + * the mapping of ethertype to the real protocol name. + * + * @param type + * The Ethertype to convert. + * @return The Ethertype as a string. + */ + public static String toEtherType(int type) { + return toString(type) + " (0x" + String.format("%04x", type) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/IPProtocolNumberHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/IPProtocolNumberHelper.java new file mode 100644 index 0000000000..52381ba3f7 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/IPProtocolNumberHelper.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.util; + +import org.eclipse.linuxtools.pcap.core.protocol.Protocol; + +// TODO finish this +// TODO maybe match it to protocol instead of string. + +/** + * Helper that is used to help mapping a certain protocol number to a particular + * protocol (i.e. TCP). This is used when finding the child packet of an IPv4 + * packet, for instance. + * + * See http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers + * + * @author Vincent Perot + */ +public final class IPProtocolNumberHelper { + + /** Protocol Number ICMP */ + public static final int PROTOCOL_NUMBER_ICMP = 1; + + /** Protocol Number IGMP */ + public static final int PROTOCOL_NUMBER_IGMP = 2; + + /** Protocol Number TCP */ + public static final int PROTOCOL_NUMBER_TCP = 6; + + /** Protocol Number UDP */ + public static final int PROTOCOL_NUMBER_UDP = 17; + + /** Protocol Number Encapsulated IPv6 */ + public static final int PROTOCOL_NUMBER_ENCAP_IPV6 = 41; + + /** Protocol Number OSPF */ + public static final int PROTOCOL_NUMBER_OSPF = 89; + + /** Protocol Number SCTP */ + public static final int PROTOCOL_NUMBER_SCTP = 132; + + private IPProtocolNumberHelper() {} + + /** + * Method that match the protocol number to a protocol as a string. + * + * @param protocolNumber + * The protocol number as an int. + * @return The protocol as a string. + */ + public static String toString(int protocolNumber) { + switch (protocolNumber) { + case PROTOCOL_NUMBER_ICMP: + return "ICMP"; //$NON-NLS-1$ + case PROTOCOL_NUMBER_IGMP: + return "IGMP"; //$NON-NLS-1$ + case PROTOCOL_NUMBER_TCP: + return Protocol.TCP.getName(); + case PROTOCOL_NUMBER_UDP: + return Protocol.UDP.getName(); + case PROTOCOL_NUMBER_ENCAP_IPV6: + return "IPv6"; //$NON-NLS-1$ + case PROTOCOL_NUMBER_OSPF: + return "OSPF"; //$NON-NLS-1$ + case PROTOCOL_NUMBER_SCTP: + return "SCTP"; //$NON-NLS-1$ + default: + return "Unknown"; //$NON-NLS-1$ + } + } +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/LinkTypeHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/LinkTypeHelper.java new file mode 100644 index 0000000000..e5d54fa0f6 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/LinkTypeHelper.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.util; + +// TODO finish this +// TODO map to protocol instead of string? that would make more sense imo. + +/** + * Helper that is used to help mapping a certain linktype to a particular + * protocol (i.e. ethernet). + * + * See http://www.tcpdump.org/linktypes.html + * + * @author Vincent Perot + */ +public final class LinkTypeHelper { + + /** Linktype Null */ + public static final int LINKTYPE_NULL = 0; + + /** Linktype Ethernet II */ + public static final int LINKTYPE_ETHERNET = 1; + + /** Linktype AX25 */ + public static final int LINKTYPE_AX25 = 3; + + /** Linktype IEEE802.5 */ + public static final int LINKTYPE_IEEE802_5 = 6; + + /** Linktype Raw */ + public static final int LINKTYPE_RAW = 101; + + /** Linktype IEEE802.11 */ + public static final int LINKTYPE_IEEE802_11 = 105; + + /** Linktype Linux SLL */ + public static final int LINKTYPE_LINUX_SLL = 113; + + private LinkTypeHelper() {} + + /** + * Method that match the linktype as an int to a protocol as a string. + * + * @param linkType + * The linkType as an int. + * @return The protocol as a string. + */ + public static String toString(int linkType) { + switch (linkType) { + case LINKTYPE_NULL: + return "null"; //$NON-NLS-1$ + case LINKTYPE_ETHERNET: + return "ethernet"; //$NON-NLS-1$ + case LINKTYPE_AX25: + return "ax25"; //$NON-NLS-1$ + case LINKTYPE_IEEE802_5: + return "ieee802.5"; //$NON-NLS-1$ + case LINKTYPE_RAW: + return "raw"; //$NON-NLS-1$ + case LINKTYPE_IEEE802_11: + return "ieee802.11"; //$NON-NLS-1$ + case LINKTYPE_LINUX_SLL: + return "linux_sll"; //$NON-NLS-1$ + default: + return "unknown"; //$NON-NLS-1$ + } + } + +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/PcapTimestampScale.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/PcapTimestampScale.java new file mode 100644 index 0000000000..af5552cdb1 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/PcapTimestampScale.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.util; + +/** + * Enum for the different time precision for pcap files. + * + * @author Vincent Perot + */ +public enum PcapTimestampScale { + + /** Microsecond Pcap */ + MICROSECOND, + /** Nanosecond Pcap */ + NANOSECOND +} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/package-info.java new file mode 100644 index 0000000000..9d8a6e4084 --- /dev/null +++ b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/pcap/core/util/package-info.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.linuxtools.pcap.core.util; \ No newline at end of file -- 2.34.1