aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2018-10-10 17:26:59 +0200
committerPeter Wu <peter@lekensteyn.nl>2018-10-18 07:51:36 +0000
commit178001e74d42199d7cfadd668331a6bcdb3eeb42 (patch)
tree7490cc2443d7834162cc9f6bc1b23cfcb3737a6f /test
parent0f3a4db65713c7425f7825aca0f7c0b81823a893 (diff)
lua: add support for ethernet addresses to the Address class
The code for the Address class already contains commented-out code for a number of additional address types. Activate the draft constructor for ethernet addresses and complete it. Use the newly-added function to parse a string that contains an ethernet address. Add a basic test tvb.lua. Read an ethernet address from a tvb and compare it to a constant Address.ether object. Change-Id: I9771dd6e7ade4b572a8b864b8986d641b4eba3e5 Reviewed-on: https://code.wireshark.org/review/30163 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'test')
-rw-r--r--test/lua/tvb.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/lua/tvb.lua b/test/lua/tvb.lua
index 43a042ee85..cfc068fcd6 100644
--- a/test/lua/tvb.lua
+++ b/test/lua/tvb.lua
@@ -54,7 +54,7 @@ end
-- number of verifyFields() * (1 + number of fields) +
-- number of verifyResults() * (1 + 2 * number of values)
--
-local taptests = { [FRAME]=4, [OTHER]=330 }
+local taptests = { [FRAME]=4, [OTHER]=333 }
local function getResults()
print("\n-----------------------------\n")
@@ -166,6 +166,7 @@ local testfield =
ABSOLUTE_UTC = ProtoField.absolute_time("test.basic.absolute.utc", "Basic absolute utc", base.UTC),
IPv4 = ProtoField.ipv4 ("test.basic.ipv4", "Basic ipv4 address"),
IPv6 = ProtoField.ipv6 ("test.basic.ipv6", "Basic ipv6 address"),
+ ETHER = ProtoField.ether ("test.basic.ether", "Basic ethernet address"),
-- GUID = ProtoField.guid ("test.basic.guid", "Basic GUID"),
},
@@ -216,6 +217,7 @@ local getfield =
ABSOLUTE_UTC = Field.new ("test.basic.absolute.utc"),
IPv4 = Field.new ("test.basic.ipv4"),
IPv6 = Field.new ("test.basic.ipv6"),
+ ETHER = Field.new ("test.basic.ether"),
-- GUID = Field.new ("test.basic.guid"),
},
@@ -577,6 +579,18 @@ function test_proto.dissector(tvbuf,pktinfo,root)
verifyFields("basic.IPv4", ipv4_match_fields)
----------------------------------------
+ testing(OTHER, "tree:add ether")
+
+ local tvb = ByteArray.new("010203040506"):tvb("Ether")
+ local ether = testfield.basic.ETHER
+ local ether_match_fields = {}
+
+ execute ("ether", pcall (callTreeAdd, tree, ether, tvb:range(0,6)))
+ addMatchFields(ether_match_fields, Address.ether('01:02:03:04:05:06'))
+
+ verifyFields("basic.ETHER", ether_match_fields)
+
+----------------------------------------
testing(OTHER, "tree:add_packet_field Bytes")
resetResults()