diff options
author | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2013-06-16 01:53:43 +0000 |
---|---|---|
committer | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2013-06-16 01:53:43 +0000 |
commit | b3ac3506e8bdc24b177eeab8a1d667c223e278e2 (patch) | |
tree | afcfb6cbb449feed0c8c3570ebc47bac2785b513 /epan/addr_resolv.c | |
parent | 82a13484b3dbf5ae8007226a62e63a2c7c4fc74d (diff) |
Add some comments around looking up names for port numbers.
(calling getservbyname() is really slow, but only called once per port
number...)
svn path=/trunk/; revision=49953
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r-- | epan/addr_resolv.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 92873696b2..33565b377a 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -612,6 +612,7 @@ static gchar initialize_services(); } + /* Set which table we should look up port in */ switch(proto) { case PT_UDP: table = udp_port_table; @@ -635,26 +636,32 @@ static gchar /*NOTREACHED*/ } /* proto */ + /* Look for port in table */ hash_idx = HASH_PORT(port); tp = table[hash_idx]; if( tp == NULL ) { + /* Not found so allocate new entry */ tp = table[hash_idx] = se_new(hashport_t); } else { + /* Hash matched, but need to loop around entries looking for matching port */ while(1) { if( tp->port == port ) { + /* Found matching entry, return name! */ return tp->name; } if (tp->next == NULL) { + /* Reached end of current list without match. Allocate and add to end of list */ tp->next = se_new(hashport_t); tp = tp->next; break; } + /* Try next entry */ tp = tp->next; } } - /* fill in a new entry */ + /* Fill in a new entry (which must be at the end of its list) */ tp->port = port; tp->next = NULL; |