YAML field type object
A field type object is the type of data field, found in data streams.
A field type object describes what a CTF consumer needs to decode a data field.
You can use a field type alias name (a string) anywhere a field type object is expected.
Expected usage locations
A field type object is expected at the following locations:
- Within another field type object
-
-
The
field-type
property of a structure field type member object. -
The
element-field-type
property of a static or dynamic field type object.
-
- Within a trace type object
-
-
A value of a field type alias mapping entry.
-
Any property of a features object.
-
- Within a data stream type object
-
-
Any property of a packet features object.
-
Any property of an event record features object.
-
- Within an event record type object
Available field type objects
As of barectf 3.1, the available field type objects are:
- Integer field type objects
-
Describes unsigned and signed integer data fields.
- Enumeration field type objects
-
Describes unsigned and signed enumeration data fields.
- Real field type object
-
Describes single-precision and double-precision real data fields.
- String field type object
-
Describes null-terminated string data fields.
- Structure field type object
-
Describes structure data fields.
- Static array field type object
-
Describes array data fields with a static length.
- Dynamic array field type object
-
Describes array data fields with a dynamic (variable) length.
Generated C types
barectf uses configured field types to generate user data parameters of packet opening and tracing functions.
Each field type object page indicates the field type’s corresponding C type(s).
Here’s a summary:
Field type | C type |
---|---|
Unsigned integer/enumeration field type |
Depending on the
|
Signed integer/enumeration field type |
Depending on the
|
Depending on the
|
|
|
|
Pointer to |
|
Two adjacent parameters:
|
Inherit a field type object
A field type object can inherit the properties of another field type
object with the common $inherit
property.
When a field type object A inherits another field type object B, the effective field type object is A “patching” B.
For a given property of A, the patching rules are:
A's property type | <em>A</em>'s property exists in <em>B</em> | <em>A</em>'s property doesn’t exist in <em>B</em> |
---|---|---|
Null, boolean, integer, and string |
Replace B's property with A's property. |
Keep A's property. |
Sequence |
|
Keep A's property. |
Mapping |
|
Keep A's property. |
When A's property replaces B's property and the value of A's property is null, this effectively “resets” the property to its default value. |
Examples
In the examples below, the name of the base field type object’s alias is
base
.
class: unsigned-integer
size: 32
alignment: 8
$inherit: base
size: 16
class: unsigned-integer
size: 16
alignment: 8
class: unsigned-integer
size: 32
alignment: 8
$inherit: base
size: 16
preferred-display-base: hexadecimal
class: unsigned-integer
size: 16
alignment: 8
preferred-display-base: hexadecimal
class: signed-enumeration
mappings:
COMPOSE:
- 56
- [100, 299]
DIRTY: [0]
$inherit: base
size: 16
mappings:
COMPOSE:
- -22
class: signed-enumeration
size: 16
mappings:
COMPOSE:
- 56
- [100, 299]
- -22
DIRTY: [0]
class: structure
members:
- msg: string
- user_id: uint16
$inherit: base
members:
- src_ip_addr:
field-type:
class: static-array
length: 4
element-field-type: uint8
- user_id: int8
class: structure
members:
- msg: string
- user_id: int8
- src_ip_addr:
field-type:
class: static-array
length: 4
element-field-type: uint8
Common properties
All field type objects require that the class
or the
$inherit
property be set, but not both.
Name | Type | Description | Required? |
---|---|---|---|
String |
Class of this field type amongst:
|
Yes if the |
|
String |
Name of a field type alias from which to inherit. |
Yes if the |