--RFC2217-------------------------------------
local dataBitSizeTable = {
[0] = "5",
[1] = "6",
[2] = "7",
[3] = "8"
}
local stopBitSizeTable = {
[0] = "1",
[1] = "2",
}
local checkTypeTable = {
[0] = "NO",
[1] = "ODD",
[2] = "2",
[3] = "EVEN",
[4] = "4",
[5] = "MARK",
[6] = "6",
[7] = "7",
[8] = "8",
}
---------------------------------------------------------------------------
fields.baudrate=ProtoField.uint16("RFC2217" .. ".baudrate", "baudrate")
fields.dataBitSize=ProtoField.uint8("RFC2217" .. ".dataBitSize", "dataBitSize",base.hex,dataBitSizeTable,0x03)
fields.stopBitSize=ProtoField.uint8("RFC2217" .. ".stopBitSize", "stopBitSize",base.hex,stopBitSizeTable,0x04)
fields.checkType=ProtoField.uint8("RFC2217" .. ".checkType", "checkType",base.hex,checkTypeTable,0xf8)
----------------------------------------------------------------------------
function rfc2217 (tvb, pinfo, tree)
local subtree = tree:add(mc, tvb())
local offset=0
offset=4
subtree:add(fields.baudrate, tvb(offset,2))
local str="baudrate:"..tvb(offset,2):uint()
offset=6
subtree:add(fields.dataBitSize, tvb(offset,1))
str=str.." dataBitSize:".. tvb(offset,1):uint()%4+5
subtree:add(fields.stopBitSize, tvb(offset,1))
str=str.." stopBitSize:"..math.modf(tvb(offset,1):uint()/4)%2+1
subtree:add(fields.checkType, tvb(offset,1))
str=str.." checkType:"..checkTypeTable[math.modf(tvb(offset,1):uint()/8)]
pinfo.cols.info=str
end