diff options
Diffstat (limited to 'wireshark/util.lua')
-rw-r--r-- | wireshark/util.lua | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/wireshark/util.lua b/wireshark/util.lua index 140308b..6051351 100644 --- a/wireshark/util.lua +++ b/wireshark/util.lua @@ -3,8 +3,88 @@ function bits(idx, len) return ((2^len)-1) * 2^idx end +function fix_addr_endianness(addr) + local fixed = ByteArray.new() + fixed:set_size(6) + fixed:set_index(0, string.byte(addr, 2)) + fixed:set_index(1, string.byte(addr, 1)) + fixed:set_index(2, string.byte(addr, 4)) + fixed:set_index(3, string.byte(addr, 3)) + fixed:set_index(4, string.byte(addr, 6)) + fixed:set_index(5, string.byte(addr, 5)) + return fixed:raw() +end + +room_user_addrs = { } +DS_SYSTEM_ADDRS = { + ["\x00\x00\x00\x00\x00\x00"] = "Null / empty", + ["\x00\x09\xbf\x11\x22\x33"] = "Default firmware MAC", + ["\x03\x09\xbf\x00\x00\x00"] = "Multiplayer CMD", + ["\x03\x09\xbf\x00\x00\x10"] = "Multiplayer Reply", + ["\x03\x09\xbf\x00\x00\x03"] = "Multiplayer ACK", + ["\x00\xf0\x77\x77\x77\x77"] = "Access point", + ["\xff\xff\xff\xff\xff\xff"] = "Broadcast", +} + +function get_addr_label(addr) + local label = DS_SYSTEM_ADDRS[addr] + if label ~= nil then + return label + end + + label = room_user_addrs[addr] + if label ~= nil then + return string.format("User: %s", label) + end + + return nil +end + +function add_addr(tree, field, buffer, value) + value = value or buffer:raw() + local treeitem = tree:add(field, buffer, value) + + local label = get_addr_label(value) + if label ~= nil then + treeitem:append_text(string.format(" (%s)", label)) + end + + return treeitem +end + +function add_addr_le(tree, field, buffer) + return add_addr(tree, field, buffer, fix_addr_endianness(buffer:raw())) +end + +function register_addr(addr, label) + room_user_addrs[addr] = label +end + +function register_addr_le(addr, label) + room_user_addrs[fix_addr_endianness(addr)] = label +end + GAMEID = { PICTOCHAT = 0xe603, MARIOKART = 0xbe01, } +PROFILE_COLOR_MAP = { + [0] = "greyish blue", + [1] = "brown", + [2] = "red", + [3] = "light pink", + [4] = "orange", + [5] = "yellow", + [6] = "lime", + [7] = "light green", + [8] = "dark green", + [9] = "turqoise", + [10] = "light blue", + [11] = "blue", + [12] = "dark blue", + [13] = "dark purple", + [14] = "light purple", + [15] = "dark pink", +} + |