diff options
-rw-r--r-- | epan/wslua/wslua_address.c | 26 | ||||
-rw-r--r-- | test/lua/tvb.lua | 16 |
2 files changed, 32 insertions, 10 deletions
diff --git a/epan/wslua/wslua_address.c b/epan/wslua/wslua_address.c index 04bb6e5102..7bbce3653b 100644 --- a/epan/wslua/wslua_address.c +++ b/epan/wslua/wslua_address.c @@ -60,17 +60,25 @@ WSLUA_CONSTRUCTOR Address_ipv6(lua_State* L) { WSLUA_RETURN(1); /* The Address object */ } -#if 0 -/* TODO */ -static int Address_ss7(lua_State* L) { - Address addr = g_malloc(sizeof(address)); +WSLUA_CONSTRUCTOR Address_ether(lua_State *L) { + /* Creates an Address Object representing an Ethernet address. */ - /* alloc_address() */ +#define WSLUA_ARG_Address_ether_ETH 1 /* The Ethernet address. */ + Address addr = (Address)g_malloc(sizeof(address)); + const gchar *name = luaL_checkstring(L, WSLUA_ARG_Address_ether_ETH); + guint8 eth_buf[6]; - pushAddress(L,addr); - return 1; + if(!str_to_eth(name, eth_buf)) + memset(eth_buf, 0, sizeof(eth_buf)); + + alloc_address_wmem(NULL, addr, AT_ETHER, sizeof(eth_buf), eth_buf); + pushAddress(L, addr); + WSLUA_RETURN(1); /* The Address object. */ } -static int Address_eth(lua_State* L) { + +#if 0 +/* TODO */ +static int Address_ss7(lua_State* L) { Address addr = g_malloc(sizeof(address)); /* alloc_address() */ @@ -164,9 +172,9 @@ WSLUA_METHODS Address_methods[] = { WSLUA_CLASS_FNREG(Address,ip), WSLUA_CLASS_FNREG_ALIAS(Address,ipv4,ip), WSLUA_CLASS_FNREG(Address,ipv6), + WSLUA_CLASS_FNREG(Address,ether), #if 0 WSLUA_CLASS_FNREG_ALIAS(Address,ss7pc,ss7), - WSLUA_CLASS_FNREG(Address,eth), WSLUA_CLASS_FNREG(Address,sna}, WSLUA_CLASS_FNREG(Address,atalk), WSLUA_CLASS_FNREG(Address,vines), 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() |