diff options
author | Uwe Heuert <uwe.heuert@exceeding-solutions.de> | 2022-12-09 12:25:20 +0100 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2023-01-03 07:44:19 +0000 |
commit | eb05f77b71f9bdc3798afd39159003179eeb15d4 (patch) | |
tree | c55c0195503f99bb3590bb49fe4dfcb29cd74a65 /epan/dissectors | |
parent | e60dc74d9015112e58e8240de5e1617e62a39762 (diff) |
BSI TR-03109 required extensions
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/asn1/cms/CryptographicMessageSyntax.asn | 85 | ||||
-rw-r--r-- | epan/dissectors/asn1/cms/cms.cnf | 15 | ||||
-rw-r--r-- | epan/dissectors/asn1/cms/packet-cms-template.c | 49 | ||||
-rw-r--r-- | epan/dissectors/asn1/cms/packet-cms-template.h | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-cms.c | 219 | ||||
-rw-r--r-- | epan/dissectors/packet-cms.h | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-sml.c | 507 |
7 files changed, 785 insertions, 93 deletions
diff --git a/epan/dissectors/asn1/cms/CryptographicMessageSyntax.asn b/epan/dissectors/asn1/cms/CryptographicMessageSyntax.asn index 3ade46892a..a2b9d92185 100644 --- a/epan/dissectors/asn1/cms/CryptographicMessageSyntax.asn +++ b/epan/dissectors/asn1/cms/CryptographicMessageSyntax.asn @@ -398,3 +398,88 @@ RC2CBCParameters ::= CHOICE { END -- of CryptographicMessageSyntax2004 + +CMS-AuthEnvelopedData-2007 { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) + pkcs-9(9) smime(16) modules(0) cms-authEnvelopedData(31) } + +DEFINITIONS IMPLICIT TAGS ::= +BEGIN + +-- EXPORTS All +-- The types and values defined in this module are exported for use +-- in the other ASN.1 modules. Other applications may use them for +-- their own purposes. + +-- IMPORTS + +-- Imports from RFC 3852 [CMS], Section 12.1 +-- AuthAttributes, +-- CMSVersion, +-- EncryptedContentInfo, +-- MessageAuthenticationCode, +-- OriginatorInfo, +-- RecipientInfos, +-- UnauthAttributes +-- FROM CryptographicMessageSyntax2004 +-- { iso(1) member-body(2) us(840) rsadsi(113549) +-- pkcs(1) pkcs-9(9) smime(16) modules(0) +-- cms-2004(24) } ; + + +AuthEnvelopedData ::= SEQUENCE { + version CMSVersion, + originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, + recipientInfos RecipientInfos, + authEncryptedContentInfo EncryptedContentInfo, + authAttrs [1] IMPLICIT AuthAttributes OPTIONAL, + mac MessageAuthenticationCode, + unauthAttrs [2] IMPLICIT UnauthAttributes OPTIONAL } + +id-ct-authEnvelopedData OBJECT IDENTIFIER ::= { iso(1) + member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9) + smime(16) ct(1) 23 } + +END -- of CMS-AuthEnvelopedData-2007 + +CMS-AES-CCM-and-AES-GCM + { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) + pkcs-9(9) smime(16) modules(0) cms-aes-ccm-and-gcm(32) } + +DEFINITIONS IMPLICIT TAGS ::= BEGIN + +-- EXPORTS All + +-- Object Identifiers + +aes OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) + organization(1) gov(101) csor(3) nistAlgorithm(4) 1 } + +id-aes128-CCM OBJECT IDENTIFIER ::= { aes 7 } + +id-aes192-CCM OBJECT IDENTIFIER ::= { aes 27 } + +id-aes256-CCM OBJECT IDENTIFIER ::= { aes 47 } + +id-aes128-GCM OBJECT IDENTIFIER ::= { aes 6 } + +id-aes192-GCM OBJECT IDENTIFIER ::= { aes 26 } + +id-aes256-GCM OBJECT IDENTIFIER ::= { aes 46 } + + +-- Parameters for AigorithmIdentifier + +CCMParameters ::= SEQUENCE { + aes-nonce OCTET STRING (SIZE(7..13)), + aes-ICVlen AES-CCM-ICVlen DEFAULT 12 } + +AES-CCM-ICVlen ::= INTEGER (4 | 6 | 8 | 10 | 12 | 14 | 16) + +GCMParameters ::= SEQUENCE { + aes-nonce OCTET STRING, -- recommended size is 12 octets + aes-ICVlen AES-GCM-ICVlen DEFAULT 12 } + +AES-GCM-ICVlen ::= INTEGER (12 | 13 | 14 | 15 | 16) + +END + diff --git a/epan/dissectors/asn1/cms/cms.cnf b/epan/dissectors/asn1/cms/cms.cnf index 6f0402fa0a..e067c55add 100644 --- a/epan/dissectors/asn1/cms/cms.cnf +++ b/epan/dissectors/asn1/cms/cms.cnf @@ -21,6 +21,7 @@ DigestAlgorithmIdentifiers DigestInfo EncapsulatedContentInfo EnvelopedData +AuthEnvelopedData IssuerAndSerialNumber SignedAttributes SignedData @@ -38,6 +39,8 @@ EnvelopedData B "1.2.840.113549.1.7.3" "id-envelopedData" DigestedData B "1.2.840.113549.1.7.5" "id-digestedData" EncryptedData B "1.2.840.113549.1.7.6" "id-encryptedData" AuthenticatedData B "1.2.840.113549.1.9.16.1.2" "id-ct-authenticatedData" +EncryptedContentInfo B "1.2.840.113549.1.9.16.1.9" "id-ct-compressedData" +AuthEnvelopedData B "1.2.840.113549.1.9.16.1.23" "id-ct-authEnvelopedData" ContentType B "1.2.840.113549.1.9.3" "id-contentType" MessageDigest B "1.2.840.113549.1.9.4" "id-messageDigest" @@ -53,6 +56,18 @@ SMIMEEncryptionKeyPreference B "1.2.840.113549.1.9.16.2.11" "id-encryption-key-p # I think the following should be RC2CBCParameter - but that appears to be incorrect RC2CBCParameters B "1.2.840.113549.3.4" "id-alg-rc4" +KeyEncryptionAlgorithmIdentifier B "0.4.0.127.0.7.1.1.5.1.1.3" "ecka-eg-X963KDF-SHA256" +KeyEncryptionAlgorithmIdentifier B "0.4.0.127.0.7.1.1.5.1.1.4" "ecka-eg-X963KDF-SHA384" +KeyEncryptionAlgorithmIdentifier B "0.4.0.127.0.7.1.1.5.1.1.5" "ecka-eg-X963KDF-SHA512" + +KeyEncryptionAlgorithmIdentifier B "2.16.840.1.101.3.4.1.5" "id-aes128-wrap" +KeyEncryptionAlgorithmIdentifier B "2.16.840.1.101.3.4.1.25" "id-aes192-wrap" +KeyEncryptionAlgorithmIdentifier B "2.16.840.1.101.3.4.1.45" "id-aes256-wrap" + +GCMParameters B "2.16.840.1.101.3.4.1.6" "id-aes128-GCM" +GCMParameters B "2.16.840.1.101.3.4.1.26" "id-aes192-GCM" +GCMParameters B "2.16.840.1.101.3.4.1.46" "id-aes256-GCM" + # EC algorithms from RFC 3278 / RFC 5753 KeyWrapAlgorithm B "1.3.133.16.840.63.0.2" "dhSinglePass-stdDH-sha1kdf-scheme" KeyWrapAlgorithm B "1.3.132.1.11.0" "dhSinglePass-stdDH-sha224kdf-scheme" diff --git a/epan/dissectors/asn1/cms/packet-cms-template.c b/epan/dissectors/asn1/cms/packet-cms-template.c index 52164a6df0..e1d4f2791c 100644 --- a/epan/dissectors/asn1/cms/packet-cms-template.c +++ b/epan/dissectors/asn1/cms/packet-cms-template.c @@ -2,6 +2,7 @@ * Routines for RFC5652 Cryptographic Message Syntax packet dissection * Ronnie Sahlberg 2004 * Stig Bjorlykke 2010 + * Uwe Heuert 2022 * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> @@ -39,8 +40,11 @@ static int hf_cms_ci_contentType = -1; #include "packet-cms-hf.c" /* Initialize the subtree pointers */ +static gint ett_cms = -1; #include "packet-cms-ett.c" +static dissector_handle_t cms_handle = NULL; + static int dissect_cms_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) ; /* XXX kill a compiler warning until asn2wrs stops generating these silly wrappers */ struct cms_private_data { @@ -64,6 +68,31 @@ static proto_tree *cap_tree=NULL; unsigned char digest_buf[MAX(HASH_SHA1_LENGTH, HASH_MD5_LENGTH)]; +/* +* Dissect CMS PDUs inside a PPDU. +*/ +static int +dissect_cms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) +{ + int offset = 0; + proto_item *item=NULL; + proto_tree *tree=NULL; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + + if(parent_tree){ + item = proto_tree_add_item(parent_tree, proto_cms, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_cms); + } + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMS"); + col_clear(pinfo->cinfo, COL_INFO); + + while (tvb_reported_length_remaining(tvb, offset) > 0){ + offset=dissect_cms_ContentInfo(FALSE, tvb, offset, &asn1_ctx , tree, -1); + } + return tvb_captured_length(tvb); +} + static struct cms_private_data* cms_get_private_data(packet_info *pinfo) { @@ -127,12 +156,15 @@ void proto_register_cms(void) { /* List of subtrees */ static gint *ett[] = { + &ett_cms, #include "packet-cms-ettarr.c" }; /* Register protocol */ proto_cms = proto_register_protocol(PNAME, PSNAME, PFNAME); + cms_handle = register_dissector(PFNAME, dissect_cms, proto_cms); + /* Register fields and subtrees */ proto_register_field_array(proto_cms, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -156,10 +188,25 @@ void proto_reg_handoff_cms(void) { register_ber_oid_dissector("1.2.840.113549.1.9.16.3.6", dissect_ber_oid_NULL_callback, proto_cms, "id-alg-CMS3DESwrap"); oid_add_from_string("id-data","1.2.840.113549.1.7.1"); + oid_add_from_string("id-alg-des-ede3-cbc","1.2.840.113549.3.7"); oid_add_from_string("id-alg-des-cbc","1.3.14.3.2.7"); + oid_add_from_string("id-ct-authEnvelopedData","1.2.840.113549.1.9.16.1.23"); + oid_add_from_string("id-aes-CBC-CMAC-128","0.4.0.127.0.7.1.3.1.1.2"); + oid_add_from_string("id-aes-CBC-CMAC-192","0.4.0.127.0.7.1.3.1.1.3"); + oid_add_from_string("id-aes-CBC-CMAC-256","0.4.0.127.0.7.1.3.1.1.4"); + oid_add_from_string("ecdsaWithSHA256","1.2.840.10045.4.3.2"); + oid_add_from_string("ecdsaWithSHA384","1.2.840.10045.4.3.3"); + oid_add_from_string("ecdsaWithSHA512","1.2.840.10045.4.3.4"); + content_info_handle = create_dissector_handle (dissect_ContentInfo_PDU, proto_cms); + dissector_add_string("media_type", "application/pkcs7-mime", content_info_handle); dissector_add_string("media_type", "application/pkcs7-signature", content_info_handle); - dissector_add_string("rfc7468.preeb_label", "CMS", content_info_handle); + + dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml", content_info_handle); + dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml; encap=cms-tr03109", content_info_handle); + dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml; encap=cms-tr03109-zlib", content_info_handle); + dissector_add_string("media_type", "application/hgp;encap=cms", content_info_handle); } + diff --git a/epan/dissectors/asn1/cms/packet-cms-template.h b/epan/dissectors/asn1/cms/packet-cms-template.h index fc72844c75..eb1f45fbee 100644 --- a/epan/dissectors/asn1/cms/packet-cms-template.h +++ b/epan/dissectors/asn1/cms/packet-cms-template.h @@ -2,6 +2,7 @@ * Routines for RFC5652 Cryptographic Message Syntax packet dissection * Ronnie Sahlberg 2004 * Stig Bjorlykke 2010 + * Uwe Heuert 2022 * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> diff --git a/epan/dissectors/packet-cms.c b/epan/dissectors/packet-cms.c index c6a9da78fe..ec95eedc1a 100644 --- a/epan/dissectors/packet-cms.c +++ b/epan/dissectors/packet-cms.c @@ -7,6 +7,7 @@ * Routines for RFC5652 Cryptographic Message Syntax packet dissection * Ronnie Sahlberg 2004 * Stig Bjorlykke 2010 + * Uwe Heuert 2022 * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> @@ -45,9 +46,11 @@ static int hf_cms_ContentInfo_PDU = -1; /* ContentInfo */ static int hf_cms_ContentType_PDU = -1; /* ContentType */ static int hf_cms_SignedData_PDU = -1; /* SignedData */ static int hf_cms_EnvelopedData_PDU = -1; /* EnvelopedData */ +static int hf_cms_EncryptedContentInfo_PDU = -1; /* EncryptedContentInfo */ static int hf_cms_DigestedData_PDU = -1; /* DigestedData */ static int hf_cms_EncryptedData_PDU = -1; /* EncryptedData */ static int hf_cms_AuthenticatedData_PDU = -1; /* AuthenticatedData */ +static int hf_cms_KeyEncryptionAlgorithmIdentifier_PDU = -1; /* KeyEncryptionAlgorithmIdentifier */ static int hf_cms_IssuerAndSerialNumber_PDU = -1; /* IssuerAndSerialNumber */ static int hf_cms_MessageDigest_PDU = -1; /* MessageDigest */ static int hf_cms_SigningTime_PDU = -1; /* SigningTime */ @@ -58,6 +61,8 @@ static int hf_cms_IV_PDU = -1; /* IV */ static int hf_cms_SMIMECapabilities_PDU = -1; /* SMIMECapabilities */ static int hf_cms_SMIMEEncryptionKeyPreference_PDU = -1; /* SMIMEEncryptionKeyPreference */ static int hf_cms_RC2CBCParameters_PDU = -1; /* RC2CBCParameters */ +static int hf_cms_AuthEnvelopedData_PDU = -1; /* AuthEnvelopedData */ +static int hf_cms_GCMParameters_PDU = -1; /* GCMParameters */ static int hf_cms_FirmwarePkgData_PDU = -1; /* FirmwarePkgData */ static int hf_cms_FirmwarePackageIdentifier_PDU = -1; /* FirmwarePackageIdentifier */ static int hf_cms_TargetHardwareIdentifiers_PDU = -1; /* TargetHardwareIdentifiers */ @@ -165,6 +170,11 @@ static int hf_cms_recipientKeyId = -1; /* RecipientKeyIdentifier */ static int hf_cms_subjectAltKeyIdentifier = -1; /* SubjectKeyIdentifier */ static int hf_cms_rc2WrapParameter = -1; /* RC2WrapParameter */ static int hf_cms_rc2CBCParameter = -1; /* RC2CBCParameter */ +static int hf_cms_authEncryptedContentInfo = -1; /* EncryptedContentInfo */ +static int hf_cms_aes_nonce = -1; /* OCTET_STRING_SIZE_7_13 */ +static int hf_cms_aes_ICVlen = -1; /* AES_CCM_ICVlen */ +static int hf_cms_aes_nonce_01 = -1; /* OCTET_STRING */ +static int hf_cms_aes_ICVlen_01 = -1; /* AES_GCM_ICVlen */ static int hf_cms_acInfo = -1; /* AttributeCertificateInfoV1 */ static int hf_cms_signatureAlgorithm_v1 = -1; /* AlgorithmIdentifier */ static int hf_cms_signatureValue_v1 = -1; /* BIT_STRING */ @@ -217,6 +227,7 @@ static int hf_cms_config_item = -1; /* CurrentFWConfig */ static int hf_cms_msgDigest = -1; /* OCTET_STRING */ /* Initialize the subtree pointers */ +static gint ett_cms = -1; static gint ett_cms_ContentInfo = -1; static gint ett_cms_SignedData = -1; static gint ett_cms_DigestAlgorithmIdentifiers = -1; @@ -268,6 +279,9 @@ static gint ett_cms_SMIMECapabilities = -1; static gint ett_cms_SMIMECapability = -1; static gint ett_cms_SMIMEEncryptionKeyPreference = -1; static gint ett_cms_RC2CBCParameters = -1; +static gint ett_cms_AuthEnvelopedData = -1; +static gint ett_cms_CCMParameters = -1; +static gint ett_cms_GCMParameters = -1; static gint ett_cms_AttributeCertificateV1 = -1; static gint ett_cms_AttributeCertificateInfoV1 = -1; static gint ett_cms_T_subject = -1; @@ -294,6 +308,8 @@ static gint ett_cms_CurrentFWConfig = -1; static gint ett_cms_HardwareModuleName = -1; static gint ett_cms_FirmwarePackageMessageDigest = -1; +static dissector_handle_t cms_handle = NULL; + static int dissect_cms_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) ; /* XXX kill a compiler warning until asn2wrs stops generating these silly wrappers */ struct cms_private_data { @@ -317,6 +333,31 @@ static proto_tree *cap_tree=NULL; unsigned char digest_buf[MAX(HASH_SHA1_LENGTH, HASH_MD5_LENGTH)]; +/* +* Dissect CMS PDUs inside a PPDU. +*/ +static int +dissect_cms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) +{ + int offset = 0; + proto_item *item=NULL; + proto_tree *tree=NULL; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + + if(parent_tree){ + item = proto_tree_add_item(parent_tree, proto_cms, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_cms); + } + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMS"); + col_clear(pinfo->cinfo, COL_INFO); + + while (tvb_reported_length_remaining(tvb, offset) > 0){ + offset=dissect_cms_ContentInfo(FALSE, tvb, offset, &asn1_ctx , tree, -1); + } + return tvb_captured_length(tvb); +} + static struct cms_private_data* cms_get_private_data(packet_info *pinfo) { @@ -1809,6 +1850,86 @@ dissect_cms_RC2CBCParameters(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o } +static const ber_sequence_t AuthEnvelopedData_sequence[] = { + { &hf_cms_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_cms_CMSVersion }, + { &hf_cms_originatorInfo , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_cms_OriginatorInfo }, + { &hf_cms_recipientInfos , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_cms_RecipientInfos }, + { &hf_cms_authEncryptedContentInfo, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cms_EncryptedContentInfo }, + { &hf_cms_authAttrs , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_cms_AuthAttributes }, + { &hf_cms_mac , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_cms_MessageAuthenticationCode }, + { &hf_cms_unauthAttrs , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_cms_UnauthAttributes }, + { NULL, 0, 0, 0, NULL } +}; + +int +dissect_cms_AuthEnvelopedData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, + AuthEnvelopedData_sequence, hf_index, ett_cms_AuthEnvelopedData); + + return offset; +} + + + +static int +dissect_cms_OCTET_STRING_SIZE_7_13(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset, + 7, 13, hf_index, NULL); + + return offset; +} + + + +static int +dissect_cms_AES_CCM_ICVlen(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset, + 4U, 16U, hf_index, NULL); + + return offset; +} + + +static const ber_sequence_t CCMParameters_sequence[] = { + { &hf_cms_aes_nonce , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_cms_OCTET_STRING_SIZE_7_13 }, + { &hf_cms_aes_ICVlen , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_cms_AES_CCM_ICVlen }, + { NULL, 0, 0, 0, NULL } +}; + +static int +dissect_cms_CCMParameters(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, + CCMParameters_sequence, hf_index, ett_cms_CCMParameters); + + return offset; +} + + + +static int +dissect_cms_AES_GCM_ICVlen(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset, + 12U, 16U, hf_index, NULL); + + return offset; +} + + +static const ber_sequence_t GCMParameters_sequence[] = { + { &hf_cms_aes_nonce_01 , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_cms_OCTET_STRING }, + { &hf_cms_aes_ICVlen_01 , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_cms_AES_GCM_ICVlen }, + { NULL, 0, 0, 0, NULL } +}; + +static int +dissect_cms_GCMParameters(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, + GCMParameters_sequence, hf_index, ett_cms_GCMParameters); + + return offset; +} + + static int dissect_cms_FirmwarePkgData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { @@ -2326,6 +2447,13 @@ static int dissect_EnvelopedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, offset = dissect_cms_EnvelopedData(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_EnvelopedData_PDU); return offset; } +static int dissect_EncryptedContentInfo_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { + int offset = 0; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + offset = dissect_cms_EncryptedContentInfo(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_EncryptedContentInfo_PDU); + return offset; +} static int dissect_DigestedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { int offset = 0; asn1_ctx_t asn1_ctx; @@ -2347,6 +2475,13 @@ static int dissect_AuthenticatedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _ offset = dissect_cms_AuthenticatedData(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_AuthenticatedData_PDU); return offset; } +static int dissect_KeyEncryptionAlgorithmIdentifier_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { + int offset = 0; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + offset = dissect_cms_KeyEncryptionAlgorithmIdentifier(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_KeyEncryptionAlgorithmIdentifier_PDU); + return offset; +} static int dissect_IssuerAndSerialNumber_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { int offset = 0; asn1_ctx_t asn1_ctx; @@ -2417,6 +2552,20 @@ static int dissect_RC2CBCParameters_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U offset = dissect_cms_RC2CBCParameters(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_RC2CBCParameters_PDU); return offset; } +static int dissect_AuthEnvelopedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { + int offset = 0; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + offset = dissect_cms_AuthEnvelopedData(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_AuthEnvelopedData_PDU); + return offset; +} +static int dissect_GCMParameters_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { + int offset = 0; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + offset = dissect_cms_GCMParameters(FALSE, tvb, offset, &asn1_ctx, tree, hf_cms_GCMParameters_PDU); + return offset; +} static int dissect_FirmwarePkgData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { int offset = 0; asn1_ctx_t asn1_ctx; @@ -2535,6 +2684,10 @@ void proto_register_cms(void) { { "EnvelopedData", "cms.EnvelopedData_element", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }}, + { &hf_cms_EncryptedContentInfo_PDU, + { "EncryptedContentInfo", "cms.EncryptedContentInfo_element", + FT_NONE, BASE_NONE, NULL, 0, + NULL, HFILL }}, { &hf_cms_DigestedData_PDU, { "DigestedData", "cms.DigestedData_element", FT_NONE, BASE_NONE, NULL, 0, @@ -2547,6 +2700,10 @@ void proto_register_cms(void) { { "AuthenticatedData", "cms.AuthenticatedData_element", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }}, + { &hf_cms_KeyEncryptionAlgorithmIdentifier_PDU, + { "KeyEncryptionAlgorithmIdentifier", "cms.KeyEncryptionAlgorithmIdentifier_element", + FT_NONE, BASE_NONE, NULL, 0, + NULL, HFILL }}, { &hf_cms_IssuerAndSerialNumber_PDU, { "IssuerAndSerialNumber", "cms.IssuerAndSerialNumber_element", FT_NONE, BASE_NONE, NULL, 0, @@ -2587,6 +2744,14 @@ void proto_register_cms(void) { { "RC2CBCParameters", "cms.RC2CBCParameters", FT_UINT32, BASE_DEC, VALS(cms_RC2CBCParameters_vals), 0, NULL, HFILL }}, + { &hf_cms_AuthEnvelopedData_PDU, + { "AuthEnvelopedData", "cms.AuthEnvelopedData_element", + FT_NONE, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_cms_GCMParameters_PDU, + { "GCMParameters", "cms.GCMParameters_element", + FT_NONE, BASE_NONE, NULL, 0, + NULL, HFILL }}, { &hf_cms_FirmwarePkgData_PDU, { "FirmwarePkgData", "cms.FirmwarePkgData", FT_BYTES, BASE_NONE, NULL, 0, @@ -3015,6 +3180,26 @@ void proto_register_cms(void) { { "rc2CBCParameter", "cms.rc2CBCParameter_element", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }}, + { &hf_cms_authEncryptedContentInfo, + { "authEncryptedContentInfo", "cms.authEncryptedContentInfo_element", + FT_NONE, BASE_NONE, NULL, 0, + "EncryptedContentInfo", HFILL }}, + { &hf_cms_aes_nonce, + { "aes-nonce", "cms.aes_nonce", + FT_BYTES, BASE_NONE, NULL, 0, + "OCTET_STRING_SIZE_7_13", HFILL }}, + { &hf_cms_aes_ICVlen, + { "aes-ICVlen", "cms.aes_ICVlen", + FT_UINT32, BASE_DEC, NULL, 0, + "AES_CCM_ICVlen", HFILL }}, + { &hf_cms_aes_nonce_01, + { "aes-nonce", "cms.aes_nonce", + FT_BYTES, BASE_NONE, NULL, 0, + "OCTET_STRING", HFILL }}, + { &hf_cms_aes_ICVlen_01, + { "aes-ICVlen", "cms.aes_ICVlen", + FT_UINT32, BASE_DEC, NULL, 0, + "AES_GCM_ICVlen", HFILL }}, { &hf_cms_acInfo, { "acInfo", "cms.acInfo_element", FT_NONE, BASE_NONE, NULL, 0, @@ -3219,6 +3404,7 @@ void proto_register_cms(void) { /* List of subtrees */ static gint *ett[] = { + &ett_cms, &ett_cms_ContentInfo, &ett_cms_SignedData, &ett_cms_DigestAlgorithmIdentifiers, @@ -3270,6 +3456,9 @@ void proto_register_cms(void) { &ett_cms_SMIMECapability, &ett_cms_SMIMEEncryptionKeyPreference, &ett_cms_RC2CBCParameters, + &ett_cms_AuthEnvelopedData, + &ett_cms_CCMParameters, + &ett_cms_GCMParameters, &ett_cms_AttributeCertificateV1, &ett_cms_AttributeCertificateInfoV1, &ett_cms_T_subject, @@ -3300,6 +3489,8 @@ void proto_register_cms(void) { /* Register protocol */ proto_cms = proto_register_protocol(PNAME, PSNAME, PFNAME); + cms_handle = register_dissector(PFNAME, dissect_cms, proto_cms); + /* Register fields and subtrees */ proto_register_field_array(proto_cms, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -3323,6 +3514,8 @@ void proto_reg_handoff_cms(void) { register_ber_oid_dissector("1.2.840.113549.1.7.5", dissect_DigestedData_PDU, proto_cms, "id-digestedData"); register_ber_oid_dissector("1.2.840.113549.1.7.6", dissect_EncryptedData_PDU, proto_cms, "id-encryptedData"); register_ber_oid_dissector("1.2.840.113549.1.9.16.1.2", dissect_AuthenticatedData_PDU, proto_cms, "id-ct-authenticatedData"); + register_ber_oid_dissector("1.2.840.113549.1.9.16.1.9", dissect_EncryptedContentInfo_PDU, proto_cms, "id-ct-compressedData"); + register_ber_oid_dissector("1.2.840.113549.1.9.16.1.23", dissect_AuthEnvelopedData_PDU, proto_cms, "id-ct-authEnvelopedData"); register_ber_oid_dissector("1.2.840.113549.1.9.3", dissect_ContentType_PDU, proto_cms, "id-contentType"); register_ber_oid_dissector("1.2.840.113549.1.9.4", dissect_MessageDigest_PDU, proto_cms, "id-messageDigest"); register_ber_oid_dissector("1.2.840.113549.1.9.5", dissect_SigningTime_PDU, proto_cms, "id-signingTime"); @@ -3332,6 +3525,15 @@ void proto_reg_handoff_cms(void) { register_ber_oid_dissector("1.2.840.113549.1.9.15", dissect_SMIMECapabilities_PDU, proto_cms, "id-smime-capabilities"); register_ber_oid_dissector("1.2.840.113549.1.9.16.2.11", dissect_SMIMEEncryptionKeyPreference_PDU, proto_cms, "id-encryption-key-preference"); register_ber_oid_dissector("1.2.840.113549.3.4", dissect_RC2CBCParameters_PDU, proto_cms, "id-alg-rc4"); + register_ber_oid_dissector("0.4.0.127.0.7.1.1.5.1.1.3", dissect_KeyEncryptionAlgorithmIdentifier_PDU, proto_cms, "ecka-eg-X963KDF-SHA256"); + register_ber_oid_dissector("0.4.0.127.0.7.1.1.5.1.1.4", dissect_KeyEncryptionAlgorithmIdentifier_PDU, proto_cms, "ecka-eg-X963KDF-SHA384"); + register_ber_oid_dissector("0.4.0.127.0.7.1.1.5.1.1.5", dissect_KeyEncryptionAlgorithmIdentifier_PDU, proto_cms, "ecka-eg-X963KDF-SHA512"); + register_ber_oid_dissector("2.16.840.1.101.3.4.1.5", dissect_KeyEncryptionAlgorithmIdentifier_PDU, proto_cms, "id-aes128-wrap"); + register_ber_oid_dissector("2.16.840.1.101.3.4.1.25", dissect_KeyEncryptionAlgorithmIdentifier_PDU, proto_cms, "id-aes192-wrap"); + register_ber_oid_dissector("2.16.840.1.101.3.4.1.45", dissect_KeyEncryptionAlgorithmIdentifier_PDU, proto_cms, "id-aes256-wrap"); + register_ber_oid_dissector("2.16.840.1.101.3.4.1.6", dissect_GCMParameters_PDU, proto_cms, "id-aes128-GCM"); + register_ber_oid_dissector("2.16.840.1.101.3.4.1.26", dissect_GCMParameters_PDU, proto_cms, "id-aes192-GCM"); + register_ber_oid_dissector("2.16.840.1.101.3.4.1.46", dissect_GCMParameters_PDU, proto_cms, "id-aes256-GCM"); register_ber_oid_dissector("1.3.133.16.840.63.0.2", dissect_KeyWrapAlgorithm_PDU, proto_cms, "dhSinglePass-stdDH-sha1kdf-scheme"); register_ber_oid_dissector("1.3.132.1.11.0", dissect_KeyWrapAlgorithm_PDU, proto_cms, "dhSinglePass-stdDH-sha224kdf-scheme"); register_ber_oid_dissector("1.3.132.1.11.1", dissect_KeyWrapAlgorithm_PDU, proto_cms, "dhSinglePass-stdDH-sha256kdf-scheme"); @@ -3370,10 +3572,25 @@ void proto_reg_handoff_cms(void) { register_ber_oid_dissector("1.2.840.113549.1.9.16.3.6", dissect_ber_oid_NULL_callback, proto_cms, "id-alg-CMS3DESwrap"); oid_add_from_string("id-data","1.2.840.113549.1.7.1"); + oid_add_from_string("id-alg-des-ede3-cbc","1.2.840.113549.3.7"); oid_add_from_string("id-alg-des-cbc","1.3.14.3.2.7"); + oid_add_from_string("id-ct-authEnvelopedData","1.2.840.113549.1.9.16.1.23"); + oid_add_from_string("id-aes-CBC-CMAC-128","0.4.0.127.0.7.1.3.1.1.2"); + oid_add_from_string("id-aes-CBC-CMAC-192","0.4.0.127.0.7.1.3.1.1.3"); + oid_add_from_string("id-aes-CBC-CMAC-256","0.4.0.127.0.7.1.3.1.1.4"); + oid_add_from_string("ecdsaWithSHA256","1.2.840.10045.4.3.2"); + oid_add_from_string("ecdsaWithSHA384","1.2.840.10045.4.3.3"); + oid_add_from_string("ecdsaWithSHA512","1.2.840.10045.4.3.4"); + content_info_handle = create_dissector_handle (dissect_ContentInfo_PDU, proto_cms); + dissector_add_string("media_type", "application/pkcs7-mime", content_info_handle); dissector_add_string("media_type", "application/pkcs7-signature", content_info_handle); - dissector_add_string("rfc7468.preeb_label", "CMS", content_info_handle); + + dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml", content_info_handle); + dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml; encap=cms-tr03109", content_info_handle); + dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml; encap=cms-tr03109-zlib", content_info_handle); + dissector_add_string("media_type", "application/hgp;encap=cms", content_info_handle); } + diff --git a/epan/dissectors/packet-cms.h b/epan/dissectors/packet-cms.h index 48b7e05439..39834eb140 100644 --- a/epan/dissectors/packet-cms.h +++ b/epan/dissectors/packet-cms.h @@ -7,6 +7,7 @@ * Routines for RFC5652 Cryptographic Message Syntax packet dissection * Ronnie Sahlberg 2004 * Stig Bjorlykke 2010 + * Uwe Heuert 2022 * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> @@ -36,6 +37,7 @@ int dissect_cms_DigestAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *t int dissect_cms_IssuerAndSerialNumber(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_); int dissect_cms_Countersignature(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_); int dissect_cms_DigestInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_); +int dissect_cms_AuthEnvelopedData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_); #endif /* PACKET_CMS_H */ diff --git a/epan/dissectors/packet-sml.c b/epan/dissectors/packet-sml.c index 1dded4e872..e2251439a1 100644 --- a/epan/dissectors/packet-sml.c +++ b/epan/dissectors/packet-sml.c @@ -2,6 +2,9 @@ * Routines for SML dissection * Copyright 2013, Alexander Gaertner <gaertner.alex@gmx.de> * + * Enhancements for SML 1.05 dissection + * Copyright 2022, Uwe Heuert <uwe.heuert@exceeding-solutions.de> + * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs @@ -48,6 +51,17 @@ Short description of the SML protocol on the SML Wireshark Wiki page: #define PROC_PERIOD 0x02 #define PROC_TUPLE 0x03 #define PROC_TIME 0x04 +#define PROC_LISTENTRY 0x05 + +#define TIME_SECINDEX 0x01 +#define TIME_TIMESTAMP 0x02 +#define TIME_LOCALTIMESTAMP 0x03 + +#define LISTTYPE_TIME 0x01 +#define LISTTYPE_TIMESTAMPEDVALUE 0x02 +#define LISTTYPE_COSEMVALUE 0x03 + +#define COSEMVALUE_SCALER_UNIT 0x01 #define SHORT_LIST 0x70 #define LONG_LIST 0xF0 @@ -97,6 +111,7 @@ static int hf_sml_valTime = -1; static int hf_sml_unit = -1; static int hf_sml_scaler = -1; static int hf_sml_value = -1; +static int hf_sml_simplevalue = -1; static int hf_sml_valueSignature = -1; static int hf_sml_listSignature = -1; static int hf_sml_actGatewayTime = -1; @@ -107,6 +122,9 @@ static int hf_sml_procParValue = -1; static int hf_sml_procParValueTime = -1; static int hf_sml_padding = -1; static int hf_sml_secIndex = -1; +static int hf_sml_timestamp = -1; +static int hf_sml_localOffset = -1; +static int hf_sml_seasonTimeOffset = -1; static int hf_sml_attentionNo = -1; static int hf_sml_attentionMsg = -1; static int hf_sml_withRawdata = -1; @@ -140,6 +158,8 @@ static int hf_sml_scaler_R4 = -1; static int hf_sml_value_R4 = -1; static int hf_sml_file_marker = -1; static int hf_sml_new_file_marker = -1; +static int hf_sml_listtype = -1; +static int hf_sml_cosemvalue = -1; static const value_string datatype []={ {0x52, "Integer 8"}, @@ -159,6 +179,7 @@ static const value_string datatype []={ {0x68, "Unsigned cropped"}, {0x69, "Unsigned 64"}, {0x42, "Boolean"}, + {0x72, "ListType" }, {0, NULL} }; @@ -191,6 +212,7 @@ static const value_string sml_body[]={ static const value_string sml_timetypes[]={ {0x01, "secIndex"}, {0x02, "timestamp"}, + {0x03, "localTimestamp" }, {0, NULL} }; @@ -199,9 +221,22 @@ static const value_string procvalues[]={ {PROC_PERIOD, "PeriodEntry"}, {PROC_TUPLE, "TupleEntry"}, {PROC_TIME, "Time"}, + {PROC_LISTENTRY, "ListEntry"}, {0, NULL} }; +static const value_string listtypevalues[] = { + { LISTTYPE_TIME, "smlTime" }, + { LISTTYPE_TIMESTAMPEDVALUE, "smlTimestampedValue" }, + { LISTTYPE_COSEMVALUE, "smlCosemValue" }, + { 0, NULL } +}; + +static const value_string cosemvaluevalues[] = { + { COSEMVALUE_SCALER_UNIT, "scaler_unit" }, + { 0, NULL } +}; + static const range_string attentionValues[]={ {0xE000, 0xFCFF, "application specific"}, {0xFD00, 0xFD00, "acknowledged"}, @@ -270,6 +305,7 @@ static gint ett_sml_valTime = -1; static gint ett_sml_unit = -1; static gint ett_sml_scaler = -1; static gint ett_sml_value = -1; +static gint ett_sml_simplevalue = -1; static gint ett_sml_valueSignature = -1; static gint ett_sml_listSignature = -1; static gint ett_sml_valtree = -1; @@ -287,6 +323,10 @@ static gint ett_sml_procParValuetype = -1; static gint ett_sml_msgend = -1; static gint ett_sml_tuple = -1; static gint ett_sml_secIndex = -1; +static gint ett_sml_timestamp = -1; +static gint ett_sml_localTimestamp = -1; +static gint ett_sml_localOffset = -1; +static gint ett_sml_seasonTimeOffset = -1; static gint ett_sml_signature = -1; static gint ett_sml_attentionNo = -1; static gint ett_sml_attentionMsg = -1; @@ -329,6 +369,13 @@ static gint ett_sml_value_R4 = -1; static gint ett_sml_tree_Entry = -1; static gint ett_sml_dasDetails = -1; static gint ett_sml_attentionDetails = -1; +static gint ett_sml_listtypetype = -1; +static gint ett_sml_listtype = -1; +static gint ett_sml_timestampedvaluetype = -1; +static gint ett_sml_timestampedvalue = -1; +static gint ett_sml_cosemvaluetype = -1; +static gint ett_sml_cosemvalue = -1; +static gint ett_sml_scaler_unit = -1; static expert_field ei_sml_messagetype_unknown = EI_INIT; static expert_field ei_sml_procParValue_errror = EI_INIT; @@ -343,7 +390,8 @@ static expert_field ei_sml_MessageBody = EI_INIT; static expert_field ei_sml_esc_error = EI_INIT; static expert_field ei_sml_version2_not_supported = EI_INIT; static expert_field ei_sml_attentionNo = EI_INIT; - +static expert_field ei_sml_listtype_invalid = EI_INIT; +static expert_field ei_sml_cosemvalue_invalid = EI_INIT; /*options*/ static gboolean sml_reassemble = TRUE; @@ -387,39 +435,250 @@ static void get_length(tvbuff_t *tvb, guint *offset, guint *data, guint *length) } /*often used fields*/ -static void sml_value(tvbuff_t *tvb,proto_tree *insert_tree,guint *offset, guint *data, guint *length){ +static void field_scaler(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length); +static void field_unit(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length); +static void field_status(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length); +static void sml_time_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *SML_time_tree, guint *offset); + +static void sml_simplevalue(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *value = NULL; proto_tree *value_tree = NULL; get_length(tvb, offset, data, length); - value = proto_tree_add_bytes_format (insert_tree, hf_sml_value, tvb, *offset, *length + *data, NULL,"value %s", (*data == 0)? ": NOT SET" : ""); + value = proto_tree_add_bytes_format(insert_tree, hf_sml_simplevalue, tvb, *offset, *length + *data, NULL, "value %s", (*data == 0) ? ": NOT SET" : ""); if (tvb_get_guint8(tvb, *offset) != OPTIONAL){ - value_tree = proto_item_add_subtree (value, ett_sml_value); + value_tree = proto_item_add_subtree(value, ett_sml_simplevalue); if ((tvb_get_guint8(tvb, *offset) & 0x80) == MSB || (tvb_get_guint8(tvb, *offset) & 0xF0) == 0){ proto_tree_add_uint(value_tree, hf_sml_length, tvb, *offset, *length, *data); - *offset+= *length; + *offset += *length; } else { - proto_tree_add_item (value_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; + proto_tree_add_item(value_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + } + proto_tree_add_item(value_tree, hf_sml_simplevalue, tvb, *offset, *data, ENC_NA); + *offset += *data; + } + else + *offset += 1; +} + +static void sml_timestampedvalue_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *timestampedvalue_tree, guint *offset){ + proto_tree *SML_timestampedvalue_type_tree; + proto_tree *SML_time_tree; + proto_item *SML_time; + guint data = 0; + guint length = 0; + + SML_timestampedvalue_type_tree = proto_tree_add_subtree(timestampedvalue_tree, tvb, *offset, -1, ett_sml_timestampedvaluetype, NULL, "SML_TimestampedValue Type"); + + /*smlTime*/ + SML_time_tree = proto_tree_add_subtree(SML_timestampedvalue_type_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "smlTime"); + *offset += 1; + sml_time_type(tvb, pinfo, SML_time_tree, offset); + proto_item_set_end(SML_time, tvb, *offset); + + /*status*/ + field_status(tvb, SML_timestampedvalue_type_tree, offset, &data, &length); + + /*simpleValue*/ + sml_simplevalue(tvb, SML_timestampedvalue_type_tree, offset, &data, &length); +} + +static void sml_cosem_scaler_unit_type(tvbuff_t *tvb, proto_tree *cosem_scaler_unit_tree, guint *offset){ + guint data, length; + + /*scaler*/ + get_length(tvb, offset, &data, &length); + field_scaler(tvb, cosem_scaler_unit_tree, offset, &data, &length); + + /*unit*/ + get_length(tvb, offset, &data, &length); + field_unit(tvb, cosem_scaler_unit_tree, offset, &data, &length); +} + +static void sml_cosemvalue_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cosemvalue_tree, guint *offset){ + guint check = 0; + proto_item *SML_cosem_scaler_unit; + proto_tree *SML_cosemvalue_type_tree; + proto_tree *SML_cosem_scaler_unit_tree; + + SML_cosemvalue_type_tree = proto_tree_add_subtree(cosemvalue_tree, tvb, *offset, -1, ett_sml_cosemvaluetype, NULL, "SML_CosemValue Type"); + + proto_tree_add_item(SML_cosemvalue_type_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(SML_cosemvalue_type_tree, hf_sml_cosemvalue, tvb, *offset, 1, ENC_BIG_ENDIAN); + + check = tvb_get_guint8(tvb, *offset); + *offset += 1; + + switch (check) { + case COSEMVALUE_SCALER_UNIT: + /*scaler_unit*/ + SML_cosem_scaler_unit_tree = proto_tree_add_subtree(SML_cosemvalue_type_tree, tvb, *offset, -1, ett_sml_scaler_unit, &SML_cosem_scaler_unit, "CosemScalerUnit"); + *offset += 1; + sml_cosem_scaler_unit_type(tvb, SML_cosem_scaler_unit_tree, offset); + break; + + default: + expert_add_info(pinfo, SML_cosemvalue_type_tree, &ei_sml_cosemvalue_invalid); + break; + } +} + +static void sml_listtype_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *listtype_tree, guint *offset){ + guint check = 0; + proto_tree *SML_listtype_type_tree; + proto_item *SML_time; + proto_tree *SML_time_tree = NULL; + proto_item *SML_timestampedvalue; + proto_tree *SML_timestampedvalue_tree = NULL; + proto_item *SML_cosemvalue; + proto_tree *SML_cosemvalue_tree = NULL; + + SML_listtype_type_tree = proto_tree_add_subtree(listtype_tree, tvb, *offset, -1, ett_sml_listtypetype, NULL, "SML_ListType Type"); + + proto_tree_add_item(SML_listtype_type_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(SML_listtype_type_tree, hf_sml_listtype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + + check = tvb_get_guint8(tvb, *offset); + *offset += 1; + + switch (check) { + case LISTTYPE_TIME: + /*smlTime*/ + SML_time_tree = proto_tree_add_subtree(SML_listtype_type_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "Time"); + *offset += 1; + sml_time_type(tvb, pinfo, SML_time_tree, offset); + proto_item_set_end(SML_time, tvb, *offset); + break; + + case LISTTYPE_TIMESTAMPEDVALUE: + /*smlTimestampedValue*/ + SML_timestampedvalue_tree = proto_tree_add_subtree(SML_listtype_type_tree, tvb, *offset, -1, ett_sml_timestampedvalue, &SML_timestampedvalue, "TimestampedValue"); + *offset += 1; + sml_timestampedvalue_type(tvb, pinfo, SML_timestampedvalue_tree, offset); + proto_item_set_end(SML_timestampedvalue, tvb, *offset); + break; + + case LISTTYPE_COSEMVALUE: + /*smlCosemValue*/ + SML_cosemvalue_tree = proto_tree_add_subtree(SML_listtype_type_tree, tvb, *offset, -1, ett_sml_cosemvalue, &SML_cosemvalue, "CosemValue"); + *offset += 1; + sml_cosemvalue_type(tvb, pinfo, SML_cosemvalue_tree, offset); + break; + + default: + expert_add_info(pinfo, SML_listtype_type_tree, &ei_sml_listtype_invalid); + break; + } +} + +static void sml_value(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ + proto_item *value = NULL; + proto_tree *value_tree = NULL; + + get_length(tvb, offset, data, length); + value = proto_tree_add_bytes_format (insert_tree, hf_sml_value, tvb, *offset, *length + *data, NULL,"value %s", (*data == 0)? ": NOT SET" : ""); + + if (tvb_get_guint8(tvb, *offset) != OPTIONAL){ + value_tree = proto_item_add_subtree (value, ett_sml_value); + if (tvb_get_guint8(tvb, *offset) == 0x72) { + sml_listtype_type(tvb, pinfo, value_tree, offset); + } + else + { + if ((tvb_get_guint8(tvb, *offset) & 0x80) == MSB || (tvb_get_guint8(tvb, *offset) & 0xF0) == 0){ + proto_tree_add_uint(value_tree, hf_sml_length, tvb, *offset, *length, *data); + *offset+= *length; + } + else { + proto_tree_add_item (value_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset+=1; + } + proto_tree_add_item (value_tree, hf_sml_value, tvb, *offset, *data, ENC_NA); + *offset+= *data; } - proto_tree_add_item (value_tree, hf_sml_value, tvb, *offset, *data, ENC_NA); - *offset+= *data; } else *offset+=1; } -static void sml_time_type(tvbuff_t *tvb, proto_tree *SML_time_tree, guint *offset){ +static void sml_time_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *SML_time_tree, guint *offset){ + guint check = 0; proto_tree *timetype_tree; + proto_tree *timevalue_tree; + proto_tree *localtimestamptype_tree; + guint data = 0; + guint length = 0; timetype_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, 2, ett_sml_timetype, NULL, "SML-Time Type"); proto_tree_add_item (timetype_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); *offset+=1; proto_tree_add_item (timetype_tree, hf_sml_timetype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; + //*offset+=1; + + check = tvb_get_guint8(tvb, *offset); + *offset += 1; + + switch (check) { + case TIME_SECINDEX: + /*secIndex*/ + get_length(tvb, offset, &data, &length); + timevalue_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_secIndex, NULL, "secIndex"); + proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(timevalue_tree, hf_sml_secIndex, tvb, *offset, data, ENC_BIG_ENDIAN); + *offset += data; + + break; + case TIME_TIMESTAMP: + /*timestamp*/ + get_length(tvb, offset, &data, &length); + timevalue_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_timestamp, NULL, "timestamp"); + proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(timevalue_tree, hf_sml_timestamp, tvb, *offset, data, ENC_BIG_ENDIAN); + *offset += data; + + break; + + case TIME_LOCALTIMESTAMP: + /*localTimestamp*/ + localtimestamptype_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_localTimestamp, NULL, "localTimestamp"); + *offset += 1; + + get_length(tvb, offset, &data, &length); + timevalue_tree = proto_tree_add_subtree(localtimestamptype_tree, tvb, *offset, length + data, ett_sml_timestamp, NULL, "timestamp"); + proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(timevalue_tree, hf_sml_timestamp, tvb, *offset, data, ENC_BIG_ENDIAN); + *offset += data; + + get_length(tvb, offset, &data, &length); + timevalue_tree = proto_tree_add_subtree(localtimestamptype_tree, tvb, *offset, length + data, ett_sml_localOffset, NULL, "localOffset"); + proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(timevalue_tree, hf_sml_localOffset, tvb, *offset, data, ENC_BIG_ENDIAN); + *offset += data; + + get_length(tvb, offset, &data, &length); + timevalue_tree = proto_tree_add_subtree(localtimestamptype_tree, tvb, *offset, length + data, ett_sml_seasonTimeOffset, NULL, "seasonTimeOffset"); + proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + *offset += 1; + proto_tree_add_item(timevalue_tree, hf_sml_seasonTimeOffset, tvb, *offset, data, ENC_BIG_ENDIAN); + *offset += data; + + break; + + default: + expert_add_info(pinfo, timetype_tree, &ei_sml_listtype_invalid); + break; + } } static void field_codepage(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ @@ -749,7 +1008,7 @@ static void field_periodSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint else *offset+=1; } - +/* static void field_actTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_tree *actTime_tree; @@ -771,14 +1030,14 @@ static void field_valTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, proto_tree_add_item(valTime_tree, hf_sml_valTime, tvb, *offset, *data, ENC_BIG_ENDIAN); *offset+=*data; } - -static void TupleEntryTree(tvbuff_t *tvb, proto_tree *procParValue_tree, guint *offset){ +*/ +static void TupleEntryTree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *procParValue_tree, guint *offset){ proto_item *SML_time; proto_item *TupleEntry; proto_tree *TupleEntry_list = NULL; proto_tree *SML_time_tree = NULL; - proto_tree *secIndex_tree = NULL; + //proto_tree *secIndex_tree = NULL; proto_tree *unit_pA_tree = NULL; proto_tree *scaler_pA_tree = NULL; proto_tree *value_pA_tree = NULL; @@ -812,15 +1071,16 @@ static void TupleEntryTree(tvbuff_t *tvb, proto_tree *procParValue_tree, guint * field_serverId(tvb, TupleEntry_list, offset, &data, &length); /*secindex*/ + // TODO: check this SML_time_tree = proto_tree_add_subtree(procParValue_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "secIndex"); *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); - get_length(tvb, offset, &data, &length); - secIndex_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_secIndex, NULL, "secIndex"); - proto_tree_add_item (secIndex_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(secIndex_tree, hf_sml_secIndex, tvb, *offset, data, ENC_BIG_ENDIAN); - *offset+=data; + sml_time_type(tvb, pinfo, SML_time_tree, offset); +// get_length(tvb, offset, &data, &length); +// secIndex_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_secIndex, NULL, "secIndex"); +// proto_tree_add_item (secIndex_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); +// *offset+=1; +// proto_tree_add_item(secIndex_tree, hf_sml_secIndex, tvb, *offset, data, ENC_BIG_ENDIAN); +// *offset+=data; proto_item_set_end(SML_time, tvb, *offset); /*Sml Status OPTIONAL*/ @@ -983,6 +1243,7 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre proto_item *child; proto_item *periodEntry; proto_item *SML_time; + proto_item *listEntry; proto_item *tree_Entry; proto_tree *parameterName_tree = NULL; @@ -990,7 +1251,8 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre proto_tree *procParValuetype_tree = NULL; proto_tree *periodEntry_tree = NULL; proto_tree *SML_time_tree = NULL; - proto_tree *procParValueTime_tree = NULL; + proto_tree *listEntry_tree = NULL; + //proto_tree *procParValueTime_tree = NULL; proto_tree *child_list = NULL; proto_tree *tree_Entry_list = NULL; @@ -1030,7 +1292,7 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre switch (check) { case PROC_VALUE: /*value*/ - sml_value(tvb, procParValue_tree, offset, data, length); + sml_value(tvb, pinfo, procParValue_tree, offset, data, length); break; case PROC_PERIOD: @@ -1050,7 +1312,7 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre field_scaler(tvb, periodEntry_tree, offset, data, length); /*value*/ - sml_value(tvb, periodEntry_tree, offset, data, length); + sml_value(tvb, pinfo, periodEntry_tree, offset, data, length); /*value Signature*/ field_valueSignature(tvb, periodEntry_tree, offset, data, length); @@ -1061,7 +1323,7 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre case PROC_TUPLE: /*TupleEntry*/ if (tvb_get_guint8(tvb, *offset) == 0xF1 && tvb_get_guint8(tvb, *offset+1) == 0x07){ - TupleEntryTree(tvb, procParValue_tree, offset); + TupleEntryTree(tvb, pinfo, procParValue_tree, offset); } else { expert_add_info(pinfo, NULL, &ei_sml_tuple_error); @@ -1073,17 +1335,51 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre SML_time_tree = proto_tree_add_subtree(procParValue_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "Time"); *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); + sml_time_type(tvb, pinfo, SML_time_tree, offset); /*Time*/ + //get_length(tvb, offset, data, length); + //procParValueTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, *length + *data, ett_sml_procParValueTime, NULL, "procParValueTime"); + //proto_tree_add_item (procParValueTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + //*offset+=1; + //proto_tree_add_item(procParValueTime_tree, hf_sml_procParValueTime, tvb, *offset, *data, ENC_BIG_ENDIAN); + //*offset+=*data; + + proto_item_set_end(SML_time, tvb, *offset); + break; + + case PROC_LISTENTRY: + /*listEntry*/ get_length(tvb, offset, data, length); - procParValueTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, *length + *data, ett_sml_procParValueTime, NULL, "procParValueTime"); - proto_tree_add_item (procParValueTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(procParValueTime_tree, hf_sml_procParValueTime, tvb, *offset, *data, ENC_BIG_ENDIAN); - *offset+=*data; + listEntry_tree = proto_tree_add_subtree_format(procParValue_tree, tvb, *offset, -1, ett_sml_listEntry, &listEntry, + "ListEntry List with %d %s", *length + *data, plurality(*length + *data, "element", "elements")); + *offset += *length; + + /*objName*/ + field_objName(tvb, listEntry_tree, offset, data, length); + + /*status OPTIONAL*/ + field_status(tvb, listEntry_tree, offset, data, length); + /*valTime OPTIONAL*/ + SML_time_tree = proto_tree_add_subtree(listEntry_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "Time"); + *offset += 1; + sml_time_type(tvb, pinfo, SML_time_tree, offset); proto_item_set_end(SML_time, tvb, *offset); + + /*unit OPTIONAL*/ + field_unit(tvb, listEntry_tree, offset, data, length); + + /*scaler OPTIONAL*/ + field_scaler(tvb, listEntry_tree, offset, data, length); + + /*value*/ + sml_value(tvb, pinfo, listEntry_tree, offset, data, length); + + /*valueSignature OPTIONAL*/ + field_valueSignature(tvb, listEntry_tree, offset, data, length); + + proto_item_set_end(listEntry, tvb, *offset); break; default: @@ -1177,10 +1473,10 @@ static void decode_PublicOpenReq (tvbuff_t *tvb, proto_tree *messagebodytree_lis field_smlVersion(tvb,messagebodytree_list, offset, &data, &length); } -static void decode_PublicOpenRes (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){ +static void decode_PublicOpenRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ proto_item *SML_time = NULL; - proto_tree *refTime_tree = NULL; + //proto_tree *refTime_tree = NULL; proto_tree *SML_time_tree = NULL; guint data = 0; @@ -1211,15 +1507,15 @@ static void decode_PublicOpenRes (tvbuff_t *tvb, proto_tree *messagebodytree_lis /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); + sml_time_type(tvb, pinfo, SML_time_tree, offset); /*refTime*/ - get_length(tvb, offset, &data, &length); - refTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length+data, ett_sml_refTime, NULL, "refTime"); - proto_tree_add_item (refTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(refTime_tree, hf_sml_refTime, tvb, *offset, data, ENC_BIG_ENDIAN); - *offset+=data; + //get_length(tvb, offset, &data, &length); + //refTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length+data, ett_sml_refTime, NULL, "refTime"); + //proto_tree_add_item (refTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + //*offset+=1; + //proto_tree_add_item(refTime_tree, hf_sml_refTime, tvb, *offset, data, ENC_BIG_ENDIAN); + //*offset+=data; proto_item_set_end(SML_time,tvb,*offset); } /*sml-Version OPTIONAL*/ @@ -1235,10 +1531,10 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin proto_tree *withRawdata_tree = NULL; proto_tree *SML_time_tree = NULL; - proto_tree *beginTime_tree = NULL; + //proto_tree *beginTime_tree = NULL; proto_tree *treepath_list = NULL; proto_tree *object_list_list = NULL; - proto_tree *endTime_tree = NULL; + //proto_tree *endTime_tree = NULL; proto_tree *dasDetails_list = NULL; guint i = 0; @@ -1283,15 +1579,15 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); + sml_time_type(tvb, pinfo, SML_time_tree, offset); /*beginTime*/ - get_length(tvb, offset, &data, &length); - beginTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_beginTime, NULL, "beginTime"); - proto_tree_add_item (beginTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(beginTime_tree, hf_sml_beginTime, tvb, *offset, data, ENC_BIG_ENDIAN); - *offset+=data; + //get_length(tvb, offset, &data, &length); + //beginTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_beginTime, NULL, "beginTime"); + //proto_tree_add_item (beginTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + //*offset+=1; + //proto_tree_add_item(beginTime_tree, hf_sml_beginTime, tvb, *offset, data, ENC_BIG_ENDIAN); + //*offset+=data; proto_item_set_end(SML_time,tvb,*offset); } @@ -1308,15 +1604,15 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); + sml_time_type(tvb, pinfo, SML_time_tree, offset); /*endTime*/ - get_length(tvb, offset, &data, &length); - endTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_beginTime, NULL, "endTime"); - proto_tree_add_item (endTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(endTime_tree, hf_sml_endTime, tvb, *offset, data, ENC_BIG_ENDIAN); - *offset+=data; + //get_length(tvb, offset, &data, &length); + //endTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_beginTime, NULL, "endTime"); + //proto_tree_add_item (endTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + //*offset+=1; + //proto_tree_add_item(endTime_tree, hf_sml_endTime, tvb, *offset, data, ENC_BIG_ENDIAN); + //*offset+=data; proto_item_set_end(SML_time,tvb,*offset); } @@ -1430,8 +1726,8 @@ static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, prot SML_time_tree = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "actTime List with %d %s", length+data, plurality(length+data, "element", "elements")); *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); - field_actTime(tvb, SML_time_tree, offset, &data, &length); + sml_time_type(tvb, pinfo, SML_time_tree, offset); + //field_actTime(tvb, SML_time_tree, offset, &data, &length); proto_item_set_end(SML_time,tvb,*offset); /*regPeriod*/ @@ -1522,8 +1818,8 @@ static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, prot get_length(tvb, offset, &data, &length); SML_time_tree = proto_tree_add_subtree(period_List_Entry, tvb, *offset, -1, ett_sml_time, &SML_time, "valTime"); *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); - field_valTime(tvb, SML_time_tree, offset, &data, &length); + sml_time_type(tvb, pinfo, SML_time_tree, offset); + //field_valTime(tvb, SML_time_tree, offset, &data, &length); proto_item_set_end(SML_time,tvb, *offset); /*status*/ @@ -1553,7 +1849,7 @@ static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, prot *offset+=1; /*value*/ - sml_value(tvb, value_List_Entry_list, offset, &data, &length); + sml_value(tvb, pinfo, value_List_Entry_list, offset, &data, &length); /*value Signature*/ field_valueSignature(tvb, value_List_Entry_list, offset, &data, &length); @@ -1612,8 +1908,8 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot get_length(tvb, offset, &data, &length); SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "actTime"); *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); - field_actTime(tvb, SML_time_tree, offset, &data, &length); + sml_time_type(tvb, pinfo, SML_time_tree, offset); + //field_actTime(tvb, SML_time_tree, offset, &data, &length); proto_item_set_end(SML_time,tvb, *offset); /*regPeriod*/ @@ -1654,8 +1950,8 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); - field_valTime(tvb, SML_time_tree, offset, &data, &length); + sml_time_type(tvb, pinfo, SML_time_tree, offset); + //field_valTime(tvb, SML_time_tree, offset, &data, &length); proto_item_set_end(SML_time,tvb,*offset); } @@ -1694,7 +1990,7 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot field_scaler(tvb, periodList_Entry_list, offset, &data, &length); /*value*/ - sml_value(tvb, periodList_Entry_list, offset, &data, &length); + sml_value(tvb, pinfo, periodList_Entry_list, offset, &data, &length); /*value*/ field_valueSignature(tvb, periodList_Entry_list, offset, &data, &length); @@ -1738,11 +2034,11 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item *valtree = NULL; proto_item *SML_time; - proto_tree *actSensorTime_tree = NULL; + //proto_tree *actSensorTime_tree = NULL; proto_tree *valList_list = NULL; proto_tree *listSignature_tree = NULL; proto_tree *valtree_list = NULL; - proto_tree *actGatewayTime_tree = NULL; + //proto_tree *actGatewayTime_tree = NULL; proto_tree *SML_time_tree = NULL; guint repeat = 0; @@ -1772,15 +2068,15 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); + sml_time_type(tvb, pinfo, SML_time_tree, offset); /*actSensorTime*/ - get_length(tvb, offset, &data, &length); - actSensorTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_actSensorTime, NULL, "actSensorTime"); - proto_tree_add_item (actSensorTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(actSensorTime_tree, hf_sml_actSensorTime, tvb, *offset, data, ENC_BIG_ENDIAN); - *offset+=data; + //get_length(tvb, offset, &data, &length); + //actSensorTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_actSensorTime, NULL, "actSensorTime"); + //proto_tree_add_item (actSensorTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + //*offset+=1; + //proto_tree_add_item(actSensorTime_tree, hf_sml_actSensorTime, tvb, *offset, data, ENC_BIG_ENDIAN); + //*offset+=data; proto_item_set_end(SML_time,tvb,*offset); } @@ -1825,8 +2121,8 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); - field_valTime(tvb, SML_time_tree, offset, &data, &length); + sml_time_type(tvb, pinfo, SML_time_tree, offset); + //field_valTime(tvb, SML_time_tree, offset, &data, &length); proto_item_set_end(SML_time, tvb, *offset); } @@ -1837,7 +2133,7 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree field_scaler(tvb, valList_list, offset, &data, &length); /*value*/ - sml_value(tvb, valList_list, offset, &data, &length); + sml_value(tvb, pinfo, valList_list, offset, &data, &length); /*value Signature*/ field_valueSignature(tvb, valList_list, offset, &data, &length); @@ -1873,14 +2169,14 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree /*SML TIME*/ *offset+=1; - sml_time_type(tvb, SML_time_tree, offset); + sml_time_type(tvb, pinfo, SML_time_tree, offset); - get_length(tvb, offset, &data, &length); - actGatewayTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_actSensorTime, NULL, "actGatewayTime"); - proto_tree_add_item (actGatewayTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); - *offset+=1; - proto_tree_add_item(actGatewayTime_tree, hf_sml_actGatewayTime, tvb, *offset, data, ENC_BIG_ENDIAN); - *offset+=data; + //get_length(tvb, offset, &data, &length); + //actGatewayTime_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_actSensorTime, NULL, "actGatewayTime"); + //proto_tree_add_item (actGatewayTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN); + //*offset+=1; + //proto_tree_add_item(actGatewayTime_tree, hf_sml_actGatewayTime, tvb, *offset, data, ENC_BIG_ENDIAN); + //*offset+=data; proto_item_set_end(SML_time,tvb,*offset); } return FALSE; @@ -2288,7 +2584,7 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr case OPEN_RES: col_append_str (pinfo->cinfo, COL_INFO, "OpenRes; "); proto_item_append_text(mainlist, " [Open Response]"); - decode_PublicOpenRes(tvb, messagebodytree_list, offset); + decode_PublicOpenRes(tvb, pinfo, messagebodytree_list, offset); break; case CLOSE_REQ: col_append_str (pinfo->cinfo, COL_INFO, "CloseReq; "); @@ -2507,7 +2803,7 @@ static int dissect_sml (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi static void sml_fmt_length( gchar *result, guint32 length ) { - snprintf( result, ITEM_LABEL_LENGTH, "%d %s", length, plurality(length, "octet", "octets")); + g_snprintf( result, ITEM_LABEL_LENGTH, "%d %s", length, plurality(length, "octet", "octets")); } void proto_register_sml (void) { @@ -2523,8 +2819,9 @@ void proto_register_sml (void) { { "SML Version", "sml.version", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_sml_crc16, { "CRC16", "sml.crc", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_sml_crc16_status, - { "CRC16 Status", "sml.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }}, +//TODO:check this +// { &hf_sml_crc16_status, +// { "CRC16 Status", "sml.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }}, { &hf_sml_endOfSmlMsg, { "End of SML Msg", "sml.end", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_sml_transactionId, @@ -2575,6 +2872,8 @@ void proto_register_sml (void) { { "scaler", "sml.scaler", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_sml_value, { "value", "sml.value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_sml_simplevalue, + { "simplevalue", "sml.simplevalue", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { &hf_sml_valueSignature, { "ValueSignature", "sml.valuesignature", FT_BYTES, BASE_NONE, NULL, 0x0,NULL, HFILL }}, { &hf_sml_listSignature, @@ -2595,6 +2894,12 @@ void proto_register_sml (void) { { "Padding", "sml.padding", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_sml_secIndex, { "secIndex", "sml.secindex", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_sml_timestamp, + { "timestamp", "sml.timestamp", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } }, + { &hf_sml_localOffset, + { "localOffset", "sml.localOffset", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } }, + { &hf_sml_seasonTimeOffset, + { "seasonTimeOffset", "sml.seasonTimeOffset", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } }, { &hf_sml_attentionNo, { "attentionNo", "sml.attentionno", FT_UINT16, BASE_HEX|BASE_RANGE_STRING, RVALS(attentionValues), 0x0, NULL, HFILL }}, { &hf_sml_attentionMsg, @@ -2661,6 +2966,10 @@ void proto_register_sml (void) { { "---SML-File---", "sml.file_marker", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_sml_new_file_marker, { "---New SML File---", "sml.new_file_marker", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_sml_listtype, + { "listType", "sml.listtype", FT_UINT8, BASE_HEX, VALS(listtypevalues), 0x0, NULL, HFILL }}, + { &hf_sml_cosemvalue, + { "cosemvalue", "sml.cosemvalue", FT_UINT8, BASE_HEX, VALS(cosemvaluevalues), 0x0, NULL, HFILL } }, }; /* Setup protocol subtree array */ @@ -2697,6 +3006,7 @@ void proto_register_sml (void) { &ett_sml_unit, &ett_sml_scaler, &ett_sml_value, + &ett_sml_simplevalue, &ett_sml_valueSignature, &ett_sml_valtree, &ett_sml_listSignature, @@ -2714,6 +3024,10 @@ void proto_register_sml (void) { &ett_sml_msgend, &ett_sml_tuple, &ett_sml_secIndex, + &ett_sml_timestamp, + &ett_sml_localTimestamp, + &ett_sml_localOffset, + &ett_sml_seasonTimeOffset, &ett_sml_signature, &ett_sml_attentionNo, &ett_sml_attentionMsg, @@ -2755,7 +3069,14 @@ void proto_register_sml (void) { &ett_sml_value_R4, &ett_sml_tree_Entry, &ett_sml_dasDetails, - &ett_sml_attentionDetails + &ett_sml_attentionDetails, + &ett_sml_listtypetype, + &ett_sml_listtype, + &ett_sml_timestampedvaluetype, + &ett_sml_timestampedvalue, + &ett_sml_cosemvaluetype, + &ett_sml_cosemvalue, + &ett_sml_scaler_unit }; static ei_register_info ei[] = { @@ -2772,6 +3093,8 @@ void proto_register_sml (void) { { &ei_sml_esc_error, { "sml.esc.error", PI_PROTOCOL, PI_ERROR, "escapesequence error", EXPFILL }}, { &ei_sml_version2_not_supported, { "sml.version2_not_supported", PI_UNDECODED, PI_WARN, "SML Version 2 not supported", EXPFILL }}, { &ei_sml_attentionNo, { "sml.attentionno.unknown", PI_PROTOCOL, PI_WARN, "unknown attentionNo", EXPFILL }}, + { &ei_sml_listtype_invalid, { "sml.listtype.invalid", PI_PROTOCOL, PI_WARN, "invalid listtype", EXPFILL } }, + { &ei_sml_cosemvalue_invalid, { "sml.cosemvalue.invalid", PI_PROTOCOL, PI_WARN, "invalid cosemvalue", EXPFILL } }, }; proto_sml = proto_register_protocol("Smart Message Language","SML", "sml"); @@ -2792,6 +3115,8 @@ void proto_reg_handoff_sml(void) { sml_handle = create_dissector_handle(dissect_sml, proto_sml); dissector_add_for_decode_as_with_preference("tcp.port", sml_handle); dissector_add_for_decode_as_with_preference("udp.port", sml_handle); + + register_dissector("sml", dissect_sml, proto_sml); } /* |