I want to dissector my own protocol (app layer protocol)

the protocol based on IP&UDP protocol.

the protocol is dynamic:

It have field "type" -8 bits) which define the following fields,
for example:
if (type == 0x01) the following fields will be "op" (4 bits) "src id" (8 bits)
if (type == 0x02) the following fields will be "slf id " (8 bits) "sip" (16 bits)

I know I can dissector my own protocol wireshark
But Can I dissector a dynamic protocol as I just describe ?