home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / getethrs / part01 < prev    next >
Encoding:
Text File  |  1993-04-09  |  45.3 KB  |  1,882 lines

  1. Newsgroups: comp.sources.unix
  2. From: davy@ecn.purdue.edu (Dave Curry)
  3. Subject: v26i116: getethers - find IP addrs for all local ether addrs (V1.4), Part01/01
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: davy@ecn.purdue.edu (Dave Curry)
  8. Posting-Number: Volume 26, Issue 116
  9. Archive-Name: getethers/part01
  10.  
  11. (This is a new version of getethers, which originally appeared in Volume 25)
  12.  
  13.                             May, 1992
  14.  
  15. This is GETETHERS Version 1.4.
  16.  
  17. New functionality since the 1.0 release in 11/91:
  18.  
  19.     - Thanks to Ric Anderson (ric@cs.arizona.edu), you can now write
  20.       Network General Sniffer data files as well as Excelan Lanalyzer
  21.       files.  The file format is selected with the -e and -s options
  22.       in conjunction with -w.
  23.  
  24.     - Thanks to Peter Shipley (shipley@tfs.com), when the -v option is
  25.       given, vendor names for the discovered ethernet addresses are
  26.       now printed as well as the previously printed data.
  27.  
  28.     - Thanks to Peter again, GETETHERS can now be compiled and run on
  29.       pretty much any 4.3BSD system.  It will *not* obtain the ethernet
  30.       address of the local host unless you're running on a Sun (4.3BSD
  31.       does not provide a way to do this).
  32.  
  33.     - GETETHERS will no longer exit if it bumps into an interface not
  34.       supported by the Network Interface Tap (e.g., Sun X.25 interfaces).
  35.  
  36. If you don't know what GETETHERS is:
  37.  
  38. GETETHERS runs through all the addresses on an ethernet (a.b.c.1 - a.b.c.254)
  39. and pings each address, and then determines the ethernet address for that
  40. host.  It produces a list, either in ASCII or in the binary format for an
  41. Excelan Lanalyzer, of hostname/ethernet address pairs for all hosts on that
  42. network.
  43.  
  44. This program has been tested on Sun workstations under SunOS 4.1.1, and on
  45. DEC Vaxes under 4.3BSD.  It should be relatively easy to port to any system
  46. with BSD-style networking.  Mostly you need to work on if.c a bit, and maybe
  47. on arp.c.
  48.  
  49. If you make modifications or fixes, please send them to me for incorporation
  50. into future versions.
  51.  
  52.     Dave Curry
  53.     Purdue University
  54.     Engineering Computer Network
  55.     davy@ecn.purdue.edu
  56.  
  57. #! /bin/sh
  58. # This is a shell archive.  Remove anything before this line, then unpack
  59. # it by saving it into a file and typing "sh file".  To overwrite existing
  60. # files, type "sh file -c".  You can also feed this as standard input via
  61. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  62. # will see the following message at the end:
  63. #        "End of archive 1 (of 1)."
  64. # Contents:  MANIFEST Makefile README arp.c defs.h excelan.c
  65. #   getethers.8l if.c main.c ping.c sniffer.c vendors.c
  66. # Wrapped by vixie@gw.home.vix.com on Sat Apr 10 00:46:20 1993
  67. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  68. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  70. else
  71. echo shar: Extracting \"'MANIFEST'\" \(486 characters\)
  72. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  73. X   File Name        Archive #    Description
  74. X-----------------------------------------------------------
  75. X MANIFEST                   1    This shipping list
  76. X Makefile                   1    
  77. X README                     1    
  78. X arp.c                      1    
  79. X defs.h                     1    
  80. X excelan.c                  1    
  81. X getethers.8l               1    
  82. X if.c                       1    
  83. X main.c                     1    
  84. X ping.c                     1    
  85. X sniffer.c                  1    
  86. X vendors.c                  1    
  87. END_OF_FILE
  88. if test 486 -ne `wc -c <'MANIFEST'`; then
  89.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  90. fi
  91. # end of 'MANIFEST'
  92. fi
  93. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  94.   echo shar: Will not clobber existing file \"'Makefile'\"
  95. else
  96. echo shar: Extracting \"'Makefile'\" \(952 characters\)
  97. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  98. X#
  99. X# $Header: /usr/src/ecn/getethers/RCS/Makefile,v 1.4 92/05/08 14:15:36 davy Exp $
  100. X#
  101. X# Makefile for getethers.
  102. X#
  103. X# David A. Curry
  104. X# Purdue University
  105. X# Engineering Computer Network
  106. X# davy@ecn.purdue.edu
  107. X# November, 1991
  108. X#
  109. X#BINDIR=    /usr/ecn/etc
  110. BINDIR=    /usr/local/etc
  111. X#MANDIR=    /usr/man/man8
  112. MANDIR=    /usr/local/man/man8
  113. X
  114. X#
  115. X# Add -DNEED_STRDUP if you don't have the strdup() library routine.
  116. X# Add -DNEED_ENTOA  if you don'y have the ether_ntoa() library routine.
  117. X#
  118. DEFS=
  119. CFLAGS=    -O $(DEFS)
  120. X
  121. OBJS=    arp.o excelan.o if.o main.o ping.o sniffer.o vendors.o
  122. X
  123. getethers: $(OBJS)
  124. X    $(CC) -o getethers $(OBJS)
  125. X
  126. install: getethers
  127. X    install -c -s -m 4750 -o root -g wheel getethers $(BINDIR)/getethers
  128. X    install -c -m 644 getethers.8l $(MANDIR)/getethers.8l
  129. X
  130. clean:
  131. X    rm -f a.out core getethers *.o \#*
  132. X
  133. arp.o:        arp.c defs.h
  134. excelan.o:    excelan.c defs.h
  135. main.o:        main.c defs.h
  136. if.o:        if.c defs.h
  137. ping.o:        ping.c
  138. sniffer.o:    sniffer.c defs.h
  139. vendors.o:    vendors.c defs.h
  140. END_OF_FILE
  141. if test 952 -ne `wc -c <'Makefile'`; then
  142.     echo shar: \"'Makefile'\" unpacked with wrong size!
  143. fi
  144. # end of 'Makefile'
  145. fi
  146. if test -f 'README' -a "${1}" != "-c" ; then 
  147.   echo shar: Will not clobber existing file \"'README'\"
  148. else
  149. echo shar: Extracting \"'README'\" \(1667 characters\)
  150. sed "s/^X//" >'README' <<'END_OF_FILE'
  151. X                            May, 1992
  152. X
  153. This is GETETHERS Version 1.4.
  154. X
  155. New functionality since the 1.0 release in 11/91:
  156. X
  157. X    - Thanks to Ric Anderson (ric@cs.arizona.edu), you can now write
  158. X      Network General Sniffer data files as well as Excelan Lanalyzer
  159. X      files.  The file format is selected with the -e and -s options
  160. X      in conjunction with -w.
  161. X
  162. X    - Thanks to Peter Shipley (shipley@tfs.com), when the -v option is
  163. X      given, vendor names for the discovered ethernet addresses are
  164. X      now printed as well as the previously printed data.
  165. X
  166. X    - Thanks to Peter again, GETETHERS can now be compiled and run on
  167. X      pretty much any 4.3BSD system.  It will *not* obtain the ethernet
  168. X      address of the local host unless you're running on a Sun (4.3BSD
  169. X      does not provide a way to do this).
  170. X
  171. X    - GETETHERS will no longer exit if it bumps into an interface not
  172. X      supported by the Network Interface Tap (e.g., Sun X.25 interfaces).
  173. X
  174. If you don't know what GETETHERS is:
  175. X
  176. GETETHERS runs through all the addresses on an ethernet (a.b.c.1 - a.b.c.254)
  177. and pings each address, and then determines the ethernet address for that
  178. host.  It produces a list, either in ASCII or in the binary format for an
  179. XExcelan Lanalyzer, of hostname/ethernet address pairs for all hosts on that
  180. network.
  181. X
  182. This program has been tested on Sun workstations under SunOS 4.1.1, and on
  183. DEC Vaxes under 4.3BSD.  It should be relatively easy to port to any system
  184. with BSD-style networking.  Mostly you need to work on if.c a bit, and maybe
  185. on arp.c.
  186. X
  187. If you make modifications or fixes, please send them to me for incorporation
  188. into future versions.
  189. X
  190. Dave Curry
  191. Purdue University
  192. XEngineering Computer Network
  193. davy@ecn.purdue.edu
  194. END_OF_FILE
  195. if test 1667 -ne `wc -c <'README'`; then
  196.     echo shar: \"'README'\" unpacked with wrong size!
  197. fi
  198. # end of 'README'
  199. fi
  200. if test -f 'arp.c' -a "${1}" != "-c" ; then 
  201.   echo shar: Will not clobber existing file \"'arp.c'\"
  202. else
  203. echo shar: Extracting \"'arp.c'\" \(2182 characters\)
  204. sed "s/^X//" >'arp.c' <<'END_OF_FILE'
  205. X#ifndef lint
  206. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/arp.c,v 1.3 92/05/08 14:15:55 davy Exp $";
  207. X#endif
  208. X
  209. X/*
  210. X * arp.c - routines for digging up arp table entries.
  211. X *
  212. X * David A. Curry
  213. X * Purdue University
  214. X * Engineering Computer Network
  215. X * davy@ecn.purdue.edu
  216. X * November, 1991
  217. X *
  218. X * $Log:    arp.c,v $
  219. X * Revision 1.3  92/05/08  14:15:55  davy
  220. X * Made portable to 4.3BSD, from Peter Shipley (shipley@tfs.com).
  221. X * 
  222. X * Revision 1.2  92/05/08  13:06:31  davy
  223. X * Added vendor name printing from Peter Shipley (shipley@tfs.com).
  224. X * 
  225. X * Revision 1.1  91/11/27  10:56:13  davy
  226. X * Initial revision
  227. X * 
  228. X */
  229. X#include <sys/param.h>
  230. X#include <sys/socket.h>
  231. X#include <netinet/in.h>
  232. X#include <sys/ioctl.h>
  233. X#include <net/if.h>
  234. X#ifdef sun
  235. X#include <net/if_arp.h>
  236. X#endif
  237. X#include <netinet/if_ether.h>
  238. X#include <string.h>
  239. X#include <errno.h>
  240. X#include <stdio.h>
  241. X#include "defs.h"
  242. X
  243. extern int errno;
  244. X
  245. X/*
  246. X * get_arp - get the arp table entry for the internet address in addr, and
  247. X *         return the ethernet address as a character string.
  248. X */
  249. char *
  250. get_arp(addr, vname)
  251. struct in_addr addr;
  252. char **vname;
  253. X{
  254. X    int s;
  255. X    struct arpreq ar;
  256. X    struct sockaddr_in *sin;
  257. X    char *ether_ntoa(), *vendor_name();
  258. X
  259. X    /*
  260. X     * Clear the structure.
  261. X     */
  262. X    bzero((char *) &ar, sizeof(struct arpreq));
  263. X
  264. X    /*
  265. X     * We want internet family only.
  266. X     */
  267. X    ar.arp_pa.sa_family = AF_INET;
  268. X    sin = (struct sockaddr_in *) &ar.arp_pa;
  269. X
  270. X    /*
  271. X     * Copy in the internet address.
  272. X     */
  273. X    sin->sin_family = AF_INET;
  274. X    bcopy((char *) &addr, (char *) &sin->sin_addr, sizeof(struct in_addr));
  275. X
  276. X    /*
  277. X     * Get a socket.
  278. X     */
  279. X    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
  280. X        error("socket");
  281. X        return(strdup("(unknown)"));
  282. X    }
  283. X
  284. X    /*
  285. X     * Get the arp table entry.
  286. X     */
  287. X    if (ioctl(s, SIOCGARP, (char *) &ar) < 0) {
  288. X        /*
  289. X         * Nothing in the table.
  290. X         */
  291. X        if (errno == ENXIO) {
  292. X            close(s);
  293. X            return(strdup("(no entry)"));
  294. X        }
  295. X
  296. X        error("ioctl: SIOCGARP");
  297. X        close(s);
  298. X
  299. X        return("(unknown)");
  300. X    }
  301. X
  302. X    close(s);
  303. X
  304. X    /*
  305. X     * Is the entry complete?
  306. X     */
  307. X    if (ar.arp_flags & ATF_COM) {
  308. X        *vname = vendor_name((struct ether_addr *) ar.arp_ha.sa_data);
  309. X        return(strdup(ether_ntoa((struct ether_addr *) ar.arp_ha.sa_data)));
  310. X    }
  311. X
  312. X    return(strdup("(incomplete)"));
  313. X}
  314. END_OF_FILE
  315. if test 2182 -ne `wc -c <'arp.c'`; then
  316.     echo shar: \"'arp.c'\" unpacked with wrong size!
  317. fi
  318. # end of 'arp.c'
  319. fi
  320. if test -f 'defs.h' -a "${1}" != "-c" ; then 
  321.   echo shar: Will not clobber existing file \"'defs.h'\"
  322. else
  323. echo shar: Extracting \"'defs.h'\" \(1660 characters\)
  324. sed "s/^X//" >'defs.h' <<'END_OF_FILE'
  325. X/*
  326. X * $Header: /usr/src/ecn/getethers/RCS/defs.h,v 1.5 92/05/08 14:18:38 davy Exp $
  327. X *
  328. X * Definitions for getethers.
  329. X *
  330. X * David A. Curry
  331. X * Purdue University
  332. X * Engineering Computer Network
  333. X * davy@ecn.purdue.edu
  334. X * November, 1991
  335. X *
  336. X * $Log:    defs.h,v $
  337. X * Revision 1.5  92/05/08  14:18:38  davy
  338. X * Fix from David Ferbrache (ferbrache@ajaz.rsre.mod.uk) for passing over
  339. X * non-Ethernet links.
  340. X * 
  341. X * Revision 1.4  92/05/08  14:15:57  davy
  342. X * Made portable to 4.3BSD, from Peter Shipley (shipley@tfs.com).
  343. X * 
  344. X * Revision 1.3  92/05/08  13:06:33  davy
  345. X * Added vendor name printing from Peter Shipley (shipley@tfs.com).
  346. X * 
  347. X * Revision 1.2  92/05/08  10:54:43  davy
  348. X * Added changes to dump Sniffer format files from Ric Anderson,
  349. X * ric@cs.arizona.edu.
  350. X * 
  351. X * Revision 1.1  91/11/27  10:56:28  davy
  352. X * Initial revision
  353. X * 
  354. X */
  355. X#define VERSION        1.4
  356. X
  357. X#define MAXHOST        256        /* max number of hosts to check    */
  358. X#define MINADDR        1        /* minimum host number        */
  359. X#define MAXADDR        254        /* maximum host number        */
  360. X#define MAXPING        3        /* max number of pings to send    */
  361. X#define PACKWAIT    1        /* min time to wait for packet    */
  362. X#define MAXPACKET    4096        /* max packet size for ping    */
  363. X#define FILESIZE    2584        /* size of lanalyzer file    */
  364. X
  365. X/*
  366. X * Analyzer file output types.
  367. X */
  368. X#define EXCELAN        1
  369. X#define SNIFFER        2
  370. X
  371. X/*
  372. X * Record for a host.
  373. X */
  374. typedef struct {
  375. X    char    *hl_name;        /* host name            */
  376. X    char    *hl_inet;        /* internet address        */
  377. X    char    *hl_ether;        /* ethernet address        */
  378. X    char    *hl_vname;        /* vendor name            */
  379. X} HostInfo;
  380. X
  381. X#ifdef NEED_ENTOA
  382. struct ether_addr {
  383. X        u_char  ether_addr_octet[6];
  384. X};
  385. X
  386. char    *ether_ntoa();
  387. X#endif
  388. X
  389. X#ifdef NEED_STRDUP
  390. char    *strdup();
  391. X#endif
  392. END_OF_FILE
  393. if test 1660 -ne `wc -c <'defs.h'`; then
  394.     echo shar: \"'defs.h'\" unpacked with wrong size!
  395. fi
  396. # end of 'defs.h'
  397. fi
  398. if test -f 'excelan.c' -a "${1}" != "-c" ; then 
  399.   echo shar: Will not clobber existing file \"'excelan.c'\"
  400. else
  401. echo shar: Extracting \"'excelan.c'\" \(1748 characters\)
  402. sed "s/^X//" >'excelan.c' <<'END_OF_FILE'
  403. X#ifndef lint
  404. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/excelan.c,v 1.1 91/11/27 10:56:30 davy Exp $";
  405. X#endif
  406. X
  407. X/*
  408. X * excelan.c - routines to write lanalyzer files.
  409. X *
  410. X * David A. Curry
  411. X * Purdue University
  412. X * Engineering Computer Network
  413. X * davy@ecn.purdue.edu
  414. X * November, 1991
  415. X *
  416. X * $Log:    excelan.c,v $
  417. X * Revision 1.1  91/11/27  10:56:30  davy
  418. X * Initial revision
  419. X * 
  420. X */
  421. X#include <sys/param.h>
  422. X#include <sys/socket.h>
  423. X#include <net/if.h>
  424. X#include <netinet/in.h>
  425. X#include <netinet/if_ether.h>
  426. X#include <stdio.h>
  427. X#include "defs.h"
  428. X
  429. int nbytes;                /* number of bytes written    */
  430. X
  431. X/*
  432. X * excelan_header - put out the mysterious crap at the top of the file.
  433. X */
  434. excelan_header(fp)
  435. XFILE *fp;
  436. X{
  437. X    int i;
  438. X
  439. X    fwrite(" \20L\0\01\01", 1, 6, fp);
  440. X    fwrite("Excelan host name file", 1, 22, fp);
  441. X
  442. X    for (i = 0; i < 52; i++)
  443. X        fputc('\0', fp);
  444. X
  445. X    fwrite("!\20\304\t", 1, 4, fp);
  446. X
  447. X    nbytes = 84;
  448. X}
  449. X
  450. X/*
  451. X * excelan_entry - write out an ethernet address/hostname pair.
  452. X */
  453. excelan_entry(h, fp)
  454. HostInfo *h;
  455. XFILE *fp;
  456. X{
  457. X    int i;
  458. X    register char *p;
  459. X    struct ether_addr *ea, *ether_aton();
  460. X
  461. X    /*
  462. X     * Magic.
  463. X     */
  464. X    fputc('\31', fp);
  465. X
  466. X    /*
  467. X     * Write the ethernet address.
  468. X     */
  469. X    ea = ether_aton(h->hl_ether);
  470. X    fwrite(ea, 1, 6, fp);
  471. X
  472. X    /*
  473. X     * Put the hostname.
  474. X     */
  475. X    for (i=0, p=h->hl_name; (i < 18) && (*p != '.'); i++, p++)
  476. X        fputc(*p, fp);
  477. X
  478. X    /*
  479. X     * Pad with nulls.
  480. X     */
  481. X    for (; i < 18; i++)
  482. X        fputc('\0', fp);
  483. X
  484. X    nbytes += 25;
  485. X}
  486. X
  487. X/*
  488. X * excelan_footer - pad the file to FILESIZE bytes.
  489. X */
  490. excelan_footer(fp)
  491. XFILE *fp;
  492. X{
  493. X    /*
  494. X     * Put out the broadcast address.
  495. X     */
  496. X    fputc('\31', fp);
  497. X    fwrite("\377\377\377\377\377\377", 1, 6, fp);
  498. X    fwrite("BROADCAST\0", 1, 10, fp);
  499. X
  500. X    nbytes += 17;
  501. X
  502. X    /*
  503. X     * Pad the file.
  504. X     */
  505. X    for (; nbytes < FILESIZE; nbytes++)
  506. X        fputc('\0', fp);
  507. X}
  508. END_OF_FILE
  509. if test 1748 -ne `wc -c <'excelan.c'`; then
  510.     echo shar: \"'excelan.c'\" unpacked with wrong size!
  511. fi
  512. # end of 'excelan.c'
  513. fi
  514. if test -f 'getethers.8l' -a "${1}" != "-c" ; then 
  515.   echo shar: Will not clobber existing file \"'getethers.8l'\"
  516. else
  517. echo shar: Extracting \"'getethers.8l'\" \(2569 characters\)
  518. sed "s/^X//" >'getethers.8l' <<'END_OF_FILE'
  519. X.TH GETETHERS 8L "27 November 1991" "ECN"
  520. X.SH NAME
  521. getethers \- get ethernet address/hostname information
  522. X.SH SYNOPSIS
  523. X.B getethers
  524. X[
  525. X.B \-e
  526. X] [
  527. X.B \-s
  528. X] [
  529. X.B \-v
  530. X] [
  531. X.B \-w
  532. X]
  533. X.I net
  534. X[
  535. X.IR net ...
  536. X]
  537. X.SH DESCRIPTION
  538. X.PP
  539. X.B getethers
  540. probes the specified network(s),
  541. whose addresses are given in Internet ``dot'' notation,
  542. and produces a list of host name and ethernet address pairs for each host
  543. on the network that responds to ICMP ECHO_REQUEST packets.
  544. The program assumes a subnet mask of 255.255.255.0 (0xffffff00),
  545. and does not probe host number 0 or host number 255,
  546. which are used as the broadcast address.
  547. X.PP
  548. If the
  549. X.B \-v
  550. option is specified,
  551. a list is produced on the standard output that contains the host name,
  552. internet address,
  553. ethernet address,
  554. and vendor name of the ethernet board for each host that responded to
  555. ICMP ECHO_REQUEST packets.
  556. X.PP
  557. If the
  558. X.B \-w
  559. option is specified,
  560. along with either the
  561. X.B \-e
  562. or
  563. X.B \-s
  564. options,
  565. a file will be written for each network that can be used with the Excelan
  566. Lanalyzer (\fB\-e\fP)
  567. or Network General Sniffer (\fB\-s\fP)
  568. products as a name-to-address translation file.
  569. The name of the file will be
  570. X.IR XXXnet.nam ,
  571. where
  572. X.I XXX
  573. is the last byte of the network address.
  574. X.PP
  575. X.B getethers
  576. works by first probing the system's ethernet interfaces,
  577. looking for the interface that is connected to the specified network.
  578. If the system is not connected to that network,
  579. X.B getethers
  580. prints an error message and goes on to the next network.
  581. After discovering the proper interface,
  582. X.B getethers
  583. sends up to three ICMP ECHO_REQUEST packets to each host number on that
  584. network from 1 to 254.
  585. If the host responds,
  586. X.B getethers
  587. then searches the local host's arp table for the remote host's ethernet
  588. address.
  589. If the remote host does not respond to the ECHO_REQUEST packets within
  590. three seconds,
  591. it is assumed to be down or non-existent,
  592. and is skipped.
  593. X.SH SEE ALSO
  594. X.BR arp (4P),
  595. X.BR arp (8C),
  596. X.BR etherfind (8C),
  597. X.BR ethers (3N),
  598. X.BR icmp (4P),
  599. X.BR inet (3N),
  600. X.BR nit (4P),
  601. X.BR ping (8C),
  602. X.BR rarpd (8C)
  603. X.SH BUGS
  604. X.PP
  605. The assumption of a 255.255.255.0 subnet mask,
  606. and the assumption of all-zero or all-ones as a broadcast address,
  607. are probably not good ideas and should be determined at run-time,
  608. but it works in our environment.
  609. X.PP
  610. The Lanalyzer file,
  611. due to its fixed size,
  612. cannot handle more than 100 entries.
  613. If a network has more than 100 hosts connected (and up),
  614. the file will not be usable (or at least the stuff after 100 entries won't
  615. be).
  616. X.SH AUTHOR
  617. David A. Curry, Purdue University Engineering Computer Network
  618. END_OF_FILE
  619. if test 2569 -ne `wc -c <'getethers.8l'`; then
  620.     echo shar: \"'getethers.8l'\" unpacked with wrong size!
  621. fi
  622. # end of 'getethers.8l'
  623. fi
  624. if test -f 'if.c' -a "${1}" != "-c" ; then 
  625.   echo shar: Will not clobber existing file \"'if.c'\"
  626. else
  627. echo shar: Extracting \"'if.c'\" \(3917 characters\)
  628. sed "s/^X//" >'if.c' <<'END_OF_FILE'
  629. X#ifndef lint
  630. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/if.c,v 1.4 92/05/08 14:19:29 davy Exp $";
  631. X#endif
  632. X
  633. X/*
  634. X * if.c - routines to check a system's ethernet interfaces.
  635. X *
  636. X * David A. Curry
  637. X * Purdue University
  638. X * Engineering Computer Network
  639. X * davy@ecn.purdue.edu
  640. X * November, 1991
  641. X *
  642. X * $Log:    if.c,v $
  643. X * Revision 1.4  92/05/08  14:19:29  davy
  644. X * Fix from David Ferbrache (ferbrache@ajaz.rsre.mod.uk) for passing over
  645. X * non-Ethernet links.
  646. X * 
  647. X * Revision 1.3  92/05/08  14:15:58  davy
  648. X * Made portable to 4.3BSD, from Peter Shipley (shipley@tfs.com).
  649. X * 
  650. X * Revision 1.2  92/05/08  13:06:36  davy
  651. X * Added vendor name printing from Peter Shipley (shipley@tfs.com).
  652. X * 
  653. X * Revision 1.1  91/11/27  10:56:31  davy
  654. X * Initial revision
  655. X * 
  656. X */
  657. X#ifdef sun
  658. X
  659. X#include <sys/param.h>
  660. X#include <sys/socket.h>
  661. X#include <netinet/in.h>
  662. X#include <arpa/inet.h>
  663. X#include <sys/ioctl.h>
  664. X#include <sys/time.h>
  665. X#include <sys/file.h>
  666. X#include <net/if.h>
  667. X#include <net/nit_if.h>
  668. X#include <netinet/if_ether.h>
  669. X#include <string.h>
  670. X#include <stdio.h>
  671. X#include "defs.h"
  672. X
  673. X/*
  674. X * check_if - check our ethernet interfaces and find the one that's attached
  675. X *          to the network in addr.
  676. X */
  677. check_if(addr, hosts)
  678. struct in_addr addr;
  679. HostInfo *hosts;
  680. X{
  681. X    int n, s, lna;
  682. X    char buf[BUFSIZ];
  683. X    struct ifreq ifr;
  684. X    struct ifconf ifc;
  685. X    char *vendor_name();
  686. X    struct sockaddr *sad;
  687. X    struct sockaddr_in *sin;
  688. X    register struct ifreq *ifrp;
  689. X
  690. X    /*
  691. X     * Need a socket...
  692. X     */
  693. X    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
  694. X        error("socket");
  695. X        return(-1);
  696. X    }
  697. X
  698. X    ifc.ifc_buf = buf;
  699. X    ifc.ifc_len = sizeof(buf);
  700. X
  701. X    /*
  702. X     * Get the list of configured interfaces.
  703. X     */
  704. X    if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) {
  705. X        error("ioctl: SIOCGIFCONF");
  706. X        close(s);
  707. X
  708. X        return(-1);
  709. X    }
  710. X
  711. X    close(s);
  712. X
  713. X    /*
  714. X     * For each interface...
  715. X     */
  716. X    ifrp = ifc.ifc_req;
  717. X    for (n = ifc.ifc_len/sizeof(struct ifreq); n > 0; n--, ifrp++) {
  718. X        bcopy((char *) ifrp, (char *) &ifr, sizeof(struct ifreq));
  719. X
  720. X        /*
  721. X         * Need a new socket.
  722. X         */
  723. X        if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
  724. X            error("socket");
  725. X            return(-1);
  726. X        }
  727. X
  728. X        /*
  729. X         * Get the address of this interface.
  730. X         */
  731. X        if (ioctl(s, SIOCGIFADDR, (char *) &ifr) < 0) {
  732. X            error("ioctl: SIOCGIFADDR");
  733. X            close(s);
  734. X            
  735. X            continue;
  736. X        }
  737. X
  738. X        close(s);
  739. X
  740. X        sin = (struct sockaddr_in *) &ifr.ifr_addr;
  741. X
  742. X        /*
  743. X         * If it's not the one we need, bag it.
  744. X         */
  745. X        if ((sin->sin_addr.s_addr & addr.s_addr) != addr.s_addr)
  746. X            continue;
  747. X
  748. X        /*
  749. X         * Save the internet address, and keep the host byte.
  750. X         * We are assuming a netmask of 255.255.255.0 here.
  751. X         */
  752. X        lna = inet_lnaof(sin->sin_addr) & 0xff;
  753. X        hosts[lna].hl_inet = strdup(inet_ntoa(sin->sin_addr));
  754. X
  755. X        /*
  756. X         * Now we need the NIT, to get the ethernet address.
  757. X         */
  758. X        if ((s = open("/dev/nit", O_RDONLY)) < 0) {
  759. X            error("open: /dev/nit");
  760. X            return(-1);
  761. X        }
  762. X
  763. X        /*
  764. X         * Bind the nit to this interface.
  765. X         */
  766. X        if (ioctl(s, NIOCBIND, (char *) ifrp) < 0) {
  767. X            error("ioctl: NIOCBIND");
  768. X            close(s);
  769. X
  770. X            return(-1);
  771. X        }
  772. X
  773. X        /*
  774. X         * Get the address.
  775. X         */
  776. X        if (ioctl(s, SIOCGIFADDR, (char *) ifrp) < 0) {
  777. X            error("ioctl: SIOCGIFADDR");
  778. X            close(s);
  779. X
  780. X            continue;
  781. X        }
  782. X
  783. X        close(s);
  784. X
  785. X        /*
  786. X         * Save the ethernet address.
  787. X         */
  788. X        sad = (struct sockaddr *) &ifrp->ifr_addr;
  789. X        hosts[lna].hl_ether = strdup(ether_ntoa((struct ether_addr *)
  790. X                            sad->sa_data));
  791. X        hosts[lna].hl_vname = vendor_name((struct ether_addr *)
  792. X                          sad->sa_data);
  793. X
  794. X        return(lna);
  795. X    }
  796. X
  797. X    return(-1);
  798. X}
  799. X
  800. X#else
  801. X
  802. X#include <sys/param.h>
  803. X#include <netinet/in.h>
  804. X#include <netdb.h>
  805. X#include "defs.h"
  806. X
  807. check_if(addr, hosts)
  808. struct in_addr addr;
  809. HostInfo *hosts;
  810. X{
  811. X    int lna;
  812. X    char hn[256];
  813. X    struct hostent *hp;
  814. X    extern char *strdup();
  815. X
  816. X    (void) gethostname(hn, sizeof(hn));
  817. X
  818. X    hp = gethostbyname(hn);
  819. X
  820. X    lna = inet_lnaof(hp->h_addr) & 0xff;
  821. X    hosts[lna].hl_inet = strdup(inet_ntoa(hp->h_addr));
  822. X    hosts[lna].hl_name = strdup(hp->h_name);
  823. X    hosts[lna].hl_ether = "???";
  824. X    hosts[lna].hl_vname = "???";
  825. X    return(0);
  826. X}
  827. X
  828. X#endif
  829. END_OF_FILE
  830. if test 3917 -ne `wc -c <'if.c'`; then
  831.     echo shar: \"'if.c'\" unpacked with wrong size!
  832. fi
  833. # end of 'if.c'
  834. fi
  835. if test -f 'main.c' -a "${1}" != "-c" ; then 
  836.   echo shar: Will not clobber existing file \"'main.c'\"
  837. else
  838. echo shar: Extracting \"'main.c'\" \(6625 characters\)
  839. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  840. X#ifndef lint
  841. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/main.c,v 1.4 92/05/08 14:15:59 davy Exp $";
  842. X#endif
  843. X/*
  844. X * getethers - get hostname/ethernet address information for all hosts on
  845. X *           an ethernet.
  846. X *
  847. X * David A. Curry
  848. X * Purdue University
  849. X * Engineering Computer Network
  850. X * davy@ecn.purdue.edu
  851. X * November, 1991
  852. X *
  853. X * $Log:    main.c,v $
  854. X * Revision 1.4  92/05/08  14:15:59  davy
  855. X * Made portable to 4.3BSD, from Peter Shipley (shipley@tfs.com).
  856. X * 
  857. X * Revision 1.3  92/05/08  13:06:38  davy
  858. X * Added vendor name printing from Peter Shipley (shipley@tfs.com).
  859. X * 
  860. X * Revision 1.2  92/05/08  09:27:48  davy
  861. X * Added changes to dump Sniffer format files from Ric Anderson,
  862. X * ric@cs.arizona.edu.
  863. X * 
  864. X * Revision 1.1  91/11/27  10:56:32  davy
  865. X * Initial revision
  866. X * 
  867. X */
  868. X#include <sys/param.h>
  869. X#include <sys/socket.h>
  870. X#include <netinet/in.h>
  871. X#include <arpa/inet.h>
  872. X#include <string.h>
  873. X#include <netdb.h>
  874. X#include <stdio.h>
  875. X#include "defs.h"
  876. X
  877. char    *pname;
  878. X
  879. main(argc, argv)
  880. char **argv;
  881. int argc;
  882. X{
  883. X    char *p;
  884. X    FILE *fp;
  885. X    char *vname;
  886. X    u_long network;
  887. X    struct hostent *hp;
  888. X    struct in_addr addr;
  889. X    HostInfo hosts[MAXHOST];
  890. X    char hname[64], fname[BUFSIZ];
  891. X    char *get_arp(), *strip_domain();
  892. X    int analyzer_type, lna, verbose, writefile;
  893. X
  894. X    pname = *argv;
  895. X    analyzer_type = verbose = writefile = 0;
  896. X
  897. X    if (argc < 2)
  898. X        usage();
  899. X
  900. X    /*
  901. X     * Get our hostname.
  902. X     */
  903. X    if (gethostname(hname, sizeof(hname)) < 0) {
  904. X        error("gethostname");
  905. X        exit(1);
  906. X    }
  907. X
  908. X    /*
  909. X     * Process arguments.
  910. X     */
  911. X    while (--argc) {
  912. X        /*
  913. X         * Option.
  914. X         */
  915. X        if (**++argv == '-') {
  916. X            switch (*++*argv) {
  917. X            case 'e':            /* excelan    */
  918. X                analyzer_type = EXCELAN;
  919. X                break;
  920. X            case 's':            /* sniffer    */
  921. X                analyzer_type = SNIFFER;
  922. X                break;
  923. X            case 'v':            /* verbose    */
  924. X                verbose = 1;
  925. X                break;
  926. X            case 'w':            /* write files    */
  927. X                writefile = 1;
  928. X                break;
  929. X            default:
  930. X                usage();
  931. X                break;
  932. X            }
  933. X
  934. X            continue;
  935. X        }
  936. X
  937. X        /*
  938. X         * Do *something*.
  939. X         */
  940. X        if (!verbose && !writefile)
  941. X            verbose = 1;
  942. X
  943. X        /*
  944. X         * Just so they know.
  945. X         */
  946. X        if (writefile && !analyzer_type) {
  947. X            fprintf(stderr, "%s: -w with no format; excelan format assumed.\n",
  948. X                pname);
  949. X            analyzer_type = EXCELAN;
  950. X        }
  951. X
  952. X        /*
  953. X         * Convert the given network address to an internet
  954. X         * address.
  955. X         */
  956. X        network = inet_network(*argv);
  957. X        addr = inet_makeaddr(network, 0);
  958. X        bzero(hosts, sizeof(hosts));
  959. X
  960. X        /*
  961. X         * Find the ethernet interface that's on that network.
  962. X         */
  963. X        if ((lna = check_if(addr, hosts)) < 0) {
  964. X            fprintf(stderr, "%s: this host is not on the %s net.\n",
  965. X                pname, inet_ntoa(addr));
  966. X            continue;
  967. X        }
  968. X
  969. X        /*
  970. X         * Save our hostname.  check_if() filled in our
  971. X         * internet address and ethernet address.
  972. X         */
  973. X        hosts[lna].hl_name = strip_domain(hname);
  974. X
  975. X        if (verbose)
  976. X            printf("%s:\n    ", *argv);
  977. X
  978. X        /*
  979. X         * For each host...
  980. X         */
  981. X        for (lna = MINADDR; lna <= MAXADDR; lna++) {
  982. X            if ((verbose == 1) && ((lna % 16) == 0)) {
  983. X                printf("%d...", lna);
  984. X                fflush(stdout);
  985. X            }
  986. X
  987. X            /*
  988. X             * Skip our entry; we did it already.
  989. X             */
  990. X            if (hosts[lna].hl_name != NULL)
  991. X                continue;
  992. X
  993. X            /*
  994. X             * Build the internet address.
  995. X             */
  996. X            addr = inet_makeaddr(network, lna);
  997. X
  998. X            /*
  999. X             * Ping it, and if it's up...
  1000. X             */
  1001. X            if (ping(addr, lna)) {
  1002. X                /*
  1003. X                 * Get the hostname.
  1004. X                 */
  1005. X                hp = gethostbyaddr(&addr.s_addr,
  1006. X                           sizeof(addr.s_addr),
  1007. X                           AF_INET);
  1008. X
  1009. X                /*
  1010. X                 * Save the hostname.
  1011. X                 */
  1012. X                if (hp != NULL)
  1013. X                    hosts[lna].hl_name =
  1014. X                        strip_domain(hp->h_name);
  1015. X                else
  1016. X                    hosts[lna].hl_name = strdup("???");
  1017. X
  1018. X                /*
  1019. X                 * Save the internet address and get the
  1020. X                 * ethernet address from the arp table.
  1021. X                 */
  1022. X                hosts[lna].hl_inet = strdup(inet_ntoa(addr));
  1023. X                hosts[lna].hl_ether = get_arp(addr, &vname);
  1024. X                hosts[lna].hl_vname = vname;
  1025. X            }
  1026. X        }
  1027. X
  1028. X        if (verbose)
  1029. X            putchar('\n');
  1030. X
  1031. X        /*
  1032. X         * If we need to write files, create the file for this
  1033. X         * network.
  1034. X         */
  1035. X        if (writefile) {
  1036. X            p = strrchr(*argv, '.') + 1;
  1037. X            sprintf(fname, "%snet.nam", p);
  1038. X
  1039. X            if ((fp = fopen(fname, "w")) == NULL) {
  1040. X                error(fname);
  1041. X                exit(1);
  1042. X            }
  1043. X
  1044. X            switch (analyzer_type) {
  1045. X            case EXCELAN:
  1046. X                excelan_header(fp);
  1047. X                break;
  1048. X            case SNIFFER:
  1049. X                sniffer_header(fp);
  1050. X                break;
  1051. X            }
  1052. X        }
  1053. X            
  1054. X        if (verbose) {
  1055. X            printf("    Hostname       Internet Addr   ");
  1056. X            printf("  Ethernet Addr    Vendor Name\n");
  1057. X            printf("--------------------------");
  1058. X            printf("--------------------------");
  1059. X            printf("--------------------------\n");
  1060. X        }
  1061. X
  1062. X        /*
  1063. X         * Write or print each entry.
  1064. X         */
  1065. X        for (lna = MINADDR; lna <= MAXADDR; lna++) {
  1066. X            if (hosts[lna].hl_name == NULL)
  1067. X                continue;
  1068. X
  1069. X            if (writefile) {
  1070. X                switch (analyzer_type) {
  1071. X                case EXCELAN:
  1072. X                    excelan_entry(&hosts[lna], fp);
  1073. X                    break;
  1074. X                case SNIFFER:
  1075. X                    sniffer_entry(&hosts[lna], fp);
  1076. X                    break;
  1077. X                }
  1078. X            }
  1079. X                
  1080. X            if (verbose) {
  1081. X                printf("%-16.16s  %-15.15s  %-17.17s  %s\n",
  1082. X                       hosts[lna].hl_name, hosts[lna].hl_inet,
  1083. X                       hosts[lna].hl_ether,
  1084. X                       hosts[lna].hl_vname);
  1085. X            }
  1086. X
  1087. X            free(hosts[lna].hl_name);
  1088. X            free(hosts[lna].hl_inet);
  1089. X            free(hosts[lna].hl_ether);
  1090. X        }
  1091. X
  1092. X        /*
  1093. X         * Write a footer and close the file.
  1094. X         */
  1095. X        if (writefile) {
  1096. X            switch (analyzer_type) {
  1097. X            case EXCELAN:
  1098. X                excelan_footer(fp);
  1099. X                break;
  1100. X            case SNIFFER:
  1101. X                sniffer_footer(fp);
  1102. X                break;
  1103. X            }
  1104. X
  1105. X            fclose(fp);
  1106. X        }
  1107. X    }
  1108. X
  1109. X    exit(0);
  1110. X}
  1111. X
  1112. X/*
  1113. X * strip_domain - strip the domain name
  1114. X */
  1115. char *
  1116. strip_domain(name)
  1117. char *name;
  1118. X{
  1119. X    char *index();
  1120. X    register char *p;
  1121. X
  1122. X    if ((p = index(name, '.')) != NULL)
  1123. X        *p = '\0';
  1124. X
  1125. X    return(strdup(name));
  1126. X}
  1127. X
  1128. X#ifdef NEED_ENTOA
  1129. X
  1130. X#define ETHER_INDEX(i, j)   (unsigned int)(i->ether_addr_octet[(j)])
  1131. X
  1132. char *
  1133. ether_ntoa(ea)
  1134. struct ether_addr *ea;
  1135. X{
  1136. X    static char s[20];
  1137. X
  1138. X    s[0] = 0;
  1139. X    (void) sprintf(s, "%x:%x:%x:%x:%x:%x",
  1140. X               ETHER_INDEX(ea,0), ETHER_INDEX(ea,1), ETHER_INDEX(ea,2),
  1141. X               ETHER_INDEX(ea,3), ETHER_INDEX(ea,4), ETHER_INDEX(ea,5));
  1142. X    return (s);
  1143. X}
  1144. X
  1145. struct ether_addr *
  1146. ether_aton(s)
  1147. char *s;
  1148. X{
  1149. X    int i;
  1150. X    unsigned int t[6];
  1151. X    static struct ether_addr ep;
  1152. X
  1153. X    bzero(&ep, sizeof (struct ether_addr));
  1154. X
  1155. X    i = sscanf(s, " %x:%x:%x:%x:%x:%x",
  1156. X           &t[0], &t[1], &t[2], &t[3], &t[4], &t[5]);
  1157. X
  1158. X    if (i != 6)
  1159. X        return ((struct ether_addr *)NULL);
  1160. X
  1161. X    for (i = 0; i < 6; i++)
  1162. X        ep.ether_addr_octet[i] = t[i];
  1163. X
  1164. X    return (&ep);
  1165. X}
  1166. X#endif
  1167. X
  1168. X#ifdef NEED_STRDUP
  1169. char *
  1170. strdup(s)
  1171. char *s;
  1172. X{
  1173. X    char *p;
  1174. X    char *malloc();
  1175. X
  1176. X    if ((p = malloc(strlen(s)+1)) == NULL) {
  1177. X        fprintf(stderr, "%s: out of memory.\n", pname);
  1178. X        exit(1);
  1179. X    }
  1180. X
  1181. X    strcpy(p, s);
  1182. X    return(p);
  1183. X}
  1184. X#endif
  1185. X
  1186. X/*
  1187. X * error - perror with program name.
  1188. X */
  1189. error(s)
  1190. char *s;
  1191. X{
  1192. X    fprintf(stderr, "%s: ", pname);
  1193. X    perror(s);
  1194. X}
  1195. X
  1196. usage()
  1197. X{
  1198. X    fprintf(stderr, "Usage: %s [-v] [-w] network [network...]\n", pname);
  1199. X    exit(1);
  1200. X}
  1201. END_OF_FILE
  1202. if test 6625 -ne `wc -c <'main.c'`; then
  1203.     echo shar: \"'main.c'\" unpacked with wrong size!
  1204. fi
  1205. # end of 'main.c'
  1206. fi
  1207. if test -f 'ping.c' -a "${1}" != "-c" ; then 
  1208.   echo shar: Will not clobber existing file \"'ping.c'\"
  1209. else
  1210. echo shar: Extracting \"'ping.c'\" \(4244 characters\)
  1211. sed "s/^X//" >'ping.c' <<'END_OF_FILE'
  1212. X#ifndef lint
  1213. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/ping.c,v 1.2 92/05/08 14:16:01 davy Exp $";
  1214. X#endif
  1215. X
  1216. X/*
  1217. X * ping.c - routines for pinging a host.
  1218. X *
  1219. X * David A. Curry
  1220. X * Purdue University
  1221. X * Engineering Computer Network
  1222. X * davy@ecn.purdue.edu
  1223. X * November, 1991
  1224. X *
  1225. X * $Log:    ping.c,v $
  1226. X * Revision 1.2  92/05/08  14:16:01  davy
  1227. X * Made portable to 4.3BSD, from Peter Shipley (shipley@tfs.com).
  1228. X * 
  1229. X * Revision 1.1  91/11/27  10:56:33  davy
  1230. X * Initial revision
  1231. X * 
  1232. X */
  1233. X#include <sys/param.h>
  1234. X#include <sys/socket.h>
  1235. X#include <sys/file.h>
  1236. X#include <netinet/in_systm.h>
  1237. X#include <netinet/in.h>
  1238. X#include <netinet/ip.h>
  1239. X#include <netinet/ip_icmp.h>
  1240. X#include <signal.h>
  1241. X#include <setjmp.h>
  1242. X#include <netdb.h>
  1243. X#include <errno.h>
  1244. X#include <stdio.h>
  1245. X#include "defs.h"
  1246. X
  1247. static jmp_buf    env;
  1248. static int    ident;
  1249. static int    datalen = 64 - 8;
  1250. static u_char    inpacket[MAXPACKET], outpacket[MAXPACKET];
  1251. X
  1252. extern int    errno;
  1253. X
  1254. X/*
  1255. X * ping - send ICMP ECHO REQUEST packets to the host at addr until it either
  1256. X *      responds or we decide to bag it.  Most of this code was stolen and
  1257. X *      simplified from Mike Muuss' ping program.
  1258. X */
  1259. ping(addr, id)
  1260. struct in_addr addr;
  1261. int id;
  1262. X{
  1263. X    int ringring();
  1264. X    register int i, n, s;
  1265. X    int cc, hlen, fromlen;
  1266. X    register u_char *datap;
  1267. X    register struct ip *ip;
  1268. X    register struct icmp *icp;
  1269. X    struct sockaddr_in from, to;
  1270. X    static struct protoent *proto = NULL;
  1271. X
  1272. X    bzero((char *) &to, sizeof(struct in_addr));
  1273. X
  1274. X    /*
  1275. X     * Construct destination address.
  1276. X     */
  1277. X    to.sin_family = AF_INET;
  1278. X    bcopy((char *) &addr, (char *) &to.sin_addr, sizeof(struct in_addr));
  1279. X
  1280. X    /*
  1281. X     * ICMP ID number.
  1282. X     */
  1283. X    ident = (getpid() + id) & 0xFFFF;
  1284. X
  1285. X    /*
  1286. X     * Look up protocol number.
  1287. X     */
  1288. X    if (proto == NULL) {
  1289. X        if ((proto = getprotobyname("icmp")) == NULL) {
  1290. X            error("icmp: unknown protocol");
  1291. X            return(0);
  1292. X        }
  1293. X    }
  1294. X
  1295. X    /*
  1296. X     * Need a raw socket.
  1297. X     */
  1298. X    if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) {
  1299. X        error("socket");
  1300. X        return(0);
  1301. X    }
  1302. X
  1303. X    icp = (struct icmp *) outpacket;
  1304. X
  1305. X    /*
  1306. X     * Send up to MAXPING packets.
  1307. X     */
  1308. X    for (i=0; i < MAXPING; i++) {
  1309. X        /*
  1310. X         * Construct ICMP header.
  1311. X         */
  1312. X        icp->icmp_type = ICMP_ECHO;
  1313. X        icp->icmp_code = 0;
  1314. X        icp->icmp_cksum = 0;
  1315. X        icp->icmp_seq = i;
  1316. X        icp->icmp_id = ident;
  1317. X
  1318. X        /*
  1319. X         * Stick some junk in the packet.
  1320. X         */
  1321. X        cc = datalen + 8;
  1322. X        datap = &outpacket[8];
  1323. X
  1324. X        for (n = 0; n < datalen; n++)
  1325. X            *datap++ = n;
  1326. X
  1327. X        /*
  1328. X         * Compute the IP checksum.
  1329. X         */
  1330. X        icp->icmp_cksum = in_cksum(icp, cc);
  1331. X
  1332. X        /*
  1333. X         * Send the packet...
  1334. X         */
  1335. X        n = sendto(s, outpacket, cc, 0, &to, sizeof(struct sockaddr));
  1336. X
  1337. X        if ((n < 0) || (n != cc)) {
  1338. X            if (n < 0)
  1339. X                error("sendto");
  1340. X            else
  1341. X                error("sendto truncated");
  1342. X
  1343. X            close(s);
  1344. X            return(0);
  1345. X        }
  1346. X
  1347. X        /*
  1348. X         * We'll wait for PACKWAIT seconds for a response.
  1349. X         */
  1350. X        signal(SIGALRM, ringring);
  1351. X        fromlen = sizeof(struct sockaddr_in);
  1352. X
  1353. X        alarm(PACKWAIT);
  1354. X
  1355. X        /*
  1356. X         * Bag it... send the next packet.
  1357. X         */
  1358. X        if (setjmp(env))
  1359. X            continue;
  1360. X
  1361. X        /*
  1362. X         * Get the packet.
  1363. X         */
  1364. X        cc = recvfrom(s, inpacket, MAXPACKET, 0, &from, &fromlen);
  1365. X        alarm(0);
  1366. X
  1367. X        if (cc < 0) {
  1368. X            if (errno == EINTR)
  1369. X                continue;
  1370. X
  1371. X            error("recvfrom");
  1372. X            continue;
  1373. X        }
  1374. X
  1375. X        /*
  1376. X         * Make sure it's a reply to ours.
  1377. X         */
  1378. X        ip = (struct ip *) inpacket;
  1379. X        hlen = ip->ip_hl << 2;
  1380. X
  1381. X        if (cc < (hlen + ICMP_MINLEN))
  1382. X            continue;
  1383. X
  1384. X        cc -= hlen;
  1385. X        icp = (struct icmp *) (&inpacket[hlen]);
  1386. X
  1387. X        if (icp->icmp_type != ICMP_ECHOREPLY)
  1388. X            continue;
  1389. X
  1390. X        if (icp->icmp_id != ident)
  1391. X            continue;
  1392. X
  1393. X        /*
  1394. X         * Yay!  The host is up.
  1395. X         */
  1396. X        close(s);
  1397. X        return(1);
  1398. X    }
  1399. X
  1400. X    /*
  1401. X     * Boo!  The host is down.
  1402. X     */
  1403. X    close(s);
  1404. X    return(0);
  1405. X}
  1406. X
  1407. X/*
  1408. X * in_cksum - compute the IP checksum.
  1409. X */
  1410. in_cksum(addr, len)
  1411. u_short *addr;
  1412. int len;
  1413. X{
  1414. X    register u_short *w = addr;
  1415. X    register int nleft = len;
  1416. X    register u_short answer;
  1417. X    register int sum = 0;
  1418. X
  1419. X    /*
  1420. X     * Use a 32-bit accumulator (sum) and add sequential 16-bit
  1421. X     * words to it, then fold back all the carry bits from the
  1422. X     * top 16 bits into the lower 16 bits.
  1423. X     */
  1424. X    while (nleft > 1) {
  1425. X        sum += *w++;
  1426. X        nleft -= 2;
  1427. X    }
  1428. X
  1429. X    /*
  1430. X     * Pick up odd byte if necessary.
  1431. X     */
  1432. X    if (nleft == 1)
  1433. X        sum += *(u_char *) w;
  1434. X
  1435. X    /*
  1436. X     * Add back the carry bits.
  1437. X     */
  1438. X    sum = (sum >> 16) + (sum & 0xFFFF);
  1439. X    sum += (sum >> 16);
  1440. X
  1441. X    /*
  1442. X     * Truncate to 16 bits.
  1443. X     */
  1444. X    answer = ~sum;
  1445. X
  1446. X    return(answer);
  1447. X}
  1448. X
  1449. ringring()
  1450. X{
  1451. X    longjmp(env, 1);
  1452. X}
  1453. END_OF_FILE
  1454. if test 4244 -ne `wc -c <'ping.c'`; then
  1455.     echo shar: \"'ping.c'\" unpacked with wrong size!
  1456. fi
  1457. # end of 'ping.c'
  1458. fi
  1459. if test -f 'sniffer.c' -a "${1}" != "-c" ; then 
  1460.   echo shar: Will not clobber existing file \"'sniffer.c'\"
  1461. else
  1462. echo shar: Extracting \"'sniffer.c'\" \(2787 characters\)
  1463. sed "s/^X//" >'sniffer.c' <<'END_OF_FILE'
  1464. X#ifndef lint
  1465. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/sniffer.c,v 1.1 92/05/08 09:27:49 davy Exp $";
  1466. X#endif
  1467. X/*
  1468. X * sniffer.c - routines to write Network General Sniffer files.
  1469. X *
  1470. X * Ric Anderson
  1471. X * University of Arizona
  1472. X * ric@cs.arizona.edu
  1473. X *
  1474. X * $Log:    sniffer.c,v $
  1475. X * Revision 1.1  92/05/08  09:27:49  davy
  1476. X * Initial revision
  1477. X * 
  1478. X */
  1479. X#include <sys/param.h>
  1480. X#include <sys/socket.h>
  1481. X#include <net/if.h>
  1482. X#include <netinet/in.h>
  1483. X#include <netinet/if_ether.h>
  1484. X#include <stdio.h>
  1485. X#include <string.h>
  1486. X#include "defs.h"
  1487. X
  1488. X#define PADDING_SIZE 18
  1489. X
  1490. X/*
  1491. X * sniffer_header - put out the constant stuff at top of file.
  1492. X */
  1493. sniffer_header(fp)
  1494. XFILE *fp;
  1495. X{
  1496. X    int i;
  1497. X
  1498. X    fprintf(fp,"station \"Broadcast\"     = addrtype \"DLC\" FFFFFFFFFFFF\n");
  1499. X    fprintf(fp,"station \"Broadcast\"     = addrtype \"XNS\" FFFFFFFFFFFF\n");
  1500. X    fprintf(fp,"station \"MOP Download\"  = addrtype \"DLC\" AB0000010000\n");
  1501. X    fprintf(fp,"station \"DEC Rem Cons\"  = addrtype \"DLC\" AB0000020000\n");
  1502. X    fprintf(fp,"station \"DEC Endnode\"   = addrtype \"DLC\" AB0000040000\n");
  1503. X    fprintf(fp,"station \"DEC Routers\"   = addrtype \"DLC\" AB0000030000\n");
  1504. X    fprintf(fp,"station \"LTM listnrs\"   = addrtype \"DLC\" 09002B000003\n");
  1505. X    fprintf(fp,"station \"LAT units\"     = addrtype \"DLC\" 09002B00000F\n");
  1506. X    fprintf(fp,"station \"NetBIOS\"       = addrtype \"DLC\" 030000000001\n");
  1507. X}
  1508. X
  1509. X/*
  1510. X * sniffer_entry - write out an ethernet address/hostname pair.
  1511. X */
  1512. sniffer_entry(h, fp)
  1513. HostInfo *h;
  1514. XFILE *fp;
  1515. X{
  1516. X    int i;
  1517. X    extern char *format_hn(), *format_enet();
  1518. X
  1519. X    fprintf(fp,"station %s = addrtype\"DLC\" %s\n",
  1520. X      format_hn(h->hl_name),format_enet(h->hl_ether));
  1521. X}
  1522. X
  1523. X/*
  1524. X * sniffer_footer - dummy routine.
  1525. X */
  1526. sniffer_footer(fp)
  1527. XFILE *fp;
  1528. X{
  1529. X    return; /* no trailer for sniffer */
  1530. X}
  1531. X
  1532. X/*
  1533. X * format_enet - format ethernet number for printing.
  1534. X *
  1535. X *    Entry    ether = string of the form aa:bb:cc:dd:ee:ff:gg
  1536. X *            (leading zeros optional).
  1537. X *
  1538. X *    Exit    returns a string of the form aabbccddeeff
  1539. X *            with leading zeros added to each octet
  1540. X *            as needed.
  1541. X */
  1542. char *
  1543. format_enet(ether)
  1544. char *ether;
  1545. X{
  1546. X    int n1, n2, n3, n4, n5, n6;
  1547. X    static char buf[16];
  1548. X
  1549. X    sscanf(ether,"%x:%x:%x:%x:%x:%x:",&n1,&n2,&n3,&n4,&n5,&n6);
  1550. X    sprintf(buf,"%02x%02x%02x%02x%02x%02x",n1,n2,n3,n4,n5,n6);
  1551. X    return(buf);
  1552. X}
  1553. X
  1554. X/*
  1555. X * format_hn - format hostname for printing.
  1556. X */
  1557. char *
  1558. format_hn(host)
  1559. char *host;
  1560. X{
  1561. X    char *p;
  1562. X    int i, len;
  1563. X    static char buf[128];
  1564. X
  1565. X    memset(buf,'\0',sizeof(buf));
  1566. X    (void) strcpy(buf,"\"");    /* start with a " */
  1567. X    p = strchr(host,'.');
  1568. X    if(p != NULL)
  1569. X    len = p - &host[0];
  1570. X    else
  1571. X    len = strlen(host);
  1572. X    (void) strncat(buf,host,len);
  1573. X    (void) strcat(buf,"\"");    /* and end with a " */
  1574. X    for(i = strlen(buf); i < PADDING_SIZE; i++)
  1575. X    buf[i] = ' ';
  1576. X    return(buf);
  1577. X}
  1578. END_OF_FILE
  1579. if test 2787 -ne `wc -c <'sniffer.c'`; then
  1580.     echo shar: \"'sniffer.c'\" unpacked with wrong size!
  1581. fi
  1582. # end of 'sniffer.c'
  1583. fi
  1584. if test -f 'vendors.c' -a "${1}" != "-c" ; then 
  1585.   echo shar: Will not clobber existing file \"'vendors.c'\"
  1586. else
  1587. echo shar: Extracting \"'vendors.c'\" \(8842 characters\)
  1588. sed "s/^X//" >'vendors.c' <<'END_OF_FILE'
  1589. X#ifndef lint
  1590. static char *RCSid = "$Header: /usr/src/ecn/getethers/RCS/vendors.c,v 1.2 92/05/08 14:16:03 davy Exp $";
  1591. X#endif
  1592. X/*
  1593. X * vendors.c - print ethernet vendor codes
  1594. X *
  1595. X * Peter Shipley
  1596. X * shipley@tfs.com
  1597. X *
  1598. X * More vendors added, code rearranged by D. Curry.
  1599. X *
  1600. X * $Log:    vendors.c,v $
  1601. X * Revision 1.2  92/05/08  14:16:03  davy
  1602. X * Made portable to 4.3BSD, from Peter Shipley (shipley@tfs.com).
  1603. X * 
  1604. X * Revision 1.1  92/05/08  13:06:39  davy
  1605. X * Initial revision
  1606. X * 
  1607. X */
  1608. X#include <sys/param.h>
  1609. X#include <sys/socket.h>
  1610. X#include <netinet/in.h>
  1611. X#include <net/if.h>
  1612. X#ifdef sun
  1613. X#include <net/if_arp.h>
  1614. X#endif
  1615. X#include <netinet/if_ether.h>
  1616. X#include <stdio.h>
  1617. X#include "defs.h"
  1618. X
  1619. X#define VENDOR_NUMS_MASK    0xFFFFFF00
  1620. X#define VEN_MAX        (sizeof(Vendor_nums) / sizeof(struct _vendor_nums))
  1621. X
  1622. static struct _vendor_nums  {
  1623. X    unsigned long addr;
  1624. X    char *name;
  1625. X} Vendor_nums[] = { 
  1626. X    0x00000200, "BBN (internal)",
  1627. X    0x00000C00, "Cisco Systems",
  1628. X    0x00000E00, "Fujitsu",
  1629. X    0x00000F00, "NeXT",
  1630. X    0x00001000, "Hughes LAN Systems (Sytek)",
  1631. X    0x00001100, "Tektronix",
  1632. X    0x00001500, "Datapoint Corporation",
  1633. X    0x00001800, "Webster (?)",
  1634. X    0x00001B00, "Novell",
  1635. X    0x00001D00, "Cabletron",
  1636. X    0x00002000, "Data Industrier AB (DIAB)",
  1637. X    0x00002100, "SC&C",
  1638. X    0x00002200, "Visual Technology",
  1639. X    0x00002900, "IMC",
  1640. X    0x00002A00, "TRW",
  1641. X    0x00003C00, "Auspex",
  1642. X    0x00003D00, "AT&T",
  1643. X    0x00004400, "Castelle",
  1644. X    0x00004600, "ISC-Bunker Ramo (Olivetti)",
  1645. X    0x00004900, "Apricot, Ltd.",
  1646. X    0x00004B00, "APT AppleTalk WAN Router",
  1647. X    0x00004F00, "Logicraft (386-Ware PC Emulator)",
  1648. X    0x00005200, "ODS",
  1649. X    0x00005500, "AT&T",
  1650. X    0x00005A00, "Schneider&Koch/Syskonnect",
  1651. X    0x00005D00, "RDE",
  1652. X    0x00005E00, "US Dept. of Defense (IANA)",
  1653. X    0x00006200, "Honeywell",
  1654. X    0x00006500, "Network General",
  1655. X    0x00006900, "Silicon Graphics (?)",
  1656. X    0x00006B00, "MIPS",
  1657. X    0x00006E00, "Artisoft, Inc.",
  1658. X    0x00007700, "MIPS (?), Interphase (?)",
  1659. X    0x00007900, "Net Ware (?)",
  1660. X    0x00007A00, "Ardent",
  1661. X    0x00007B00, "Research Machines",
  1662. X    0x00007D00, "Harris (3M) (old)",
  1663. X    0x00007F00, "Linotronic",
  1664. X    0x00008000, "Imagen (?) Harris (3M) (new)?",
  1665. X    0x00008100, "Synoptics",
  1666. X    0x00008400, "Aquila (?), ADI Systems, Inc. (?)",
  1667. X    0x00008600, "Gateway (?), Megahertz Corp. (?)",
  1668. X    0x00008900, "Cayman Systems (Gatorbox)",
  1669. X    0x00008E00, "Jupiter (?), Solbourne (?)",
  1670. X    0x00009300, "Proteon",
  1671. X    0x00009400, "Asante MAC",
  1672. X    0x00009500, "Sony/Tektronix",
  1673. X    0x00009700, "Epoch",
  1674. X    0x00009800, "Cross Com",
  1675. X    0x00009F00, "Ameristar Technology",
  1676. X    0x0000A000, "Sanyo Electronics",
  1677. X    0x0000A200, "Wellfleet",
  1678. X    0x0000A300, "Network Application Technology",
  1679. X    0x0000A400, "Acorn",
  1680. X    0x0000A500, "Compatible Systems Corporation",
  1681. X    0x0000A600, "Network General (internal)",
  1682. X    0x0000A700, "Network Computing Devices (NCD) (X terminal)",
  1683. X    0x0000A800, "Stratus Computer, Inc.",
  1684. X    0x0000A900, "Network Systems Corp. (NSC)",
  1685. X    0x0000AA00, "Xerox",
  1686. X    0x0000AC00, "Apollo",
  1687. X    0x0000AF00, "Nuclear Data",
  1688. X    0x0000B000, "RAD Network Devices (RND)",
  1689. X    0x0000B300, "CIMLinc",
  1690. X    0x0000B500, "Datability",
  1691. X    0x0000B700, "Dove Fastnet",
  1692. X    0x0000BB00, "??? (AppleTalk?)",
  1693. X    0x0000BC00, "Allen-Bradley",
  1694. X    0x0000C000, "Standard Microsystems Corp. (SMC) (Western Digital)",
  1695. X    0x0000C600, "HP Intelligent Networks Operation (Eon Systems)",
  1696. X    0x0000C800, "Altos",
  1697. X    0x0000C900, "Emulex (terminal server)",
  1698. X    0x0000D000, "Develcon Electronics, Ltd.",
  1699. X    0x0000D100, "Adaptec, Inc. (Nodem)",
  1700. X    0x0000D700, "Dartmouth College (NED router)",
  1701. X    0x0000D800, "3Com? Novell? (IBM PS/2)",
  1702. X    0x0000DD00, "Gould",
  1703. X    0x0000DE00, "Unigraph",
  1704. X    0x0000E200, "Acer Counterpoint",
  1705. X    0x0000E800, "Accton Technology Corporation",
  1706. X    0x0000EE00, "Network Designers Limited (?)",
  1707. X    0x0000EF00, "Alantec",
  1708. X    0x0000F000, "Samsung",
  1709. X    0x0000F300, "Gandalf",
  1710. X    0x0000F400, "Allied Telesis, Inc.",
  1711. X    0x0000F600, "Applied Microsystems Corp. (AMC)",
  1712. X    0x0000FD00, "High Level Hardware (Orion, UK)",
  1713. X    0x00010200, "BBN (internal)",
  1714. X    0x00014300, "IEEE 802",
  1715. X    0x00016300, "National Datacomm Corporation",
  1716. X    0x00016800, "Wandel & Goltermann",
  1717. X    0x0001C800, "Thomas Conrad Corp.",
  1718. X    0x00170000, "Kabel",
  1719. X    0x00402B00, "TriGem",
  1720. X    0x0040C500, "Micom Communications Corp.",
  1721. X    0x0040C800, "Milan Technology Corp.",
  1722. X    0x00608C00, "3Com (1990 onwards)",
  1723. X    0x00800F00, "Standard Microsystems Corp. (SMC)",
  1724. X    0x00801000, "Commodore",
  1725. X    0x00801700, "PFU",
  1726. X    0x00801900, "Dayna COmmunications (Etherprint)",
  1727. X    0x00801B00, "Kodiak Technology",
  1728. X    0x00802100, "Newbridge Networks Corporation",
  1729. X    0x00802900, "Microdyne Corporation",
  1730. X    0x00802D00, "Xylogics (Annex server)",
  1731. X    0x00802E00, "Plexcom, Inc.",
  1732. X    0x00803400, "SMT-Goupil",
  1733. X    0x00803500, "Technology Works",
  1734. X    0x00805100, "ADC Fibermux",
  1735. X    0x00805200, "Network Professor",
  1736. X    0x00805C00, "Agilis (?)",
  1737. X    0x00807C00, "FiberCom",
  1738. X    0x00808700, "Okidata",
  1739. X    0x00808C00, "Frontier Software Development",
  1740. X    0x00809600, "Human Designed Systems (HDS) (X terminal)",
  1741. X    0x0080A100, "Microtest",
  1742. X    0x0080A300, "Lantronix",
  1743. X    0x0080B200, "Network Equipment Technologies",
  1744. X    0x0080C700, "Xircom, Inc.",
  1745. X    0x0080C800, "D-Link, Solectek Pocket Adapters",
  1746. X    0x0080D000, "Computer Products International",
  1747. X    0x0080D300, "Shiva (Fastpath)",
  1748. X    0x0080D400, "Chase Limited",
  1749. X    0x0080D800, "Network Perihperals",
  1750. X    0x0080F100, "Opus",
  1751. X    0x00AA0000, "Intel",
  1752. X    0x00B0D000, "Computer Products International",
  1753. X    0x00DD0000, "Ungermann-Bass (IBM RT)",
  1754. X    0x00DD0100, "Ungermann-Bass",
  1755. X    0x00EFE500, "3Com (IBM Microchannel card)",
  1756. X    0x02040600, "BBN (internal)",
  1757. X    0x02070100, "MICOM/Interlan (UNIBUS/QBUS/Apollo/Cisco)",
  1758. X    0x02606000, "3Com",
  1759. X    0x02608600, "Satelcom MegaPac (UK)",
  1760. X    0x02608C00, "3Com (IBM-PC/Imagen/Valid/Cisco/Macintosh)",
  1761. X    0x02CF1F00, "CMC (Masscomp/Silicon Graphics)",
  1762. X    0x02E6D300, "Bus-Tech, Inc. (IBM mainframes)",
  1763. X    0x08000100, "Computer Vision",
  1764. X    0x08000200, "3Com (Bridge)",
  1765. X    0x08000300, "Advanced Computer Communications (ACC)",
  1766. X    0x08000500, "Symbolics (LISP machine)",
  1767. X    0x08000700, "Apple",
  1768. X    0x08000800, "BBN",
  1769. X    0x08000900, "Hewlett-Packard",
  1770. X    0x08000A00, "Nestar Systems",
  1771. X    0x08000B00, "Unisys",
  1772. X    0x08000D00, "International Computers, Ltd. (ICL)",
  1773. X    0x08000E00, "NCR/AT&T",
  1774. X    0x08000F00, "Standard Microsystems Corporation (SMC)",
  1775. X    0x08001000, "AT&T",
  1776. X    0x08001100, "Tektronix",
  1777. X    0x08001400, "Excelan (BBN Butterfly/Masscomp/Silicon Graphics)",
  1778. X    0x08001700, "National Semiconductor (NSC)",
  1779. X    0x08001A00, "Data General",
  1780. X    0x08001B00, "Data General",
  1781. X    0x08001E00, "Apollo",
  1782. X    0x08001F00, "Sharp",
  1783. X    0x08002000, "Sun",
  1784. X    0x08002200, "NBI",
  1785. X    0x08002300, "Matsushita Denso",
  1786. X    0x08002500, "CDC",
  1787. X    0x08002600, "Norsk Data",
  1788. X    0x08002700, "PCS Computer Systems GmbH",
  1789. X    0x08002800, "TI (Explorer)",
  1790. X    0x08002B00, "Digital Equipment Corp.",
  1791. X    0x08002E00, "Metaphor",
  1792. X    0x08002F00, "Prime Computer (50-series LHC300)",
  1793. X    0x08003600, "Intergraph",
  1794. X    0x08003700, "Fujitsu-Xerox",
  1795. X    0x08003800, "Bull",
  1796. X    0x08003900, "Spider Systems",
  1797. X    0x08003B00, "Torus Systems",
  1798. X    0x08003E00, "Motorola (VME bus processor module)",
  1799. X    0x08004100, "Digital Comm. Association (DCA)",
  1800. X    0x08004400, "DAVID Systems, Inc. (DSI)",
  1801. X    0x08004500, "Xylogics (?)",
  1802. X    0x08004600, "Sony",
  1803. X    0x08004700, "Sequent",
  1804. X    0x08004900, "Univation",
  1805. X    0x08004C00, "Encore",
  1806. X    0x08004E00, "BICC",
  1807. X    0x08005100, "Experdata",
  1808. X    0x08005600, "Stanford University",
  1809. X    0x08005700, "Evans & Sutherland (?)",
  1810. X    0x08005800, "??? (DECsystem-20)",
  1811. X    0x08005A00, "IBM",
  1812. X    0x08005D00, "Gould",
  1813. X    0x08006700, "Comdesign",
  1814. X    0x08006800, "Ridge",
  1815. X    0x08006900, "Silicon Graphics",
  1816. X    0x08006A00, "ATTst (?)",
  1817. X    0x08006E00, "Excelan",
  1818. X    0x08007000, "Mitsubishi",
  1819. X    0x08007400, "Casio",
  1820. X    0x08007500, "Danish Data Elektronik A/S (DDE)",
  1821. X    0x08007700, "TSL (Retix)",
  1822. X    0x08007900, "Silicon Graphics",
  1823. X    0x08007C00, "Vitalink TransLAN III",
  1824. X    0x08008000, "XIOS",
  1825. X    0x08008100, "Crosfield Electronics",
  1826. X    0x08008300, "Seiko Denshi",
  1827. X    0x08008600, "Imagen/QMS",
  1828. X    0x08008700, "Xyplex",
  1829. X    0x08008900, "Kinetics",
  1830. X    0x08008B00, "Pyramid",
  1831. X    0x08008D00, "XyVision",
  1832. X    0x08008E00, "Tandem",
  1833. X    0x08009000, "Retix",
  1834. X};
  1835. X
  1836. char *
  1837. vendor_name(ea)
  1838. struct ether_addr *ea;
  1839. X{
  1840. X    int ether_num;
  1841. X    int i;
  1842. X
  1843. X    ether_num = 0;
  1844. X    ether_num =
  1845. X        (ea->ether_addr_octet[0] << 24 ) |
  1846. X        (ea->ether_addr_octet[1] << 16 ) |
  1847. X        (ea->ether_addr_octet[2] << 8 );
  1848. X
  1849. X    /* I should install a binary search */
  1850. X    for (i=0; i < VEN_MAX; i++) {
  1851. X        if ((ether_num & VENDOR_NUMS_MASK) ==
  1852. X            (Vendor_nums[i].addr & VENDOR_NUMS_MASK)) {
  1853. X            return(Vendor_nums[i].name);
  1854. X        }
  1855. X    }
  1856. X
  1857. X    return("???");
  1858. X}
  1859. END_OF_FILE
  1860. if test 8842 -ne `wc -c <'vendors.c'`; then
  1861.     echo shar: \"'vendors.c'\" unpacked with wrong size!
  1862. fi
  1863. # end of 'vendors.c'
  1864. fi
  1865. echo shar: End of archive 1 \(of 1\).
  1866. cp /dev/null ark1isdone
  1867. MISSING=""
  1868. for I in 1 ; do
  1869.     if test ! -f ark${I}isdone ; then
  1870.     MISSING="${MISSING} ${I}"
  1871.     fi
  1872. done
  1873. if test "${MISSING}" = "" ; then
  1874.     echo You have the archive.
  1875.     rm -f ark[1-9]isdone
  1876. else
  1877.     echo You still need to unpack the following archives:
  1878.     echo "        " ${MISSING}
  1879. fi
  1880. ##  End of shell archive.
  1881. exit 0
  1882.