1 /* $NetBSD: addrtoname.c,v 1.8 2007/07/24 11:53:36 drochner Exp $ */
4 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * Internet, ethernet, port, and protocol string to address
24 * and address to string conversion routines
26 #include <sys/cdefs.h>
29 static const char rcsid
[] _U_
=
30 "@(#) Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.8 2006/02/27 07:27:16 hannes Exp (LBL)";
32 __RCSID("$NetBSD: addrtoname.c,v 1.8 2007/07/24 11:53:36 drochner Exp $");
40 #include <tcpdump-stdinc.h>
42 #ifdef USE_ETHER_NTOHOST
43 #ifdef HAVE_NETINET_IF_ETHER_H
44 struct mbuf
; /* Squelch compiler warnings on some platforms for */
45 struct rtentry
; /* declarations in <net/if.h> */
46 #include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
47 #include <netinet/if_ether.h>
48 #endif /* HAVE_NETINET_IF_ETHER_H */
49 #ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
50 #include <netinet/ether.h>
51 #endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
53 #if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
54 #ifndef HAVE_STRUCT_ETHER_ADDR
56 unsigned char ether_addr_octet
[6];
59 extern int ether_ntohost(char *, const struct ether_addr
*);
62 #endif /* USE_ETHER_NTOHOST */
65 #include <pcap-namedb.h>
71 #include "interface.h"
72 #include "addrtoname.h"
74 #include "setsignal.h"
78 #ifndef ETHER_ADDR_LEN
83 * hash tables for whatever-to-name translations
85 * XXX there has to be error checks against strdup(3) failure
88 #define HASHNAMESIZE 4096
97 struct hnamemem hnametable
[HASHNAMESIZE
];
98 struct hnamemem tporttable
[HASHNAMESIZE
];
99 struct hnamemem uporttable
[HASHNAMESIZE
];
100 struct hnamemem eprototable
[HASHNAMESIZE
];
101 struct hnamemem dnaddrtable
[HASHNAMESIZE
];
102 struct hnamemem ipxsaptable
[HASHNAMESIZE
];
104 #if defined(INET6) && defined(WIN32)
106 * fake gethostbyaddr for Win2k/XP
107 * gethostbyaddr() returns incorrect value when AF_INET6 is passed
110 * h_name in struct hostent is only valid.
112 static struct hostent
*
113 win32_gethostbyaddr(const char *addr
, int len
, int type
)
115 static struct hostent host
;
116 static char hostbuf
[NI_MAXHOST
];
117 char hname
[NI_MAXHOST
];
118 struct sockaddr_in6 addr6
;
120 host
.h_name
= hostbuf
;
123 return gethostbyaddr(addr
, len
, type
);
126 memset(&addr6
, 0, sizeof(addr6
));
127 addr6
.sin6_family
= AF_INET6
;
128 memcpy(&addr6
.sin6_addr
, addr
, len
);
129 if (getnameinfo((struct sockaddr
*)&addr6
, sizeof(addr6
),
130 hname
, sizeof(hname
), NULL
, 0, 0)) {
133 strcpy(host
.h_name
, hname
);
141 #define gethostbyaddr win32_gethostbyaddr
142 #endif /* INET6 & WIN32 */
146 struct in6_addr addr
;
148 struct h6namemem
*nxt
;
151 struct h6namemem h6nametable
[HASHNAMESIZE
];
159 u_char
*e_nsap
; /* used only for nsaptable[] */
160 #define e_bs e_nsap /* for bytestringtable */
161 struct enamemem
*e_nxt
;
164 struct enamemem enametable
[HASHNAMESIZE
];
165 struct enamemem nsaptable
[HASHNAMESIZE
];
166 struct enamemem bytestringtable
[HASHNAMESIZE
];
172 struct protoidmem
*p_nxt
;
175 struct protoidmem protoidtable
[HASHNAMESIZE
];
178 * A faster replacement for inet_ntoa().
181 intoa(u_int32_t addr
)
186 static char buf
[sizeof(".xxx.xxx.xxx.xxx")];
189 cp
= buf
+ sizeof(buf
);
195 *--cp
= byte
% 10 + '0';
198 *--cp
= byte
% 10 + '0';
210 static u_int32_t f_netmask
;
211 static u_int32_t f_localnet
;
214 * Return a name for the IP address pointed to by ap. This address
215 * is assumed to be in network byte order.
217 * NOTE: ap is *NOT* necessarily part of the packet data (not even if
218 * this is being called with the "ipaddr_string()" macro), so you
219 * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
220 * even in cases where it *is* part of the packet data, the caller
221 * would still have to check for a null return value, even if it's
222 * just printing the return value with "%s" - not all versions of
223 * printf print "(null)" with "%s" and a null pointer, some of them
224 * don't check for a null pointer and crash in that case.
226 * The callers of this routine should, before handing this routine
227 * a pointer to packet data, be sure that the data is present in
228 * the packet buffer. They should probably do those checks anyway,
229 * as other data at that layer might not be IP addresses, and it
230 * also needs to check whether they're present in the packet buffer.
233 getname(const u_char
*ap
)
235 register struct hostent
*hp
;
237 static struct hnamemem
*p
; /* static for longjmp() */
239 memcpy(&addr
, ap
, sizeof(addr
));
240 p
= &hnametable
[addr
& (HASHNAMESIZE
-1)];
241 for (; p
->nxt
; p
= p
->nxt
) {
246 p
->nxt
= newhnamemem();
249 * Print names unless:
251 * (2) Address is foreign and -f was given. (If -f was not
252 * given, f_netmask and f_localnet are 0 and the test
256 (addr
& f_netmask
) == f_localnet
) {
257 hp
= gethostbyaddr((char *)&addr
, 4, AF_INET
);
261 p
->name
= strdup(hp
->h_name
);
263 /* Remove domain qualifications */
264 dotp
= strchr(p
->name
, '.');
271 p
->name
= strdup(intoa(addr
));
277 * Return a name for the IP6 address pointed to by ap. This address
278 * is assumed to be in network byte order.
281 getname6(const u_char
*ap
)
283 register struct hostent
*hp
;
284 struct in6_addr addr
;
285 static struct h6namemem
*p
; /* static for longjmp() */
286 register const char *cp
;
287 char ntop_buf
[INET6_ADDRSTRLEN
];
289 memcpy(&addr
, ap
, sizeof(addr
));
290 p
= &h6nametable
[*(u_int16_t
*)&addr
.s6_addr
[14] & (HASHNAMESIZE
-1)];
291 for (; p
->nxt
; p
= p
->nxt
) {
292 if (memcmp(&p
->addr
, &addr
, sizeof(addr
)) == 0)
296 p
->nxt
= newh6namemem();
299 * Do not print names if -n was given.
302 hp
= gethostbyaddr((char *)&addr
, sizeof(addr
), AF_INET6
);
306 p
->name
= strdup(hp
->h_name
);
308 /* Remove domain qualifications */
309 dotp
= strchr(p
->name
, '.');
316 cp
= inet_ntop(AF_INET6
, &addr
, ntop_buf
, sizeof(ntop_buf
));
317 p
->name
= strdup(cp
);
322 static char hex
[] = "0123456789abcdef";
325 /* Find the hash node that corresponds the ether address 'ep' */
327 static inline struct enamemem
*
328 lookup_emem(const u_char
*ep
)
330 register u_int i
, j
, k
;
333 k
= (ep
[0] << 8) | ep
[1];
334 j
= (ep
[2] << 8) | ep
[3];
335 i
= (ep
[4] << 8) | ep
[5];
337 tp
= &enametable
[(i
^ j
) & (HASHNAMESIZE
-1)];
339 if (tp
->e_addr0
== i
&&
348 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
349 if (tp
->e_nxt
== NULL
)
350 error("lookup_emem: calloc");
356 * Find the hash node that corresponds to the bytestring 'bs'
360 static inline struct enamemem
*
361 lookup_bytestring(register const u_char
*bs
, const unsigned int nlen
)
364 register u_int i
, j
, k
;
367 k
= (bs
[0] << 8) | bs
[1];
368 j
= (bs
[2] << 8) | bs
[3];
369 i
= (bs
[4] << 8) | bs
[5];
370 } else if (nlen
>= 4) {
371 k
= (bs
[0] << 8) | bs
[1];
372 j
= (bs
[2] << 8) | bs
[3];
377 tp
= &bytestringtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
379 if (tp
->e_addr0
== i
&&
382 memcmp((const char *)bs
, (const char *)(tp
->e_bs
), nlen
) == 0)
391 tp
->e_bs
= (u_char
*) calloc(1, nlen
+ 1);
392 memcpy(tp
->e_bs
, bs
, nlen
);
393 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
394 if (tp
->e_nxt
== NULL
)
395 error("lookup_bytestring: calloc");
400 /* Find the hash node that corresponds the NSAP 'nsap' */
402 static inline struct enamemem
*
403 lookup_nsap(register const u_char
*nsap
)
405 register u_int i
, j
, k
;
406 unsigned int nlen
= *nsap
;
408 const u_char
*ensap
= nsap
+ nlen
- 6;
411 k
= (ensap
[0] << 8) | ensap
[1];
412 j
= (ensap
[2] << 8) | ensap
[3];
413 i
= (ensap
[4] << 8) | ensap
[5];
418 tp
= &nsaptable
[(i
^ j
) & (HASHNAMESIZE
-1)];
420 if (tp
->e_addr0
== i
&&
423 tp
->e_nsap
[0] == nlen
&&
424 memcmp((const char *)&(nsap
[1]),
425 (char *)&(tp
->e_nsap
[1]), nlen
) == 0)
432 tp
->e_nsap
= (u_char
*)malloc(nlen
+ 1);
433 if (tp
->e_nsap
== NULL
)
434 error("lookup_nsap: malloc");
435 memcpy((char *)tp
->e_nsap
, (const char *)nsap
, nlen
+ 1);
436 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
437 if (tp
->e_nxt
== NULL
)
438 error("lookup_nsap: calloc");
443 /* Find the hash node that corresponds the protoid 'pi'. */
445 static inline struct protoidmem
*
446 lookup_protoid(const u_char
*pi
)
449 struct protoidmem
*tp
;
451 /* 5 octets won't be aligned */
452 i
= (((pi
[0] << 8) + pi
[1]) << 8) + pi
[2];
453 j
= (pi
[3] << 8) + pi
[4];
454 /* XXX should be endian-insensitive, but do big-endian testing XXX */
456 tp
= &protoidtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
458 if (tp
->p_oui
== i
&& tp
->p_proto
== j
)
464 tp
->p_nxt
= (struct protoidmem
*)calloc(1, sizeof(*tp
));
465 if (tp
->p_nxt
== NULL
)
466 error("lookup_protoid: calloc");
472 etheraddr_string(register const u_char
*ep
)
476 register struct enamemem
*tp
;
480 tp
= lookup_emem(ep
);
483 #ifdef USE_ETHER_NTOHOST
488 * We don't cast it to "const struct ether_addr *"
489 * because some systems fail to declare the second
490 * argument as a "const" pointer, even though they
491 * don't modify what it points to.
493 if (ether_ntohost(buf2
, (struct ether_addr
*)ep
) == 0) {
494 tp
->e_name
= strdup(buf2
);
500 oui
= EXTRACT_24BITS(ep
);
501 *cp
++ = hex
[*ep
>> 4 ];
502 *cp
++ = hex
[*ep
++ & 0xf];
503 for (i
= 5; --i
>= 0;) {
505 *cp
++ = hex
[*ep
>> 4 ];
506 *cp
++ = hex
[*ep
++ & 0xf];
510 snprintf(cp
, BUFSIZE
- (2 + 5*3), " (oui %s)",
511 tok2str(oui_values
, "Unknown", oui
));
514 tp
->e_name
= strdup(buf
);
519 linkaddr_string(const u_char
*ep
, const unsigned int len
)
523 register struct enamemem
*tp
;
525 if (len
== 6) /* XXX not totally correct... */
526 return etheraddr_string(ep
);
528 tp
= lookup_bytestring(ep
, len
);
532 tp
->e_name
= cp
= (char *)malloc(len
*3);
533 if (tp
->e_name
== NULL
)
534 error("linkaddr_string: malloc");
535 *cp
++ = hex
[*ep
>> 4];
536 *cp
++ = hex
[*ep
++ & 0xf];
537 for (i
= len
-1; i
> 0 ; --i
) {
539 *cp
++ = hex
[*ep
>> 4];
540 *cp
++ = hex
[*ep
++ & 0xf];
547 etherproto_string(u_short port
)
550 register struct hnamemem
*tp
;
551 register u_int32_t i
= port
;
552 char buf
[sizeof("0000")];
554 for (tp
= &eprototable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
559 tp
->nxt
= newhnamemem();
563 *cp
++ = hex
[port
>> 12 & 0xf];
564 *cp
++ = hex
[port
>> 8 & 0xf];
565 *cp
++ = hex
[port
>> 4 & 0xf];
566 *cp
++ = hex
[port
& 0xf];
568 tp
->name
= strdup(buf
);
573 protoid_string(register const u_char
*pi
)
577 register struct protoidmem
*tp
;
578 char buf
[sizeof("00:00:00:00:00")];
580 tp
= lookup_protoid(pi
);
585 if ((j
= *pi
>> 4) != 0)
587 *cp
++ = hex
[*pi
++ & 0xf];
588 for (i
= 4; (int)--i
>= 0;) {
590 if ((j
= *pi
>> 4) != 0)
592 *cp
++ = hex
[*pi
++ & 0xf];
595 tp
->p_name
= strdup(buf
);
599 #define ISONSAP_MAX_LENGTH 20
601 isonsap_string(const u_char
*nsap
, register u_int nsap_length
)
603 register u_int nsap_idx
;
605 register struct enamemem
*tp
;
607 if (nsap_length
< 1 || nsap_length
> ISONSAP_MAX_LENGTH
)
608 return ("isonsap_string: illegal length");
610 tp
= lookup_nsap(nsap
);
614 tp
->e_name
= cp
= (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
616 error("isonsap_string: malloc");
618 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
619 *cp
++ = hex
[*nsap
>> 4];
620 *cp
++ = hex
[*nsap
++ & 0xf];
621 if (((nsap_idx
& 1) == 0) &&
622 (nsap_idx
+ 1 < nsap_length
)) {
631 tcpport_string(u_short port
)
633 register struct hnamemem
*tp
;
634 register u_int32_t i
= port
;
635 char buf
[sizeof("00000")];
637 for (tp
= &tporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
642 tp
->nxt
= newhnamemem();
644 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
645 tp
->name
= strdup(buf
);
650 udpport_string(register u_short port
)
652 register struct hnamemem
*tp
;
653 register u_int32_t i
= port
;
654 char buf
[sizeof("00000")];
656 for (tp
= &uporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
661 tp
->nxt
= newhnamemem();
663 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
664 tp
->name
= strdup(buf
);
669 ipxsap_string(u_short port
)
672 register struct hnamemem
*tp
;
673 register u_int32_t i
= port
;
674 char buf
[sizeof("0000")];
676 for (tp
= &ipxsaptable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
681 tp
->nxt
= newhnamemem();
685 *cp
++ = hex
[port
>> 12 & 0xf];
686 *cp
++ = hex
[port
>> 8 & 0xf];
687 *cp
++ = hex
[port
>> 4 & 0xf];
688 *cp
++ = hex
[port
& 0xf];
690 tp
->name
= strdup(buf
);
698 register struct hnamemem
*table
;
700 char buf
[sizeof("0000000000")];
702 while ((sv
= getservent()) != NULL
) {
703 int port
= ntohs(sv
->s_port
);
704 i
= port
& (HASHNAMESIZE
-1);
705 if (strcmp(sv
->s_proto
, "tcp") == 0)
706 table
= &tporttable
[i
];
707 else if (strcmp(sv
->s_proto
, "udp") == 0)
708 table
= &uporttable
[i
];
715 (void)snprintf(buf
, sizeof(buf
), "%d", port
);
716 table
->name
= strdup(buf
);
718 table
->name
= strdup(sv
->s_name
);
720 table
->nxt
= newhnamemem();
725 /* in libpcap.a (nametoaddr.c) */
726 #if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
727 __declspec(dllimport
)
731 const struct eproto
{
737 init_eprotoarray(void)
740 register struct hnamemem
*table
;
742 for (i
= 0; eproto_db
[i
].s
; i
++) {
743 int j
= htons(eproto_db
[i
].p
) & (HASHNAMESIZE
-1);
744 table
= &eprototable
[j
];
747 table
->name
= eproto_db
[i
].s
;
748 table
->addr
= htons(eproto_db
[i
].p
);
749 table
->nxt
= newhnamemem();
753 static struct protoidlist
{
754 const u_char protoid
[5];
757 {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
758 {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
759 {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" },
760 {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" },
761 {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" },
762 {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
766 * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet
770 init_protoidarray(void)
773 register struct protoidmem
*tp
;
774 struct protoidlist
*pl
;
780 for (i
= 0; eproto_db
[i
].s
; i
++) {
781 u_short etype
= htons(eproto_db
[i
].p
);
783 memcpy((char *)&protoid
[3], (char *)&etype
, 2);
784 tp
= lookup_protoid(protoid
);
785 tp
->p_name
= strdup(eproto_db
[i
].s
);
787 /* Hardwire some SNAP proto ID names */
788 for (pl
= protoidlist
; pl
->name
!= NULL
; ++pl
) {
789 tp
= lookup_protoid(pl
->protoid
);
790 /* Don't override existing name */
791 if (tp
->p_name
!= NULL
)
794 tp
->p_name
= pl
->name
;
798 static struct etherlist
{
799 const u_char addr
[6];
802 {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
803 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
807 * Initialize the ethers hash table. We take two different approaches
808 * depending on whether or not the system provides the ethers name
809 * service. If it does, we just wire in a few names at startup,
810 * and etheraddr_string() fills in the table on demand. If it doesn't,
811 * then we suck in the entire /etc/ethers file at startup. The idea
812 * is that parsing the local file will be fast, but spinning through
813 * all the ethers entries via NIS & next_etherent might be very slow.
815 * XXX pcap_next_etherent doesn't belong in the pcap interface, but
816 * since the pcap module already does name-to-address translation,
817 * it's already does most of the work for the ethernet address-to-name
818 * translation, so we just pcap_next_etherent as a convenience.
821 init_etherarray(void)
823 register struct etherlist
*el
;
824 register struct enamemem
*tp
;
825 #ifdef USE_ETHER_NTOHOST
828 register struct pcap_etherent
*ep
;
831 /* Suck in entire ethers file */
832 fp
= fopen(PCAP_ETHERS_FILE
, "r");
834 while ((ep
= pcap_next_etherent(fp
)) != NULL
) {
835 tp
= lookup_emem(ep
->addr
);
836 tp
->e_name
= strdup(ep
->name
);
842 /* Hardwire some ethernet names */
843 for (el
= etherlist
; el
->name
!= NULL
; ++el
) {
844 tp
= lookup_emem(el
->addr
);
845 /* Don't override existing name */
846 if (tp
->e_name
!= NULL
)
849 #ifdef USE_ETHER_NTOHOST
851 * Use YP/NIS version of name if available.
853 * We don't cast it to "const struct ether_addr *"
854 * because some systems don't modify the Ethernet
855 * address but fail to declare the second argument
856 * as a "const" pointer.
858 if (ether_ntohost(name
, (struct ether_addr
*)el
->addr
) == 0) {
859 tp
->e_name
= strdup(name
);
863 tp
->e_name
= el
->name
;
867 static struct tok ipxsap_db
[] = {
868 { 0x0000, "Unknown" },
870 { 0x0002, "User Group" },
871 { 0x0003, "PrintQueue" },
872 { 0x0004, "FileServer" },
873 { 0x0005, "JobServer" },
874 { 0x0006, "Gateway" },
875 { 0x0007, "PrintServer" },
876 { 0x0008, "ArchiveQueue" },
877 { 0x0009, "ArchiveServer" },
878 { 0x000a, "JobQueue" },
879 { 0x000b, "Administration" },
880 { 0x000F, "Novell TI-RPC" },
881 { 0x0017, "Diagnostics" },
882 { 0x0020, "NetBIOS" },
883 { 0x0021, "NAS SNA Gateway" },
884 { 0x0023, "NACS AsyncGateway" },
885 { 0x0024, "RemoteBridge/RoutingService" },
886 { 0x0026, "BridgeServer" },
887 { 0x0027, "TCP/IP Gateway" },
888 { 0x0028, "Point-to-point X.25 BridgeServer" },
889 { 0x0029, "3270 Gateway" },
890 { 0x002a, "CHI Corp" },
891 { 0x002c, "PC Chalkboard" },
892 { 0x002d, "TimeSynchServer" },
893 { 0x002e, "ARCserve5.0/PalindromeBackup" },
894 { 0x0045, "DI3270 Gateway" },
895 { 0x0047, "AdvertisingPrintServer" },
896 { 0x004a, "NetBlazerModems" },
897 { 0x004b, "BtrieveVAP" },
898 { 0x004c, "NetwareSQL" },
899 { 0x004d, "XtreeNetwork" },
900 { 0x0050, "BtrieveVAP4.11" },
901 { 0x0052, "QuickLink" },
902 { 0x0053, "PrintQueueUser" },
903 { 0x0058, "Multipoint X.25 Router" },
904 { 0x0060, "STLB/NLM" },
905 { 0x0064, "ARCserve" },
906 { 0x0066, "ARCserve3.0" },
907 { 0x0072, "WAN CopyUtility" },
908 { 0x007a, "TES-NetwareVMS" },
909 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" },
910 { 0x0095, "DDA OBGYN" },
911 { 0x0098, "NetwareAccessServer" },
912 { 0x009a, "Netware for VMS II/NamedPipeServer" },
913 { 0x009b, "NetwareAccessServer" },
914 { 0x009e, "PortableNetwareServer/SunLinkNVT" },
915 { 0x00a1, "PowerchuteAPC UPS" },
916 { 0x00aa, "LAWserve" },
917 { 0x00ac, "CompaqIDA StatusMonitor" },
918 { 0x0100, "PIPE STAIL" },
919 { 0x0102, "LAN ProtectBindery" },
920 { 0x0103, "OracleDataBaseServer" },
921 { 0x0107, "Netware386/RSPX RemoteConsole" },
922 { 0x010f, "NovellSNA Gateway" },
923 { 0x0111, "TestServer" },
924 { 0x0112, "HP PrintServer" },
925 { 0x0114, "CSA MUX" },
926 { 0x0115, "CSA LCA" },
927 { 0x0116, "CSA CM" },
928 { 0x0117, "CSA SMA" },
929 { 0x0118, "CSA DBA" },
930 { 0x0119, "CSA NMA" },
931 { 0x011a, "CSA SSA" },
932 { 0x011b, "CSA STATUS" },
933 { 0x011e, "CSA APPC" },
934 { 0x0126, "SNA TEST SSA Profile" },
935 { 0x012a, "CSA TRACE" },
936 { 0x012b, "NetwareSAA" },
937 { 0x012e, "IKARUS VirusScan" },
938 { 0x0130, "CommunicationsExecutive" },
939 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" },
940 { 0x0135, "NetwareNamingServicesProfile" },
941 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" },
942 { 0x0141, "LAN SpoolServer" },
943 { 0x0152, "IRMALAN Gateway" },
944 { 0x0154, "NamedPipeServer" },
945 { 0x0166, "NetWareManagement" },
946 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" },
947 { 0x0173, "Compaq" },
948 { 0x0174, "Compaq SNMP Agent" },
949 { 0x0175, "Compaq" },
950 { 0x0180, "XTreeServer/XTreeTools" },
951 { 0x018A, "NASI ServicesBroadcastServer" },
952 { 0x01b0, "GARP Gateway" },
953 { 0x01b1, "Binfview" },
954 { 0x01bf, "IntelLanDeskManager" },
956 { 0x01cb, "ShivaNetModem/E" },
957 { 0x01cc, "ShivaLanRover/E" },
958 { 0x01cd, "ShivaLanRover/T" },
959 { 0x01ce, "ShivaUniversal" },
960 { 0x01d8, "CastelleFAXPressServer" },
961 { 0x01da, "CastelleLANPressPrintServer" },
962 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" },
963 { 0x01f0, "LEGATO" },
964 { 0x01f5, "LEGATO" },
965 { 0x0233, "NMS Agent/NetwareManagementAgent" },
966 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" },
967 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" },
968 { 0x023a, "LANtern" },
969 { 0x023c, "MAVERICK" },
970 { 0x023f, "NovellSMDR" },
971 { 0x024e, "NetwareConnect" },
972 { 0x024f, "NASI ServerBroadcast Cisco" },
973 { 0x026a, "NMS ServiceConsole" },
974 { 0x026b, "TimeSynchronizationServer Netware 4.x" },
975 { 0x0278, "DirectoryServer Netware 4.x" },
976 { 0x027b, "NetwareManagementAgent" },
977 { 0x0280, "Novell File and Printer Sharing Service for PC" },
978 { 0x0304, "NovellSAA Gateway" },
979 { 0x0308, "COM/VERMED" },
980 { 0x030a, "GalacticommWorldgroupServer" },
981 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" },
982 { 0x0320, "AttachmateGateway" },
983 { 0x0327, "MicrosoftDiagnostiocs" },
984 { 0x0328, "WATCOM SQL Server" },
985 { 0x0335, "MultiTechSystems MultisynchCommServer" },
986 { 0x0343, "Xylogics RemoteAccessServer/LANModem" },
987 { 0x0355, "ArcadaBackupExec" },
988 { 0x0358, "MSLCD1" },
989 { 0x0361, "NETINELO" },
990 { 0x037e, "Powerchute UPS Monitoring" },
991 { 0x037f, "ViruSafeNotify" },
992 { 0x0386, "HP Bridge" },
993 { 0x0387, "HP Hub" },
994 { 0x0394, "NetWare SAA Gateway" },
995 { 0x039b, "LotusNotes" },
996 { 0x03b7, "CertusAntiVirus" },
997 { 0x03c4, "ARCserve4.0" },
998 { 0x03c7, "LANspool3.5" },
999 { 0x03d7, "LexmarkPrinterServer" },
1000 { 0x03d8, "LexmarkXLE PrinterServer" },
1001 { 0x03dd, "BanyanENS NetwareClient" },
1002 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" },
1003 { 0x03e1, "UnivelUnixware" },
1004 { 0x03e4, "UnivelUnixware" },
1005 { 0x03fc, "IntelNetport" },
1006 { 0x03fd, "PrintServerQueue" },
1007 { 0x040A, "ipnServer" },
1008 { 0x040D, "LVERRMAN" },
1009 { 0x040E, "LVLIC" },
1010 { 0x0414, "NET Silicon (DPI)/Kyocera" },
1011 { 0x0429, "SiteLockVirus" },
1012 { 0x0432, "UFHELPR???" },
1013 { 0x0433, "Synoptics281xAdvancedSNMPAgent" },
1014 { 0x0444, "MicrosoftNT SNA Server" },
1015 { 0x0448, "Oracle" },
1016 { 0x044c, "ARCserve5.01" },
1017 { 0x0457, "CanonGP55" },
1018 { 0x045a, "QMS Printers" },
1019 { 0x045b, "DellSCSI Array" },
1020 { 0x0491, "NetBlazerModems" },
1021 { 0x04ac, "OnTimeScheduler" },
1022 { 0x04b0, "CD-Net" },
1023 { 0x0513, "EmulexNQA" },
1024 { 0x0520, "SiteLockChecks" },
1025 { 0x0529, "SiteLockChecks" },
1026 { 0x052d, "CitrixOS2 AppServer" },
1027 { 0x0535, "Tektronix" },
1028 { 0x0536, "Milan" },
1029 { 0x055d, "Attachmate SNA gateway" },
1030 { 0x056b, "IBM8235 ModemServer" },
1031 { 0x056c, "ShivaLanRover/E PLUS" },
1032 { 0x056d, "ShivaLanRover/T PLUS" },
1033 { 0x0580, "McAfeeNetShield" },
1034 { 0x05B8, "NLM to workstation communication (Revelation Software)" },
1035 { 0x05BA, "CompatibleSystemsRouters" },
1036 { 0x05BE, "CheyenneHierarchicalStorageManager" },
1037 { 0x0606, "JCWatermarkImaging" },
1038 { 0x060c, "AXISNetworkPrinter" },
1039 { 0x0610, "AdaptecSCSIManagement" },
1040 { 0x0621, "IBM AntiVirus" },
1041 { 0x0640, "Windows95 RemoteRegistryService" },
1042 { 0x064e, "MicrosoftIIS" },
1043 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1044 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1045 { 0x076C, "Xerox" },
1046 { 0x079b, "ShivaLanRover/E 115" },
1047 { 0x079c, "ShivaLanRover/T 115" },
1048 { 0x07B4, "CubixWorldDesk" },
1049 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" },
1050 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" },
1051 { 0x0810, "ELAN License Server Demo" },
1052 { 0x0824, "ShivaLanRoverAccessSwitch/E" },
1053 { 0x086a, "ISSC Collector" },
1054 { 0x087f, "ISSC DAS AgentAIX" },
1055 { 0x0880, "Intel Netport PRO" },
1056 { 0x0881, "Intel Netport PRO" },
1057 { 0x0b29, "SiteLock" },
1058 { 0x0c29, "SiteLockApplications" },
1059 { 0x0c2c, "LicensingServer" },
1060 { 0x2101, "PerformanceTechnologyInstantInternet" },
1061 { 0x2380, "LAI SiteLock" },
1062 { 0x238c, "MeetingMaker" },
1063 { 0x4808, "SiteLockServer/SiteLockMetering" },
1064 { 0x5555, "SiteLockUser" },
1065 { 0x6312, "Tapeware" },
1066 { 0x6f00, "RabbitGateway" },
1067 { 0x7703, "MODEM" },
1068 { 0x8002, "NetPortPrinters" },
1069 { 0x8008, "WordPerfectNetworkVersion" },
1070 { 0x85BE, "Cisco EIGRP" },
1071 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" },
1072 { 0x9000, "McAfeeNetShield" },
1073 { 0x9604, "CSA-NT_MON" },
1074 { 0xb6a8, "OceanIsleReachoutRemoteControl" },
1075 { 0xf11f, "SiteLockMetering" },
1076 { 0xf1ff, "SiteLock" },
1077 { 0xf503, "Microsoft SQL Server" },
1078 { 0xF905, "IBM TimeAndPlace" },
1079 { 0xfbfb, "TopCallIII FaxServer" },
1080 { 0xffff, "AnyService/Wildcard" },
1085 init_ipxsaparray(void)
1088 register struct hnamemem
*table
;
1090 for (i
= 0; ipxsap_db
[i
].s
!= NULL
; i
++) {
1091 int j
= htons(ipxsap_db
[i
].v
) & (HASHNAMESIZE
-1);
1092 table
= &ipxsaptable
[j
];
1095 table
->name
= ipxsap_db
[i
].s
;
1096 table
->addr
= htons(ipxsap_db
[i
].v
);
1097 table
->nxt
= newhnamemem();
1102 * Initialize the address to name translation machinery. We map all
1103 * non-local IP addresses to numeric addresses if fflag is true (i.e.,
1104 * to prevent blocking on the nameserver). localnet is the IP address
1105 * of the local network. mask is its subnet mask.
1108 init_addrtoname(u_int32_t localnet
, u_int32_t mask
)
1111 f_localnet
= localnet
;
1116 * Simplest way to suppress names.
1123 init_protoidarray();
1128 dnaddr_string(u_short dnaddr
)
1130 register struct hnamemem
*tp
;
1132 for (tp
= &dnaddrtable
[dnaddr
& (HASHNAMESIZE
-1)]; tp
->nxt
!= 0;
1134 if (tp
->addr
== dnaddr
)
1138 tp
->nxt
= newhnamemem();
1140 tp
->name
= dnnum_string(dnaddr
);
1142 tp
->name
= dnname_string(dnaddr
);
1147 /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
1151 register struct hnamemem
*p
;
1152 static struct hnamemem
*ptr
= NULL
;
1153 static u_int num
= 0;
1157 ptr
= (struct hnamemem
*)calloc(num
, sizeof (*ptr
));
1159 error("newhnamemem: calloc");
1167 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
1171 register struct h6namemem
*p
;
1172 static struct h6namemem
*ptr
= NULL
;
1173 static u_int num
= 0;
1177 ptr
= (struct h6namemem
*)calloc(num
, sizeof (*ptr
));
1179 error("newh6namemem: calloc");