libyang  2.2.8
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LYB Binary Format

LYB (LibYang Binary) is a proprietary libyang binary data and file format. Its primary purpose is efficient serialization (printing) and deserialization (parsing). With this goal in mind, every term node value is stored in its new binary format specification according to its type. Following is the format for all types with explicit support out-of-the-box (meaning that have a special type plugin). Any derived types inherit the format of its closest type with explicit support (up to a built-in type).

Format of specific data type values

binary (built-in)

Size (B) Mandatory Type Meaning
binary value size yes void * value in binary

bits (built-in)

Size (B) Mandatory Type Meaning
returned by lyplg_type_bits_bitmap_size() yes pointer to integer type of the specific size, if size more than 8 use char * bitmap of the set bits

boolean (built-in)

Size (B) Mandatory Type Meaning
1 yes int8_t * 0 for false, otherwise true

decimal64 (built-in)

Size (B) Mandatory Type Meaning
8 yes int64_t * little-endian value represented without floating point

empty (built-in)

Size (B) Mandatory Type Meaning
0 yes void none

enumeration (built-in)

Size (B) Mandatory Type Meaning
4 yes int32 * assigned little-endian value of the enum

identityref (built-in)

Size (B) Mandatory Type Meaning
string length yes char * string JSON format of the identityref

instance-identifier (built-in)

Size (B) Mandatory Type Meaning
string length yes char * string JSON format of the instance-identifier

instance-identifier-keys (yang)

Size (B) Mandatory Type Meaning
string length yes char * string JSON format of the instance-identifier keys predicate

(u)int(8/16/32/64) (built-in)

Size (B) Mandatory Type Meaning
1/2/4/8 yes pointer to the specific integer type little-endian integer value

leafref (built-in)

Size (B) Mandatory Type Meaning
exact same format as the leafref target

string (built-in)

Size (B) Mandatory Type Meaning
string length yes char * string itself

union (built-in)

Size (B) Mandatory Type Meaning
4 yes uint32_t * little-endian index of the resolved type in lysc_type_union.types
exact same format as the resolved type

Note that loading union value in this format prevents it from changing its real (resolved) type.

ipv4-address (ietf-inet-types)

Size (B) Mandatory Type Meaning
4 yes struct in_addr * IPv4 address in network-byte order
string length no char * IPv4 address zone string

ipv4-address-no-zone (ietf-inet-types)

Size (B) Mandatory Type Meaning
4 yes struct in_addr * IPv4 address in network-byte order

ipv6-address (ietf-inet-types)

Size (B) Mandatory Type Meaning
16 yes struct in6_addr * IPv6 address in network-byte order
string length no char * IPv6 address zone string

ipv6-address-no-zone (ietf-inet-types)

Size (B) Mandatory Type Meaning
16 yes struct in6_addr * IPv6 address in network-byte order

ipv4-prefix (ietf-inet-types)

Size (B) Mandatory Type Meaning
4 yes struct in_addr * IPv4 address in network-byte order
1 yes uint8_t * prefix length up to 32

ipv6-prefix (ietf-inet-types)

Size (B) Mandatory Type Meaning
16 yes struct in6_addr * IPv6 address in network-byte order
1 yes uint8_t * prefix length up to 128

date-and-time (ietf-yang-types)

Size (B) Mandatory Type Meaning
8 yes time_t * UNIX timestamp
1 no int8_t * flag whether the value is in the special -00:00 unknown timezone or not
string length no char * string with the fraction digits of a second

phys-address, mac-address, hex-string, uuid (ietf-yang-types)

Size (B) Mandatory Type Meaning
string length yes char * string itself

xpath1.0 (ietf-yang-types)

Size (B) Mandatory Type Meaning
string length yes char * string JSON format of the XPath expression

node-instance-identifier (ietf-netconf-acm)

Size (B) Mandatory Type Meaning
string length yes char * string JSON format of the instance-identifier