]>
The Tcpdump Group git mirrors - tcpdump/blob - addrtoname.c
ad2f6e285380dfd0378f575b84f72e9200d4d7cd
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
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
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
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.
21 * Internet, ethernet, port, and protocol string to address
22 * and address to string conversion routines
25 static const char rcsid
[] _U_
=
26 "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.7 2005-09-29 07:46:45 hannes Exp $ (LBL)";
33 #include <tcpdump-stdinc.h>
35 #ifdef USE_ETHER_NTOHOST
36 #ifdef HAVE_NETINET_IF_ETHER_H
37 struct mbuf
; /* Squelch compiler warnings on some platforms for */
38 struct rtentry
; /* declarations in <net/if.h> */
39 #include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
40 #include <netinet/if_ether.h>
41 #endif /* HAVE_NETINET_IF_ETHER_H */
42 #ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
43 #include <netinet/ether.h>
44 #endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
46 #if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
47 #ifndef HAVE_STRUCT_ETHER_ADDR
49 unsigned char ether_addr_octet
[6];
52 extern int ether_ntohost(char *, const struct ether_addr
*);
55 #endif /* USE_ETHER_NTOHOST */
58 #include <pcap-namedb.h>
64 #include "interface.h"
65 #include "addrtoname.h"
67 #include "setsignal.h"
72 * hash tables for whatever-to-name translations
74 * XXX there has to be error checks against strdup(3) failure
77 #define HASHNAMESIZE 4096
86 struct hnamemem hnametable
[HASHNAMESIZE
];
87 struct hnamemem tporttable
[HASHNAMESIZE
];
88 struct hnamemem uporttable
[HASHNAMESIZE
];
89 struct hnamemem eprototable
[HASHNAMESIZE
];
90 struct hnamemem dnaddrtable
[HASHNAMESIZE
];
91 struct hnamemem ipxsaptable
[HASHNAMESIZE
];
93 #if defined(INET6) && defined(WIN32)
95 * fake gethostbyaddr for Win2k/XP
96 * gethostbyaddr() returns incorrect value when AF_INET6 is passed
99 * h_name in struct hostent is only valid.
101 static struct hostent
*
102 win32_gethostbyaddr(const char *addr
, int len
, int type
)
104 static struct hostent host
;
105 static char hostbuf
[NI_MAXHOST
];
106 char hname
[NI_MAXHOST
];
107 struct sockaddr_in6 addr6
;
109 host
.h_name
= hostbuf
;
112 return gethostbyaddr(addr
, len
, type
);
115 memset(&addr6
, 0, sizeof(addr6
));
116 addr6
.sin6_family
= AF_INET6
;
117 memcpy(&addr6
.sin6_addr
, addr
, len
);
118 if (getnameinfo((struct sockaddr
*)&addr6
, sizeof(addr6
),
119 hname
, sizeof(hname
), NULL
, 0, 0)) {
122 strcpy(host
.h_name
, hname
);
130 #define gethostbyaddr win32_gethostbyaddr
131 #endif /* INET6 & WIN32 */
135 struct in6_addr addr
;
137 struct h6namemem
*nxt
;
140 struct h6namemem h6nametable
[HASHNAMESIZE
];
148 u_char
*e_nsap
; /* used only for nsaptable[] */
149 #define e_bs e_nsap /* for bytestringtable */
150 struct enamemem
*e_nxt
;
153 struct enamemem enametable
[HASHNAMESIZE
];
154 struct enamemem nsaptable
[HASHNAMESIZE
];
155 struct enamemem bytestringtable
[HASHNAMESIZE
];
161 struct protoidmem
*p_nxt
;
164 struct protoidmem protoidtable
[HASHNAMESIZE
];
167 * A faster replacement for inet_ntoa().
170 intoa(u_int32_t addr
)
175 static char buf
[sizeof(".xxx.xxx.xxx.xxx")];
178 cp
= buf
+ sizeof(buf
);
184 *--cp
= byte
% 10 + '0';
187 *--cp
= byte
% 10 + '0';
199 static u_int32_t f_netmask
;
200 static u_int32_t f_localnet
;
203 * Return a name for the IP address pointed to by ap. This address
204 * is assumed to be in network byte order.
206 * NOTE: ap is *NOT* necessarily part of the packet data (not even if
207 * this is being called with the "ipaddr_string()" macro), so you
208 * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
209 * even in cases where it *is* part of the packet data, the caller
210 * would still have to check for a null return value, even if it's
211 * just printing the return value with "%s" - not all versions of
212 * printf print "(null)" with "%s" and a null pointer, some of them
213 * don't check for a null pointer and crash in that case.
215 * The callers of this routine should, before handing this routine
216 * a pointer to packet data, be sure that the data is present in
217 * the packet buffer. They should probably do those checks anyway,
218 * as other data at that layer might not be IP addresses, and it
219 * also needs to check whether they're present in the packet buffer.
222 getname(const u_char
*ap
)
224 register struct hostent
*hp
;
226 static struct hnamemem
*p
; /* static for longjmp() */
228 memcpy(&addr
, ap
, sizeof(addr
));
229 p
= &hnametable
[addr
& (HASHNAMESIZE
-1)];
230 for (; p
->nxt
; p
= p
->nxt
) {
235 p
->nxt
= newhnamemem();
238 * Print names unless:
240 * (2) Address is foreign and -f was given. (If -f was not
241 * given, f_netmask and f_localnet are 0 and the test
245 (addr
& f_netmask
) == f_localnet
) {
246 hp
= gethostbyaddr((char *)&addr
, 4, AF_INET
);
250 p
->name
= strdup(hp
->h_name
);
252 /* Remove domain qualifications */
253 dotp
= strchr(p
->name
, '.');
260 p
->name
= strdup(intoa(addr
));
266 * Return a name for the IP6 address pointed to by ap. This address
267 * is assumed to be in network byte order.
270 getname6(const u_char
*ap
)
272 register struct hostent
*hp
;
273 struct in6_addr addr
;
274 static struct h6namemem
*p
; /* static for longjmp() */
275 register const char *cp
;
276 char ntop_buf
[INET6_ADDRSTRLEN
];
278 memcpy(&addr
, ap
, sizeof(addr
));
279 p
= &h6nametable
[*(u_int16_t
*)&addr
.s6_addr
[14] & (HASHNAMESIZE
-1)];
280 for (; p
->nxt
; p
= p
->nxt
) {
281 if (memcmp(&p
->addr
, &addr
, sizeof(addr
)) == 0)
285 p
->nxt
= newh6namemem();
288 * Do not print names if -n was given.
291 hp
= gethostbyaddr((char *)&addr
, sizeof(addr
), AF_INET6
);
295 p
->name
= strdup(hp
->h_name
);
297 /* Remove domain qualifications */
298 dotp
= strchr(p
->name
, '.');
305 cp
= inet_ntop(AF_INET6
, &addr
, ntop_buf
, sizeof(ntop_buf
));
306 p
->name
= strdup(cp
);
311 static char hex
[] = "0123456789abcdef";
314 /* Find the hash node that corresponds the ether address 'ep' */
316 static inline struct enamemem
*
317 lookup_emem(const u_char
*ep
)
319 register u_int i
, j
, k
;
322 k
= (ep
[0] << 8) | ep
[1];
323 j
= (ep
[2] << 8) | ep
[3];
324 i
= (ep
[4] << 8) | ep
[5];
326 tp
= &enametable
[(i
^ j
) & (HASHNAMESIZE
-1)];
328 if (tp
->e_addr0
== i
&&
337 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
338 if (tp
->e_nxt
== NULL
)
339 error("lookup_emem: calloc");
345 * Find the hash node that corresponds to the bytestring 'bs'
349 static inline struct enamemem
*
350 lookup_bytestring(register const u_char
*bs
, const unsigned int nlen
)
353 register u_int i
, j
, k
;
356 k
= (bs
[0] << 8) | bs
[1];
357 j
= (bs
[2] << 8) | bs
[3];
358 i
= (bs
[4] << 8) | bs
[5];
359 } else if (nlen
>= 4) {
360 k
= (bs
[0] << 8) | bs
[1];
361 j
= (bs
[2] << 8) | bs
[3];
366 tp
= &bytestringtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
368 if (tp
->e_addr0
== i
&&
371 memcmp((const char *)bs
, (const char *)(tp
->e_bs
), nlen
) == 0)
380 tp
->e_bs
= (u_char
*) calloc(1, nlen
+ 1);
381 memcpy(tp
->e_bs
, bs
, nlen
);
382 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
383 if (tp
->e_nxt
== NULL
)
384 error("lookup_bytestring: calloc");
389 /* Find the hash node that corresponds the NSAP 'nsap' */
391 static inline struct enamemem
*
392 lookup_nsap(register const u_char
*nsap
)
394 register u_int i
, j
, k
;
395 unsigned int nlen
= *nsap
;
397 const u_char
*ensap
= nsap
+ nlen
- 6;
400 k
= (ensap
[0] << 8) | ensap
[1];
401 j
= (ensap
[2] << 8) | ensap
[3];
402 i
= (ensap
[4] << 8) | ensap
[5];
407 tp
= &nsaptable
[(i
^ j
) & (HASHNAMESIZE
-1)];
409 if (tp
->e_addr0
== i
&&
412 tp
->e_nsap
[0] == nlen
&&
413 memcmp((const char *)&(nsap
[1]),
414 (char *)&(tp
->e_nsap
[1]), nlen
) == 0)
421 tp
->e_nsap
= (u_char
*)malloc(nlen
+ 1);
422 if (tp
->e_nsap
== NULL
)
423 error("lookup_nsap: malloc");
424 memcpy((char *)tp
->e_nsap
, (const char *)nsap
, nlen
+ 1);
425 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
426 if (tp
->e_nxt
== NULL
)
427 error("lookup_nsap: calloc");
432 /* Find the hash node that corresponds the protoid 'pi'. */
434 static inline struct protoidmem
*
435 lookup_protoid(const u_char
*pi
)
438 struct protoidmem
*tp
;
440 /* 5 octets won't be aligned */
441 i
= (((pi
[0] << 8) + pi
[1]) << 8) + pi
[2];
442 j
= (pi
[3] << 8) + pi
[4];
443 /* XXX should be endian-insensitive, but do big-endian testing XXX */
445 tp
= &protoidtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
447 if (tp
->p_oui
== i
&& tp
->p_proto
== j
)
453 tp
->p_nxt
= (struct protoidmem
*)calloc(1, sizeof(*tp
));
454 if (tp
->p_nxt
== NULL
)
455 error("lookup_protoid: calloc");
461 etheraddr_string(register const u_char
*ep
)
465 register struct enamemem
*tp
;
469 tp
= lookup_emem(ep
);
472 #ifdef USE_ETHER_NTOHOST
477 * We don't cast it to "const struct ether_addr *"
478 * because some systems fail to declare the second
479 * argument as a "const" pointer, even though they
480 * don't modify what it points to.
482 if (ether_ntohost(buf2
, (struct ether_addr
*)ep
) == 0) {
483 tp
->e_name
= strdup(buf2
);
489 oui
= EXTRACT_24BITS(ep
);
490 *cp
++ = hex
[*ep
>> 4 ];
491 *cp
++ = hex
[*ep
++ & 0xf];
492 for (i
= 5; --i
>= 0;) {
494 *cp
++ = hex
[*ep
>> 4 ];
495 *cp
++ = hex
[*ep
++ & 0xf];
499 snprintf(cp
, BUFSIZE
- (2 + 5*3), " (oui %s)",
500 tok2str(oui_values
, "Unknown", oui
));
503 tp
->e_name
= strdup(buf
);
508 linkaddr_string(const u_char
*ep
, const unsigned int len
)
512 register struct enamemem
*tp
;
514 if (len
== 6) /* XXX not totally correct... */
515 return etheraddr_string(ep
);
517 tp
= lookup_bytestring(ep
, len
);
521 tp
->e_name
= cp
= (char *)malloc(len
*3);
522 if (tp
->e_name
== NULL
)
523 error("linkaddr_string: malloc");
524 *cp
++ = hex
[*ep
>> 4];
525 *cp
++ = hex
[*ep
++ & 0xf];
526 for (i
= len
-1; i
> 0 ; --i
) {
528 *cp
++ = hex
[*ep
>> 4];
529 *cp
++ = hex
[*ep
++ & 0xf];
536 etherproto_string(u_short port
)
539 register struct hnamemem
*tp
;
540 register u_int32_t i
= port
;
541 char buf
[sizeof("0000")];
543 for (tp
= &eprototable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
548 tp
->nxt
= newhnamemem();
552 *cp
++ = hex
[port
>> 12 & 0xf];
553 *cp
++ = hex
[port
>> 8 & 0xf];
554 *cp
++ = hex
[port
>> 4 & 0xf];
555 *cp
++ = hex
[port
& 0xf];
557 tp
->name
= strdup(buf
);
562 protoid_string(register const u_char
*pi
)
566 register struct protoidmem
*tp
;
567 char buf
[sizeof("00:00:00:00:00")];
569 tp
= lookup_protoid(pi
);
574 if ((j
= *pi
>> 4) != 0)
576 *cp
++ = hex
[*pi
++ & 0xf];
577 for (i
= 4; (int)--i
>= 0;) {
579 if ((j
= *pi
>> 4) != 0)
581 *cp
++ = hex
[*pi
++ & 0xf];
584 tp
->p_name
= strdup(buf
);
588 #define ISONSAP_MAX_LENGTH 20
590 isonsap_string(const u_char
*nsap
, register u_int nsap_length
)
592 register u_int nsap_idx
;
594 register struct enamemem
*tp
;
596 if (nsap_length
< 1 || nsap_length
> ISONSAP_MAX_LENGTH
)
597 return ("isonsap_string: illegal length");
599 tp
= lookup_nsap(nsap
);
603 tp
->e_name
= cp
= (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
605 error("isonsap_string: malloc");
607 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
608 *cp
++ = hex
[*nsap
>> 4];
609 *cp
++ = hex
[*nsap
++ & 0xf];
610 if (((nsap_idx
& 1) == 0) &&
611 (nsap_idx
+ 1 < nsap_length
)) {
620 tcpport_string(u_short port
)
622 register struct hnamemem
*tp
;
623 register u_int32_t i
= port
;
624 char buf
[sizeof("00000")];
626 for (tp
= &tporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
631 tp
->nxt
= newhnamemem();
633 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
634 tp
->name
= strdup(buf
);
639 udpport_string(register u_short port
)
641 register struct hnamemem
*tp
;
642 register u_int32_t i
= port
;
643 char buf
[sizeof("00000")];
645 for (tp
= &uporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
650 tp
->nxt
= newhnamemem();
652 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
653 tp
->name
= strdup(buf
);
658 ipxsap_string(u_short port
)
661 register struct hnamemem
*tp
;
662 register u_int32_t i
= port
;
663 char buf
[sizeof("0000")];
665 for (tp
= &ipxsaptable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
670 tp
->nxt
= newhnamemem();
674 *cp
++ = hex
[port
>> 12 & 0xf];
675 *cp
++ = hex
[port
>> 8 & 0xf];
676 *cp
++ = hex
[port
>> 4 & 0xf];
677 *cp
++ = hex
[port
& 0xf];
679 tp
->name
= strdup(buf
);
687 register struct hnamemem
*table
;
689 char buf
[sizeof("0000000000")];
691 while ((sv
= getservent()) != NULL
) {
692 int port
= ntohs(sv
->s_port
);
693 i
= port
& (HASHNAMESIZE
-1);
694 if (strcmp(sv
->s_proto
, "tcp") == 0)
695 table
= &tporttable
[i
];
696 else if (strcmp(sv
->s_proto
, "udp") == 0)
697 table
= &uporttable
[i
];
704 (void)snprintf(buf
, sizeof(buf
), "%d", port
);
705 table
->name
= strdup(buf
);
707 table
->name
= strdup(sv
->s_name
);
709 table
->nxt
= newhnamemem();
714 /* in libpcap.a (nametoaddr.c) */
715 #if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
716 __declspec(dllimport
)
720 const struct eproto
{
726 init_eprotoarray(void)
729 register struct hnamemem
*table
;
731 for (i
= 0; eproto_db
[i
].s
; i
++) {
732 int j
= htons(eproto_db
[i
].p
) & (HASHNAMESIZE
-1);
733 table
= &eprototable
[j
];
736 table
->name
= eproto_db
[i
].s
;
737 table
->addr
= htons(eproto_db
[i
].p
);
738 table
->nxt
= newhnamemem();
742 static struct protoidlist
{
743 const u_char protoid
[5];
746 {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
747 {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
748 {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" },
749 {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" },
750 {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" },
751 {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
755 * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet
759 init_protoidarray(void)
762 register struct protoidmem
*tp
;
763 struct protoidlist
*pl
;
769 for (i
= 0; eproto_db
[i
].s
; i
++) {
770 u_short etype
= htons(eproto_db
[i
].p
);
772 memcpy((char *)&protoid
[3], (char *)&etype
, 2);
773 tp
= lookup_protoid(protoid
);
774 tp
->p_name
= strdup(eproto_db
[i
].s
);
776 /* Hardwire some SNAP proto ID names */
777 for (pl
= protoidlist
; pl
->name
!= NULL
; ++pl
) {
778 tp
= lookup_protoid(pl
->protoid
);
779 /* Don't override existing name */
780 if (tp
->p_name
!= NULL
)
783 tp
->p_name
= pl
->name
;
787 static struct etherlist
{
788 const u_char addr
[6];
791 {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
792 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
796 * Initialize the ethers hash table. We take two different approaches
797 * depending on whether or not the system provides the ethers name
798 * service. If it does, we just wire in a few names at startup,
799 * and etheraddr_string() fills in the table on demand. If it doesn't,
800 * then we suck in the entire /etc/ethers file at startup. The idea
801 * is that parsing the local file will be fast, but spinning through
802 * all the ethers entries via NIS & next_etherent might be very slow.
804 * XXX pcap_next_etherent doesn't belong in the pcap interface, but
805 * since the pcap module already does name-to-address translation,
806 * it's already does most of the work for the ethernet address-to-name
807 * translation, so we just pcap_next_etherent as a convenience.
810 init_etherarray(void)
812 register struct etherlist
*el
;
813 register struct enamemem
*tp
;
814 #ifdef USE_ETHER_NTOHOST
817 register struct pcap_etherent
*ep
;
820 /* Suck in entire ethers file */
821 fp
= fopen(PCAP_ETHERS_FILE
, "r");
823 while ((ep
= pcap_next_etherent(fp
)) != NULL
) {
824 tp
= lookup_emem(ep
->addr
);
825 tp
->e_name
= strdup(ep
->name
);
831 /* Hardwire some ethernet names */
832 for (el
= etherlist
; el
->name
!= NULL
; ++el
) {
833 tp
= lookup_emem(el
->addr
);
834 /* Don't override existing name */
835 if (tp
->e_name
!= NULL
)
838 #ifdef USE_ETHER_NTOHOST
840 * Use YP/NIS version of name if available.
842 * We don't cast it to "const struct ether_addr *"
843 * because some systems don't modify the Ethernet
844 * address but fail to declare the second argument
845 * as a "const" pointer.
847 if (ether_ntohost(name
, (struct ether_addr
*)el
->addr
) == 0) {
848 tp
->e_name
= strdup(name
);
852 tp
->e_name
= el
->name
;
856 static struct tok ipxsap_db
[] = {
857 { 0x0000, "Unknown" },
859 { 0x0002, "User Group" },
860 { 0x0003, "PrintQueue" },
861 { 0x0004, "FileServer" },
862 { 0x0005, "JobServer" },
863 { 0x0006, "Gateway" },
864 { 0x0007, "PrintServer" },
865 { 0x0008, "ArchiveQueue" },
866 { 0x0009, "ArchiveServer" },
867 { 0x000a, "JobQueue" },
868 { 0x000b, "Administration" },
869 { 0x000F, "Novell TI-RPC" },
870 { 0x0017, "Diagnostics" },
871 { 0x0020, "NetBIOS" },
872 { 0x0021, "NAS SNA Gateway" },
873 { 0x0023, "NACS AsyncGateway" },
874 { 0x0024, "RemoteBridge/RoutingService" },
875 { 0x0026, "BridgeServer" },
876 { 0x0027, "TCP/IP Gateway" },
877 { 0x0028, "Point-to-point X.25 BridgeServer" },
878 { 0x0029, "3270 Gateway" },
879 { 0x002a, "CHI Corp" },
880 { 0x002c, "PC Chalkboard" },
881 { 0x002d, "TimeSynchServer" },
882 { 0x002e, "ARCserve5.0/PalindromeBackup" },
883 { 0x0045, "DI3270 Gateway" },
884 { 0x0047, "AdvertisingPrintServer" },
885 { 0x004a, "NetBlazerModems" },
886 { 0x004b, "BtrieveVAP" },
887 { 0x004c, "NetwareSQL" },
888 { 0x004d, "XtreeNetwork" },
889 { 0x0050, "BtrieveVAP4.11" },
890 { 0x0052, "QuickLink" },
891 { 0x0053, "PrintQueueUser" },
892 { 0x0058, "Multipoint X.25 Router" },
893 { 0x0060, "STLB/NLM" },
894 { 0x0064, "ARCserve" },
895 { 0x0066, "ARCserve3.0" },
896 { 0x0072, "WAN CopyUtility" },
897 { 0x007a, "TES-NetwareVMS" },
898 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" },
899 { 0x0095, "DDA OBGYN" },
900 { 0x0098, "NetwareAccessServer" },
901 { 0x009a, "Netware for VMS II/NamedPipeServer" },
902 { 0x009b, "NetwareAccessServer" },
903 { 0x009e, "PortableNetwareServer/SunLinkNVT" },
904 { 0x00a1, "PowerchuteAPC UPS" },
905 { 0x00aa, "LAWserve" },
906 { 0x00ac, "CompaqIDA StatusMonitor" },
907 { 0x0100, "PIPE STAIL" },
908 { 0x0102, "LAN ProtectBindery" },
909 { 0x0103, "OracleDataBaseServer" },
910 { 0x0107, "Netware386/RSPX RemoteConsole" },
911 { 0x010f, "NovellSNA Gateway" },
912 { 0x0111, "TestServer" },
913 { 0x0112, "HP PrintServer" },
914 { 0x0114, "CSA MUX" },
915 { 0x0115, "CSA LCA" },
916 { 0x0116, "CSA CM" },
917 { 0x0117, "CSA SMA" },
918 { 0x0118, "CSA DBA" },
919 { 0x0119, "CSA NMA" },
920 { 0x011a, "CSA SSA" },
921 { 0x011b, "CSA STATUS" },
922 { 0x011e, "CSA APPC" },
923 { 0x0126, "SNA TEST SSA Profile" },
924 { 0x012a, "CSA TRACE" },
925 { 0x012b, "NetwareSAA" },
926 { 0x012e, "IKARUS VirusScan" },
927 { 0x0130, "CommunicationsExecutive" },
928 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" },
929 { 0x0135, "NetwareNamingServicesProfile" },
930 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" },
931 { 0x0141, "LAN SpoolServer" },
932 { 0x0152, "IRMALAN Gateway" },
933 { 0x0154, "NamedPipeServer" },
934 { 0x0166, "NetWareManagement" },
935 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" },
936 { 0x0173, "Compaq" },
937 { 0x0174, "Compaq SNMP Agent" },
938 { 0x0175, "Compaq" },
939 { 0x0180, "XTreeServer/XTreeTools" },
940 { 0x018A, "NASI ServicesBroadcastServer" },
941 { 0x01b0, "GARP Gateway" },
942 { 0x01b1, "Binfview" },
943 { 0x01bf, "IntelLanDeskManager" },
945 { 0x01cb, "ShivaNetModem/E" },
946 { 0x01cc, "ShivaLanRover/E" },
947 { 0x01cd, "ShivaLanRover/T" },
948 { 0x01ce, "ShivaUniversal" },
949 { 0x01d8, "CastelleFAXPressServer" },
950 { 0x01da, "CastelleLANPressPrintServer" },
951 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" },
952 { 0x01f0, "LEGATO" },
953 { 0x01f5, "LEGATO" },
954 { 0x0233, "NMS Agent/NetwareManagementAgent" },
955 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" },
956 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" },
957 { 0x023a, "LANtern" },
958 { 0x023c, "MAVERICK" },
959 { 0x023f, "NovellSMDR" },
960 { 0x024e, "NetwareConnect" },
961 { 0x024f, "NASI ServerBroadcast Cisco" },
962 { 0x026a, "NMS ServiceConsole" },
963 { 0x026b, "TimeSynchronizationServer Netware 4.x" },
964 { 0x0278, "DirectoryServer Netware 4.x" },
965 { 0x027b, "NetwareManagementAgent" },
966 { 0x0280, "Novell File and Printer Sharing Service for PC" },
967 { 0x0304, "NovellSAA Gateway" },
968 { 0x0308, "COM/VERMED" },
969 { 0x030a, "GalacticommWorldgroupServer" },
970 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" },
971 { 0x0320, "AttachmateGateway" },
972 { 0x0327, "MicrosoftDiagnostiocs" },
973 { 0x0328, "WATCOM SQL Server" },
974 { 0x0335, "MultiTechSystems MultisynchCommServer" },
975 { 0x0343, "Xylogics RemoteAccessServer/LANModem" },
976 { 0x0355, "ArcadaBackupExec" },
977 { 0x0358, "MSLCD1" },
978 { 0x0361, "NETINELO" },
979 { 0x037e, "Powerchute UPS Monitoring" },
980 { 0x037f, "ViruSafeNotify" },
981 { 0x0386, "HP Bridge" },
982 { 0x0387, "HP Hub" },
983 { 0x0394, "NetWare SAA Gateway" },
984 { 0x039b, "LotusNotes" },
985 { 0x03b7, "CertusAntiVirus" },
986 { 0x03c4, "ARCserve4.0" },
987 { 0x03c7, "LANspool3.5" },
988 { 0x03d7, "LexmarkPrinterServer" },
989 { 0x03d8, "LexmarkXLE PrinterServer" },
990 { 0x03dd, "BanyanENS NetwareClient" },
991 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" },
992 { 0x03e1, "UnivelUnixware" },
993 { 0x03e4, "UnivelUnixware" },
994 { 0x03fc, "IntelNetport" },
995 { 0x03fd, "PrintServerQueue" },
996 { 0x040A, "ipnServer" },
997 { 0x040D, "LVERRMAN" },
999 { 0x0414, "NET Silicon (DPI)/Kyocera" },
1000 { 0x0429, "SiteLockVirus" },
1001 { 0x0432, "UFHELPR???" },
1002 { 0x0433, "Synoptics281xAdvancedSNMPAgent" },
1003 { 0x0444, "MicrosoftNT SNA Server" },
1004 { 0x0448, "Oracle" },
1005 { 0x044c, "ARCserve5.01" },
1006 { 0x0457, "CanonGP55" },
1007 { 0x045a, "QMS Printers" },
1008 { 0x045b, "DellSCSI Array" },
1009 { 0x0491, "NetBlazerModems" },
1010 { 0x04ac, "OnTimeScheduler" },
1011 { 0x04b0, "CD-Net" },
1012 { 0x0513, "EmulexNQA" },
1013 { 0x0520, "SiteLockChecks" },
1014 { 0x0529, "SiteLockChecks" },
1015 { 0x052d, "CitrixOS2 AppServer" },
1016 { 0x0535, "Tektronix" },
1017 { 0x0536, "Milan" },
1018 { 0x055d, "Attachmate SNA gateway" },
1019 { 0x056b, "IBM8235 ModemServer" },
1020 { 0x056c, "ShivaLanRover/E PLUS" },
1021 { 0x056d, "ShivaLanRover/T PLUS" },
1022 { 0x0580, "McAfeeNetShield" },
1023 { 0x05B8, "NLM to workstation communication (Revelation Software)" },
1024 { 0x05BA, "CompatibleSystemsRouters" },
1025 { 0x05BE, "CheyenneHierarchicalStorageManager" },
1026 { 0x0606, "JCWatermarkImaging" },
1027 { 0x060c, "AXISNetworkPrinter" },
1028 { 0x0610, "AdaptecSCSIManagement" },
1029 { 0x0621, "IBM AntiVirus" },
1030 { 0x0640, "Windows95 RemoteRegistryService" },
1031 { 0x064e, "MicrosoftIIS" },
1032 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1033 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1034 { 0x076C, "Xerox" },
1035 { 0x079b, "ShivaLanRover/E 115" },
1036 { 0x079c, "ShivaLanRover/T 115" },
1037 { 0x07B4, "CubixWorldDesk" },
1038 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" },
1039 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" },
1040 { 0x0810, "ELAN License Server Demo" },
1041 { 0x0824, "ShivaLanRoverAccessSwitch/E" },
1042 { 0x086a, "ISSC Collector" },
1043 { 0x087f, "ISSC DAS AgentAIX" },
1044 { 0x0880, "Intel Netport PRO" },
1045 { 0x0881, "Intel Netport PRO" },
1046 { 0x0b29, "SiteLock" },
1047 { 0x0c29, "SiteLockApplications" },
1048 { 0x0c2c, "LicensingServer" },
1049 { 0x2101, "PerformanceTechnologyInstantInternet" },
1050 { 0x2380, "LAI SiteLock" },
1051 { 0x238c, "MeetingMaker" },
1052 { 0x4808, "SiteLockServer/SiteLockMetering" },
1053 { 0x5555, "SiteLockUser" },
1054 { 0x6312, "Tapeware" },
1055 { 0x6f00, "RabbitGateway" },
1056 { 0x7703, "MODEM" },
1057 { 0x8002, "NetPortPrinters" },
1058 { 0x8008, "WordPerfectNetworkVersion" },
1059 { 0x85BE, "Cisco EIGRP" },
1060 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" },
1061 { 0x9000, "McAfeeNetShield" },
1062 { 0x9604, "CSA-NT_MON" },
1063 { 0xb6a8, "OceanIsleReachoutRemoteControl" },
1064 { 0xf11f, "SiteLockMetering" },
1065 { 0xf1ff, "SiteLock" },
1066 { 0xf503, "Microsoft SQL Server" },
1067 { 0xF905, "IBM TimeAndPlace" },
1068 { 0xfbfb, "TopCallIII FaxServer" },
1069 { 0xffff, "AnyService/Wildcard" },
1074 init_ipxsaparray(void)
1077 register struct hnamemem
*table
;
1079 for (i
= 0; ipxsap_db
[i
].s
!= NULL
; i
++) {
1080 int j
= htons(ipxsap_db
[i
].v
) & (HASHNAMESIZE
-1);
1081 table
= &ipxsaptable
[j
];
1084 table
->name
= ipxsap_db
[i
].s
;
1085 table
->addr
= htons(ipxsap_db
[i
].v
);
1086 table
->nxt
= newhnamemem();
1091 * Initialize the address to name translation machinery. We map all
1092 * non-local IP addresses to numeric addresses if fflag is true (i.e.,
1093 * to prevent blocking on the nameserver). localnet is the IP address
1094 * of the local network. mask is its subnet mask.
1097 init_addrtoname(u_int32_t localnet
, u_int32_t mask
)
1100 f_localnet
= localnet
;
1105 * Simplest way to suppress names.
1112 init_protoidarray();
1117 dnaddr_string(u_short dnaddr
)
1119 register struct hnamemem
*tp
;
1121 for (tp
= &dnaddrtable
[dnaddr
& (HASHNAMESIZE
-1)]; tp
->nxt
!= 0;
1123 if (tp
->addr
== dnaddr
)
1127 tp
->nxt
= newhnamemem();
1129 tp
->name
= dnnum_string(dnaddr
);
1131 tp
->name
= dnname_string(dnaddr
);
1136 /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
1140 register struct hnamemem
*p
;
1141 static struct hnamemem
*ptr
= NULL
;
1142 static u_int num
= 0;
1146 ptr
= (struct hnamemem
*)calloc(num
, sizeof (*ptr
));
1148 error("newhnamemem: calloc");
1156 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
1160 register struct h6namemem
*p
;
1161 static struct h6namemem
*ptr
= NULL
;
1162 static u_int num
= 0;
1166 ptr
= (struct h6namemem
*)calloc(num
, sizeof (*ptr
));
1168 error("newh6namemem: calloc");