]>
The Tcpdump Group git mirrors - tcpdump/blob - addrtoname.c
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
[] =
26 "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.96 2003-07-31 22:36:44 fenner 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 HAVE_NETINET_ETHER_H
43 #include <netinet/ether.h> /* ether_ntohost on linux */
44 #endif /* HAVE_NETINET_ETHER_H */
45 #endif /* USE_ETHER_NTOHOST */
48 #include <pcap-namedb.h>
54 #include "interface.h"
55 #include "addrtoname.h"
57 #include "setsignal.h"
60 * hash tables for whatever-to-name translations
62 * XXX there has to be error checks against strdup(3) failure
65 #define HASHNAMESIZE 4096
73 struct hnamemem hnametable
[HASHNAMESIZE
];
74 struct hnamemem tporttable
[HASHNAMESIZE
];
75 struct hnamemem uporttable
[HASHNAMESIZE
];
76 struct hnamemem eprototable
[HASHNAMESIZE
];
77 struct hnamemem dnaddrtable
[HASHNAMESIZE
];
78 struct hnamemem llcsaptable
[HASHNAMESIZE
];
79 struct hnamemem ipxsaptable
[HASHNAMESIZE
];
81 #if defined(INET6) && defined(WIN32)
83 * fake gethostbyaddr for Win2k/XP
84 * gethostbyaddr() returns incorrect value when AF_INET6 is passed
87 * h_name in struct hostent is only valid.
89 static struct hostent
*
90 win32_gethostbyaddr(const char *addr
, int len
, int type
)
92 static struct hostent host
;
93 static char hostbuf
[NI_MAXHOST
];
94 char hname
[NI_MAXHOST
];
95 struct sockaddr_in6 addr6
;
97 host
.h_name
= hostbuf
;
100 return gethostbyaddr(addr
, len
, type
);
103 memset(&addr6
, 0, sizeof(addr6
));
104 addr6
.sin6_family
= AF_INET6
;
105 memcpy(&addr6
.sin6_addr
, addr
, len
);
106 if (getnameinfo((struct sockaddr
*)&addr6
, sizeof(addr6
),
107 hname
, sizeof(hname
), NULL
, 0, 0)) {
110 strcpy(host
.h_name
, hname
);
118 #define gethostbyaddr win32_gethostbyaddr
119 #endif /* INET6 & WIN32*/
123 struct in6_addr addr
;
125 struct h6namemem
*nxt
;
128 struct h6namemem h6nametable
[HASHNAMESIZE
];
136 u_char
*e_nsap
; /* used only for nsaptable[] */
137 #define e_bs e_nsap /* for bytestringtable */
138 struct enamemem
*e_nxt
;
141 struct enamemem enametable
[HASHNAMESIZE
];
142 struct enamemem nsaptable
[HASHNAMESIZE
];
143 struct enamemem bytestringtable
[HASHNAMESIZE
];
149 struct protoidmem
*p_nxt
;
152 struct protoidmem protoidtable
[HASHNAMESIZE
];
155 * A faster replacement for inet_ntoa().
158 intoa(u_int32_t addr
)
163 static char buf
[sizeof(".xxx.xxx.xxx.xxx")];
166 cp
= &buf
[sizeof buf
];
172 *--cp
= byte
% 10 + '0';
175 *--cp
= byte
% 10 + '0';
187 static u_int32_t f_netmask
;
188 static u_int32_t f_localnet
;
189 static u_int32_t netmask
;
192 * Return a name for the IP address pointed to by ap. This address
193 * is assumed to be in network byte order.
196 getname(const u_char
*ap
)
198 register struct hostent
*hp
;
200 static struct hnamemem
*p
; /* static for longjmp() */
202 memcpy(&addr
, ap
, sizeof(addr
));
203 p
= &hnametable
[addr
& (HASHNAMESIZE
-1)];
204 for (; p
->nxt
; p
= p
->nxt
) {
209 p
->nxt
= newhnamemem();
212 * Print names unless:
214 * (2) Address is foreign and -f was given. (If -f was not
215 * given, f_netmask and f_localnet are 0 and the test
219 (addr
& f_netmask
) == f_localnet
) {
220 hp
= gethostbyaddr((char *)&addr
, 4, AF_INET
);
224 p
->name
= strdup(hp
->h_name
);
226 /* Remove domain qualifications */
227 dotp
= strchr(p
->name
, '.');
234 p
->name
= strdup(intoa(addr
));
240 * Return a name for the IP6 address pointed to by ap. This address
241 * is assumed to be in network byte order.
244 getname6(const u_char
*ap
)
246 register struct hostent
*hp
;
247 struct in6_addr addr
;
248 static struct h6namemem
*p
; /* static for longjmp() */
249 register const char *cp
;
250 char ntop_buf
[INET6_ADDRSTRLEN
];
252 memcpy(&addr
, ap
, sizeof(addr
));
253 p
= &h6nametable
[*(u_int16_t
*)&addr
.s6_addr
[14] & (HASHNAMESIZE
-1)];
254 for (; p
->nxt
; p
= p
->nxt
) {
255 if (memcmp(&p
->addr
, &addr
, sizeof(addr
)) == 0)
259 p
->nxt
= newh6namemem();
262 * Do not print names if -n was given.
265 hp
= gethostbyaddr((char *)&addr
, sizeof(addr
), AF_INET6
);
269 p
->name
= strdup(hp
->h_name
);
271 /* Remove domain qualifications */
272 dotp
= strchr(p
->name
, '.');
279 cp
= inet_ntop(AF_INET6
, &addr
, ntop_buf
, sizeof(ntop_buf
));
280 p
->name
= strdup(cp
);
285 static char hex
[] = "0123456789abcdef";
288 /* Find the hash node that corresponds the ether address 'ep' */
290 static inline struct enamemem
*
291 lookup_emem(const u_char
*ep
)
293 register u_int i
, j
, k
;
296 k
= (ep
[0] << 8) | ep
[1];
297 j
= (ep
[2] << 8) | ep
[3];
298 i
= (ep
[4] << 8) | ep
[5];
300 tp
= &enametable
[(i
^ j
) & (HASHNAMESIZE
-1)];
302 if (tp
->e_addr0
== i
&&
311 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
312 if (tp
->e_nxt
== NULL
)
313 error("lookup_emem: calloc");
319 * Find the hash node that corresponds to the bytestring 'bs'
323 static inline struct enamemem
*
324 lookup_bytestring(register const u_char
*bs
, const unsigned int nlen
)
327 register u_int i
, j
, k
;
330 k
= (bs
[0] << 8) | bs
[1];
331 j
= (bs
[2] << 8) | bs
[3];
332 i
= (bs
[4] << 8) | bs
[5];
333 } else if (nlen
>= 4) {
334 k
= (bs
[0] << 8) | bs
[1];
335 j
= (bs
[2] << 8) | bs
[3];
340 tp
= &bytestringtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
342 if (tp
->e_addr0
== i
&&
345 memcmp((const char *)bs
, (const char *)(tp
->e_bs
), nlen
) == 0)
354 tp
->e_bs
= (u_char
*) calloc(1, nlen
+ 1);
355 memcpy(tp
->e_bs
, bs
, nlen
);
356 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
357 if (tp
->e_nxt
== NULL
)
358 error("lookup_bytestring: calloc");
363 /* Find the hash node that corresponds the NSAP 'nsap' */
365 static inline struct enamemem
*
366 lookup_nsap(register const u_char
*nsap
)
368 register u_int i
, j
, k
;
369 unsigned int nlen
= *nsap
;
371 const u_char
*ensap
= nsap
+ nlen
- 6;
374 k
= (ensap
[0] << 8) | ensap
[1];
375 j
= (ensap
[2] << 8) | ensap
[3];
376 i
= (ensap
[4] << 8) | ensap
[5];
381 tp
= &nsaptable
[(i
^ j
) & (HASHNAMESIZE
-1)];
383 if (tp
->e_addr0
== i
&&
386 tp
->e_nsap
[0] == nlen
&&
387 memcmp((const char *)&(nsap
[1]),
388 (char *)&(tp
->e_nsap
[1]), nlen
) == 0)
395 tp
->e_nsap
= (u_char
*)malloc(nlen
+ 1);
396 if (tp
->e_nsap
== NULL
)
397 error("lookup_nsap: malloc");
398 memcpy((char *)tp
->e_nsap
, (const char *)nsap
, nlen
+ 1);
399 tp
->e_nxt
= (struct enamemem
*)calloc(1, sizeof(*tp
));
400 if (tp
->e_nxt
== NULL
)
401 error("lookup_nsap: calloc");
406 /* Find the hash node that corresponds the protoid 'pi'. */
408 static inline struct protoidmem
*
409 lookup_protoid(const u_char
*pi
)
412 struct protoidmem
*tp
;
414 /* 5 octets won't be aligned */
415 i
= (((pi
[0] << 8) + pi
[1]) << 8) + pi
[2];
416 j
= (pi
[3] << 8) + pi
[4];
417 /* XXX should be endian-insensitive, but do big-endian testing XXX */
419 tp
= &protoidtable
[(i
^ j
) & (HASHNAMESIZE
-1)];
421 if (tp
->p_oui
== i
&& tp
->p_proto
== j
)
427 tp
->p_nxt
= (struct protoidmem
*)calloc(1, sizeof(*tp
));
428 if (tp
->p_nxt
== NULL
)
429 error("lookup_protoid: calloc");
435 etheraddr_string(register const u_char
*ep
)
439 register struct enamemem
*tp
;
440 char buf
[sizeof("00:00:00:00:00:00")];
442 tp
= lookup_emem(ep
);
445 #ifdef USE_ETHER_NTOHOST
448 if (ether_ntohost(buf2
, (const struct ether_addr
*)ep
) == 0) {
449 tp
->e_name
= strdup(buf2
);
455 *cp
++ = hex
[*ep
>> 4 ];
456 *cp
++ = hex
[*ep
++ & 0xf];
457 for (i
= 5; (int)--i
>= 0;) {
459 *cp
++ = hex
[*ep
>> 4 ];
460 *cp
++ = hex
[*ep
++ & 0xf];
463 tp
->e_name
= strdup(buf
);
468 linkaddr_string(const u_char
*ep
, const unsigned int len
)
472 register struct enamemem
*tp
;
474 if (len
== 6) /* XXX not totally correct... */
475 return etheraddr_string(ep
);
477 tp
= lookup_bytestring(ep
, len
);
481 tp
->e_name
= cp
= (char *)malloc(len
*3);
482 if (tp
->e_name
== NULL
)
483 error("linkaddr_string: malloc");
484 if ((j
= *ep
>> 4) != 0)
486 *cp
++ = hex
[*ep
++ & 0xf];
487 for (i
= len
-1; i
> 0 ; --i
) {
489 if ((j
= *ep
>> 4) != 0)
491 *cp
++ = hex
[*ep
++ & 0xf];
498 etherproto_string(u_short port
)
501 register struct hnamemem
*tp
;
502 register u_int32_t i
= port
;
503 char buf
[sizeof("0000")];
505 for (tp
= &eprototable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
510 tp
->nxt
= newhnamemem();
514 *cp
++ = hex
[port
>> 12 & 0xf];
515 *cp
++ = hex
[port
>> 8 & 0xf];
516 *cp
++ = hex
[port
>> 4 & 0xf];
517 *cp
++ = hex
[port
& 0xf];
519 tp
->name
= strdup(buf
);
524 protoid_string(register const u_char
*pi
)
528 register struct protoidmem
*tp
;
529 char buf
[sizeof("00:00:00:00:00")];
531 tp
= lookup_protoid(pi
);
536 if ((j
= *pi
>> 4) != 0)
538 *cp
++ = hex
[*pi
++ & 0xf];
539 for (i
= 4; (int)--i
>= 0;) {
541 if ((j
= *pi
>> 4) != 0)
543 *cp
++ = hex
[*pi
++ & 0xf];
546 tp
->p_name
= strdup(buf
);
551 llcsap_string(u_char sap
)
553 register struct hnamemem
*tp
;
554 register u_int32_t i
= sap
;
555 char buf
[sizeof("sap 00")];
557 for (tp
= &llcsaptable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
562 tp
->nxt
= newhnamemem();
564 snprintf(buf
, sizeof(buf
), "sap %02x", sap
& 0xff);
565 tp
->name
= strdup(buf
);
570 isonsap_string(const u_char
*nsap
)
572 register u_int i
, nlen
= nsap
[0];
574 register struct enamemem
*tp
;
576 tp
= lookup_nsap(nsap
);
580 tp
->e_name
= cp
= (char *)malloc(nlen
* 2 + 2);
582 error("isonsap_string: malloc");
586 for (i
= nlen
; (int)--i
>= 0;) {
587 *cp
++ = hex
[*nsap
>> 4];
588 *cp
++ = hex
[*nsap
++ & 0xf];
595 tcpport_string(u_short port
)
597 register struct hnamemem
*tp
;
598 register u_int32_t i
= port
;
599 char buf
[sizeof("00000")];
601 for (tp
= &tporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
606 tp
->nxt
= newhnamemem();
608 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
609 tp
->name
= strdup(buf
);
614 udpport_string(register u_short port
)
616 register struct hnamemem
*tp
;
617 register u_int32_t i
= port
;
618 char buf
[sizeof("00000")];
620 for (tp
= &uporttable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
625 tp
->nxt
= newhnamemem();
627 (void)snprintf(buf
, sizeof(buf
), "%u", i
);
628 tp
->name
= strdup(buf
);
633 ipxsap_string(u_short port
)
636 register struct hnamemem
*tp
;
637 register u_int32_t i
= port
;
638 char buf
[sizeof("0000")];
640 for (tp
= &ipxsaptable
[i
& (HASHNAMESIZE
-1)]; tp
->nxt
; tp
= tp
->nxt
)
645 tp
->nxt
= newhnamemem();
649 *cp
++ = hex
[port
>> 12 & 0xf];
650 *cp
++ = hex
[port
>> 8 & 0xf];
651 *cp
++ = hex
[port
>> 4 & 0xf];
652 *cp
++ = hex
[port
& 0xf];
654 tp
->name
= strdup(buf
);
662 register struct hnamemem
*table
;
664 char buf
[sizeof("0000000000")];
666 while ((sv
= getservent()) != NULL
) {
667 int port
= ntohs(sv
->s_port
);
668 i
= port
& (HASHNAMESIZE
-1);
669 if (strcmp(sv
->s_proto
, "tcp") == 0)
670 table
= &tporttable
[i
];
671 else if (strcmp(sv
->s_proto
, "udp") == 0)
672 table
= &uporttable
[i
];
679 (void)snprintf(buf
, sizeof(buf
), "%d", port
);
680 table
->name
= strdup(buf
);
682 table
->name
= strdup(sv
->s_name
);
684 table
->nxt
= newhnamemem();
689 /*XXX from libbpfc.a */
691 extern struct eproto
{
693 __declspec( dllimport
) struct eproto
{
700 init_eprotoarray(void)
703 register struct hnamemem
*table
;
705 for (i
= 0; eproto_db
[i
].s
; i
++) {
706 int j
= htons(eproto_db
[i
].p
) & (HASHNAMESIZE
-1);
707 table
= &eprototable
[j
];
710 table
->name
= eproto_db
[i
].s
;
711 table
->addr
= htons(eproto_db
[i
].p
);
712 table
->nxt
= newhnamemem();
716 static struct protoidlist
{
717 const u_char protoid
[5];
720 {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
721 {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
722 {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" },
723 {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" },
724 {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" },
725 {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
729 * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet
733 init_protoidarray(void)
736 register struct protoidmem
*tp
;
737 struct protoidlist
*pl
;
743 for (i
= 0; eproto_db
[i
].s
; i
++) {
744 u_short etype
= htons(eproto_db
[i
].p
);
746 memcpy((char *)&protoid
[3], (char *)&etype
, 2);
747 tp
= lookup_protoid(protoid
);
748 tp
->p_name
= strdup(eproto_db
[i
].s
);
750 /* Hardwire some SNAP proto ID names */
751 for (pl
= protoidlist
; pl
->name
!= NULL
; ++pl
) {
752 tp
= lookup_protoid(pl
->protoid
);
753 /* Don't override existing name */
754 if (tp
->p_name
!= NULL
)
757 tp
->p_name
= pl
->name
;
761 static struct etherlist
{
762 const u_char addr
[6];
765 {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
766 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL
}
770 * Initialize the ethers hash table. We take two different approaches
771 * depending on whether or not the system provides the ethers name
772 * service. If it does, we just wire in a few names at startup,
773 * and etheraddr_string() fills in the table on demand. If it doesn't,
774 * then we suck in the entire /etc/ethers file at startup. The idea
775 * is that parsing the local file will be fast, but spinning through
776 * all the ethers entries via NIS & next_etherent might be very slow.
778 * XXX pcap_next_etherent doesn't belong in the pcap interface, but
779 * since the pcap module already does name-to-address translation,
780 * it's already does most of the work for the ethernet address-to-name
781 * translation, so we just pcap_next_etherent as a convenience.
784 init_etherarray(void)
786 register struct etherlist
*el
;
787 register struct enamemem
*tp
;
788 #ifdef USE_ETHER_NTOHOST
791 register struct pcap_etherent
*ep
;
794 /* Suck in entire ethers file */
795 fp
= fopen(PCAP_ETHERS_FILE
, "r");
797 while ((ep
= pcap_next_etherent(fp
)) != NULL
) {
798 tp
= lookup_emem(ep
->addr
);
799 tp
->e_name
= strdup(ep
->name
);
805 /* Hardwire some ethernet names */
806 for (el
= etherlist
; el
->name
!= NULL
; ++el
) {
807 tp
= lookup_emem(el
->addr
);
808 /* Don't override existing name */
809 if (tp
->e_name
!= NULL
)
812 #ifdef USE_ETHER_NTOHOST
813 /* Use yp/nis version of name if available */
814 if (ether_ntohost(name
, (const struct ether_addr
*)el
->addr
) == 0) {
815 tp
->e_name
= strdup(name
);
819 tp
->e_name
= el
->name
;
823 static struct tok llcsap_db
[] = {
824 { LLCSAP_NULL
, "null" },
825 { LLCSAP_8021B_I
, "802.1b-gsap" },
826 { LLCSAP_8021B_G
, "802.1b-isap" },
827 { LLCSAP_IP
, "ip-sap" },
828 { LLCSAP_PROWAYNM
, "proway-nm" },
829 { LLCSAP_8021D
, "802.1d" },
830 { LLCSAP_RS511
, "eia-rs511" },
831 { LLCSAP_ISO8208
, "x.25/llc2" },
832 { LLCSAP_PROWAY
, "proway" },
833 { LLCSAP_SNAP
, "snap" },
834 { LLCSAP_IPX
, "IPX" },
835 { LLCSAP_NETBEUI
, "netbeui" },
836 { LLCSAP_ISONS
, "iso-clns" },
837 { LLCSAP_GLOBAL
, "global" },
842 init_llcsaparray(void)
845 register struct hnamemem
*table
;
847 for (i
= 0; llcsap_db
[i
].s
!= NULL
; i
++) {
848 table
= &llcsaptable
[llcsap_db
[i
].v
];
851 table
->name
= llcsap_db
[i
].s
;
852 table
->addr
= llcsap_db
[i
].v
;
853 table
->nxt
= newhnamemem();
857 static struct tok ipxsap_db
[] = {
858 { 0x0000, "Unknown" },
860 { 0x0002, "User Group" },
861 { 0x0003, "PrintQueue" },
862 { 0x0004, "FileServer" },
863 { 0x0005, "JobServer" },
864 { 0x0006, "Gateway" },
865 { 0x0007, "PrintServer" },
866 { 0x0008, "ArchiveQueue" },
867 { 0x0009, "ArchiveServer" },
868 { 0x000a, "JobQueue" },
869 { 0x000b, "Administration" },
870 { 0x000F, "Novell TI-RPC" },
871 { 0x0017, "Diagnostics" },
872 { 0x0020, "NetBIOS" },
873 { 0x0021, "NAS SNA Gateway" },
874 { 0x0023, "NACS AsyncGateway" },
875 { 0x0024, "RemoteBridge/RoutingService" },
876 { 0x0026, "BridgeServer" },
877 { 0x0027, "TCP/IP Gateway" },
878 { 0x0028, "Point-to-point X.25 BridgeServer" },
879 { 0x0029, "3270 Gateway" },
880 { 0x002a, "CHI Corp" },
881 { 0x002c, "PC Chalkboard" },
882 { 0x002d, "TimeSynchServer" },
883 { 0x002e, "ARCserve5.0/PalindromeBackup" },
884 { 0x0045, "DI3270 Gateway" },
885 { 0x0047, "AdvertisingPrintServer" },
886 { 0x004a, "NetBlazerModems" },
887 { 0x004b, "BtrieveVAP" },
888 { 0x004c, "NetwareSQL" },
889 { 0x004d, "XtreeNetwork" },
890 { 0x0050, "BtrieveVAP4.11" },
891 { 0x0052, "QuickLink" },
892 { 0x0053, "PrintQueueUser" },
893 { 0x0058, "Multipoint X.25 Router" },
894 { 0x0060, "STLB/NLM" },
895 { 0x0064, "ARCserve" },
896 { 0x0066, "ARCserve3.0" },
897 { 0x0072, "WAN CopyUtility" },
898 { 0x007a, "TES-NetwareVMS" },
899 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" },
900 { 0x0095, "DDA OBGYN" },
901 { 0x0098, "NetwareAccessServer" },
902 { 0x009a, "Netware for VMS II/NamedPipeServer" },
903 { 0x009b, "NetwareAccessServer" },
904 { 0x009e, "PortableNetwareServer/SunLinkNVT" },
905 { 0x00a1, "PowerchuteAPC UPS" },
906 { 0x00aa, "LAWserve" },
907 { 0x00ac, "CompaqIDA StatusMonitor" },
908 { 0x0100, "PIPE STAIL" },
909 { 0x0102, "LAN ProtectBindery" },
910 { 0x0103, "OracleDataBaseServer" },
911 { 0x0107, "Netware386/RSPX RemoteConsole" },
912 { 0x010f, "NovellSNA Gateway" },
913 { 0x0111, "TestServer" },
914 { 0x0112, "HP PrintServer" },
915 { 0x0114, "CSA MUX" },
916 { 0x0115, "CSA LCA" },
917 { 0x0116, "CSA CM" },
918 { 0x0117, "CSA SMA" },
919 { 0x0118, "CSA DBA" },
920 { 0x0119, "CSA NMA" },
921 { 0x011a, "CSA SSA" },
922 { 0x011b, "CSA STATUS" },
923 { 0x011e, "CSA APPC" },
924 { 0x0126, "SNA TEST SSA Profile" },
925 { 0x012a, "CSA TRACE" },
926 { 0x012b, "NetwareSAA" },
927 { 0x012e, "IKARUS VirusScan" },
928 { 0x0130, "CommunicationsExecutive" },
929 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" },
930 { 0x0135, "NetwareNamingServicesProfile" },
931 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" },
932 { 0x0141, "LAN SpoolServer" },
933 { 0x0152, "IRMALAN Gateway" },
934 { 0x0154, "NamedPipeServer" },
935 { 0x0166, "NetWareManagement" },
936 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" },
937 { 0x0173, "Compaq" },
938 { 0x0174, "Compaq SNMP Agent" },
939 { 0x0175, "Compaq" },
940 { 0x0180, "XTreeServer/XTreeTools" },
941 { 0x018A, "NASI ServicesBroadcastServer" },
942 { 0x01b0, "GARP Gateway" },
943 { 0x01b1, "Binfview" },
944 { 0x01bf, "IntelLanDeskManager" },
946 { 0x01cb, "ShivaNetModem/E" },
947 { 0x01cc, "ShivaLanRover/E" },
948 { 0x01cd, "ShivaLanRover/T" },
949 { 0x01ce, "ShivaUniversal" },
950 { 0x01d8, "CastelleFAXPressServer" },
951 { 0x01da, "CastelleLANPressPrintServer" },
952 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" },
953 { 0x01f0, "LEGATO" },
954 { 0x01f5, "LEGATO" },
955 { 0x0233, "NMS Agent/NetwareManagementAgent" },
956 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" },
957 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" },
958 { 0x023a, "LANtern" },
959 { 0x023c, "MAVERICK" },
960 { 0x023f, "NovellSMDR" },
961 { 0x024e, "NetwareConnect" },
962 { 0x024f, "NASI ServerBroadcast Cisco" },
963 { 0x026a, "NMS ServiceConsole" },
964 { 0x026b, "TimeSynchronizationServer Netware 4.x" },
965 { 0x0278, "DirectoryServer Netware 4.x" },
966 { 0x027b, "NetwareManagementAgent" },
967 { 0x0280, "Novell File and Printer Sharing Service for PC" },
968 { 0x0304, "NovellSAA Gateway" },
969 { 0x0308, "COM/VERMED" },
970 { 0x030a, "GalacticommWorldgroupServer" },
971 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" },
972 { 0x0320, "AttachmateGateway" },
973 { 0x0327, "MicrosoftDiagnostiocs" },
974 { 0x0328, "WATCOM SQL Server" },
975 { 0x0335, "MultiTechSystems MultisynchCommServer" },
976 { 0x0343, "Xylogics RemoteAccessServer/LANModem" },
977 { 0x0355, "ArcadaBackupExec" },
978 { 0x0358, "MSLCD1" },
979 { 0x0361, "NETINELO" },
980 { 0x037e, "Powerchute UPS Monitoring" },
981 { 0x037f, "ViruSafeNotify" },
982 { 0x0386, "HP Bridge" },
983 { 0x0387, "HP Hub" },
984 { 0x0394, "NetWare SAA Gateway" },
985 { 0x039b, "LotusNotes" },
986 { 0x03b7, "CertusAntiVirus" },
987 { 0x03c4, "ARCserve4.0" },
988 { 0x03c7, "LANspool3.5" },
989 { 0x03d7, "LexmarkPrinterServer" },
990 { 0x03d8, "LexmarkXLE PrinterServer" },
991 { 0x03dd, "BanyanENS NetwareClient" },
992 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" },
993 { 0x03e1, "UnivelUnixware" },
994 { 0x03e4, "UnivelUnixware" },
995 { 0x03fc, "IntelNetport" },
996 { 0x03fd, "PrintServerQueue" },
997 { 0x040A, "ipnServer" },
998 { 0x040D, "LVERRMAN" },
1000 { 0x0414, "NET Silicon (DPI)/Kyocera" },
1001 { 0x0429, "SiteLockVirus" },
1002 { 0x0432, "UFHELPR???" },
1003 { 0x0433, "Synoptics281xAdvancedSNMPAgent" },
1004 { 0x0444, "MicrosoftNT SNA Server" },
1005 { 0x0448, "Oracle" },
1006 { 0x044c, "ARCserve5.01" },
1007 { 0x0457, "CanonGP55" },
1008 { 0x045a, "QMS Printers" },
1009 { 0x045b, "DellSCSI Array" },
1010 { 0x0491, "NetBlazerModems" },
1011 { 0x04ac, "OnTimeScheduler" },
1012 { 0x04b0, "CD-Net" },
1013 { 0x0513, "EmulexNQA" },
1014 { 0x0520, "SiteLockChecks" },
1015 { 0x0529, "SiteLockChecks" },
1016 { 0x052d, "CitrixOS2 AppServer" },
1017 { 0x0535, "Tektronix" },
1018 { 0x0536, "Milan" },
1019 { 0x055d, "Attachmate SNA gateway" },
1020 { 0x056b, "IBM8235 ModemServer" },
1021 { 0x056c, "ShivaLanRover/E PLUS" },
1022 { 0x056d, "ShivaLanRover/T PLUS" },
1023 { 0x0580, "McAfeeNetShield" },
1024 { 0x05B8, "NLM to workstation communication (Revelation Software)" },
1025 { 0x05BA, "CompatibleSystemsRouters" },
1026 { 0x05BE, "CheyenneHierarchicalStorageManager" },
1027 { 0x0606, "JCWatermarkImaging" },
1028 { 0x060c, "AXISNetworkPrinter" },
1029 { 0x0610, "AdaptecSCSIManagement" },
1030 { 0x0621, "IBM AntiVirus" },
1031 { 0x0640, "Windows95 RemoteRegistryService" },
1032 { 0x064e, "MicrosoftIIS" },
1033 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1034 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" },
1035 { 0x076C, "Xerox" },
1036 { 0x079b, "ShivaLanRover/E 115" },
1037 { 0x079c, "ShivaLanRover/T 115" },
1038 { 0x07B4, "CubixWorldDesk" },
1039 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" },
1040 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" },
1041 { 0x0810, "ELAN License Server Demo" },
1042 { 0x0824, "ShivaLanRoverAccessSwitch/E" },
1043 { 0x086a, "ISSC Collector" },
1044 { 0x087f, "ISSC DAS AgentAIX" },
1045 { 0x0880, "Intel Netport PRO" },
1046 { 0x0881, "Intel Netport PRO" },
1047 { 0x0b29, "SiteLock" },
1048 { 0x0c29, "SiteLockApplications" },
1049 { 0x0c2c, "LicensingServer" },
1050 { 0x2101, "PerformanceTechnologyInstantInternet" },
1051 { 0x2380, "LAI SiteLock" },
1052 { 0x238c, "MeetingMaker" },
1053 { 0x4808, "SiteLockServer/SiteLockMetering" },
1054 { 0x5555, "SiteLockUser" },
1055 { 0x6312, "Tapeware" },
1056 { 0x6f00, "RabbitGateway" },
1057 { 0x7703, "MODEM" },
1058 { 0x8002, "NetPortPrinters" },
1059 { 0x8008, "WordPerfectNetworkVersion" },
1060 { 0x85BE, "Cisco EIGRP" },
1061 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" },
1062 { 0x9000, "McAfeeNetShield" },
1063 { 0x9604, "CSA-NT_MON" },
1064 { 0xb6a8, "OceanIsleReachoutRemoteControl" },
1065 { 0xf11f, "SiteLockMetering" },
1066 { 0xf1ff, "SiteLock" },
1067 { 0xf503, "Microsoft SQL Server" },
1068 { 0xF905, "IBM TimeAndPlace" },
1069 { 0xfbfb, "TopCallIII FaxServer" },
1070 { 0xffff, "AnyService/Wildcard" },
1075 init_ipxsaparray(void)
1078 register struct hnamemem
*table
;
1080 for (i
= 0; ipxsap_db
[i
].s
!= NULL
; i
++) {
1081 int j
= htons(ipxsap_db
[i
].v
) & (HASHNAMESIZE
-1);
1082 table
= &ipxsaptable
[j
];
1085 table
->name
= ipxsap_db
[i
].s
;
1086 table
->addr
= htons(ipxsap_db
[i
].v
);
1087 table
->nxt
= newhnamemem();
1092 * Initialize the address to name translation machinery. We map all
1093 * non-local IP addresses to numeric addresses if fflag is true (i.e.,
1094 * to prevent blocking on the nameserver). localnet is the IP address
1095 * of the local network. mask is its subnet mask.
1098 init_addrtoname(u_int32_t localnet
, u_int32_t mask
)
1102 f_localnet
= localnet
;
1107 * Simplest way to suppress names.
1115 init_protoidarray();
1120 dnaddr_string(u_short dnaddr
)
1122 register struct hnamemem
*tp
;
1124 for (tp
= &dnaddrtable
[dnaddr
& (HASHNAMESIZE
-1)]; tp
->nxt
!= 0;
1126 if (tp
->addr
== dnaddr
)
1130 tp
->nxt
= newhnamemem();
1132 tp
->name
= dnnum_string(dnaddr
);
1134 tp
->name
= dnname_string(dnaddr
);
1139 /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
1143 register struct hnamemem
*p
;
1144 static struct hnamemem
*ptr
= NULL
;
1145 static u_int num
= 0;
1149 ptr
= (struct hnamemem
*)calloc(num
, sizeof (*ptr
));
1151 error("newhnamemem: calloc");
1159 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
1163 register struct h6namemem
*p
;
1164 static struct h6namemem
*ptr
= NULL
;
1165 static u_int num
= 0;
1169 ptr
= (struct h6namemem
*)calloc(num
, sizeof (*ptr
));
1171 error("newh6namemem: calloc");