609} 610 611const char * 612etherproto_string(netdissect_options *ndo, u_short port) 613{ 614 register char *cp; 615 register struct hnamemem *tp; 616 register uint32_t i = port; 617 char buf[sizeof("0000")]; 618 619 for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 620 if (tp->addr == i) 621 return (tp->name); 622 623 tp->addr = i; 624 tp->nxt = newhnamemem(ndo); 625 626 cp = buf; 627 NTOHS(port); 628 *cp++ = hex[port >> 12 & 0xf]; 629 *cp++ = hex[port >> 8 & 0xf]; 630 *cp++ = hex[port >> 4 & 0xf]; 631 *cp++ = hex[port & 0xf]; 632 *cp++ = '\0'; 633 tp->name = strdup(buf); 634 if (tp->name == NULL) 635 (*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)"); 636 return (tp->name); 637} 638 639const char * 640protoid_string(netdissect_options *ndo, register const u_char *pi) 641{ 642 register u_int i, j; 643 register char *cp; 644 register struct protoidmem *tp; 645 char buf[sizeof("00:00:00:00:00")]; 646 647 tp = lookup_protoid(ndo, pi); 648 if (tp->p_name) 649 return tp->p_name; 650 651 cp = buf; 652 if ((j = *pi >> 4) != 0) 653 *cp++ = hex[j]; 654 *cp++ = hex[*pi++ & 0xf]; 655 for (i = 4; (int)--i >= 0;) { 656 *cp++ = ':'; 657 if ((j = *pi >> 4) != 0) 658 *cp++ = hex[j]; 659 *cp++ = hex[*pi++ & 0xf]; 660 } 661 *cp = '\0'; 662 tp->p_name = strdup(buf); 663 if (tp->p_name == NULL) 664 (*ndo->ndo_error)(ndo, "protoid_string: strdup(buf)"); 665 return (tp->p_name); 666} 667 668#define ISONSAP_MAX_LENGTH 20 669const char * 670isonsap_string(netdissect_options *ndo, const u_char *nsap, 671 register u_int nsap_length) 672{ 673 register u_int nsap_idx; 674 register char *cp; 675 register struct enamemem *tp; 676 677 if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH) 678 return ("isonsap_string: illegal length"); 679 680 tp = lookup_nsap(ndo, nsap, nsap_length); 681 if (tp->e_name) 682 return tp->e_name; 683 684 tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")); 685 if (cp == NULL) 686 (*ndo->ndo_error)(ndo, "isonsap_string: malloc"); 687 688 for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) { 689 *cp++ = hex[*nsap >> 4]; 690 *cp++ = hex[*nsap++ & 0xf]; 691 if (((nsap_idx & 1) == 0) && 692 (nsap_idx + 1 < nsap_length)) { 693 *cp++ = '.'; 694 } 695 } 696 *cp = '\0'; 697 return (tp->e_name); 698} 699 700const char * 701tcpport_string(netdissect_options *ndo, u_short port) 702{ 703 register struct hnamemem *tp; 704 register uint32_t i = port; 705 char buf[sizeof("00000")]; 706 707 for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 708 if (tp->addr == i) 709 return (tp->name); 710 711 tp->addr = i; 712 tp->nxt = newhnamemem(ndo); 713 714 (void)snprintf(buf, sizeof(buf), "%u", i); 715 tp->name = strdup(buf); 716 if (tp->name == NULL) 717 (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)"); 718 return (tp->name); 719} 720 721const char * 722udpport_string(netdissect_options *ndo, register u_short port) 723{ 724 register struct hnamemem *tp; 725 register uint32_t i = port; 726 char buf[sizeof("00000")]; 727 728 for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 729 if (tp->addr == i) 730 return (tp->name); 731 732 tp->addr = i; 733 tp->nxt = newhnamemem(ndo); 734 735 (void)snprintf(buf, sizeof(buf), "%u", i); 736 tp->name = strdup(buf); 737 if (tp->name == NULL) 738 (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)"); 739 return (tp->name); 740} 741 742const char * 743ipxsap_string(netdissect_options *ndo, u_short port) 744{ 745 register char *cp; 746 register struct hnamemem *tp; 747 register uint32_t i = port; 748 char buf[sizeof("0000")]; 749 750 for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 751 if (tp->addr == i) 752 return (tp->name); 753 754 tp->addr = i; 755 tp->nxt = newhnamemem(ndo); 756 757 cp = buf; 758 NTOHS(port); 759 *cp++ = hex[port >> 12 & 0xf]; 760 *cp++ = hex[port >> 8 & 0xf]; 761 *cp++ = hex[port >> 4 & 0xf]; 762 *cp++ = hex[port & 0xf]; 763 *cp++ = '\0'; 764 tp->name = strdup(buf); 765 if (tp->name == NULL) 766 (*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)"); 767 return (tp->name); 768} 769 770static void 771init_servarray(netdissect_options *ndo) 772{ 773 struct servent *sv; 774 register struct hnamemem *table; 775 register int i; 776 char buf[sizeof("0000000000")]; 777 778 while ((sv = getservent()) != NULL) { 779 int port = ntohs(sv->s_port); 780 i = port & (HASHNAMESIZE-1); 781 if (strcmp(sv->s_proto, "tcp") == 0) 782 table = &tporttable[i]; 783 else if (strcmp(sv->s_proto, "udp") == 0) 784 table = &uporttable[i]; 785 else 786 continue; 787 788 while (table->name) 789 table = table->nxt; 790 if (ndo->ndo_nflag) { 791 (void)snprintf(buf, sizeof(buf), "%d", port); 792 table->name = strdup(buf); 793 } else 794 table->name = strdup(sv->s_name); 795 if (table->name == NULL) 796 (*ndo->ndo_error)(ndo, "init_servarray: strdup"); 797 798 table->addr = port; 799 table->nxt = newhnamemem(ndo); 800 } 801 endservent(); 802} 803 804static const struct eproto { 805 const char *s; 806 u_short p; 807} eproto_db[] = { 808 { "pup", ETHERTYPE_PUP }, 809 { "xns", ETHERTYPE_NS }, 810 { "ip", ETHERTYPE_IP }, 811 { "ip6", ETHERTYPE_IPV6 }, 812 { "arp", ETHERTYPE_ARP }, 813 { "rarp", ETHERTYPE_REVARP }, 814 { "sprite", ETHERTYPE_SPRITE }, 815 { "mopdl", ETHERTYPE_MOPDL }, 816 { "moprc", ETHERTYPE_MOPRC }, 817 { "decnet", ETHERTYPE_DN }, 818 { "lat", ETHERTYPE_LAT }, 819 { "sca", ETHERTYPE_SCA }, 820 { "lanbridge", ETHERTYPE_LANBRIDGE }, 821 { "vexp", ETHERTYPE_VEXP }, 822 { "vprod", ETHERTYPE_VPROD }, 823 { "atalk", ETHERTYPE_ATALK }, 824 { "atalkarp", ETHERTYPE_AARP }, 825 { "loopback", ETHERTYPE_LOOPBACK }, 826 { "decdts", ETHERTYPE_DECDTS }, 827 { "decdns", ETHERTYPE_DECDNS }, 828 { (char *)0, 0 } 829}; 830 831static void 832init_eprotoarray(netdissect_options *ndo) 833{ 834 register int i; 835 register struct hnamemem *table; 836 837 for (i = 0; eproto_db[i].s; i++) { 838 int j = htons(eproto_db[i].p) & (HASHNAMESIZE-1); 839 table = &eprototable[j]; 840 while (table->name) 841 table = table->nxt; 842 table->name = eproto_db[i].s; 843 table->addr = htons(eproto_db[i].p); 844 table->nxt = newhnamemem(ndo); 845 } 846} 847 848static const struct protoidlist { 849 const u_char protoid[5]; 850 const char *name; 851} protoidlist[] = { 852 {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" }, 853 {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" }, 854 {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" }, 855 {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" }, 856 {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" }, 857 {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } 858}; 859 860/* 861 * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet 862 * types. 863 */ 864static void 865init_protoidarray(netdissect_options *ndo) 866{ 867 register int i; 868 register struct protoidmem *tp; 869 const struct protoidlist *pl; 870 u_char protoid[5]; 871 872 protoid[0] = 0; 873 protoid[1] = 0; 874 protoid[2] = 0; 875 for (i = 0; eproto_db[i].s; i++) { 876 u_short etype = htons(eproto_db[i].p); 877 878 memcpy((char *)&protoid[3], (char *)&etype, 2); 879 tp = lookup_protoid(ndo, protoid); 880 tp->p_name = strdup(eproto_db[i].s); 881 if (tp->p_name == NULL) 882 (*ndo->ndo_error)(ndo, 883 "init_protoidarray: strdup(eproto_db[i].s)"); 884 } 885 /* Hardwire some SNAP proto ID names */ 886 for (pl = protoidlist; pl->name != NULL; ++pl) { 887 tp = lookup_protoid(ndo, pl->protoid); 888 /* Don't override existing name */ 889 if (tp->p_name != NULL) 890 continue; 891 892 tp->p_name = pl->name; 893 } 894} 895 896static const struct etherlist { 897 const u_char addr[6]; 898 const char *name; 899} etherlist[] = { 900 {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" }, 901 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } 902}; 903 904/* 905 * Initialize the ethers hash table. We take two different approaches 906 * depending on whether or not the system provides the ethers name 907 * service. If it does, we just wire in a few names at startup, 908 * and etheraddr_string() fills in the table on demand. If it doesn't, 909 * then we suck in the entire /etc/ethers file at startup. The idea 910 * is that parsing the local file will be fast, but spinning through 911 * all the ethers entries via NIS & next_etherent might be very slow. 912 * 913 * XXX pcap_next_etherent doesn't belong in the pcap interface, but 914 * since the pcap module already does name-to-address translation, 915 * it's already does most of the work for the ethernet address-to-name 916 * translation, so we just pcap_next_etherent as a convenience. 917 */ 918static void 919init_etherarray(netdissect_options *ndo) 920{ 921 register const struct etherlist *el; 922 register struct enamemem *tp; 923#ifdef USE_ETHER_NTOHOST 924 char name[256]; 925#else 926 register struct pcap_etherent *ep; 927 register FILE *fp; 928 929 /* Suck in entire ethers file */ 930 fp = fopen(PCAP_ETHERS_FILE, "r"); 931 if (fp != NULL) { 932 while ((ep = pcap_next_etherent(fp)) != NULL) { 933 tp = lookup_emem(ndo, ep->addr); 934 tp->e_name = strdup(ep->name); 935 if (tp->e_name == NULL) 936 (*ndo->ndo_error)(ndo, 937 "init_etherarray: strdup(ep->addr)"); 938 } 939 (void)fclose(fp); 940 } 941#endif 942 943 /* Hardwire some ethernet names */ 944 for (el = etherlist; el->name != NULL; ++el) { 945 tp = lookup_emem(ndo, el->addr); 946 /* Don't override existing name */ 947 if (tp->e_name != NULL) 948 continue; 949 950#ifdef USE_ETHER_NTOHOST 951 /* 952 * Use YP/NIS version of name if available. 953 */ 954 if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) { 955 tp->e_name = strdup(name); 956 if (tp->e_name == NULL) 957 (*ndo->ndo_error)(ndo, 958 "init_etherarray: strdup(name)"); 959 continue; 960 } 961#endif 962 tp->e_name = el->name; 963 } 964} 965 966static const struct tok ipxsap_db[] = { 967 { 0x0000, "Unknown" }, 968 { 0x0001, "User" }, 969 { 0x0002, "User Group" }, 970 { 0x0003, "PrintQueue" }, 971 { 0x0004, "FileServer" }, 972 { 0x0005, "JobServer" }, 973 { 0x0006, "Gateway" }, 974 { 0x0007, "PrintServer" }, 975 { 0x0008, "ArchiveQueue" }, 976 { 0x0009, "ArchiveServer" }, 977 { 0x000a, "JobQueue" }, 978 { 0x000b, "Administration" }, 979 { 0x000F, "Novell TI-RPC" }, 980 { 0x0017, "Diagnostics" }, 981 { 0x0020, "NetBIOS" }, 982 { 0x0021, "NAS SNA Gateway" }, 983 { 0x0023, "NACS AsyncGateway" }, 984 { 0x0024, "RemoteBridge/RoutingService" }, 985 { 0x0026, "BridgeServer" }, 986 { 0x0027, "TCP/IP Gateway" }, 987 { 0x0028, "Point-to-point X.25 BridgeServer" }, 988 { 0x0029, "3270 Gateway" }, 989 { 0x002a, "CHI Corp" }, 990 { 0x002c, "PC Chalkboard" }, 991 { 0x002d, "TimeSynchServer" }, 992 { 0x002e, "ARCserve5.0/PalindromeBackup" }, 993 { 0x0045, "DI3270 Gateway" }, 994 { 0x0047, "AdvertisingPrintServer" }, 995 { 0x004a, "NetBlazerModems" }, 996 { 0x004b, "BtrieveVAP" }, 997 { 0x004c, "NetwareSQL" }, 998 { 0x004d, "XtreeNetwork" }, 999 { 0x0050, "BtrieveVAP4.11" }, 1000 { 0x0052, "QuickLink" }, 1001 { 0x0053, "PrintQueueUser" }, 1002 { 0x0058, "Multipoint X.25 Router" }, 1003 { 0x0060, "STLB/NLM" }, 1004 { 0x0064, "ARCserve" }, 1005 { 0x0066, "ARCserve3.0" }, 1006 { 0x0072, "WAN CopyUtility" }, 1007 { 0x007a, "TES-NetwareVMS" }, 1008 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" }, 1009 { 0x0095, "DDA OBGYN" }, 1010 { 0x0098, "NetwareAccessServer" }, 1011 { 0x009a, "Netware for VMS II/NamedPipeServer" }, 1012 { 0x009b, "NetwareAccessServer" }, 1013 { 0x009e, "PortableNetwareServer/SunLinkNVT" }, 1014 { 0x00a1, "PowerchuteAPC UPS" }, 1015 { 0x00aa, "LAWserve" }, 1016 { 0x00ac, "CompaqIDA StatusMonitor" }, 1017 { 0x0100, "PIPE STAIL" }, 1018 { 0x0102, "LAN ProtectBindery" }, 1019 { 0x0103, "OracleDataBaseServer" }, 1020 { 0x0107, "Netware386/RSPX RemoteConsole" }, 1021 { 0x010f, "NovellSNA Gateway" }, 1022 { 0x0111, "TestServer" }, 1023 { 0x0112, "HP PrintServer" }, 1024 { 0x0114, "CSA MUX" }, 1025 { 0x0115, "CSA LCA" }, 1026 { 0x0116, "CSA CM" }, 1027 { 0x0117, "CSA SMA" }, 1028 { 0x0118, "CSA DBA" }, 1029 { 0x0119, "CSA NMA" }, 1030 { 0x011a, "CSA SSA" }, 1031 { 0x011b, "CSA STATUS" }, 1032 { 0x011e, "CSA APPC" }, 1033 { 0x0126, "SNA TEST SSA Profile" }, 1034 { 0x012a, "CSA TRACE" }, 1035 { 0x012b, "NetwareSAA" }, 1036 { 0x012e, "IKARUS VirusScan" }, 1037 { 0x0130, "CommunicationsExecutive" }, 1038 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" }, 1039 { 0x0135, "NetwareNamingServicesProfile" }, 1040 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" }, 1041 { 0x0141, "LAN SpoolServer" }, 1042 { 0x0152, "IRMALAN Gateway" }, 1043 { 0x0154, "NamedPipeServer" }, 1044 { 0x0166, "NetWareManagement" }, 1045 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" }, 1046 { 0x0173, "Compaq" }, 1047 { 0x0174, "Compaq SNMP Agent" }, 1048 { 0x0175, "Compaq" }, 1049 { 0x0180, "XTreeServer/XTreeTools" }, 1050 { 0x018A, "NASI ServicesBroadcastServer" }, 1051 { 0x01b0, "GARP Gateway" }, 1052 { 0x01b1, "Binfview" }, 1053 { 0x01bf, "IntelLanDeskManager" }, 1054 { 0x01ca, "AXTEC" }, 1055 { 0x01cb, "ShivaNetModem/E" }, 1056 { 0x01cc, "ShivaLanRover/E" }, 1057 { 0x01cd, "ShivaLanRover/T" }, 1058 { 0x01ce, "ShivaUniversal" }, 1059 { 0x01d8, "CastelleFAXPressServer" }, 1060 { 0x01da, "CastelleLANPressPrintServer" }, 1061 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" }, 1062 { 0x01f0, "LEGATO" }, 1063 { 0x01f5, "LEGATO" }, 1064 { 0x0233, "NMS Agent/NetwareManagementAgent" }, 1065 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" }, 1066 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" }, 1067 { 0x023a, "LANtern" }, 1068 { 0x023c, "MAVERICK" }, 1069 { 0x023f, "NovellSMDR" }, 1070 { 0x024e, "NetwareConnect" }, 1071 { 0x024f, "NASI ServerBroadcast Cisco" }, 1072 { 0x026a, "NMS ServiceConsole" }, 1073 { 0x026b, "TimeSynchronizationServer Netware 4.x" }, 1074 { 0x0278, "DirectoryServer Netware 4.x" }, 1075 { 0x027b, "NetwareManagementAgent" }, 1076 { 0x0280, "Novell File and Printer Sharing Service for PC" }, 1077 { 0x0304, "NovellSAA Gateway" }, 1078 { 0x0308, "COM/VERMED" }, 1079 { 0x030a, "GalacticommWorldgroupServer" }, 1080 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" }, 1081 { 0x0320, "AttachmateGateway" }, 1082 { 0x0327, "MicrosoftDiagnostiocs" }, 1083 { 0x0328, "WATCOM SQL Server" }, 1084 { 0x0335, "MultiTechSystems MultisynchCommServer" }, 1085 { 0x0343, "Xylogics RemoteAccessServer/LANModem" }, 1086 { 0x0355, "ArcadaBackupExec" }, 1087 { 0x0358, "MSLCD1" }, 1088 { 0x0361, "NETINELO" }, 1089 { 0x037e, "Powerchute UPS Monitoring" }, 1090 { 0x037f, "ViruSafeNotify" }, 1091 { 0x0386, "HP Bridge" }, 1092 { 0x0387, "HP Hub" }, 1093 { 0x0394, "NetWare SAA Gateway" }, 1094 { 0x039b, "LotusNotes" }, 1095 { 0x03b7, "CertusAntiVirus" }, 1096 { 0x03c4, "ARCserve4.0" }, 1097 { 0x03c7, "LANspool3.5" }, 1098 { 0x03d7, "LexmarkPrinterServer" }, 1099 { 0x03d8, "LexmarkXLE PrinterServer" }, 1100 { 0x03dd, "BanyanENS NetwareClient" }, 1101 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" }, 1102 { 0x03e1, "UnivelUnixware" }, 1103 { 0x03e4, "UnivelUnixware" }, 1104 { 0x03fc, "IntelNetport" }, 1105 { 0x03fd, "PrintServerQueue" }, 1106 { 0x040A, "ipnServer" }, 1107 { 0x040D, "LVERRMAN" }, 1108 { 0x040E, "LVLIC" }, 1109 { 0x0414, "NET Silicon (DPI)/Kyocera" }, 1110 { 0x0429, "SiteLockVirus" }, 1111 { 0x0432, "UFHELPR???" }, 1112 { 0x0433, "Synoptics281xAdvancedSNMPAgent" }, 1113 { 0x0444, "MicrosoftNT SNA Server" }, 1114 { 0x0448, "Oracle" }, 1115 { 0x044c, "ARCserve5.01" }, 1116 { 0x0457, "CanonGP55" }, 1117 { 0x045a, "QMS Printers" }, 1118 { 0x045b, "DellSCSI Array" }, 1119 { 0x0491, "NetBlazerModems" }, 1120 { 0x04ac, "OnTimeScheduler" }, 1121 { 0x04b0, "CD-Net" }, 1122 { 0x0513, "EmulexNQA" }, 1123 { 0x0520, "SiteLockChecks" }, 1124 { 0x0529, "SiteLockChecks" }, 1125 { 0x052d, "CitrixOS2 AppServer" }, 1126 { 0x0535, "Tektronix" }, 1127 { 0x0536, "Milan" }, 1128 { 0x055d, "Attachmate SNA gateway" }, 1129 { 0x056b, "IBM8235 ModemServer" }, 1130 { 0x056c, "ShivaLanRover/E PLUS" }, 1131 { 0x056d, "ShivaLanRover/T PLUS" }, 1132 { 0x0580, "McAfeeNetShield" }, 1133 { 0x05B8, "NLM to workstation communication (Revelation Software)" }, 1134 { 0x05BA, "CompatibleSystemsRouters" }, 1135 { 0x05BE, "CheyenneHierarchicalStorageManager" }, 1136 { 0x0606, "JCWatermarkImaging" }, 1137 { 0x060c, "AXISNetworkPrinter" }, 1138 { 0x0610, "AdaptecSCSIManagement" }, 1139 { 0x0621, "IBM AntiVirus" }, 1140 { 0x0640, "Windows95 RemoteRegistryService" }, 1141 { 0x064e, "MicrosoftIIS" }, 1142 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" }, 1143 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" }, 1144 { 0x076C, "Xerox" }, 1145 { 0x079b, "ShivaLanRover/E 115" }, 1146 { 0x079c, "ShivaLanRover/T 115" }, 1147 { 0x07B4, "CubixWorldDesk" }, 1148 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" }, 1149 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" }, 1150 { 0x0810, "ELAN License Server Demo" }, 1151 { 0x0824, "ShivaLanRoverAccessSwitch/E" }, 1152 { 0x086a, "ISSC Collector" }, 1153 { 0x087f, "ISSC DAS AgentAIX" }, 1154 { 0x0880, "Intel Netport PRO" }, 1155 { 0x0881, "Intel Netport PRO" }, 1156 { 0x0b29, "SiteLock" }, 1157 { 0x0c29, "SiteLockApplications" }, 1158 { 0x0c2c, "LicensingServer" }, 1159 { 0x2101, "PerformanceTechnologyInstantInternet" }, 1160 { 0x2380, "LAI SiteLock" }, 1161 { 0x238c, "MeetingMaker" }, 1162 { 0x4808, "SiteLockServer/SiteLockMetering" }, 1163 { 0x5555, "SiteLockUser" }, 1164 { 0x6312, "Tapeware" }, 1165 { 0x6f00, "RabbitGateway" }, 1166 { 0x7703, "MODEM" }, 1167 { 0x8002, "NetPortPrinters" }, 1168 { 0x8008, "WordPerfectNetworkVersion" }, 1169 { 0x85BE, "Cisco EIGRP" }, 1170 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" }, 1171 { 0x9000, "McAfeeNetShield" }, 1172 { 0x9604, "CSA-NT_MON" }, 1173 { 0xb6a8, "OceanIsleReachoutRemoteControl" }, 1174 { 0xf11f, "SiteLockMetering" }, 1175 { 0xf1ff, "SiteLock" }, 1176 { 0xf503, "Microsoft SQL Server" }, 1177 { 0xF905, "IBM TimeAndPlace" }, 1178 { 0xfbfb, "TopCallIII FaxServer" }, 1179 { 0xffff, "AnyService/Wildcard" }, 1180 { 0, (char *)0 } 1181}; 1182 1183static void 1184init_ipxsaparray(netdissect_options *ndo) 1185{ 1186 register int i; 1187 register struct hnamemem *table; 1188 1189 for (i = 0; ipxsap_db[i].s != NULL; i++) { 1190 int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1); 1191 table = &ipxsaptable[j]; 1192 while (table->name) 1193 table = table->nxt; 1194 table->name = ipxsap_db[i].s; 1195 table->addr = htons(ipxsap_db[i].v); 1196 table->nxt = newhnamemem(ndo); 1197 } 1198} 1199 1200/* 1201 * Initialize the address to name translation machinery. We map all 1202 * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true 1203 * (i.e., to prevent blocking on the nameserver). localnet is the IP address 1204 * of the local network. mask is its subnet mask. 1205 */ 1206void 1207init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask) 1208{ 1209 if (ndo->ndo_fflag) { 1210 f_localnet = localnet; 1211 f_netmask = mask; 1212 } 1213 if (ndo->ndo_nflag) 1214 /* 1215 * Simplest way to suppress names. 1216 */ 1217 return; 1218 1219 init_etherarray(ndo); 1220 init_servarray(ndo); 1221 init_eprotoarray(ndo); 1222 init_protoidarray(ndo); 1223 init_ipxsaparray(ndo); 1224} 1225 1226const char * 1227dnaddr_string(netdissect_options *ndo, u_short dnaddr) 1228{ 1229 register struct hnamemem *tp; 1230 1231 for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != NULL; 1232 tp = tp->nxt) 1233 if (tp->addr == dnaddr) 1234 return (tp->name); 1235 1236 tp->addr = dnaddr; 1237 tp->nxt = newhnamemem(ndo); 1238 if (ndo->ndo_nflag) 1239 tp->name = dnnum_string(ndo, dnaddr); 1240 else 1241 tp->name = dnname_string(ndo, dnaddr); 1242 1243 return(tp->name); 1244} 1245 1246/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */ 1247struct hnamemem * 1248newhnamemem(netdissect_options *ndo) 1249{ 1250 register struct hnamemem *p; 1251 static struct hnamemem *ptr = NULL; 1252 static u_int num = 0; 1253 1254 if (num <= 0) { 1255 num = 64; 1256 ptr = (struct hnamemem *)calloc(num, sizeof (*ptr)); 1257 if (ptr == NULL) 1258 (*ndo->ndo_error)(ndo, "newhnamemem: calloc"); 1259 } 1260 --num; 1261 p = ptr++; 1262 return (p); 1263} 1264 1265/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */ 1266struct h6namemem * 1267newh6namemem(netdissect_options *ndo) 1268{ 1269 register struct h6namemem *p; 1270 static struct h6namemem *ptr = NULL; 1271 static u_int num = 0; 1272 1273 if (num <= 0) { 1274 num = 64; 1275 ptr = (struct h6namemem *)calloc(num, sizeof (*ptr)); 1276 if (ptr == NULL) 1277 (*ndo->ndo_error)(ndo, "newh6namemem: calloc"); 1278 } 1279 --num; 1280 p = ptr++; 1281 return (p); 1282} 1283 1284/* Represent TCI part of the 802.1Q 4-octet tag as text. */ 1285const char * 1286ieee8021q_tci_string(const uint16_t tci) 1287{ 1288 static char buf[128]; 1289 snprintf(buf, sizeof(buf), "vlan %u, p %u%s", 1290 tci & 0xfff, 1291 tci >> 13, 1292 (tci & 0x1000) ? ", DEI" : ""); 1293 return buf; 1294}
| 621} 622 623const char * 624etherproto_string(netdissect_options *ndo, u_short port) 625{ 626 register char *cp; 627 register struct hnamemem *tp; 628 register uint32_t i = port; 629 char buf[sizeof("0000")]; 630 631 for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 632 if (tp->addr == i) 633 return (tp->name); 634 635 tp->addr = i; 636 tp->nxt = newhnamemem(ndo); 637 638 cp = buf; 639 NTOHS(port); 640 *cp++ = hex[port >> 12 & 0xf]; 641 *cp++ = hex[port >> 8 & 0xf]; 642 *cp++ = hex[port >> 4 & 0xf]; 643 *cp++ = hex[port & 0xf]; 644 *cp++ = '\0'; 645 tp->name = strdup(buf); 646 if (tp->name == NULL) 647 (*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)"); 648 return (tp->name); 649} 650 651const char * 652protoid_string(netdissect_options *ndo, register const u_char *pi) 653{ 654 register u_int i, j; 655 register char *cp; 656 register struct protoidmem *tp; 657 char buf[sizeof("00:00:00:00:00")]; 658 659 tp = lookup_protoid(ndo, pi); 660 if (tp->p_name) 661 return tp->p_name; 662 663 cp = buf; 664 if ((j = *pi >> 4) != 0) 665 *cp++ = hex[j]; 666 *cp++ = hex[*pi++ & 0xf]; 667 for (i = 4; (int)--i >= 0;) { 668 *cp++ = ':'; 669 if ((j = *pi >> 4) != 0) 670 *cp++ = hex[j]; 671 *cp++ = hex[*pi++ & 0xf]; 672 } 673 *cp = '\0'; 674 tp->p_name = strdup(buf); 675 if (tp->p_name == NULL) 676 (*ndo->ndo_error)(ndo, "protoid_string: strdup(buf)"); 677 return (tp->p_name); 678} 679 680#define ISONSAP_MAX_LENGTH 20 681const char * 682isonsap_string(netdissect_options *ndo, const u_char *nsap, 683 register u_int nsap_length) 684{ 685 register u_int nsap_idx; 686 register char *cp; 687 register struct enamemem *tp; 688 689 if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH) 690 return ("isonsap_string: illegal length"); 691 692 tp = lookup_nsap(ndo, nsap, nsap_length); 693 if (tp->e_name) 694 return tp->e_name; 695 696 tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")); 697 if (cp == NULL) 698 (*ndo->ndo_error)(ndo, "isonsap_string: malloc"); 699 700 for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) { 701 *cp++ = hex[*nsap >> 4]; 702 *cp++ = hex[*nsap++ & 0xf]; 703 if (((nsap_idx & 1) == 0) && 704 (nsap_idx + 1 < nsap_length)) { 705 *cp++ = '.'; 706 } 707 } 708 *cp = '\0'; 709 return (tp->e_name); 710} 711 712const char * 713tcpport_string(netdissect_options *ndo, u_short port) 714{ 715 register struct hnamemem *tp; 716 register uint32_t i = port; 717 char buf[sizeof("00000")]; 718 719 for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 720 if (tp->addr == i) 721 return (tp->name); 722 723 tp->addr = i; 724 tp->nxt = newhnamemem(ndo); 725 726 (void)snprintf(buf, sizeof(buf), "%u", i); 727 tp->name = strdup(buf); 728 if (tp->name == NULL) 729 (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)"); 730 return (tp->name); 731} 732 733const char * 734udpport_string(netdissect_options *ndo, register u_short port) 735{ 736 register struct hnamemem *tp; 737 register uint32_t i = port; 738 char buf[sizeof("00000")]; 739 740 for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 741 if (tp->addr == i) 742 return (tp->name); 743 744 tp->addr = i; 745 tp->nxt = newhnamemem(ndo); 746 747 (void)snprintf(buf, sizeof(buf), "%u", i); 748 tp->name = strdup(buf); 749 if (tp->name == NULL) 750 (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)"); 751 return (tp->name); 752} 753 754const char * 755ipxsap_string(netdissect_options *ndo, u_short port) 756{ 757 register char *cp; 758 register struct hnamemem *tp; 759 register uint32_t i = port; 760 char buf[sizeof("0000")]; 761 762 for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 763 if (tp->addr == i) 764 return (tp->name); 765 766 tp->addr = i; 767 tp->nxt = newhnamemem(ndo); 768 769 cp = buf; 770 NTOHS(port); 771 *cp++ = hex[port >> 12 & 0xf]; 772 *cp++ = hex[port >> 8 & 0xf]; 773 *cp++ = hex[port >> 4 & 0xf]; 774 *cp++ = hex[port & 0xf]; 775 *cp++ = '\0'; 776 tp->name = strdup(buf); 777 if (tp->name == NULL) 778 (*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)"); 779 return (tp->name); 780} 781 782static void 783init_servarray(netdissect_options *ndo) 784{ 785 struct servent *sv; 786 register struct hnamemem *table; 787 register int i; 788 char buf[sizeof("0000000000")]; 789 790 while ((sv = getservent()) != NULL) { 791 int port = ntohs(sv->s_port); 792 i = port & (HASHNAMESIZE-1); 793 if (strcmp(sv->s_proto, "tcp") == 0) 794 table = &tporttable[i]; 795 else if (strcmp(sv->s_proto, "udp") == 0) 796 table = &uporttable[i]; 797 else 798 continue; 799 800 while (table->name) 801 table = table->nxt; 802 if (ndo->ndo_nflag) { 803 (void)snprintf(buf, sizeof(buf), "%d", port); 804 table->name = strdup(buf); 805 } else 806 table->name = strdup(sv->s_name); 807 if (table->name == NULL) 808 (*ndo->ndo_error)(ndo, "init_servarray: strdup"); 809 810 table->addr = port; 811 table->nxt = newhnamemem(ndo); 812 } 813 endservent(); 814} 815 816static const struct eproto { 817 const char *s; 818 u_short p; 819} eproto_db[] = { 820 { "pup", ETHERTYPE_PUP }, 821 { "xns", ETHERTYPE_NS }, 822 { "ip", ETHERTYPE_IP }, 823 { "ip6", ETHERTYPE_IPV6 }, 824 { "arp", ETHERTYPE_ARP }, 825 { "rarp", ETHERTYPE_REVARP }, 826 { "sprite", ETHERTYPE_SPRITE }, 827 { "mopdl", ETHERTYPE_MOPDL }, 828 { "moprc", ETHERTYPE_MOPRC }, 829 { "decnet", ETHERTYPE_DN }, 830 { "lat", ETHERTYPE_LAT }, 831 { "sca", ETHERTYPE_SCA }, 832 { "lanbridge", ETHERTYPE_LANBRIDGE }, 833 { "vexp", ETHERTYPE_VEXP }, 834 { "vprod", ETHERTYPE_VPROD }, 835 { "atalk", ETHERTYPE_ATALK }, 836 { "atalkarp", ETHERTYPE_AARP }, 837 { "loopback", ETHERTYPE_LOOPBACK }, 838 { "decdts", ETHERTYPE_DECDTS }, 839 { "decdns", ETHERTYPE_DECDNS }, 840 { (char *)0, 0 } 841}; 842 843static void 844init_eprotoarray(netdissect_options *ndo) 845{ 846 register int i; 847 register struct hnamemem *table; 848 849 for (i = 0; eproto_db[i].s; i++) { 850 int j = htons(eproto_db[i].p) & (HASHNAMESIZE-1); 851 table = &eprototable[j]; 852 while (table->name) 853 table = table->nxt; 854 table->name = eproto_db[i].s; 855 table->addr = htons(eproto_db[i].p); 856 table->nxt = newhnamemem(ndo); 857 } 858} 859 860static const struct protoidlist { 861 const u_char protoid[5]; 862 const char *name; 863} protoidlist[] = { 864 {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" }, 865 {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" }, 866 {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" }, 867 {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" }, 868 {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" }, 869 {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } 870}; 871 872/* 873 * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet 874 * types. 875 */ 876static void 877init_protoidarray(netdissect_options *ndo) 878{ 879 register int i; 880 register struct protoidmem *tp; 881 const struct protoidlist *pl; 882 u_char protoid[5]; 883 884 protoid[0] = 0; 885 protoid[1] = 0; 886 protoid[2] = 0; 887 for (i = 0; eproto_db[i].s; i++) { 888 u_short etype = htons(eproto_db[i].p); 889 890 memcpy((char *)&protoid[3], (char *)&etype, 2); 891 tp = lookup_protoid(ndo, protoid); 892 tp->p_name = strdup(eproto_db[i].s); 893 if (tp->p_name == NULL) 894 (*ndo->ndo_error)(ndo, 895 "init_protoidarray: strdup(eproto_db[i].s)"); 896 } 897 /* Hardwire some SNAP proto ID names */ 898 for (pl = protoidlist; pl->name != NULL; ++pl) { 899 tp = lookup_protoid(ndo, pl->protoid); 900 /* Don't override existing name */ 901 if (tp->p_name != NULL) 902 continue; 903 904 tp->p_name = pl->name; 905 } 906} 907 908static const struct etherlist { 909 const u_char addr[6]; 910 const char *name; 911} etherlist[] = { 912 {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" }, 913 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } 914}; 915 916/* 917 * Initialize the ethers hash table. We take two different approaches 918 * depending on whether or not the system provides the ethers name 919 * service. If it does, we just wire in a few names at startup, 920 * and etheraddr_string() fills in the table on demand. If it doesn't, 921 * then we suck in the entire /etc/ethers file at startup. The idea 922 * is that parsing the local file will be fast, but spinning through 923 * all the ethers entries via NIS & next_etherent might be very slow. 924 * 925 * XXX pcap_next_etherent doesn't belong in the pcap interface, but 926 * since the pcap module already does name-to-address translation, 927 * it's already does most of the work for the ethernet address-to-name 928 * translation, so we just pcap_next_etherent as a convenience. 929 */ 930static void 931init_etherarray(netdissect_options *ndo) 932{ 933 register const struct etherlist *el; 934 register struct enamemem *tp; 935#ifdef USE_ETHER_NTOHOST 936 char name[256]; 937#else 938 register struct pcap_etherent *ep; 939 register FILE *fp; 940 941 /* Suck in entire ethers file */ 942 fp = fopen(PCAP_ETHERS_FILE, "r"); 943 if (fp != NULL) { 944 while ((ep = pcap_next_etherent(fp)) != NULL) { 945 tp = lookup_emem(ndo, ep->addr); 946 tp->e_name = strdup(ep->name); 947 if (tp->e_name == NULL) 948 (*ndo->ndo_error)(ndo, 949 "init_etherarray: strdup(ep->addr)"); 950 } 951 (void)fclose(fp); 952 } 953#endif 954 955 /* Hardwire some ethernet names */ 956 for (el = etherlist; el->name != NULL; ++el) { 957 tp = lookup_emem(ndo, el->addr); 958 /* Don't override existing name */ 959 if (tp->e_name != NULL) 960 continue; 961 962#ifdef USE_ETHER_NTOHOST 963 /* 964 * Use YP/NIS version of name if available. 965 */ 966 if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) { 967 tp->e_name = strdup(name); 968 if (tp->e_name == NULL) 969 (*ndo->ndo_error)(ndo, 970 "init_etherarray: strdup(name)"); 971 continue; 972 } 973#endif 974 tp->e_name = el->name; 975 } 976} 977 978static const struct tok ipxsap_db[] = { 979 { 0x0000, "Unknown" }, 980 { 0x0001, "User" }, 981 { 0x0002, "User Group" }, 982 { 0x0003, "PrintQueue" }, 983 { 0x0004, "FileServer" }, 984 { 0x0005, "JobServer" }, 985 { 0x0006, "Gateway" }, 986 { 0x0007, "PrintServer" }, 987 { 0x0008, "ArchiveQueue" }, 988 { 0x0009, "ArchiveServer" }, 989 { 0x000a, "JobQueue" }, 990 { 0x000b, "Administration" }, 991 { 0x000F, "Novell TI-RPC" }, 992 { 0x0017, "Diagnostics" }, 993 { 0x0020, "NetBIOS" }, 994 { 0x0021, "NAS SNA Gateway" }, 995 { 0x0023, "NACS AsyncGateway" }, 996 { 0x0024, "RemoteBridge/RoutingService" }, 997 { 0x0026, "BridgeServer" }, 998 { 0x0027, "TCP/IP Gateway" }, 999 { 0x0028, "Point-to-point X.25 BridgeServer" }, 1000 { 0x0029, "3270 Gateway" }, 1001 { 0x002a, "CHI Corp" }, 1002 { 0x002c, "PC Chalkboard" }, 1003 { 0x002d, "TimeSynchServer" }, 1004 { 0x002e, "ARCserve5.0/PalindromeBackup" }, 1005 { 0x0045, "DI3270 Gateway" }, 1006 { 0x0047, "AdvertisingPrintServer" }, 1007 { 0x004a, "NetBlazerModems" }, 1008 { 0x004b, "BtrieveVAP" }, 1009 { 0x004c, "NetwareSQL" }, 1010 { 0x004d, "XtreeNetwork" }, 1011 { 0x0050, "BtrieveVAP4.11" }, 1012 { 0x0052, "QuickLink" }, 1013 { 0x0053, "PrintQueueUser" }, 1014 { 0x0058, "Multipoint X.25 Router" }, 1015 { 0x0060, "STLB/NLM" }, 1016 { 0x0064, "ARCserve" }, 1017 { 0x0066, "ARCserve3.0" }, 1018 { 0x0072, "WAN CopyUtility" }, 1019 { 0x007a, "TES-NetwareVMS" }, 1020 { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" }, 1021 { 0x0095, "DDA OBGYN" }, 1022 { 0x0098, "NetwareAccessServer" }, 1023 { 0x009a, "Netware for VMS II/NamedPipeServer" }, 1024 { 0x009b, "NetwareAccessServer" }, 1025 { 0x009e, "PortableNetwareServer/SunLinkNVT" }, 1026 { 0x00a1, "PowerchuteAPC UPS" }, 1027 { 0x00aa, "LAWserve" }, 1028 { 0x00ac, "CompaqIDA StatusMonitor" }, 1029 { 0x0100, "PIPE STAIL" }, 1030 { 0x0102, "LAN ProtectBindery" }, 1031 { 0x0103, "OracleDataBaseServer" }, 1032 { 0x0107, "Netware386/RSPX RemoteConsole" }, 1033 { 0x010f, "NovellSNA Gateway" }, 1034 { 0x0111, "TestServer" }, 1035 { 0x0112, "HP PrintServer" }, 1036 { 0x0114, "CSA MUX" }, 1037 { 0x0115, "CSA LCA" }, 1038 { 0x0116, "CSA CM" }, 1039 { 0x0117, "CSA SMA" }, 1040 { 0x0118, "CSA DBA" }, 1041 { 0x0119, "CSA NMA" }, 1042 { 0x011a, "CSA SSA" }, 1043 { 0x011b, "CSA STATUS" }, 1044 { 0x011e, "CSA APPC" }, 1045 { 0x0126, "SNA TEST SSA Profile" }, 1046 { 0x012a, "CSA TRACE" }, 1047 { 0x012b, "NetwareSAA" }, 1048 { 0x012e, "IKARUS VirusScan" }, 1049 { 0x0130, "CommunicationsExecutive" }, 1050 { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" }, 1051 { 0x0135, "NetwareNamingServicesProfile" }, 1052 { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" }, 1053 { 0x0141, "LAN SpoolServer" }, 1054 { 0x0152, "IRMALAN Gateway" }, 1055 { 0x0154, "NamedPipeServer" }, 1056 { 0x0166, "NetWareManagement" }, 1057 { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" }, 1058 { 0x0173, "Compaq" }, 1059 { 0x0174, "Compaq SNMP Agent" }, 1060 { 0x0175, "Compaq" }, 1061 { 0x0180, "XTreeServer/XTreeTools" }, 1062 { 0x018A, "NASI ServicesBroadcastServer" }, 1063 { 0x01b0, "GARP Gateway" }, 1064 { 0x01b1, "Binfview" }, 1065 { 0x01bf, "IntelLanDeskManager" }, 1066 { 0x01ca, "AXTEC" }, 1067 { 0x01cb, "ShivaNetModem/E" }, 1068 { 0x01cc, "ShivaLanRover/E" }, 1069 { 0x01cd, "ShivaLanRover/T" }, 1070 { 0x01ce, "ShivaUniversal" }, 1071 { 0x01d8, "CastelleFAXPressServer" }, 1072 { 0x01da, "CastelleLANPressPrintServer" }, 1073 { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" }, 1074 { 0x01f0, "LEGATO" }, 1075 { 0x01f5, "LEGATO" }, 1076 { 0x0233, "NMS Agent/NetwareManagementAgent" }, 1077 { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" }, 1078 { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" }, 1079 { 0x023a, "LANtern" }, 1080 { 0x023c, "MAVERICK" }, 1081 { 0x023f, "NovellSMDR" }, 1082 { 0x024e, "NetwareConnect" }, 1083 { 0x024f, "NASI ServerBroadcast Cisco" }, 1084 { 0x026a, "NMS ServiceConsole" }, 1085 { 0x026b, "TimeSynchronizationServer Netware 4.x" }, 1086 { 0x0278, "DirectoryServer Netware 4.x" }, 1087 { 0x027b, "NetwareManagementAgent" }, 1088 { 0x0280, "Novell File and Printer Sharing Service for PC" }, 1089 { 0x0304, "NovellSAA Gateway" }, 1090 { 0x0308, "COM/VERMED" }, 1091 { 0x030a, "GalacticommWorldgroupServer" }, 1092 { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" }, 1093 { 0x0320, "AttachmateGateway" }, 1094 { 0x0327, "MicrosoftDiagnostiocs" }, 1095 { 0x0328, "WATCOM SQL Server" }, 1096 { 0x0335, "MultiTechSystems MultisynchCommServer" }, 1097 { 0x0343, "Xylogics RemoteAccessServer/LANModem" }, 1098 { 0x0355, "ArcadaBackupExec" }, 1099 { 0x0358, "MSLCD1" }, 1100 { 0x0361, "NETINELO" }, 1101 { 0x037e, "Powerchute UPS Monitoring" }, 1102 { 0x037f, "ViruSafeNotify" }, 1103 { 0x0386, "HP Bridge" }, 1104 { 0x0387, "HP Hub" }, 1105 { 0x0394, "NetWare SAA Gateway" }, 1106 { 0x039b, "LotusNotes" }, 1107 { 0x03b7, "CertusAntiVirus" }, 1108 { 0x03c4, "ARCserve4.0" }, 1109 { 0x03c7, "LANspool3.5" }, 1110 { 0x03d7, "LexmarkPrinterServer" }, 1111 { 0x03d8, "LexmarkXLE PrinterServer" }, 1112 { 0x03dd, "BanyanENS NetwareClient" }, 1113 { 0x03de, "GuptaSequelBaseServer/NetWareSQL" }, 1114 { 0x03e1, "UnivelUnixware" }, 1115 { 0x03e4, "UnivelUnixware" }, 1116 { 0x03fc, "IntelNetport" }, 1117 { 0x03fd, "PrintServerQueue" }, 1118 { 0x040A, "ipnServer" }, 1119 { 0x040D, "LVERRMAN" }, 1120 { 0x040E, "LVLIC" }, 1121 { 0x0414, "NET Silicon (DPI)/Kyocera" }, 1122 { 0x0429, "SiteLockVirus" }, 1123 { 0x0432, "UFHELPR???" }, 1124 { 0x0433, "Synoptics281xAdvancedSNMPAgent" }, 1125 { 0x0444, "MicrosoftNT SNA Server" }, 1126 { 0x0448, "Oracle" }, 1127 { 0x044c, "ARCserve5.01" }, 1128 { 0x0457, "CanonGP55" }, 1129 { 0x045a, "QMS Printers" }, 1130 { 0x045b, "DellSCSI Array" }, 1131 { 0x0491, "NetBlazerModems" }, 1132 { 0x04ac, "OnTimeScheduler" }, 1133 { 0x04b0, "CD-Net" }, 1134 { 0x0513, "EmulexNQA" }, 1135 { 0x0520, "SiteLockChecks" }, 1136 { 0x0529, "SiteLockChecks" }, 1137 { 0x052d, "CitrixOS2 AppServer" }, 1138 { 0x0535, "Tektronix" }, 1139 { 0x0536, "Milan" }, 1140 { 0x055d, "Attachmate SNA gateway" }, 1141 { 0x056b, "IBM8235 ModemServer" }, 1142 { 0x056c, "ShivaLanRover/E PLUS" }, 1143 { 0x056d, "ShivaLanRover/T PLUS" }, 1144 { 0x0580, "McAfeeNetShield" }, 1145 { 0x05B8, "NLM to workstation communication (Revelation Software)" }, 1146 { 0x05BA, "CompatibleSystemsRouters" }, 1147 { 0x05BE, "CheyenneHierarchicalStorageManager" }, 1148 { 0x0606, "JCWatermarkImaging" }, 1149 { 0x060c, "AXISNetworkPrinter" }, 1150 { 0x0610, "AdaptecSCSIManagement" }, 1151 { 0x0621, "IBM AntiVirus" }, 1152 { 0x0640, "Windows95 RemoteRegistryService" }, 1153 { 0x064e, "MicrosoftIIS" }, 1154 { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" }, 1155 { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" }, 1156 { 0x076C, "Xerox" }, 1157 { 0x079b, "ShivaLanRover/E 115" }, 1158 { 0x079c, "ShivaLanRover/T 115" }, 1159 { 0x07B4, "CubixWorldDesk" }, 1160 { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" }, 1161 { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" }, 1162 { 0x0810, "ELAN License Server Demo" }, 1163 { 0x0824, "ShivaLanRoverAccessSwitch/E" }, 1164 { 0x086a, "ISSC Collector" }, 1165 { 0x087f, "ISSC DAS AgentAIX" }, 1166 { 0x0880, "Intel Netport PRO" }, 1167 { 0x0881, "Intel Netport PRO" }, 1168 { 0x0b29, "SiteLock" }, 1169 { 0x0c29, "SiteLockApplications" }, 1170 { 0x0c2c, "LicensingServer" }, 1171 { 0x2101, "PerformanceTechnologyInstantInternet" }, 1172 { 0x2380, "LAI SiteLock" }, 1173 { 0x238c, "MeetingMaker" }, 1174 { 0x4808, "SiteLockServer/SiteLockMetering" }, 1175 { 0x5555, "SiteLockUser" }, 1176 { 0x6312, "Tapeware" }, 1177 { 0x6f00, "RabbitGateway" }, 1178 { 0x7703, "MODEM" }, 1179 { 0x8002, "NetPortPrinters" }, 1180 { 0x8008, "WordPerfectNetworkVersion" }, 1181 { 0x85BE, "Cisco EIGRP" }, 1182 { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" }, 1183 { 0x9000, "McAfeeNetShield" }, 1184 { 0x9604, "CSA-NT_MON" }, 1185 { 0xb6a8, "OceanIsleReachoutRemoteControl" }, 1186 { 0xf11f, "SiteLockMetering" }, 1187 { 0xf1ff, "SiteLock" }, 1188 { 0xf503, "Microsoft SQL Server" }, 1189 { 0xF905, "IBM TimeAndPlace" }, 1190 { 0xfbfb, "TopCallIII FaxServer" }, 1191 { 0xffff, "AnyService/Wildcard" }, 1192 { 0, (char *)0 } 1193}; 1194 1195static void 1196init_ipxsaparray(netdissect_options *ndo) 1197{ 1198 register int i; 1199 register struct hnamemem *table; 1200 1201 for (i = 0; ipxsap_db[i].s != NULL; i++) { 1202 int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1); 1203 table = &ipxsaptable[j]; 1204 while (table->name) 1205 table = table->nxt; 1206 table->name = ipxsap_db[i].s; 1207 table->addr = htons(ipxsap_db[i].v); 1208 table->nxt = newhnamemem(ndo); 1209 } 1210} 1211 1212/* 1213 * Initialize the address to name translation machinery. We map all 1214 * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true 1215 * (i.e., to prevent blocking on the nameserver). localnet is the IP address 1216 * of the local network. mask is its subnet mask. 1217 */ 1218void 1219init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask) 1220{ 1221 if (ndo->ndo_fflag) { 1222 f_localnet = localnet; 1223 f_netmask = mask; 1224 } 1225 if (ndo->ndo_nflag) 1226 /* 1227 * Simplest way to suppress names. 1228 */ 1229 return; 1230 1231 init_etherarray(ndo); 1232 init_servarray(ndo); 1233 init_eprotoarray(ndo); 1234 init_protoidarray(ndo); 1235 init_ipxsaparray(ndo); 1236} 1237 1238const char * 1239dnaddr_string(netdissect_options *ndo, u_short dnaddr) 1240{ 1241 register struct hnamemem *tp; 1242 1243 for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != NULL; 1244 tp = tp->nxt) 1245 if (tp->addr == dnaddr) 1246 return (tp->name); 1247 1248 tp->addr = dnaddr; 1249 tp->nxt = newhnamemem(ndo); 1250 if (ndo->ndo_nflag) 1251 tp->name = dnnum_string(ndo, dnaddr); 1252 else 1253 tp->name = dnname_string(ndo, dnaddr); 1254 1255 return(tp->name); 1256} 1257 1258/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */ 1259struct hnamemem * 1260newhnamemem(netdissect_options *ndo) 1261{ 1262 register struct hnamemem *p; 1263 static struct hnamemem *ptr = NULL; 1264 static u_int num = 0; 1265 1266 if (num <= 0) { 1267 num = 64; 1268 ptr = (struct hnamemem *)calloc(num, sizeof (*ptr)); 1269 if (ptr == NULL) 1270 (*ndo->ndo_error)(ndo, "newhnamemem: calloc"); 1271 } 1272 --num; 1273 p = ptr++; 1274 return (p); 1275} 1276 1277/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */ 1278struct h6namemem * 1279newh6namemem(netdissect_options *ndo) 1280{ 1281 register struct h6namemem *p; 1282 static struct h6namemem *ptr = NULL; 1283 static u_int num = 0; 1284 1285 if (num <= 0) { 1286 num = 64; 1287 ptr = (struct h6namemem *)calloc(num, sizeof (*ptr)); 1288 if (ptr == NULL) 1289 (*ndo->ndo_error)(ndo, "newh6namemem: calloc"); 1290 } 1291 --num; 1292 p = ptr++; 1293 return (p); 1294} 1295 1296/* Represent TCI part of the 802.1Q 4-octet tag as text. */ 1297const char * 1298ieee8021q_tci_string(const uint16_t tci) 1299{ 1300 static char buf[128]; 1301 snprintf(buf, sizeof(buf), "vlan %u, p %u%s", 1302 tci & 0xfff, 1303 tci >> 13, 1304 (tci & 0x1000) ? ", DEI" : ""); 1305 return buf; 1306}
|