From 1df206e63cddde74b7591600d57d053f9fa80c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Fri, 23 Aug 2024 00:49:53 +0200 Subject: [PATCH] Tweak opcua xslt a little bit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Dywicki --- .../protocols/opcua/opc-manual.mspec | 65 ++-- protocols/opcua/src/main/xslt/opc-manual.xsl | 49 ++- .../opcua/ParserSerializerTestsuite.xml | 283 ++++++++++++++++++ 3 files changed, 340 insertions(+), 57 deletions(-) diff --git a/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec b/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec index e65a82bfde9..df223e44f6d 100644 --- a/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec +++ b/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec @@ -150,11 +150,12 @@ [simple bit namespaceURISpecified] [simple bit serverIndexSpecified] [simple NodeIdTypeDefinition nodeId] - [virtual vstring '-1' identifier 'nodeId.identifier'] [optional PascalString namespaceURI 'namespaceURISpecified'] [optional uint 32 serverIndex 'serverIndexSpecified'] ] + + [type ExtensionObjectEncodingMask [reserved int 5 '0x00'] [simple bit typeIdSpecified] @@ -1058,6 +1059,24 @@ ['318' UserIdentityToken [simple PascalString policyId] ] + ['321' AnonymousIdentityToken + [simple PascalString policyId] + ] + ['324' UserNameIdentityToken + [simple PascalString policyId] + [simple PascalString userName] + [simple PascalByteString password] + [simple PascalString encryptionAlgorithm] + ] + ['327' X509IdentityToken + [simple PascalString policyId] + [simple PascalByteString certificateData] + ] + ['940' IssuedIdentityToken + [simple PascalString policyId] + [simple PascalByteString tokenData] + [simple PascalString encryptionAlgorithm] + ] ['467' ActivateSessionRequest [simple RequestHeader('391') requestHeader] [simple SignatureData('458') clientSignature] @@ -2269,35 +2288,9 @@ [simple PascalString userName] [simple int 64 annotationTime] ] - - ['316' UserIdentityToken - [implicit int 32 policyLength 'policyId.lengthInBytes + userIdentityTokenDefinition.lengthInBytes'] - [simple PascalString policyId] - [simple UserIdentityTokenDefinition('policyId.stringValue') userIdentityTokenDefinition] - ] - ] -] - -[discriminatedType UserIdentityTokenDefinition(vstring '-1' identifier) - [typeSwitch identifier - ['"anonymous"' AnonymousIdentityToken - ] - ['"username"' UserNameIdentityToken - [simple PascalString userName] - [simple PascalByteString password] - [simple PascalString encryptionAlgorithm] - ] - ['"certificate"' X509IdentityToken - [simple PascalByteString certificateData] - ] - ['"identity"' IssuedIdentityToken - [simple PascalByteString tokenData] - [simple PascalString encryptionAlgorithm] - ] ] ] - [discriminatedType Variant [simple bit arrayLengthSpecified] [simple bit arrayDimensionsSpecified] @@ -2410,38 +2403,55 @@ [array bit arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions'] ] +// node type, with two leading reserved bytes +[enum uint 6 NodeIdType + ['0' TwoByte ] + ['1' FourByte ] + ['2' Numeric ] + ['3' String ] + ['4' Guid ] + ['5' ByteString ] +] + [discriminatedType NodeIdTypeDefinition [abstract vstring '-1' identifier] + [abstract uint 16 namespace] [discriminator NodeIdType nodeType] [typeSwitch nodeType ['nodeIdTypeTwoByte' NodeIdTwoByte [simple uint 8 id] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace '-1'] // cause an error ] ['nodeIdTypeFourByte' NodeIdFourByte [simple uint 8 namespaceIndex] [simple uint 16 id] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeNumeric' NodeIdNumeric [simple uint 16 namespaceIndex] [simple uint 32 id] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeString' NodeIdString [simple uint 16 namespaceIndex] [simple PascalString id] [virtual vstring '-1' identifier 'id.stringValue'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeGuid' NodeIdGuid [simple uint 16 namespaceIndex] [array byte id count '16'] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeByteString' NodeIdByteString [simple uint 16 namespaceIndex] [simple PascalByteString id] [virtual vstring '-1' identifier 'id.stringValue'] + [virtual uint 16 namespace 'namespaceIndex'] ] ] ] @@ -2449,7 +2459,6 @@ [type NodeId [reserved int 2 '0x00'] [simple NodeIdTypeDefinition nodeId] - [virtual vstring '-1' id 'nodeId.identifier'] ] [type PascalString diff --git a/protocols/opcua/src/main/xslt/opc-manual.xsl b/protocols/opcua/src/main/xslt/opc-manual.xsl index b6820595f60..755bd2729f5 100644 --- a/protocols/opcua/src/main/xslt/opc-manual.xsl +++ b/protocols/opcua/src/main/xslt/opc-manual.xsl @@ -199,11 +199,12 @@ [simple bit namespaceURISpecified] [simple bit serverIndexSpecified] [simple NodeIdTypeDefinition nodeId] - [virtual vstring '-1' identifier 'nodeId.identifier'] [optional PascalString namespaceURI 'namespaceURISpecified'] [optional uint 32 serverIndex 'serverIndexSpecified'] ] + + [type ExtensionObjectEncodingMask [reserved int 5 '0x00'] [simple bit typeIdSpecified] @@ -239,39 +240,13 @@ ['0' NullExtension ] - + - - ['316' UserIdentityToken - [implicit int 32 policyLength 'policyId.lengthInBytes + userIdentityTokenDefinition.lengthInBytes'] - [simple PascalString policyId] - [simple UserIdentityTokenDefinition('policyId.stringValue') userIdentityTokenDefinition] - ] - ] -] - -[discriminatedType UserIdentityTokenDefinition(vstring '-1' identifier) - [typeSwitch identifier - ['"anonymous"' AnonymousIdentityToken - ] - ['"username"' UserNameIdentityToken - [simple PascalString userName] - [simple PascalByteString password] - [simple PascalString encryptionAlgorithm] - ] - ['"certificate"' X509IdentityToken - [simple PascalByteString certificateData] - ] - ['"identity"' IssuedIdentityToken - [simple PascalByteString tokenData] - [simple PascalString encryptionAlgorithm] - ] ] ] - [discriminatedType Variant [simple bit arrayLengthSpecified] [simple bit arrayDimensionsSpecified] @@ -384,38 +359,55 @@ [array bit arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions'] ] +// node type, with two leading reserved bytes +[enum uint 6 NodeIdType + ['0' TwoByte ] + ['1' FourByte ] + ['2' Numeric ] + ['3' String ] + ['4' Guid ] + ['5' ByteString ] +] + [discriminatedType NodeIdTypeDefinition [abstract vstring '-1' identifier] + [abstract uint 16 namespace] [discriminator NodeIdType nodeType] [typeSwitch nodeType ['nodeIdTypeTwoByte' NodeIdTwoByte [simple uint 8 id] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace '-1'] // cause an error ] ['nodeIdTypeFourByte' NodeIdFourByte [simple uint 8 namespaceIndex] [simple uint 16 id] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeNumeric' NodeIdNumeric [simple uint 16 namespaceIndex] [simple uint 32 id] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeString' NodeIdString [simple uint 16 namespaceIndex] [simple PascalString id] [virtual vstring '-1' identifier 'id.stringValue'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeGuid' NodeIdGuid [simple uint 16 namespaceIndex] [array byte id count '16'] [virtual vstring '-1' identifier 'id'] + [virtual uint 16 namespace 'namespaceIndex'] ] ['nodeIdTypeByteString' NodeIdByteString [simple uint 16 namespaceIndex] [simple PascalByteString id] [virtual vstring '-1' identifier 'id.stringValue'] + [virtual uint 16 namespace 'namespaceIndex'] ] ] ] @@ -423,7 +415,6 @@ [type NodeId [reserved int 2 '0x00'] [simple NodeIdTypeDefinition nodeId] - [virtual vstring '-1' id 'nodeId.identifier'] ] [type PascalString diff --git a/protocols/opcua/src/test/resources/protocols/opcua/ParserSerializerTestsuite.xml b/protocols/opcua/src/test/resources/protocols/opcua/ParserSerializerTestsuite.xml index 1060cb681fb..9fc863cfd5b 100644 --- a/protocols/opcua/src/test/resources/protocols/opcua/ParserSerializerTestsuite.xml +++ b/protocols/opcua/src/test/resources/protocols/opcua/ParserSerializerTestsuite.xml @@ -25,6 +25,289 @@ opcua read-write + + OPC UA Node Id + 01004101 + ExpandedNodeId + + + false + false + + + + 1 + + + 0 + 321 + + + + + + + + + OPC UA Extension Object Encoding Mask + 01 + ExtensionObjectEncodingMask + + + 0 + false + false + true + + + + + + OPC UA Anonymous Identity Token + 09000000616e6f6e796d6f7573 + UserIdentityToken + + 321 + + + + + + + 9 + anonymous + + + + + + + + + + OPC UA Extension Object Anonymous Identity Token + 01004101010d00000009000000616e6f6e796d6f7573 + ExtensionObject + + true + + + + + + false + false + + + + 1 + + + 0 + 321 + + + + + + + + + 0 + false + false + true + + + + 13 + + + + + + 9 + anonymous + + + + + + + + + + + + + OPC UA Activate Session request + 0500002000000084428062123302a3e7470f91899aa477deeab6ba1d83368c8a8e1a5bfffefa6de065de8f04edda010200000000000000ffffffff30750000000000ffffffffffffffff000000000000000001004101010d00000009000000616e6f6e796d6f7573ffffffffffffffff + ActivateSessionRequest + + 467 + + + + + + + + + + 0 + + + + 5 + + + 0 + + + 32 + 0x84428062123302a3e7470f91899aa477deeab6ba1d83368c8a8e1a5bfffefa6d + + + + + + + + 133679742810220000 + 2 + 0 + + + -1 + + + 30000 + + + + + false + false + + + + 0 + + + 0 + + + + + + + + + 0 + false + false + false + + + + + + + + + + + + + + + + -1 + + + + + -1 + 0x + + + + + + 0 + + + 0 + + + + + + + false + false + + + + 1 + + + 0 + 321 + + + + + + + + + 0 + false + false + true + + + + 13 + + + + + + 9 + anonymous + + + + + + + + + + + + + + + -1 + + + + + -1 + 0x + + + + + + + + + + OPC UA Publish Response Payload (data change) 20427b9004edda01350000000000000000ffffffff000000010000000100000001000000000100000020427b9004edda010100000001002b03012200000001000000010000000d0620000000f0cc098e04edda017089e98f04edda01000000000000000000000000