From: Alexandre Montplaisir Date: Tue, 23 Sep 2014 22:08:30 +0000 (-0400) Subject: pcap: Move plugins to the Trace Compass namespace X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=93f3824e77951493863def4ec532f4404960ba36;p=deliverable%2Ftracecompass.git pcap: Move plugins to the Trace Compass namespace Change-Id: I8effa07aba182ee4796d007355e0f31e1b38b356 Signed-off-by: Alexandre Montplaisir --- diff --git a/org.eclipse.linuxtools.lttng.alltests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng.alltests/META-INF/MANIFEST.MF index 2eff8fdb01..ab2dc961e3 100644 --- a/org.eclipse.linuxtools.lttng.alltests/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng.alltests/META-INF/MANIFEST.MF @@ -30,7 +30,7 @@ Require-Bundle: org.junit;bundle-version="4.0.0", org.eclipse.tracecompass.btf.core.tests;bundle-version="3.1.0", org.eclipse.linuxtools.tmf.analysis.xml.core.tests;bundle-version="1.1.0", org.eclipse.linuxtools.tmf.analysis.xml.ui.tests;bundle-version="1.1.0", - org.eclipse.linuxtools.pcap.core.tests;bundle-version="1.0.0", + org.eclipse.tracecompass.pcap.core.tests;bundle-version="1.0.0", org.eclipse.linuxtools.tmf.pcap.core.tests;bundle-version="1.0.0", org.eclipse.linuxtools.tmf.pcap.ui.swtbot.tests;bundle-version="1.0.0" Export-Package: org.eclipse.linuxtools.lttng.alltests;x-internal:=true diff --git a/org.eclipse.linuxtools.lttng.testing/feature.xml b/org.eclipse.linuxtools.lttng.testing/feature.xml index 97586da8bb..2ad96274e3 100644 --- a/org.eclipse.linuxtools.lttng.testing/feature.xml +++ b/org.eclipse.linuxtools.lttng.testing/feature.xml @@ -101,7 +101,7 @@ unpack="false"/> - - - - - - - - diff --git a/org.eclipse.linuxtools.pcap.core.tests/.project b/org.eclipse.linuxtools.pcap.core.tests/.project deleted file mode 100644 index c0c7873e17..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - 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 deleted file mode 100644 index 99f26c0203..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 5a0ad22d2a..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index f3fc64575b..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,393 +0,0 @@ -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=ignore -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 deleted file mode 100644 index 4fd0c7006a..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,56 +0,0 @@ -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 deleted file mode 100644 index acc3abd47c..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs +++ /dev/null @@ -1,97 +0,0 @@ -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 deleted file mode 100644 index 62cfa90dee..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/.settings/org.eclipse.pde.prefs +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 59a576b788..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,29 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %Bundle-Name -Bundle-Vendor: %Bundle-Vendor -Bundle-Version: 1.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="1.0.0" -Export-Package: org.eclipse.linuxtools.pcap.core.tests, - org.eclipse.linuxtools.pcap.core.tests.file;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.packet;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.perf, - org.eclipse.linuxtools.pcap.core.tests.perf.trace;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol.ethernet2;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol.ipv4;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol.pcap;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol.tcp;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol.udp;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.protocol.unknown;x-internal:=true, - org.eclipse.linuxtools.pcap.core.tests.shared;x-friends:="org.eclipse.linuxtools.tmf.pcap.core.tests", - org.eclipse.linuxtools.pcap.core.tests.stream;x-internal:=true -Import-Package: com.google.common.collect, - org.eclipse.test.performance diff --git a/org.eclipse.linuxtools.pcap.core.tests/about.html b/org.eclipse.linuxtools.pcap.core.tests/about.html deleted file mode 100644 index 28737f60b7..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -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 deleted file mode 100644 index 7de632eb60..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/build.properties +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################### -# 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/,\ - perf/,\ - shared/ -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/perf/org/eclipse/linuxtools/pcap/core/tests/perf/AllPerfTests.java b/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/AllPerfTests.java deleted file mode 100644 index 3482713418..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/AllPerfTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * 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 implementation and API - *******************************************************************************/ - -package org.eclipse.linuxtools.pcap.core.tests.perf; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Run all performance test suites. - * - * @author Vincent Perot - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - org.eclipse.linuxtools.pcap.core.tests.perf.trace.AllTests.class -}) -public class AllPerfTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/AllTests.java deleted file mode 100644 index 4eb62a4d75..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.perf.trace; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - PcapReadBenchmark.class, - PcapSeekBenchmark.class -}) -public class AllTests { -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java b/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java deleted file mode 100644 index 1e98a81d91..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * 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.tests.perf.trace; - -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceMeter; -import org.junit.Test; - -/** - * Benchmark of the Pcap parser for reading a trace. Note: We should get a - * bigger trace. One that has WAYYYY more events since this current trace is - * just parsed too fast. - * - * @author Vincent Perot - */ -public class PcapReadBenchmark { - - private static final String TEST_SUITE_NAME = "Pcap Read Benchmark"; - private static final String TEST_ID = "org.eclipse.linuxtools#" + TEST_SUITE_NAME; - private static final int LOOP_COUNT = 25; - private static final int RUN_BETWEEN_COMMIT_COUNT = 15; - - /** - * Benchmark reading the pcap trace - */ - @Test - public void testPcapTrace() { - readTrace(PcapTestTrace.BENCHMARK_TRACE, "trace-pcap", true); - } - - private static void readTrace(PcapTestTrace testTrace, String testName, boolean inGlobalSummary) { - assumeTrue(testTrace.exists()); - - Performance perf = Performance.getDefault(); - PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); - perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); - - if (inGlobalSummary) { - perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); - } - - for (int loop = 0; loop < LOOP_COUNT; loop++) { - pm.start(); - try (PcapFile trace = testTrace.getTrace();) { - for (int i = 0; i < RUN_BETWEEN_COMMIT_COUNT; i++) { - trace.seekPacket(0); - while (trace.hasNextPacket()) { - Packet packet = trace.parseNextPacket(); - if (packet == null) { - fail("Test failed at iteration " + loop + '.' + i + ", at packet " + trace.getCurrentRank()); - return; - } - /* Do something with the packet because we are awesome */ - packet.getPayload(); - } - } - } catch (IOException | BadPcapFileException | BadPacketException e) { - fail("Test failed at iteration " + loop + ':' + e.getMessage()); - } - pm.stop(); - } - pm.commit(); - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java b/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java deleted file mode 100644 index e16cebac58..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * 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.tests.perf.trace; - -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceMeter; -import org.junit.Test; - -/** - * Tests for performance regressions of the pcap reader. It only tests the pcap - * reader, not tmf.
- * This test runs in 3 passes. - *
    - *
  • first it opens a trace
  • - *
  • then it reads the trace completely
  • - *
  • then it randomly (seeded) seeks NB_SEEKS locations in the trace and reads - * one event at each position.
  • - *
- *
  • Note: We should make more seeks, since the current number is just too - * fast.
  • - * - * @author Vincent Perot - */ -public class PcapSeekBenchmark { - - private static final Random RND = new Random(1000); - - private static final int LOOP_COUNT = 25; - private static final int NB_SEEKS = 1000000; - private static final String TEST_SUITE_NAME = "Pcap Read & Seek Benchmark (" + NB_SEEKS + " seeks)"; - private static final String TEST_ID = "org.eclipse.linuxtools#" + TEST_SUITE_NAME; - - /** - * Run the benchmark scenario for the pcap trace. - */ - @Test - public void testPcapTrace() { - readAndSeekTrace(PcapTestTrace.BENCHMARK_TRACE, "trace-pcap", true); - } - - private static void readAndSeekTrace(PcapTestTrace testTrace, String testName, boolean inGlobalSummary) { - assumeTrue(testTrace.exists()); - - Performance perf = Performance.getDefault(); - PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); - perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); - - if (inGlobalSummary) { - perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); - } - - for (int loop = 0; loop < LOOP_COUNT; loop++) { - try (PcapFile trace = testTrace.getTrace()) { - trace.seekPacket(0); - - /* Read the whole trace to find out the number of packets */ - long nbPackets = trace.getTotalNbPackets(); - - /* Generate the timestamps we will seek to */ - List seekTimestamps = new LinkedList<>(); - final long range = nbPackets; - for (int i = 0; i < NB_SEEKS; i++) { - long rank = (RND.nextLong() % range); - if (rank < 0) { - // This is needed since modulus can return a negative - // number. - rank += range; - } - seekTimestamps.add(rank); - } - - /* Benchmark seeking to the generated timestamps */ - pm.start(); - for (Long rank : seekTimestamps) { - trace.seekPacket(rank); - trace.parseNextPacket(); - } - pm.stop(); - - } catch (IOException | BadPcapFileException | BadPacketException e) { - /* Should not happen if assumeTrue() passed above */ - fail("Test failed at iteration " + loop + ':' + e.getMessage()); - } - } - pm.commit(); - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/plugin.properties b/org.eclipse.linuxtools.pcap.core.tests/plugin.properties deleted file mode 100644 index 2839a98dc9..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/plugin.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# 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 deleted file mode 100644 index fc8305cd1b..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - 4.0.0 - - - org.eclipse.tracecompass - org.eclipse.tracecompass - 3.2.0-SNAPSHOT - - - org.eclipse.linuxtools.pcap.core.tests - 1.0.0-SNAPSHOT - eclipse-test-plugin - - Linux Tools Pcap Parser Core Tests Plug-in - - - - - download-traces - - - !maven.test.skip - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - prepare - pre-integration-test - - - - - - - run - - - - - - - - - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - org.eclipse.linuxtools.pcap.core.tests - org.eclipse.linuxtools.pcap.core.tests.AllPcapCoreTests - false - false - org.eclipse.platform.ide - - - - - - maven-clean-plugin - 2.5 - - - clean-traces - clean - - - - rsc - - *.zip - *.pcap - *.cap - *.tar* - - - *.xml - *.sh - - - rsc/kernel - - - - clean - - - - - - - - - org.eclipse.linuxtools.pcap - diff --git a/org.eclipse.linuxtools.pcap.core.tests/rsc/.gitignore b/org.eclipse.linuxtools.pcap.core.tests/rsc/.gitignore deleted file mode 100644 index a8ddf0ad84..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/rsc/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.zip -*.pcap -*.cap -*.tar* -/kernel diff --git a/org.eclipse.linuxtools.pcap.core.tests/rsc/get-traces.xml b/org.eclipse.linuxtools.pcap.core.tests/rsc/get-traces.xml deleted file mode 100644 index 73d7df96c0..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/rsc/get-traces.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.eclipse.linuxtools.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.java b/org.eclipse.linuxtools.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.java deleted file mode 100644 index 5f78b56b83..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * 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.tests.shared; - -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; - -/** - * Here is the list of the available test traces for the Pcap parser. - * - * @author Vincent Perot - */ -public enum PcapTestTrace { - - /** A bad pcap file. */ - BAD_PCAPFILE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "BadPcapFile.pcap"), - - /** A Valid Pcap that is empty. */ - EMPTY_PCAP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "EmptyPcap.pcap"), - - /** A Pcap that mostly contains TCP packets. */ - MOSTLY_TCP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "mostlyTCP.pcap"), - - /** A Pcap that mostly contains UDP packets. */ - MOSTLY_UDP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "mostlyUDP.pcap"), - - /** A big-endian trace that contains two packets. */ - SHORT_BIG_ENDIAN("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "Short_BigEndian.pcap"), - - /** A little-endian trace that contains two packets. */ - SHORT_LITTLE_ENDIAN("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "Short_LittleEndian.pcap"), - - /** A large trace for benchmarking. */ - BENCHMARK_TRACE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "benchmarkTrace.pcap"), - - /** A Kernel trace directory. */ - KERNEL_DIRECTORY("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "kernel"), - - /** A Kernel trace file. */ - KERNEL_TRACE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "kernel", "channel0_0"); - - private final @NonNull Path fPath; - - private PcapTestTrace(@NonNull String first, String... more) { - @SuppressWarnings("null") - @NonNull Path path = FileSystems.getDefault().getPath(first, more); - fPath = path; - } - - /** @return The path to the test trace */ - public @NonNull Path getPath() { - return fPath; - } - - /** - * Get a Pcap Trace instance of a test trace. Make sure to call - * {@link #exists()} before calling this! - * - * @return The PcapFile object - * @throws IOException - * Thrown when some IO error occurs. - * @throws BadPcapFileException - * Thrown when the file is not a valid Pcap File. - */ - public PcapFile getTrace() throws BadPcapFileException, IOException { - return new PcapFile(fPath); - } - - /** - * Check if this test trace actually exists on disk. - * - * @return If the trace exists - */ - public boolean exists() { - if (Files.notExists(fPath)) { - return false; - } - return true; - } - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java deleted file mode 100644 index 86e1cb8c38..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * 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.tests; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Master test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - org.eclipse.linuxtools.pcap.core.tests.file.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.packet.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.ethernet2.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.ipv4.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.pcap.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.tcp.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.udp.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.protocol.unknown.AllTests.class, - org.eclipse.linuxtools.pcap.core.tests.stream.AllTests.class -}) -public class AllPcapCoreTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/AllTests.java deleted file mode 100644 index 5f5b9a8018..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/AllTests.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * 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.tests.file; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * File test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - PcapFileOpenTest.class, - PcapFileOpenFailTest.class, - PcapFileReadTest.class, - PcapFileEndiannessTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java deleted file mode 100644 index 28a1dc744c..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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.tests.file; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteOrder; -import java.nio.file.Path; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Test; - -/** - * JUnit Class that tests whether the Pcap parser can read both big endian and - * little endian files. - * - * @author Vincent Perot - */ -public class PcapFileEndiannessTest { - - /** - * Test that verify that two files with different endianness contain the - * same packets. - * - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void EndiannessTest() throws IOException, BadPcapFileException, BadPacketException { - PcapTestTrace trace = PcapTestTrace.SHORT_LITTLE_ENDIAN; - assumeTrue(trace.exists()); - Path path1 = trace.getPath(); - - trace = PcapTestTrace.SHORT_LITTLE_ENDIAN; - assumeTrue(trace.exists()); - Path path2 = PcapTestTrace.SHORT_BIG_ENDIAN.getPath(); - - try (PcapFile littleEndian = new PcapFile(path1); - PcapFile bigEndian = new PcapFile(path2);) { - assertEquals(ByteOrder.BIG_ENDIAN, bigEndian.getByteOrder()); - assertEquals(ByteOrder.LITTLE_ENDIAN, littleEndian.getByteOrder()); - while (littleEndian.hasNextPacket() && bigEndian.hasNextPacket()) { - assertEquals(littleEndian.parseNextPacket(), bigEndian.parseNextPacket()); - } - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java deleted file mode 100644 index 7b8ffcac8f..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * 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.tests.file; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Test; - -/** - * JUnit Class that tests the opening of non-valid pcap files. - * - * @author Vincent Perot - */ -public class PcapFileOpenFailTest { - - /** - * Test that tries to open a pcap with a bad magic number - * - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - */ - @Test - public void FileOpenBadPcapTest() throws IOException { - PcapTestTrace trace = PcapTestTrace.BAD_PCAPFILE; - assumeTrue(trace.exists()); - - try (PcapFile file = new PcapFile(trace.getPath());) { - fail("The pcap was accepted even though the magic number is invalid!"); - } catch (BadPcapFileException e) { - assertEquals("c3d4a1b2 is not a known magic number.", e.getMessage()); - } - } - - /** - * Test that tries to open a non-pcap binary file - * - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - */ - @Test - public void FileOpenBinaryFile() throws IOException { - PcapTestTrace trace = PcapTestTrace.KERNEL_TRACE; - assumeTrue(trace.exists()); - - try (PcapFile file = new PcapFile(trace.getPath());) { - fail("The file was accepted even though it is not a pcap file!"); - } catch (BadPcapFileException e) { - assertEquals("c11ffcc1 is not a known magic number.", e.getMessage()); - } - } - - /** - * Test that tries to open a directory - * - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - */ - @Test - public void FileOpenDirectory() throws IOException { - PcapTestTrace trace = PcapTestTrace.KERNEL_DIRECTORY; - assumeTrue(trace.exists()); - - try (PcapFile file = new PcapFile(trace.getPath());) { - fail("The file was accepted even though it is not a pcap file!"); - } catch (BadPcapFileException e) { - assertEquals("Bad Pcap File.", e.getMessage()); - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java deleted file mode 100644 index df22a7b902..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * 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.tests.file; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteOrder; - -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Test; - -/** - * JUnit Class that tests the opening of valid pcap files. - * - * @author Vincent Perot - */ -public class PcapFileOpenTest { - - /** - * Test that verify that an empty pcap file is properly opened and that the - * file properties are correct. - * - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - */ - @Test - public void FileOpenEmptyTest() throws IOException, BadPcapFileException { - - PcapTestTrace trace = PcapTestTrace.EMPTY_PCAP; - assumeTrue(trace.exists()); - - try (PcapFile file = new PcapFile(trace.getPath());) { - assertEquals(PcapTestTrace.EMPTY_PCAP.getPath(), file.getPath()); - assertEquals(2, file.getMajorVersion()); - assertEquals(4, file.getMinorVersion()); - assertEquals(1, file.getDataLinkType()); - assertEquals(65535, file.getSnapLength()); - assertEquals(0, file.getTimeAccuracy()); - assertEquals(0, file.getTimeZoneCorrection()); - assertEquals(ByteOrder.LITTLE_ENDIAN, file.getByteOrder()); - - assertEquals(0, file.getTotalNbPackets()); - - } - } - - /** - * Test that verify that an non-empty pcap file is properly opened and that - * the file properties are correct. - * - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - */ - - @Test - public void FileOpenTest() throws IOException, BadPcapFileException { - - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - - try (PcapFile file = new PcapFile(trace.getPath());) { - assertEquals(PcapTestTrace.MOSTLY_TCP.getPath(), file.getPath()); - assertEquals(2, file.getMajorVersion()); - assertEquals(4, file.getMinorVersion()); - assertEquals(1, file.getDataLinkType()); - assertEquals(65535, file.getSnapLength()); - assertEquals(0, file.getTimeAccuracy()); - assertEquals(0, file.getTimeZoneCorrection()); - assertEquals(ByteOrder.LITTLE_ENDIAN, file.getByteOrder()); - - assertEquals(43, file.getTotalNbPackets()); - - } - } - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java deleted file mode 100644 index 5d86e74adc..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * 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.tests.file; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Test; - -/** - * JUnit Class that tests if packets are read without error. - * - * @author Vincent Perot - */ -public class PcapFileReadTest { - - /** - * Test that verify that packets are well read and that no error happens in - * file index. - * - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void FileReadTest() throws IOException, BadPcapFileException, BadPacketException { - - PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; - assumeTrue(trace.exists()); - - try (PcapFile file = new PcapFile(trace.getPath());) { - - PcapPacket packet = file.parseNextPacket(); - if (packet == null) { - fail("FileReadTest() failed!"); - return; - } - - assertEquals(1, file.getCurrentRank()); - // Verify Pcap packet. - assertEquals(file, packet.getPcapFile()); - assertEquals(PcapProtocol.PCAP, packet.getProtocol()); - assertEquals(0, packet.getIndex()); - assertEquals(1120469540839312L, packet.getTimestamp()); - assertEquals(92, packet.getOriginalLength()); - assertEquals(92, packet.getIncludedLength()); - assertEquals(false, packet.isTruncated()); - assertEquals(true, packet.validate()); - // Verify Ethernet Packet - if (!packet.hasProtocol(PcapProtocol.ETHERNET_II)) { - fail("Packet doesn't have ethernet!"); - } - // Verify IPv4 Packet - if (!packet.hasProtocol(PcapProtocol.IPV4)) { - fail("Packet doesn't have IPv4!"); - } - // Verify UDP Packet - if (!packet.hasProtocol(PcapProtocol.UDP)) { - fail("Packet doesn't have UDP!"); - } - // Verify Unknown Packet - if (!packet.hasProtocol(PcapProtocol.UNKNOWN)) { - fail("Packet doesn't have payload!"); - } - - // Parse a "random" packet - file.seekPacket(58); - packet = file.parseNextPacket(); - if (packet == null) { - fail("FileReadTest() failed!"); - return; - } - - // Verify Pcap packet. - assertEquals(file, packet.getPcapFile()); - assertEquals(PcapProtocol.PCAP, packet.getProtocol()); - assertEquals(58, packet.getIndex()); - assertEquals(1120469635045415L, packet.getTimestamp()); - assertEquals(113, packet.getOriginalLength()); - assertEquals(113, packet.getIncludedLength()); - assertEquals(false, packet.isTruncated()); - assertEquals(true, packet.validate()); - // Verify Ethernet Packet - if (!packet.hasProtocol(PcapProtocol.ETHERNET_II)) { - fail("Packet doesn't have ethernet!"); - } - // Verify IPv4 Packet - if (!packet.hasProtocol(PcapProtocol.IPV4)) { - fail("Packet doesn't have IPv4!"); - } - // Verify TCP Packet - if (!packet.hasProtocol(PcapProtocol.TCP)) { - fail("Packet doesn't have TCP!"); - } - // Verify Unknown Packet - if (!packet.hasProtocol(PcapProtocol.UNKNOWN)) { - fail("Packet doesn't have payload!"); - } - - // Skip packet - file.skipNextPacket(); - assertEquals(60, file.getCurrentRank()); - - // Parse outside of file. - file.seekPacket(99999999); - assertEquals(file.getTotalNbPackets(), file.getCurrentRank()); - file.skipNextPacket(); // Should be a no-op - assertEquals(file.getTotalNbPackets(), file.getCurrentRank()); - packet = file.parseNextPacket(); - assertNull(packet); - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/AllTests.java deleted file mode 100644 index d53f197bf6..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/AllTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.tests.packet; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Generic Packet test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - PacketTest.class, - BadPacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java deleted file mode 100644 index 484e46a9c5..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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.tests.packet; - -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -/** - * JUnit Class that tests if BadPacketExceptions are thrown correctly. - * - * @author Vincent Perot - */ -public class BadPacketTest { - - private ByteBuffer fEthernetPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fEthernetPacket = ByteBuffer.allocate(8); - fEthernetPacket.order(ByteOrder.BIG_ENDIAN); - - // This packet is erroneous. It contains 8 bytes while the minimum is 14 - // bytes for an Ethernet II packet. - - // Destination MAC - 6 bytes - fEthernetPacket.put((byte) 0x34); - fEthernetPacket.put((byte) 0x67); - fEthernetPacket.put((byte) 0x0C); - fEthernetPacket.put((byte) 0xD2); - fEthernetPacket.put((byte) 0x91); - fEthernetPacket.put((byte) 0x51); - - // Source MAC - 2 bytes - fEthernetPacket.put((byte) 0x10); - fEthernetPacket.put((byte) 0xF8); - - fEthernetPacket.flip(); - - } - - /** - * Test that verify if a BadPacketException is correctly thrown (when a - * packet is erroneous). - * - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Expected from the test. - */ - @Test(expected = BadPacketException.class) - public void PacketExceptionTest() throws BadPacketException, IOException, BadPcapFileException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer packet = fEthernetPacket; - if (packet != null) { - new EthernetIIPacket(dummy, null, packet); - } - fail("PacketExceptionTest has failed!"); - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java deleted file mode 100644 index d87f44117e..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * 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.tests.packet; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -/** - * JUnit Class that tests the generic Packet class and its method. - * - * @author Vincent Perot - */ -public class PacketTest { - - private ByteBuffer fEthernetPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fEthernetPacket = ByteBuffer.allocate(15); - fEthernetPacket.order(ByteOrder.BIG_ENDIAN); - - // Destination MAC - 6 bytes - fEthernetPacket.put((byte) 0x34); - fEthernetPacket.put((byte) 0x67); - fEthernetPacket.put((byte) 0x0C); - fEthernetPacket.put((byte) 0xD2); - fEthernetPacket.put((byte) 0x91); - fEthernetPacket.put((byte) 0x51); - - // Source MAC - 6 bytes - fEthernetPacket.put((byte) 0x10); - fEthernetPacket.put((byte) 0xF8); - fEthernetPacket.put((byte) 0x82); - fEthernetPacket.put((byte) 0xB3); - fEthernetPacket.put((byte) 0x44); - fEthernetPacket.put((byte) 0x78); - - // Ethertype - 2 bytes - fEthernetPacket.put((byte) 0xA2); - fEthernetPacket.put((byte) 0x56); - - // Payload - 1 byte - fEthernetPacket.put((byte) 0xA6); - - fEthernetPacket.flip(); - - } - - /** - * Test that verify the correctness of the Packet's methods. - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void GenericPacketTest() throws BadPacketException, IOException, BadPcapFileException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer byteBuffer = fEthernetPacket; - if (byteBuffer == null) { - fail("GenericPacketTest has failed!"); - return; - } - - Packet packet = new EthernetIIPacket(dummy, null, byteBuffer); - assertTrue(packet.hasProtocol(PcapProtocol.ETHERNET_II)); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.TCP)); - assertEquals(PcapProtocol.ETHERNET_II, packet.getProtocol()); - - assertEquals(packet, packet.getPacket(PcapProtocol.ETHERNET_II)); - assertNull(packet.getPacket(PcapProtocol.TCP)); - assertEquals(packet.getChildPacket(), packet.getPacket(PcapProtocol.UNKNOWN)); - assertEquals(packet.getPacket(PcapProtocol.ETHERNET_II), packet.getMostEcapsulatedPacket()); - - assertNull(packet.getParentPacket()); - assertFalse(packet.getPcapFile().equals(null)); - - Packet child = packet.getChildPacket(); - if (child == null) { - fail("GenericPacketTest has failed!"); - return; - } - assertEquals(packet.getPayload(), child.getPayload()); - assertEquals(packet.getGlobalSummaryString(), "Source MAC: 10:f8:82:b3:44:78 , Destination MAC: 34:67:0c:d2:91:51"); - - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/AllTests.java deleted file mode 100644 index 57a545771c..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Protocol test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - ProtocolTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java deleted file mode 100644 index bedc50f0e0..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.junit.Test; - -/** - * JUnit Class that tests whether protocol operation are happening without - * error. - * - * @author Vincent Perot - */ -public class ProtocolTest { - - /** - * Test that verify if the protocol attributes are as expected. - */ - @Test - public void TestProtocolAttributes() { - assertEquals(PcapProtocol.PCAP.getName(), "Packet Capture"); - assertEquals(PcapProtocol.PCAP.getShortName(), "pcap"); - assertEquals(PcapProtocol.PCAP.getLayer(), PcapProtocol.Layer.LAYER_0); - } - - /** - * Test that verify if the protocol getter methods are working properly. - */ - @Test - public void TestgetProtocols() { - List manualListLayer = new ArrayList<>(); - for (PcapProtocol.Layer layer : PcapProtocol.Layer.values()) { - assertNotNull(layer); - Collection listLayer = PcapProtocol.getProtocolsOnLayer(layer); - - manualListLayer.clear(); - switch (layer) { - case LAYER_0: - manualListLayer.add(PcapProtocol.PCAP); - break; - case LAYER_1: - break; - case LAYER_2: - manualListLayer.add(PcapProtocol.ETHERNET_II); - break; - case LAYER_3: - manualListLayer.add(PcapProtocol.IPV4); - break; - case LAYER_4: - manualListLayer.add(PcapProtocol.TCP); - manualListLayer.add(PcapProtocol.UDP); - break; - case LAYER_5: - break; - case LAYER_6: - break; - case LAYER_7: - manualListLayer.add(PcapProtocol.UNKNOWN); - break; - default: - fail("Illegal layer value!"); - } - assertEquals(manualListLayer, listLayer); - } - } - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/AllTests.java deleted file mode 100644 index b640d9c206..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.ethernet2; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Ethernet II test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - EthernetIIPacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java deleted file mode 100644 index 5337c1b375..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.ethernet2; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.Map; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIValues; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * JUnit Class that tests the EthernetIIPacket class and its method. - * - * @author Vincent Perot - */ -public class EthernetIIPacketTest { - - private static final Map EXPECTED_FIELDS = ImmutableMap.of( - "Source MAC Address", "10:f8:82:b3:44:78", - "Destination MAC Address", "34:67:0c:d2:91:51", - "Ethertype", "Unknown (0xa256)" - ); - - private static final String EXPECTED_TOSTRING = - "Ethernet II, Source: 10:f8:82:b3:44:78, Destination: 34:67:0c:d2:91:51, Type: Unknown (0xa256)\nPayload: a6"; - - private ByteBuffer fPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fPacket = ByteBuffer.allocate(15); - fPacket.order(ByteOrder.BIG_ENDIAN); - - // Destination MAC - 6 bytes - fPacket.put((byte) 0x34); - fPacket.put((byte) 0x67); - fPacket.put((byte) 0x0C); - fPacket.put((byte) 0xD2); - fPacket.put((byte) 0x91); - fPacket.put((byte) 0x51); - - // Source MAC - 6 bytes - fPacket.put((byte) 0x10); - fPacket.put((byte) 0xF8); - fPacket.put((byte) 0x82); - fPacket.put((byte) 0xB3); - fPacket.put((byte) 0x44); - fPacket.put((byte) 0x78); - - // Ethertype - 2 bytes - fPacket.put((byte) 0xA2); - fPacket.put((byte) 0x56); - - // Payload - 1 byte - fPacket.put((byte) 0xA6); - - fPacket.flip(); - } - - /** - * Test that verify the correctness of the EthernetIIPacket's methods. - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void CompleteEthernetIIPacketTest() throws IOException, BadPcapFileException, BadPacketException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer byteBuffer = fPacket; - if (byteBuffer == null) { - fail("CompleteEthernetIIPacketTest has failed!"); - return; - } - EthernetIIPacket packet = new EthernetIIPacket(dummy, null, byteBuffer); - - // Protocol Testing - assertEquals(PcapProtocol.ETHERNET_II, packet.getProtocol()); - assertTrue(packet.hasProtocol(PcapProtocol.ETHERNET_II)); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.TCP)); - - // Abstract methods Testing - assertTrue(packet.validate()); - assertEquals(-653947816, packet.hashCode()); - assertFalse(packet.equals(null)); - assertEquals(new EthernetIIPacket(dummy, null, byteBuffer), packet); - - assertEquals(EXPECTED_FIELDS, packet.getFields()); - assertEquals(EXPECTED_TOSTRING, packet.toString()); - assertEquals("Src: 10:f8:82:b3:44:78 , Dst: 34:67:0c:d2:91:51", packet.getLocalSummaryString()); - assertEquals("Source MAC: 10:f8:82:b3:44:78 , Destination MAC: 34:67:0c:d2:91:51", packet.getGlobalSummaryString()); - - assertEquals(new EthernetIIEndpoint(packet, true), packet.getSourceEndpoint()); - assertEquals(new EthernetIIEndpoint(packet, false), packet.getDestinationEndpoint()); - - fPacket.position(14); - byte[] payload = new byte[1]; - fPacket.get(payload); - assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); - - // Packet-specific methods Testing - assertTrue(Arrays.equals(packet.getSourceMacAddress(), Arrays.copyOfRange(fPacket.array(), EthernetIIValues.MAC_ADDRESS_SIZE, EthernetIIValues.MAC_ADDRESS_SIZE + EthernetIIValues.MAC_ADDRESS_SIZE))); - assertTrue(Arrays.equals(packet.getDestinationMacAddress(), Arrays.copyOfRange(fPacket.array(), 0, 0 + EthernetIIValues.MAC_ADDRESS_SIZE))); - assertEquals(0xA256, packet.getEthertype()); - - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/AllTests.java deleted file mode 100644 index e431897506..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.ipv4; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * IPv4 test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - IPv4PacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java deleted file mode 100644 index 4e72c020c0..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.ipv4; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.net.InetAddress; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Endpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Packet; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -/** - * JUnit Class that tests the IPv4Packet class and its method. - * - * @author Vincent Perot - */ -public class IPv4PacketTest { - - private static final Map EXPECTED_FIELDS; - static { - EXPECTED_FIELDS = new LinkedHashMap<>(); - EXPECTED_FIELDS.put("Version", "4"); - EXPECTED_FIELDS.put("Header Length", "24 bytes"); - EXPECTED_FIELDS.put("Differentiated Services Field", "0x26"); - EXPECTED_FIELDS.put("Explicit Congestion Notification", "0x02"); - EXPECTED_FIELDS.put("Total Length", "255 bytes"); - EXPECTED_FIELDS.put("Identification", "0x0ff0"); - EXPECTED_FIELDS.put("Don't Fragment Flag", "false"); - EXPECTED_FIELDS.put("More Fragment Flag", "false"); - EXPECTED_FIELDS.put("Fragment Offset", "7905"); - EXPECTED_FIELDS.put("Time to live", "160"); - EXPECTED_FIELDS.put("Protocol", "Unknown (254)"); - EXPECTED_FIELDS.put("Checksum", "0x3344"); - EXPECTED_FIELDS.put("Source IP Address", "192.168.1.0"); - EXPECTED_FIELDS.put("Destination IP Address", "193.169.2.1"); - EXPECTED_FIELDS.put("Options", "a2 56 a2 56"); - } - - private static final String EXPECTED_TOSTRING; - static { - StringBuilder sb = new StringBuilder(); - sb.append("Internet Protocol Version 4, Source: 192.168.1.0, Destination: 193.169.2.1\n"); - sb.append("Version: 4, Identification: 0x0ff0, Header Length: 24 bytes, Total Length: 255 bytes\n"); - sb.append("Differentiated Services Code Point: 0x26; Explicit Congestion Notification: 0x02\n"); - sb.append("Flags: 0x00 (Don't have more fragments), Fragment Offset: 7905\n"); - sb.append("Time to live: 160\n"); - sb.append("Protocol: 254\n"); - sb.append("Header Checksum: 0x3344\n"); - sb.append("Payload: a6"); - - EXPECTED_TOSTRING = sb.toString(); - } - - private ByteBuffer fPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fPacket = ByteBuffer.allocate(25); - fPacket.order(ByteOrder.BIG_ENDIAN); - - // Version + IHL - fPacket.put((byte) 0x46); - - // DSCP + ECN - fPacket.put((byte) 0x9A); - - // Total length - this is randomly chosen so that we verify that the - // packet handles wrong total length. - fPacket.put((byte) 0x00); - fPacket.put((byte) 0xFF); - - // Identification - fPacket.put((byte) 0x0F); - fPacket.put((byte) 0xF0); - - // Flags + Fragment Offset - fPacket.put((byte) 0x1E); - fPacket.put((byte) 0xE1); - - // Time to live - fPacket.put((byte) 0xA0); - - // Protocol - Unknown - fPacket.put((byte) 0xFE); - - // Header checksum - chosen randomly - fPacket.put((byte) 0x33); - fPacket.put((byte) 0x44); - - // Source IP - 4 bytes - fPacket.put((byte) 192); - fPacket.put((byte) 168); - fPacket.put((byte) 1); - fPacket.put((byte) 0); - - // Destination IP - 4 bytes - fPacket.put((byte) 193); - fPacket.put((byte) 169); - fPacket.put((byte) 2); - fPacket.put((byte) 1); - - // Options - 4 bytes - fPacket.put((byte) 0xA2); - fPacket.put((byte) 0x56); - fPacket.put((byte) 0xA2); - fPacket.put((byte) 0x56); - - // Payload - 1 byte - fPacket.put((byte) 0xA6); - - fPacket.flip(); - } - - /** - * Test that verify the correctness of the IPv4Packet's methods. - * - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void CompleteIPv4PacketTest() throws IOException, BadPcapFileException, BadPacketException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer byteBuffer = fPacket; - if (byteBuffer == null) { - fail("CompleteIPv4PacketTest has failed!"); - return; - } - IPv4Packet packet = new IPv4Packet(dummy, null, byteBuffer); - - // Protocol Testing - assertEquals(PcapProtocol.IPV4, packet.getProtocol()); - assertTrue(packet.hasProtocol(PcapProtocol.IPV4)); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.TCP)); - - // Abstract methods Testing - assertTrue(packet.validate()); - assertEquals(-222021887, packet.hashCode()); - assertFalse(packet.equals(null)); - assertEquals(new IPv4Packet(dummy, null, byteBuffer), packet); - - assertEquals(EXPECTED_FIELDS, packet.getFields()); - assertEquals(EXPECTED_TOSTRING, packet.toString()); - assertEquals("Src: 192.168.1.0 , Dst: 193.169.2.1", packet.getLocalSummaryString()); - assertEquals("192.168.1.0 > 193.169.2.1 Id=4080 Len=1", packet.getGlobalSummaryString()); - - assertEquals(new IPv4Endpoint(packet, true), packet.getSourceEndpoint()); - assertEquals(new IPv4Endpoint(packet, false), packet.getDestinationEndpoint()); - - fPacket.position(24); - byte[] payload = new byte[1]; - fPacket.get(payload); - assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); - - // Packet-specific methods Testing - assertEquals(InetAddress.getByAddress(Arrays.copyOfRange(fPacket.array(), 12, 16)), packet.getSourceIpAddress()); - assertEquals(InetAddress.getByAddress(Arrays.copyOfRange(fPacket.array(), 16, 20)), packet.getDestinationIpAddress()); - assertTrue(Arrays.equals(packet.getOptions(), Arrays.copyOfRange(fPacket.array(), 20, 24))); - assertEquals(4, packet.getVersion()); - assertEquals(24, packet.getHeaderLength()); - assertEquals(0x26, packet.getDSCP()); - assertEquals(0x02, packet.getExplicitCongestionNotification()); - assertEquals(255, packet.getTotalLength()); - assertEquals(0x0FF0, packet.getIdentification()); - assertFalse(packet.getReservedFlag()); - assertFalse(packet.getDontFragmentFlag()); - assertFalse(packet.getHasMoreFragment()); - assertEquals(7905, packet.getFragmentOffset()); - assertEquals(160, packet.getTimeToLive()); - assertEquals(0xFE, packet.getIpDatagramProtocol()); - assertEquals(0x3344, packet.getHeaderChecksum()); - - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/AllTests.java deleted file mode 100644 index c5d70f7bea..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.pcap; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Pcap test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - PcapPacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java deleted file mode 100644 index bf066354c1..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.pcap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Map; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * JUnit Class that tests the PcapPacket class and its method. - * - * @author Vincent Perot - */ -public class PcapPacketTest { - - private static final Map EXPECTED_FIELDS = ImmutableMap.of( - "Frame", "36", - "Frame Length", "75 bytes", - "Capture Length", "75 bytes", - "Capture Time", "2005-07-04 05:33:52.829.277.000" - ); - - private static final String EXPECTED_TOSTRING; - static { - StringBuilder sb = new StringBuilder(); - sb.append("Packet Capture 36: 75 bytes on wire, 75 bytes captured.\n"); - sb.append("Arrival time: 2005-07-04 05:33:52.829.277.000\n"); - sb.append("Ethernet II, Source: 00:e0:ed:01:6e:bd, Destination: 00:30:54:00:34:56, Type: Internet Protocol Version 4 (0x0800)\n"); - sb.append("Internet Protocol Version 4, Source: 192.168.1.2, Destination: 192.168.1.1\n"); - sb.append("Version: 4, Identification: 0x69aa, Header Length: 20 bytes, Total Length: 61 bytes\n"); - sb.append("Differentiated Services Code Point: 0x00; Explicit Congestion Notification: 0x00\n"); - sb.append("Flags: 0x00 (Don't have more fragments), Fragment Offset: 0\n"); - sb.append("Time to live: 128\n"); - sb.append("Protocol: 17\n"); - sb.append("Header Checksum: 0x4db2\n"); - sb.append("User Datagram Protocol, Source Port: 2719, Destination Port: 53, Length: 41, Checksum: 19038\n"); - sb.append("Payload: ed d4 01 00 00 01 00 00 00 00 00 00 03 66 74 70 07 65 63 69 74 65 6c 65 03 63 6f 6d 00 00 01 00 01"); - - EXPECTED_TOSTRING = sb.toString(); - } - - private ByteBuffer fPayload; - - /** - * Initialize the payload. - */ - @Before - public void initialize() { - fPayload = ByteBuffer.allocate(75); - fPayload.order(ByteOrder.BIG_ENDIAN); - - // Values copied from wireshark - - // Bytes 0x01-0x10 - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x30); - fPayload.put((byte) 0x54); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x34); - fPayload.put((byte) 0x56); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0xE0); - fPayload.put((byte) 0xED); - fPayload.put((byte) 0x01); - fPayload.put((byte) 0x6E); - fPayload.put((byte) 0xBD); - fPayload.put((byte) 0x08); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x45); - fPayload.put((byte) 0x00); - - // Bytes 0x11-0x20 - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x3D); - fPayload.put((byte) 0x69); - fPayload.put((byte) 0xAA); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x80); - fPayload.put((byte) 0x11); - fPayload.put((byte) 0x4D); - fPayload.put((byte) 0xB2); - fPayload.put((byte) 0xC0); - fPayload.put((byte) 0xA8); - fPayload.put((byte) 0x01); - fPayload.put((byte) 0x02); - fPayload.put((byte) 0xC0); - fPayload.put((byte) 0xA8); - - // Bytes 0x21-0x30 - fPayload.put((byte) 0x01); - fPayload.put((byte) 0x01); - fPayload.put((byte) 0x0A); - fPayload.put((byte) 0x9F); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x35); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x29); - fPayload.put((byte) 0x4A); - fPayload.put((byte) 0x5E); - fPayload.put((byte) 0xED); - fPayload.put((byte) 0xd4); - fPayload.put((byte) 0x01); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x01); - - // Bytes 0x31-0x40 - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x03); - fPayload.put((byte) 0x66); - fPayload.put((byte) 0x74); - fPayload.put((byte) 0x70); - fPayload.put((byte) 0x07); - fPayload.put((byte) 0x65); - fPayload.put((byte) 0x63); - fPayload.put((byte) 0x69); - fPayload.put((byte) 0x74); - fPayload.put((byte) 0x65); - - // Bytes 0x41-0x4B - fPayload.put((byte) 0x6C); - fPayload.put((byte) 0x65); - fPayload.put((byte) 0x03); - fPayload.put((byte) 0x63); - fPayload.put((byte) 0x6F); - fPayload.put((byte) 0x6D); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x01); - fPayload.put((byte) 0x00); - fPayload.put((byte) 0x01); - - fPayload.flip(); - } - - /** - * Test that verify the correctness of the PcapPacket's methods. - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void CompletePcapPacketTest() throws IOException, BadPcapFileException, BadPacketException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; - assumeTrue(trace.exists()); - try (PcapFile file = new PcapFile(trace.getPath());) { - - file.seekPacket(36); - PcapPacket packet = file.parseNextPacket(); - if (packet == null) { - fail("CompletePcapPacketTest has failed!"); - return; - } - // Protocol Testing - assertEquals(PcapProtocol.PCAP, packet.getProtocol()); - assertTrue(packet.hasProtocol(PcapProtocol.PCAP)); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.TCP)); - - // Abstract methods Testing - assertTrue(packet.validate()); - assertEquals(86567859, packet.hashCode()); - assertFalse(packet.equals(null)); - assertFalse(packet.equals(file.parseNextPacket())); - - assertEquals(EXPECTED_FIELDS, packet.getFields()); - assertEquals(EXPECTED_TOSTRING, packet.toString()); - assertEquals("Frame 36: 75 bytes on wire, 75 bytes captured", packet.getLocalSummaryString()); - assertEquals("Source Port: 2719, Destination Port: 53", packet.getGlobalSummaryString()); - - assertEquals(new PcapEndpoint(packet, true), packet.getSourceEndpoint()); - assertEquals(new PcapEndpoint(packet, false), packet.getDestinationEndpoint()); - - ByteBuffer payload = packet.getPayload(); - if (payload == null) { - fail("CompletePcapPacketTest has failed!"); - return; - } - assertEquals(fPayload, payload.flip()); - - // Packet-specific methods Testing - assertEquals(36, packet.getIndex()); - assertEquals(75, packet.getOriginalLength()); - assertEquals(75, packet.getIncludedLength()); - assertEquals(1120469632829277L, packet.getTimestamp()); - assertFalse(packet.isTruncated()); - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/AllTests.java deleted file mode 100644 index 201e83dc4d..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.tcp; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * TCP test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - TCPPacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/TCPPacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/TCPPacketTest.java deleted file mode 100644 index 2a197dd09b..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/TCPPacketTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.tcp; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.tcp.TCPEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.tcp.TCPPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -/** - * JUnit Class that tests the TCPPacket class and its method. - * - * @author Vincent Perot - */ -public class TCPPacketTest { - - private static final Map EXPECTED_FIELDS; - static { - EXPECTED_FIELDS = new LinkedHashMap<>(); - EXPECTED_FIELDS.put("Source Port", "18057"); - EXPECTED_FIELDS.put("Destination Port", "39611"); - EXPECTED_FIELDS.put("Sequence Number", "2575857510"); - EXPECTED_FIELDS.put("Acknowledgement Number", "1430532898"); - EXPECTED_FIELDS.put("Length", "24 bytes"); - EXPECTED_FIELDS.put("ECN-Nonce Flag", "true"); - EXPECTED_FIELDS.put("Congestion Window Reduced Flag", "false"); - EXPECTED_FIELDS.put("ECN-Echo Flag", "true"); - EXPECTED_FIELDS.put("Urgent Flag", "false"); - EXPECTED_FIELDS.put("ACK Flag", "true"); - EXPECTED_FIELDS.put("PSH Flag", "false"); - EXPECTED_FIELDS.put("RST Flag", "true"); - EXPECTED_FIELDS.put("SYN Flag", "false"); - EXPECTED_FIELDS.put("FIN Flag", "true"); - EXPECTED_FIELDS.put("Window Size Value", "4352"); - EXPECTED_FIELDS.put("Checksum", "0xffee"); - EXPECTED_FIELDS.put("Urgent Pointer", "0xddcc"); - EXPECTED_FIELDS.put("Options", "ad da bc cb"); - } - - private static final String EXPECTED_TOSTRING; - static { - StringBuilder sb = new StringBuilder(); - sb.append("Transmission Control Protocol, Source Port: 18057, Destination Port: 39611\n"); - sb.append("Sequence Number: 2575857510, Acknowledgment Number: 1430532898\n"); - sb.append("Header length: 24 bytes, Data length: 4\n"); - sb.append("Window size value: 4352, Urgent Pointer: 0xddcc\n"); - sb.append("Checksum: 0xffee\n"); - sb.append("Payload: 99 88 77 66"); - - EXPECTED_TOSTRING = sb.toString(); - } - - private ByteBuffer fPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fPacket = ByteBuffer.allocate(28); - fPacket.order(ByteOrder.BIG_ENDIAN); - - // Source Port - fPacket.put((byte) 0x46); - fPacket.put((byte) 0x89); - - // Destination Port - fPacket.put((byte) 0x9A); - fPacket.put((byte) 0xBB); - - // Sequence Number - fPacket.put((byte) 0x99); - fPacket.put((byte) 0x88); - fPacket.put((byte) 0x77); - fPacket.put((byte) 0x66); - - // Acknowledgment Number - fPacket.put((byte) 0x55); - fPacket.put((byte) 0x44); - fPacket.put((byte) 0x33); - fPacket.put((byte) 0x22); - - // Data Offset + Reserved + NS - fPacket.put((byte) 0x61); - - // Other flags - fPacket.put((byte) 0b01010101); - - // Window Size - fPacket.put((byte) 0x11); - fPacket.put((byte) 0x00); - - // Checksum - fPacket.put((byte) 0xFF); - fPacket.put((byte) 0xEE); - - // Urgent Pointer - fPacket.put((byte) 0xDD); - fPacket.put((byte) 0xCC); - - // Options - 4 bytes - fPacket.put((byte) 0xAD); - fPacket.put((byte) 0xDA); - fPacket.put((byte) 0xBC); - fPacket.put((byte) 0xCB); - - // Payload - 4 bytes - fPacket.put((byte) 0x99); - fPacket.put((byte) 0x88); - fPacket.put((byte) 0x77); - fPacket.put((byte) 0x66); - - fPacket.flip(); - } - - /** - * Test that verify the correctness of the TCPPacket's methods. - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void CompleteTCPPacketTest() throws BadPacketException, IOException, BadPcapFileException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer byteBuffer = fPacket; - if (byteBuffer == null) { - fail("CompleteTCPPacketTest has failed!"); - return; - } - TCPPacket packet = new TCPPacket(dummy, null, byteBuffer); - - // Protocol Testing - assertEquals(PcapProtocol.TCP, packet.getProtocol()); - assertTrue(packet.hasProtocol(PcapProtocol.TCP)); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.IPV4)); - - // Abstract methods Testing - assertTrue(packet.validate()); - assertEquals(-677046102, packet.hashCode()); - assertFalse(packet.equals(null)); - assertEquals(new TCPPacket(dummy, null, byteBuffer), packet); - - assertEquals(EXPECTED_FIELDS, packet.getFields()); - assertEquals(EXPECTED_TOSTRING, packet.toString()); - assertEquals("Src Port: 18057, Dst Port: 39611, Seq: 2575857510, Ack: 1430532898, Len: 24", packet.getLocalSummaryString()); - assertEquals("18057 > 39611 [ACK, FIN, RST, NS, ECE] Seq=2575857510 Ack=1430532898 Len=24", packet.getGlobalSummaryString()); - - assertEquals(new TCPEndpoint(packet, true), packet.getSourceEndpoint()); - assertEquals(new TCPEndpoint(packet, false), packet.getDestinationEndpoint()); - - fPacket.position(24); - byte[] payload = new byte[4]; - fPacket.get(payload); - assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); - - // Packet-specific methods Testing - assertEquals(0x4689, packet.getSourcePort()); - assertEquals(0x9ABB, packet.getDestinationPort()); - assertEquals(2575857510L, packet.getSequenceNumber()); - assertEquals(1430532898L, packet.getAcknowledgmentNumber()); - assertEquals(6, packet.getDataOffset()); - assertEquals(0, packet.getReservedField()); - assertEquals(true, packet.isNSFlagSet()); - assertEquals(false, packet.isCongestionWindowReducedFlagSet()); - assertEquals(true, packet.isECNEchoFlagSet()); - assertEquals(false, packet.isUrgentFlagSet()); - assertEquals(true, packet.isAcknowledgeFlagSet()); - assertEquals(false, packet.isPushFlagSet()); - assertEquals(true, packet.isResetFlagSet()); - assertEquals(false, packet.isSynchronizationFlagSet()); - assertEquals(true, packet.isFinalFlagSet()); - assertEquals(4352, packet.getWindowSize()); - assertEquals(65518, packet.getChecksum()); - assertEquals(56780, packet.getUrgentPointer()); - assertTrue(Arrays.equals(packet.getOptions(), Arrays.copyOfRange(fPacket.array(), 20, 24))); - - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/AllTests.java deleted file mode 100644 index 13c541e103..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.udp; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * UDP test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - UDPPacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/UDPPacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/UDPPacketTest.java deleted file mode 100644 index bb70c291a1..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/UDPPacketTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.udp; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Map; - -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.udp.UDPEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.udp.UDPPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * JUnit Class that tests the UDPPacket class and its method. - * - * @author Vincent Perot - */ -public class UDPPacketTest { - - private static final Map EXPECTED_FIELDS = ImmutableMap.of( - "Source Port", "18057", - "Destination Port", "39611", - "Length", "41452 bytes", - "Checksum", "0xfaaf" - ); - - private static final String EXPTECTED_TOSTRING; - static { - StringBuilder sb = new StringBuilder(); - sb.append("User Datagram Protocol, Source Port: 18057, Destination Port: 39611, Length: 41452, Checksum: 64175\n"); - sb.append("Payload: 99 88 77 66"); - - EXPTECTED_TOSTRING = sb.toString(); - } - - private ByteBuffer fPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fPacket = ByteBuffer.allocate(12); - fPacket.order(ByteOrder.BIG_ENDIAN); - - // Source Port - fPacket.put((byte) 0x46); - fPacket.put((byte) 0x89); - - // Destination Port - fPacket.put((byte) 0x9A); - fPacket.put((byte) 0xBB); - - // Total length - this is randomly chosen so that we verify that the - // packet handles wrong total length. - fPacket.put((byte) 0xA1); - fPacket.put((byte) 0xEC); - - // Checksum - fPacket.put((byte) 0xFA); - fPacket.put((byte) 0xAF); - - // Payload - 4 bytes - fPacket.put((byte) 0x99); - fPacket.put((byte) 0x88); - fPacket.put((byte) 0x77); - fPacket.put((byte) 0x66); - - fPacket.flip(); - } - - /** - * Test that verify the correctness of the UDPPacket's methods. - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - * @throws BadPacketException - * Thrown when a packet is erroneous. Fails the test. - */ - @Test - public void CompleteUDPPacketTest() throws IOException, BadPcapFileException, BadPacketException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer byteBuffer = fPacket; - if (byteBuffer == null) { - fail("CompleteUDPPacketTest has failed!"); - return; - } - UDPPacket packet = new UDPPacket(dummy, null, byteBuffer); - - // Protocol Testing - assertEquals(PcapProtocol.UDP, packet.getProtocol()); - assertTrue(packet.hasProtocol(PcapProtocol.UDP)); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.ETHERNET_II)); - - // Abstract methods Testing - assertTrue(packet.validate()); - assertEquals(473000225, packet.hashCode()); - assertFalse(packet.equals(null)); - assertEquals(new UDPPacket(dummy, null, byteBuffer), packet); - - assertEquals(EXPECTED_FIELDS, packet.getFields()); - assertEquals(EXPTECTED_TOSTRING, packet.toString()); - assertEquals("Src Port: 18057, Dst Port: 39611", packet.getLocalSummaryString()); - assertEquals("Source Port: 18057, Destination Port: 39611", packet.getGlobalSummaryString()); - - assertEquals(new UDPEndpoint(packet, true), packet.getSourceEndpoint()); - assertEquals(new UDPEndpoint(packet, false), packet.getDestinationEndpoint()); - - fPacket.position(8); - byte[] payload = new byte[4]; - fPacket.get(payload); - assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); - - // Packet-specific methods Testing - assertEquals(0x4689, packet.getSourcePort()); - assertEquals(0x9ABB, packet.getDestinationPort()); - assertEquals(0xA1EC, packet.getTotalLength()); - assertEquals(0xFAAF, packet.getChecksum()); - - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/AllTests.java deleted file mode 100644 index f33d53b7f4..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.unknown; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Unknown test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - UnknownPacketTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/UnknownPacketTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/UnknownPacketTest.java deleted file mode 100644 index 8f0d28d39a..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/UnknownPacketTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * 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.tests.protocol.unknown; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Map; - -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * JUnit Class that tests the UnknownPacket class and its method. - * - * @author Vincent Perot - */ -public class UnknownPacketTest { - - private static final Map EXPECTED_FIELDS = ImmutableMap.of( - "Binary", "61", - "Character", "a" - ); - - private static final String fToString = "Payload: 61"; - - private ByteBuffer fPacket; - - /** - * Initialize the packet. - */ - @Before - public void initialize() { - fPacket = ByteBuffer.allocate(1); - fPacket.order(ByteOrder.BIG_ENDIAN); - - // Payload - 1 byte - fPacket.put((byte) 97); - - fPacket.flip(); - } - - /** - * Test that verify the correctness of the UnknownPacket's methods. - * @throws BadPcapFileException - * Thrown when the file is erroneous. Fails the test. - * @throws IOException - * Thrown when an IO error occurs. Fails the test. - */ - @Test - public void CompleteUnknownPacketTest() throws IOException, BadPcapFileException { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - try (PcapFile dummy = new PcapFile(trace.getPath())) { - ByteBuffer byteBuffer = fPacket; - if (byteBuffer == null) { - fail("CompleteUnknownPacketTest has failed!"); - return; - } - UnknownPacket packet = new UnknownPacket(dummy, null, byteBuffer); - - // Protocol Testing - assertEquals(PcapProtocol.UNKNOWN, packet.getProtocol()); - assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); - assertFalse(packet.hasProtocol(PcapProtocol.UDP)); - - // Abstract methods Testing - assertTrue(packet.validate()); - assertEquals(1089, packet.hashCode()); - assertFalse(packet.equals(null)); - assertEquals(new UnknownPacket(dummy, null, byteBuffer), packet); - - assertEquals(EXPECTED_FIELDS, packet.getFields()); - assertEquals(fToString, packet.toString()); - assertEquals("Len: 1 bytes", packet.getLocalSummaryString()); - assertEquals("Data: 1 bytes", packet.getGlobalSummaryString()); - // TODO take care of plural form. - - // Unknown Endpoints are never equal! - assertFalse(packet.getSourceEndpoint().equals(new UnknownEndpoint(packet, true))); - assertFalse(packet.getDestinationEndpoint().equals(new UnknownEndpoint(packet, false))); - - fPacket.position(0); - byte[] payload = new byte[1]; - fPacket.get(payload); - ByteBuffer payloadBB = ByteBuffer.wrap(payload); - payloadBB.flip(); - - assertEquals(payloadBB, packet.getPayload()); - - // Packet-specific methods Testing - // None - - } - } -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/AllTests.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/AllTests.java deleted file mode 100644 index df90513f7b..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.tests.stream; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Stream test suite - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - StreamBuildTest.class -}) -public class AllTests { - -} diff --git a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java b/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java deleted file mode 100644 index 182c150fd5..0000000000 --- a/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * 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.tests.stream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.stream.PacketStream; -import org.eclipse.linuxtools.internal.pcap.core.stream.PacketStreamBuilder; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; -import org.junit.Test; - -/** - * JUnit Class that tests whether packet streams are built correctly. - * - * @author Vincent Perot - */ -public class StreamBuildTest { - - private static final double DELTA = 0.001; - - /** - * Test that verify that stream building is done correctly. - */ - @Test - public void StreamBuildingTest() { - PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; - assumeTrue(trace.exists()); - - try { - // Test Ethernet II stream - PacketStreamBuilder builder = new PacketStreamBuilder(PcapProtocol.ETHERNET_II); - builder.parsePcapFile(trace.getPath()); - assertEquals(PcapProtocol.ETHERNET_II, builder.getProtocol()); - // Should do one loop only, so hardcoded values are okay. - for (PacketStream stream : builder.getStreams()) { - assertEquals("Stream eth.0, Number of Packets: 43\n", stream.toString()); - assertEquals(43, stream.getNbPackets()); - assertEquals(25091, stream.getNbBytes()); - assertEquals(20, stream.getNbPacketsAtoB()); - assertEquals(2323, stream.getNbBytesAtoB()); - assertEquals(23, stream.getNbPacketsBtoA()); - assertEquals(22768, stream.getNbBytesBtoA()); - assertEquals(1084443427311224000L, stream.getStartTime()); - assertEquals(1084443457704928000L, stream.getStopTime()); - assertEquals(30.393704, stream.getDuration(), DELTA); - assertEquals(76.43030280218561, stream.getBPSAtoB(), DELTA); - assertEquals(749.1025114938278, stream.getBPSBtoA(), DELTA); - } - - // Test TCP streams and other constructor - builder = new PacketStreamBuilder(PcapProtocol.TCP); - builder.parsePcapFile(trace.getPath()); - assertEquals(PcapProtocol.TCP, builder.getProtocol()); - - PacketStream stream = builder.getStream(0); - if (stream == null) { - fail("StreamBuildingTest has failed!"); - return; - } - assertEquals(PcapProtocol.TCP, stream.getProtocol()); - assertEquals(0, stream.getID()); - assertEquals("tcp.0", stream.getUniqueID()); - assertEquals(34, stream.getNbPackets()); - assertEquals(20695, stream.getNbBytes()); - assertEquals(16, stream.getNbPacketsAtoB()); - assertEquals(1351, stream.getNbBytesAtoB()); - assertEquals(18, stream.getNbPacketsBtoA()); - assertEquals(19344, stream.getNbBytesBtoA()); - assertEquals(1084443427311224000L, stream.getStartTime()); - assertEquals(1084443457704928000L, stream.getStopTime()); - assertEquals(30.393704, stream.getDuration(), DELTA); - assertEquals(44.449995301658525, stream.getBPSAtoB(), DELTA); - assertEquals(636.4476011216008, stream.getBPSBtoA(), DELTA); - - stream = builder.getStream(1); - if (stream == null) { - fail("StreamBuildingTest has failed!"); - return; - } - assertEquals(PcapProtocol.TCP, stream.getProtocol()); - assertEquals(1, stream.getID()); - assertEquals("tcp.1", stream.getUniqueID()); - assertEquals(7, stream.getNbPackets()); - assertEquals(4119, stream.getNbBytes()); - assertEquals(3, stream.getNbPacketsAtoB()); - assertEquals(883, stream.getNbBytesAtoB()); - assertEquals(4, stream.getNbPacketsBtoA()); - assertEquals(3236, stream.getNbBytesBtoA()); - assertEquals(1084443430295515000L, stream.getStartTime()); - assertEquals(1084443432088092000L, stream.getStopTime()); - assertEquals(1.792577, stream.getDuration(), DELTA); - assertEquals(492.58692932019096, stream.getBPSAtoB(), DELTA); - assertEquals(1805.2223140205413, stream.getBPSBtoA(), DELTA); - - builder.clear(); - assertEquals(0, builder.getNbStreams()); - } catch (IOException | BadPcapFileException e) { - fail("StreamBuildingTest has failed!"); - } - - } -} diff --git a/org.eclipse.linuxtools.pcap.core/.classpath b/org.eclipse.linuxtools.pcap.core/.classpath deleted file mode 100644 index 098194ca4b..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.linuxtools.pcap.core/.project b/org.eclipse.linuxtools.pcap.core/.project deleted file mode 100644 index 965bfb79ae..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - 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 deleted file mode 100644 index 99f26c0203..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 5a0ad22d2a..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.core.runtime.prefs +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 9f3662cd78..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,394 +0,0 @@ -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.methodParameters=do not generate -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=ignore -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 deleted file mode 100644 index 4fd0c7006a..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,56 +0,0 @@ -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 deleted file mode 100644 index acc3abd47c..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.api.tools.prefs +++ /dev/null @@ -1,97 +0,0 @@ -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 deleted file mode 100644 index d92b94fd4b..0000000000 --- a/org.eclipse.linuxtools.pcap.core/.settings/org.eclipse.pde.prefs +++ /dev/null @@ -1,32 +0,0 @@ -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=1 -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 deleted file mode 100644 index 93664d2fde..0000000000 --- a/org.eclipse.linuxtools.pcap.core/META-INF/MANIFEST.MF +++ /dev/null @@ -1,28 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %Bundle-Name -Bundle-Vendor: %Bundle-Vendor -Bundle-Version: 1.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.internal.pcap.core.endpoint;x-friends:="org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.filter;x-internal:=true, - org.eclipse.linuxtools.internal.pcap.core.packet;x-friends:="org.eclipse.linuxtools.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.protocol;x-friends:="org.eclipse.linuxtools.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2;x-friends:="org.eclipse.linuxtools.pcap.core.tests", - org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4;x-friends:="org.eclipse.linuxtools.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.protocol.pcap;x-friends:="org.eclipse.linuxtools.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.protocol.tcp;x-friends:="org.eclipse.linuxtools.pcap.core.tests", - org.eclipse.linuxtools.internal.pcap.core.protocol.udp;x-friends:="org.eclipse.linuxtools.pcap.core.tests", - org.eclipse.linuxtools.internal.pcap.core.protocol.unknown;x-friends:="org.eclipse.linuxtools.pcap.core.tests", - org.eclipse.linuxtools.internal.pcap.core.stream;x-friends:="org.eclipse.linuxtools.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.trace;x-friends:="org.eclipse.linuxtools.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", - org.eclipse.linuxtools.internal.pcap.core.util;x-friends:="org.eclipse.linuxtools.tmf.pcap.core" -Import-Package: com.google.common.collect, - com.google.common.math diff --git a/org.eclipse.linuxtools.pcap.core/about.html b/org.eclipse.linuxtools.pcap.core/about.html deleted file mode 100644 index 28737f60b7..0000000000 --- a/org.eclipse.linuxtools.pcap.core/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -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 deleted file mode 100644 index 857bf1e800..0000000000 --- a/org.eclipse.linuxtools.pcap.core/build.properties +++ /dev/null @@ -1,21 +0,0 @@ -############################################################################### -# 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 deleted file mode 100644 index 0a4f9c25f1..0000000000 --- a/org.eclipse.linuxtools.pcap.core/plugin.properties +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################### -# 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 deleted file mode 100644 index ba35735a0a..0000000000 --- a/org.eclipse.linuxtools.pcap.core/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - 4.0.0 - - - org.eclipse.tracecompass - org.eclipse.tracecompass - 3.2.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 deleted file mode 100644 index 885adc1726..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * 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/endpoint/ProtocolEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpoint.java deleted file mode 100644 index 79fdf72ddf..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpoint.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.endpoint; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.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) { - 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/internal/pcap/core/endpoint/ProtocolEndpointPair.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpointPair.java deleted file mode 100644 index 15dd90cd2f..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpointPair.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * 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.endpoint; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.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/internal/pcap/core/endpoint/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/package-info.java deleted file mode 100644 index c68f342be7..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.endpoint; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/IPacketFilter.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/IPacketFilter.java deleted file mode 100644 index 457fa7fc91..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/IPacketFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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.filter; - -import org.eclipse.linuxtools.internal.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/internal/pcap/core/filter/PacketFilterByProtocol.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/PacketFilterByProtocol.java deleted file mode 100644 index fb2eb394dc..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/PacketFilterByProtocol.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.filter; - -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; - -/** - * 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 PcapProtocol fProtocol; - - /** - * Constructor of the PacketFilterByProtocol class. - * - * @param protocol - * The protocol that the incoming packets must contain. - */ - public PacketFilterByProtocol(PcapProtocol 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 PcapProtocol getProtocol() { - return fProtocol; - } - -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/package-info.java deleted file mode 100644 index d5e6b615bf..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.filter; \ No newline at end of file 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 deleted file mode 100644 index 495502c7f8..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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/internal/pcap/core/packet/BadPacketException.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/BadPacketException.java deleted file mode 100644 index 9db396ae67..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/BadPacketException.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/packet/Packet.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/Packet.java deleted file mode 100644 index e499ae7bd9..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/Packet.java +++ /dev/null @@ -1,297 +0,0 @@ -/******************************************************************************* - * 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.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.internal.pcap.core.endpoint.ProtocolEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.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 PcapProtocol 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, PcapProtocol 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 PcapProtocol 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(PcapProtocol 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(PcapProtocol 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() != PcapProtocol.UNKNOWN) { - Packet childPacket = packet.getChildPacket(); - if (childPacket == null || childPacket.getProtocol() == PcapProtocol.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/internal/pcap/core/packet/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/package-info.java deleted file mode 100644 index 9edaef996b..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.packet; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/PcapProtocol.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/PcapProtocol.java deleted file mode 100644 index d810dbf12c..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/PcapProtocol.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * 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.protocol; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Enumeration used for describing the different known protocols. - * - * @author Vincent Perot - */ -public enum PcapProtocol { - - // Layer 0 - /** - * The Pcap Protocol is not a real protocol but is used as an helper to - * generate Pcap packets. - */ - PCAP("Packet Capture", "pcap", Layer.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", Layer.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", Layer.LAYER_3, true), //$NON-NLS-1$ //$NON-NLS-2$ - - // Layer 4 - /** - * The description of the Transmission Control Protocol. - */ - TCP("Transmission Control Protocol", "tcp", Layer.LAYER_4, true), //$NON-NLS-1$ //$NON-NLS-2$ - /** - * The description of the User Datagram Protocol. - */ - UDP("User Datagram Protocol", "udp", Layer.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", "???", Layer.LAYER_7, false); //$NON-NLS-1$ //$NON-NLS-2$ - - - /** - * Enum that lists constants related to protocols/layers. - * - * See http://en.wikipedia.org/wiki/OSI_model#Description_of_OSI_layers. - * - * @author Vincent Perot - */ - public static enum Layer { - - /** - * Layer 0. This layer is not an OSI layer but is used as an helper to store - * the pseudo-protocol PCAP. - */ - LAYER_0, - - /** Layer 1 of the OSI model */ - LAYER_1, - - /** Layer 2 of the OSI model */ - LAYER_2, - - /** Layer 3 of the OSI model */ - LAYER_3, - - /** Layer 4 of the OSI model */ - LAYER_4, - - /** Layer 5 of the OSI model */ - LAYER_5, - - /** Layer 6 of the OSI model */ - LAYER_6, - - /** Layer 7 of the OSI model */ - LAYER_7; - } - - - // Fields - private final String fName; - private final String fShortName; - private final Layer fLayer; - private final boolean fSupportsStream; - - private PcapProtocol(String name, String shortName, Layer 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 Layer 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 Collection getProtocolsOnLayer(Layer layer) { - List protocolsOnLayer = new ArrayList<>(); - for (PcapProtocol p : PcapProtocol.values()) { - if (p.getLayer() == layer) { - protocolsOnLayer.add(p); - } - } - return protocolsOnLayer; - } -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java deleted file mode 100644 index 912343c890..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * 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.protocol.ethernet2; - -import java.util.Arrays; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint; -import org.eclipse.linuxtools.internal.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().equals(EMPTY_STRING) ? - ConversionHelper.toMacAddress(fMacAddress) : - endpoint.toString() + '/' + ConversionHelper.toMacAddress(fMacAddress)); - - } -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java deleted file mode 100644 index d9f95edd37..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java +++ /dev/null @@ -1,313 +0,0 @@ -/******************************************************************************* - * 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.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.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; -import org.eclipse.linuxtools.internal.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; - - /* We store MAC addresses as byte arrays since - * there is no standard java class to store them. */ - 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, PcapProtocol.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() { - @SuppressWarnings("null") - @NonNull byte[] mac = Arrays.copyOf(fSourceMacAddress, fSourceMacAddress.length); - return mac; - } - - /** - * Getter method for the destination MAC Address. - * - * @return The destination MAC address. - */ - public byte[] getDestinationMacAddress() { - @SuppressWarnings("null") - @NonNull byte[] mac = Arrays.copyOf(fDestinationMacAddress, fDestinationMacAddress.length); - return mac; - } - - /** - * 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/internal/pcap/core/protocol/ethernet2/EthernetIIValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIValues.java deleted file mode 100644 index 42804932db..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIValues.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/protocol/ethernet2/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/package-info.java deleted file mode 100644 index 1dfef35d1e..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol.ethernet2; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java deleted file mode 100644 index 85668b2447..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * 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.protocol.ipv4; - -import java.net.Inet4Address; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint; - -/** - * 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 Inet4Address 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 + fIPAddress.hashCode(); - 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 = fIPAddress.equals(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) { - @SuppressWarnings("null") - @NonNull String ret = fIPAddress.getHostAddress(); - return ret; - } - return endpoint.toString() + '/' + fIPAddress.getHostAddress(); - } - -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Packet.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Packet.java deleted file mode 100644 index fc804639c1..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Packet.java +++ /dev/null @@ -1,651 +0,0 @@ -/******************************************************************************* - * 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.protocol.ipv4; - -import java.net.Inet4Address; -import java.net.InetAddress; -import java.net.UnknownHostException; -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.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.tcp.TCPPacket; -import org.eclipse.linuxtools.internal.pcap.core.protocol.udp.UDPPacket; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; -import org.eclipse.linuxtools.internal.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 Inet4Address fSourceIpAddress; - private final Inet4Address 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, PcapProtocol.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); - int msb = ((storage & 0b00011111) << 8); - int lsb = ConversionHelper.unsignedByteToInt(packet.get()); - fFragmentOffset = msb + lsb; - - fTimeToLive = ConversionHelper.unsignedByteToInt(packet.get()); - fIpDatagramProtocol = ConversionHelper.unsignedByteToInt(packet.get()); - fHeaderChecksum = ConversionHelper.unsignedShortToInt(packet.getShort()); - - byte[] source = new byte[IPv4Values.IP_ADDRESS_SIZE]; - byte[] destination = new byte[IPv4Values.IP_ADDRESS_SIZE]; - packet.get(source); - packet.get(destination); - - try { - @SuppressWarnings("null") - @NonNull Inet4Address sourceIP = (Inet4Address) InetAddress.getByAddress(source); - @SuppressWarnings("null") - @NonNull Inet4Address destinationIP = (Inet4Address) InetAddress.getByAddress(destination); - fSourceIpAddress = sourceIP; - fDestinationIpAddress = destinationIP; - } catch (UnknownHostException e) { - throw new BadPacketException("The IP Address size is not valid!"); //$NON-NLS-1$ - } - - // 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: " + fSourceIpAddress.getHostAddress() + ", Destination: " + fDestinationIpAddress.getHostAddress() + //$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 Inet4Address getSourceIpAddress() { - return fSourceIpAddress; - } - - /** - * Getter method that returns the destination IP address. - * - * @return The destination IP address, as a byte array in big-endian. - */ - public Inet4Address 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", fSourceIpAddress.getHostAddress()) //$NON-NLS-1$ - .put("Destination IP Address", fDestinationIpAddress.getHostAddress()); //$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: " + fSourceIpAddress.getHostAddress() + " , Dst: " + fDestinationIpAddress.getHostAddress(); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Override - protected String getSignificationString() { - StringBuilder sb = new StringBuilder(); - sb.append(fSourceIpAddress.getHostAddress()) - .append(" > ") //$NON-NLS-1$ - .append(fDestinationIpAddress.getHostAddress()); - - 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 + fDestinationIpAddress.hashCode(); - 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 + fSourceIpAddress.hashCode(); - 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 (!(fDestinationIpAddress.equals(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 (!(fSourceIpAddress.equals(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/internal/pcap/core/protocol/ipv4/IPv4Values.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Values.java deleted file mode 100644 index 3e4e157241..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Values.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/protocol/ipv4/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/package-info.java deleted file mode 100644 index b8484b6472..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol.ipv4; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/package-info.java deleted file mode 100644 index eea3ac9296..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapEndpoint.java deleted file mode 100644 index 8662c76e30..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapEndpoint.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.protocol.pcap; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.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/internal/pcap/core/protocol/pcap/PcapPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapPacket.java deleted file mode 100644 index 79945bae8a..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapPacket.java +++ /dev/null @@ -1,372 +0,0 @@ -/******************************************************************************* - * 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.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.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFileValues; -import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; -import org.eclipse.linuxtools.internal.pcap.core.util.LinkTypeHelper; -import org.eclipse.linuxtools.internal.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, PcapProtocol.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/internal/pcap/core/protocol/pcap/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/package-info.java deleted file mode 100644 index 173f3a9557..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol.pcap; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPEndpoint.java deleted file mode 100644 index 97b291cdf3..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPEndpoint.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.protocol.tcp; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.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/internal/pcap/core/protocol/tcp/TCPPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPPacket.java deleted file mode 100644 index 7e5823e2f6..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPPacket.java +++ /dev/null @@ -1,702 +0,0 @@ -/******************************************************************************* - * 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.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.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.internal.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, PcapProtocol.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); - } - - sb.append(" Len=") //$NON-NLS-1$ - .append((fDataOffset * TCPValues.BLOCK_SIZE)); - - 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/internal/pcap/core/protocol/tcp/TCPValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPValues.java deleted file mode 100644 index fc1e389a73..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPValues.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/protocol/tcp/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/package-info.java deleted file mode 100644 index 2f7a7fdc99..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol.tcp; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPEndpoint.java deleted file mode 100644 index a55416f933..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPEndpoint.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * 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.protocol.udp; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.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/internal/pcap/core/protocol/udp/UDPPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPPacket.java deleted file mode 100644 index 99d5c98147..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPPacket.java +++ /dev/null @@ -1,301 +0,0 @@ -/******************************************************************************* - * 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.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.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.internal.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, PcapProtocol.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/internal/pcap/core/protocol/udp/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/package-info.java deleted file mode 100644 index a55251124b..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol.udp; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownEndpoint.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownEndpoint.java deleted file mode 100644 index a731bd5d0f..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownEndpoint.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * 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.protocol.unknown; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.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) { - if (this == obj) { - return true; - } - return false; - } -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownPacket.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownPacket.java deleted file mode 100644 index b4384eb1be..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownPacket.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * 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.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.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; -import org.eclipse.linuxtools.internal.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, PcapProtocol.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/internal/pcap/core/protocol/unknown/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/package-info.java deleted file mode 100644 index 8478b55a88..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.protocol.unknown; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStream.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStream.java deleted file mode 100644 index 2036a01bc3..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStream.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * 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.stream; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpointPair; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; - -import com.google.common.math.DoubleMath; - -// 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 double SECOND_TO_NANOSECOND = 1000000000.0; - private static final double DELTA = 0.000000001; - private final PcapProtocol fProtocol; - private final int fId; - private final ProtocolEndpointPair fEndpointPair; - - private long fNbPacketsAtoB; - private long fNbPacketsBtoA; - private long fNbBytesAtoB; - private long fNbBytesBtoA; - private long fStartTime; - private long fEndTime; - - /** - * 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(PcapProtocol protocol, int id, ProtocolEndpointPair endpointPair) { - fProtocol = protocol; - fId = id; - fEndpointPair = endpointPair; - fNbPacketsAtoB = 0; - fNbPacketsBtoA = 0; - fNbBytesAtoB = 0; - fNbBytesBtoA = 0; - fStartTime = Long.MAX_VALUE; - fEndTime = Long.MIN_VALUE; - } - - /** - * Add a packet to the stream. - * - * @param packet - * The packet that must be added. - */ - synchronized void add(PcapPacket packet) { - - Packet newPacket = packet.getPacket(fProtocol); - if (newPacket == null) { - return; - } - - // Update packet and byte number - if (fEndpointPair.getFirstEndpoint().equals(newPacket.getSourceEndpoint()) && - fEndpointPair.getSecondEndpoint().equals(newPacket.getDestinationEndpoint())) { - fNbPacketsAtoB++; - fNbBytesAtoB += packet.getOriginalLength(); - } else if (fEndpointPair.getFirstEndpoint().equals(newPacket.getDestinationEndpoint()) && - fEndpointPair.getSecondEndpoint().equals(newPacket.getSourceEndpoint())) { - fNbPacketsBtoA++; - fNbBytesBtoA += packet.getOriginalLength(); - } else { - throw new IllegalStateException(); - } - - // Update start and stop time - // Stream timestamp is ALWAYS in nanoseconds. - long timestamp; - switch (packet.getTimestampScale()) { - case MICROSECOND: - timestamp = packet.getTimestamp() * 1000; - break; - case NANOSECOND: - timestamp = packet.getTimestamp(); - break; - default: - throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$ - } - fStartTime = Math.min(fStartTime, timestamp); - fEndTime = Math.max(fEndTime, timestamp); - } - - /** - * Get the Protocol of this stream. - * - * @return The protocol of this stream. - */ - public PcapProtocol 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: " + getNbPackets() + "\n"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - - @SuppressWarnings("null") - @NonNull String string = sb.toString(); - return string; - - } - - /** - * Get the number of packets going from the first endpoint to the second. - * - * @return The number of packets from A to B. - */ - public synchronized long getNbPacketsAtoB() { - return fNbPacketsAtoB; - } - - /** - * Get the number of packets going from the second endpoint to the first. - * - * @return The number of packets from B to A. - */ - public synchronized long getNbPacketsBtoA() { - return fNbPacketsBtoA; - } - - /** - * Get the total number of packets in this stream. - * - * @return The total number of packets. - */ - public synchronized long getNbPackets() { - return fNbPacketsAtoB + fNbPacketsBtoA; - } - - /** - * Get the number of bytes going from the first endpoint to the second. - * - * @return The number of bytes from A to B. - */ - public synchronized long getNbBytesAtoB() { - return fNbBytesAtoB; - } - - /** - * Get the number of bytes going from the second endpoint to the first. - * - * @return The number of bytes from B to A. - */ - public synchronized long getNbBytesBtoA() { - return fNbBytesBtoA; - } - - /** - * Get the total number of bytes in this stream. - * - * @return The total number of bytes. - */ - public synchronized long getNbBytes() { - return fNbBytesAtoB + fNbBytesBtoA; - } - - /** - * Get the start time of this stream, in nanoseconds relative to epoch. - * - * @return The start time. - */ - public synchronized long getStartTime() { - return fStartTime; - } - - /** - * Get the stop time of this stream, in nanoseconds relative to epoch. - * - * @return The stop time. - */ - public synchronized long getStopTime() { - return fEndTime; - } - - /** - * Get the duration of this stream, in seconds - * - * @return The duration of this stream. - */ - public synchronized double getDuration() { - return (fEndTime - fStartTime) / SECOND_TO_NANOSECOND; - } - - /** - * Get the the average byte per second from A to B. - * - * @return the average byte per second from A to B. - */ - public synchronized double getBPSAtoB() { - if (DoubleMath.fuzzyEquals(getDuration(), 0, DELTA)) { - return 0; - } - return fNbBytesAtoB / getDuration(); - } - - /** - * Get the the average byte per second from B to A. - * - * @return the average byte per second from B to A. - */ - public synchronized double getBPSBtoA() { - if (DoubleMath.fuzzyEquals(getDuration(), 0, DELTA)) { - return 0; - } - return fNbBytesBtoA / getDuration(); - } - -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStreamBuilder.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStreamBuilder.java deleted file mode 100644 index 6780b3d465..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStreamBuilder.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * 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.stream; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint; -import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpointPair; -import org.eclipse.linuxtools.internal.pcap.core.filter.IPacketFilter; -import org.eclipse.linuxtools.internal.pcap.core.filter.PacketFilterByProtocol; -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; -import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; -import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; -import org.eclipse.linuxtools.internal.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 PcapProtocol fProtocol; - - private final Map fStreams; - private final Map fIDs; - private int fCurrentId; - - /** - * Main constructor. - * - * @param protocol - * The protocol of the builder. - */ - public PacketStreamBuilder(PcapProtocol 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 PcapProtocol 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 filePath - * The file path. - * @throws IOException - * When an IO error occurs. - * @throws BadPcapFileException - * When the PcapFile is not valid. - */ - public synchronized void parsePcapFile(Path filePath) throws IOException, BadPcapFileException { - try (PcapFile pcapFile = new PcapFile(filePath);) { - 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/internal/pcap/core/stream/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/package-info.java deleted file mode 100644 index e9904b7a8b..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.stream; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/BadPcapFileException.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/BadPcapFileException.java deleted file mode 100644 index dbf825d343..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/BadPcapFileException.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/trace/PcapFile.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFile.java deleted file mode 100644 index 2c29c8afde..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFile.java +++ /dev/null @@ -1,401 +0,0 @@ -/******************************************************************************* - * 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.trace; - -import java.io.Closeable; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.channels.SeekableByteChannel; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.TreeMap; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; -import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; -import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; -import org.eclipse.linuxtools.internal.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 Path fPcapFilePath; - private final ByteOrder fByteOrder; - private final SeekableByteChannel fFileChannel; - 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(Path filePath) throws BadPcapFileException, IOException { - - fFileIndex = new TreeMap<>(); - fCurrentRank = 0; - fTotalNumberPackets = -1; - fPcapFilePath = filePath; - - // Check file validity - if (Files.notExists(fPcapFilePath) || !Files.isRegularFile(fPcapFilePath) || - Files.size(fPcapFilePath) < PcapFileValues.GLOBAL_HEADER_SIZE) { - throw new BadPcapFileException("Bad Pcap File."); //$NON-NLS-1$ - } - - if (!Files.isReadable(fPcapFilePath)) { - throw new BadPcapFileException("File is not readable."); //$NON-NLS-1$ - } - - // File is not empty. Try to open. - @SuppressWarnings("null") - @NonNull SeekableByteChannel channel = Files.newByteChannel(fPcapFilePath); - fFileChannel = channel; - - // 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; - 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 Path 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(); - } - -} diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFileValues.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFileValues.java deleted file mode 100644 index 169a0c388d..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFileValues.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/trace/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/package-info.java deleted file mode 100644 index 1b5ed9ac32..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.trace; \ No newline at end of file diff --git a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/ConversionHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/ConversionHelper.java deleted file mode 100644 index 7757dbb122..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/ConversionHelper.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * 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.util; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIValues; - -/** - * Class for helping with the conversion of data. - * - * @author Vincent Perot - */ -public final class ConversionHelper { - - @SuppressWarnings("null") - private static final @NonNull 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 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/internal/pcap/core/util/EthertypeHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/EthertypeHelper.java deleted file mode 100644 index 8f5f81aa69..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/EthertypeHelper.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/util/IPProtocolNumberHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/IPProtocolNumberHelper.java deleted file mode 100644 index 5a3a875dc2..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/IPProtocolNumberHelper.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * 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.util; - -import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; - -// 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 PcapProtocol.TCP.getName(); - case PROTOCOL_NUMBER_UDP: - return PcapProtocol.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/internal/pcap/core/util/LinkTypeHelper.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/LinkTypeHelper.java deleted file mode 100644 index 4241864520..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/LinkTypeHelper.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/util/PcapTimestampScale.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/PcapTimestampScale.java deleted file mode 100644 index 9dc04fcc39..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/PcapTimestampScale.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * 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.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/internal/pcap/core/util/package-info.java b/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/package-info.java deleted file mode 100644 index da154e4298..0000000000 --- a/org.eclipse.linuxtools.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.util; \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.pcap.core.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.pcap.core.tests/META-INF/MANIFEST.MF index acfd408731..883ee00b92 100644 --- a/org.eclipse.linuxtools.tmf.pcap.core.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.pcap.core.tests/META-INF/MANIFEST.MF @@ -10,8 +10,8 @@ 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="1.0.0", - org.eclipse.linuxtools.pcap.core.tests;bundle-version="1.0.0", + org.eclipse.tracecompass.pcap.core;bundle-version="1.0.0", + org.eclipse.tracecompass.pcap.core.tests;bundle-version="1.0.0", org.eclipse.linuxtools.tmf.core;bundle-version="3.1.0", org.eclipse.linuxtools.tmf.core.tests;bundle-version="3.1.0", org.eclipse.linuxtools.tmf.pcap.core;bundle-version="1.0.0" diff --git a/org.eclipse.linuxtools.tmf.pcap.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.pcap.core/META-INF/MANIFEST.MF index 7bc16f7bab..b048b0c8f0 100644 --- a/org.eclipse.linuxtools.tmf.pcap.core/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.pcap.core/META-INF/MANIFEST.MF @@ -11,7 +11,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.linuxtools.tmf.core;bundle-version="3.1.0", - org.eclipse.linuxtools.pcap.core;bundle-version="1.0.0" + org.eclipse.tracecompass.pcap.core;bundle-version="1.0.0" Export-Package: org.eclipse.linuxtools.internal.tmf.pcap.core;x-internal:=true, org.eclipse.linuxtools.internal.tmf.pcap.core.analysis;x-friends:="org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.ui", org.eclipse.linuxtools.internal.tmf.pcap.core.event;x-friends:="org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.ui", diff --git a/org.eclipse.linuxtools.tmf.pcap/feature.xml b/org.eclipse.linuxtools.tmf.pcap/feature.xml index 4c89aa3bc3..578daa742b 100644 --- a/org.eclipse.linuxtools.tmf.pcap/feature.xml +++ b/org.eclipse.linuxtools.tmf.pcap/feature.xml @@ -36,11 +36,11 @@ - + diff --git a/org.eclipse.tracecompass.pcap.core.tests/.classpath b/org.eclipse.tracecompass.pcap.core.tests/.classpath new file mode 100644 index 0000000000..8fbc9a2058 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/org.eclipse.tracecompass.pcap.core.tests/.project b/org.eclipse.tracecompass.pcap.core.tests/.project new file mode 100644 index 0000000000..76c8be9c0b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/.project @@ -0,0 +1,34 @@ + + + org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/.settings/org.eclipse.core.resources.prefs b/org.eclipse.tracecompass.pcap.core.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.tracecompass.pcap.core.tests/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..5a0ad22d2a --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.tracecompass.pcap.core.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..f3fc64575b --- /dev/null +++ b/org.eclipse.tracecompass.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=ignore +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.tracecompass.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.tracecompass.pcap.core.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..4fd0c7006a --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs b/org.eclipse.tracecompass.pcap.core.tests/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000000..acc3abd47c --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/.settings/org.eclipse.pde.prefs b/org.eclipse.tracecompass.pcap.core.tests/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..62cfa90dee --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/META-INF/MANIFEST.MF b/org.eclipse.tracecompass.pcap.core.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..b5b1a11f02 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/META-INF/MANIFEST.MF @@ -0,0 +1,29 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-Vendor: %Bundle-Vendor +Bundle-Version: 1.0.0.qualifier +Bundle-Localization: plugin +Bundle-SymbolicName: org.eclipse.tracecompass.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.tracecompass.pcap.core;bundle-version="1.0.0" +Export-Package: org.eclipse.linuxtools.pcap.core.tests, + org.eclipse.linuxtools.pcap.core.tests.file;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.packet;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.perf, + org.eclipse.linuxtools.pcap.core.tests.perf.trace;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol.ethernet2;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol.ipv4;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol.pcap;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol.tcp;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol.udp;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.protocol.unknown;x-internal:=true, + org.eclipse.linuxtools.pcap.core.tests.shared;x-friends:="org.eclipse.linuxtools.tmf.pcap.core.tests", + org.eclipse.linuxtools.pcap.core.tests.stream;x-internal:=true +Import-Package: com.google.common.collect, + org.eclipse.test.performance diff --git a/org.eclipse.tracecompass.pcap.core.tests/about.html b/org.eclipse.tracecompass.pcap.core.tests/about.html new file mode 100644 index 0000000000..28737f60b7 --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core.tests/build.properties b/org.eclipse.tracecompass.pcap.core.tests/build.properties new file mode 100644 index 0000000000..7de632eb60 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/build.properties @@ -0,0 +1,22 @@ +############################################################################### +# 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/,\ + perf/,\ + shared/ +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.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/AllPerfTests.java b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/AllPerfTests.java new file mode 100644 index 0000000000..3482713418 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/AllPerfTests.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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 implementation and API + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.perf; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Run all performance test suites. + * + * @author Vincent Perot + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + org.eclipse.linuxtools.pcap.core.tests.perf.trace.AllTests.class +}) +public class AllPerfTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/AllTests.java new file mode 100644 index 0000000000..4eb62a4d75 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.perf.trace; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + PcapReadBenchmark.class, + PcapSeekBenchmark.class +}) +public class AllTests { +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java new file mode 100644 index 0000000000..1e98a81d91 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * 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.tests.perf.trace; + +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.eclipse.test.performance.Dimension; +import org.eclipse.test.performance.Performance; +import org.eclipse.test.performance.PerformanceMeter; +import org.junit.Test; + +/** + * Benchmark of the Pcap parser for reading a trace. Note: We should get a + * bigger trace. One that has WAYYYY more events since this current trace is + * just parsed too fast. + * + * @author Vincent Perot + */ +public class PcapReadBenchmark { + + private static final String TEST_SUITE_NAME = "Pcap Read Benchmark"; + private static final String TEST_ID = "org.eclipse.linuxtools#" + TEST_SUITE_NAME; + private static final int LOOP_COUNT = 25; + private static final int RUN_BETWEEN_COMMIT_COUNT = 15; + + /** + * Benchmark reading the pcap trace + */ + @Test + public void testPcapTrace() { + readTrace(PcapTestTrace.BENCHMARK_TRACE, "trace-pcap", true); + } + + private static void readTrace(PcapTestTrace testTrace, String testName, boolean inGlobalSummary) { + assumeTrue(testTrace.exists()); + + Performance perf = Performance.getDefault(); + PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); + perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); + + if (inGlobalSummary) { + perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); + } + + for (int loop = 0; loop < LOOP_COUNT; loop++) { + pm.start(); + try (PcapFile trace = testTrace.getTrace();) { + for (int i = 0; i < RUN_BETWEEN_COMMIT_COUNT; i++) { + trace.seekPacket(0); + while (trace.hasNextPacket()) { + Packet packet = trace.parseNextPacket(); + if (packet == null) { + fail("Test failed at iteration " + loop + '.' + i + ", at packet " + trace.getCurrentRank()); + return; + } + /* Do something with the packet because we are awesome */ + packet.getPayload(); + } + } + } catch (IOException | BadPcapFileException | BadPacketException e) { + fail("Test failed at iteration " + loop + ':' + e.getMessage()); + } + pm.stop(); + } + pm.commit(); + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java new file mode 100644 index 0000000000..e16cebac58 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * 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.tests.perf.trace; + +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.eclipse.test.performance.Dimension; +import org.eclipse.test.performance.Performance; +import org.eclipse.test.performance.PerformanceMeter; +import org.junit.Test; + +/** + * Tests for performance regressions of the pcap reader. It only tests the pcap + * reader, not tmf.
    + * This test runs in 3 passes. + *
      + *
    • first it opens a trace
    • + *
    • then it reads the trace completely
    • + *
    • then it randomly (seeded) seeks NB_SEEKS locations in the trace and reads + * one event at each position.
    • + *
    + *
  • Note: We should make more seeks, since the current number is just too + * fast.
  • + * + * @author Vincent Perot + */ +public class PcapSeekBenchmark { + + private static final Random RND = new Random(1000); + + private static final int LOOP_COUNT = 25; + private static final int NB_SEEKS = 1000000; + private static final String TEST_SUITE_NAME = "Pcap Read & Seek Benchmark (" + NB_SEEKS + " seeks)"; + private static final String TEST_ID = "org.eclipse.linuxtools#" + TEST_SUITE_NAME; + + /** + * Run the benchmark scenario for the pcap trace. + */ + @Test + public void testPcapTrace() { + readAndSeekTrace(PcapTestTrace.BENCHMARK_TRACE, "trace-pcap", true); + } + + private static void readAndSeekTrace(PcapTestTrace testTrace, String testName, boolean inGlobalSummary) { + assumeTrue(testTrace.exists()); + + Performance perf = Performance.getDefault(); + PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); + perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); + + if (inGlobalSummary) { + perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); + } + + for (int loop = 0; loop < LOOP_COUNT; loop++) { + try (PcapFile trace = testTrace.getTrace()) { + trace.seekPacket(0); + + /* Read the whole trace to find out the number of packets */ + long nbPackets = trace.getTotalNbPackets(); + + /* Generate the timestamps we will seek to */ + List seekTimestamps = new LinkedList<>(); + final long range = nbPackets; + for (int i = 0; i < NB_SEEKS; i++) { + long rank = (RND.nextLong() % range); + if (rank < 0) { + // This is needed since modulus can return a negative + // number. + rank += range; + } + seekTimestamps.add(rank); + } + + /* Benchmark seeking to the generated timestamps */ + pm.start(); + for (Long rank : seekTimestamps) { + trace.seekPacket(rank); + trace.parseNextPacket(); + } + pm.stop(); + + } catch (IOException | BadPcapFileException | BadPacketException e) { + /* Should not happen if assumeTrue() passed above */ + fail("Test failed at iteration " + loop + ':' + e.getMessage()); + } + } + pm.commit(); + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/plugin.properties b/org.eclipse.tracecompass.pcap.core.tests/plugin.properties new file mode 100644 index 0000000000..8f0d91d7e8 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/plugin.properties @@ -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 +############################################################################### + +Bundle-Vendor = Eclipse Trace Compass +Bundle-Name = Trace Compass Pcap Parser Core Tests Plug-in diff --git a/org.eclipse.tracecompass.pcap.core.tests/pom.xml b/org.eclipse.tracecompass.pcap.core.tests/pom.xml new file mode 100644 index 0000000000..ba9e9be140 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/pom.xml @@ -0,0 +1,115 @@ + + + + + 4.0.0 + + + org.eclipse.tracecompass + org.eclipse.tracecompass + 3.2.0-SNAPSHOT + + + org.eclipse.tracecompass.pcap.core.tests + 1.0.0-SNAPSHOT + eclipse-test-plugin + + Trace Compass Pcap Parser Core Tests Plug-in + + + + + download-traces + + + !maven.test.skip + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + prepare + pre-integration-test + + + + + + + run + + + + + + + + + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + org.eclipse.tracecompass.pcap.core.tests + org.eclipse.linuxtools.pcap.core.tests.AllPcapCoreTests + false + false + org.eclipse.platform.ide + + + + + + maven-clean-plugin + 2.5 + + + clean-traces + clean + + + + rsc + + *.zip + *.pcap + *.cap + *.tar* + + + *.xml + *.sh + + + rsc/kernel + + + + clean + + + + + + + + + org.eclipse.tracecompass + diff --git a/org.eclipse.tracecompass.pcap.core.tests/rsc/.gitignore b/org.eclipse.tracecompass.pcap.core.tests/rsc/.gitignore new file mode 100644 index 0000000000..a8ddf0ad84 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/rsc/.gitignore @@ -0,0 +1,5 @@ +*.zip +*.pcap +*.cap +*.tar* +/kernel diff --git a/org.eclipse.tracecompass.pcap.core.tests/rsc/get-traces.xml b/org.eclipse.tracecompass.pcap.core.tests/rsc/get-traces.xml new file mode 100644 index 0000000000..73d7df96c0 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/rsc/get-traces.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.tracecompass.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.java b/org.eclipse.tracecompass.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.java new file mode 100644 index 0000000000..5f78b56b83 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.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.tests.shared; + +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; + +/** + * Here is the list of the available test traces for the Pcap parser. + * + * @author Vincent Perot + */ +public enum PcapTestTrace { + + /** A bad pcap file. */ + BAD_PCAPFILE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "BadPcapFile.pcap"), + + /** A Valid Pcap that is empty. */ + EMPTY_PCAP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "EmptyPcap.pcap"), + + /** A Pcap that mostly contains TCP packets. */ + MOSTLY_TCP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "mostlyTCP.pcap"), + + /** A Pcap that mostly contains UDP packets. */ + MOSTLY_UDP("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "mostlyUDP.pcap"), + + /** A big-endian trace that contains two packets. */ + SHORT_BIG_ENDIAN("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "Short_BigEndian.pcap"), + + /** A little-endian trace that contains two packets. */ + SHORT_LITTLE_ENDIAN("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "Short_LittleEndian.pcap"), + + /** A large trace for benchmarking. */ + BENCHMARK_TRACE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "benchmarkTrace.pcap"), + + /** A Kernel trace directory. */ + KERNEL_DIRECTORY("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "kernel"), + + /** A Kernel trace file. */ + KERNEL_TRACE("..", "org.eclipse.linuxtools.pcap.core.tests", "rsc", "kernel", "channel0_0"); + + private final @NonNull Path fPath; + + private PcapTestTrace(@NonNull String first, String... more) { + @SuppressWarnings("null") + @NonNull Path path = FileSystems.getDefault().getPath(first, more); + fPath = path; + } + + /** @return The path to the test trace */ + public @NonNull Path getPath() { + return fPath; + } + + /** + * Get a Pcap Trace instance of a test trace. Make sure to call + * {@link #exists()} before calling this! + * + * @return The PcapFile object + * @throws IOException + * Thrown when some IO error occurs. + * @throws BadPcapFileException + * Thrown when the file is not a valid Pcap File. + */ + public PcapFile getTrace() throws BadPcapFileException, IOException { + return new PcapFile(fPath); + } + + /** + * Check if this test trace actually exists on disk. + * + * @return If the trace exists + */ + public boolean exists() { + if (Files.notExists(fPath)) { + return false; + } + return true; + } + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java new file mode 100644 index 0000000000..86e1cb8c38 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Master test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + org.eclipse.linuxtools.pcap.core.tests.file.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.packet.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.ethernet2.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.ipv4.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.pcap.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.tcp.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.udp.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.protocol.unknown.AllTests.class, + org.eclipse.linuxtools.pcap.core.tests.stream.AllTests.class +}) +public class AllPcapCoreTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/AllTests.java new file mode 100644 index 0000000000..5f5b9a8018 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/AllTests.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.tests.file; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * File test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + PcapFileOpenTest.class, + PcapFileOpenFailTest.class, + PcapFileReadTest.class, + PcapFileEndiannessTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java new file mode 100644 index 0000000000..28a1dc744c --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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.tests.file; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteOrder; +import java.nio.file.Path; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Test; + +/** + * JUnit Class that tests whether the Pcap parser can read both big endian and + * little endian files. + * + * @author Vincent Perot + */ +public class PcapFileEndiannessTest { + + /** + * Test that verify that two files with different endianness contain the + * same packets. + * + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void EndiannessTest() throws IOException, BadPcapFileException, BadPacketException { + PcapTestTrace trace = PcapTestTrace.SHORT_LITTLE_ENDIAN; + assumeTrue(trace.exists()); + Path path1 = trace.getPath(); + + trace = PcapTestTrace.SHORT_LITTLE_ENDIAN; + assumeTrue(trace.exists()); + Path path2 = PcapTestTrace.SHORT_BIG_ENDIAN.getPath(); + + try (PcapFile littleEndian = new PcapFile(path1); + PcapFile bigEndian = new PcapFile(path2);) { + assertEquals(ByteOrder.BIG_ENDIAN, bigEndian.getByteOrder()); + assertEquals(ByteOrder.LITTLE_ENDIAN, littleEndian.getByteOrder()); + while (littleEndian.hasNextPacket() && bigEndian.hasNextPacket()) { + assertEquals(littleEndian.parseNextPacket(), bigEndian.parseNextPacket()); + } + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java new file mode 100644 index 0000000000..7b8ffcac8f --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * 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.tests.file; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Test; + +/** + * JUnit Class that tests the opening of non-valid pcap files. + * + * @author Vincent Perot + */ +public class PcapFileOpenFailTest { + + /** + * Test that tries to open a pcap with a bad magic number + * + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + */ + @Test + public void FileOpenBadPcapTest() throws IOException { + PcapTestTrace trace = PcapTestTrace.BAD_PCAPFILE; + assumeTrue(trace.exists()); + + try (PcapFile file = new PcapFile(trace.getPath());) { + fail("The pcap was accepted even though the magic number is invalid!"); + } catch (BadPcapFileException e) { + assertEquals("c3d4a1b2 is not a known magic number.", e.getMessage()); + } + } + + /** + * Test that tries to open a non-pcap binary file + * + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + */ + @Test + public void FileOpenBinaryFile() throws IOException { + PcapTestTrace trace = PcapTestTrace.KERNEL_TRACE; + assumeTrue(trace.exists()); + + try (PcapFile file = new PcapFile(trace.getPath());) { + fail("The file was accepted even though it is not a pcap file!"); + } catch (BadPcapFileException e) { + assertEquals("c11ffcc1 is not a known magic number.", e.getMessage()); + } + } + + /** + * Test that tries to open a directory + * + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + */ + @Test + public void FileOpenDirectory() throws IOException { + PcapTestTrace trace = PcapTestTrace.KERNEL_DIRECTORY; + assumeTrue(trace.exists()); + + try (PcapFile file = new PcapFile(trace.getPath());) { + fail("The file was accepted even though it is not a pcap file!"); + } catch (BadPcapFileException e) { + assertEquals("Bad Pcap File.", e.getMessage()); + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java new file mode 100644 index 0000000000..df22a7b902 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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.tests.file; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteOrder; + +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Test; + +/** + * JUnit Class that tests the opening of valid pcap files. + * + * @author Vincent Perot + */ +public class PcapFileOpenTest { + + /** + * Test that verify that an empty pcap file is properly opened and that the + * file properties are correct. + * + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + */ + @Test + public void FileOpenEmptyTest() throws IOException, BadPcapFileException { + + PcapTestTrace trace = PcapTestTrace.EMPTY_PCAP; + assumeTrue(trace.exists()); + + try (PcapFile file = new PcapFile(trace.getPath());) { + assertEquals(PcapTestTrace.EMPTY_PCAP.getPath(), file.getPath()); + assertEquals(2, file.getMajorVersion()); + assertEquals(4, file.getMinorVersion()); + assertEquals(1, file.getDataLinkType()); + assertEquals(65535, file.getSnapLength()); + assertEquals(0, file.getTimeAccuracy()); + assertEquals(0, file.getTimeZoneCorrection()); + assertEquals(ByteOrder.LITTLE_ENDIAN, file.getByteOrder()); + + assertEquals(0, file.getTotalNbPackets()); + + } + } + + /** + * Test that verify that an non-empty pcap file is properly opened and that + * the file properties are correct. + * + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + */ + + @Test + public void FileOpenTest() throws IOException, BadPcapFileException { + + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + + try (PcapFile file = new PcapFile(trace.getPath());) { + assertEquals(PcapTestTrace.MOSTLY_TCP.getPath(), file.getPath()); + assertEquals(2, file.getMajorVersion()); + assertEquals(4, file.getMinorVersion()); + assertEquals(1, file.getDataLinkType()); + assertEquals(65535, file.getSnapLength()); + assertEquals(0, file.getTimeAccuracy()); + assertEquals(0, file.getTimeZoneCorrection()); + assertEquals(ByteOrder.LITTLE_ENDIAN, file.getByteOrder()); + + assertEquals(43, file.getTotalNbPackets()); + + } + } + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java new file mode 100644 index 0000000000..5d86e74adc --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * 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.tests.file; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Test; + +/** + * JUnit Class that tests if packets are read without error. + * + * @author Vincent Perot + */ +public class PcapFileReadTest { + + /** + * Test that verify that packets are well read and that no error happens in + * file index. + * + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void FileReadTest() throws IOException, BadPcapFileException, BadPacketException { + + PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; + assumeTrue(trace.exists()); + + try (PcapFile file = new PcapFile(trace.getPath());) { + + PcapPacket packet = file.parseNextPacket(); + if (packet == null) { + fail("FileReadTest() failed!"); + return; + } + + assertEquals(1, file.getCurrentRank()); + // Verify Pcap packet. + assertEquals(file, packet.getPcapFile()); + assertEquals(PcapProtocol.PCAP, packet.getProtocol()); + assertEquals(0, packet.getIndex()); + assertEquals(1120469540839312L, packet.getTimestamp()); + assertEquals(92, packet.getOriginalLength()); + assertEquals(92, packet.getIncludedLength()); + assertEquals(false, packet.isTruncated()); + assertEquals(true, packet.validate()); + // Verify Ethernet Packet + if (!packet.hasProtocol(PcapProtocol.ETHERNET_II)) { + fail("Packet doesn't have ethernet!"); + } + // Verify IPv4 Packet + if (!packet.hasProtocol(PcapProtocol.IPV4)) { + fail("Packet doesn't have IPv4!"); + } + // Verify UDP Packet + if (!packet.hasProtocol(PcapProtocol.UDP)) { + fail("Packet doesn't have UDP!"); + } + // Verify Unknown Packet + if (!packet.hasProtocol(PcapProtocol.UNKNOWN)) { + fail("Packet doesn't have payload!"); + } + + // Parse a "random" packet + file.seekPacket(58); + packet = file.parseNextPacket(); + if (packet == null) { + fail("FileReadTest() failed!"); + return; + } + + // Verify Pcap packet. + assertEquals(file, packet.getPcapFile()); + assertEquals(PcapProtocol.PCAP, packet.getProtocol()); + assertEquals(58, packet.getIndex()); + assertEquals(1120469635045415L, packet.getTimestamp()); + assertEquals(113, packet.getOriginalLength()); + assertEquals(113, packet.getIncludedLength()); + assertEquals(false, packet.isTruncated()); + assertEquals(true, packet.validate()); + // Verify Ethernet Packet + if (!packet.hasProtocol(PcapProtocol.ETHERNET_II)) { + fail("Packet doesn't have ethernet!"); + } + // Verify IPv4 Packet + if (!packet.hasProtocol(PcapProtocol.IPV4)) { + fail("Packet doesn't have IPv4!"); + } + // Verify TCP Packet + if (!packet.hasProtocol(PcapProtocol.TCP)) { + fail("Packet doesn't have TCP!"); + } + // Verify Unknown Packet + if (!packet.hasProtocol(PcapProtocol.UNKNOWN)) { + fail("Packet doesn't have payload!"); + } + + // Skip packet + file.skipNextPacket(); + assertEquals(60, file.getCurrentRank()); + + // Parse outside of file. + file.seekPacket(99999999); + assertEquals(file.getTotalNbPackets(), file.getCurrentRank()); + file.skipNextPacket(); // Should be a no-op + assertEquals(file.getTotalNbPackets(), file.getCurrentRank()); + packet = file.parseNextPacket(); + assertNull(packet); + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/AllTests.java new file mode 100644 index 0000000000..d53f197bf6 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/AllTests.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.tests.packet; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Generic Packet test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + PacketTest.class, + BadPacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java new file mode 100644 index 0000000000..484e46a9c5 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * 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.tests.packet; + +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +/** + * JUnit Class that tests if BadPacketExceptions are thrown correctly. + * + * @author Vincent Perot + */ +public class BadPacketTest { + + private ByteBuffer fEthernetPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fEthernetPacket = ByteBuffer.allocate(8); + fEthernetPacket.order(ByteOrder.BIG_ENDIAN); + + // This packet is erroneous. It contains 8 bytes while the minimum is 14 + // bytes for an Ethernet II packet. + + // Destination MAC - 6 bytes + fEthernetPacket.put((byte) 0x34); + fEthernetPacket.put((byte) 0x67); + fEthernetPacket.put((byte) 0x0C); + fEthernetPacket.put((byte) 0xD2); + fEthernetPacket.put((byte) 0x91); + fEthernetPacket.put((byte) 0x51); + + // Source MAC - 2 bytes + fEthernetPacket.put((byte) 0x10); + fEthernetPacket.put((byte) 0xF8); + + fEthernetPacket.flip(); + + } + + /** + * Test that verify if a BadPacketException is correctly thrown (when a + * packet is erroneous). + * + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Expected from the test. + */ + @Test(expected = BadPacketException.class) + public void PacketExceptionTest() throws BadPacketException, IOException, BadPcapFileException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer packet = fEthernetPacket; + if (packet != null) { + new EthernetIIPacket(dummy, null, packet); + } + fail("PacketExceptionTest has failed!"); + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java new file mode 100644 index 0000000000..d87f44117e --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * 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.tests.packet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +/** + * JUnit Class that tests the generic Packet class and its method. + * + * @author Vincent Perot + */ +public class PacketTest { + + private ByteBuffer fEthernetPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fEthernetPacket = ByteBuffer.allocate(15); + fEthernetPacket.order(ByteOrder.BIG_ENDIAN); + + // Destination MAC - 6 bytes + fEthernetPacket.put((byte) 0x34); + fEthernetPacket.put((byte) 0x67); + fEthernetPacket.put((byte) 0x0C); + fEthernetPacket.put((byte) 0xD2); + fEthernetPacket.put((byte) 0x91); + fEthernetPacket.put((byte) 0x51); + + // Source MAC - 6 bytes + fEthernetPacket.put((byte) 0x10); + fEthernetPacket.put((byte) 0xF8); + fEthernetPacket.put((byte) 0x82); + fEthernetPacket.put((byte) 0xB3); + fEthernetPacket.put((byte) 0x44); + fEthernetPacket.put((byte) 0x78); + + // Ethertype - 2 bytes + fEthernetPacket.put((byte) 0xA2); + fEthernetPacket.put((byte) 0x56); + + // Payload - 1 byte + fEthernetPacket.put((byte) 0xA6); + + fEthernetPacket.flip(); + + } + + /** + * Test that verify the correctness of the Packet's methods. + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void GenericPacketTest() throws BadPacketException, IOException, BadPcapFileException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer byteBuffer = fEthernetPacket; + if (byteBuffer == null) { + fail("GenericPacketTest has failed!"); + return; + } + + Packet packet = new EthernetIIPacket(dummy, null, byteBuffer); + assertTrue(packet.hasProtocol(PcapProtocol.ETHERNET_II)); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.TCP)); + assertEquals(PcapProtocol.ETHERNET_II, packet.getProtocol()); + + assertEquals(packet, packet.getPacket(PcapProtocol.ETHERNET_II)); + assertNull(packet.getPacket(PcapProtocol.TCP)); + assertEquals(packet.getChildPacket(), packet.getPacket(PcapProtocol.UNKNOWN)); + assertEquals(packet.getPacket(PcapProtocol.ETHERNET_II), packet.getMostEcapsulatedPacket()); + + assertNull(packet.getParentPacket()); + assertFalse(packet.getPcapFile().equals(null)); + + Packet child = packet.getChildPacket(); + if (child == null) { + fail("GenericPacketTest has failed!"); + return; + } + assertEquals(packet.getPayload(), child.getPayload()); + assertEquals(packet.getGlobalSummaryString(), "Source MAC: 10:f8:82:b3:44:78 , Destination MAC: 34:67:0c:d2:91:51"); + + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/AllTests.java new file mode 100644 index 0000000000..57a545771c --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Protocol test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ProtocolTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java new file mode 100644 index 0000000000..bedc50f0e0 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * 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.tests.protocol; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.junit.Test; + +/** + * JUnit Class that tests whether protocol operation are happening without + * error. + * + * @author Vincent Perot + */ +public class ProtocolTest { + + /** + * Test that verify if the protocol attributes are as expected. + */ + @Test + public void TestProtocolAttributes() { + assertEquals(PcapProtocol.PCAP.getName(), "Packet Capture"); + assertEquals(PcapProtocol.PCAP.getShortName(), "pcap"); + assertEquals(PcapProtocol.PCAP.getLayer(), PcapProtocol.Layer.LAYER_0); + } + + /** + * Test that verify if the protocol getter methods are working properly. + */ + @Test + public void TestgetProtocols() { + List manualListLayer = new ArrayList<>(); + for (PcapProtocol.Layer layer : PcapProtocol.Layer.values()) { + assertNotNull(layer); + Collection listLayer = PcapProtocol.getProtocolsOnLayer(layer); + + manualListLayer.clear(); + switch (layer) { + case LAYER_0: + manualListLayer.add(PcapProtocol.PCAP); + break; + case LAYER_1: + break; + case LAYER_2: + manualListLayer.add(PcapProtocol.ETHERNET_II); + break; + case LAYER_3: + manualListLayer.add(PcapProtocol.IPV4); + break; + case LAYER_4: + manualListLayer.add(PcapProtocol.TCP); + manualListLayer.add(PcapProtocol.UDP); + break; + case LAYER_5: + break; + case LAYER_6: + break; + case LAYER_7: + manualListLayer.add(PcapProtocol.UNKNOWN); + break; + default: + fail("Illegal layer value!"); + } + assertEquals(manualListLayer, listLayer); + } + } + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/AllTests.java new file mode 100644 index 0000000000..b640d9c206 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol.ethernet2; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Ethernet II test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + EthernetIIPacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java new file mode 100644 index 0000000000..5337c1b375 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java @@ -0,0 +1,145 @@ +/******************************************************************************* + * 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.tests.protocol.ethernet2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIValues; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * JUnit Class that tests the EthernetIIPacket class and its method. + * + * @author Vincent Perot + */ +public class EthernetIIPacketTest { + + private static final Map EXPECTED_FIELDS = ImmutableMap.of( + "Source MAC Address", "10:f8:82:b3:44:78", + "Destination MAC Address", "34:67:0c:d2:91:51", + "Ethertype", "Unknown (0xa256)" + ); + + private static final String EXPECTED_TOSTRING = + "Ethernet II, Source: 10:f8:82:b3:44:78, Destination: 34:67:0c:d2:91:51, Type: Unknown (0xa256)\nPayload: a6"; + + private ByteBuffer fPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fPacket = ByteBuffer.allocate(15); + fPacket.order(ByteOrder.BIG_ENDIAN); + + // Destination MAC - 6 bytes + fPacket.put((byte) 0x34); + fPacket.put((byte) 0x67); + fPacket.put((byte) 0x0C); + fPacket.put((byte) 0xD2); + fPacket.put((byte) 0x91); + fPacket.put((byte) 0x51); + + // Source MAC - 6 bytes + fPacket.put((byte) 0x10); + fPacket.put((byte) 0xF8); + fPacket.put((byte) 0x82); + fPacket.put((byte) 0xB3); + fPacket.put((byte) 0x44); + fPacket.put((byte) 0x78); + + // Ethertype - 2 bytes + fPacket.put((byte) 0xA2); + fPacket.put((byte) 0x56); + + // Payload - 1 byte + fPacket.put((byte) 0xA6); + + fPacket.flip(); + } + + /** + * Test that verify the correctness of the EthernetIIPacket's methods. + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void CompleteEthernetIIPacketTest() throws IOException, BadPcapFileException, BadPacketException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer byteBuffer = fPacket; + if (byteBuffer == null) { + fail("CompleteEthernetIIPacketTest has failed!"); + return; + } + EthernetIIPacket packet = new EthernetIIPacket(dummy, null, byteBuffer); + + // Protocol Testing + assertEquals(PcapProtocol.ETHERNET_II, packet.getProtocol()); + assertTrue(packet.hasProtocol(PcapProtocol.ETHERNET_II)); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.TCP)); + + // Abstract methods Testing + assertTrue(packet.validate()); + assertEquals(-653947816, packet.hashCode()); + assertFalse(packet.equals(null)); + assertEquals(new EthernetIIPacket(dummy, null, byteBuffer), packet); + + assertEquals(EXPECTED_FIELDS, packet.getFields()); + assertEquals(EXPECTED_TOSTRING, packet.toString()); + assertEquals("Src: 10:f8:82:b3:44:78 , Dst: 34:67:0c:d2:91:51", packet.getLocalSummaryString()); + assertEquals("Source MAC: 10:f8:82:b3:44:78 , Destination MAC: 34:67:0c:d2:91:51", packet.getGlobalSummaryString()); + + assertEquals(new EthernetIIEndpoint(packet, true), packet.getSourceEndpoint()); + assertEquals(new EthernetIIEndpoint(packet, false), packet.getDestinationEndpoint()); + + fPacket.position(14); + byte[] payload = new byte[1]; + fPacket.get(payload); + assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); + + // Packet-specific methods Testing + assertTrue(Arrays.equals(packet.getSourceMacAddress(), Arrays.copyOfRange(fPacket.array(), EthernetIIValues.MAC_ADDRESS_SIZE, EthernetIIValues.MAC_ADDRESS_SIZE + EthernetIIValues.MAC_ADDRESS_SIZE))); + assertTrue(Arrays.equals(packet.getDestinationMacAddress(), Arrays.copyOfRange(fPacket.array(), 0, 0 + EthernetIIValues.MAC_ADDRESS_SIZE))); + assertEquals(0xA256, packet.getEthertype()); + + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/AllTests.java new file mode 100644 index 0000000000..e431897506 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol.ipv4; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * IPv4 test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + IPv4PacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java new file mode 100644 index 0000000000..4e72c020c0 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java @@ -0,0 +1,211 @@ +/******************************************************************************* + * 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.tests.protocol.ipv4; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.net.InetAddress; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Endpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Packet; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +/** + * JUnit Class that tests the IPv4Packet class and its method. + * + * @author Vincent Perot + */ +public class IPv4PacketTest { + + private static final Map EXPECTED_FIELDS; + static { + EXPECTED_FIELDS = new LinkedHashMap<>(); + EXPECTED_FIELDS.put("Version", "4"); + EXPECTED_FIELDS.put("Header Length", "24 bytes"); + EXPECTED_FIELDS.put("Differentiated Services Field", "0x26"); + EXPECTED_FIELDS.put("Explicit Congestion Notification", "0x02"); + EXPECTED_FIELDS.put("Total Length", "255 bytes"); + EXPECTED_FIELDS.put("Identification", "0x0ff0"); + EXPECTED_FIELDS.put("Don't Fragment Flag", "false"); + EXPECTED_FIELDS.put("More Fragment Flag", "false"); + EXPECTED_FIELDS.put("Fragment Offset", "7905"); + EXPECTED_FIELDS.put("Time to live", "160"); + EXPECTED_FIELDS.put("Protocol", "Unknown (254)"); + EXPECTED_FIELDS.put("Checksum", "0x3344"); + EXPECTED_FIELDS.put("Source IP Address", "192.168.1.0"); + EXPECTED_FIELDS.put("Destination IP Address", "193.169.2.1"); + EXPECTED_FIELDS.put("Options", "a2 56 a2 56"); + } + + private static final String EXPECTED_TOSTRING; + static { + StringBuilder sb = new StringBuilder(); + sb.append("Internet Protocol Version 4, Source: 192.168.1.0, Destination: 193.169.2.1\n"); + sb.append("Version: 4, Identification: 0x0ff0, Header Length: 24 bytes, Total Length: 255 bytes\n"); + sb.append("Differentiated Services Code Point: 0x26; Explicit Congestion Notification: 0x02\n"); + sb.append("Flags: 0x00 (Don't have more fragments), Fragment Offset: 7905\n"); + sb.append("Time to live: 160\n"); + sb.append("Protocol: 254\n"); + sb.append("Header Checksum: 0x3344\n"); + sb.append("Payload: a6"); + + EXPECTED_TOSTRING = sb.toString(); + } + + private ByteBuffer fPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fPacket = ByteBuffer.allocate(25); + fPacket.order(ByteOrder.BIG_ENDIAN); + + // Version + IHL + fPacket.put((byte) 0x46); + + // DSCP + ECN + fPacket.put((byte) 0x9A); + + // Total length - this is randomly chosen so that we verify that the + // packet handles wrong total length. + fPacket.put((byte) 0x00); + fPacket.put((byte) 0xFF); + + // Identification + fPacket.put((byte) 0x0F); + fPacket.put((byte) 0xF0); + + // Flags + Fragment Offset + fPacket.put((byte) 0x1E); + fPacket.put((byte) 0xE1); + + // Time to live + fPacket.put((byte) 0xA0); + + // Protocol - Unknown + fPacket.put((byte) 0xFE); + + // Header checksum - chosen randomly + fPacket.put((byte) 0x33); + fPacket.put((byte) 0x44); + + // Source IP - 4 bytes + fPacket.put((byte) 192); + fPacket.put((byte) 168); + fPacket.put((byte) 1); + fPacket.put((byte) 0); + + // Destination IP - 4 bytes + fPacket.put((byte) 193); + fPacket.put((byte) 169); + fPacket.put((byte) 2); + fPacket.put((byte) 1); + + // Options - 4 bytes + fPacket.put((byte) 0xA2); + fPacket.put((byte) 0x56); + fPacket.put((byte) 0xA2); + fPacket.put((byte) 0x56); + + // Payload - 1 byte + fPacket.put((byte) 0xA6); + + fPacket.flip(); + } + + /** + * Test that verify the correctness of the IPv4Packet's methods. + * + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void CompleteIPv4PacketTest() throws IOException, BadPcapFileException, BadPacketException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer byteBuffer = fPacket; + if (byteBuffer == null) { + fail("CompleteIPv4PacketTest has failed!"); + return; + } + IPv4Packet packet = new IPv4Packet(dummy, null, byteBuffer); + + // Protocol Testing + assertEquals(PcapProtocol.IPV4, packet.getProtocol()); + assertTrue(packet.hasProtocol(PcapProtocol.IPV4)); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.TCP)); + + // Abstract methods Testing + assertTrue(packet.validate()); + assertEquals(-222021887, packet.hashCode()); + assertFalse(packet.equals(null)); + assertEquals(new IPv4Packet(dummy, null, byteBuffer), packet); + + assertEquals(EXPECTED_FIELDS, packet.getFields()); + assertEquals(EXPECTED_TOSTRING, packet.toString()); + assertEquals("Src: 192.168.1.0 , Dst: 193.169.2.1", packet.getLocalSummaryString()); + assertEquals("192.168.1.0 > 193.169.2.1 Id=4080 Len=1", packet.getGlobalSummaryString()); + + assertEquals(new IPv4Endpoint(packet, true), packet.getSourceEndpoint()); + assertEquals(new IPv4Endpoint(packet, false), packet.getDestinationEndpoint()); + + fPacket.position(24); + byte[] payload = new byte[1]; + fPacket.get(payload); + assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); + + // Packet-specific methods Testing + assertEquals(InetAddress.getByAddress(Arrays.copyOfRange(fPacket.array(), 12, 16)), packet.getSourceIpAddress()); + assertEquals(InetAddress.getByAddress(Arrays.copyOfRange(fPacket.array(), 16, 20)), packet.getDestinationIpAddress()); + assertTrue(Arrays.equals(packet.getOptions(), Arrays.copyOfRange(fPacket.array(), 20, 24))); + assertEquals(4, packet.getVersion()); + assertEquals(24, packet.getHeaderLength()); + assertEquals(0x26, packet.getDSCP()); + assertEquals(0x02, packet.getExplicitCongestionNotification()); + assertEquals(255, packet.getTotalLength()); + assertEquals(0x0FF0, packet.getIdentification()); + assertFalse(packet.getReservedFlag()); + assertFalse(packet.getDontFragmentFlag()); + assertFalse(packet.getHasMoreFragment()); + assertEquals(7905, packet.getFragmentOffset()); + assertEquals(160, packet.getTimeToLive()); + assertEquals(0xFE, packet.getIpDatagramProtocol()); + assertEquals(0x3344, packet.getHeaderChecksum()); + + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/AllTests.java new file mode 100644 index 0000000000..c5d70f7bea --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol.pcap; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Pcap test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + PcapPacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java new file mode 100644 index 0000000000..bf066354c1 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java @@ -0,0 +1,227 @@ +/******************************************************************************* + * 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.tests.protocol.pcap; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Map; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * JUnit Class that tests the PcapPacket class and its method. + * + * @author Vincent Perot + */ +public class PcapPacketTest { + + private static final Map EXPECTED_FIELDS = ImmutableMap.of( + "Frame", "36", + "Frame Length", "75 bytes", + "Capture Length", "75 bytes", + "Capture Time", "2005-07-04 05:33:52.829.277.000" + ); + + private static final String EXPECTED_TOSTRING; + static { + StringBuilder sb = new StringBuilder(); + sb.append("Packet Capture 36: 75 bytes on wire, 75 bytes captured.\n"); + sb.append("Arrival time: 2005-07-04 05:33:52.829.277.000\n"); + sb.append("Ethernet II, Source: 00:e0:ed:01:6e:bd, Destination: 00:30:54:00:34:56, Type: Internet Protocol Version 4 (0x0800)\n"); + sb.append("Internet Protocol Version 4, Source: 192.168.1.2, Destination: 192.168.1.1\n"); + sb.append("Version: 4, Identification: 0x69aa, Header Length: 20 bytes, Total Length: 61 bytes\n"); + sb.append("Differentiated Services Code Point: 0x00; Explicit Congestion Notification: 0x00\n"); + sb.append("Flags: 0x00 (Don't have more fragments), Fragment Offset: 0\n"); + sb.append("Time to live: 128\n"); + sb.append("Protocol: 17\n"); + sb.append("Header Checksum: 0x4db2\n"); + sb.append("User Datagram Protocol, Source Port: 2719, Destination Port: 53, Length: 41, Checksum: 19038\n"); + sb.append("Payload: ed d4 01 00 00 01 00 00 00 00 00 00 03 66 74 70 07 65 63 69 74 65 6c 65 03 63 6f 6d 00 00 01 00 01"); + + EXPECTED_TOSTRING = sb.toString(); + } + + private ByteBuffer fPayload; + + /** + * Initialize the payload. + */ + @Before + public void initialize() { + fPayload = ByteBuffer.allocate(75); + fPayload.order(ByteOrder.BIG_ENDIAN); + + // Values copied from wireshark + + // Bytes 0x01-0x10 + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x30); + fPayload.put((byte) 0x54); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x34); + fPayload.put((byte) 0x56); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0xE0); + fPayload.put((byte) 0xED); + fPayload.put((byte) 0x01); + fPayload.put((byte) 0x6E); + fPayload.put((byte) 0xBD); + fPayload.put((byte) 0x08); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x45); + fPayload.put((byte) 0x00); + + // Bytes 0x11-0x20 + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x3D); + fPayload.put((byte) 0x69); + fPayload.put((byte) 0xAA); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x80); + fPayload.put((byte) 0x11); + fPayload.put((byte) 0x4D); + fPayload.put((byte) 0xB2); + fPayload.put((byte) 0xC0); + fPayload.put((byte) 0xA8); + fPayload.put((byte) 0x01); + fPayload.put((byte) 0x02); + fPayload.put((byte) 0xC0); + fPayload.put((byte) 0xA8); + + // Bytes 0x21-0x30 + fPayload.put((byte) 0x01); + fPayload.put((byte) 0x01); + fPayload.put((byte) 0x0A); + fPayload.put((byte) 0x9F); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x35); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x29); + fPayload.put((byte) 0x4A); + fPayload.put((byte) 0x5E); + fPayload.put((byte) 0xED); + fPayload.put((byte) 0xd4); + fPayload.put((byte) 0x01); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x01); + + // Bytes 0x31-0x40 + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x03); + fPayload.put((byte) 0x66); + fPayload.put((byte) 0x74); + fPayload.put((byte) 0x70); + fPayload.put((byte) 0x07); + fPayload.put((byte) 0x65); + fPayload.put((byte) 0x63); + fPayload.put((byte) 0x69); + fPayload.put((byte) 0x74); + fPayload.put((byte) 0x65); + + // Bytes 0x41-0x4B + fPayload.put((byte) 0x6C); + fPayload.put((byte) 0x65); + fPayload.put((byte) 0x03); + fPayload.put((byte) 0x63); + fPayload.put((byte) 0x6F); + fPayload.put((byte) 0x6D); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x01); + fPayload.put((byte) 0x00); + fPayload.put((byte) 0x01); + + fPayload.flip(); + } + + /** + * Test that verify the correctness of the PcapPacket's methods. + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void CompletePcapPacketTest() throws IOException, BadPcapFileException, BadPacketException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; + assumeTrue(trace.exists()); + try (PcapFile file = new PcapFile(trace.getPath());) { + + file.seekPacket(36); + PcapPacket packet = file.parseNextPacket(); + if (packet == null) { + fail("CompletePcapPacketTest has failed!"); + return; + } + // Protocol Testing + assertEquals(PcapProtocol.PCAP, packet.getProtocol()); + assertTrue(packet.hasProtocol(PcapProtocol.PCAP)); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.TCP)); + + // Abstract methods Testing + assertTrue(packet.validate()); + assertEquals(86567859, packet.hashCode()); + assertFalse(packet.equals(null)); + assertFalse(packet.equals(file.parseNextPacket())); + + assertEquals(EXPECTED_FIELDS, packet.getFields()); + assertEquals(EXPECTED_TOSTRING, packet.toString()); + assertEquals("Frame 36: 75 bytes on wire, 75 bytes captured", packet.getLocalSummaryString()); + assertEquals("Source Port: 2719, Destination Port: 53", packet.getGlobalSummaryString()); + + assertEquals(new PcapEndpoint(packet, true), packet.getSourceEndpoint()); + assertEquals(new PcapEndpoint(packet, false), packet.getDestinationEndpoint()); + + ByteBuffer payload = packet.getPayload(); + if (payload == null) { + fail("CompletePcapPacketTest has failed!"); + return; + } + assertEquals(fPayload, payload.flip()); + + // Packet-specific methods Testing + assertEquals(36, packet.getIndex()); + assertEquals(75, packet.getOriginalLength()); + assertEquals(75, packet.getIncludedLength()); + assertEquals(1120469632829277L, packet.getTimestamp()); + assertFalse(packet.isTruncated()); + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/AllTests.java new file mode 100644 index 0000000000..201e83dc4d --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol.tcp; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * TCP test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + TCPPacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/TCPPacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/TCPPacketTest.java new file mode 100644 index 0000000000..2a197dd09b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/tcp/TCPPacketTest.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.tests.protocol.tcp; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.tcp.TCPEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.tcp.TCPPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +/** + * JUnit Class that tests the TCPPacket class and its method. + * + * @author Vincent Perot + */ +public class TCPPacketTest { + + private static final Map EXPECTED_FIELDS; + static { + EXPECTED_FIELDS = new LinkedHashMap<>(); + EXPECTED_FIELDS.put("Source Port", "18057"); + EXPECTED_FIELDS.put("Destination Port", "39611"); + EXPECTED_FIELDS.put("Sequence Number", "2575857510"); + EXPECTED_FIELDS.put("Acknowledgement Number", "1430532898"); + EXPECTED_FIELDS.put("Length", "24 bytes"); + EXPECTED_FIELDS.put("ECN-Nonce Flag", "true"); + EXPECTED_FIELDS.put("Congestion Window Reduced Flag", "false"); + EXPECTED_FIELDS.put("ECN-Echo Flag", "true"); + EXPECTED_FIELDS.put("Urgent Flag", "false"); + EXPECTED_FIELDS.put("ACK Flag", "true"); + EXPECTED_FIELDS.put("PSH Flag", "false"); + EXPECTED_FIELDS.put("RST Flag", "true"); + EXPECTED_FIELDS.put("SYN Flag", "false"); + EXPECTED_FIELDS.put("FIN Flag", "true"); + EXPECTED_FIELDS.put("Window Size Value", "4352"); + EXPECTED_FIELDS.put("Checksum", "0xffee"); + EXPECTED_FIELDS.put("Urgent Pointer", "0xddcc"); + EXPECTED_FIELDS.put("Options", "ad da bc cb"); + } + + private static final String EXPECTED_TOSTRING; + static { + StringBuilder sb = new StringBuilder(); + sb.append("Transmission Control Protocol, Source Port: 18057, Destination Port: 39611\n"); + sb.append("Sequence Number: 2575857510, Acknowledgment Number: 1430532898\n"); + sb.append("Header length: 24 bytes, Data length: 4\n"); + sb.append("Window size value: 4352, Urgent Pointer: 0xddcc\n"); + sb.append("Checksum: 0xffee\n"); + sb.append("Payload: 99 88 77 66"); + + EXPECTED_TOSTRING = sb.toString(); + } + + private ByteBuffer fPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fPacket = ByteBuffer.allocate(28); + fPacket.order(ByteOrder.BIG_ENDIAN); + + // Source Port + fPacket.put((byte) 0x46); + fPacket.put((byte) 0x89); + + // Destination Port + fPacket.put((byte) 0x9A); + fPacket.put((byte) 0xBB); + + // Sequence Number + fPacket.put((byte) 0x99); + fPacket.put((byte) 0x88); + fPacket.put((byte) 0x77); + fPacket.put((byte) 0x66); + + // Acknowledgment Number + fPacket.put((byte) 0x55); + fPacket.put((byte) 0x44); + fPacket.put((byte) 0x33); + fPacket.put((byte) 0x22); + + // Data Offset + Reserved + NS + fPacket.put((byte) 0x61); + + // Other flags + fPacket.put((byte) 0b01010101); + + // Window Size + fPacket.put((byte) 0x11); + fPacket.put((byte) 0x00); + + // Checksum + fPacket.put((byte) 0xFF); + fPacket.put((byte) 0xEE); + + // Urgent Pointer + fPacket.put((byte) 0xDD); + fPacket.put((byte) 0xCC); + + // Options - 4 bytes + fPacket.put((byte) 0xAD); + fPacket.put((byte) 0xDA); + fPacket.put((byte) 0xBC); + fPacket.put((byte) 0xCB); + + // Payload - 4 bytes + fPacket.put((byte) 0x99); + fPacket.put((byte) 0x88); + fPacket.put((byte) 0x77); + fPacket.put((byte) 0x66); + + fPacket.flip(); + } + + /** + * Test that verify the correctness of the TCPPacket's methods. + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void CompleteTCPPacketTest() throws BadPacketException, IOException, BadPcapFileException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer byteBuffer = fPacket; + if (byteBuffer == null) { + fail("CompleteTCPPacketTest has failed!"); + return; + } + TCPPacket packet = new TCPPacket(dummy, null, byteBuffer); + + // Protocol Testing + assertEquals(PcapProtocol.TCP, packet.getProtocol()); + assertTrue(packet.hasProtocol(PcapProtocol.TCP)); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.IPV4)); + + // Abstract methods Testing + assertTrue(packet.validate()); + assertEquals(-677046102, packet.hashCode()); + assertFalse(packet.equals(null)); + assertEquals(new TCPPacket(dummy, null, byteBuffer), packet); + + assertEquals(EXPECTED_FIELDS, packet.getFields()); + assertEquals(EXPECTED_TOSTRING, packet.toString()); + assertEquals("Src Port: 18057, Dst Port: 39611, Seq: 2575857510, Ack: 1430532898, Len: 24", packet.getLocalSummaryString()); + assertEquals("18057 > 39611 [ACK, FIN, RST, NS, ECE] Seq=2575857510 Ack=1430532898 Len=24", packet.getGlobalSummaryString()); + + assertEquals(new TCPEndpoint(packet, true), packet.getSourceEndpoint()); + assertEquals(new TCPEndpoint(packet, false), packet.getDestinationEndpoint()); + + fPacket.position(24); + byte[] payload = new byte[4]; + fPacket.get(payload); + assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); + + // Packet-specific methods Testing + assertEquals(0x4689, packet.getSourcePort()); + assertEquals(0x9ABB, packet.getDestinationPort()); + assertEquals(2575857510L, packet.getSequenceNumber()); + assertEquals(1430532898L, packet.getAcknowledgmentNumber()); + assertEquals(6, packet.getDataOffset()); + assertEquals(0, packet.getReservedField()); + assertEquals(true, packet.isNSFlagSet()); + assertEquals(false, packet.isCongestionWindowReducedFlagSet()); + assertEquals(true, packet.isECNEchoFlagSet()); + assertEquals(false, packet.isUrgentFlagSet()); + assertEquals(true, packet.isAcknowledgeFlagSet()); + assertEquals(false, packet.isPushFlagSet()); + assertEquals(true, packet.isResetFlagSet()); + assertEquals(false, packet.isSynchronizationFlagSet()); + assertEquals(true, packet.isFinalFlagSet()); + assertEquals(4352, packet.getWindowSize()); + assertEquals(65518, packet.getChecksum()); + assertEquals(56780, packet.getUrgentPointer()); + assertTrue(Arrays.equals(packet.getOptions(), Arrays.copyOfRange(fPacket.array(), 20, 24))); + + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/AllTests.java new file mode 100644 index 0000000000..13c541e103 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol.udp; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * UDP test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + UDPPacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/UDPPacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/UDPPacketTest.java new file mode 100644 index 0000000000..bb70c291a1 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/udp/UDPPacketTest.java @@ -0,0 +1,151 @@ +/******************************************************************************* + * 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.tests.protocol.udp; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Map; + +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.udp.UDPEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.udp.UDPPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * JUnit Class that tests the UDPPacket class and its method. + * + * @author Vincent Perot + */ +public class UDPPacketTest { + + private static final Map EXPECTED_FIELDS = ImmutableMap.of( + "Source Port", "18057", + "Destination Port", "39611", + "Length", "41452 bytes", + "Checksum", "0xfaaf" + ); + + private static final String EXPTECTED_TOSTRING; + static { + StringBuilder sb = new StringBuilder(); + sb.append("User Datagram Protocol, Source Port: 18057, Destination Port: 39611, Length: 41452, Checksum: 64175\n"); + sb.append("Payload: 99 88 77 66"); + + EXPTECTED_TOSTRING = sb.toString(); + } + + private ByteBuffer fPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fPacket = ByteBuffer.allocate(12); + fPacket.order(ByteOrder.BIG_ENDIAN); + + // Source Port + fPacket.put((byte) 0x46); + fPacket.put((byte) 0x89); + + // Destination Port + fPacket.put((byte) 0x9A); + fPacket.put((byte) 0xBB); + + // Total length - this is randomly chosen so that we verify that the + // packet handles wrong total length. + fPacket.put((byte) 0xA1); + fPacket.put((byte) 0xEC); + + // Checksum + fPacket.put((byte) 0xFA); + fPacket.put((byte) 0xAF); + + // Payload - 4 bytes + fPacket.put((byte) 0x99); + fPacket.put((byte) 0x88); + fPacket.put((byte) 0x77); + fPacket.put((byte) 0x66); + + fPacket.flip(); + } + + /** + * Test that verify the correctness of the UDPPacket's methods. + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + * @throws BadPacketException + * Thrown when a packet is erroneous. Fails the test. + */ + @Test + public void CompleteUDPPacketTest() throws IOException, BadPcapFileException, BadPacketException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer byteBuffer = fPacket; + if (byteBuffer == null) { + fail("CompleteUDPPacketTest has failed!"); + return; + } + UDPPacket packet = new UDPPacket(dummy, null, byteBuffer); + + // Protocol Testing + assertEquals(PcapProtocol.UDP, packet.getProtocol()); + assertTrue(packet.hasProtocol(PcapProtocol.UDP)); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.ETHERNET_II)); + + // Abstract methods Testing + assertTrue(packet.validate()); + assertEquals(473000225, packet.hashCode()); + assertFalse(packet.equals(null)); + assertEquals(new UDPPacket(dummy, null, byteBuffer), packet); + + assertEquals(EXPECTED_FIELDS, packet.getFields()); + assertEquals(EXPTECTED_TOSTRING, packet.toString()); + assertEquals("Src Port: 18057, Dst Port: 39611", packet.getLocalSummaryString()); + assertEquals("Source Port: 18057, Destination Port: 39611", packet.getGlobalSummaryString()); + + assertEquals(new UDPEndpoint(packet, true), packet.getSourceEndpoint()); + assertEquals(new UDPEndpoint(packet, false), packet.getDestinationEndpoint()); + + fPacket.position(8); + byte[] payload = new byte[4]; + fPacket.get(payload); + assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); + + // Packet-specific methods Testing + assertEquals(0x4689, packet.getSourcePort()); + assertEquals(0x9ABB, packet.getDestinationPort()); + assertEquals(0xA1EC, packet.getTotalLength()); + assertEquals(0xFAAF, packet.getChecksum()); + + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/AllTests.java new file mode 100644 index 0000000000..f33d53b7f4 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.protocol.unknown; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Unknown test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + UnknownPacketTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/UnknownPacketTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/UnknownPacketTest.java new file mode 100644 index 0000000000..8f0d28d39a --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/unknown/UnknownPacketTest.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * 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.tests.protocol.unknown; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Map; + +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * JUnit Class that tests the UnknownPacket class and its method. + * + * @author Vincent Perot + */ +public class UnknownPacketTest { + + private static final Map EXPECTED_FIELDS = ImmutableMap.of( + "Binary", "61", + "Character", "a" + ); + + private static final String fToString = "Payload: 61"; + + private ByteBuffer fPacket; + + /** + * Initialize the packet. + */ + @Before + public void initialize() { + fPacket = ByteBuffer.allocate(1); + fPacket.order(ByteOrder.BIG_ENDIAN); + + // Payload - 1 byte + fPacket.put((byte) 97); + + fPacket.flip(); + } + + /** + * Test that verify the correctness of the UnknownPacket's methods. + * @throws BadPcapFileException + * Thrown when the file is erroneous. Fails the test. + * @throws IOException + * Thrown when an IO error occurs. Fails the test. + */ + @Test + public void CompleteUnknownPacketTest() throws IOException, BadPcapFileException { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + try (PcapFile dummy = new PcapFile(trace.getPath())) { + ByteBuffer byteBuffer = fPacket; + if (byteBuffer == null) { + fail("CompleteUnknownPacketTest has failed!"); + return; + } + UnknownPacket packet = new UnknownPacket(dummy, null, byteBuffer); + + // Protocol Testing + assertEquals(PcapProtocol.UNKNOWN, packet.getProtocol()); + assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); + assertFalse(packet.hasProtocol(PcapProtocol.UDP)); + + // Abstract methods Testing + assertTrue(packet.validate()); + assertEquals(1089, packet.hashCode()); + assertFalse(packet.equals(null)); + assertEquals(new UnknownPacket(dummy, null, byteBuffer), packet); + + assertEquals(EXPECTED_FIELDS, packet.getFields()); + assertEquals(fToString, packet.toString()); + assertEquals("Len: 1 bytes", packet.getLocalSummaryString()); + assertEquals("Data: 1 bytes", packet.getGlobalSummaryString()); + // TODO take care of plural form. + + // Unknown Endpoints are never equal! + assertFalse(packet.getSourceEndpoint().equals(new UnknownEndpoint(packet, true))); + assertFalse(packet.getDestinationEndpoint().equals(new UnknownEndpoint(packet, false))); + + fPacket.position(0); + byte[] payload = new byte[1]; + fPacket.get(payload); + ByteBuffer payloadBB = ByteBuffer.wrap(payload); + payloadBB.flip(); + + assertEquals(payloadBB, packet.getPayload()); + + // Packet-specific methods Testing + // None + + } + } +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/AllTests.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/AllTests.java new file mode 100644 index 0000000000..df90513f7b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/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: + * Vincent Perot - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.pcap.core.tests.stream; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Stream test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + StreamBuildTest.class +}) +public class AllTests { + +} diff --git a/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java new file mode 100644 index 0000000000..182c150fd5 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * 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.tests.stream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.stream.PacketStream; +import org.eclipse.linuxtools.internal.pcap.core.stream.PacketStreamBuilder; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.pcap.core.tests.shared.PcapTestTrace; +import org.junit.Test; + +/** + * JUnit Class that tests whether packet streams are built correctly. + * + * @author Vincent Perot + */ +public class StreamBuildTest { + + private static final double DELTA = 0.001; + + /** + * Test that verify that stream building is done correctly. + */ + @Test + public void StreamBuildingTest() { + PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; + assumeTrue(trace.exists()); + + try { + // Test Ethernet II stream + PacketStreamBuilder builder = new PacketStreamBuilder(PcapProtocol.ETHERNET_II); + builder.parsePcapFile(trace.getPath()); + assertEquals(PcapProtocol.ETHERNET_II, builder.getProtocol()); + // Should do one loop only, so hardcoded values are okay. + for (PacketStream stream : builder.getStreams()) { + assertEquals("Stream eth.0, Number of Packets: 43\n", stream.toString()); + assertEquals(43, stream.getNbPackets()); + assertEquals(25091, stream.getNbBytes()); + assertEquals(20, stream.getNbPacketsAtoB()); + assertEquals(2323, stream.getNbBytesAtoB()); + assertEquals(23, stream.getNbPacketsBtoA()); + assertEquals(22768, stream.getNbBytesBtoA()); + assertEquals(1084443427311224000L, stream.getStartTime()); + assertEquals(1084443457704928000L, stream.getStopTime()); + assertEquals(30.393704, stream.getDuration(), DELTA); + assertEquals(76.43030280218561, stream.getBPSAtoB(), DELTA); + assertEquals(749.1025114938278, stream.getBPSBtoA(), DELTA); + } + + // Test TCP streams and other constructor + builder = new PacketStreamBuilder(PcapProtocol.TCP); + builder.parsePcapFile(trace.getPath()); + assertEquals(PcapProtocol.TCP, builder.getProtocol()); + + PacketStream stream = builder.getStream(0); + if (stream == null) { + fail("StreamBuildingTest has failed!"); + return; + } + assertEquals(PcapProtocol.TCP, stream.getProtocol()); + assertEquals(0, stream.getID()); + assertEquals("tcp.0", stream.getUniqueID()); + assertEquals(34, stream.getNbPackets()); + assertEquals(20695, stream.getNbBytes()); + assertEquals(16, stream.getNbPacketsAtoB()); + assertEquals(1351, stream.getNbBytesAtoB()); + assertEquals(18, stream.getNbPacketsBtoA()); + assertEquals(19344, stream.getNbBytesBtoA()); + assertEquals(1084443427311224000L, stream.getStartTime()); + assertEquals(1084443457704928000L, stream.getStopTime()); + assertEquals(30.393704, stream.getDuration(), DELTA); + assertEquals(44.449995301658525, stream.getBPSAtoB(), DELTA); + assertEquals(636.4476011216008, stream.getBPSBtoA(), DELTA); + + stream = builder.getStream(1); + if (stream == null) { + fail("StreamBuildingTest has failed!"); + return; + } + assertEquals(PcapProtocol.TCP, stream.getProtocol()); + assertEquals(1, stream.getID()); + assertEquals("tcp.1", stream.getUniqueID()); + assertEquals(7, stream.getNbPackets()); + assertEquals(4119, stream.getNbBytes()); + assertEquals(3, stream.getNbPacketsAtoB()); + assertEquals(883, stream.getNbBytesAtoB()); + assertEquals(4, stream.getNbPacketsBtoA()); + assertEquals(3236, stream.getNbBytesBtoA()); + assertEquals(1084443430295515000L, stream.getStartTime()); + assertEquals(1084443432088092000L, stream.getStopTime()); + assertEquals(1.792577, stream.getDuration(), DELTA); + assertEquals(492.58692932019096, stream.getBPSAtoB(), DELTA); + assertEquals(1805.2223140205413, stream.getBPSBtoA(), DELTA); + + builder.clear(); + assertEquals(0, builder.getNbStreams()); + } catch (IOException | BadPcapFileException e) { + fail("StreamBuildingTest has failed!"); + } + + } +} diff --git a/org.eclipse.tracecompass.pcap.core/.classpath b/org.eclipse.tracecompass.pcap.core/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.eclipse.tracecompass.pcap.core/.project b/org.eclipse.tracecompass.pcap.core/.project new file mode 100644 index 0000000000..1574fd6acb --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/.project @@ -0,0 +1,34 @@ + + + org.eclipse.tracecompass.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.tracecompass.pcap.core/.settings/org.eclipse.core.resources.prefs b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..5a0ad22d2a --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..9f3662cd78 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,394 @@ +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.methodParameters=do not generate +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=ignore +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.tracecompass.pcap.core/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..4fd0c7006a --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core/.settings/org.eclipse.pde.api.tools.prefs b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000000..acc3abd47c --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core/.settings/org.eclipse.pde.prefs b/org.eclipse.tracecompass.pcap.core/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..d92b94fd4b --- /dev/null +++ b/org.eclipse.tracecompass.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=1 +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.tracecompass.pcap.core/META-INF/MANIFEST.MF b/org.eclipse.tracecompass.pcap.core/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..bb5969c244 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-Vendor: %Bundle-Vendor +Bundle-Version: 1.0.0.qualifier +Bundle-Localization: plugin +Bundle-SymbolicName: org.eclipse.tracecompass.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.tracecompass.pcap.core.tests", + org.eclipse.linuxtools.internal.pcap.core.endpoint;x-friends:="org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.filter;x-internal:=true, + org.eclipse.linuxtools.internal.pcap.core.packet;x-friends:="org.eclipse.tracecompass.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.protocol;x-friends:="org.eclipse.tracecompass.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2;x-friends:="org.eclipse.tracecompass.pcap.core.tests", + org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4;x-friends:="org.eclipse.tracecompass.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.protocol.pcap;x-friends:="org.eclipse.tracecompass.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.protocol.tcp;x-friends:="org.eclipse.tracecompass.pcap.core.tests", + org.eclipse.linuxtools.internal.pcap.core.protocol.udp;x-friends:="org.eclipse.tracecompass.pcap.core.tests", + org.eclipse.linuxtools.internal.pcap.core.protocol.unknown;x-friends:="org.eclipse.tracecompass.pcap.core.tests", + org.eclipse.linuxtools.internal.pcap.core.stream;x-friends:="org.eclipse.tracecompass.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.trace;x-friends:="org.eclipse.tracecompass.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core.tests,org.eclipse.linuxtools.tmf.pcap.core", + org.eclipse.linuxtools.internal.pcap.core.util;x-friends:="org.eclipse.linuxtools.tmf.pcap.core" +Import-Package: com.google.common.collect, + com.google.common.math diff --git a/org.eclipse.tracecompass.pcap.core/about.html b/org.eclipse.tracecompass.pcap.core/about.html new file mode 100644 index 0000000000..28737f60b7 --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core/build.properties b/org.eclipse.tracecompass.pcap.core/build.properties new file mode 100644 index 0000000000..857bf1e800 --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core/plugin.properties b/org.eclipse.tracecompass.pcap.core/plugin.properties new file mode 100644 index 0000000000..49400fc3ad --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/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 +############################################################################### + +Bundle-Vendor = Eclipse Trace Compass +Bundle-Name = Trace Compass Pcap Parser Core Plug-in + diff --git a/org.eclipse.tracecompass.pcap.core/pom.xml b/org.eclipse.tracecompass.pcap.core/pom.xml new file mode 100644 index 0000000000..c3ab63b08c --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + + org.eclipse.tracecompass + org.eclipse.tracecompass + 3.2.0-SNAPSHOT + + + org.eclipse.tracecompass.pcap.core + 1.0.0-SNAPSHOT + eclipse-plugin + + Trace Compass Pcap Parser Core Plug-in + + + + + org.eclipse.tycho + tycho-source-plugin + + + + + org.eclipse.tracecompass + diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/Activator.java new file mode 100644 index 0000000000..885adc1726 --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpoint.java new file mode 100644 index 0000000000..79fdf72ddf --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.endpoint; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.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) { + 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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpointPair.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/ProtocolEndpointPair.java new file mode 100644 index 0000000000..15dd90cd2f --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.endpoint; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/endpoint/package-info.java new file mode 100644 index 0000000000..c68f342be7 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.endpoint; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/IPacketFilter.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/IPacketFilter.java new file mode 100644 index 0000000000..457fa7fc91 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.filter; + +import org.eclipse.linuxtools.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/PacketFilterByProtocol.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/PacketFilterByProtocol.java new file mode 100644 index 0000000000..fb2eb394dc --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.filter; + +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; + +/** + * 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 PcapProtocol fProtocol; + + /** + * Constructor of the PacketFilterByProtocol class. + * + * @param protocol + * The protocol that the incoming packets must contain. + */ + public PacketFilterByProtocol(PcapProtocol 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 PcapProtocol getProtocol() { + return fProtocol; + } + +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/filter/package-info.java new file mode 100644 index 0000000000..d5e6b615bf --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.filter; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/package-info.java new file mode 100644 index 0000000000..495502c7f8 --- /dev/null +++ b/org.eclipse.tracecompass.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/BadPacketException.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/BadPacketException.java new file mode 100644 index 0000000000..9db396ae67 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/Packet.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/Packet.java new file mode 100644 index 0000000000..e499ae7bd9 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/Packet.java @@ -0,0 +1,297 @@ +/******************************************************************************* + * 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.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.internal.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.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 PcapProtocol 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, PcapProtocol 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 PcapProtocol 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(PcapProtocol 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(PcapProtocol 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() != PcapProtocol.UNKNOWN) { + Packet childPacket = packet.getChildPacket(); + if (childPacket == null || childPacket.getProtocol() == PcapProtocol.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/packet/package-info.java new file mode 100644 index 0000000000..9edaef996b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.packet; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/PcapProtocol.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/PcapProtocol.java new file mode 100644 index 0000000000..d810dbf12c --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/PcapProtocol.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * 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.protocol; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Enumeration used for describing the different known protocols. + * + * @author Vincent Perot + */ +public enum PcapProtocol { + + // Layer 0 + /** + * The Pcap Protocol is not a real protocol but is used as an helper to + * generate Pcap packets. + */ + PCAP("Packet Capture", "pcap", Layer.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", Layer.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", Layer.LAYER_3, true), //$NON-NLS-1$ //$NON-NLS-2$ + + // Layer 4 + /** + * The description of the Transmission Control Protocol. + */ + TCP("Transmission Control Protocol", "tcp", Layer.LAYER_4, true), //$NON-NLS-1$ //$NON-NLS-2$ + /** + * The description of the User Datagram Protocol. + */ + UDP("User Datagram Protocol", "udp", Layer.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", "???", Layer.LAYER_7, false); //$NON-NLS-1$ //$NON-NLS-2$ + + + /** + * Enum that lists constants related to protocols/layers. + * + * See http://en.wikipedia.org/wiki/OSI_model#Description_of_OSI_layers. + * + * @author Vincent Perot + */ + public static enum Layer { + + /** + * Layer 0. This layer is not an OSI layer but is used as an helper to store + * the pseudo-protocol PCAP. + */ + LAYER_0, + + /** Layer 1 of the OSI model */ + LAYER_1, + + /** Layer 2 of the OSI model */ + LAYER_2, + + /** Layer 3 of the OSI model */ + LAYER_3, + + /** Layer 4 of the OSI model */ + LAYER_4, + + /** Layer 5 of the OSI model */ + LAYER_5, + + /** Layer 6 of the OSI model */ + LAYER_6, + + /** Layer 7 of the OSI model */ + LAYER_7; + } + + + // Fields + private final String fName; + private final String fShortName; + private final Layer fLayer; + private final boolean fSupportsStream; + + private PcapProtocol(String name, String shortName, Layer 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 Layer 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 Collection getProtocolsOnLayer(Layer layer) { + List protocolsOnLayer = new ArrayList<>(); + for (PcapProtocol p : PcapProtocol.values()) { + if (p.getLayer() == layer) { + protocolsOnLayer.add(p); + } + } + return protocolsOnLayer; + } +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIEndpoint.java new file mode 100644 index 0000000000..912343c890 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.ethernet2; + +import java.util.Arrays; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.internal.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().equals(EMPTY_STRING) ? + ConversionHelper.toMacAddress(fMacAddress) : + endpoint.toString() + '/' + ConversionHelper.toMacAddress(fMacAddress)); + + } +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java new file mode 100644 index 0000000000..d9f95edd37 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java @@ -0,0 +1,313 @@ +/******************************************************************************* + * 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.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.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ipv4.IPv4Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.internal.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; + + /* We store MAC addresses as byte arrays since + * there is no standard java class to store them. */ + 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, PcapProtocol.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() { + @SuppressWarnings("null") + @NonNull byte[] mac = Arrays.copyOf(fSourceMacAddress, fSourceMacAddress.length); + return mac; + } + + /** + * Getter method for the destination MAC Address. + * + * @return The destination MAC address. + */ + public byte[] getDestinationMacAddress() { + @SuppressWarnings("null") + @NonNull byte[] mac = Arrays.copyOf(fDestinationMacAddress, fDestinationMacAddress.length); + return mac; + } + + /** + * 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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIValues.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/EthernetIIValues.java new file mode 100644 index 0000000000..42804932db --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ethernet2/package-info.java new file mode 100644 index 0000000000..1dfef35d1e --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.ethernet2; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java new file mode 100644 index 0000000000..85668b2447 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * 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.protocol.ipv4; + +import java.net.Inet4Address; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint; + +/** + * 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 Inet4Address 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 + fIPAddress.hashCode(); + 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 = fIPAddress.equals(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) { + @SuppressWarnings("null") + @NonNull String ret = fIPAddress.getHostAddress(); + return ret; + } + return endpoint.toString() + '/' + fIPAddress.getHostAddress(); + } + +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Packet.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Packet.java new file mode 100644 index 0000000000..fc804639c1 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Packet.java @@ -0,0 +1,651 @@ +/******************************************************************************* + * 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.protocol.ipv4; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.UnknownHostException; +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.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.tcp.TCPPacket; +import org.eclipse.linuxtools.internal.pcap.core.protocol.udp.UDPPacket; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.internal.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 Inet4Address fSourceIpAddress; + private final Inet4Address 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, PcapProtocol.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); + int msb = ((storage & 0b00011111) << 8); + int lsb = ConversionHelper.unsignedByteToInt(packet.get()); + fFragmentOffset = msb + lsb; + + fTimeToLive = ConversionHelper.unsignedByteToInt(packet.get()); + fIpDatagramProtocol = ConversionHelper.unsignedByteToInt(packet.get()); + fHeaderChecksum = ConversionHelper.unsignedShortToInt(packet.getShort()); + + byte[] source = new byte[IPv4Values.IP_ADDRESS_SIZE]; + byte[] destination = new byte[IPv4Values.IP_ADDRESS_SIZE]; + packet.get(source); + packet.get(destination); + + try { + @SuppressWarnings("null") + @NonNull Inet4Address sourceIP = (Inet4Address) InetAddress.getByAddress(source); + @SuppressWarnings("null") + @NonNull Inet4Address destinationIP = (Inet4Address) InetAddress.getByAddress(destination); + fSourceIpAddress = sourceIP; + fDestinationIpAddress = destinationIP; + } catch (UnknownHostException e) { + throw new BadPacketException("The IP Address size is not valid!"); //$NON-NLS-1$ + } + + // 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: " + fSourceIpAddress.getHostAddress() + ", Destination: " + fDestinationIpAddress.getHostAddress() + //$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 Inet4Address getSourceIpAddress() { + return fSourceIpAddress; + } + + /** + * Getter method that returns the destination IP address. + * + * @return The destination IP address, as a byte array in big-endian. + */ + public Inet4Address 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", fSourceIpAddress.getHostAddress()) //$NON-NLS-1$ + .put("Destination IP Address", fDestinationIpAddress.getHostAddress()); //$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: " + fSourceIpAddress.getHostAddress() + " , Dst: " + fDestinationIpAddress.getHostAddress(); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected String getSignificationString() { + StringBuilder sb = new StringBuilder(); + sb.append(fSourceIpAddress.getHostAddress()) + .append(" > ") //$NON-NLS-1$ + .append(fDestinationIpAddress.getHostAddress()); + + 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 + fDestinationIpAddress.hashCode(); + 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 + fSourceIpAddress.hashCode(); + 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 (!(fDestinationIpAddress.equals(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 (!(fSourceIpAddress.equals(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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Values.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/IPv4Values.java new file mode 100644 index 0000000000..3e4e157241 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/ipv4/package-info.java new file mode 100644 index 0000000000..b8484b6472 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.ipv4; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/package-info.java new file mode 100644 index 0000000000..eea3ac9296 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapEndpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapEndpoint.java new file mode 100644 index 0000000000..8662c76e30 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.pcap; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapPacket.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/PcapPacket.java new file mode 100644 index 0000000000..79945bae8a --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIPacket; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFileValues; +import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.internal.pcap.core.util.LinkTypeHelper; +import org.eclipse.linuxtools.internal.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, PcapProtocol.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/pcap/package-info.java new file mode 100644 index 0000000000..173f3a9557 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.pcap; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPEndpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPEndpoint.java new file mode 100644 index 0000000000..97b291cdf3 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.tcp; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPPacket.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPPacket.java new file mode 100644 index 0000000000..7e5823e2f6 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPPacket.java @@ -0,0 +1,702 @@ +/******************************************************************************* + * 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.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.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.internal.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, PcapProtocol.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); + } + + sb.append(" Len=") //$NON-NLS-1$ + .append((fDataOffset * TCPValues.BLOCK_SIZE)); + + 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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPValues.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/TCPValues.java new file mode 100644 index 0000000000..fc1e389a73 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/tcp/package-info.java new file mode 100644 index 0000000000..2f7a7fdc99 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.tcp; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPEndpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPEndpoint.java new file mode 100644 index 0000000000..a55416f933 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.udp; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPPacket.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/UDPPacket.java new file mode 100644 index 0000000000..99d5c98147 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.unknown.UnknownPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.internal.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, PcapProtocol.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/udp/package-info.java new file mode 100644 index 0000000000..a55251124b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.udp; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownEndpoint.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownEndpoint.java new file mode 100644 index 0000000000..a731bd5d0f --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownEndpoint.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.protocol.unknown; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.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) { + if (this == obj) { + return true; + } + return false; + } +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownPacket.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/UnknownPacket.java new file mode 100644 index 0000000000..b4384eb1be --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.trace.PcapFile; +import org.eclipse.linuxtools.internal.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, PcapProtocol.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/protocol/unknown/package-info.java new file mode 100644 index 0000000000..8478b55a88 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.protocol.unknown; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStream.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStream.java new file mode 100644 index 0000000000..2036a01bc3 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStream.java @@ -0,0 +1,269 @@ +/******************************************************************************* + * 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.stream; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpointPair; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; + +import com.google.common.math.DoubleMath; + +// 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 double SECOND_TO_NANOSECOND = 1000000000.0; + private static final double DELTA = 0.000000001; + private final PcapProtocol fProtocol; + private final int fId; + private final ProtocolEndpointPair fEndpointPair; + + private long fNbPacketsAtoB; + private long fNbPacketsBtoA; + private long fNbBytesAtoB; + private long fNbBytesBtoA; + private long fStartTime; + private long fEndTime; + + /** + * 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(PcapProtocol protocol, int id, ProtocolEndpointPair endpointPair) { + fProtocol = protocol; + fId = id; + fEndpointPair = endpointPair; + fNbPacketsAtoB = 0; + fNbPacketsBtoA = 0; + fNbBytesAtoB = 0; + fNbBytesBtoA = 0; + fStartTime = Long.MAX_VALUE; + fEndTime = Long.MIN_VALUE; + } + + /** + * Add a packet to the stream. + * + * @param packet + * The packet that must be added. + */ + synchronized void add(PcapPacket packet) { + + Packet newPacket = packet.getPacket(fProtocol); + if (newPacket == null) { + return; + } + + // Update packet and byte number + if (fEndpointPair.getFirstEndpoint().equals(newPacket.getSourceEndpoint()) && + fEndpointPair.getSecondEndpoint().equals(newPacket.getDestinationEndpoint())) { + fNbPacketsAtoB++; + fNbBytesAtoB += packet.getOriginalLength(); + } else if (fEndpointPair.getFirstEndpoint().equals(newPacket.getDestinationEndpoint()) && + fEndpointPair.getSecondEndpoint().equals(newPacket.getSourceEndpoint())) { + fNbPacketsBtoA++; + fNbBytesBtoA += packet.getOriginalLength(); + } else { + throw new IllegalStateException(); + } + + // Update start and stop time + // Stream timestamp is ALWAYS in nanoseconds. + long timestamp; + switch (packet.getTimestampScale()) { + case MICROSECOND: + timestamp = packet.getTimestamp() * 1000; + break; + case NANOSECOND: + timestamp = packet.getTimestamp(); + break; + default: + throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$ + } + fStartTime = Math.min(fStartTime, timestamp); + fEndTime = Math.max(fEndTime, timestamp); + } + + /** + * Get the Protocol of this stream. + * + * @return The protocol of this stream. + */ + public PcapProtocol 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: " + getNbPackets() + "\n"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + + @SuppressWarnings("null") + @NonNull String string = sb.toString(); + return string; + + } + + /** + * Get the number of packets going from the first endpoint to the second. + * + * @return The number of packets from A to B. + */ + public synchronized long getNbPacketsAtoB() { + return fNbPacketsAtoB; + } + + /** + * Get the number of packets going from the second endpoint to the first. + * + * @return The number of packets from B to A. + */ + public synchronized long getNbPacketsBtoA() { + return fNbPacketsBtoA; + } + + /** + * Get the total number of packets in this stream. + * + * @return The total number of packets. + */ + public synchronized long getNbPackets() { + return fNbPacketsAtoB + fNbPacketsBtoA; + } + + /** + * Get the number of bytes going from the first endpoint to the second. + * + * @return The number of bytes from A to B. + */ + public synchronized long getNbBytesAtoB() { + return fNbBytesAtoB; + } + + /** + * Get the number of bytes going from the second endpoint to the first. + * + * @return The number of bytes from B to A. + */ + public synchronized long getNbBytesBtoA() { + return fNbBytesBtoA; + } + + /** + * Get the total number of bytes in this stream. + * + * @return The total number of bytes. + */ + public synchronized long getNbBytes() { + return fNbBytesAtoB + fNbBytesBtoA; + } + + /** + * Get the start time of this stream, in nanoseconds relative to epoch. + * + * @return The start time. + */ + public synchronized long getStartTime() { + return fStartTime; + } + + /** + * Get the stop time of this stream, in nanoseconds relative to epoch. + * + * @return The stop time. + */ + public synchronized long getStopTime() { + return fEndTime; + } + + /** + * Get the duration of this stream, in seconds + * + * @return The duration of this stream. + */ + public synchronized double getDuration() { + return (fEndTime - fStartTime) / SECOND_TO_NANOSECOND; + } + + /** + * Get the the average byte per second from A to B. + * + * @return the average byte per second from A to B. + */ + public synchronized double getBPSAtoB() { + if (DoubleMath.fuzzyEquals(getDuration(), 0, DELTA)) { + return 0; + } + return fNbBytesAtoB / getDuration(); + } + + /** + * Get the the average byte per second from B to A. + * + * @return the average byte per second from B to A. + */ + public synchronized double getBPSBtoA() { + if (DoubleMath.fuzzyEquals(getDuration(), 0, DELTA)) { + return 0; + } + return fNbBytesBtoA / getDuration(); + } + +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStreamBuilder.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStreamBuilder.java new file mode 100644 index 0000000000..6780b3d465 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/PacketStreamBuilder.java @@ -0,0 +1,182 @@ +/******************************************************************************* + * 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.stream; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint; +import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpointPair; +import org.eclipse.linuxtools.internal.pcap.core.filter.IPacketFilter; +import org.eclipse.linuxtools.internal.pcap.core.filter.PacketFilterByProtocol; +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; +import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; +import org.eclipse.linuxtools.internal.pcap.core.trace.BadPcapFileException; +import org.eclipse.linuxtools.internal.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 PcapProtocol fProtocol; + + private final Map fStreams; + private final Map fIDs; + private int fCurrentId; + + /** + * Main constructor. + * + * @param protocol + * The protocol of the builder. + */ + public PacketStreamBuilder(PcapProtocol 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 PcapProtocol 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 filePath + * The file path. + * @throws IOException + * When an IO error occurs. + * @throws BadPcapFileException + * When the PcapFile is not valid. + */ + public synchronized void parsePcapFile(Path filePath) throws IOException, BadPcapFileException { + try (PcapFile pcapFile = new PcapFile(filePath);) { + 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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/stream/package-info.java new file mode 100644 index 0000000000..e9904b7a8b --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.stream; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/BadPcapFileException.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/BadPcapFileException.java new file mode 100644 index 0000000000..dbf825d343 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFile.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFile.java new file mode 100644 index 0000000000..2c29c8afde --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFile.java @@ -0,0 +1,401 @@ +/******************************************************************************* + * 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.trace; + +import java.io.Closeable; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.SeekableByteChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.TreeMap; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.linuxtools.internal.pcap.core.packet.BadPacketException; +import org.eclipse.linuxtools.internal.pcap.core.protocol.pcap.PcapPacket; +import org.eclipse.linuxtools.internal.pcap.core.util.ConversionHelper; +import org.eclipse.linuxtools.internal.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 Path fPcapFilePath; + private final ByteOrder fByteOrder; + private final SeekableByteChannel fFileChannel; + 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(Path filePath) throws BadPcapFileException, IOException { + + fFileIndex = new TreeMap<>(); + fCurrentRank = 0; + fTotalNumberPackets = -1; + fPcapFilePath = filePath; + + // Check file validity + if (Files.notExists(fPcapFilePath) || !Files.isRegularFile(fPcapFilePath) || + Files.size(fPcapFilePath) < PcapFileValues.GLOBAL_HEADER_SIZE) { + throw new BadPcapFileException("Bad Pcap File."); //$NON-NLS-1$ + } + + if (!Files.isReadable(fPcapFilePath)) { + throw new BadPcapFileException("File is not readable."); //$NON-NLS-1$ + } + + // File is not empty. Try to open. + @SuppressWarnings("null") + @NonNull SeekableByteChannel channel = Files.newByteChannel(fPcapFilePath); + fFileChannel = channel; + + // 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; + 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 Path 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(); + } + +} diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFileValues.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/PcapFileValues.java new file mode 100644 index 0000000000..169a0c388d --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/trace/package-info.java new file mode 100644 index 0000000000..1b5ed9ac32 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.trace; \ No newline at end of file diff --git a/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/ConversionHelper.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/ConversionHelper.java new file mode 100644 index 0000000000..7757dbb122 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/ConversionHelper.java @@ -0,0 +1,184 @@ +/******************************************************************************* + * 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.util; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.linuxtools.internal.pcap.core.protocol.ethernet2.EthernetIIValues; + +/** + * Class for helping with the conversion of data. + * + * @author Vincent Perot + */ +public final class ConversionHelper { + + @SuppressWarnings("null") + private static final @NonNull 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 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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/EthertypeHelper.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/EthertypeHelper.java new file mode 100644 index 0000000000..8f5f81aa69 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/IPProtocolNumberHelper.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/IPProtocolNumberHelper.java new file mode 100644 index 0000000000..5a3a875dc2 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.util; + +import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; + +// 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 PcapProtocol.TCP.getName(); + case PROTOCOL_NUMBER_UDP: + return PcapProtocol.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/LinkTypeHelper.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/LinkTypeHelper.java new file mode 100644 index 0000000000..4241864520 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/PcapTimestampScale.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/PcapTimestampScale.java new file mode 100644 index 0000000000..9dc04fcc39 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.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.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/package-info.java b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/pcap/core/util/package-info.java new file mode 100644 index 0000000000..da154e4298 --- /dev/null +++ b/org.eclipse.tracecompass.pcap.core/src/org/eclipse/linuxtools/internal/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.internal.pcap.core.util; \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7326abf78c..0b4a55b07f 100644 --- a/pom.xml +++ b/pom.xml @@ -109,8 +109,8 @@ org.eclipse.tracecompass.ctf.parser org.eclipse.tracecompass.ctf.parser.tests - org.eclipse.linuxtools.pcap.core - org.eclipse.linuxtools.pcap.core.tests + org.eclipse.tracecompass.pcap.core + org.eclipse.tracecompass.pcap.core.tests org.eclipse.linuxtools.statesystem.core org.eclipse.linuxtools.statesystem.core.tests