datatypes

package
v0.0.0-...-7e7b345 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package datatypes defines the structures, decoders and encoder for built-in data types described in Part 6 Section 5 Data encoding.

Index

Constants

View Source
const (
	TypeTwoByte = iota
	TypeFourByte
	TypeNumeric
	TypeString
	TypeGUID
	TypeOpaque
)

NodeID type definitions.

Specification: Part 6, 5.2.2.9

Variables

This section is empty.

Functions

This section is empty.

Types

type AnonymousIdentityToken

type AnonymousIdentityToken struct {
	PolicyID *String
}

AnonymousIdentityToken is used to indicate that the Client has no user credentials.

Specification: Part4, 7.36.5

func DecodeAnonymousIdentityToken

func DecodeAnonymousIdentityToken(b []byte) (*AnonymousIdentityToken, error)

DecodeAnonymousIdentityToken decodes given bytes as AnonymousIdentityToken.

func NewAnonymousIdentityToken

func NewAnonymousIdentityToken(policyID string) *AnonymousIdentityToken

NewAnonymousIdentityToken creates a new AnonymousIdentityToken.

func (*AnonymousIdentityToken) DecodeFromBytes

func (a *AnonymousIdentityToken) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes as AnonymousIdentityToken.

func (*AnonymousIdentityToken) ID

ID returns PolicyID in string.

func (*AnonymousIdentityToken) Len

func (a *AnonymousIdentityToken) Len() int

Len returns the actual Length of AnonymousIdentityToken in int.

func (*AnonymousIdentityToken) Serialize

func (a *AnonymousIdentityToken) Serialize() ([]byte, error)

Serialize serializes AnonymousIdentityToken into bytes.

func (*AnonymousIdentityToken) SerializeTo

func (a *AnonymousIdentityToken) SerializeTo(b []byte) error

SerializeTo serializes AnonymousIdentityToken into bytes.

func (*AnonymousIdentityToken) Type

func (a *AnonymousIdentityToken) Type() int

Type returns type of token defined in NodeIds.csv in int.

type Boolean

type Boolean struct {
	Value uint8
}

Boolean represents the datatype Boolean.

Specification: Part 3, 8.8

func DecodeBoolean

func DecodeBoolean(b []byte) (*Boolean, error)

DecodeBoolean decodes given bytes into Boolean.

func NewBoolean

func NewBoolean(b bool) *Boolean

NewBoolean creates a new Boolean datatype. If given true, this returns the Boolean(=uint8) value 0x01. Otherwise the value is 0x00,

func (*Boolean) DataType

func (bo *Boolean) DataType() uint16

DataType returns type of Data.

func (*Boolean) DecodeFromBytes

func (bo *Boolean) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into Boolean.

func (*Boolean) Len

func (bo *Boolean) Len() int

Len returns the actual length of Boolean.

func (*Boolean) Serialize

func (bo *Boolean) Serialize() ([]byte, error)

Serialize serializes Boolean into bytes.

func (*Boolean) SerializeTo

func (bo *Boolean) SerializeTo(b []byte) error

SerializeTo serializes Boolean into bytes.

func (*Boolean) String

func (bo *Boolean) String() string

String returns the value of Boolean in string.

The returned value would be "FALSE" if the Boolean is 0x00. Otherwise "TRUE".

type ByteString

type ByteString struct {
	Length int32
	Value  []byte
}

ByteString is encoded as sequence of bytes preceded by its length in bytes. The length is encoded as a 32-bit signed integer. If the length of the byte string is −1 then the byte string is ‘null’.

Specification: Part 6, 5.2.2.7

func DecodeByteString

func DecodeByteString(b []byte) (*ByteString, error)

DecodeByteString decodes given bytes into ByteString.

func NewByteString

func NewByteString(b []byte) *ByteString

NewByteString creates a new ByteString.

func (*ByteString) DecodeFromBytes

func (s *ByteString) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA ByteString.

func (*ByteString) Get

func (s *ByteString) Get() []byte

Get returns the value in Golang's built-in type string.

func (*ByteString) Len

func (s *ByteString) Len() int

Len returns the actual length of ByteString in int.

func (*ByteString) Serialize

func (s *ByteString) Serialize() ([]byte, error)

Serialize serializes ByteString into bytes.

func (*ByteString) SerializeTo

func (s *ByteString) SerializeTo(b []byte) error

SerializeTo serializes ByteString into bytes.

func (*ByteString) Set

func (s *ByteString) Set(b []byte)

Set sets the string value in ByteString and calcurate length.

type Data

type Data interface {
	DecodeFromBytes([]byte) error
	Serialize() ([]byte, error)
	SerializeTo([]byte) error
	Len() int
	DataType() uint16
}

Data is an interface to handle any kind of OPC UA data types.

type DataValue

type DataValue struct {
	EncodingMask      byte
	Value             *Variant
	Status            uint32
	SourceTimestamp   time.Time
	SourcePicoSeconds uint16
	ServerTimestamp   time.Time
	ServerPicoSeconds uint16
}

DataValue is always preceded by a mask that indicates which fields are present in the stream.

Specification: Part 6, 5.2.2.17

func DecodeDataValue

func DecodeDataValue(b []byte) (*DataValue, error)

DecodeDataValue decodes given bytes into DataValue.

func NewDataValue

func NewDataValue(hasValue, hasStatus, hasSrcTs, hasSrcPs, hasSvrTs, hasSvrPs bool, v *Variant, status uint32, srcTs time.Time, srcPs uint16, svrTs time.Time, svrPs uint16) *DataValue

NewDataValue creates a new DataValue.

func (*DataValue) DecodeFromBytes

func (d *DataValue) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into DataValue.

func (*DataValue) HasServerPicoSeconds

func (d *DataValue) HasServerPicoSeconds() bool

HasServerPicoSeconds checks if DataValue has ServerPicoSeconds or not.

func (*DataValue) HasServerTimestamp

func (d *DataValue) HasServerTimestamp() bool

HasServerTimestamp checks if DataValue has ServerTimestamp or not.

func (*DataValue) HasSourcePicoSeconds

func (d *DataValue) HasSourcePicoSeconds() bool

HasSourcePicoSeconds checks if DataValue has SourcePicoSeconds or not.

func (*DataValue) HasSourceTimestamp

func (d *DataValue) HasSourceTimestamp() bool

HasSourceTimestamp checks if DataValue has SourceTimestamp or not.

func (*DataValue) HasStatus

func (d *DataValue) HasStatus() bool

HasStatus checks if DataValue has Status or not.

func (*DataValue) HasValue

func (d *DataValue) HasValue() bool

HasValue checks if DataValue has Value or not.

func (*DataValue) Len

func (d *DataValue) Len() int

Len returns the actual length of DataValue in int.

func (*DataValue) Serialize

func (d *DataValue) Serialize() ([]byte, error)

Serialize serializes DataValue into bytes.

func (*DataValue) SerializeTo

func (d *DataValue) SerializeTo(b []byte) error

SerializeTo serializes DataValue into bytes.

func (*DataValue) SetServerPicoSecondsFlag

func (d *DataValue) SetServerPicoSecondsFlag()

SetServerPicoSecondsFlag sets server picoseconds flag in EncodingMask in DataValue.

func (*DataValue) SetServerTimestampFlag

func (d *DataValue) SetServerTimestampFlag()

SetServerTimestampFlag sets server timestamp flag in EncodingMask in DataValue.

func (*DataValue) SetSourcePicoSecondsFlag

func (d *DataValue) SetSourcePicoSecondsFlag()

SetSourcePicoSecondsFlag sets source picoseconds flag in EncodingMask in DataValue.

func (*DataValue) SetSourceTimestampFlag

func (d *DataValue) SetSourceTimestampFlag()

SetSourceTimestampFlag sets source timestamp flag in EncodingMask in DataValue.

func (*DataValue) SetStatusFlag

func (d *DataValue) SetStatusFlag()

SetStatusFlag sets status flag in EncodingMask in DataValue.

func (*DataValue) SetValueFlag

func (d *DataValue) SetValueFlag()

SetValueFlag sets value flag in EncodingMask in DataValue.

type DataValueArray

type DataValueArray struct {
	ArraySize  int32
	DataValues []*DataValue
}

DataValueArray represents the DataValueArray.

func DecodeDataValueArray

func DecodeDataValueArray(b []byte) (*DataValueArray, error)

DecodeDataValueArray decodes given bytes into DataValueArray.

func NewDataValueArray

func NewDataValueArray(values []*DataValue) *DataValueArray

NewDataValueArray creates a new DataValueArray from multiple data values.

func (*DataValueArray) DecodeFromBytes

func (d *DataValueArray) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into DataValueArray.

func (*DataValueArray) Len

func (d *DataValueArray) Len() int

Len returns the actual length in int.

func (*DataValueArray) Serialize

func (d *DataValueArray) Serialize() ([]byte, error)

Serialize serializes DataValueArray into bytes.

func (*DataValueArray) SerializeTo

func (d *DataValueArray) SerializeTo(b []byte) error

SerializeTo serializes DataValueArray into bytes.

type ExpandedNodeID

type ExpandedNodeID struct {
	NodeID       *NodeID
	NamespaceURI *String
	ServerIndex  uint32
}

ExpandedNodeID extends the NodeID structure by allowing the NamespaceURI to be explicitly specified instead of using the NamespaceIndex. The NamespaceURI is optional. If it is specified, then the NamespaceIndex inside the NodeID shall be ignored.

Specification: Part 6, 5.2.2.10

func DecodeExpandedNodeID

func DecodeExpandedNodeID(b []byte) (*ExpandedNodeID, error)

DecodeExpandedNodeID decodes given bytes into ExpandedNodeID.

func NewExpandedNodeID

func NewExpandedNodeID(hasURI, hasIndex bool, nodeID *NodeID, uri string, idx uint32) *ExpandedNodeID

NewExpandedNodeID creates a new ExpandedNodeID.

func NewFourByteExpandedNodeID

func NewFourByteExpandedNodeID(ns uint8, id uint16) *ExpandedNodeID

NewFourByteExpandedNodeID creates a four byte numeric expanded node id.

func NewTwoByteExpandedNodeID

func NewTwoByteExpandedNodeID(id uint8) *ExpandedNodeID

NewTwoByteExpandedNodeID creates a two byte numeric expanded node id.

func (*ExpandedNodeID) DecodeFromBytes

func (e *ExpandedNodeID) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into ExpandedNodeID.

func (*ExpandedNodeID) HasNamespaceURI

func (e *ExpandedNodeID) HasNamespaceURI() bool

HasNamespaceURI checks if an ExpandedNodeID has NamespaceURI Flag.

func (*ExpandedNodeID) HasServerIndex

func (e *ExpandedNodeID) HasServerIndex() bool

HasServerIndex checks if an ExpandedNodeID has ServerIndex Flag.

func (*ExpandedNodeID) Len

func (e *ExpandedNodeID) Len() int

Len returns the actual length of ExpandedNodeID in int.

func (*ExpandedNodeID) Serialize

func (e *ExpandedNodeID) Serialize() ([]byte, error)

Serialize serializes ExpandedNodeID into bytes.

func (*ExpandedNodeID) SerializeTo

func (e *ExpandedNodeID) SerializeTo(b []byte) error

SerializeTo serializes ExpandedNodeID into bytes.

type ExtensionObject

type ExtensionObject struct {
	TypeID       *ExpandedNodeID
	EncodingMask byte
	Length       int32
	Value        ExtensionObjectValue
}

ExtensionObject is encoded as sequence of bytes prefixed by the NodeId of its DataTypeEncoding and the number of bytes encoded.

Specification: Part 6, 5.2.2.15

func DecodeExtensionObject

func DecodeExtensionObject(b []byte) (*ExtensionObject, error)

DecodeExtensionObject decodes given bytes into ExtensionObject.

func NewExtensionObject

func NewExtensionObject(mask uint8, extParam ExtensionObjectValue) *ExtensionObject

NewExtensionObject creates a new ExtensionObject from the ExtensionObjectValue given.

func (*ExtensionObject) DecodeFromBytes

func (e *ExtensionObject) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into ExtensionObject.

func (*ExtensionObject) Len

func (e *ExtensionObject) Len() int

Len returns the actual length of ExtensionObject in int.

func (*ExtensionObject) Serialize

func (e *ExtensionObject) Serialize() ([]byte, error)

Serialize serializes ExtensionObject into bytes.

func (*ExtensionObject) SerializeTo

func (e *ExtensionObject) SerializeTo(b []byte) error

SerializeTo serializes ExtensionObject into bytes.

func (*ExtensionObject) SetLength

func (e *ExtensionObject) SetLength()

SetLength sets the length of Value in Length field.

type ExtensionObjectValue

type ExtensionObjectValue interface {
	DecodeFromBytes([]byte) error
	SerializeTo(b []byte) error
	Len() int
	Type() int
}

ExtensionObjectValue represents the value in ExtensionObject.

func DecodeExtensionObjectValue

func DecodeExtensionObjectValue(b []byte, typ int) (ExtensionObjectValue, error)

DecodeExtensionObjectValue decodes given bytes as an ExtensionObjectValue depending on the specified type.

The type should be one defined in the DiscoveryConfiguration, UserIdentityToken, NodeAttributes, HistoryReadDetails, HistoryData, HistoryUpdateDetails, MonitoringFilterResult, FilterOperand.

type Float

type Float struct {
	Value float32
}

Float values shall be encoded with the appropriate IEEE-754 binary representation which has three basic components: the sign, the exponent, and the fraction.

Specification: Part 6, 5.2.2.3

func DecodeFloat

func DecodeFloat(b []byte) (*Float, error)

DecodeFloat decodes given bytes into Float.

func NewFloat

func NewFloat(value float32) *Float

NewFloat creates a new Float.

func (*Float) DataType

func (f *Float) DataType() uint16

DataType returns type of Data.

func (*Float) DecodeFromBytes

func (f *Float) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA Float.

func (*Float) Len

func (f *Float) Len() int

Len returns the actual length of Float in int.

func (*Float) Serialize

func (f *Float) Serialize() ([]byte, error)

Serialize serializes Float into bytes.

func (*Float) SerializeTo

func (f *Float) SerializeTo(b []byte) error

SerializeTo serializes Float into bytes.

type GUID

type GUID struct {
	Data1 uint32
	Data2 uint16
	Data3 uint16
	Data4 uint64
}

GUID represents GUID in binary stream. It is a 16-byte globally unique identifier.

Specification: Part 6, 5.1.3

func DecodeGUID

func DecodeGUID(b []byte) (*GUID, error)

DecodeGUID decodes given bytes into GUID.

func NewGUID

func NewGUID(guid string) *GUID

NewGUID creates a new GUID. Input should be GUID string of 16 hexadecimal characters like 1111AAAA-22BB-33CC-44DD-55EE77FF9900. Dash can be omitted, and alphabets are not case-sensitive.

func (*GUID) DecodeFromBytes

func (g *GUID) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into GUID.

func (*GUID) Len

func (g *GUID) Len() int

Len returns the actual size of GUID in int.

func (*GUID) Serialize

func (g *GUID) Serialize() ([]byte, error)

Serialize serializes GUID into bytes.

func (*GUID) SerializeTo

func (g *GUID) SerializeTo(b []byte) error

SerializeTo serializes GUID into given bytes.

func (*GUID) String

func (g *GUID) String() string

String returns GUID in human-readable string.

type IntegerID

type IntegerID uint32

IntegerID is a UInt32 that is used as an identifier, such as a handle. All values, except for 0, are valid.

Specification: Part 4, 7.14

const (
	IntegerIDNodeID IntegerID = iota + 1
	IntegerIDNodeClass
	IntegerIDBrowseName
	IntegerIDDisplayName
	IntegerIDDescription
	IntegerIDWriteMask
	IntegerIDUserWriteMask
	IntegerIDIsAbstract
	IntegerIDSymmetric
	IntegerIDInverseName
	IntegerIDContainsNoLoops
	IntegerIDEventNotifier
	IntegerIDValue
	IntegerIDDataType
	IntegerIDValueRank
	IntegerIDArrayDimensions
	IntegerIDAccessLevel
	IntegerIDUserAccessLevel
	IntegerIDMinimumSamplingInterval
	IntegerIDHistorizing
	IntegerIDExecutable
	IntegerIDUserExecutable
	IntegerIDDataTypeDefinition
	IntegerIDRolePermissions
	IntegerIDUserRolePermissions
	IntegerIDAccessRestrictions
	IntegerIDAccessLevelEx
)

Identifiers assigned to Attributes.

Specification: Part 6, A.1

type IssuedIdentityToken

type IssuedIdentityToken struct {
	PolicyID            *String
	TokenData           *ByteString
	EncryptionAlgorithm *String
}

IssuedIdentityToken is used to pass SecurityTokens issued by an external Authorization Service to the Server. These tokens may be text or binary. OAuth2 defines a standard for Authorization Services that produce JSON Web Tokens (JWT). These JWTs are passed as an Issued Token to an OPC UA Server which uses the signature contained in the JWT to validate the token. Part 6 describes OAuth2 and JWTs in more detail. If the token is encrypted, it shall use the EncryptedSecret format defined in 7.36.2.3. This token shall be encrypted by the Client if required by the SecurityPolicy of the UserTokenPolicy. The Server should specify a SecurityPolicy for the UserTokenPolicy if the SecureChannel has a SecurityPolicy of None and no transport layer encryption is available. The SecurityPolicy of the SecureChannel is used If no SecurityPolicy is specified in the UserTokenPolicy. If the SecurityPolicy is not None, the tokenData shall be encoded in UTF-8 (if it is not already binary), signed and encrypted according the rules specified for the tokenType of the associated UserTokenPolicy (see 7.37). If the SecurityPolicy is None then the tokenData only contains the UTF-8 encoded tokenData. This configuration should not be used unless the network is encrypted in some other manner such as a VPN. The use of this configuration without network encryption would result in a serious security fault, in that it would cause the appearance of a secure user access, but it would make the token visible in clear text.

Specification: Part4, 7.36.6

func DecodeIssuedIdentityToken

func DecodeIssuedIdentityToken(b []byte) (*IssuedIdentityToken, error)

DecodeIssuedIdentityToken decodes given bytes as IssuedIdentityToken.

func NewIssuedIdentityToken

func NewIssuedIdentityToken(policyID string, tokenData []byte, alg string) *IssuedIdentityToken

NewIssuedIdentityToken creates a new IssuedIdentityToken.

func (*IssuedIdentityToken) DecodeFromBytes

func (i *IssuedIdentityToken) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes as IssuedIdentityToken.

func (*IssuedIdentityToken) ID

func (i *IssuedIdentityToken) ID() string

ID returns PolicyID in string.

func (*IssuedIdentityToken) Len

func (i *IssuedIdentityToken) Len() int

Len returns the actual Length of IssuedIdentityToken in int.

func (*IssuedIdentityToken) Serialize

func (i *IssuedIdentityToken) Serialize() ([]byte, error)

Serialize serializes IssuedIdentityToken into bytes.

func (*IssuedIdentityToken) SerializeTo

func (i *IssuedIdentityToken) SerializeTo(b []byte) error

SerializeTo serializes IssuedIdentityToken into bytes.

func (*IssuedIdentityToken) Type

func (i *IssuedIdentityToken) Type() int

Type returns type of token defined in NodeIds.csv in int.

type LocalizedText

type LocalizedText struct {
	EncodingMask uint8
	Locale       *String
	Text         *String
}

LocalizedText represents a LocalizedText. A LocalizedText structure contains two fields that could be missing. For that reason, the encoding uses a bit mask to indicate which fields are actually present in the encoded form.

Specification: Part 6, 5.2.2.14

func DecodeLocalizedText

func DecodeLocalizedText(b []byte) (*LocalizedText, error)

DecodeLocalizedText decodes given bytes into LocalizedText.

func NewLocalizedText

func NewLocalizedText(locale, text string) *LocalizedText

NewLocalizedText creates a new NewLocalizedText.

func (*LocalizedText) DataType

func (l *LocalizedText) DataType() uint16

DataType returns type of Data.

func (*LocalizedText) DecodeFromBytes

func (l *LocalizedText) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into LocalizedText.

func (*LocalizedText) HasLocale

func (l *LocalizedText) HasLocale() bool

HasLocale checks if the LocalizedText has HasLocale mask in EncodingMask.

func (*LocalizedText) HasText

func (l *LocalizedText) HasText() bool

HasText checks if the LocalizedText has HasText mask in EncodingMask.

func (*LocalizedText) Len

func (l *LocalizedText) Len() int

Len returns the actual length of LocalizedText in int.

func (*LocalizedText) Serialize

func (l *LocalizedText) Serialize() ([]byte, error)

Serialize serializes LocalizedText into bytes.

func (*LocalizedText) SerializeTo

func (l *LocalizedText) SerializeTo(b []byte) error

SerializeTo serializes LocalizedText into bytes.

func (*LocalizedText) SetLocaleMask

func (l *LocalizedText) SetLocaleMask()

SetLocaleMask sets the HasLocale mask in EncodingMask.

func (*LocalizedText) SetTextMask

func (l *LocalizedText) SetTextMask()

SetTextMask sets the HasText mask in EncodingMask.

func (*LocalizedText) String

func (l *LocalizedText) String() string

String returns LocalizedText in string.

type NodeID

type NodeID struct {
	// contains filtered or unexported fields
}

NodeID is an identifier for a node in the address space of an OPC UA Server. The NodeID object encodes all different node id types.

func DecodeNodeID

func DecodeNodeID(b []byte) (*NodeID, error)

DecodeNodeID decodes a node id from bytes.

func NewFourByteNodeID

func NewFourByteNodeID(ns uint8, id uint16) *NodeID

NewFourByteNodeID returns a new four byte node id.

func NewGUIDNodeID

func NewGUIDNodeID(ns uint16, id string) *NodeID

NewGUIDNodeID returns a new GUID node id.

func NewNodeID

func NewNodeID(s string) (*NodeID, error)

NewNodeID returns a node id from a string definition of the format 'ns=<namespace>;{s,i,b,g}=<identifier>'.

For string node ids the 's=' prefix can be omitted.

For numeric ids the smallest possible type which can store the namespace and id value is returned.

Namespace URLs 'nsu=' are not supported since they require a lookup.

func NewNumericNodeID

func NewNumericNodeID(ns uint16, id uint32) *NodeID

NewNumericNodeID returns a new numeric node id.

func NewOpaqueNodeID

func NewOpaqueNodeID(ns uint16, id []byte) *NodeID

NewOpaqueNodeID returns a new opaque node id.

func NewStringNodeID

func NewStringNodeID(ns uint16, id string) *NodeID

NewStringNodeID returns a new string node id.

func NewTwoByteNodeID

func NewTwoByteNodeID(id uint8) *NodeID

NewTwoByteNodeID returns a new two byte node id.

func (*NodeID) DecodeFromBytes

func (n *NodeID) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes a NodeID from bytes.

func (*NodeID) EncodingMask

func (n *NodeID) EncodingMask() uint8

EncodingMask returns the encoding mask field including the type information and additional flags.

func (*NodeID) IndexFlag

func (n *NodeID) IndexFlag() bool

IndexFlag returns whether the Index flag is set in EncodingMask.

func (*NodeID) IntID

func (n *NodeID) IntID() int

IntID returns the identifier value if the type is TwoByte, FourByte or Numeric. For all other types IntID returns 0.

func (*NodeID) Len

func (n *NodeID) Len() int

Len returns the length of a serialized NodeID in bytes.

func (*NodeID) Namespace

func (n *NodeID) Namespace() int

Namespace returns the namespace id. For two byte node ids this will always be zero.

func (*NodeID) Serialize

func (n *NodeID) Serialize() ([]byte, error)

Serialize serializes NodeID to bytes.

func (*NodeID) SerializeTo

func (n *NodeID) SerializeTo(b []byte) error

SerializeTo serializes NodeID into bytes.

func (*NodeID) SetIndexFlag

func (n *NodeID) SetIndexFlag()

SetIndexFlag sets NamespaceURI flag in EncodingMask.

func (*NodeID) SetIntID

func (n *NodeID) SetIntID(v int) error

SetIntID sets the identifier value for two byte, four byte and numeric node ids. It returns an error for other types.

func (*NodeID) SetNamespace

func (n *NodeID) SetNamespace(v int) error

SetNamespace sets the namespace id. It returns an error if the id is not within the range of the node id type.

func (*NodeID) SetStringID

func (n *NodeID) SetStringID(v string) error

SetStringID sets the identifier value for string, guid and opaque node ids. It returns an error for other types.

func (*NodeID) SetURIFlag

func (n *NodeID) SetURIFlag()

SetURIFlag sets NamespaceURI flag in EncodingMask.

func (*NodeID) String

func (n *NodeID) String() string

String returns the string representation of the NodeID in the format described by NewNodeID.

func (*NodeID) StringID

func (n *NodeID) StringID() string

StringID returns the string value of the identifier for String and GUID NodeIDs, and the base64 encoded value for Opaque types. For all other types StringID returns an empty string.

func (*NodeID) Type

func (n *NodeID) Type() uint8

Type returns the node id type in EncodingMask.

func (*NodeID) URIFlag

func (n *NodeID) URIFlag() bool

URIFlag returns whether the URI flag is set in EncodingMask.

type QualifiedName

type QualifiedName struct {
	NamespaceIndex uint16
	Name           *String
}

QualifiedName contains a qualified name. It is, for example, used as BrowseName. The name part of the QualifiedName is restricted to 512 characters.

Specification: Part 3, 8.3

func DecodeQualifiedName

func DecodeQualifiedName(b []byte) (*QualifiedName, error)

DecodeQualifiedName decodes given bytes into QualifiedName.

func NewQualifiedName

func NewQualifiedName(index uint16, name string) *QualifiedName

NewQualifiedName creates a new QualifiedName.

func (*QualifiedName) DecodeFromBytes

func (q *QualifiedName) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA QualifiedName.

func (*QualifiedName) Len

func (q *QualifiedName) Len() int

Len returns the actual length of QualifiedName in int.

func (*QualifiedName) Serialize

func (q *QualifiedName) Serialize() ([]byte, error)

Serialize serializes QualifiedName into bytes.

func (*QualifiedName) SerializeTo

func (q *QualifiedName) SerializeTo(b []byte) error

SerializeTo serializes QualifiedName into bytes.

type ReadValueID

type ReadValueID struct {
	NodeID       *NodeID
	AttributeID  IntegerID
	IndexRange   *String
	DataEncoding *QualifiedName
}

ReadValueID is an identifier for an item to read or to monitor.

Specification: Part 4, 7.24

func DecodeReadValueID

func DecodeReadValueID(b []byte) (*ReadValueID, error)

DecodeReadValueID decodes given bytes into ReadValueID.

func NewReadValueID

func NewReadValueID(nodeID *NodeID, attrID IntegerID, idxRange string, qIdx uint16, qName string) *ReadValueID

NewReadValueID creates a new ReadValueID.

func (*ReadValueID) DecodeFromBytes

func (r *ReadValueID) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA ReadValueID.

func (*ReadValueID) Len

func (r *ReadValueID) Len() int

Len returns the actual length of ReadValueID in int.

func (*ReadValueID) Serialize

func (r *ReadValueID) Serialize() ([]byte, error)

Serialize serializes ReadValueID into bytes.

func (*ReadValueID) SerializeTo

func (r *ReadValueID) SerializeTo(b []byte) error

SerializeTo serializes ReadValueID into bytes.

type ReadValueIDArray

type ReadValueIDArray struct {
	ArraySize    int32
	ReadValueIDs []*ReadValueID
}

ReadValueIDArray represents an array of ReadValueIDs. It does not correspond to a certain type from the specification but makes encoding and decoding easier.

func DecodeReadValueIDArray

func DecodeReadValueIDArray(b []byte) (*ReadValueIDArray, error)

DecodeReadValueIDArray decodes given bytes into ReadValueIDArray.

func NewReadValueIDArray

func NewReadValueIDArray(ids []*ReadValueID) *ReadValueIDArray

NewReadValueIDArray creates a new ReadValueIDArray from multiple ReadValueIDs.

func (*ReadValueIDArray) DecodeFromBytes

func (r *ReadValueIDArray) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into ReadValueIDArray.

func (*ReadValueIDArray) Len

func (r *ReadValueIDArray) Len() int

Len returns the actual length in int.

func (*ReadValueIDArray) Serialize

func (r *ReadValueIDArray) Serialize() ([]byte, error)

Serialize serializes ReadValueIDArray into bytes.

func (*ReadValueIDArray) SerializeTo

func (r *ReadValueIDArray) SerializeTo(b []byte) error

SerializeTo serializes ReadValueIDArray into bytes.

type ServersOnNetwork

type ServersOnNetwork struct {
	RecordID           uint32
	ServerName         *String
	DiscoveryURI       *String
	ServerCapabilities *StringArray
}

ServersOnNetwork is a DNS service record that meet criteria specified in the request. This list is empty if no Servers meet the criteria.

Specification: Part4, 5.4.3.2

func DecodeServersOnNetwork

func DecodeServersOnNetwork(b []byte) (*ServersOnNetwork, error)

DecodeServersOnNetwork decodes given bytes into ServersOnNetwork.

func NewServersOnNetwork

func NewServersOnNetwork(record uint32, serverName, discoveryURI string, serverCap []string) *ServersOnNetwork

NewServersOnNetwork creates a new NewServersOnNetwork.

func (*ServersOnNetwork) DecodeFromBytes

func (s *ServersOnNetwork) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA ServersOnNetwork.

func (*ServersOnNetwork) Len

func (s *ServersOnNetwork) Len() int

Len returns the actual length of ServersOnNetwork in int.

func (*ServersOnNetwork) Serialize

func (s *ServersOnNetwork) Serialize() ([]byte, error)

Serialize serializes ServersOnNetwork into bytes.

func (*ServersOnNetwork) SerializeTo

func (s *ServersOnNetwork) SerializeTo(b []byte) error

SerializeTo serializes ServersOnNetwork into bytes.

type ServersOnNetworkArray

type ServersOnNetworkArray struct {
	ArraySize         int32
	ServersOnNetworks []*ServersOnNetwork
}

ServersOnNetworkArray represents an array of ServersOnNetworks. It does not correspond to a certain type from the specification but makes encoding and decoding easier.

func DecodeServersOnNetworkArray

func DecodeServersOnNetworkArray(b []byte) (*ServersOnNetworkArray, error)

DecodeServersOnNetworkArray decodes given bytes into ServersOnNetworkArray.

func NewServersOnNetworkArray

func NewServersOnNetworkArray(ids []*ServersOnNetwork) *ServersOnNetworkArray

NewServersOnNetworkArray creates a new ServersOnNetworkArray from multiple ServersOnNetworks.

func (*ServersOnNetworkArray) DecodeFromBytes

func (s *ServersOnNetworkArray) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into ServersOnNetworkArray.

func (*ServersOnNetworkArray) Len

func (s *ServersOnNetworkArray) Len() int

Len returns the actual length in int.

func (*ServersOnNetworkArray) Serialize

func (s *ServersOnNetworkArray) Serialize() ([]byte, error)

Serialize serializes ServersOnNetworkArray into bytes.

func (*ServersOnNetworkArray) SerializeTo

func (s *ServersOnNetworkArray) SerializeTo(b []byte) error

SerializeTo serializes ServersOnNetworkArray into bytes.

type String

type String struct {
	Length int32
	Value  []byte
}

String represents the String type in OPC UA Specifications. This consists of the four-byte length field and variable length of contents.

func DecodeString

func DecodeString(b []byte) (*String, error)

DecodeString decodes given bytes into String.

func NewString

func NewString(str string) *String

NewString creates a new String.

func (*String) DecodeFromBytes

func (s *String) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA String.

func (*String) Get

func (s *String) Get() string

Get returns the value in Golang's built-in type string.

func (*String) Len

func (s *String) Len() int

Len returns the actual length of String in int.

func (*String) Serialize

func (s *String) Serialize() ([]byte, error)

Serialize serializes String into bytes.

func (*String) SerializeTo

func (s *String) SerializeTo(b []byte) error

SerializeTo serializes String into bytes.

func (*String) Set

func (s *String) Set(str string)

Set sets the string value in String and calcurate length.

func (*String) String

func (s *String) String() string

String returns String in string.

type StringArray

type StringArray struct {
	ArraySize int32
	Strings   []*String
}

StringArray represents the StringArray.

func DecodeStringArray

func DecodeStringArray(b []byte) (*StringArray, error)

DecodeStringArray decodes given bytes into StringArray.

func NewStringArray

func NewStringArray(strs []string) *StringArray

NewStringArray creates a new StringArray from multiple strings.

func (*StringArray) DecodeFromBytes

func (s *StringArray) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into StringArray. TODO: add validation to avoid crash.

func (*StringArray) Len

func (s *StringArray) Len() int

Len returns the actual length in int.

func (*StringArray) Serialize

func (s *StringArray) Serialize() ([]byte, error)

Serialize serializes StringArray into bytes.

func (*StringArray) SerializeTo

func (s *StringArray) SerializeTo(b []byte) error

SerializeTo serializes StringArray into bytes.

type Uint32Array

type Uint32Array struct {
	ArraySize int32
	Values    []uint32
}

Uint32Array represents the array of Uint32 type of data.

func DecodeUint32Array

func DecodeUint32Array(b []byte) (*Uint32Array, error)

DecodeUint32Array decodes given bytes into Uint32Array.

func NewUint32Array

func NewUint32Array(vals []uint32) *Uint32Array

NewUint32Array creates a new NewUint32Array from multiple uint32 values.

func (*Uint32Array) DecodeFromBytes

func (u *Uint32Array) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into Uint32Array. TODO: add validation to avoid crash.

func (*Uint32Array) Len

func (u *Uint32Array) Len() int

Len returns the actual length in int.

func (*Uint32Array) Serialize

func (u *Uint32Array) Serialize() ([]byte, error)

Serialize serializes Uint32Array into bytes.

func (*Uint32Array) SerializeTo

func (u *Uint32Array) SerializeTo(b []byte) error

SerializeTo serializes Uint32Array into bytes.

type UserIdentityToken

type UserIdentityToken interface {
	ExtensionObjectValue
}

UserIdentityToken is an interface to handle all types of UserIdentityToken types as one type.

type UserNameIdentityToken

type UserNameIdentityToken struct {
	PolicyID            *String
	UserName            *String
	Password            *ByteString
	EncryptionAlgorithm *String
}

UserNameIdentityToken is used to pass simple username/password credentials to the Server.

This token shall be encrypted by the Client if required by the SecurityPolicy of the UserTokenPolicy. The Server should specify a SecurityPolicy for the UserTokenPolicy if the SecureChannel has a SecurityPolicy of None and no transport layer encryption is available. If None is specified for the UserTokenPolicy and SecurityPolicy is None then the password only contains the UTF-8 encoded password. The SecurityPolicy of the SecureChannel is used if no SecurityPolicy is specified in the UserTokenPolicy.

If the token is to be encrypted the password shall be converted to a UTF-8 ByteString, encrypted and then serialized as shown in Table 181. The Server shall decrypt the password and verify the ServerNonce.

If the SecurityPolicy is None then the password only contains the UTF-8 encoded password. This configuration should not be used unless the network is encrypted in some other manner such as a VPN. The use of this configuration without network encryption would result in a serious security fault, in that it would cause the appearance of a secure user access, but it would make the password visible in clear text.

Specification: Part4, 7.36.4

func DecodeUserNameIdentityToken

func DecodeUserNameIdentityToken(b []byte) (*UserNameIdentityToken, error)

DecodeUserNameIdentityToken decodes given bytes as UserNameIdentityToken.

func NewUserNameIdentityToken

func NewUserNameIdentityToken(policyID, username string, password []byte, alg string) *UserNameIdentityToken

NewUserNameIdentityToken creates a new UserNameIdentityToken.

func (*UserNameIdentityToken) DecodeFromBytes

func (u *UserNameIdentityToken) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes as UserNameIdentityToken.

func (*UserNameIdentityToken) ID

func (u *UserNameIdentityToken) ID() string

ID returns PolicyID in string.

func (*UserNameIdentityToken) Len

func (u *UserNameIdentityToken) Len() int

Len returns the actual Length of UserNameIdentityToken in int.

func (*UserNameIdentityToken) Serialize

func (u *UserNameIdentityToken) Serialize() ([]byte, error)

Serialize serializes UserNameIdentityToken into bytes.

func (*UserNameIdentityToken) SerializeTo

func (u *UserNameIdentityToken) SerializeTo(b []byte) error

SerializeTo serializes UserNameIdentityToken into bytes.

func (*UserNameIdentityToken) Type

func (u *UserNameIdentityToken) Type() int

Type returns type of token defined in NodeIds.csv in int.

type Variant

type Variant struct {
	EncodingMask          uint8
	ArrayLength           *int32
	Value                 Data
	ArrayDimensionsLength *int32
	ArrayDimensions       []*int32
}

Variant is a union of the built-in types.

Specification: Part 6, 5.2.2.16

func DecodeVariant

func DecodeVariant(b []byte) (*Variant, error)

DecodeVariant decodes given bytes into Variant.

func NewVariant

func NewVariant(data Data) *Variant

NewVariant creates a new Variant.

func (*Variant) DecodeFromBytes

func (v *Variant) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into Variant.

func (*Variant) Len

func (v *Variant) Len() int

Len returns the actual length of Variant in int.

func (*Variant) Serialize

func (v *Variant) Serialize() ([]byte, error)

Serialize serializes Variant into bytes.

func (*Variant) SerializeTo

func (v *Variant) SerializeTo(b []byte) error

SerializeTo serializes Variant into bytes.

type WriteValue

type WriteValue struct {
	NodeID      *NodeID
	AttributeID IntegerID
	IndexRange  *String
	Value       *DataValue
}

WriteValue is a set of Node and Attribute to write.

Specification: Part4, 5.10.4.2

func DecodeWriteValue

func DecodeWriteValue(b []byte) (*WriteValue, error)

DecodeWriteValue decodes given bytes into WriteValue.

func NewWriteValue

func NewWriteValue(node *NodeID, attr IntegerID, idxRange string, value *DataValue) *WriteValue

NewWriteValue creates a new NewWriteValue.

func (*WriteValue) DecodeFromBytes

func (w *WriteValue) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into OPC UA WriteValue.

func (*WriteValue) Len

func (w *WriteValue) Len() int

Len returns the actual length of WriteValue in int.

func (*WriteValue) Serialize

func (w *WriteValue) Serialize() ([]byte, error)

Serialize serializes WriteValue into bytes.

func (*WriteValue) SerializeTo

func (w *WriteValue) SerializeTo(b []byte) error

SerializeTo serializes WriteValue into bytes.

type WriteValueArray

type WriteValueArray struct {
	ArraySize   int32
	WriteValues []*WriteValue
}

WriteValueArray represents an array of WriteValues. It does not correspond to a certain type from the specification but makes encoding and decoding easier.

func DecodeWriteValueArray

func DecodeWriteValueArray(b []byte) (*WriteValueArray, error)

DecodeWriteValueArray decodes given bytes into WriteValueArray.

func NewWriteValueArray

func NewWriteValueArray(ids []*WriteValue) *WriteValueArray

NewWriteValueArray creates a new WriteValueArray from multiple WriteValues.

func (*WriteValueArray) DecodeFromBytes

func (w *WriteValueArray) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes into WriteValueArray.

func (*WriteValueArray) Len

func (w *WriteValueArray) Len() int

Len returns the actual length in int.

func (*WriteValueArray) Serialize

func (w *WriteValueArray) Serialize() ([]byte, error)

Serialize serializes WriteValueArray into bytes.

func (*WriteValueArray) SerializeTo

func (w *WriteValueArray) SerializeTo(b []byte) error

SerializeTo serializes WriteValueArray into bytes.

type X509IdentityToken

type X509IdentityToken struct {
	PolicyID        *String
	CertificateData *String
}

X509IdentityToken is used to pass an X.509 v3 Certificate which is issued by the user. This token shall always be accompanied by a Signature in the userTokenSignature parameter of ActivateSession if required by the SecurityPolicy. The Server should specify a SecurityPolicy for the UserTokenPolicy if the SecureChannel has a SecurityPolicy of None.

Specification: Part4, 7.36.5

func DecodeX509IdentityToken

func DecodeX509IdentityToken(b []byte) (*X509IdentityToken, error)

DecodeX509IdentityToken decodes given bytes as X509IdentityToken.

func NewX509IdentityToken

func NewX509IdentityToken(policyID, cert string) *X509IdentityToken

NewX509IdentityToken creates a new X509IdentityToken.

func (*X509IdentityToken) DecodeFromBytes

func (x *X509IdentityToken) DecodeFromBytes(b []byte) error

DecodeFromBytes decodes given bytes as X509IdentityToken.

func (*X509IdentityToken) ID

func (x *X509IdentityToken) ID() string

ID returns PolicyID in string.

func (*X509IdentityToken) Len

func (x *X509IdentityToken) Len() int

Len returns the actual Length of X509IdentityToken in int.

func (*X509IdentityToken) Serialize

func (x *X509IdentityToken) Serialize() ([]byte, error)

Serialize serializes X509IdentityToken into bytes.

func (*X509IdentityToken) SerializeTo

func (x *X509IdentityToken) SerializeTo(b []byte) error

SerializeTo serializes X509IdentityToken into bytes.

func (*X509IdentityToken) Type

func (x *X509IdentityToken) Type() int

Type returns type of token defined in NodeIds.csv in int.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL