# Revision history [back]

### Dynamic mask in LUA ProtoFields

Writing in LUA. Is it possible to adjust the bit pattern in a mask for a ProtoField?

I have:

local default_settings =
{
}

local hf_cod_pseq          = ProtoField.new   ("P Seq", "cod.pseq", ftypes.UINT32, nil, base.DEC,    default_settings.pmask, "(p) seq number")
local hf_cod_qseq          = ProtoField.new   ("Q Seq", "cod.qseq", ftypes.UINT32, nil, base.DEC,    default_settings.qmask, "(q) seq number")
local hf_cod_rsvd          = ProtoField.new   ("Reserved", "cod.rsvd", ftypes.UINT32, nil, base.DEC, default_settings.rmask, "Rsvd")


Where I set a mask that, for example might be 0xfff if I'm interested in the bottom 12 bits of an item. But for the data I'm interested in decoding, I'd like to be able to adjust the patterns, e.g. use masks of 0xff, 0xffff00, 0xff000000

So the question is whether it is possible/what is the syntax to allow me to modify the mask information in the proto objects hf_cod_pseq, hf_cod_qseq, etc?

I can think of creating a table of similar items, each with different masks, and chose which to use but that seems very inefficient/inflexible.

So is it possible to make these masks dynamic? Or can I delete them and re-create them after the object has been registered?

I don't need these changes to adjust on a packet by packet basis, but would like to be able to control the parameters (I'm able to create and manipulate the protocol preferences, and can dynamically adjust the default_parameters.pmask etc, but obviously these do not affect objects like hf_cod_pseq that have already been created). BTW I'm new to LUA and to wireshark.

### Dynamic mask in LUA ProtoFields

Writing in LUA. Is it possible to adjust the bit pattern in a mask for a ProtoField?

I have:

local default_settings =
{
}

local hf_cod_pseq          = ProtoField.new   ("P Seq", "cod.pseq", ftypes.UINT32, nil, base.DEC,    default_settings.pmask, "(p) seq number")
local hf_cod_qseq          = ProtoField.new   ("Q Seq", "cod.qseq", ftypes.UINT32, nil, base.DEC,    default_settings.qmask, "(q) seq number")
local hf_cod_rsvd          = ProtoField.new   ("Reserved", "cod.rsvd", ftypes.UINT32, nil, base.DEC, default_settings.rmask, "Rsvd")


Where I set a mask that, for example might be 0xfff if I'm interested in the bottom 12 bits of an item. But for the data I'm interested in decoding, I'd like to be able to adjust the patterns, e.g. use masks of 0xff, 0xffff00, 0xff000000

So the question is whether it is possible/what is the syntax to allow me to modify the mask information in the proto objects hf_cod_pseq, hf_cod_qseq, hf_cod_pseq, hf_cod_qseq, etc?

I can think of creating a table of similar items, each with different masks, and chose which to use but that seems very inefficient/inflexible.

So is it possible to make these masks dynamic? Or can I delete them and re-create them after the object has been registered?

I don't need these changes to adjust on a packet by packet basis, but would like to be able to control the parameters (I'm able to create and manipulate the protocol preferences, and can dynamically adjust the default_parameters.pmask default_parameters.pmask etc, but obviously these do not affect objects like hf_cod_pseq hf_cod_pseq that have already been created). BTW I'm new to LUA and to wireshark.

### Dynamic mask in LUA ProtoFields

Writing in LUA. Is it possible to adjust the bit pattern in a mask for a ProtoField?

I have:

local default_settings =
{
0xf000,
}

local hf_cod_pseq          = ProtoField.new   ("P Seq", "cod.pseq", ftypes.UINT32, nil, base.DEC,    default_settings.pmask, "(p) seq number")
local hf_cod_qseq          = ProtoField.new   ("Q Seq", "cod.qseq", ftypes.UINT32, nil, base.DEC,    default_settings.qmask, "(q) seq number")
local hf_cod_rsvd          = ProtoField.new   ("Reserved", "cod.rsvd", ftypes.UINT32, nil, base.DEC, default_settings.rmask, "Rsvd")


Where I set a mask that, for example might be 0xfff if I'm interested in the bottom 12 bits of an item. But for the data I'm interested in decoding, I'd like to be able to adjust the patterns, e.g. use masks of 0xff, 0xffff00, 0xff000000

So the question is whether it is possible/what is the syntax to allow me to modify the mask information in the proto objects hf_cod_pseq, hf_cod_qseq, etc?

I can think of creating a table of similar items, each with different masks, and chose which to use but that seems very inefficient/inflexible.

So is it possible to make these masks dynamic? Or can I delete them and re-create them after the object has been registered?

I don't need these changes to adjust on a packet by packet basis, but would like to be able to control the parameters (I'm able to create and manipulate the protocol preferences, and can dynamically adjust the default_parameters.pmask etc, but obviously these do not affect objects like hf_cod_pseq that have already been created). BTW I'm new to LUA and to wireshark.

### Dynamic mask in LUA ProtoFields

Writing in LUA. Is it possible to adjust the bit pattern in a mask for a ProtoField?

I have:

local default_settings =
{
}

local hf_cod_pseq          = ProtoField.new   ("P Seq", "cod.pseq", ftypes.UINT32, nil, base.DEC,    default_settings.pmask, "(p) seq number")
local hf_cod_qseq          = ProtoField.new   ("Q Seq", "cod.qseq", ftypes.UINT32, nil, base.DEC,    default_settings.qmask, "(q) seq number")
local hf_cod_rsvd          = ProtoField.new   ("Reserved", "cod.rsvd", ftypes.UINT32, nil, base.DEC, default_settings.rmask, "Rsvd")


Where I set a mask that, for example might be 0xfff if I'm interested in the bottom 12 bits of an item. But for the data I'm interested in decoding, I'd like to be able to adjust the patterns, e.g. use masks of 0xff, 0xffff00, 0xff000000

So the question is whether it is possible/what is the syntax to allow me to modify the mask information in the proto objects hf_cod_pseq, hf_cod_qseq, etc?

I can think of creating a table of similar items, each with different masks, and chose which to use but that seems very inefficient/inflexible.

So is it possible to make these masks dynamic? Or can I delete them and re-create them after the object has been registered?

I don't need these changes to adjust on a packet by packet basis, but would like to be able to control the parameters (I'm able to create and manipulate the protocol preferences, and can dynamically adjust the default_parameters.pmask etc, but obviously these do not affect objects like hf_cod_pseq that have already been created). BTW I'm new to LUA and to wireshark.