From 5e384792db65c0ea6a24b2cbdfa606f8c512f422 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Thu, 24 Nov 2016 03:59:06 +0000 Subject: [PATCH] dissect-wireshark: display Nonce value only Previously, TLV-TYPE and TLV-LENGTH are incorrectly included in Nonce row. refs #3107 Change-Id: I101c8d2962ddb81230c653ae95ff50e5f45a8c43 --- tools/dissect-wireshark/ndn.lua | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) mode change 100644 => 100755 tools/dissect-wireshark/ndn.lua diff --git a/tools/dissect-wireshark/ndn.lua b/tools/dissect-wireshark/ndn.lua old mode 100644 new mode 100755 index 724861b..1ae18fd --- a/tools/dissect-wireshark/ndn.lua +++ b/tools/dissect-wireshark/ndn.lua @@ -48,9 +48,14 @@ function escapeString(str) return str end -function getUriFromNameComponent(block) +-- @return TLV-VALUE portion of a TLV block +function getValue(b) + return b.tvb(b.offset + b.typeLen + b.lengthLen, b.length) +end + +function getUriFromNameComponent(b) -- @todo Implement proper proper URL escaping - return block.tvb(block.offset + block.typeLen + block.lengthLen, block.length):string() + return getValue(b):string() end function getUriFromName(nameBlock) @@ -66,6 +71,11 @@ function getUriFromName(nameBlock) end end +function getUriFromExclude(block) + -- @todo + return "" +end + function getNackReasonDetail(b) local code = getNonNegativeInteger(b) if (code == 0) then return "None" @@ -84,12 +94,8 @@ function getCachePolicyDetail(b) end function getNonNegativeInteger(b) - if (b.length == 1) then - return b.tvb(b.offset + b.typeLen + b.lengthLen, 1):uint() - elseif (b.length == 2) then - return b.tvb(b.offset + b.typeLen + b.lengthLen, 2):uint() - elseif (b.length == 4) then - return b.tvb(b.offset + b.typeLen + b.lengthLen, 4):uint() + if (b.length == 1 or b.length == 2 or b.length == 4) then + return getValue(b):uint() -- Something strange with uint64, not supporting it for now -- elseif (b.length == 8) then -- return b.tvb(b.offset + b.typeLen + b.lengthLen, 8):uint64() @@ -98,9 +104,12 @@ function getNonNegativeInteger(b) end end -function getUriFromExclude(block) - -- @todo - return "" +function getNonce(b) + assert(b.type == 10) + if (b.length ~= 4) then + return "invalid (should have 4 octets)" + end + return getValue(b):uint() end function getTrue(block) @@ -161,7 +170,7 @@ local NDN_DICT = { -- Sub-fields of Interest packet [9] = {name = "Selectors" , summary = true}, - [10] = {name = "Nonce" , field = ProtoField.bytes("ndn.nonce", "Nonce")}, + [10] = {name = "Nonce" , field = ProtoField.uint32("ndn.nonce", "Nonce", base.HEX) , value = getNonce}, [12] = {name = "InterestLifetime" , field = ProtoField.uint32("ndn.interestlifetime", "InterestLifetime", base.DEC) , value = getNonNegativeInteger}, -- Sub-fields of Interest/Selector field