Skip to content

PredefinedInstructions

Diego Nieto Cid edited this page Mar 13, 2015 · 2 revisions

This document is not complete. In the meanwhile, some documentation can be found in the source code. See: https://github.com/diegonc/packet-bnetp/tree/master/src/api

Constructor functions

Constructor functions encapsulate the initialization of commonly used instruction objects in a way they become easier to type an read.

In packet-bnetp constructor functions are overloaded to act as constructors

cons ( arg1, arg2, arg3 )

and copy-constructors

cons { attr1="val1" }

Constructors receive the instruction attributes in formal parameters. Each instruction constructor has its own parameter list and they are documented in the following sections.

Copy-constructors receive a template of the instruction object as its only parameter. The attributes of the template are copied to the new instruction object overriding those inherited from the base instruction type.

Field Description

uint

 uint8 ( label, base, string-map )
uint16 ( label, base, string-map )
uint32 ( label, base, string-map )
uint64 ( label, base, string-map )

These functions create a field for an unsigned integer of the specified size. The base argument is the base the number is displayed in when the field is shown in Wireshark and it must be one of

base.HEX
base.DEC
base.OCT

The label argument must be a non-empty string.

The string-map argument maps integer values to meaningful strings. It must be given as a lua table where the strings are stored using its corresponding integer value as a key. For example:

uint8 ( "Num", base.DEC, {
    "ONE",
    "TWO",
    "THREE",
    [1000] = "ONE THOUSAND",
    [0] = "CERO",
})

When constructing the field from a template object the following attributes are given special meaning:

uint8 {
    label="foo",      -- the label argument
    display=base.HEX, -- the base argument
    desc={...},       -- the string-map argument
    big_endian=false, -- the endianness of the integer.
                      -- (default: little-endian)
}