The STRUCT keyword
STRUCT <name> <field> <value> [<flags>]
The STRUCT
keyword defines a child structure of a previous struct
,
which is keyed by a particular MEMBER.
Many protocols are defined as a header which contains information
about the protocol, and a data portion which contains data carried
by that header. The header usually includes a type field, which
defines how the data portion is interpreted. The STRUCT
keyword
allows the server to automatically decode these protocols, and all of
their contents.
- <name>
-
The name of the attribute. The name can contain alphanumeric characters,
-
, and_
. The name should be short and descriptive.As the names are hierarchical, the name is scoped to its parent. So the name
Counter
can mean different things, depending on its context. - <field>
-
The name of a previous MEMBER which has been marked up with the word
key
in theflags
field.In most cases, the <field> reference is simply the name of a field in the attribute of type
struct
which was defined immediately before this definition.The <field> reference can also be an OID-style name, as in
Client-Id.Type
. The name is always looked up in the current dictionary. References cannot be to fields in other dictionaries. - <value>
-
When the <field> has this value, the data is interpreted as this
struct
. Numbers can be specified as decimal (19
), or as hex (0xffee
). - <flags>
-
Can only be
length=uint8
orlength=uint16
. When encoding or decoding the structure, it is prefixed by auint8
oruint16
field containing the length of the structure.
Common flags and meanings
Name | Description |
---|---|
|
When encoding or decoding the structure, it is prefixed by a |
|
When encoding or decoding the structure, it is prefixed by a |
|
When encoding or decoding the structure, add |
The following example shows how one structure can include another one. In this example, the Information
structure has two fields: Type
and Other
. It has two possible sub-structures which can appear after the Other
field. Which sub-structure to be decoded is defined by the key
field: Type
.
ATTRIBUTE Information 1 struct MEMBER Type uint8 key MEMBER Other uint32 STRUCT Foo Type 1 MEMBER Bar uint16 MEMBER Baz uint16 STRUCT Blag Type 2 MEMBER Whoops uint32 MEMBER Stuff uint8