Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Initialize ProtoField table inside protocol init function.

I would like to initialize the fields protocol table inside the protocol init function, is it possible ?

I've tried the following but it doesn't seem to be working:

function my_protocol_addProtoFieds()
    local field_table = {}
    local attr_id = "test"
    local field_name = "proto." .. attr_id
    local field_abbr = attr_id
    local ltype = ftypes.BOOLEAN

    if ltype ~= nil then
        local field = ProtoField.new(field_name, field_abbr, ltype)
        table.insert(field_table, field)
    end
    my_protocol.fields = field_table
end

function my_protocol.init()
    -- read some initialization files
    my_protocol_addProtoFieds()
end

Initialize ProtoField table inside protocol init function.

I would like to initialize the fields protocol table inside the protocol init function, is it possible ?

I've tried the following but it doesn't seem to be working:

(The Wireshark UI search filter does not see the added ProtoField)

function my_protocol_addProtoFieds()
    local field_table = {}
    local attr_id = "test"
    local field_name = "proto." .. attr_id
    local field_abbr = attr_id
    local ltype = ftypes.BOOLEAN

    if ltype ~= nil then
        local field = ProtoField.new(field_name, field_abbr, ltype)
        table.insert(field_table, field)
    end
    my_protocol.fields = field_table
end

function my_protocol.init()
    -- read some initialization files
    my_protocol_addProtoFieds()
end