aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2010-06-28 22:29:49 +0000
committerBill Meier <wmeier@newsguy.com>2010-06-28 22:29:49 +0000
commit3af757c87597665cf5ceb46843cf1ef880f9eff4 (patch)
treec5b3640dc630c8a8cb5aa7f8b9e767016486540f /epan/addr_resolv.c
parentdd4e1943047bf86e42b46708ef24bc9d94228641 (diff)
Rework ethernet address resolution: step 1: simplify 'get_ether_name_if_known()'
svn path=/trunk/; revision=33359
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 758f66a328..b3a29900ca 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -2817,15 +2817,12 @@ get_ether_name(const guint8 *addr)
return tp->name;
} /* get_ether_name */
-
-/* Look for an ether name in the hash, and return it if found.
- * If it's not found, simply return NULL. We DO NOT make a new
- * hash entry for it with the hex digits turned into a string.
+/* Look for a (non-dummy) ether name in the hash, and return it if found.
+ * If it's not found, simply return NULL.
*/
gchar *
get_ether_name_if_known(const guint8 *addr)
{
- int hash_idx;
hashether_t *tp;
/* Initialize ether structs if we're the first
@@ -2838,46 +2835,20 @@ get_ether_name_if_known(const guint8 *addr)
eth_resolution_initialized = 1;
}
- hash_idx = HASH_ETH_ADDRESS(addr);
-
- tp = eth_table[hash_idx];
+ /* eth_name_lookup will create a hash entry if it doesn't exist */
+ tp = eth_name_lookup(addr, TRUE);
+ g_assert(tp != NULL);
- if( tp == NULL ) {
- /* Hash key not found in table.
- * Force a lookup (and a hash entry) for addr, then call
- * myself. I plan on not getting into an infinite loop because
- * eth_name_lookup() is guaranteed to make a hashtable entry,
- * so when I call myself again, I can never get into this
- * block of code again. Knock on wood...
- */
- (void) eth_name_lookup(addr, TRUE);
- return get_ether_name_if_known(addr); /* a well-placed goto would suffice */
+ if (! tp->is_dummy_entry) {
+ /* Name is from an ethers file (or is a "well-known" MAC address name from the manuf file) */
+ return tp->name;
}
else {
- while(1) {
- if (memcmp(tp->addr, addr, sizeof(tp->addr)) == 0) {
- if (!tp->is_dummy_entry) {
- /* A name was found, and its origin is an ethers file */
- return tp->name;
- }
- else {
- /* A name was found, but it was created, not found in a file */
- return NULL;
- }
- }
- if (tp->next == NULL) {
- /* Read my reason above for why I'm sure I can't get into an infinite loop */
- (void) eth_name_lookup(addr, TRUE);
- return get_ether_name_if_known(addr); /* a well-placed goto would suffice */
- }
- tp = tp->next;
- }
+ /* Name was created */
+ return NULL;
}
- g_assert_not_reached();
- return NULL;
}
-
extern guint8 *
get_ether_addr(const gchar *name)
{