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.9 2007/09/14 00:26:18 guy 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"
71 #ifndef ETHER_ADDR_LEN
72 #define ETHER_ADDR_LEN 6
76 * hash tables for whatever-to-name translations
78 * XXX there has to be error checks against strdup(3) failure
81 #define HASHNAMESIZE 4096
90 struct hnamemem hnametable
[HASHNAMESIZE
];
91 struct hnamemem tporttable
[HASHNAMESIZE
];
92 struct hnamemem uporttable
[HASHNAMESIZE
];
93 struct hnamemem eprototable
[HASHNAMESIZE
];
94 struct hnamemem dnaddrtable
[HASHNAMESIZE
];
95 struct hnamemem ipxsaptable
[HASHNAMESIZE
];
97 #if defined(INET6) && defined(WIN32)
99 * fake gethostbyaddr for Win2k/XP
100 * gethostbyaddr() returns incorrect value when AF_INET6 is passed
103 * h_name in struct hostent is only valid.
105 static struct hostent
*
106 win32_gethostbyaddr(const char *addr
, int len
, int type
)
108 static struct hostent host
;
109 static char hostbuf
[NI_MAXHOST
];
110 char hname
[NI_MAXHOST
];
111 struct sockaddr_in6 addr6
;
113 host
.h_name
= hostbuf
;
116 return gethostbyaddr(addr
, len
, type
);
119 memset(&addr6
, 0, sizeof(addr6
));
120 addr6
.sin6_family
= AF_INET6
;
121 memcpy(&addr6
.sin6_addr
, addr
, len
);
122 if (getnameinfo((struct sockaddr
*)&addr6
, sizeof(addr6
),
123 hname
, sizeof(hname
), NULL
, 0, 0)) {
126 strcpy(host
.h_name
, hname
);
134 #define gethostbyaddr win32_gethostbyaddr
135 #endif /* INET6 & WIN32 */
139 struct in6_addr addr
;
141 struct h6namemem
*nxt
;
144 struct h6namemem h6nametable
[HASHNAMESIZE
];
152 u_char
*e_nsap
; /* used only for nsaptable[] */
153 #define e_bs e_nsap /* for bytestringtable */
154 struct enamemem
*e_nxt
;
157 struct enamemem enametable
[HASHNAMESIZE
];
158 struct enamemem nsaptable
[HASHNAMESIZE
];
159 struct enamemem bytestringtable
[HASHNAMESIZE
];
165 struct protoidmem
*p_nxt
;
168 struct protoidmem protoidtable
[HASHNAMESIZE
];
171 * A faster replacement for inet_ntoa().
174 intoa(u_int32_t addr
)
179 static char buf
[sizeof(".xxx.xxx.xxx.xxx")];
182 cp
= buf
+ sizeof(buf
);
188 *--cp
= byte
% 10 + '0';
191 *--cp
= byte
% 10 + '0';
203 static u_int32_t f_netmask
;
204 static u_int32_t f_localnet
;
207 * Return a name for the IP address pointed to by ap. This address
208 * is assumed to be in network byte order.
210 * NOTE: ap is *NOT* necessarily part of the packet data (not even if
211 * this is being called with the "ipaddr_string()" macro), so you
212 * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
213 * even in cases where it *is* part of the packet data, the caller
214 * would still have to check for a null return value, even if it's
215 * just printing the return value with "%s" - not all versions of
216 * printf print "(null)" with "%s" and a null pointer, some of them
217 * don't check for a null pointer and crash in that case.
219 * The callers of this routine should, before handing this routine
220 * a pointer to packet data, be sure that the data is present in
221 * the packet buffer. They should probably do those checks anyway,
222 * as other data at that layer might not be IP addresses, and it
223 * also needs to check whether they're present in the packet buffer.
226 getname(const u_char
*ap
)
228 register struct hostent
*hp
;
230 static struct hnamemem
*p
; /* static for longjmp() */
232 memcpy(&addr
, ap
, sizeof(addr
));
233 p
= &hnametable
[addr
& (HASHNAMESIZE
-1)];
234 for (; p
->nxt
; p
= p
->nxt
) {
239 p
->nxt
= newhnamemem();
242 * Print names unless:
244 * (2) Address is foreign and -f was given. (If -f was not
245 * given, f_netmask and f_localnet are 0 and the test
249 (addr
& f_netmask
) == f_localnet
) {
250 hp
= gethostbyaddr((char *)&addr
, 4, AF_INET
);
254 p
->name
= strdup(hp
->h_name
);
256 /* Remove domain qualifications */
257 dotp
= strchr(p
->name
, '.');
264 p
->name
= strdup(intoa(addr
));
270 * Return a name for the IP6 address pointed to by ap. This address
271 * is assumed to be in network byte order.
274 getname6(const u_char
*ap
)
276 register struct hostent
*hp
;
277 struct in6_addr addr
;
278 static struct h6namemem
*p
; /* static for longjmp() */
279 register const char *cp
;
280 char ntop_buf
[INET6_ADDRSTRLEN
];
282 memcpy(&addr
, ap
, sizeof(addr
));
283 p
= &h6nametable
[*(u_int16_t
*)&addr
.s6_addr
[14] & (HASHNAMESIZE
-1)];
284 for (; p
->nxt
; p
= p
->nxt
) {
285 if (memcmp(&p
->addr
, &addr
, sizeof(addr
)) == 0)
289 p
->nxt
= newh6namemem();
292 * Do not print names if -n was given.
295 hp
= gethostbyaddr((char *)&addr
, sizeof(addr
), AF_INET6
);
299 p
->name
= strdup(hp
->h_name
);
301 /* Remove domain qualifications */
302 dotp
= strchr(p
->name
, '.');
309 cp
= inet_ntop(AF_INET6
, &addr
, ntop_buf
, sizeof(ntop_buf
));
310 p
->name
= strdup(cp
);
315 static char hex
[] = "0123456789abcdef";
318 /* Find the hash node that corresponds the ether address 'ep' */
320 static inline struct enamemem
*
321 lookup_emem(const u_char
*ep
)
323 register u_int i
, j
, k
;
326 k
= (ep
[0] << 8) | ep
[1];
327 j
= (ep
[2] << 8) | ep
[3];
328 i
= (ep
[4] << 8) | ep
[5];
330 tp
= &enametable
[(i
^ j
) & (HASHNAMESIZE
-1)];
332 if (tp
->e_addr0
== i
&&
341 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
342 if (tp
->e_nxt
== NULL
)
343 error("lookup_emem: calloc");
349 * Find the hash node that corresponds to the bytestring 'bs'
353 static inline struct enamemem
*
354 lookup_bytestring(register const u_char
*bs
, const unsigned int nlen
)
357 register u_int i
, j
, k
;
360 k
= (bs
[0] << 8) | bs
[1];
361 j
= (bs
[2] << 8) | bs
[3];
362 i
= (bs
[4] << 8) | bs
[5];
363 } else if (nlen
>= 4) {
364 k
= (bs
[0] << 8) | bs
[1];
365 j
= (bs
[2] << 8) | bs
[3];
370 tp
= &bytestringtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
372 if (tp
->e_addr0
== i
&&
375 memcmp((const char *)bs
, (const char *)(tp
->e_bs
), nlen
) == 0)
384 tp
->e_bs
= (u_char
*) calloc(1, nlen
+ 1);
385 memcpy(tp
->e_bs
, bs
, nlen
);
386 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
387 if (tp
->e_nxt
== NULL
)
388 error("lookup_bytestring: calloc");
393 /* Find the hash node that corresponds the NSAP 'nsap' */
395 static inline struct enamemem
*
396 lookup_nsap(register const u_char
*nsap
)
398 register u_int i
, j
, k
;
399 unsigned int nlen
= *nsap
;
401 const u_char
*ensap
= nsap
+ nlen
- 6;
404 k
= (ensap
[0] << 8) | ensap
[1];
405 j
= (ensap
[2] << 8) | ensap
[3];
406 i
= (ensap
[4] << 8) | ensap
[5];
411 tp
= &nsaptable
[(i
^ j
) & (HASHNAMESIZE
-1)];
413 if (tp
->e_addr0
== i
&&
416 tp
->e_nsap
[0] == nlen
&&
417 memcmp((const char *)&(nsap
[1]),
418 (char *)&(tp
->e_nsap
[1]), nlen
) == 0)
425 tp
->e_nsap
= (u_char
*)malloc(nlen
+ 1);
426 if (tp
->e_nsap
== NULL
)
427 error("lookup_nsap: malloc");
428 memcpy((char *)tp
->e_nsap
, (const char *)nsap
, nlen
+ 1);
429 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
430 if (tp
->e_nxt
== NULL
)
431 error("lookup_nsap: calloc");
436 /* Find the hash node that corresponds the protoid 'pi'. */
438 static inline struct protoidmem
*
439 lookup_protoid(const u_char
*pi
)
442 struct protoidmem
*tp
;
444 /* 5 octets won't be aligned */
445 i
= (((pi
[0] << 8) + pi
[1]) << 8) + pi
[2];
446 j
= (pi
[3] << 8) + pi
[4];
447 /* XXX should be endian-insensitive, but do big-endian testing XXX */
449 tp
= &protoidtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
451 if (tp
->p_oui
== i
&& tp
->p_proto
== j
)
457 tp
->p_nxt
= (struct protoidmem
*)calloc(1, sizeof(*tp
));
458 if (tp
->p_nxt
== NULL
)
459 error("lookup_protoid: calloc");
465 etheraddr_string(register const u_char
*ep
)
469 register struct enamemem
*tp
;
473 tp
= lookup_emem(ep
);
476 #ifdef USE_ETHER_NTOHOST
481 * We don't cast it to "const struct ether_addr *"
482 * because some systems fail to declare the second
483 * argument as a "const" pointer, even though they
484 * don't modify what it points to.
486 if (ether_ntohost(buf2
, (struct ether_addr
*)ep
) == 0) {
487 tp
->e_name
= strdup(buf2
);
493 oui
= EXTRACT_24BITS(ep
);
494 *cp
++ = hex
[*ep
>> 4 ];
495 *cp
++ = hex
[*ep
++ & 0xf];
496 for (i
= 5; --i
>= 0;) {
498 *cp
++ = hex
[*ep
>> 4 ];
499 *cp
++ = hex
[*ep
++ & 0xf];
503 snprintf(cp
, BUFSIZE
- (2 + 5*3), " (oui %s)",
504 tok2str(oui_values
, "Unknown", oui
));
507 tp
->e_name
= strdup(buf
);
512 linkaddr_string(const u_char
*ep
, const unsigned int len
)
516 register struct enamemem
*tp
;
518 if (len
== ETHER_ADDR_LEN
) /* XXX not totally correct... */
519 return etheraddr_string(ep
);
521 tp
= lookup_bytestring(ep
, len
);
525 tp
->e_name
= cp
= (char *)malloc(len
*3);
526 if (tp
->e_name
== NULL
)
527 error("linkaddr_string: malloc");
528 *cp
++ = hex
[*ep
>> 4];
529 *cp
++ = hex
[*ep
++ & 0xf];
530 for (i
= len
-1; i
> 0 ; --i
) {
532 *cp
++ = hex
[*ep
>> 4];
533 *cp
++ = hex
[*ep
++ & 0xf];
540 etherproto_string(u_short port
)
543 register struct hnamemem
*tp
;
544 register u_int32_t i
= port
;
545 char buf
[sizeof("0000")];
547 for (tp
= &eprototable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
552 tp
->nxt
= newhnamemem();
556 *cp
++ = hex
[port
>> 12 & 0xf];
557 *cp
++ = hex
[port
>> 8 & 0xf];
558 *cp
++ = hex
[port
>> 4 & 0xf];
559 *cp
++ = hex
[port
& 0xf];
561 tp
->name
= strdup(buf
);
566 protoid_string(register const u_char
*pi
)
570 register struct protoidmem
*tp
;
571 char buf
[sizeof("00:00:00:00:00")];
573 tp
= lookup_protoid(pi
);
578 if ((j
= *pi
>> 4) != 0)
580 *cp
++ = hex
[*pi
++ & 0xf];
581 for (i
= 4; (int)--i
>= 0;) {
583 if ((j
= *pi
>> 4) != 0)
585 *cp
++ = hex
[*pi
++ & 0xf];
588 tp
->p_name
= strdup(buf
);
592 #define ISONSAP_MAX_LENGTH 20
594 isonsap_string(const u_char
*nsap
, register u_int nsap_length
)
596 register u_int nsap_idx
;
598 register struct enamemem
*tp
;
600 if (nsap_length
< 1 || nsap_length
> ISONSAP_MAX_LENGTH
)
601 return ("isonsap_string: illegal length");
603 tp
= lookup_nsap(nsap
);
607 tp
->e_name
= cp
= (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
609 error("isonsap_string: malloc");
611 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
612 *cp
++ = hex
[*nsap
>> 4];
613 *cp
++ = hex
[*nsap
++ & 0xf];
614 if (((nsap_idx
& 1) == 0) &&
615 (nsap_idx
+ 1 < nsap_length
)) {
624 tcpport_string(u_short port
)
626 register struct hnamemem
*tp
;
627 register u_int32_t i
= port
;
628 char buf
[sizeof("00000")];
630 for (tp
= &tporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
635 tp
->nxt
= newhnamemem();
637 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
638 tp
->name
= strdup(buf
);
643 udpport_string(register u_short port
)
645 register struct hnamemem
*tp
;
646 register u_int32_t i
= port
;
647 char buf
[sizeof("00000")];
649 for (tp
= &uporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
654 tp
->nxt
= newhnamemem();
656 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
657 tp
->name
= strdup(buf
);
662 ipxsap_string(u_short port
)
665 register struct hnamemem
*tp
;
666 register u_int32_t i
= port
;
667 char buf
[sizeof("0000")];
669 for (tp
= &ipxsaptable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
674 tp
->nxt
= newhnamemem();
678 *cp
++ = hex
[port
>> 12 & 0xf];
679 *cp
++ = hex
[port
>> 8 & 0xf];
680 *cp
++ = hex
[port
>> 4 & 0xf];
681 *cp
++ = hex
[port
& 0xf];
683 tp
->name
= strdup(buf
);
691 register struct hnamemem
*table
;
693 char buf
[sizeof("0000000000")];
695 while ((sv
= getservent()) != NULL
) {
696 int port
= ntohs(sv
->s_port
);
697 i
= port
& (HASHNAMESIZE
-1);
698 if (strcmp(sv
->s_proto
, "tcp") == 0)
699 table
= &tporttable
[i
];
700 else if (strcmp(sv
->s_proto
, "udp") == 0)
701 table
= &uporttable
[i
];
708 (void)snprintf(buf
, sizeof(buf
), "%d", port
);
709 table
->name
= strdup(buf
);
711 table
->name
= strdup(sv
->s_name
);
713 table
->nxt
= newhnamemem();
718 /* in libpcap.a (nametoaddr.c) */
719 #if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
720 __declspec(dllimport
)
724 const struct eproto
{
730 init_eprotoarray(void)
733 register struct hnamemem
*table
;
735 for (i
= 0; eproto_db
[i
].s
; i
++) {
736 int j
= htons(eproto_db
[i
].p
) & (HASHNAMESIZE
-1);
737 table
= &eprototable
[j
];
740 table
->name
= eproto_db
[i
].s
;
741 table
->addr
= htons(eproto_db
[i
].p
);
742 table
->nxt
= newhnamemem();
746 static struct protoidlist
{
747 const u_char protoid
[5];
750 {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
751 {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
752 {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" },
753 {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" },
754 {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" },
755 {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
759 * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet
763 init_protoidarray(void)
766 register struct protoidmem
*tp
;
767 struct protoidlist
*pl
;
773 for (i
= 0; eproto_db
[i
].s
; i
++) {
774 u_short etype
= htons(eproto_db
[i
].p
);
776 memcpy((char *)&protoid
[3], (char *)&etype
, 2);
777 tp
= lookup_protoid(protoid
);
778 tp
->p_name
= strdup(eproto_db
[i
].s
);
780 /* Hardwire some SNAP proto ID names */
781 for (pl
= protoidlist
; pl
->name
!= NULL
; ++pl
) {
782 tp
= lookup_protoid(pl
->protoid
);
783 /* Don't override existing name */
784 if (tp
->p_name
!= NULL
)
787 tp
->p_name
= pl
->name
;
791 static struct etherlist
{
792 const u_char addr
[6];
795 {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
796 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
800 * Initialize the ethers hash table. We take two different approaches
801 * depending on whether or not the system provides the ethers name
802 * service. If it does, we just wire in a few names at startup,
803 * and etheraddr_string() fills in the table on demand. If it doesn't,
804 * then we suck in the entire /etc/ethers file at startup. The idea
805 * is that parsing the local file will be fast, but spinning through
806 * all the ethers entries via NIS & next_etherent might be very slow.
808 * XXX pcap_next_etherent doesn't belong in the pcap interface, but
809 * since the pcap module already does name-to-address translation,
810 * it's already does most of the work for the ethernet address-to-name
811 * translation, so we just pcap_next_etherent as a convenience.
814 init_etherarray(void)
816 register struct etherlist
*el
;
817 register struct enamemem
*tp
;
818 #ifdef USE_ETHER_NTOHOST
821 register struct pcap_etherent
*ep
;
824 /* Suck in entire ethers file */
825 fp
= fopen(PCAP_ETHERS_FILE
, "r");
827 while ((ep
= pcap_next_etherent(fp
)) != NULL
) {
828 tp
= lookup_emem(ep
->addr
);
829 tp
->e_name
= strdup(ep
->name
);
835 /* Hardwire some ethernet names */
836 for (el
= etherlist
; el
->name
!= NULL
; ++el
) {
837 tp
= lookup_emem(el
->addr
);
838 /* Don't override existing name */
839 if (tp
->e_name
!= NULL
)
842 #ifdef USE_ETHER_NTOHOST
844 * Use YP/NIS version of name if available.
846 * We don't cast it to "const struct ether_addr *"
847 * because some systems don't modify the Ethernet
848 * address but fail to declare the second argument
849 * as a "const" pointer.
851 if (ether_ntohost(name
, (struct ether_addr
*)el
->addr
) == 0) {
852 tp
->e_name
= strdup(name
);
856 tp
->e_name
= el
->name
;
860 static struct tok ipxsap_db
[] = {
861 { 0x0000, "Unknown" },
863 { 0x0002, "User Group" },
864 { 0x0003, "PrintQueue" },
865 { 0x0004, "FileServer" },
866 { 0x0005, "JobServer" },
867 { 0x0006, "Gateway" },
868 { 0x0007, "PrintServer" },
869 { 0x0008, "ArchiveQueue" },
870 { 0x0009, "ArchiveServer" },
871 { 0x000a, "JobQueue" },
872 { 0x000b, "Administration" },
873 { 0x000F, "Novell TI-RPC" },
874 { 0x0017, "Diagnostics" },
875 { 0x0020, "NetBIOS" },
876 { 0x0021, "NAS SNA Gateway" },
877 { 0x0023, "NACS AsyncGateway" },
878 { 0x0024, "RemoteBridge/RoutingService" },
879 { 0x0026, "BridgeServer" },
880 { 0x0027, "TCP/IP Gateway" },
881 { 0x0028, "Point-to-point X.25 BridgeServer" },
882 { 0x0029, "3270 Gateway" },
883 { 0x002a, "CHI Corp" },
884 { 0x002c, "PC Chalkboard" },
885 { 0x002d, "TimeSynchServer" },
886 { 0x002e, "ARCserve5.0/PalindromeBackup" },
887 { 0x0045, "DI3270 Gateway" },
888 { 0x0047, "AdvertisingPrintServer" },
889 { 0x004a, "NetBlazerModems" },
890 { 0x004b, "BtrieveVAP" },
891 { 0x004c, "NetwareSQL" },
892 { 0x004d, "XtreeNetwork" },
893 { 0x0050, "BtrieveVAP4.11" },
894 { 0x0052, "QuickLink" },
895 { 0x0053, "PrintQueueUser" },
896 { 0x0058, "Multipoint X.25 Router" },
897 { 0x0060, "STLB/NLM" },
898 { 0x0064, "ARCserve" },
899 { 0x0066, "ARCserve3.0" },
900 { 0x0072, "WAN CopyUtility" },
901 { 0x007a, "TES-NetwareVMS" },
902 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" },
903 { 0x0095, "DDA OBGYN" },
904 { 0x0098, "NetwareAccessServer" },
905 { 0x009a, "Netware for VMS II/NamedPipeServer" },
906 { 0x009b, "NetwareAccessServer" },
907 { 0x009e, "PortableNetwareServer/SunLinkNVT" },
908 { 0x00a1, "PowerchuteAPC UPS" },
909 { 0x00aa, "LAWserve" },
910 { 0x00ac, "CompaqIDA StatusMonitor" },
911 { 0x0100, "PIPE STAIL" },
912 { 0x0102, "LAN ProtectBindery" },
913 { 0x0103, "OracleDataBaseServer" },
914 { 0x0107, "Netware386/RSPX RemoteConsole" },
915 { 0x010f, "NovellSNA Gateway" },
916 { 0x0111, "TestServer" },
917 { 0x0112, "HP PrintServer" },
918 { 0x0114, "CSA MUX" },
919 { 0x0115, "CSA LCA" },
920 { 0x0116, "CSA CM" },
921 { 0x0117, "CSA SMA" },
922 { 0x0118, "CSA DBA" },
923 { 0x0119, "CSA NMA" },
924 { 0x011a, "CSA SSA" },
925 { 0x011b, "CSA STATUS" },
926 { 0x011e, "CSA APPC" },
927 { 0x0126, "SNA TEST SSA Profile" },
928 { 0x012a, "CSA TRACE" },
929 { 0x012b, "NetwareSAA" },
930 { 0x012e, "IKARUS VirusScan" },
931 { 0x0130, "CommunicationsExecutive" },
932 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" },
933 { 0x0135, "NetwareNamingServicesProfile" },
934 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" },
935 { 0x0141, "LAN SpoolServer" },
936 { 0x0152, "IRMALAN Gateway" },
937 { 0x0154, "NamedPipeServer" },
938 { 0x0166, "NetWareManagement" },
939 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" },
940 { 0x0173, "Compaq" },
941 { 0x0174, "Compaq SNMP Agent" },
942 { 0x0175, "Compaq" },
943 { 0x0180, "XTreeServer/XTreeTools" },
944 { 0x018A, "NASI ServicesBroadcastServer" },
945 { 0x01b0, "GARP Gateway" },
946 { 0x01b1, "Binfview" },
947 { 0x01bf, "IntelLanDeskManager" },
949 { 0x01cb, "ShivaNetModem/E" },
950 { 0x01cc, "ShivaLanRover/E" },
951 { 0x01cd, "ShivaLanRover/T" },
952 { 0x01ce, "ShivaUniversal" },
953 { 0x01d8, "CastelleFAXPressServer" },
954 { 0x01da, "CastelleLANPressPrintServer" },
955 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" },
956 { 0x01f0, "LEGATO" },
957 { 0x01f5, "LEGATO" },
958 { 0x0233, "NMS Agent/NetwareManagementAgent" },
959 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" },
960 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" },
961 { 0x023a, "LANtern" },
962 { 0x023c, "MAVERICK" },
963 { 0x023f, "NovellSMDR" },
964 { 0x024e, "NetwareConnect" },
965 { 0x024f, "NASI ServerBroadcast Cisco" },
966 { 0x026a, "NMS ServiceConsole" },
967 { 0x026b, "TimeSynchronizationServer Netware 4.x" },
968 { 0x0278, "DirectoryServer Netware 4.x" },
969 { 0x027b, "NetwareManagementAgent" },
970 { 0x0280, "Novell File and Printer Sharing Service for PC" },
971 { 0x0304, "NovellSAA Gateway" },
972 { 0x0308, "COM/VERMED" },
973 { 0x030a, "GalacticommWorldgroupServer" },
974 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" },
975 { 0x0320, "AttachmateGateway" },
976 { 0x0327, "MicrosoftDiagnostiocs" },
977 { 0x0328, "WATCOM SQL Server" },
978 { 0x0335, "MultiTechSystems MultisynchCommServer" },
979 { 0x0343, "Xylogics RemoteAccessServer/LANModem" },
980 { 0x0355, "ArcadaBackupExec" },
981 { 0x0358, "MSLCD1" },
982 { 0x0361, "NETINELO" },
983 { 0x037e, "Powerchute UPS Monitoring" },
984 { 0x037f, "ViruSafeNotify" },
985 { 0x0386, "HP Bridge" },
986 { 0x0387, "HP Hub" },
987 { 0x0394, "NetWare SAA Gateway" },
988 { 0x039b, "LotusNotes" },
989 { 0x03b7, "CertusAntiVirus" },
990 { 0x03c4, "ARCserve4.0" },
991 { 0x03c7, "LANspool3.5" },
992 { 0x03d7, "LexmarkPrinterServer" },
993 { 0x03d8, "LexmarkXLE PrinterServer" },
994 { 0x03dd, "BanyanENS NetwareClient" },
995 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" },
996 { 0x03e1, "UnivelUnixware" },
997 { 0x03e4, "UnivelUnixware" },
998 { 0x03fc, "IntelNetport" },
999 { 0x03fd, "PrintServerQueue" },
1000 { 0x040A, "ipnServer" },
1001 { 0x040D, "LVERRMAN" },
1002 { 0x040E, "LVLIC" },
1003 { 0x0414, "NET Silicon (DPI)/Kyocera" },
1004 { 0x0429, "SiteLockVirus" },
1005 { 0x0432, "UFHELPR???" },
1006 { 0x0433, "Synoptics281xAdvancedSNMPAgent" },
1007 { 0x0444, "MicrosoftNT SNA Server" },
1008 { 0x0448, "Oracle" },
1009 { 0x044c, "ARCserve5.01" },
1010 { 0x0457, "CanonGP55" },
1011 { 0x045a, "QMS Printers" },
1012 { 0x045b, "DellSCSI Array" },
1013 { 0x0491, "NetBlazerModems" },
1014 { 0x04ac, "OnTimeScheduler" },
1015 { 0x04b0, "CD-Net" },
1016 { 0x0513, "EmulexNQA" },
1017 { 0x0520, "SiteLockChecks" },
1018 { 0x0529, "SiteLockChecks" },
1019 { 0x052d, "CitrixOS2 AppServer" },
1020 { 0x0535, "Tektronix" },
1021 { 0x0536, "Milan" },
1022 { 0x055d, "Attachmate SNA gateway" },
1023 { 0x056b, "IBM8235 ModemServer" },
1024 { 0x056c, "ShivaLanRover/E PLUS" },
1025 { 0x056d, "ShivaLanRover/T PLUS" },
1026 { 0x0580, "McAfeeNetShield" },
1027 { 0x05B8, "NLM to workstation communication (Revelation Software)" },
1028 { 0x05BA, "CompatibleSystemsRouters" },
1029 { 0x05BE, "CheyenneHierarchicalStorageManager" },
1030 { 0x0606, "JCWatermarkImaging" },
1031 { 0x060c, "AXISNetworkPrinter" },
1032 { 0x0610, "AdaptecSCSIManagement" },
1033 { 0x0621, "IBM AntiVirus" },
1034 { 0x0640, "Windows95 RemoteRegistryService" },
1035 { 0x064e, "MicrosoftIIS" },
1036 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1037 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1038 { 0x076C, "Xerox" },
1039 { 0x079b, "ShivaLanRover/E 115" },
1040 { 0x079c, "ShivaLanRover/T 115" },
1041 { 0x07B4, "CubixWorldDesk" },
1042 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" },
1043 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" },
1044 { 0x0810, "ELAN License Server Demo" },
1045 { 0x0824, "ShivaLanRoverAccessSwitch/E" },
1046 { 0x086a, "ISSC Collector" },
1047 { 0x087f, "ISSC DAS AgentAIX" },
1048 { 0x0880, "Intel Netport PRO" },
1049 { 0x0881, "Intel Netport PRO" },
1050 { 0x0b29, "SiteLock" },
1051 { 0x0c29, "SiteLockApplications" },
1052 { 0x0c2c, "LicensingServer" },
1053 { 0x2101, "PerformanceTechnologyInstantInternet" },
1054 { 0x2380, "LAI SiteLock" },
1055 { 0x238c, "MeetingMaker" },
1056 { 0x4808, "SiteLockServer/SiteLockMetering" },
1057 { 0x5555, "SiteLockUser" },
1058 { 0x6312, "Tapeware" },
1059 { 0x6f00, "RabbitGateway" },
1060 { 0x7703, "MODEM" },
1061 { 0x8002, "NetPortPrinters" },
1062 { 0x8008, "WordPerfectNetworkVersion" },
1063 { 0x85BE, "Cisco EIGRP" },
1064 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" },
1065 { 0x9000, "McAfeeNetShield" },
1066 { 0x9604, "CSA-NT_MON" },
1067 { 0xb6a8, "OceanIsleReachoutRemoteControl" },
1068 { 0xf11f, "SiteLockMetering" },
1069 { 0xf1ff, "SiteLock" },
1070 { 0xf503, "Microsoft SQL Server" },
1071 { 0xF905, "IBM TimeAndPlace" },
1072 { 0xfbfb, "TopCallIII FaxServer" },
1073 { 0xffff, "AnyService/Wildcard" },
1078 init_ipxsaparray(void)
1081 register struct hnamemem
*table
;
1083 for (i
= 0; ipxsap_db
[i
].s
!= NULL
; i
++) {
1084 int j
= htons(ipxsap_db
[i
].v
) & (HASHNAMESIZE
-1);
1085 table
= &ipxsaptable
[j
];
1088 table
->name
= ipxsap_db
[i
].s
;
1089 table
->addr
= htons(ipxsap_db
[i
].v
);
1090 table
->nxt
= newhnamemem();
1095 * Initialize the address to name translation machinery. We map all
1096 * non-local IP addresses to numeric addresses if fflag is true (i.e.,
1097 * to prevent blocking on the nameserver). localnet is the IP address
1098 * of the local network. mask is its subnet mask.
1101 init_addrtoname(u_int32_t localnet
, u_int32_t mask
)
1104 f_localnet
= localnet
;
1109 * Simplest way to suppress names.
1116 init_protoidarray();
1121 dnaddr_string(u_short dnaddr
)
1123 register struct hnamemem
*tp
;
1125 for (tp
= &dnaddrtable
[dnaddr
& (HASHNAMESIZE
-1)]; tp
->nxt
!= 0;
1127 if (tp
->addr
== dnaddr
)
1131 tp
->nxt
= newhnamemem();
1133 tp
->name
= dnnum_string(dnaddr
);
1135 tp
->name
= dnname_string(dnaddr
);
1140 /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
1144 register struct hnamemem
*p
;
1145 static struct hnamemem
*ptr
= NULL
;
1146 static u_int num
= 0;
1150 ptr
= (struct hnamemem
*)calloc(num
, sizeof (*ptr
));
1152 error("newhnamemem: calloc");
1160 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
1164 register struct h6namemem
*p
;
1165 static struct h6namemem
*ptr
= NULL
;
1166 static u_int num
= 0;
1170 ptr
= (struct h6namemem
*)calloc(num
, sizeof (*ptr
));
1172 error("newh6namemem: calloc");