3 utcp_protocol = Proto("UTCP", "User-space Transport Control Protocol")
4 utcp_protocol.fields = {}
6 src = ProtoField.uint16("utcp.src", "src", base.DEC)
7 dst = ProtoField.uint16("utcp.dst", "dst", base.DEC)
8 seq = ProtoField.uint32("utcp.seq", "seq", base.DEC)
9 ack = ProtoField.uint32("utcp.ack", "ack", base.DEC)
10 wnd = ProtoField.uint32("utcp.wnd", "wnd", base.DEC)
11 ctl = ProtoField.uint16("utcp.ctl", "ctl", base.HEX)
12 aux = ProtoField.uint16("utcp.aux", "aux", base.HEX)
13 aux_init = ProtoField.uint32("utcp.aux_init", "aux_init", base.HEX)
15 utcp_protocol.fields = {src, dst, seq, ack, wnd, ctl, aux, aux_init}
17 ctltext = {"SYN", "ACK", "SYN ACK", "FIN", "SYN FIN", "ACK FIN", "SYN ACK FIN", "RST", "SYN RST", "ACK RST", "SYN ACK RST", "FIN RST", "SYN FIN RST", "ACK FIN RST", "SYN ACK FIN RST"}
19 function ctl_to_text(ctl)
21 if text == nil then return "" end
22 return " (" .. text .. ")"
25 function utcp_protocol.dissector(buffer, pinfo, tree)
27 if length == 0 then return end
29 pinfo.cols.protocol = utcp_protocol.name
31 local subtree = tree:add(utcp_protocol, buffer(), "UTCP Protocol Data")
32 local ctl_text = ctl_to_text(buffer(16, 2):le_int())
33 local aux_field = buffer(18, 2):le_int()
34 local aux_len = 4 * ((aux_field - aux_field % 256) / 256) % 16
35 local aux_type = aux_field % 256
37 if aux_field ~= 0 then
38 aux_text = " (type " .. aux_type .. " length " .. aux_len .. ")"
41 subtree:add_le(src, buffer(0, 2))
42 subtree:add_le(dst, buffer(2, 2))
43 subtree:add_le(seq, buffer(4, 4))
44 subtree:add_le(ack, buffer(8, 4))
45 subtree:add_le(wnd, buffer(12, 4))
46 subtree:add_le(ctl, buffer(16, 2)):append_text(ctl_text)
47 subtree:add_le(aux, buffer(18, 2)):append_text(aux_text)
49 if aux_field == 257 then
50 local flags = buffer(23, 1):le_int()
52 if flags == 0 then flags_text = " (UDP)"
53 elseif flags == 3 then flags_text = " (TCP)"
55 subtree:add_le(aux_init, buffer(20, 4)):append_text(flags_text)
59 -- Assume we run the test program on port 9999
61 local udp_port = DissectorTable.get("udp.port")
62 udp_port:add(9999, utcp_protocol)