diff options
Diffstat (limited to 'epan/dissectors/asn1/pres')
-rw-r--r-- | epan/dissectors/asn1/pres/CMakeLists.txt | 40 | ||||
-rw-r--r-- | epan/dissectors/asn1/pres/ISO8823-PRESENTATION.asn | 388 | ||||
-rw-r--r-- | epan/dissectors/asn1/pres/ISO9576-PRESENTATION.asn | 36 | ||||
-rw-r--r-- | epan/dissectors/asn1/pres/packet-pres-template.c | 432 | ||||
-rw-r--r-- | epan/dissectors/asn1/pres/packet-pres-template.h | 18 | ||||
-rw-r--r-- | epan/dissectors/asn1/pres/pres.cnf | 101 |
6 files changed, 1015 insertions, 0 deletions
diff --git a/epan/dissectors/asn1/pres/CMakeLists.txt b/epan/dissectors/asn1/pres/CMakeLists.txt new file mode 100644 index 00000000..2fdf26fd --- /dev/null +++ b/epan/dissectors/asn1/pres/CMakeLists.txt @@ -0,0 +1,40 @@ +# 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 pres ) + +set( PROTO_OPT ) + +set( EXT_ASN_FILE_LIST +) + +set( ASN_FILE_LIST + ISO8823-PRESENTATION.asn + ISO9576-PRESENTATION.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 ) + +set( EXTRA_CNF + "${CMAKE_CURRENT_BINARY_DIR}/../rtse/rtse-exp.cnf" +) + +ASN2WRS() diff --git a/epan/dissectors/asn1/pres/ISO8823-PRESENTATION.asn b/epan/dissectors/asn1/pres/ISO8823-PRESENTATION.asn new file mode 100644 index 00000000..99289066 --- /dev/null +++ b/epan/dissectors/asn1/pres/ISO8823-PRESENTATION.asn @@ -0,0 +1,388 @@ +-- Module ISO8823-PRESENTATION (X.226:07/1994) +ISO8823-PRESENTATION DEFINITIONS ::= +BEGIN + +-- +-- In X.410-1984 mode, the value of the SS-user data parameter of the S-CONNECT request and +-- indication session-service primitives shall be a CP-type value. +-- +-- In normal mode, the value of the SS-user data parameter of the S-CONNECT request and +-- indication session-service primitives shall be a CP-type value, followed as a requestor's +-- option by zero or more CPC-type values. +IMPORTS + RTORQapdu, RTOACapdu, RTORJapdu, RTABapdu + FROM Reliable-Transfer-APDU {joint-iso-itu-t(2) reliable-transfer(3) + apdus(0)}; + +CP-type ::= SET { + mode-selector [0] IMPLICIT Mode-selector, + x410-mode-parameters +-- [1] IMPLICIT SET {COMPONENTS OF Reliable-Transfer-APDU.RTORQapdu} OPTIONAL This OPTIONAL element shall be absent for a + [1] IMPLICIT RTORQapdu OPTIONAL, +-- This OPTIONAL element shall be absent for a + -- nested presentation connection. + -- Shall be used for X.410 mode only. Shall be bitwise + -- compatible with CCITT Recommendation X.410-1984. + -- This shall be the User data parameter of the CP PPDU1) -- + normal-mode-parameters + [2] IMPLICIT SEQUENCE {protocol-version + [0] IMPLICIT Protocol-version DEFAULT {version-1}, + calling-presentation-selector + [1] IMPLICIT Calling-presentation-selector + OPTIONAL, + called-presentation-selector + [2] IMPLICIT Called-presentation-selector OPTIONAL, + presentation-context-definition-list + [4] IMPLICIT Presentation-context-definition-list + OPTIONAL, + default-context-name + [6] IMPLICIT Default-context-name OPTIONAL, + presentation-requirements + [8] IMPLICIT Presentation-requirements OPTIONAL, + user-session-requirements + [9] IMPLICIT User-session-requirements OPTIONAL-- shall not be present if equal to the Revised session + -- requirements parameter --, + protocol-options + [11] Protocol-options DEFAULT {}, + -- shall be absent if no options are offered + initiators-nominated-context + [12] Presentation-context-identifier OPTIONAL, + -- shall only be present if nominated-context is + -- offered in protocol-options + extensions + [14] SEQUENCE {...} OPTIONAL, + -- to allow for future extensions + user-data + User-data OPTIONAL} OPTIONAL + -- Shall be used for normal mode only. + -- Shall be the parameters of the CP PPDU. +} + +-- +-- As an initiator's option, the presentation data values contained in a CP PPDU may be +-- encoded more than once, using CPC-type values, to allow the transfer of the same +-- presentation data values using a number of different transfer syntaxes. +-- +CPC-type ::= + User-data + +-- Shall be used for normal mode only. +-- Shall not be present if the Presentation context definition list parameter is not present +-- in the CP PPDU. Each instance of this data type shall contain all of the presentation data +-- values which were contained in the User data parameter of the CP PPDU. +-- This shall be the same set of presentation data values which were contained in the CP-type. +-- +-- The SS-user data parameter value of the S-CONNECT response +-- and confirm session-service primitives shall be a CPA-PPDU +-- value when the Result parameter value is "accept". +-- +-- +CPA-PPDU ::= SET { + mode-selector [0] IMPLICIT Mode-selector, + x410-mode-parameters +-- [1] IMPLICIT SET {COMPONENTS OF Reliable-Transfer-APDU.RTOACapdu} OPTIONAL +-- This OPTIONAL element shall be absent for a + [1] IMPLICIT RTOACapdu OPTIONAL, +-- This OPTIONAL element shall be absent for a + -- nested presentation connection. + -- Shall be used for X.410 mode only. Shall be bitwise + -- compatible with CCITT Recommendation X.410-1984. + -- This shall be the User data parameter of the CPA PPDU1) -- + normal-mode-parameters + [2] IMPLICIT SEQUENCE {protocol-version + [0] IMPLICIT Protocol-version DEFAULT {version-1}, + responding-presentation-selector + [3] IMPLICIT Responding-presentation-selector + OPTIONAL, + presentation-context-definition-result-list + [5] IMPLICIT Presentation-context-definition-result-list + OPTIONAL, + presentation-requirements + [8] IMPLICIT Presentation-requirements OPTIONAL, + user-session-requirements + [9] IMPLICIT User-session-requirements OPTIONAL, + -- shall not be present if equal to the Revised session + -- requirements parameter + protocol-options + [11] Protocol-options DEFAULT {}, + -- shall be absent if no options are selected + responders-nominated-context + [13] Presentation-context-identifier OPTIONAL, + -- shall only be present if nominated-context is + -- selected in protocol-options + user-data + User-data OPTIONAL} OPTIONAL + -- Shall be used for normal mode only. +} + +-- +-- +-- The SS-user data parameter value of the S-CONNECT response +-- and confirm session-service primitives shall be a CPR-PPDU +-- value when the Result parameter value is "reject by SS-provider" +-- or "reject by called SS-user". +-- +CPR-PPDU ::= CHOICE { +-- x400-mode-parameters SET {COMPONENTS OF Reliable-Transfer-APDU.RTORJapdu} +-- This OPTIONAL element shall be absent for a + x400-mode-parameters RTORJapdu, + -- This OPTIONAL element shall be absent for a + -- nested presentation connection. + -- Shall be used for X.410 mode only. Shall be bitwise + -- compatible with CCITT Recommendation X.410-1984. + -- This shall be the User data parameter of the CPR PPDU2) -- + normal-mode-parameters + SEQUENCE {protocol-version + [0] IMPLICIT Protocol-version DEFAULT {version-1}, + responding-presentation-selector + [3] IMPLICIT Responding-presentation-selector OPTIONAL, + presentation-context-definition-result-list + [5] IMPLICIT Presentation-context-definition-result-list + OPTIONAL, + default-context-result + [7] IMPLICIT Default-context-result OPTIONAL, + provider-reason + [10] IMPLICIT Provider-reason OPTIONAL, + user-data User-data OPTIONAL + } + -- Shall be used for normal mode only. +} + +-- +-- +-- The SS-user data parameter of the S-U-ABORT request and indication +-- service primitives shall be an Abort-type value. +-- +Abort-type ::= CHOICE { + aru-ppdu ARU-PPDU-- for a P-U-ABORT -- , + arp-ppdu ARP-PPDU -- for a P-P-ABORT +} + +-- +ARU-PPDU ::= CHOICE { +-- x400-mode-parameters SET {COMPONENTS OF Reliable-Transfer-APDU.RTABapdu} +-- Shall be used for X.410 mode only. Shall be bitwise + x400-mode-parameters RTABapdu, +-- Shall be used for X.410 mode only. Shall be bitwise + -- compatible with CCITT Recommendation X.410-1984. + -- This shall be the User data parameter of the ARU PPDU3. -- + normal-mode-parameters + [0] IMPLICIT SEQUENCE {presentation-context-identifier-list + [0] IMPLICIT Presentation-context-identifier-list + OPTIONAL, + user-data + User-data OPTIONAL} + -- Shall be used for normal mode only. +} + +-- +ARP-PPDU ::= SEQUENCE { + provider-reason [0] IMPLICIT Abort-reason OPTIONAL, + event-identifier [1] IMPLICIT Event-identifier OPTIONAL +} + +-- +-- +-- The SS-user data parameter value of the S-TYPED-DATA request +-- and indication service primitives shall be a Typed-data-type value. +-- +Typed-data-type ::= CHOICE { + acPPDU [0] IMPLICIT AC-PPDU-- P-ALTER-CONTEXT request and indication -- , + acaPPDU [1] IMPLICIT ACA-PPDU-- P-ALTER-CONTEXT response and confirm -- , + ttdPPDU User-data -- P-TYPED-DATA request and indication +} + +-- +AC-PPDU ::= SEQUENCE { + presentation-context-addition-list + [0] IMPLICIT Presentation-context-addition-list OPTIONAL, + presentation-context-deletion-list + [1] IMPLICIT Presentation-context-deletion-list OPTIONAL, + user-data User-data OPTIONAL +} + +-- +ACA-PPDU ::= SEQUENCE { + presentation-context-addition-result-list + [0] IMPLICIT Presentation-context-addition-result-list OPTIONAL, + presentation-context-deletion-result-list + [1] IMPLICIT Presentation-context-deletion-result-list OPTIONAL, + user-data User-data OPTIONAL +} + +-- +-- +-- The SS-user data parameter value of the S-RESYNCHRONIZE request and +-- indication service primitives shall be an RS-PPDU value. +-- +RS-PPDU ::= SEQUENCE { + presentation-context-identifier-list + [0] IMPLICIT Presentation-context-identifier-list OPTIONAL, + user-data User-data OPTIONAL +} + +-- +-- The SS-user data parameter value of the S-RESYNCHRONIZE response and +-- confirm service primitives shall be an RSA-PPDU value. +-- +RSA-PPDU ::= SEQUENCE { + presentation-context-identifier-list + [0] IMPLICIT Presentation-context-identifier-list OPTIONAL, + user-data User-data OPTIONAL +} + +-- +-- +-- The SS-user data parameter values of the S-DATA, S-CAPABILITY-DATA, +-- S-EXPEDITED-DATA request and indication session-service primitives +-- and S-CAPABILITY-DATA response and confirm session-service primitives +-- shall be of type User-data. +-- +-- The SS-user data parameter values of all other session-service +-- primitives not described above shall be of type User-data. +-- +-- +-- +Abort-reason ::= INTEGER { + reason-not-specified(0), unrecognized-ppdu(1), unexpected-ppdu(2), + unexpected-session-service-primitive(3), unrecognized-ppdu-parameter(4), + unexpected-ppdu-parameter(5), invalid-ppdu-parameter-value(6)} + +Abstract-syntax-name ::= OBJECT IDENTIFIER + +Called-presentation-selector ::= Presentation-selector + +Calling-presentation-selector ::= Presentation-selector + +Context-list ::= +-- SEQUENCE SIZE (0..7, ..., 8..MAX) OF + SEQUENCE OF + SEQUENCE {presentation-context-identifier Presentation-context-identifier, + abstract-syntax-name Abstract-syntax-name, + transfer-syntax-name-list SEQUENCE OF Transfer-syntax-name + } + +Default-context-name ::= SEQUENCE { + abstract-syntax-name [0] IMPLICIT Abstract-syntax-name, + transfer-syntax-name [1] IMPLICIT Transfer-syntax-name +} + +Default-context-result ::= Result + +Event-identifier ::= INTEGER { + cp-PPDU(0), cpa-PPDU(1), cpr-PPDU(2), aru-PPDU(3), arp-PPDU(4), ac-PPDU(5), + aca-PPDU(6), td-PPDU(7), ttd-PPDU(8), te-PPDU(9), tc-PPDU(10), tcc-PPDU(11), + rs-PPDU(12), rsa-PPDU(13), s-release-indication(14), s-release-confirm(15), + s-token-give-indication(16), s-token-please-indication(17), + s-control-give-indication(18), s-sync-minor-indication(19), + s-sync-minor-confirm(20), s-sync-major-indication(21), + s-sync-major-confirm(22), s-p-exception-report-indication(23), + s-u-exception-report-indication(24), s-activity-start-indication(25), + s-activity-resume-indication(26), s-activity-interrupt-indication(27), + s-activity-interrupt-confirm(28), s-activity-discard-indication(29), + s-activity-discard-confirm(30), s-activity-end-indication(31), + s-activity-end-confirm(32)} + +Mode-selector ::= SET { + mode-value [0] IMPLICIT INTEGER {x410-1984-mode(0), normal-mode(1)} +} + +Presentation-context-addition-list ::= Context-list + +Presentation-context-addition-result-list ::= Result-list + +Presentation-context-definition-list ::= Context-list + +Presentation-context-definition-result-list ::= Result-list + +Presentation-context-deletion-list ::= +-- SEQUENCE SIZE (0..7, ..., 8..MAX) OF Presentation-context-identifier + SEQUENCE OF Presentation-context-identifier + +Presentation-context-deletion-result-list ::= +-- SEQUENCE SIZE (0..7, ..., 8..MAX) OF + SEQUENCE OF + INTEGER {acceptance(0), user-rejection(1)} + +--Presentation-context-identifier ::= INTEGER(1..127, ..., 128..MAX) +Presentation-context-identifier ::= INTEGER + +Presentation-context-identifier-list ::= +-- SEQUENCE SIZE (0..7, ..., 8..MAX) OF + SEQUENCE OF + SEQUENCE {presentation-context-identifier Presentation-context-identifier, + transfer-syntax-name Transfer-syntax-name} + +Presentation-requirements ::= BIT STRING {context-management(0), restoration(1) +} + +--Presentation-selector ::= OCTET STRING(SIZE (1..4, ..., 5..MAX)) +Presentation-selector ::= OCTET STRING + +Protocol-options ::= BIT STRING { + nominated-context(0), short-encoding(1), packed-encoding-rules(2)} + +Protocol-version ::= BIT STRING {version-1(0)} + +Provider-reason ::= INTEGER { + reason-not-specified(0), temporary-congestion(1), local-limit-exceeded(2), + called-presentation-address-unknown(3), protocol-version-not-supported(4), + default-context-not-supported(5), user-data-not-readable(6), + no-PSAP-available(7)} + +Responding-presentation-selector ::= Presentation-selector + +Result ::= INTEGER {acceptance(0), user-rejection(1), provider-rejection(2)} + +Result-list ::= +-- SEQUENCE SIZE (0..7, ..., 8..MAX) OF + SEQUENCE OF + SEQUENCE {result [0] IMPLICIT Result, + transfer-syntax-name [1] IMPLICIT Transfer-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 + } + +Transfer-syntax-name ::= OBJECT IDENTIFIER + +User-data ::= CHOICE { + simply-encoded-data [APPLICATION 0] IMPLICIT Simply-encoded-data, + fully-encoded-data [APPLICATION 1] IMPLICIT Fully-encoded-data, + ... +} + +-- Subclause 8.4 defines when each of the two alternatives shall be used. +Simply-encoded-data ::= OCTET STRING + +-- See 8.4.1. +--Fully-encoded-data ::= SEQUENCE SIZE (1, ..., 2..MAX) OF PDV-list +Fully-encoded-data ::= SEQUENCE OF PDV-list + +-- contains one or more PDV-list values. +-- See 8.4.2. +PDV-list ::= SEQUENCE { + transfer-syntax-name Transfer-syntax-name OPTIONAL, + presentation-context-identifier Presentation-context-identifier, + presentation-data-values + CHOICE {single-ASN1-type [0] ANY, +-- [0] ABSTRACT-SYNTAX.&Type +-- (CONSTRAINED BY { + + -- Type corresponding to presentation context identifier }), + octet-aligned [1] IMPLICIT OCTET STRING, + arbitrary [2] IMPLICIT BIT STRING} + -- Contains one or more presentation data values from the same + -- presentation context. + -- See 8.4.2. +} + +User-session-requirements ::= BIT STRING { + half-duplex(0), duplex(1), expedited-data(2), minor-synchronize(3), + major-synchronize(4), resynchronize(5), activity-management(6), + negotiated-release(7), capability-data(8), exceptions(9), typed-data(10), + symmetric-synchronize(11), data-separation(12)} + +END diff --git a/epan/dissectors/asn1/pres/ISO9576-PRESENTATION.asn b/epan/dissectors/asn1/pres/ISO9576-PRESENTATION.asn new file mode 100644 index 00000000..19e99dc3 --- /dev/null +++ b/epan/dissectors/asn1/pres/ISO9576-PRESENTATION.asn @@ -0,0 +1,36 @@ +-- Module ISO9576-PRESENTATION (X.236) +ISO9576-CONNECTIONLESS-PRESENTATION DEFINITIONS ::= +BEGIN + +-- +-- The value of the SS-user data parameter of the S-UNIT-DATA request and indication +-- session-service primitives shall be a UD-type value, followed as a requestor's +-- option by zero or more UDC-type values. +-- + +UD-type ::= SEQUENCE { + protocol-version [0] IMPLICIT Protocol-version DEFAULT {version-1}, + calling-presentation-selector [1] IMPLICIT Calling-presentation-selector OPTIONAL, + called-presentation-selector [2] IMPLICIT Called-presentation-selector OPTIONAL, + presentation-context-definition-list [4] IMPLICIT + Presentation-context-definition-list OPTIONAL, + user-data User-data +} + +-- Shall be the parameters of the UD PPDU. +-- +-- As an initiator's option, the presentation data values contained in a UD PPDU may be +-- encoded more than once, using UDC-type values, to allow the transfer of the same +-- presentation data values using a number of different transfer syntaxes. +-- + +UDC-type ::= User-data +-- Shall not be present if the Presentation context definition list parameter is not present +-- in the UD PPDU. Each instance of this data type shall contain all of the presentation data +-- values which were contained in the User data parameter of the UD PPDU. +-- This shall be the same set of presentation data values which were contained in the UD-type. +-- + +-- WS: trunkated here as the rest is present in ISO8823-PRESENTATION.asn. + +END diff --git a/epan/dissectors/asn1/pres/packet-pres-template.c b/epan/dissectors/asn1/pres/packet-pres-template.c new file mode 100644 index 00000000..1b3c3fc5 --- /dev/null +++ b/epan/dissectors/asn1/pres/packet-pres-template.c @@ -0,0 +1,432 @@ +/* packet-pres.c + * Routine to dissect ISO 8823 OSI Presentation Protocol packets + * Based on the dissector by + * 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/prefs.h> +#include <epan/conversation.h> +#include <epan/expert.h> +#include <epan/uat.h> + +#include <epan/asn1.h> +#include <epan/oids.h> +#include "packet-ber.h" +#include "packet-ses.h" +#include "packet-pres.h" +#include "packet-rtse.h" + + +#define PNAME "ISO 8823 OSI Presentation Protocol" +#define PSNAME "PRES" +#define PFNAME "pres" + +#define CLPNAME "ISO 9576-1 OSI Connectionless Presentation Protocol" +#define CLPSNAME "CLPRES" +#define CLPFNAME "clpres" + +void proto_register_pres(void); +void proto_reg_handoff_pres(void); + +/* Initialize the protocol and registered fields */ +static int proto_pres = -1; + +/* Initialize the connectionles protocol */ +static int proto_clpres = -1; + +/* pointers for acse dissector */ +proto_tree *global_tree = NULL; +packet_info *global_pinfo = NULL; + +static const char *abstract_syntax_name_oid; +static guint32 presentation_context_identifier; + +/* to keep track of presentation context identifiers and protocol-oids */ +typedef struct _pres_ctx_oid_t { + guint32 ctx_id; + char *oid; + guint32 idx; +} pres_ctx_oid_t; +static wmem_map_t *pres_ctx_oid_table = NULL; + +typedef struct _pres_user_t { + guint ctx_id; + char *oid; +} pres_user_t; + +static pres_user_t *pres_users; +static guint num_pres_users; + +static int hf_pres_CP_type = -1; +static int hf_pres_CPA_PPDU = -1; +static int hf_pres_Abort_type = -1; +static int hf_pres_CPR_PPDU = -1; +static int hf_pres_Typed_data_type = -1; + +#include "packet-pres-hf.c" + +/* Initialize the subtree pointers */ +static gint ett_pres = -1; + +#include "packet-pres-ett.c" + +static expert_field ei_pres_dissector_not_available = EI_INIT; +static expert_field ei_pres_wrong_spdu_type = EI_INIT; +static expert_field ei_pres_invalid_offset = EI_INIT; + +UAT_DEC_CB_DEF(pres_users, ctx_id, pres_user_t) +UAT_CSTRING_CB_DEF(pres_users, oid, pres_user_t) + +static guint +pres_ctx_oid_hash(gconstpointer k) +{ + const pres_ctx_oid_t *pco=(const pres_ctx_oid_t *)k; + return pco->ctx_id; +} + +static gint +pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2) +{ + const pres_ctx_oid_t *pco1=(const pres_ctx_oid_t *)k1; + const pres_ctx_oid_t *pco2=(const pres_ctx_oid_t *)k2; + return (pco1->ctx_id==pco2->ctx_id && pco1->idx==pco2->idx); +} + +static void +register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) +{ + pres_ctx_oid_t *pco, *tmppco; + conversation_t *conversation; + + if (!oid) { + /* we did not get any oid name, malformed packet? */ + return; + } + + pco=wmem_new(wmem_file_scope(), pres_ctx_oid_t); + pco->ctx_id=idx; + pco->oid=wmem_strdup(wmem_file_scope(), oid); + conversation=find_conversation_pinfo(pinfo, 0); + if (conversation) { + pco->idx = conversation->conv_index; + } else { + pco->idx = 0; + } + + /* if this ctx already exists, remove the old one first */ + tmppco=(pres_ctx_oid_t *)wmem_map_lookup(pres_ctx_oid_table, pco); + if (tmppco) { + wmem_map_remove(pres_ctx_oid_table, tmppco); + } + wmem_map_insert(pres_ctx_oid_table, pco, pco); +} + +static char * +find_oid_in_users_table(packet_info *pinfo, guint32 ctx_id) +{ + guint i; + + for (i = 0; i < num_pres_users; i++) { + pres_user_t *u = &(pres_users[i]); + + if (u->ctx_id == ctx_id) { + /* Register oid so other dissectors can find this connection */ + register_ctx_id_and_oid(pinfo, u->ctx_id, u->oid); + return u->oid; + } + } + + return NULL; +} + +char * +find_oid_by_pres_ctx_id(packet_info *pinfo, guint32 idx) +{ + pres_ctx_oid_t pco, *tmppco; + conversation_t *conversation; + + pco.ctx_id=idx; + conversation=find_conversation_pinfo(pinfo, 0); + if (conversation) { + pco.idx = conversation->conv_index; + } else { + pco.idx = 0; + } + + tmppco=(pres_ctx_oid_t *)wmem_map_lookup(pres_ctx_oid_table, &pco); + if (tmppco) { + return tmppco->oid; + } + + return find_oid_in_users_table(pinfo, idx); +} + +static void * +pres_copy_cb(void *dest, const void *orig, size_t len _U_) +{ + pres_user_t *u = (pres_user_t *)dest; + const pres_user_t *o = (const pres_user_t *)orig; + + u->ctx_id = o->ctx_id; + u->oid = g_strdup(o->oid); + + return dest; +} + +static void +pres_free_cb(void *r) +{ + pres_user_t *u = (pres_user_t *)r; + + g_free(u->oid); +} + + +#include "packet-pres-fn.c" + + +/* + * Dissect an PPDU. + */ +static int +dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, struct SESSION_DATA_STRUCTURE* local_session) +{ + proto_item *ti; + proto_tree *pres_tree; + 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 (local_session == NULL) { + proto_tree_add_expert(tree, pinfo, &ei_pres_wrong_spdu_type, tvb, offset, -1); + return 0; + } + + session = local_session; + if (session->spdu_type == 0) { + proto_tree_add_expert_format(tree, pinfo, &ei_pres_wrong_spdu_type, tvb, offset, -1, + "Internal error:wrong spdu type %x from session dissector.",session->spdu_type); + return 0; + } + + /* set up type of PPDU */ + col_add_str(pinfo->cinfo, COL_INFO, + val_to_str_ext(session->spdu_type, &ses_vals_ext, "Unknown PPDU type (0x%02x)")); + + asn1_ctx.private_data = session; + + ti = proto_tree_add_item(tree, proto_pres, tvb, offset, -1, ENC_NA); + pres_tree = proto_item_add_subtree(ti, ett_pres); + + switch (session->spdu_type) { + case SES_CONNECTION_REQUEST: + offset = dissect_pres_CP_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CP_type); + break; + case SES_CONNECTION_ACCEPT: + offset = dissect_pres_CPA_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CPA_PPDU); + break; + case SES_ABORT: + case SES_ABORT_ACCEPT: + offset = dissect_pres_Abort_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_Abort_type); + break; + case SES_DATA_TRANSFER: + offset = dissect_pres_CPC_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_user_data); + break; + case SES_TYPED_DATA: + offset = dissect_pres_Typed_data_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_Typed_data_type); + break; + case SES_RESYNCHRONIZE: + offset = dissect_pres_RS_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, -1); + break; + case SES_RESYNCHRONIZE_ACK: + offset = dissect_pres_RSA_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, -1); + break; + case SES_REFUSE: + offset = dissect_pres_CPR_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CPR_PPDU); + break; + default: + offset = dissect_pres_CPC_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_user_data); + break; + } + + return offset; +} + +static int +dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) +{ + int offset = 0, old_offset; + struct SESSION_DATA_STRUCTURE* session; + + session = ((struct SESSION_DATA_STRUCTURE*)data); + + /* first, try to check length */ + /* do we have at least 4 bytes */ + if (!tvb_bytes_exist(tvb, 0, 4)) { + if (session && session->spdu_type != SES_MAJOR_SYNC_POINT) { + proto_tree_add_item(parent_tree, hf_pres_user_data, tvb, offset, + tvb_reported_length_remaining(tvb,offset), ENC_NA); + return 0; /* no, it isn't a presentation PDU */ + } + } + + /* save pointers for calling the acse dissector */ + global_tree = parent_tree; + global_pinfo = pinfo; + + /* if the session unit-data packet then we process it */ + /* as a connectionless presentation protocol unit data */ + if (session && session->spdu_type == CLSES_UNIT_DATA) { + proto_tree * clpres_tree = NULL; + proto_item *ti; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CL-PRES"); + col_clear(pinfo->cinfo, COL_INFO); + + if (parent_tree) { + ti = proto_tree_add_item(parent_tree, proto_clpres, tvb, offset, -1, ENC_NA); + clpres_tree = proto_item_add_subtree(ti, ett_pres); + } + + /* dissect the packet */ + dissect_UD_type_PDU(tvb, pinfo, clpres_tree, NULL); + return tvb_captured_length(tvb); + } + + /* we can't make any additional checking here */ + /* postpone it before dissector will have more information */ + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "PRES"); + col_clear(pinfo->cinfo, COL_INFO); + + if (session && session->spdu_type == SES_MAJOR_SYNC_POINT) { + /* This is a reassembly initiated in packet-ses */ + char *oid = find_oid_by_pres_ctx_id (pinfo, session->pres_ctx_id); + if (oid) { + call_ber_oid_callback (oid, tvb, offset, pinfo, parent_tree, session); + } else { + proto_tree_add_item(parent_tree, hf_pres_user_data, tvb, offset, + tvb_reported_length_remaining(tvb,offset), ENC_NA); + } + return tvb_captured_length(tvb); + } + + while (tvb_reported_length_remaining(tvb, offset) > 0) { + old_offset = offset; + offset = dissect_ppdu(tvb, offset, pinfo, parent_tree, session); + if (offset <= old_offset) { + proto_tree_add_expert(parent_tree, pinfo, &ei_pres_invalid_offset, tvb, offset, -1); + break; + } + } + + return tvb_captured_length(tvb); +} + + +/*--- proto_register_pres -------------------------------------------*/ +void proto_register_pres(void) { + + /* List of fields */ + static hf_register_info hf[] = { + { &hf_pres_CP_type, + { "CP-type", "pres.cptype", + FT_NONE, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_pres_CPA_PPDU, + { "CPA-PPDU", "pres.cpapdu", + FT_NONE, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_pres_Abort_type, + { "Abort type", "pres.aborttype", + FT_UINT32, BASE_DEC, VALS(pres_Abort_type_vals), 0, + NULL, HFILL }}, + { &hf_pres_CPR_PPDU, + { "CPR-PPDU", "pres.cprtype", + FT_UINT32, BASE_DEC, VALS(pres_CPR_PPDU_vals), 0, + NULL, HFILL }}, + { &hf_pres_Typed_data_type, + { "Typed data type", "pres.Typed_data_type", + FT_UINT32, BASE_DEC, VALS(pres_Typed_data_type_vals), 0, + NULL, HFILL }}, + +#include "packet-pres-hfarr.c" + }; + + /* List of subtrees */ + static gint *ett[] = { + &ett_pres, +#include "packet-pres-ettarr.c" + }; + + static ei_register_info ei[] = { + { &ei_pres_dissector_not_available, { "pres.dissector_not_available", PI_UNDECODED, PI_WARN, "Dissector is not available", EXPFILL }}, + { &ei_pres_wrong_spdu_type, { "pres.wrong_spdu_type", PI_PROTOCOL, PI_WARN, "Internal error:can't get spdu type from session dissector", EXPFILL }}, + { &ei_pres_invalid_offset, { "pres.invalid_offset", PI_MALFORMED, PI_ERROR, "Internal error:can't get spdu type from session dissector", EXPFILL }}, + }; + + static uat_field_t users_flds[] = { + UAT_FLD_DEC(pres_users,ctx_id,"Context Id","Presentation Context Identifier"), + UAT_FLD_CSTRING(pres_users,oid,"Syntax Name OID","Abstract Syntax Name (Object Identifier)"), + UAT_END_FIELDS + }; + + uat_t* users_uat = uat_new("PRES Users Context List", + sizeof(pres_user_t), + "pres_context_list", + TRUE, + &pres_users, + &num_pres_users, + UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ + "ChPresContextList", + pres_copy_cb, + NULL, + pres_free_cb, + NULL, + NULL, + users_flds); + + expert_module_t* expert_pres; + module_t *pres_module; + + /* Register protocol */ + proto_pres = proto_register_protocol(PNAME, PSNAME, PFNAME); + register_dissector("pres", dissect_pres, proto_pres); + + /* Register connectionless protocol (just for the description) */ + proto_clpres = proto_register_protocol(CLPNAME, CLPSNAME, CLPFNAME); + + /* Register fields and subtrees */ + proto_register_field_array(proto_pres, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + expert_pres = expert_register_protocol(proto_pres); + expert_register_field_array(expert_pres, ei, array_length(ei)); + pres_ctx_oid_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pres_ctx_oid_hash, pres_ctx_oid_equal); + + pres_module = prefs_register_protocol(proto_pres, NULL); + + prefs_register_uat_preference(pres_module, "users_table", "Users Context List", + "A table that enumerates user protocols to be used against" + " specific presentation context identifiers", + users_uat); +} + + +/*--- proto_reg_handoff_pres ---------------------------------------*/ +void proto_reg_handoff_pres(void) { + +/* register_ber_oid_dissector("0.4.0.0.1.1.1.1", dissect_pres, proto_pres, + "itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) abstractSyntax(1) pres(1) version1(1)"); */ + +} diff --git a/epan/dissectors/asn1/pres/packet-pres-template.h b/epan/dissectors/asn1/pres/packet-pres-template.h new file mode 100644 index 00000000..b7dd7ac9 --- /dev/null +++ b/epan/dissectors/asn1/pres/packet-pres-template.h @@ -0,0 +1,18 @@ +/* packet-pres.h + * Routines for pres packet dissection + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PACKET_PRES_H +#define PACKET_PRES_H + +/*#include "packet-pres-exp.h"*/ + +extern char *find_oid_by_pres_ctx_id(packet_info *pinfo, guint32 idx); + +#endif /* PACKET_PRES_H */ diff --git a/epan/dissectors/asn1/pres/pres.cnf b/epan/dissectors/asn1/pres/pres.cnf new file mode 100644 index 00000000..fecdf0a8 --- /dev/null +++ b/epan/dissectors/asn1/pres/pres.cnf @@ -0,0 +1,101 @@ +# pres.cnf +# pres conformation file + +#.IMPORT ../rtse/rtse-exp.cnf + +#.EXPORTS + +#.PDU +UD-type + +#.NO_EMIT +UDC-type + +#.TYPE_RENAME +CPA-PPDU/normal-mode-parameters T_CPA_PPDU_normal_mode_parameters +CPR-PPDU/normal-mode-parameters T_CPR_PPDU_normal_mode_parameters +ARU-PPDU/normal-mode-parameters T_ARU_PPDU_normal_mode_parameters + +#.FIELD_RENAME +ARU-PPDU/normal-mode-parameters aRU_PPDU_normal_mode_parameters +CPA-PPDU/normal-mode-parameters cPU_PPDU_normal_mode_parameters +CPR-PPDU/normal-mode-parameters cPR_PPDU_normal_mode_parameters + +ARU-PPDU/x400-mode-parameters aRU_PPDU_x400_mode_parameters +CPR-PPDU/x400-mode-parameters cPU_PPDU_x400_mode_parameters +CPA-PPDU/x410-mode-parameters cPR_PPDU_x400_mode_parameters + +ARP-PPDU/provider-reason aRU_PPDU_provider-reason +CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason + + + + +#.FN_BODY PDV-list/presentation-data-values/single-ASN1-type + + tvbuff_t *next_tvb; + char *oid; + + oid=find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier); + if(oid){ + next_tvb = tvb_new_subset_remaining(tvb, offset); + call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree, actx->private_data); + } else { + proto_tree_add_expert(tree, actx->pinfo, &ei_pres_dissector_not_available, + tvb, offset, -1); + } + +#.FN_BODY PDV-list/presentation-data-values/octet-aligned + + tvbuff_t *next_tvb; + char *oid; + + oid=find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier); + if(oid){ + dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &next_tvb); + call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree, actx->private_data); + } else { + proto_tree_add_expert(tree, actx->pinfo, &ei_pres_dissector_not_available, + tvb, offset, -1); + %(DEFAULT_BODY)s + } + + +#.FN_PARS Abstract-syntax-name + FN_VARIANT = _str VAL_PTR = &abstract_syntax_name_oid + +#.FN_PARS Presentation-context-identifier + VAL_PTR = &presentation_context_identifier + +#.FN_BODY Presentation-context-identifier + const char *name; + char *oid; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; + + %(DEFAULT_BODY)s + + if(session) + session->pres_ctx_id = presentation_context_identifier; + + oid = find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier); + + if(oid && (name = oid_resolved_from_string(actx->pinfo->pool, oid))) { + proto_item_append_text(actx->created_item, " (%%s)", name); + } + +#.FN_PARS Abort-reason + VAL_PTR = &reason + +#.FN_BODY Abort-reason + guint32 reason; + + %(DEFAULT_BODY)s + + col_append_fstr(actx->pinfo->cinfo, COL_INFO, " (%%s)", val_to_str(reason, pres_Abort_reason_vals, "unknown: %%d")); + +#.FN_HDR Context-list/_item + abstract_syntax_name_oid=NULL; +#.END +#.FN_FTR Context-list/_item + register_ctx_id_and_oid(actx->pinfo, presentation_context_identifier, abstract_syntax_name_oid); +#.END |