aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-07-09 19:56:59 +0100
committerJoão Valverde <j@v6e.pt>2023-07-25 16:23:26 +0000
commitb4a421cf8206dc9a675fbc58500d1a625869e77a (patch)
tree6f27314ae8820dc47fb47bee937f607eeb5ef88c /epan/addr_resolv.c
parent7e08afb4786242e836455cd9807f95c4eafdc277 (diff)
Replace "manuf" files with static arrays
To reduce startup external file parsing replce the manuf file with static arrays compiled into the binary. Add 3 tables for MA-L, MA-M and MA-S. Add a fourth table to direct a 24-bit MAC prefix (OUI) to one of these tables. Adapt the make-manuf.py script to generate the static C data instead of the text file. The arrays are sorted and a binary search is performed to map an OUI (24bit/28bit/36bit) to a short and long name.
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 3fcda74adc..4d81696df0 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -24,6 +24,7 @@
#include <wsutil/ws_assert.h>
#include "enterprises.h"
+#include "manuf.h"
/*
* Win32 doesn't have SIGALRM (and it's the OS where name lookup calls
@@ -1596,7 +1597,7 @@ get_ethbyaddr(const guint8 *addr)
} /* get_ethbyaddr */
static hashmanuf_t *
-manuf_hash_new_entry(const guint8 *addr, char* name, char* longname)
+manuf_hash_new_entry(const guint8 *addr, const char* name, const char* longname)
{
guint manuf_key;
hashmanuf_t *manuf_value;
@@ -1699,6 +1700,18 @@ manuf_name_lookup(const guint8 *addr)
}
}
+ /* Try the global manuf tables. */
+ uint8_t addr_copy[6];
+ memcpy(addr_copy, addr, 6);
+ /* Mask out the broadcast/multicast flag */
+ addr_copy[0] &= 0xFE;
+ const char *long_name;
+ const char *short_name = global_manuf_lookup(addr_copy, &long_name);
+ if (short_name) {
+ /* Found it */
+ return manuf_hash_new_entry(addr, short_name, long_name);
+ }
+
/* Add the address as a hex string */
return manuf_hash_new_entry(addr, NULL, NULL);