diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /epan/dissectors/asn1/acse | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/asn1/acse')
-rw-r--r-- | epan/dissectors/asn1/acse/CMakeLists.txt | 43 | ||||
-rw-r--r-- | epan/dissectors/asn1/acse/acse.asn | 435 | ||||
-rw-r--r-- | epan/dissectors/asn1/acse/acse.cnf | 173 | ||||
-rw-r--r-- | epan/dissectors/asn1/acse/packet-acse-template.c | 283 | ||||
-rw-r--r-- | epan/dissectors/asn1/acse/packet-acse-template.h | 19 |
5 files changed, 953 insertions, 0 deletions
diff --git a/epan/dissectors/asn1/acse/CMakeLists.txt b/epan/dissectors/asn1/acse/CMakeLists.txt new file mode 100644 index 00000000..b532cf40 --- /dev/null +++ b/epan/dissectors/asn1/acse/CMakeLists.txt @@ -0,0 +1,43 @@ +# CMakeLists.txt +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# SPDX-License-Identifier: GPL-2.0-or-later +# + +set( PROTOCOL_NAME acse ) + +set( PROTO_OPT ) + +set( EXPORT_FILES + ${PROTOCOL_NAME}-exp.cnf +) + +set( EXT_ASN_FILE_LIST +) + +set( ASN_FILE_LIST + ${PROTOCOL_NAME}.asn +) + +set( EXTRA_DIST + ${ASN_FILE_LIST} + packet-${PROTOCOL_NAME}-template.c + packet-${PROTOCOL_NAME}-template.h + ${PROTOCOL_NAME}.cnf +) + +set( SRC_FILES + ${EXTRA_DIST} + ${EXT_ASN_FILE_LIST} +) + +set( A2W_FLAGS -b -C ) + +set( EXTRA_CNF + "${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf" +) + +ASN2WRS() diff --git a/epan/dissectors/asn1/acse/acse.asn b/epan/dissectors/asn1/acse/acse.asn new file mode 100644 index 00000000..968026d1 --- /dev/null +++ b/epan/dissectors/asn1/acse/acse.asn @@ -0,0 +1,435 @@ +-- ACSE definition from +-- http://www.itu.int/ITU-T/asn1/database/itu-t/x/x227bis/1998/ACSE-1.html +-- and modified to pass through asn2wrs +-- +-- +-- Module ACSE-1 (X.227bis:09/1998) +ACSE-1 {joint-iso-itu-t association-control(2) modules(0) acse1(1) version1(1)} +-- ACSE-1 refers to ACSE version 1 +DEFINITIONS ::= +BEGIN + +IMPORTS + Name, RelativeDistinguishedName + FROM InformationFramework {joint-iso-itu-t ds(5) module(1) + informationFramework(1) 3}; + +-- The data types Name and RelativeDistinguishedName are imported from +-- ITU-T Rec. X.501 | ISO/IEC 9594-2. + + +-- Workaround for bug in asn2wrs in the .cnf file +-- to handle the lack of support for tagged assignments. +-- remove that workaround once asn2wrs learns how to handle +-- tagged assignments. +EXTERNALt ::= [UNIVERSAL 8] IMPLICIT SEQUENCE + { + direct-reference OBJECT IDENTIFIER OPTIONAL, + indirect-reference INTEGER OPTIONAL, + data-value-descriptor ObjectDescriptor OPTIONAL, + encoding CHOICE + {single-ASN1-type [0] ANY, + octet-aligned [1] IMPLICIT OCTET STRING, + arbitrary [2] IMPLICIT BIT STRING} + } + +-- object identifier assignments +acse-as-id OBJECT IDENTIFIER ::= + {joint-iso-itu-t association-control(2) abstract-syntax(1) apdus(0) + version1(1)} + +-- may be used to reference the abstract syntax of the ACSE APDUs. +aCSE-id OBJECT IDENTIFIER ::= + {joint-iso-itu-t association-control(2) ase-id(3) acse-ase(1) version(1)} + +-- may be used to identify the Association Control ASE. +-- top level CHOICE +ACSE-apdu ::= CHOICE { +--asn2wrs bug +-- aarq AARQ-apdu, + aarq [APPLICATION 0] IMPLICIT AARQ-apdu, +--asn2wrs bug +-- aare AARE-apdu, + aare [APPLICATION 1] IMPLICIT AARE-apdu, +--asn2wrs bug +-- rlrq RLRQ-apdu, + rlrq [APPLICATION 2] IMPLICIT RLRQ-apdu, +--asn2wrs bug +-- rlre RLRE-apdu, + rlre [APPLICATION 3] IMPLICIT RLRE-apdu, +--asn2wrs bug +-- abrt ABRT-apdu, + abrt [APPLICATION 4] IMPLICIT ABRT-apdu, + ..., + -- Extensions for higher level association FU +--asn2wrs bug +-- adt A-DT-apdu, + adt [APPLICATION 5] IMPLICIT A-DT-apdu, +--asn2wrs bug +-- acrq ACRQ-apdu, + acrq [APPLICATION 6] IMPLICIT ACRQ-apdu, +--asn2wrs bug +-- acrp ACRP-apdu + acrp [APPLICATION 7] IMPLICIT ACRP-apdu +} + +AARQ-apdu ::= [APPLICATION 0] IMPLICIT SEQUENCE { + protocol-version + [0] IMPLICIT BIT STRING {version1(0)} DEFAULT {version1}, + aSO-context-name [1] ASO-context-name, + called-AP-title [2] AP-title OPTIONAL, + called-AE-qualifier [3] AE-qualifier OPTIONAL, + called-AP-invocation-identifier [4] AP-invocation-identifier OPTIONAL, + called-AE-invocation-identifier [5] AE-invocation-identifier OPTIONAL, + calling-AP-title [6] AP-title OPTIONAL, + calling-AE-qualifier [7] AE-qualifier OPTIONAL, + calling-AP-invocation-identifier [8] AP-invocation-identifier OPTIONAL, + calling-AE-invocation-identifier [9] AE-invocation-identifier OPTIONAL, + -- The following field shall not be present if only the Kernel is used. + sender-acse-requirements [10] IMPLICIT ACSE-requirements OPTIONAL, + -- The following field shall only be present if the Authentication functional unit is selected. + mechanism-name [11] IMPLICIT Mechanism-name OPTIONAL, + -- The following field shall only be present if the Authentication functional unit is selected. + calling-authentication-value [12] EXPLICIT Authentication-value OPTIONAL, + aSO-context-name-list + [13] IMPLICIT ASO-context-name-list OPTIONAL, + -- The above field shall only be present if the Application Context Negotiation functional unit is selected. + implementation-information [29] IMPLICIT Implementation-data OPTIONAL, + ..., + -- Extensions for higher level association FU + p-context-definition-list [14] Syntactic-context-list OPTIONAL, + called-asoi-tag [15] IMPLICIT ASOI-tag OPTIONAL, + calling-asoi-tag [16] IMPLICIT ASOI-tag OPTIONAL, + -- End of extensions for higher level association FU +-- ..., + user-information [30] IMPLICIT Association-data OPTIONAL +} + +AARE-apdu ::= [APPLICATION 1] IMPLICIT SEQUENCE { + protocol-version + [0] IMPLICIT BIT STRING {version1(0)} DEFAULT {version1}, + aSO-context-name [1] ASO-context-name, + result [2] Associate-result, + result-source-diagnostic [3] Associate-source-diagnostic, + responding-AP-title [4] AP-title OPTIONAL, + responding-AE-qualifier [5] AE-qualifier OPTIONAL, + responding-AP-invocation-identifier [6] AP-invocation-identifier OPTIONAL, + responding-AE-invocation-identifier [7] AE-invocation-identifier OPTIONAL, + -- The following field shall not be present if only the Kernel is used. + responder-acse-requirements [8] IMPLICIT ACSE-requirements OPTIONAL, + -- The following field shall only be present if the Authentication functional unit is selected. + mechanism-name [9] IMPLICIT Mechanism-name OPTIONAL, + -- This following field shall only be present if the Authentication functional unit is selected. + responding-authentication-value + [10] EXPLICIT Authentication-value OPTIONAL, + aSO-context-name-list + [11] IMPLICIT ASO-context-name-list OPTIONAL, + -- The above field shall only be present if the Application Context Negotiation functional unit is selected. + implementation-information + [29] IMPLICIT Implementation-data OPTIONAL, + ..., + -- Extensions for higher level association FU + p-context-result-list + [12] IMPLICIT P-context-result-list OPTIONAL, + called-asoi-tag [13] IMPLICIT ASOI-tag OPTIONAL, + calling-asoi-tag [14] IMPLICIT ASOI-tag OPTIONAL, + -- End of extensions for higher level association FU +-- ..., + user-information [30] IMPLICIT Association-data OPTIONAL +} + +RLRQ-apdu ::= [APPLICATION 2] IMPLICIT SEQUENCE { + reason [0] IMPLICIT Release-request-reason OPTIONAL, + ..., + -- Extensions for higher level association FU + aso-qualifier [13] ASO-qualifier OPTIONAL, + asoi-identifier [14] IMPLICIT ASOI-identifier OPTIONAL, + -- End of extensions for higher level association FU +-- ..., + user-information [30] IMPLICIT Association-data OPTIONAL +} + +RLRE-apdu ::= [APPLICATION 3] IMPLICIT SEQUENCE { + reason [0] IMPLICIT Release-response-reason OPTIONAL, + ..., + -- Extensions for higher level association FU + aso-qualifier [13] ASO-qualifier OPTIONAL, + asoi-identifier [14] IMPLICIT ASOI-identifier OPTIONAL, + -- End of extensions for higher level association FU +-- ..., + user-information [30] IMPLICIT Association-data OPTIONAL +} + +ABRT-apdu ::= [APPLICATION 4] IMPLICIT SEQUENCE { + abort-source [0] IMPLICIT ABRT-source, + abort-diagnostic [1] IMPLICIT ABRT-diagnostic OPTIONAL, + -- This field shall not be present if only the Kernel is used. + ..., + -- Extensions for higher level association FU + aso-qualifier [13] ASO-qualifier OPTIONAL, + asoi-identifier [14] IMPLICIT ASOI-identifier OPTIONAL, + -- End of extensions for higher level association FU +-- ..., + user-information [30] IMPLICIT Association-data OPTIONAL +} + +A-DT-apdu ::= [APPLICATION 5] IMPLICIT SEQUENCE { + aso-qualifier [0] ASO-qualifier OPTIONAL, + asoi-identifier [1] IMPLICIT ASOI-identifier OPTIONAL, + ..., +-- ..., + a-user-data [30] User-Data +} + +ACRQ-apdu ::= [APPLICATION 6] IMPLICIT SEQUENCE { + aso-qualifier [0] ASO-qualifier OPTIONAL, + asoi-identifier [1] IMPLICIT ASOI-identifier OPTIONAL, + aSO-context-name [3] IMPLICIT ASO-context-name OPTIONAL, + aSO-context-name-list [4] IMPLICIT ASO-context-name-list OPTIONAL, + p-context-definition-list [5] Syntactic-context-list OPTIONAL, + ..., +-- ..., + user-information [30] IMPLICIT User-information OPTIONAL +} + +ACRP-apdu ::= [APPLICATION 7] IMPLICIT SEQUENCE { + aso-qualifier [0] ASO-qualifier OPTIONAL, + asoi-identifier [1] IMPLICIT ASOI-identifier OPTIONAL, + -- originally defined as ASO-context-name-list, but this has to be wrong + -- aSO-context-name [3] IMPLICIT ASO-context-name-list OPTIONAL, + aSO-context-name [3] IMPLICIT ASO-context-name OPTIONAL, + p-context-result-list [4] IMPLICIT P-context-result-list OPTIONAL, + ..., +-- ..., + user-information [30] IMPLICIT User-information OPTIONAL +} + +ABRT-diagnostic ::= ENUMERATED { + no-reason-given(1), protocol-error(2), + authentication-mechanism-name-not-recognized(3), + authentication-mechanism-name-required(4), authentication-failure(5), + authentication-required(6), ... + } + +ABRT-source ::= INTEGER {service-user(0), service-provider(1) +}(0..1, ...) + +ACSE-requirements ::= BIT STRING { + authentication(0), aSO-context-negotiation(1), higher-level-association(2), + nested-association(3)} + +Application-context-name ::= ASO-context-name + +ASO-context-name ::= OBJECT IDENTIFIER + +-- Application-entity title productions follow (not in alphabetical order). +AP-title ::= CHOICE { + ap-title-form1 AP-title-form1, + ap-title-form2 AP-title-form2, + ..., + ap-title-form3 AP-title-form3 +} + +AE-qualifier ::= ASO-qualifier + +ASO-qualifier ::= CHOICE { + aso-qualifier-form1 ASO-qualifier-form1, + aso-qualifier-form2 ASO-qualifier-form2, + ..., + aso-qualifier-form3 ASO-qualifier-form3, +-- an alternative used by some systems from the days when ASO-qualifier +-- was an ANY + aso-qualifier-form-any-octets ASO-qualifier-form-octets +} + +-- When both AP-title and AE-qualifier data values are present in an AARQ or AARE APDU, both must +-- have the same form to allow the construction of an AE-title as discussed in itu-t Rec. X.665 | +-- ISO/IEC 9834-6 +AP-title-form1 ::= + Name + +-- The value assigned to AP-title-form1 is The Directory Name of an application-process title. +ASO-qualifier-form1 ::= + RelativeDistinguishedName + +-- The value assigned to AE-qualifier-form1 is the relative distinguished name of a particular +-- application-entity of the application-process identified by AP-title-form1. +AP-title-form2 ::= OBJECT IDENTIFIER + +ASO-qualifier-form2 ::= INTEGER + +AP-title-form3 ::= PrintableString + +ASO-qualifier-form3 ::= PrintableString + +ASO-qualifier-form-octets ::= OCTET STRING + +AE-title ::= CHOICE { + ae-title-form1 AE-title-form1, + ae-title-form2 AE-title-form2, + ... +} + +-- As defined in ITU-T Rec. X.650 | ISO/IEC 7498-3, an application-entity title is composed of an application process +-- title and an application-entity qualifier. The ACSE protocol provides for the transfer of an application-entity title +-- value by the transfer of its component values. However, the following data type is provided for International +-- Standards that reference a single syntactic structure for AE titles. +AE-title-form1 ::= + Name + +-- For access to The Directory (see ITU-T Rec. X.500 series | ISO/IEC 9594), an AE title has AE-title-form1. This value +-- can be constructed from AP-title-form1 and AE-qualifier-form1 values contained in an AARQ or AARE APDU. +-- A discussion of forming an AE-title-form1 from AP-title-form1 and AE-qualifier form1 may be found in itu-t +-- Rec X.665 | ISO/IEC 9834-6. +AE-title-form2 ::= OBJECT IDENTIFIER + +-- A discussion of forming an AE-title-form2 from AP-title-form2 and AE-qualifier-form2 may be found in +-- itu-t Rec. X.665 | ISO/IEC 9834-6. +AE-invocation-identifier ::= INTEGER + +AP-invocation-identifier ::= INTEGER + +ASOI-identifier ::= INTEGER(1..128, ...) + +ASOI-tag ::= + SEQUENCE SIZE (0..7, ...) OF + SEQUENCE {qualifier [0] ASO-qualifier OPTIONAL, + identifier [1] ASOI-identifier OPTIONAL} + +-- End of Application-entity title productions +ASO-context-name-list ::= SEQUENCE OF ASO-context-name + +Syntactic-context-list ::= CHOICE { + context-list [0] Context-list, + default-contact-list [1] Default-Context-List +} + +Context-list ::= + SEQUENCE OF + SEQUENCE {pci Presentation-context-identifier, + abstract-syntax Abstract-syntax-name, +-- bug in asn2wrs +-- transfer-syntaxes SEQUENCE OF Transfer-syntax-name} + transfer-syntaxes SEQUENCE OF TransferSyntaxName} + +Default-Context-List ::= + SEQUENCE OF + SEQUENCE {abstract-syntax-name [0] IMPLICIT Abstract-syntax-name OPTIONAL, +-- bug in asn2wrs +-- transfer-syntax-name [1] IMPLICIT Transfer-syntax-name + transfer-syntax-name [1] IMPLICIT TransferSyntaxName + } + +Abstract-syntax-name ::= OBJECT IDENTIFIER + +P-context-result-list ::= + SEQUENCE OF + SEQUENCE {result [0] IMPLICIT Result, + concrete-syntax-name [1] IMPLICIT Concrete-syntax-name OPTIONAL, + provider-reason + [2] IMPLICIT INTEGER {reason-not-specified(0), + abstract-syntax-not-supported(1), + proposed-transfer-syntaxes-not-supported(2), + local-limit-on-DCS-exceeded(3)} OPTIONAL + } + +Result ::= INTEGER {acceptance(0), user-rejection(1), provider-rejection(2)} + +--bug in asn2wrs +--Concrete-syntax-name ::= Transfer-syntax-name +Concrete-syntax-name ::= TransferSyntaxName + +--bug in asn2wrs +--Transfer-syntax-name ::= OBJECT IDENTIFIER +TransferSyntaxName ::= OBJECT IDENTIFIER + +Associate-result ::= INTEGER { + accepted(0), rejected-permanent(1), rejected-transient(2)}(0..2, ...) + +Associate-source-diagnostic ::= CHOICE { + service-user + [1] INTEGER {null(0), no-reason-given(1), + application-context-name-not-supported(2), + calling-AP-title-not-recognized(3), + calling-AP-invocation-identifier-not-recognized(4), + calling-AE-qualifier-not-recognized(5), + calling-AE-invocation-identifier-not-recognized(6), + called-AP-title-not-recognized(7), + called-AP-invocation-identifier-not-recognized(8), + called-AE-qualifier-not-recognized(9), + called-AE-invocation-identifier-not-recognized(10), + authentication-mechanism-name-not-recognized(11), + authentication-mechanism-name-required(12), + authentication-failure(13), authentication-required(14)} + (0..14, ...), + service-provider + [2] INTEGER {null(0), no-reason-given(1), no-common-acse-version(2)} + (0..2, ...) +} + +User-information ::= Association-data + +Association-data ::= SEQUENCE OF EXTERNALt + +Simply-encoded-data ::= OCTET STRING + +User-Data ::= CHOICE { + user-information User-information, + simply-encoded-data Simply-encoded-data, + fully-encoded-data [0] PDV-list +} + +-- see ITU-T Rec. X.226 | ISO/IEC 8823-1. +PDV-list ::= SEQUENCE { +--bug in asn2wrs +-- transfer-syntax-name Transfer-syntax-name OPTIONAL, + transfer-syntax-name TransferSyntaxName OPTIONAL, + presentation-context-identifier Presentation-context-identifier, + presentation-data-values + CHOICE {simple-ASN1-type + [0] ANY + (CONSTRAINED BY { + + -- Type corresponding to presentation context identifier + }), + octet-aligned [1] IMPLICIT OCTET STRING, + arbitrary [2] IMPLICIT BIT STRING} + -- see ITU-T Rec. X.226 | ISO/IEC 8823-1. +} + +Presentation-context-identifier ::= INTEGER + +Authentication-value-other ::= SEQUENCE { + other-mechanism-name OBJECT IDENTIFIER, + other-mechanism-value ANY +} + +Authentication-value ::= CHOICE { + charstring [0] IMPLICIT GraphicString, + bitstring [1] IMPLICIT BIT STRING, + external [2] IMPLICIT EXTERNALt, + other + [3] IMPLICIT Authentication-value-other +} + +-- The abstract syntax of (calling/responding) authentication-value is determined by the authentication mechanism used +-- during association establishment. The authentication mechanism is either explicitly denoted by the &id field (of type +-- OBJECT IDENTIFIER) for a mechanism belonging to the class MECHANISM-NAME, or it is known implicitly by +-- prior agreement between the communicating partners. If the "other" component is chosen, then the +-- "mechanism-name" component must be present in accordance with ITU-T Rec. X.680 | ISO/IEC 8824-1. If the value +-- "mechanism-name" occurs in the AARQ-apdu or the AARE-apdu, then that value must be the same as the value for +-- "other-mechanism-name". +Implementation-data ::= GraphicString + +Mechanism-name ::= OBJECT IDENTIFIER + +Release-request-reason ::= INTEGER {normal(0), urgent(1), user-defined(30) +} + +Release-response-reason ::= INTEGER { + normal(0), not-finished(1), user-defined(30)} + +END + +-- Generated by Asnp, the ASN.1 pretty-printer of France Telecom R&D + diff --git a/epan/dissectors/asn1/acse/acse.cnf b/epan/dissectors/asn1/acse/acse.cnf new file mode 100644 index 00000000..8676d687 --- /dev/null +++ b/epan/dissectors/asn1/acse/acse.cnf @@ -0,0 +1,173 @@ +# asce.cnf +# ACSE conformation file + +#.IMPORT ../x509if/x509if-exp.cnf + +#.OMIT_ASSIGNMENT +Application-context-name +#.END + +#.NO_EMIT ONLY_VALS +ACSE-apdu + +#.EXPORTS +EXTERNALt +AE-title +AP-title +AP-invocation-identifier +AE-qualifier +ASO-qualifier +AE-invocation-identifier + +#.TYPE_RENAME +AARQ-apdu/_untag/protocol-version T_AARQ_protocol_version +AARE-apdu/_untag/protocol-version T_AARE_protocol_version +AARQ-apdu/_untag/aSO-context-name T_AARQ_aSO_context_name +AARE-apdu/_untag/aSO-context-name T_AARE_aSO_context_name +ACRQ-apdu/_untag/aSO-context-name T_ACRQ_aSO_context_name +ACRP-apdu/_untag/aSO-context-name T_ACRP_aSO_context_name + +#.FIELD_RENAME +AARQ-apdu/_untag/user-information aARQ_user_information +AARE-apdu/_untag/user-information aARE_user_information +ABRT-apdu/_untag/user-information aBRT_user_information +RLRE-apdu/_untag/user-information rLRE_user_information +RLRQ-apdu/_untag/user-information rLRQ_user_information +P-context-result-list/_item/result pcontext_result +RLRE-apdu/_untag/reason rLRE_reason +RLRQ-apdu/_untag/reason rLRQ_reason +AARQ-apdu/_untag/protocol-version aARQ_protocol_version +AARE-apdu/_untag/protocol-version aARE_protocol_version +AARQ-apdu/_untag/aSO-context-name aARQ_aSO_context_name +AARE-apdu/_untag/aSO-context-name aARE_aSO_context_name +ACRQ-apdu/_untag/aSO-context-name aCRQ_aSO_context_name +PDV-list/presentation-data-values/octet-aligned pDVList_octet_aligned + +#.FN_PARS Authentication-value-other/other-mechanism-name + FN_VARIANT = _str VAL_PTR = &actx->external.direct_reference + +#.FN_BODY Authentication-value-other/other-mechanism-name +%(DEFAULT_BODY)s + actx->external.direct_ref_present = (actx->external.direct_reference != NULL) ? TRUE : FALSE; + +#.FN_BODY Authentication-value-other/other-mechanism-value + if (actx->external.direct_ref_present) { + offset=call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, actx->subtree.top_tree, actx->private_data); + } + +#.FN_BODY PDV-list/presentation-data-values/simple-ASN1-type +/*XXX not implemented yet */ + +#.FN_BODY AARQ-apdu/_untag/aSO-context-name + offset = dissect_ber_object_identifier_str(FALSE, actx, tree, tvb, offset, + hf_index, &actx->external.direct_reference); + actx->external.direct_ref_present = (actx->external.direct_reference != NULL) ? TRUE : FALSE; + +#.FN_BODY AARE-apdu/_untag/aSO-context-name + offset = dissect_ber_object_identifier_str(FALSE, actx, tree, tvb, offset, + hf_index, &actx->external.direct_reference); + actx->external.direct_ref_present = (actx->external.direct_reference != NULL) ? TRUE : FALSE; + +#.FN_BODY ACRQ-apdu/_untag/aSO-context-name + offset = dissect_ber_object_identifier_str(FALSE, actx, tree, tvb, offset, + hf_index, &actx->external.direct_reference); + actx->external.direct_ref_present = (actx->external.direct_reference != NULL) ? TRUE : FALSE; + +#.FN_BODY ACRP-apdu/_untag/aSO-context-name + offset = dissect_ber_object_identifier_str(FALSE, actx, tree, tvb, offset, + hf_index, &actx->external.direct_reference); + actx->external.direct_ref_present = (actx->external.direct_reference != NULL) ? TRUE : FALSE; + +#.FN_BODY EXTERNALt/_untag/indirect-reference + char *oid; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*) actx->private_data; + + offset = dissect_ber_integer(FALSE, actx, tree, tvb, offset, + hf_acse_indirect_reference, + &indir_ref); + + /* look up the indirect reference */ + if((oid = find_oid_by_pres_ctx_id(actx->pinfo, indir_ref)) != NULL) { + actx->external.direct_reference = wmem_strdup(actx->pinfo->pool, oid); + actx->external.direct_ref_present = TRUE; + } + + if(session) + session->pres_ctx_id = indir_ref; + +#.FN_PARS EXTERNALt/_untag/direct-reference + FN_VARIANT = _str VAL_PTR = &actx->external.direct_reference + +#.FN_BODY EXTERNALt/_untag/direct-reference +%(DEFAULT_BODY)s + actx->external.direct_ref_present = (actx->external.direct_reference != NULL) ? TRUE : FALSE; + +#.FN_BODY EXTERNALt/_untag/encoding/single-ASN1-type + if (actx->external.direct_ref_present) { + offset=call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->private_data); + } + +#.FN_BODY EXTERNALt/_untag/encoding/octet-aligned + if (actx->external.direct_ref_present) { + offset=call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->private_data); + } + +#.FN_BODY AARQ-apdu + col_append_str(actx->pinfo->cinfo, COL_INFO, "A-Associate-Request"); + + %(DEFAULT_BODY)s + +#.FN_BODY AARE-apdu + col_append_str(actx->pinfo->cinfo, COL_INFO, "A-Associate-Response"); + + %(DEFAULT_BODY)s + +#.FN_BODY RLRQ-apdu + col_append_str(actx->pinfo->cinfo, COL_INFO, "Release-Request"); + + %(DEFAULT_BODY)s + +#.FN_PARS Release-request-reason + VAL_PTR=&reason + +#.FN_BODY Release-request-reason + int reason = -1; + + %(DEFAULT_BODY)s + + if(reason != -1) + col_append_fstr(actx->pinfo->cinfo, COL_INFO, " (%%s)", val_to_str(reason, acse_Release_request_reason_vals, "reason(%%d)")); + +#.FN_BODY RLRE-apdu + col_append_str(actx->pinfo->cinfo, COL_INFO, "Release-Response"); + + %(DEFAULT_BODY)s + +#.FN_PARS Release-response-reason + VAL_PTR=&reason + +#.FN_BODY Release-response-reason + int reason = -1; + + %(DEFAULT_BODY)s + + if(reason != -1) + col_append_fstr(actx->pinfo->cinfo, COL_INFO, " (%%s)", val_to_str(reason, acse_Release_response_reason_vals, "reason(%%d)")); + +#.FN_BODY ABRT-apdu + col_append_str(actx->pinfo->cinfo, COL_INFO, "Abort"); + + %(DEFAULT_BODY)s + +#.FN_BODY ABRT-source VAL_PTR=&source + int source = -1; + + %(DEFAULT_BODY)s + + if(source != -1) + col_append_fstr(actx->pinfo->cinfo, COL_INFO, " (%%s)", val_to_str(source, acse_ABRT_source_vals, "source(%%d)")); + +#.FIELD_ATTR +Association-data/_item NAME = "Association-data" +P-context-result-list/_item/result ABBREV=pcontext.result +#.END diff --git a/epan/dissectors/asn1/acse/packet-acse-template.c b/epan/dissectors/asn1/acse/packet-acse-template.c new file mode 100644 index 00000000..d10208ab --- /dev/null +++ b/epan/dissectors/asn1/acse/packet-acse-template.c @@ -0,0 +1,283 @@ +/*XXX + There is a bug in asn2wrs that it can not yet handle tagged assignments such + as EXTERNAL ::= [UNIVERSAL 8] IMPLICIT SEQUENCE { + + This bug is workedaround by some .cnf magic but this should be cleaned up + once asn2wrs learns how to deal with tagged assignments +*/ + +/* packet-acse.c + * Routines for ACSE packet dissection + * Ronnie Sahlberg 2005 + * dissect_acse() based original handwritten dissector by Sid + * Yuriy Sidelnikov <YSidelnikov@hotmail.com> + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" + +#include <epan/packet.h> +#include <epan/exceptions.h> +#include <epan/expert.h> +#include <epan/oids.h> +#include <epan/asn1.h> + +#include "packet-ber.h" +#include "packet-acse.h" +#include "packet-ses.h" +#include "packet-pres.h" +#include "packet-x509if.h" + +#define PNAME "ISO 8650-1 OSI Association Control Service" +#define PSNAME "ACSE" +#define PFNAME "acse" + +#define CLPNAME "ISO 10035-1 OSI Connectionless Association Control Service" +#define CLPSNAME "CLACSE" +#define CLPFNAME "clacse" + +#define ACSE_APDU_OID "2.2.1.0.1" + +void proto_register_acse(void); +void proto_reg_handoff_acse(void); + +/* Initialize the protocol and registered fields */ +int proto_acse = -1; +int proto_clacse = -1; + + + +#include "packet-acse-hf.c" +static gint hf_acse_user_data = -1; + +/* Initialize the subtree pointers */ +static gint ett_acse = -1; +#include "packet-acse-ett.c" + +static expert_field ei_acse_dissector_not_available = EI_INIT; +static expert_field ei_acse_malformed = EI_INIT; +static expert_field ei_acse_invalid_oid = EI_INIT; + +static dissector_handle_t acse_handle = NULL; + +/* indirect_reference, used to pick up the signalling so we know what + kind of data is transferred in SES_DATA_TRANSFER_PDUs */ +static guint32 indir_ref=0; + +#if NOT_NEEDED +/* to keep track of presentation context identifiers and protocol-oids */ +typedef struct _acse_ctx_oid_t { + /* XXX here we should keep track of ADDRESS/PORT as well */ + guint32 ctx_id; + char *oid; +} acse_ctx_oid_t; +static wmem_map_t *acse_ctx_oid_table = NULL; + +static guint +acse_ctx_oid_hash(gconstpointer k) +{ + acse_ctx_oid_t *aco=(acse_ctx_oid_t *)k; + return aco->ctx_id; +} +/* XXX this one should be made ADDRESS/PORT aware */ +static gint +acse_ctx_oid_equal(gconstpointer k1, gconstpointer k2) +{ + acse_ctx_oid_t *aco1=(acse_ctx_oid_t *)k1; + acse_ctx_oid_t *aco2=(acse_ctx_oid_t *)k2; + return aco1->ctx_id==aco2->ctx_id; +} + +static void +register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, char *oid) +{ + acse_ctx_oid_t *aco, *tmpaco; + aco=wmem_new(wmem_file_scope(), acse_ctx_oid_t); + aco->ctx_id=idx; + aco->oid=wmem_strdup(wmem_file_scope(), oid); + + /* if this ctx already exists, remove the old one first */ + tmpaco=(acse_ctx_oid_t *)wmem_map_lookup(acse_ctx_oid_table, aco); + if (tmpaco) { + wmem_map_remove(acse_ctx_oid_table, tmpaco); + } + wmem_map_insert(acse_ctx_oid_table, aco, aco); +} +static char * +find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx) +{ + acse_ctx_oid_t aco, *tmpaco; + aco.ctx_id=idx; + tmpaco=(acse_ctx_oid_t *)wmem_map_lookup(acse_ctx_oid_table, &aco); + if (tmpaco) { + return tmpaco->oid; + } + return NULL; +} + +# endif /* NOT_NEEDED */ + +#include "packet-acse-fn.c" + + +/* +* Dissect ACSE PDUs inside a PPDU. +*/ +static int +dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) +{ + int offset = 0; + proto_item *item; + proto_tree *tree; + char *oid; + struct SESSION_DATA_STRUCTURE* session; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + + /* do we have spdu type from the session dissector? */ + if (data == NULL) { + return 0; + } + + /* first, try to check length */ + /* do we have at least 2 bytes */ + if (!tvb_bytes_exist(tvb, 0, 2)) { + proto_tree_add_item(parent_tree, hf_acse_user_data, tvb, offset, + tvb_reported_length_remaining(tvb,offset), ENC_NA); + return 0; /* no, it isn't a ACSE PDU */ + } + + session = ( (struct SESSION_DATA_STRUCTURE*)data); + if (session->spdu_type == 0) { + if (parent_tree) { + REPORT_DISSECTOR_BUG("Wrong spdu type %x from session dissector.",session->spdu_type); + return 0; + } + } + + asn1_ctx.private_data = session; + /* save parent_tree so subdissectors can create new top nodes */ + asn1_ctx.subtree.top_tree = parent_tree; + + /* ACSE has only AARQ,AARE,RLRQ,RLRE,ABRT type of pdu */ + /* reject everything else */ + /* data pdu is not ACSE pdu and has to go directly to app dissector */ + switch (session->spdu_type) { + case SES_CONNECTION_REQUEST: /* AARQ */ + case SES_CONNECTION_ACCEPT: /* AARE */ + case SES_REFUSE: /* RLRE */ + case SES_DISCONNECT: /* RLRQ */ + case SES_FINISH: /* RLRE */ + case SES_ABORT: /* ABRT */ + case CLSES_UNIT_DATA: /* AARQ Connectionless session */ + break; + case SES_DATA_TRANSFER: + oid=find_oid_by_pres_ctx_id(pinfo, indir_ref); + if (oid) { + if (strcmp(oid, ACSE_APDU_OID) == 0) { + proto_tree_add_expert_format(parent_tree, pinfo, &ei_acse_invalid_oid, tvb, offset, -1, + "Invalid OID: %s", ACSE_APDU_OID); + } + else { + call_ber_oid_callback(oid, tvb, offset, pinfo, parent_tree, NULL); + } + } else { + proto_tree_add_expert(parent_tree, pinfo, &ei_acse_dissector_not_available, + tvb, offset, -1); + } + return 0; + default: + return 0; + } + + if (session->spdu_type == CLSES_UNIT_DATA) { + /* create display subtree for the connectionless protocol */ + item = proto_tree_add_item(parent_tree, proto_clacse, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_acse); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CL-ACSE"); + col_clear(pinfo->cinfo, COL_INFO); + } else { + /* create display subtree for the protocol */ + item = proto_tree_add_item(parent_tree, proto_acse, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_acse); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "ACSE"); + col_clear(pinfo->cinfo, COL_INFO); + } + + /* we can't make any additional checking here */ + /* postpone it before dissector will have more information */ + while (tvb_reported_length_remaining(tvb, offset) > 0) { + int old_offset=offset; + offset = dissect_acse_ACSE_apdu(FALSE, tvb, offset, &asn1_ctx, tree, -1); + if (offset == old_offset) { + proto_tree_add_expert(tree, pinfo, &ei_acse_malformed, tvb, offset, -1); + break; + } + } + + return tvb_captured_length(tvb); +} + +/*--- proto_register_acse ----------------------------------------------*/ +void proto_register_acse(void) { + + /* List of fields */ + static hf_register_info hf[] = { + { &hf_acse_user_data, + { "User data", "acse.user_data", + FT_BYTES, BASE_NONE, NULL, 0, + NULL, HFILL }}, +#include "packet-acse-hfarr.c" + }; + + /* List of subtrees */ + static gint *ett[] = { + &ett_acse, +#include "packet-acse-ettarr.c" + }; + + static ei_register_info ei[] = { + { &ei_acse_dissector_not_available, { "acse.dissector_not_available", PI_UNDECODED, PI_WARN, "Dissector is not available", EXPFILL }}, + { &ei_acse_malformed, { "acse.malformed", PI_MALFORMED, PI_ERROR, "Malformed packet", EXPFILL }}, + { &ei_acse_invalid_oid, { "acse.invalid_oid", PI_UNDECODED, PI_WARN, "Invalid OID", EXPFILL }}, + }; + + expert_module_t* expert_acse; + + /* Register protocol */ + proto_acse = proto_register_protocol(PNAME, PSNAME, PFNAME); + acse_handle = register_dissector("acse", dissect_acse, proto_acse); + + /* Register connectionless protocol */ + proto_clacse = proto_register_protocol(CLPNAME, CLPSNAME, CLPFNAME); + + + /* Register fields and subtrees */ + proto_register_field_array(proto_acse, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + expert_acse = expert_register_protocol(proto_acse); + expert_register_field_array(expert_acse, ei, array_length(ei)); + +#if NOT_NEEDED + acse_ctx_oid_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), acse_ctx_oid_hash, + acse_ctx_oid_equal); +#endif +} + + +/*--- proto_reg_handoff_acse -------------------------------------------*/ +void proto_reg_handoff_acse(void) { +/*#include "packet-acse-dis-tab.c"*/ + oid_add_from_string("id-aCSE","2.2.3.1.1"); + register_ber_oid_dissector_handle(ACSE_APDU_OID, acse_handle, proto_acse, "id-as-acse"); + + +} + diff --git a/epan/dissectors/asn1/acse/packet-acse-template.h b/epan/dissectors/asn1/acse/packet-acse-template.h new file mode 100644 index 00000000..26c86702 --- /dev/null +++ b/epan/dissectors/asn1/acse/packet-acse-template.h @@ -0,0 +1,19 @@ +/* packet-acse.h + * Routines for ACSE packet dissection + * Ronnie Sahlberg 2005 + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PACKET_ACSE_H +#define PACKET_ACSE_H + +#include <epan/asn1.h> +#include "packet-acse-exp.h" + +#endif /* PACKET_ACSE_H */ + |