Deleted Added
full compact
addrtoname.c (111729) addrtoname.c (127675)
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Internet, ethernet, port, and protocol string to address
22 * and address to string conversion routines
23 *
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Internet, ethernet, port, and protocol string to address
22 * and address to string conversion routines
23 *
24 * $FreeBSD: head/contrib/tcpdump/addrtoname.c 111729 2003-03-02 08:25:48Z fenner $
24 * $FreeBSD: head/contrib/tcpdump/addrtoname.c 127675 2004-03-31 14:57:24Z bms $
25 */
26#ifndef lint
25 */
26#ifndef lint
27static const char rcsid[] =
28 "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.83.4.1 2002/06/02 00:08:07 guy Exp $ (LBL)";
27static const char rcsid[] _U_ =
28 "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.96.2.6 2004/03/24 04:14:31 guy Exp $ (LBL)";
29#endif
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
29#endif
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
35#include <sys/types.h>
36#include <sys/socket.h>
37#include <sys/time.h>
35#include <tcpdump-stdinc.h>
38
36
39#include <netinet/in.h>
40
41#ifdef USE_ETHER_NTOHOST
42#ifdef HAVE_NETINET_IF_ETHER_H
43struct mbuf; /* Squelch compiler warnings on some platforms for */
44struct rtentry; /* declarations in <net/if.h> */
45#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
46#include <netinet/if_ether.h>
47#endif /* HAVE_NETINET_IF_ETHER_H */
37#ifdef USE_ETHER_NTOHOST
38#ifdef HAVE_NETINET_IF_ETHER_H
39struct mbuf; /* Squelch compiler warnings on some platforms for */
40struct rtentry; /* declarations in <net/if.h> */
41#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
42#include <netinet/if_ether.h>
43#endif /* HAVE_NETINET_IF_ETHER_H */
44#ifdef HAVE_NETINET_ETHER_H
45#include <netinet/ether.h> /* ether_ntohost on linux */
46#endif /* HAVE_NETINET_ETHER_H */
48#endif /* USE_ETHER_NTOHOST */
49
47#endif /* USE_ETHER_NTOHOST */
48
50#include <arpa/inet.h>
51
52#include <ctype.h>
53#include <netdb.h>
54#include <pcap.h>
55#include <pcap-namedb.h>
56#include <signal.h>
57#include <stdio.h>
58#include <string.h>
59#include <stdlib.h>
49#include <pcap.h>
50#include <pcap-namedb.h>
51#include <signal.h>
52#include <stdio.h>
53#include <string.h>
54#include <stdlib.h>
60#include <unistd.h>
61
62#include "interface.h"
63#include "addrtoname.h"
64#include "llc.h"
65#include "setsignal.h"
66
55
56#include "interface.h"
57#include "addrtoname.h"
58#include "llc.h"
59#include "setsignal.h"
60
67/* Forwards */
68static RETSIGTYPE nohostname(int);
69
70/*
71 * hash tables for whatever-to-name translations
61/*
62 * hash tables for whatever-to-name translations
63 *
64 * XXX there has to be error checks against strdup(3) failure
72 */
73
74#define HASHNAMESIZE 4096
75
76struct hnamemem {
77 u_int32_t addr;
78 const char *name;
79 struct hnamemem *nxt;
80};
81
82struct hnamemem hnametable[HASHNAMESIZE];
83struct hnamemem tporttable[HASHNAMESIZE];
84struct hnamemem uporttable[HASHNAMESIZE];
85struct hnamemem eprototable[HASHNAMESIZE];
86struct hnamemem dnaddrtable[HASHNAMESIZE];
87struct hnamemem llcsaptable[HASHNAMESIZE];
65 */
66
67#define HASHNAMESIZE 4096
68
69struct hnamemem {
70 u_int32_t addr;
71 const char *name;
72 struct hnamemem *nxt;
73};
74
75struct hnamemem hnametable[HASHNAMESIZE];
76struct hnamemem tporttable[HASHNAMESIZE];
77struct hnamemem uporttable[HASHNAMESIZE];
78struct hnamemem eprototable[HASHNAMESIZE];
79struct hnamemem dnaddrtable[HASHNAMESIZE];
80struct hnamemem llcsaptable[HASHNAMESIZE];
81struct hnamemem ipxsaptable[HASHNAMESIZE];
88
82
83#if defined(INET6) && defined(WIN32)
84/*
85 * fake gethostbyaddr for Win2k/XP
86 * gethostbyaddr() returns incorrect value when AF_INET6 is passed
87 * to 3rd argument.
88 *
89 * h_name in struct hostent is only valid.
90 */
91static struct hostent *
92win32_gethostbyaddr(const char *addr, int len, int type)
93{
94 static struct hostent host;
95 static char hostbuf[NI_MAXHOST];
96 char hname[NI_MAXHOST];
97 struct sockaddr_in6 addr6;
98
99 host.h_name = hostbuf;
100 switch (type) {
101 case AF_INET:
102 return gethostbyaddr(addr, len, type);
103 break;
104 case AF_INET6:
105 memset(&addr6, 0, sizeof(addr6));
106 addr6.sin6_family = AF_INET6;
107 memcpy(&addr6.sin6_addr, addr, len);
108#ifdef __MINGW32__
109 /* MinGW doesn't provide getnameinfo */
110 return NULL;
111#else
112 if (getnameinfo((struct sockaddr *)&addr6, sizeof(addr6),
113 hname, sizeof(hname), NULL, 0, 0)) {
114 return NULL;
115 } else {
116 strcpy(host.h_name, hname);
117 return &host;
118 }
119#endif /* __MINGW32__ */
120 break;
121 default:
122 return NULL;
123 }
124}
125#define gethostbyaddr win32_gethostbyaddr
126#endif /* INET6 & WIN32*/
127
89#ifdef INET6
90struct h6namemem {
91 struct in6_addr addr;
92 char *name;
93 struct h6namemem *nxt;
94};
95
96struct h6namemem h6nametable[HASHNAMESIZE];

--- 52 unchanged lines hidden (view full) ---

149 addr >>= 8;
150 } while (--n > 0);
151
152 return cp + 1;
153}
154
155static u_int32_t f_netmask;
156static u_int32_t f_localnet;
128#ifdef INET6
129struct h6namemem {
130 struct in6_addr addr;
131 char *name;
132 struct h6namemem *nxt;
133};
134
135struct h6namemem h6nametable[HASHNAMESIZE];

--- 52 unchanged lines hidden (view full) ---

188 addr >>= 8;
189 } while (--n > 0);
190
191 return cp + 1;
192}
193
194static u_int32_t f_netmask;
195static u_int32_t f_localnet;
157static u_int32_t netmask;
158
159/*
196
197/*
160 * "getname" is written in this atrocious way to make sure we don't
161 * wait forever while trying to get hostnames from yp.
162 */
163#include <setjmp.h>
164
165jmp_buf getname_env;
166
167static RETSIGTYPE
168nohostname(int signo)
169{
170 longjmp(getname_env, 1);
171}
172
173/*
174 * Return a name for the IP address pointed to by ap. This address
175 * is assumed to be in network byte order.
198 * Return a name for the IP address pointed to by ap. This address
199 * is assumed to be in network byte order.
200 *
201 * NOTE: ap is *NOT* necessarily part of the packet data (not even if
202 * this is being called with the "ipaddr_string()" macro), so you
203 * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
204 * even in cases where it *is* part of the packet data, the caller
205 * would still have to check for a null return value, even if it's
206 * just printing the return value with "%s" - not all versions of
207 * printf print "(null)" with "%s" and a null pointer, some of them
208 * don't check for a null pointer and crash in that case.
209 *
210 * The callers of this routine should, before handing this routine
211 * a pointer to packet data, be sure that the data is present in
212 * the packet buffer. They should probably do those checks anyway,
213 * as other data at that layer might not be IP addresses, and it
214 * also needs to check whether they're present in the packet buffer.
176 */
177const char *
178getname(const u_char *ap)
179{
180 register struct hostent *hp;
181 u_int32_t addr;
182 static struct hnamemem *p; /* static for longjmp() */
183
184 memcpy(&addr, ap, sizeof(addr));
185 p = &hnametable[addr & (HASHNAMESIZE-1)];
186 for (; p->nxt; p = p->nxt) {
187 if (p->addr == addr)
188 return (p->name);
189 }
190 p->addr = addr;
191 p->nxt = newhnamemem();
192
193 /*
215 */
216const char *
217getname(const u_char *ap)
218{
219 register struct hostent *hp;
220 u_int32_t addr;
221 static struct hnamemem *p; /* static for longjmp() */
222
223 memcpy(&addr, ap, sizeof(addr));
224 p = &hnametable[addr & (HASHNAMESIZE-1)];
225 for (; p->nxt; p = p->nxt) {
226 if (p->addr == addr)
227 return (p->name);
228 }
229 p->addr = addr;
230 p->nxt = newhnamemem();
231
232 /*
194 * Only print names when:
195 * (1) -n was not given.
233 * Print names unless:
234 * (1) -n was given.
196 * (2) Address is foreign and -f was given. (If -f was not
235 * (2) Address is foreign and -f was given. (If -f was not
197 * give, f_netmask and f_local are 0 and the test
236 * given, f_netmask and f_localnet are 0 and the test
198 * evaluates to true)
237 * evaluates to true)
199 * (3) -a was given or the host portion is not all ones
200 * nor all zeros (i.e. not a network or broadcast address)
201 */
202 if (!nflag &&
238 */
239 if (!nflag &&
203 (addr & f_netmask) == f_localnet &&
204 (aflag ||
205 !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff))) {
206 if (!setjmp(getname_env)) {
207 (void)setsignal(SIGALRM, nohostname);
208 (void)alarm(20);
209 hp = gethostbyaddr((char *)&addr, 4, AF_INET);
210 (void)alarm(0);
211 if (hp) {
212 char *dotp;
240 (addr & f_netmask) == f_localnet) {
241 hp = gethostbyaddr((char *)&addr, 4, AF_INET);
242 if (hp) {
243 char *dotp;
213
244
214 p->name = strdup(hp->h_name);
215 if (Nflag) {
216 /* Remove domain qualifications */
217 dotp = strchr(p->name, '.');
218 if (dotp)
219 *dotp = '\0';
220 }
221 return (p->name);
245 p->name = strdup(hp->h_name);
246 if (Nflag) {
247 /* Remove domain qualifications */
248 dotp = strchr(p->name, '.');
249 if (dotp)
250 *dotp = '\0';
222 }
251 }
252 return (p->name);
223 }
224 }
225 p->name = strdup(intoa(addr));
226 return (p->name);
227}
228
229#ifdef INET6
230/*

--- 14 unchanged lines hidden (view full) ---

245 for (; p->nxt; p = p->nxt) {
246 if (memcmp(&p->addr, &addr, sizeof(addr)) == 0)
247 return (p->name);
248 }
249 p->addr = addr;
250 p->nxt = newh6namemem();
251
252 /*
253 }
254 }
255 p->name = strdup(intoa(addr));
256 return (p->name);
257}
258
259#ifdef INET6
260/*

--- 14 unchanged lines hidden (view full) ---

275 for (; p->nxt; p = p->nxt) {
276 if (memcmp(&p->addr, &addr, sizeof(addr)) == 0)
277 return (p->name);
278 }
279 p->addr = addr;
280 p->nxt = newh6namemem();
281
282 /*
253 * Only print names when:
254 * (1) -n was not given.
255 * (2) Address is foreign and -f was given. (If -f was not
256 * give, f_netmask and f_local are 0 and the test
257 * evaluates to true)
258 * (3) -a was given or the host portion is not all ones
259 * nor all zeros (i.e. not a network or broadcast address)
283 * Do not print names if -n was given.
260 */
284 */
261 if (!nflag
262#if 0
263 &&
264 (addr & f_netmask) == f_localnet &&
265 (aflag ||
266 !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff))
267#endif
268 ) {
269 if (!setjmp(getname_env)) {
270 (void)setsignal(SIGALRM, nohostname);
271 (void)alarm(20);
272 hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6);
273 (void)alarm(0);
274 if (hp) {
275 char *dotp;
285 if (!nflag) {
286 hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6);
287 if (hp) {
288 char *dotp;
276
289
277 p->name = strdup(hp->h_name);
278 if (Nflag) {
279 /* Remove domain qualifications */
280 dotp = strchr(p->name, '.');
281 if (dotp)
282 *dotp = '\0';
283 }
284 return (p->name);
290 p->name = strdup(hp->h_name);
291 if (Nflag) {
292 /* Remove domain qualifications */
293 dotp = strchr(p->name, '.');
294 if (dotp)
295 *dotp = '\0';
285 }
296 }
297 return (p->name);
286 }
287 }
288 cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
289 p->name = strdup(cp);
290 return (p->name);
291}
292#endif /* INET6 */
293

--- 26 unchanged lines hidden (view full) ---

320 tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
321 if (tp->e_nxt == NULL)
322 error("lookup_emem: calloc");
323
324 return tp;
325}
326
327/*
298 }
299 }
300 cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
301 p->name = strdup(cp);
302 return (p->name);
303}
304#endif /* INET6 */
305

--- 26 unchanged lines hidden (view full) ---

332 tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
333 if (tp->e_nxt == NULL)
334 error("lookup_emem: calloc");
335
336 return tp;
337}
338
339/*
328 * Find the hash node that corresponds to the bytestring 'bs'
340 * Find the hash node that corresponds to the bytestring 'bs'
329 * with length 'nlen'
330 */
331
332static inline struct enamemem *
333lookup_bytestring(register const u_char *bs, const unsigned int nlen)
334{
335 struct enamemem *tp;
336 register u_int i, j, k;

--- 101 unchanged lines hidden (view full) ---

438 error("lookup_protoid: calloc");
439
440 return tp;
441}
442
443const char *
444etheraddr_string(register const u_char *ep)
445{
341 * with length 'nlen'
342 */
343
344static inline struct enamemem *
345lookup_bytestring(register const u_char *bs, const unsigned int nlen)
346{
347 struct enamemem *tp;
348 register u_int i, j, k;

--- 101 unchanged lines hidden (view full) ---

450 error("lookup_protoid: calloc");
451
452 return tp;
453}
454
455const char *
456etheraddr_string(register const u_char *ep)
457{
446 register u_int i, j;
458 register u_int i;
447 register char *cp;
448 register struct enamemem *tp;
449 char buf[sizeof("00:00:00:00:00:00")];
450
451 tp = lookup_emem(ep);
452 if (tp->e_name)
453 return (tp->e_name);
454#ifdef USE_ETHER_NTOHOST
455 if (!nflag) {
459 register char *cp;
460 register struct enamemem *tp;
461 char buf[sizeof("00:00:00:00:00:00")];
462
463 tp = lookup_emem(ep);
464 if (tp->e_name)
465 return (tp->e_name);
466#ifdef USE_ETHER_NTOHOST
467 if (!nflag) {
456 char buf[128];
457 if (ether_ntohost(buf, (const struct ether_addr *)ep) == 0) {
458 tp->e_name = strdup(buf);
468 char buf2[128];
469 if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
470 tp->e_name = strdup(buf2);
459 return (tp->e_name);
460 }
461 }
462#endif
463 cp = buf;
471 return (tp->e_name);
472 }
473 }
474#endif
475 cp = buf;
464 if ((j = *ep >> 4) != 0)
465 *cp++ = hex[j];
476 *cp++ = hex[*ep >> 4 ];
466 *cp++ = hex[*ep++ & 0xf];
467 for (i = 5; (int)--i >= 0;) {
468 *cp++ = ':';
477 *cp++ = hex[*ep++ & 0xf];
478 for (i = 5; (int)--i >= 0;) {
479 *cp++ = ':';
469 if ((j = *ep >> 4) != 0)
470 *cp++ = hex[j];
480 *cp++ = hex[*ep >> 4 ];
471 *cp++ = hex[*ep++ & 0xf];
472 }
473 *cp = '\0';
474 tp->e_name = strdup(buf);
475 return (tp->e_name);
476}
477
478const char *
479linkaddr_string(const u_char *ep, const unsigned int len)
480{
481 register u_int i, j;
482 register char *cp;
483 register struct enamemem *tp;
484
485 if (len == 6) /* XXX not totally correct... */
486 return etheraddr_string(ep);
481 *cp++ = hex[*ep++ & 0xf];
482 }
483 *cp = '\0';
484 tp->e_name = strdup(buf);
485 return (tp->e_name);
486}
487
488const char *
489linkaddr_string(const u_char *ep, const unsigned int len)
490{
491 register u_int i, j;
492 register char *cp;
493 register struct enamemem *tp;
494
495 if (len == 6) /* XXX not totally correct... */
496 return etheraddr_string(ep);
487
497
488 tp = lookup_bytestring(ep, len);
489 if (tp->e_name)
490 return (tp->e_name);
491
492 tp->e_name = cp = (char *)malloc(len*3);
493 if (tp->e_name == NULL)
494 error("linkaddr_string: malloc");
495 if ((j = *ep >> 4) != 0)

--- 140 unchanged lines hidden (view full) ---

636 tp->addr = i;
637 tp->nxt = newhnamemem();
638
639 (void)snprintf(buf, sizeof(buf), "%u", i);
640 tp->name = strdup(buf);
641 return (tp->name);
642}
643
498 tp = lookup_bytestring(ep, len);
499 if (tp->e_name)
500 return (tp->e_name);
501
502 tp->e_name = cp = (char *)malloc(len*3);
503 if (tp->e_name == NULL)
504 error("linkaddr_string: malloc");
505 if ((j = *ep >> 4) != 0)

--- 140 unchanged lines hidden (view full) ---

646 tp->addr = i;
647 tp->nxt = newhnamemem();
648
649 (void)snprintf(buf, sizeof(buf), "%u", i);
650 tp->name = strdup(buf);
651 return (tp->name);
652}
653
654const char *
655ipxsap_string(u_short port)
656{
657 register char *cp;
658 register struct hnamemem *tp;
659 register u_int32_t i = port;
660 char buf[sizeof("0000")];
661
662 for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
663 if (tp->addr == i)
664 return (tp->name);
665
666 tp->addr = i;
667 tp->nxt = newhnamemem();
668
669 cp = buf;
670 NTOHS(port);
671 *cp++ = hex[port >> 12 & 0xf];
672 *cp++ = hex[port >> 8 & 0xf];
673 *cp++ = hex[port >> 4 & 0xf];
674 *cp++ = hex[port & 0xf];
675 *cp++ = '\0';
676 tp->name = strdup(buf);
677 return (tp->name);
678}
679
644static void
645init_servarray(void)
646{
647 struct servent *sv;
648 register struct hnamemem *table;
649 register int i;
650 char buf[sizeof("0000000000")];
651

--- 16 unchanged lines hidden (view full) ---

668 table->name = strdup(sv->s_name);
669 table->addr = port;
670 table->nxt = newhnamemem();
671 }
672 endservent();
673}
674
675/*XXX from libbpfc.a */
680static void
681init_servarray(void)
682{
683 struct servent *sv;
684 register struct hnamemem *table;
685 register int i;
686 char buf[sizeof("0000000000")];
687

--- 16 unchanged lines hidden (view full) ---

704 table->name = strdup(sv->s_name);
705 table->addr = port;
706 table->nxt = newhnamemem();
707 }
708 endservent();
709}
710
711/*XXX from libbpfc.a */
712#ifndef WIN32
676extern struct eproto {
713extern struct eproto {
714#else
715__declspec( dllimport) struct eproto {
716#endif
677 char *s;
678 u_short p;
679} eproto_db[];
680
681static void
682init_eprotoarray(void)
683{
684 register int i;
685 register struct hnamemem *table;
686
687 for (i = 0; eproto_db[i].s; i++) {
717 char *s;
718 u_short p;
719} eproto_db[];
720
721static void
722init_eprotoarray(void)
723{
724 register int i;
725 register struct hnamemem *table;
726
727 for (i = 0; eproto_db[i].s; i++) {
688 int j = ntohs(eproto_db[i].p) & (HASHNAMESIZE-1);
728 int j = htons(eproto_db[i].p) & (HASHNAMESIZE-1);
689 table = &eprototable[j];
690 while (table->name)
691 table = table->nxt;
692 table->name = eproto_db[i].s;
729 table = &eprototable[j];
730 while (table->name)
731 table = table->nxt;
732 table->name = eproto_db[i].s;
693 table->addr = ntohs(eproto_db[i].p);
733 table->addr = htons(eproto_db[i].p);
694 table->nxt = newhnamemem();
695 }
696}
697
698static struct protoidlist {
699 const u_char protoid[5];
700 const char *name;
701} protoidlist[] = {

--- 129 unchanged lines hidden (view full) ---

831 while (table->name)
832 table = table->nxt;
833 table->name = llcsap_db[i].s;
834 table->addr = llcsap_db[i].v;
835 table->nxt = newhnamemem();
836 }
837}
838
734 table->nxt = newhnamemem();
735 }
736}
737
738static struct protoidlist {
739 const u_char protoid[5];
740 const char *name;
741} protoidlist[] = {

--- 129 unchanged lines hidden (view full) ---

871 while (table->name)
872 table = table->nxt;
873 table->name = llcsap_db[i].s;
874 table->addr = llcsap_db[i].v;
875 table->nxt = newhnamemem();
876 }
877}
878
879static struct tok ipxsap_db[] = {
880 { 0x0000, "Unknown" },
881 { 0x0001, "User" },
882 { 0x0002, "User Group" },
883 { 0x0003, "PrintQueue" },
884 { 0x0004, "FileServer" },
885 { 0x0005, "JobServer" },
886 { 0x0006, "Gateway" },
887 { 0x0007, "PrintServer" },
888 { 0x0008, "ArchiveQueue" },
889 { 0x0009, "ArchiveServer" },
890 { 0x000a, "JobQueue" },
891 { 0x000b, "Administration" },
892 { 0x000F, "Novell TI-RPC" },
893 { 0x0017, "Diagnostics" },
894 { 0x0020, "NetBIOS" },
895 { 0x0021, "NAS SNA Gateway" },
896 { 0x0023, "NACS AsyncGateway" },
897 { 0x0024, "RemoteBridge/RoutingService" },
898 { 0x0026, "BridgeServer" },
899 { 0x0027, "TCP/IP Gateway" },
900 { 0x0028, "Point-to-point X.25 BridgeServer" },
901 { 0x0029, "3270 Gateway" },
902 { 0x002a, "CHI Corp" },
903 { 0x002c, "PC Chalkboard" },
904 { 0x002d, "TimeSynchServer" },
905 { 0x002e, "ARCserve5.0/PalindromeBackup" },
906 { 0x0045, "DI3270 Gateway" },
907 { 0x0047, "AdvertisingPrintServer" },
908 { 0x004a, "NetBlazerModems" },
909 { 0x004b, "BtrieveVAP" },
910 { 0x004c, "NetwareSQL" },
911 { 0x004d, "XtreeNetwork" },
912 { 0x0050, "BtrieveVAP4.11" },
913 { 0x0052, "QuickLink" },
914 { 0x0053, "PrintQueueUser" },
915 { 0x0058, "Multipoint X.25 Router" },
916 { 0x0060, "STLB/NLM" },
917 { 0x0064, "ARCserve" },
918 { 0x0066, "ARCserve3.0" },
919 { 0x0072, "WAN CopyUtility" },
920 { 0x007a, "TES-NetwareVMS" },
921 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" },
922 { 0x0095, "DDA OBGYN" },
923 { 0x0098, "NetwareAccessServer" },
924 { 0x009a, "Netware for VMS II/NamedPipeServer" },
925 { 0x009b, "NetwareAccessServer" },
926 { 0x009e, "PortableNetwareServer/SunLinkNVT" },
927 { 0x00a1, "PowerchuteAPC UPS" },
928 { 0x00aa, "LAWserve" },
929 { 0x00ac, "CompaqIDA StatusMonitor" },
930 { 0x0100, "PIPE STAIL" },
931 { 0x0102, "LAN ProtectBindery" },
932 { 0x0103, "OracleDataBaseServer" },
933 { 0x0107, "Netware386/RSPX RemoteConsole" },
934 { 0x010f, "NovellSNA Gateway" },
935 { 0x0111, "TestServer" },
936 { 0x0112, "HP PrintServer" },
937 { 0x0114, "CSA MUX" },
938 { 0x0115, "CSA LCA" },
939 { 0x0116, "CSA CM" },
940 { 0x0117, "CSA SMA" },
941 { 0x0118, "CSA DBA" },
942 { 0x0119, "CSA NMA" },
943 { 0x011a, "CSA SSA" },
944 { 0x011b, "CSA STATUS" },
945 { 0x011e, "CSA APPC" },
946 { 0x0126, "SNA TEST SSA Profile" },
947 { 0x012a, "CSA TRACE" },
948 { 0x012b, "NetwareSAA" },
949 { 0x012e, "IKARUS VirusScan" },
950 { 0x0130, "CommunicationsExecutive" },
951 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" },
952 { 0x0135, "NetwareNamingServicesProfile" },
953 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" },
954 { 0x0141, "LAN SpoolServer" },
955 { 0x0152, "IRMALAN Gateway" },
956 { 0x0154, "NamedPipeServer" },
957 { 0x0166, "NetWareManagement" },
958 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" },
959 { 0x0173, "Compaq" },
960 { 0x0174, "Compaq SNMP Agent" },
961 { 0x0175, "Compaq" },
962 { 0x0180, "XTreeServer/XTreeTools" },
963 { 0x018A, "NASI ServicesBroadcastServer" },
964 { 0x01b0, "GARP Gateway" },
965 { 0x01b1, "Binfview" },
966 { 0x01bf, "IntelLanDeskManager" },
967 { 0x01ca, "AXTEC" },
968 { 0x01cb, "ShivaNetModem/E" },
969 { 0x01cc, "ShivaLanRover/E" },
970 { 0x01cd, "ShivaLanRover/T" },
971 { 0x01ce, "ShivaUniversal" },
972 { 0x01d8, "CastelleFAXPressServer" },
973 { 0x01da, "CastelleLANPressPrintServer" },
974 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" },
975 { 0x01f0, "LEGATO" },
976 { 0x01f5, "LEGATO" },
977 { 0x0233, "NMS Agent/NetwareManagementAgent" },
978 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" },
979 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" },
980 { 0x023a, "LANtern" },
981 { 0x023c, "MAVERICK" },
982 { 0x023f, "NovellSMDR" },
983 { 0x024e, "NetwareConnect" },
984 { 0x024f, "NASI ServerBroadcast Cisco" },
985 { 0x026a, "NMS ServiceConsole" },
986 { 0x026b, "TimeSynchronizationServer Netware 4.x" },
987 { 0x0278, "DirectoryServer Netware 4.x" },
988 { 0x027b, "NetwareManagementAgent" },
989 { 0x0280, "Novell File and Printer Sharing Service for PC" },
990 { 0x0304, "NovellSAA Gateway" },
991 { 0x0308, "COM/VERMED" },
992 { 0x030a, "GalacticommWorldgroupServer" },
993 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" },
994 { 0x0320, "AttachmateGateway" },
995 { 0x0327, "MicrosoftDiagnostiocs" },
996 { 0x0328, "WATCOM SQL Server" },
997 { 0x0335, "MultiTechSystems MultisynchCommServer" },
998 { 0x0343, "Xylogics RemoteAccessServer/LANModem" },
999 { 0x0355, "ArcadaBackupExec" },
1000 { 0x0358, "MSLCD1" },
1001 { 0x0361, "NETINELO" },
1002 { 0x037e, "Powerchute UPS Monitoring" },
1003 { 0x037f, "ViruSafeNotify" },
1004 { 0x0386, "HP Bridge" },
1005 { 0x0387, "HP Hub" },
1006 { 0x0394, "NetWare SAA Gateway" },
1007 { 0x039b, "LotusNotes" },
1008 { 0x03b7, "CertusAntiVirus" },
1009 { 0x03c4, "ARCserve4.0" },
1010 { 0x03c7, "LANspool3.5" },
1011 { 0x03d7, "LexmarkPrinterServer" },
1012 { 0x03d8, "LexmarkXLE PrinterServer" },
1013 { 0x03dd, "BanyanENS NetwareClient" },
1014 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" },
1015 { 0x03e1, "UnivelUnixware" },
1016 { 0x03e4, "UnivelUnixware" },
1017 { 0x03fc, "IntelNetport" },
1018 { 0x03fd, "PrintServerQueue" },
1019 { 0x040A, "ipnServer" },
1020 { 0x040D, "LVERRMAN" },
1021 { 0x040E, "LVLIC" },
1022 { 0x0414, "NET Silicon (DPI)/Kyocera" },
1023 { 0x0429, "SiteLockVirus" },
1024 { 0x0432, "UFHELPR???" },
1025 { 0x0433, "Synoptics281xAdvancedSNMPAgent" },
1026 { 0x0444, "MicrosoftNT SNA Server" },
1027 { 0x0448, "Oracle" },
1028 { 0x044c, "ARCserve5.01" },
1029 { 0x0457, "CanonGP55" },
1030 { 0x045a, "QMS Printers" },
1031 { 0x045b, "DellSCSI Array" },
1032 { 0x0491, "NetBlazerModems" },
1033 { 0x04ac, "OnTimeScheduler" },
1034 { 0x04b0, "CD-Net" },
1035 { 0x0513, "EmulexNQA" },
1036 { 0x0520, "SiteLockChecks" },
1037 { 0x0529, "SiteLockChecks" },
1038 { 0x052d, "CitrixOS2 AppServer" },
1039 { 0x0535, "Tektronix" },
1040 { 0x0536, "Milan" },
1041 { 0x055d, "Attachmate SNA gateway" },
1042 { 0x056b, "IBM8235 ModemServer" },
1043 { 0x056c, "ShivaLanRover/E PLUS" },
1044 { 0x056d, "ShivaLanRover/T PLUS" },
1045 { 0x0580, "McAfeeNetShield" },
1046 { 0x05B8, "NLM to workstation communication (Revelation Software)" },
1047 { 0x05BA, "CompatibleSystemsRouters" },
1048 { 0x05BE, "CheyenneHierarchicalStorageManager" },
1049 { 0x0606, "JCWatermarkImaging" },
1050 { 0x060c, "AXISNetworkPrinter" },
1051 { 0x0610, "AdaptecSCSIManagement" },
1052 { 0x0621, "IBM AntiVirus" },
1053 { 0x0640, "Windows95 RemoteRegistryService" },
1054 { 0x064e, "MicrosoftIIS" },
1055 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1056 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1057 { 0x076C, "Xerox" },
1058 { 0x079b, "ShivaLanRover/E 115" },
1059 { 0x079c, "ShivaLanRover/T 115" },
1060 { 0x07B4, "CubixWorldDesk" },
1061 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" },
1062 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" },
1063 { 0x0810, "ELAN License Server Demo" },
1064 { 0x0824, "ShivaLanRoverAccessSwitch/E" },
1065 { 0x086a, "ISSC Collector" },
1066 { 0x087f, "ISSC DAS AgentAIX" },
1067 { 0x0880, "Intel Netport PRO" },
1068 { 0x0881, "Intel Netport PRO" },
1069 { 0x0b29, "SiteLock" },
1070 { 0x0c29, "SiteLockApplications" },
1071 { 0x0c2c, "LicensingServer" },
1072 { 0x2101, "PerformanceTechnologyInstantInternet" },
1073 { 0x2380, "LAI SiteLock" },
1074 { 0x238c, "MeetingMaker" },
1075 { 0x4808, "SiteLockServer/SiteLockMetering" },
1076 { 0x5555, "SiteLockUser" },
1077 { 0x6312, "Tapeware" },
1078 { 0x6f00, "RabbitGateway" },
1079 { 0x7703, "MODEM" },
1080 { 0x8002, "NetPortPrinters" },
1081 { 0x8008, "WordPerfectNetworkVersion" },
1082 { 0x85BE, "Cisco EIGRP" },
1083 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" },
1084 { 0x9000, "McAfeeNetShield" },
1085 { 0x9604, "CSA-NT_MON" },
1086 { 0xb6a8, "OceanIsleReachoutRemoteControl" },
1087 { 0xf11f, "SiteLockMetering" },
1088 { 0xf1ff, "SiteLock" },
1089 { 0xf503, "Microsoft SQL Server" },
1090 { 0xF905, "IBM TimeAndPlace" },
1091 { 0xfbfb, "TopCallIII FaxServer" },
1092 { 0xffff, "AnyService/Wildcard" },
1093 { 0, (char *)0 }
1094};
1095
1096static void
1097init_ipxsaparray(void)
1098{
1099 register int i;
1100 register struct hnamemem *table;
1101
1102 for (i = 0; ipxsap_db[i].s != NULL; i++) {
1103 int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1);
1104 table = &ipxsaptable[j];
1105 while (table->name)
1106 table = table->nxt;
1107 table->name = ipxsap_db[i].s;
1108 table->addr = htons(ipxsap_db[i].v);
1109 table->nxt = newhnamemem();
1110 }
1111}
1112
839/*
840 * Initialize the address to name translation machinery. We map all
841 * non-local IP addresses to numeric addresses if fflag is true (i.e.,
842 * to prevent blocking on the nameserver). localnet is the IP address
843 * of the local network. mask is its subnet mask.
844 */
845void
846init_addrtoname(u_int32_t localnet, u_int32_t mask)
847{
1113/*
1114 * Initialize the address to name translation machinery. We map all
1115 * non-local IP addresses to numeric addresses if fflag is true (i.e.,
1116 * to prevent blocking on the nameserver). localnet is the IP address
1117 * of the local network. mask is its subnet mask.
1118 */
1119void
1120init_addrtoname(u_int32_t localnet, u_int32_t mask)
1121{
848 netmask = mask;
849 if (fflag) {
850 f_localnet = localnet;
851 f_netmask = mask;
852 }
853 if (nflag)
854 /*
855 * Simplest way to suppress names.
856 */
857 return;
858
859 init_etherarray();
860 init_servarray();
861 init_eprotoarray();
862 init_llcsaparray();
863 init_protoidarray();
1122 if (fflag) {
1123 f_localnet = localnet;
1124 f_netmask = mask;
1125 }
1126 if (nflag)
1127 /*
1128 * Simplest way to suppress names.
1129 */
1130 return;
1131
1132 init_etherarray();
1133 init_servarray();
1134 init_eprotoarray();
1135 init_llcsaparray();
1136 init_protoidarray();
1137 init_ipxsaparray();
864}
865
866const char *
867dnaddr_string(u_short dnaddr)
868{
869 register struct hnamemem *tp;
870
871 for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != 0;

--- 53 unchanged lines hidden ---
1138}
1139
1140const char *
1141dnaddr_string(u_short dnaddr)
1142{
1143 register struct hnamemem *tp;
1144
1145 for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != 0;

--- 53 unchanged lines hidden ---