home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume27 / bootp22b / part01 < prev    next >
Encoding:
Text File  |  1993-10-11  |  73.8 KB  |  2,406 lines

  1. Newsgroups: comp.sources.unix
  2. From: gwr@mc.com (Gordon W. Ross)
  3. Subject: v27i063: bootp-2.2.B - RFC 1048 "bootp" server (w/ vendor extensions), Part01/02
  4. Message-id: <1.750376278.23845@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: gwr@mc.com (Gordon W. Ross)
  9. Posting-Number: Volume 27, Issue 63
  10. Archive-Name: bootp-2.2.B/part01
  11.  
  12. This is an enhanced version of the CMU BOOTP server (2.2 alpha)
  13. developed by Walter L. Wimer and Drew D. Perkins.
  14.  
  15. The original BOOTP server was designed and implemented by Bill Croft
  16. at Stanford.  Much of the credit for the ideas and code goes to him.
  17. Walter L. Wimer and Drew D. Perkins implemented all of the code
  18. in this version except for the function dovend_rfc1048() which
  19. I redesigned to make it preserve the client's option template.
  20.  
  21. I tried several times to reach the authors of this program, but
  22. have not been able to contact them.  (Help would be appreciated.)
  23. Therefore, I have decided to make this version of the BOOTP server
  24. available and will maintain it unless WLW or DDP want to do so.
  25.  
  26. New features in version 2.2.B that were not in version 2.2:
  27.  
  28. o  The server now handles clients that need the server to honor the
  29.    format of the options area in the request packet (by sending the
  30.    response with options in exactly the same layout).
  31.  
  32. o  The server now supports clients that use an extended option area
  33.    (by extending the existing option area to the end of the packet).
  34.  
  35. o  Source compatibility with SVR4 (and Solaris 2.X) thanks to
  36.    changes graciously contributed by db@sunbim.be (Danny Backx).
  37.  
  38. Please direct questions, comments, and bug reports to:
  39.  
  40.     Gordon W. Ross          Mercury Computer Systems
  41.     gwr@mc.com              199 Riverneck Road
  42.     508-256-1300            Chelmsford, MA 01824-2820
  43.  
  44. #! /bin/sh
  45. # This is a shell archive.  Remove anything before this line, then unpack
  46. # it by saving it into a file and typing "sh file".  To overwrite existing
  47. # files, type "sh file -c".  You can also feed this as standard input via
  48. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  49. # will see the following message at the end:
  50. #        "End of archive 1 (of 2)."
  51. # Contents:  Announce-2.0 Announce-2.1 Announce-2.2 Announce-2.2.B
  52. #   MANIFEST Makefile README ToDo Version.c bootp.h bootpd.8 bootpd.h
  53. #   bootptab bootptab.5 gmods hash.c hash.h newvers.sh
  54. # Wrapped by vixie@gw.home.vix.com on Mon Oct 11 14:48:25 1993
  55. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  56. if test -f 'Announce-2.0' -a "${1}" != "-c" ; then 
  57.   echo shar: Will not clobber existing file \"'Announce-2.0'\"
  58. else
  59. echo shar: Extracting \"'Announce-2.0'\" \(1719 characters\)
  60. sed "s/^X//" >'Announce-2.0' <<'END_OF_FILE'
  61. XSubject: RFC-1048 compatible BOOTP server now available
  62. X
  63. X
  64. XAn RFC-1048 (BOOTP Vendor Information Extensions) compatible BOOTP (RFC-951)
  65. Xserver is now available for anonymous FTP from lancaster.andrew.cmu.edu
  66. X(128.2.13.21).  The new server can be found in pub/bootp.2.0.tar.  This is
  67. Xan enhanced version of the existing CMU BOOTP server which was derived from
  68. Xthe original BOOTP server created by Bill Croft at Stanford.
  69. X
  70. XNew features and changes in version 2.0 include:
  71. X
  72. Xo  Full support for the vendor information extensions described in RFC-1048.
  73. Xo  Faster response time (host lookup via hash table instead of linear search).
  74. Xo  New termcap-like configuration file format which allows greater flexibility
  75. X   in specifying the variable vendor information of RFC-1048.  Host entries
  76. X   may refer to other hosts as templates so that redundant information need
  77. X   be specified only once.
  78. Xo  Continued support for the CMU vendor information format.  The server may
  79. X   be configured on a per-host basis to always reply with a certain vendor
  80. X   information format or to reply based on the client's request.
  81. Xo  Expanded logging.
  82. Xo  The server may now be run by inetd or as a standalone program like the
  83. X   old version.
  84. Xo  The configuration and debugging dump files may be specified on the command
  85. X   line.
  86. X
  87. X
  88. XThe server has been successfully tested on the following machines:
  89. X
  90. X    IBM RT PC running ACIS 4.3 (4.3 BSD)
  91. X    Sun 3/50 running SunOS 3.5
  92. X    DEC MicroVAX II running Ultrix 1.1
  93. X    DEC MicroVAX II running Ultrix 2.2
  94. X
  95. X
  96. X
  97. XPlease direct questions, comments, and bug reports to
  98. XWalt Wimer <ww0n@andrew.cmu.edu> or Drew Perkins <ddp@andrew.cmu.edu>.
  99. X
  100. X
  101. X
  102. XSincerely,
  103. X
  104. XWalt Wimer
  105. XNetwork Development
  106. XCarnegie Mellon University
  107. END_OF_FILE
  108. if test 1719 -ne `wc -c <'Announce-2.0'`; then
  109.     echo shar: \"'Announce-2.0'\" unpacked with wrong size!
  110. fi
  111. # end of 'Announce-2.0'
  112. fi
  113. if test -f 'Announce-2.1' -a "${1}" != "-c" ; then 
  114.   echo shar: Will not clobber existing file \"'Announce-2.1'\"
  115. else
  116. echo shar: Extracting \"'Announce-2.1'\" \(1534 characters\)
  117. sed "s/^X//" >'Announce-2.1' <<'END_OF_FILE'
  118. XSubject: Updated RFC1048 BOOTP server now available
  119. X
  120. XWell, no surprise, bootpd 2.0 had a few bugs.  A new improved version,
  121. Xbootpd 2.1, is now available for anonymous FTP from lancaster.andrew.cmu.edu
  122. X(128.2.13.21).  The new server can be found in pub/bootp.2.1.tar.
  123. X
  124. XBug fixes and improvements in version 2.1 include:
  125. X
  126. Xo  The definition of "access to the bootfile" has been changed to require the
  127. X   public read access bit to be set.  This is required by tftpd(8), so the
  128. X   server will not reply with a file which a client cannot obtain via TFTP.
  129. Xo  The RFC1084 bootfile size tag has been implemented.  It allows either
  130. X   automatic or manual specification of the bootfile size in 512-octet blocks.
  131. Xo  Generic tags now work as advertised.
  132. Xo  A subtle bug which caused strange parsing behavior under certain conditions
  133. X   has been fixed.
  134. Xo  The RFC1048 vendor information now has the correct byte order on
  135. X   little-endien machines such as the VAX.
  136. Xo  Failure to specify the bootfile home directory and/or default bootfile in
  137. X   the configuration file no longer causes server crashes.  The server now
  138. X   makes a reasonably intelligent choice if this configuration information is
  139. X   missing.  This is documented in the man page.
  140. Xo  BOOTP requests from clients which already know their IP addresses no longer
  141. X   cause server crashes.
  142. X
  143. X
  144. X
  145. XPlease direct questions, comments, and bug reports to
  146. XWalt Wimer <ww0n@andrew.cmu.edu> or Drew Perkins <ddp@andrew.cmu.edu>.
  147. X
  148. X
  149. X
  150. XGood luck,
  151. X
  152. XWalt Wimer
  153. XNetwork Development
  154. XCarnegie Mellon University
  155. END_OF_FILE
  156. if test 1534 -ne `wc -c <'Announce-2.1'`; then
  157.     echo shar: \"'Announce-2.1'\" unpacked with wrong size!
  158. fi
  159. # end of 'Announce-2.1'
  160. fi
  161. if test -f 'Announce-2.2' -a "${1}" != "-c" ; then 
  162.   echo shar: Will not clobber existing file \"'Announce-2.2'\"
  163. else
  164. echo shar: Extracting \"'Announce-2.2'\" \(2101 characters\)
  165. sed "s/^X//" >'Announce-2.2' <<'END_OF_FILE'
  166. X
  167. XNew features in version 2.2 include:
  168. X
  169. Xo  A new "td" tag allows the specification of a "TFTP directory" for use
  170. X   with so-called "secure" implementations of tftpd which chroot(2) to a
  171. X   particular directory.
  172. X
  173. Xo  A new "sa" tag allows the explicit specification of the TFTP
  174. X   "server address."  Formerly, the 'siaddr' field of the BOOTREPLY was
  175. X   always filled with the IP address of the BOOTP server.  The "sa" tag
  176. X   now allows the BOOTP server and the TFTP server to be two different
  177. X   machines, if desired.
  178. X
  179. Xo  The server now automatically determines whether it is running as a
  180. X   standalone program (e.g. invoked by hand from a shell) or as a child of
  181. X   /etc/inetd.  The -s option and a new -i option are provided to force
  182. X   standalone or inetd mode if necessary.
  183. X
  184. Xo  When the vendor magic cookie is zero, BOOTP replies now default to the
  185. X   RFC 1084 vendor format, rather than the old CMU format.  This helps
  186. X   interoperability with uncooperative BOOTP clients which want RFC 1084
  187. X   format but don't bother filling in the magic cookie properly to tell
  188. X   the server... *sigh*  (This makes the ":vm=rfc1048:" tag unnecessary
  189. X   in most cases now.  Oh, the "vm" tag now accepts "rfc1084" as well as
  190. X   "rfc1048" -- they mean the same thing.)
  191. X
  192. Xo  Log messages now include the specific network type.  For example, rather
  193. X   than saying "request from hardware address ABCDEF012345", the message is
  194. X   now "request from Ethernet address ABCEDF012345", or "request from
  195. X   IEEE802 address 4000A1B2C3D4".
  196. X
  197. X
  198. XBug fixes in this version include:
  199. X
  200. Xo  The automatic bootfile-size calculation now works correctly when the
  201. X   file size is an exact multiple of 512 octets.  It used to return a number
  202. X   which was one 512-octet unit greater than necessary.
  203. X
  204. Xo  A bug in comparing subnet masks has been fixed.
  205. X
  206. Xo  A bug in calculating the size of the vendor information area when
  207. X   inserting the hostname has been fixed.
  208. X
  209. X
  210. XOther changes:
  211. X
  212. Xo  The man page has been split into two man pages.  One covers the server
  213. X   itself (bootpd.8) and the other covers the configuration file format
  214. X   (bootptab.5).
  215. X
  216. X
  217. END_OF_FILE
  218. if test 2101 -ne `wc -c <'Announce-2.2'`; then
  219.     echo shar: \"'Announce-2.2'\" unpacked with wrong size!
  220. fi
  221. # end of 'Announce-2.2'
  222. fi
  223. if test -f 'Announce-2.2.B' -a "${1}" != "-c" ; then 
  224.   echo shar: Will not clobber existing file \"'Announce-2.2.B'\"
  225. else
  226. echo shar: Extracting \"'Announce-2.2.B'\" \(1813 characters\)
  227. sed "s/^X//" >'Announce-2.2.B' <<'END_OF_FILE'
  228. XSubject: Enhanced RFC-1048 compatible BOOTP server now available
  229. X
  230. XAn RFC-1048 (BOOTP Vendor Information Extensions) compatible
  231. XBOOTP (RFC-951) server is now available for anonymous FTP from
  232. Xfirewall.mc.com (192.148.197.15).  A test program (BOOTP client)
  233. Xis also available at the same location.  The file names are:
  234. X    /outgoing/bootp-2.2.B.tar.Z    (BOOTP server)
  235. X    /outgoing/bootptest-1.1.tar.Z    (BOOTP test program)
  236. XThis is an enhanced version of the CMU BOOTP server (2.2 alpha)
  237. Xdeveloped by Walter L. Wimer and Drew D. Perkins.
  238. X
  239. XThe original BOOTP server was designed and implemented by Bill Croft
  240. Xat Stanford.  Much of the credit for the ideas and code goes to him.
  241. XWalter L. Wimer and Drew D. Perkins implemented all of the code
  242. Xin this version except for the function dovend_rfc1048() which
  243. XI redesigned to make it preserve the client's option template.
  244. X
  245. XI tried several times to reach the authors of this program, but
  246. Xhave not been able to contact them.  (Help would be appreciated.)
  247. XTherefore, I have decided to make this version of the BOOTP server
  248. Xavailable and will maintain it unless WLW or DDP want to do so.
  249. X
  250. XNew features in version 2.2.B that were not in version 2.2:
  251. X
  252. Xo  The server now handles clients that need the server to honor the
  253. X   format of the options area in the request packet (by sending the
  254. X   response with options in exactly the same layout).
  255. X
  256. Xo  The server now supports clients that use an extended option area
  257. X   (by extending the existing option area to the end of the packet).
  258. X
  259. Xo  Source compatibility with SVR4 (and Solaris 2.X) thanks to
  260. X   changes graciously contributed by db@sunbim.be (Danny Backx).
  261. X
  262. XPlease direct questions, comments, and bug reports to:
  263. X
  264. XGordon W. Ross          Mercury Computer Systems
  265. Xgwr@mc.com              199 Riverneck Road
  266. X508-256-1300            Chelmsford, MA 01824-2820
  267. END_OF_FILE
  268. if test 1813 -ne `wc -c <'Announce-2.2.B'`; then
  269.     echo shar: \"'Announce-2.2.B'\" unpacked with wrong size!
  270. fi
  271. # end of 'Announce-2.2.B'
  272. fi
  273. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  274.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  275. else
  276. echo shar: Extracting \"'MANIFEST'\" \(734 characters\)
  277. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  278. X   File Name        Archive #    Description
  279. X-----------------------------------------------------------
  280. X Announce-2.0               1    
  281. X Announce-2.1               1    
  282. X Announce-2.2               1    
  283. X Announce-2.2.B             1    
  284. X MANIFEST                   1    This shipping list
  285. X Makefile                   1    
  286. X README                     1    
  287. X ToDo                       1    
  288. X Version.c                  1    
  289. X bootp.h                    1    
  290. X bootpd.8                   1    
  291. X bootpd.c                   2    
  292. X bootpd.h                   1    
  293. X bootptab                   1    
  294. X bootptab.5                 1    
  295. X gmods                      1    
  296. X hash.c                     1    
  297. X hash.h                     1    
  298. X newvers.sh                 1    
  299. X readfile.c                 2    
  300. END_OF_FILE
  301. if test 734 -ne `wc -c <'MANIFEST'`; then
  302.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  303. fi
  304. # end of 'MANIFEST'
  305. fi
  306. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  307.   echo shar: Will not clobber existing file \"'Makefile'\"
  308. else
  309. echo shar: Extracting \"'Makefile'\" \(1296 characters\)
  310. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  311. X#
  312. X# bootpd   - BOOTP server daemon
  313. X#
  314. X# $Header: /afs/andrew.cmu.edu/netdev/src/cmu/bootp-public/RCS/Makefile,v 1.1 1991/10/31 19:15:12 ww0n Exp ww0n $
  315. X#
  316. X
  317. X# FILE DEFinitions:
  318. X# The next few lines may be uncommented and changed to alter the default
  319. X# filenames bootpd uses for its configuration and dump files.
  320. X#CONFFILE= -DCONFIG_FILE=\"/usr/etc/bootptab\"
  321. X#DUMPFILE= -DDUMP_FILE=\"/usr/etc/bootpd.dump\"
  322. X#FILEDEFS= ${CONFFILE} ${DUMPFILE}
  323. X
  324. X# OPTion DEFinitions:
  325. X# Remove the -DVEND_CMU if you don't wish to support the "CMU vendor format"
  326. X# in addition to the RFC1048 format.
  327. XOPTDEFS= -DSYSLOG -DVEND_CMU
  328. X
  329. X# SYStem DEFinitions:
  330. X# Uncomment these lines for SunOS 4.X
  331. XSYSDEFS= -DSUNOS4
  332. X# Uncomment these lines for SVR4 (or Solaris 2.X)
  333. X# SYSDEFS= -DSVR4 # -Dsparc -Dsun -Dunix ?XXX?
  334. X# SYSLIBS= -lsocket -lnsl
  335. X
  336. XINSTALL=/usr/bin/install
  337. XDESTDIR=
  338. XETCDIR=/etc
  339. XOBJS=bootpd.o readfile.o hash.o
  340. XCFLAGS= ${FILEDEFS} ${OPTDEFS} ${SYSDEFS}
  341. X
  342. Xall: bootpd
  343. X
  344. Xbootpd:    ${OBJS} Version.c
  345. X    sh newvers.sh Version.c
  346. X    ${CC} ${CFLAGS} -o bootpd version.c ${OBJS} ${SYSLIBS}
  347. X
  348. Xbootpd.o: bootpd.c bootpd.h bootp.h
  349. Xreadfile.o: readfile.c bootpd.h bootp.h
  350. Xhash.o: hash.c hash.h
  351. X
  352. Xsystem: install
  353. X
  354. Xinstall: all
  355. X    ${INSTALL} -c -s bootpd ${DESTDIR}${ETCDIR}/bootpd
  356. X
  357. Xclean:
  358. X    @rm -f core bootpd *.BAK *.CKP *~ .emacs* *.o version.c
  359. END_OF_FILE
  360. if test 1296 -ne `wc -c <'Makefile'`; then
  361.     echo shar: \"'Makefile'\" unpacked with wrong size!
  362. fi
  363. # end of 'Makefile'
  364. fi
  365. if test -f 'README' -a "${1}" != "-c" ; then 
  366.   echo shar: Will not clobber existing file \"'README'\"
  367. else
  368. echo shar: Extracting \"'README'\" \(4154 characters\)
  369. sed "s/^X//" >'README' <<'END_OF_FILE'
  370. XThis is a MODIFIED VERSION of the CMU BOOTP server written by
  371. XWalter L. Wimer and Drew D. Perkins and made available as
  372. Xbootp-2.2alpha at CMU.  I tried several times to reach the
  373. Xauthors of this program, and have since decided to make this
  374. Xversion available directly.  I would be happy to maintain it.
  375. X
  376. XMy modifications allow this BOOTP server to handle clients that
  377. Xexpect the server to honor the format of the options area in
  378. Xthe request packet.  Such clients fill in all the option tag and
  379. Xlength bytes in the request packet (using a fixed structure) and
  380. Xexpect the server to fill in the missing data while preserving
  381. Xthe layout of all the tag and length bytes.
  382. X
  383. XThe README from the CMU bootp-2.2alpha follows (edited slightly).
  384. X
  385. XGordon W. Ross          Mercury Computer Systems
  386. Xgwr@mc.com              199 Riverneck Road
  387. X508-256-1300            Chelmsford, MA 01824-2820
  388. X
  389. XThis directory contains the source for the CMU BOOTP server.
  390. XThe files include:
  391. X
  392. XREADME        This file
  393. XToDo        Things not yet done
  394. Xbootpd.8    The manual page
  395. Xbootp.h        The protocol header file
  396. Xbootpd.h    The server header file
  397. Xbootpd.c    The main server module
  398. Xreadfile.c    The configuration file-reading routines
  399. Xhash.h        The hash table header file
  400. Xhash.c        The hash table module
  401. XVersion.c    The version module
  402. Xnewvers.sh    A shell script to generate new version numbers
  403. XMakefile    The makefile
  404. Xbootptab    An example database file for the server
  405. Xbootptab.5    A manual describing the bootptab format
  406. Xgmods        Text describing optional gateway modifications
  407. X
  408. X
  409. XNotes:
  410. X1) BOOTP was originally designed and implemented by Bill Croft at Stanford.
  411. X   Much of the credit for the ideas and the code goes to him.  We've added
  412. X   code to support the vendor specific area of the packet as specified in
  413. X   RFC1048.  We've also improved the host lookup algorithm and added some
  414. X   extra logging.
  415. X
  416. X2) The server now uses syslog to do logging.  Specifically it uses the 4.3bsd
  417. X   version.  I've #ifdef'd all of these calls.  If you are running 4.2 you
  418. X   should compile without the -DSYSLOG switch.
  419. X
  420. X3) You must update your /etc/services file to contain the following two lines:
  421. X    bootps        67/udp        bootp        # bootp server
  422. X    bootpc        68/udp                # bootp client
  423. X
  424. X4) Edit the bootptab.  It has some explanitory comments, and there
  425. X   is a manual entry describing its format (bootptab.5)
  426. X   If you have any questions, just let us know.
  427. X
  428. XConstruction:
  429. X    Make sure all of the files exist first.  If anything is missing,
  430. X    please contact either Walt Wimer or Drew Perkins by E-mail or phone.
  431. X    Addresses and phone numbers are listed below.
  432. X[ Or contact me at the address above. -gwr ]
  433. X
  434. X    Type 'make'.  The options at present are: -DSYSLOG which enables logging
  435. X    code, -DDEBUG which enables table dumping via signals, and -DVEND_CMU
  436. X    which enables the CMU extensions for CMU PC/IP.
  437. X
  438. X    Edit the bootptab.  The man page and the comments in the file should
  439. X    explain how to go about doing so.  If you have any problems, let me know.
  440. X
  441. X    Type 'make install'.  This should put all of the files in the right place.
  442. X
  443. X    Edit your /etc/rc.local or /etc/inetd.conf file to start up bootpd upon
  444. X    reboot.  [ The following is a sample entry for /etc/inetd.conf -gwr ]
  445. X    # BOOTP server
  446. X    bootps dgram udp wait root /usr/etc/bootpd bootpd -i
  447. X
  448. XCare and feeding:
  449. X    If you change the interface cards on your host or add new hosts you will
  450. X    need to update /etc/bootptab.  Just edit it as before.  Once you write
  451. X    it back out, bootpd will notice that there is a new copy and will
  452. X    reread it the next time it gets a request.
  453. X
  454. X    If your bootp clients don't get a response then several things might be
  455. X    wrong.  Most often, the entry for that host is not in the database.
  456. X    Check the hardware address and then check the entry and make sure
  457. X    everything is right.  Other problems include the server machine crashing,
  458. X    bad cables, and the like.  If your network is very congested you should
  459. X    try making your bootp clients send additional requests before giving up.
  460. X
  461. X
  462. XNovember 7, 1988
  463. X
  464. X
  465. XWalter L. Wimer            Drew D. Perkins
  466. Xww0n@andrew.cmu.edu        ddp@andrew.cmu.edu
  467. X(412) 268-6252            (412) 268-8576
  468. X
  469. X4910 Forbes Ave
  470. XPittsburgh, PA  15213
  471. X
  472. END_OF_FILE
  473. if test 4154 -ne `wc -c <'README'`; then
  474.     echo shar: \"'README'\" unpacked with wrong size!
  475. fi
  476. # end of 'README'
  477. fi
  478. if test -f 'ToDo' -a "${1}" != "-c" ; then 
  479.   echo shar: Will not clobber existing file \"'ToDo'\"
  480. else
  481. echo shar: Extracting \"'ToDo'\" \(1222 characters\)
  482. sed "s/^X//" >'ToDo' <<'END_OF_FILE'
  483. X
  484. XOptions in responses:
  485. X
  486. XRFC951 says:
  487. X      The 'vend' field can be filled in by the client with
  488. X      vendor-specific strings or structures.  For example the machine
  489. X      hardware type or serial number may be placed here.  However the
  490. X      operation of the BOOTP server should not DEPEND on this
  491. X      information existing.
  492. X
  493. XTherefore:
  494. X
  495. XThe bootpd should honor any vendor data structure set up by the client
  496. Xbefore trying to stuff in what it thinks the client wants.  This part
  497. Xis done, but we need a way to tell the bootp server which options to
  498. Xappend to the options area when the client provides no template.
  499. XPerhaps the server should first fill in all the options specifically
  500. Xasked for by the client (in its template), and then append all other
  501. Xoption values known by the server as option space permits.
  502. X
  503. XResponse policy:
  504. X
  505. XVersion 2.2 does not respond to a bootp client if it does not see
  506. Xa file name corresponding to the :bf=" record.  This can lead to
  507. Xsome confusion if one forgets to install the boot file.  It might
  508. Xbe less confusing if bootp just responded whenever it has a boot
  509. Xrecord for that client, and let the client report failure reading
  510. Xthe boot file when TFTP fails.  This is how bootpd-1.2 did it.
  511. X
  512. END_OF_FILE
  513. if test 1222 -ne `wc -c <'ToDo'`; then
  514.     echo shar: \"'ToDo'\" unpacked with wrong size!
  515. fi
  516. # end of 'ToDo'
  517. fi
  518. if test -f 'Version.c' -a "${1}" != "-c" ; then 
  519.   echo shar: Will not clobber existing file \"'Version.c'\"
  520. else
  521. echo shar: Extracting \"'Version.c'\" \(2040 characters\)
  522. sed "s/^X//" >'Version.c' <<'END_OF_FILE'
  523. X#ifndef _BLURB_
  524. X#define _BLURB_
  525. X/************************************************************************
  526. X          Copyright 1988, 1991 by Carnegie Mellon University
  527. X
  528. X                          All Rights Reserved
  529. X
  530. XPermission to use, copy, modify, and distribute this software and its
  531. Xdocumentation for any purpose and without fee is hereby granted, provided
  532. Xthat the above copyright notice appear in all copies and that both that
  533. Xcopyright notice and this permission notice appear in supporting
  534. Xdocumentation, and that the name of Carnegie Mellon University not be used
  535. Xin advertising or publicity pertaining to distribution of the software
  536. Xwithout specific, written prior permission.
  537. X
  538. XCARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  539. XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  540. XIN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  541. XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  542. XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  543. XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  544. XSOFTWARE.
  545. X************************************************************************/
  546. X#endif /* _BLURB_ */
  547. X
  548. X
  549. X/*
  550. X * Version.c (this file):
  551. X *
  552. X * Copyright (c) 1986, 1987 Regents of the University of California.
  553. X * All rights reserved.
  554. X *
  555. X * Redistribution and use in source and binary forms are permitted
  556. X * provided that this notice is preserved and that due credit is given
  557. X * to the University of California at Berkeley. The name of the University
  558. X * may not be used to endorse or promote products derived from this
  559. X * software without specific prior written permission. This software
  560. X * is provided ``as is'' without express or implied warranty.
  561. X *
  562. X *    @(#)Version.c    4.8 (Berkeley) 4/7/88
  563. X */
  564. X
  565. X#ifndef lint
  566. Xchar sccsid[] = "@(#)bootpd 2.2.B %VERSION% %WHOANDWHERE%\n";
  567. Xchar rcsid[] = "$Header: Version 2.2.B from gwr@mc.com $";
  568. X#endif /* not lint */
  569. X
  570. Xchar Version[] = "bootpd 2.2.B %VERSION%\n\t%WHOANDWHERE%\n";
  571. END_OF_FILE
  572. if test 2040 -ne `wc -c <'Version.c'`; then
  573.     echo shar: \"'Version.c'\" unpacked with wrong size!
  574. fi
  575. # end of 'Version.c'
  576. fi
  577. if test -f 'bootp.h' -a "${1}" != "-c" ; then 
  578.   echo shar: Will not clobber existing file \"'bootp.h'\"
  579. else
  580. echo shar: Extracting \"'bootp.h'\" \(4479 characters\)
  581. sed "s/^X//" >'bootp.h' <<'END_OF_FILE'
  582. X#ifndef _BLURB_
  583. X#define _BLURB_
  584. X/************************************************************************
  585. X          Copyright 1988, 1991 by Carnegie Mellon University
  586. X
  587. X                          All Rights Reserved
  588. X
  589. XPermission to use, copy, modify, and distribute this software and its
  590. Xdocumentation for any purpose and without fee is hereby granted, provided
  591. Xthat the above copyright notice appear in all copies and that both that
  592. Xcopyright notice and this permission notice appear in supporting
  593. Xdocumentation, and that the name of Carnegie Mellon University not be used
  594. Xin advertising or publicity pertaining to distribution of the software
  595. Xwithout specific, written prior permission.
  596. X
  597. XCARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  598. XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  599. XIN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  600. XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  601. XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  602. XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  603. XSOFTWARE.
  604. X************************************************************************/
  605. X#endif /* _BLURB_ */
  606. X
  607. X
  608. X/*
  609. X * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
  610. X *
  611. X * $Header: /afs/andrew.cmu.edu/netdev/src/cmu/bootp-public/RCS/bootp.h,v 1.3 1991/11/01 10:02:29 ww0n Exp ww0n $
  612. X *
  613. X *
  614. X * This file specifies the "implementation-independent" BOOTP protocol
  615. X * information which is common to both client and server.
  616. X *
  617. X */
  618. X
  619. X
  620. X#define BP_CHADDR_LEN     16
  621. X#define BP_SNAME_LEN     64
  622. X#define BP_FILE_LEN    128
  623. X#define BP_VEND_LEN     64
  624. X
  625. Xstruct bootp {
  626. X    unsigned char    bp_op;            /* packet opcode type */
  627. X    unsigned char    bp_htype;            /* hardware addr type */
  628. X    unsigned char    bp_hlen;            /* hardware addr length */
  629. X    unsigned char    bp_hops;            /* gateway hops */
  630. X    unsigned long    bp_xid;            /* transaction ID */
  631. X    unsigned short   bp_secs;            /* seconds since boot began */
  632. X    unsigned short   bp_unused;
  633. X    struct in_addr   bp_ciaddr;            /* client IP address */
  634. X    struct in_addr   bp_yiaddr;            /* 'your' IP address */
  635. X    struct in_addr   bp_siaddr;            /* server IP address */
  636. X    struct in_addr   bp_giaddr;            /* gateway IP address */
  637. X    unsigned char    bp_chaddr[BP_CHADDR_LEN];    /* client hardware address */
  638. X    unsigned char    bp_sname[BP_SNAME_LEN];    /* server host name */
  639. X    unsigned char    bp_file[BP_FILE_LEN];    /* boot file name */
  640. X    unsigned char    bp_vend[BP_VEND_LEN];    /* vendor-specific area */
  641. X};
  642. X
  643. X/*
  644. X * UDP port numbers, server and client.
  645. X */
  646. X#define    IPPORT_BOOTPS        67
  647. X#define    IPPORT_BOOTPC        68
  648. X
  649. X#define BOOTREPLY        2
  650. X#define BOOTREQUEST        1
  651. X
  652. X
  653. X/*
  654. X * Hardware types from Assigned Numbers RFC.
  655. X */
  656. X#define HTYPE_ETHERNET          1
  657. X#define HTYPE_EXP_ETHERNET      2
  658. X#define HTYPE_AX25          3
  659. X#define HTYPE_PRONET          4
  660. X#define HTYPE_CHAOS          5
  661. X#define HTYPE_IEEE802          6
  662. X#define HTYPE_ARCNET          7
  663. X
  664. X
  665. X
  666. X/*
  667. X * Vendor magic cookie (v_magic) for CMU
  668. X */
  669. X#define VM_CMU        "CMU"
  670. X
  671. X/*
  672. X * Vendor magic cookie (v_magic) for RFC1048
  673. X */
  674. X#define VM_RFC1048    { 99, 130, 83, 99 }
  675. X
  676. X
  677. X
  678. X/*
  679. X * RFC1048 tag values used to specify what information is being supplied in
  680. X * the vendor field of the packet.
  681. X */
  682. X
  683. X#define TAG_PAD            ((unsigned char)   0)
  684. X#define TAG_SUBNET_MASK        ((unsigned char)   1)
  685. X#define TAG_TIME_OFFSET        ((unsigned char)   2)
  686. X#define TAG_GATEWAY        ((unsigned char)   3)
  687. X#define TAG_TIME_SERVER        ((unsigned char)   4)
  688. X#define TAG_NAME_SERVER        ((unsigned char)   5)
  689. X#define TAG_DOMAIN_SERVER    ((unsigned char)   6)
  690. X#define TAG_LOG_SERVER        ((unsigned char)   7)
  691. X#define TAG_COOKIE_SERVER    ((unsigned char)   8)
  692. X#define TAG_LPR_SERVER        ((unsigned char)   9)
  693. X#define TAG_IMPRESS_SERVER    ((unsigned char)  10)
  694. X#define TAG_RLP_SERVER        ((unsigned char)  11)
  695. X#define TAG_HOSTNAME        ((unsigned char)  12)
  696. X#define TAG_BOOTSIZE        ((unsigned char)  13)
  697. X#define TAG_END            ((unsigned char) 255)
  698. X
  699. X
  700. X
  701. X/*
  702. X * "vendor" data permitted for CMU bootp clients.
  703. X */
  704. X
  705. Xstruct cmu_vend {
  706. X    unsigned char    v_magic[4];    /* magic number */
  707. X    unsigned long    v_flags;    /* flags/opcodes, etc. */
  708. X    struct in_addr     v_smask;    /* Subnet mask */
  709. X    struct in_addr     v_dgate;    /* Default gateway */
  710. X    struct in_addr    v_dns1, v_dns2; /* Domain name servers */
  711. X    struct in_addr    v_ins1, v_ins2; /* IEN-116 name servers */
  712. X    struct in_addr    v_ts1, v_ts2;    /* Time servers */
  713. X    unsigned long    v_unused[6];    /* currently unused */
  714. X};
  715. X
  716. X
  717. X/* v_flags values */
  718. X#define VF_SMASK    1    /* Subnet mask field contains valid data */
  719. END_OF_FILE
  720. if test 4479 -ne `wc -c <'bootp.h'`; then
  721.     echo shar: \"'bootp.h'\" unpacked with wrong size!
  722. fi
  723. # end of 'bootp.h'
  724. fi
  725. if test -f 'bootpd.8' -a "${1}" != "-c" ; then 
  726.   echo shar: Will not clobber existing file \"'bootpd.8'\"
  727. else
  728. echo shar: Extracting \"'bootpd.8'\" \(4357 characters\)
  729. sed "s/^X//" >'bootpd.8' <<'END_OF_FILE'
  730. X.\" Copyright (c) 1988, 1989, 1991 Carnegie Mellon University
  731. X.\"
  732. X.\"    $Header: /afs/andrew.cmu.edu/netdev/src/cmu/bootp-public/RCS/bootpd.8,v 1.1 1991/10/31 19:15:12 ww0n Exp ww0n $
  733. X.\"
  734. X.TH BOOTPD 8 "November 11, 1991" "Carnegie Mellon University"
  735. X.UC 6
  736. X
  737. X.SH NAME
  738. Xbootpd \- Internet Boot Protocol server
  739. X.SH SYNOPSIS
  740. X.B /etc/bootpd
  741. X[
  742. X.B \-i
  743. X.B \-s
  744. X.B \-t
  745. Xtimeout
  746. X.B \-d
  747. Xlevel
  748. X]
  749. X[
  750. X.I configfile
  751. X[
  752. X.I dumpfile
  753. X] ]
  754. X.SH DESCRIPTION
  755. X.I Bootpd
  756. Ximplements an Internet Bootstrap Protocol server as defined in RFC951,
  757. XRFC1048, and RFC1084.  It is normally run by
  758. X.I /etc/inetd
  759. Xby including the following line in the file
  760. X.IR /etc/inetd.conf :
  761. X.PP
  762. X.br
  763. X    bootps    dgram    udp    wait    root    /etc/bootpd    bootpd
  764. X.PP
  765. XThis mode of operation is referred to as "inetd mode" and causes
  766. X.I bootpd
  767. Xto be started only when a boot request arrives.  If
  768. X.I bootpd
  769. Xdoes not receive another boot request within fifteen minutes of the last one
  770. Xit received, it will exit to conserve system resources.  The
  771. X.B \-t
  772. Xswitch may be used to specify a different timeout value in minutes (e.g.
  773. X-t 20).  A timeout value of zero means forever.
  774. X.PP
  775. XIt is also possible to run
  776. X.I bootpd
  777. Xin "standalone mode" (without
  778. X.IR inetd )
  779. Xby simply invoking it from a shell like any other regular command.
  780. XStandalone mode is probably the desired mode of operation for large network
  781. Xinstallations with many BOOTP clients.  (The greater the number of clients
  782. Xlisted in the configuration database,
  783. X.IR /etc/bootptab ,
  784. Xthe longer it takes
  785. X.I bootpd
  786. Xto start up.  To ensure quick response to clients in a large network,
  787. Xit is better to start
  788. X.I bootpd
  789. Xonce during the server machine's bootup sequence.  This can be done by invoking
  790. X.I bootpd
  791. Xfrom within
  792. X.IR /etc/rc.local ,
  793. Xfor example.)
  794. X. 
  795. XIn standalone mode, the
  796. X.B \-t
  797. Xswitch has no effect since
  798. X.I bootpd
  799. Xwill never exit.
  800. X.PP
  801. XThe server automatically detects whether it was invoked from inetd or from a
  802. Xshell and automatically selects the appropriate mode.  For compatibility with
  803. Xolder versions of
  804. X.IR bootpd ,
  805. Xthe
  806. X.B \-s
  807. Xswitch may be used to force standalone operation.  Similarly, the
  808. X.B \-i
  809. Xswitch may be used to force the inetd mode of operation.  Normally, though,
  810. Xit should be unnecessary to use these switches.
  811. X.PP
  812. XThe
  813. X.B \-d
  814. Xswitch takes a numeric parameter which sets the level of debugging output.
  815. XFor example, -d4 or -d 4 will set the debugging level to 4.
  816. XFor compatibility with older versions of
  817. X.IR bootpd ,
  818. Xomitting the numeric parameter (i.e. just -d) will
  819. Xsimply increment the debug level by one.
  820. X.PP
  821. XUpon startup,
  822. X.I bootpd
  823. Xfirst reads its configuration file,
  824. X.IR /etc/bootptab ,
  825. Xand then begins listening for BOOTREQUEST packets.
  826. X.PP
  827. X.I Bootpd
  828. Xlooks in
  829. X.I /etc/services
  830. Xto find the UDP port numbers it should use.  Two entries are extracted:
  831. X.BR bootps ,
  832. Xthe bootp server listening port, and
  833. X.BR bootpc ,
  834. Xthe destination port used to reply to clients.  If the port numbers cannot
  835. Xbe determined this way,
  836. X.I bootpd
  837. Xdefaults to using 67 for the server and 68 for the client.
  838. X.PP
  839. X.I Bootpd
  840. Xcompletely reloads its configuration file when it receives a hangup signal,
  841. XSIGHUP, or when it receives a BOOTREQUEST packet and detects that the file
  842. Xhas been updated.  If
  843. X.I bootpd
  844. Xis compiled with the -DDEBUG option, receipt of a SIGUSR1 signal causes it
  845. Xto dump its memory-resident database to
  846. Xthe file
  847. X.I /etc/bootpd.dump
  848. Xor the command-line-specified dumpfile.
  849. X
  850. X.SH FILES
  851. X/etc/bootptab
  852. X.br
  853. X/etc/bootpd.dump
  854. X.br
  855. X/etc/services
  856. X
  857. X.SH BUGS
  858. XIndividual host entries must not exceed 1024 characters.
  859. X
  860. X.SH HISTORY
  861. X.TP
  862. X22-Jan-86  Bill Croft at Stanford University
  863. X.br
  864. XCreated.
  865. X
  866. X.TP
  867. X30-Jul-86  David Kovar at Carnegie Mellon University
  868. X.br
  869. XModified to CMU specifications.
  870. X
  871. X.TP
  872. X24-Jul-87  Drew D. Perkins at Carnegie Mellon University
  873. X.br
  874. XModified to use syslog.  Added debugging dumps.  Other bug fixes.
  875. X
  876. X.TP
  877. X17-Jul-88  Walter L. Wimer at Carnegie Mellon University
  878. X.br
  879. XAdded vendor information to conform to RFC1048.
  880. XAdopted termcap-like file format to allow variable data.
  881. X
  882. X.TP
  883. X11-Nov-91  Walter L. Wimer at Carnegie Mellon University
  884. X.br
  885. XAdded TFTP directory- and server-specification features.  Added automatic
  886. Xdetection of inetd/standalone mode, making -s switch no longer necessary.
  887. XOther minor improvements and bug fixes.
  888. X
  889. X.SH "SEE ALSO"
  890. X.br
  891. Xbootptab(5), inetd(8), tftpd(8),
  892. X.br
  893. XDARPA Internet Request For Comments RFC951, RFC1048, RFC1084, Assigned Numbers
  894. END_OF_FILE
  895. if test 4357 -ne `wc -c <'bootpd.8'`; then
  896.     echo shar: \"'bootpd.8'\" unpacked with wrong size!
  897. fi
  898. # end of 'bootpd.8'
  899. fi
  900. if test -f 'bootpd.h' -a "${1}" != "-c" ; then 
  901.   echo shar: Will not clobber existing file \"'bootpd.h'\"
  902. else
  903. echo shar: Extracting \"'bootpd.h'\" \(5535 characters\)
  904. sed "s/^X//" >'bootpd.h' <<'END_OF_FILE'
  905. X#ifndef _BLURB_
  906. X#define _BLURB_
  907. X/************************************************************************
  908. X          Copyright 1988, 1991 by Carnegie Mellon University
  909. X
  910. X                          All Rights Reserved
  911. X
  912. XPermission to use, copy, modify, and distribute this software and its
  913. Xdocumentation for any purpose and without fee is hereby granted, provided
  914. Xthat the above copyright notice appear in all copies and that both that
  915. Xcopyright notice and this permission notice appear in supporting
  916. Xdocumentation, and that the name of Carnegie Mellon University not be used
  917. Xin advertising or publicity pertaining to distribution of the software
  918. Xwithout specific, written prior permission.
  919. X
  920. XCARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  921. XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  922. XIN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  923. XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  924. XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  925. XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  926. XSOFTWARE.
  927. X************************************************************************/
  928. X#endif /* _BLURB_ */
  929. X
  930. X
  931. X/*
  932. X * bootpd.h -- common header file for all the modules of the bootpd program.
  933. X */
  934. X
  935. X
  936. X#ifndef TRUE
  937. X#define TRUE    1
  938. X#endif
  939. X#ifndef FALSE
  940. X#define FALSE    0
  941. X#endif
  942. X
  943. X#ifndef PRIVATE
  944. X#define PRIVATE static
  945. X#endif
  946. X
  947. X#ifndef SIGUSR1
  948. X#define SIGUSR1             30    /* From 4.3 <signal.h> */
  949. X#endif
  950. X
  951. X#define MAXHADDRLEN          6    /* Max hw address length in bytes */
  952. X#define MAXSTRINGLEN         80    /* Max string length */
  953. X
  954. X/*
  955. X * Return the length in bytes of a hardware address of the given type.
  956. X * Return the canonical name of the network of the given type.
  957. X */
  958. X#define haddrlength(type)    ((hwinfolist[(int) (type)]).hlen)
  959. X#define netname(type)        ((hwinfolist[(int) (type)]).name)
  960. X
  961. X
  962. X/*
  963. X * Return pointer to static string which gives full network error message.
  964. X */
  965. X#define get_network_errmsg get_errmsg
  966. X
  967. X
  968. X/*
  969. X * Variables shared among modules.
  970. X */
  971. X
  972. Xextern int debug;
  973. Xextern char *bootptab;
  974. X
  975. Xextern struct hwinfo hwinfolist[];
  976. Xextern int hwinfocnt;
  977. X
  978. Xextern hash_tbl *hwhashtable;
  979. Xextern hash_tbl *iphashtable;
  980. Xextern hash_tbl *nmhashtable;
  981. Xextern unsigned char vm_cmu[4];
  982. Xextern unsigned char vm_rfc1048[4];
  983. X
  984. X
  985. X/*
  986. X * Functions shared among modules
  987. X */
  988. X
  989. Xextern void report();
  990. Xextern char *get_errmsg();
  991. Xextern char *haddrtoa();
  992. Xextern void readtab();
  993. X
  994. X
  995. X
  996. X/*
  997. X * Nice typedefs. . .
  998. X */
  999. X
  1000. Xtypedef int boolean;
  1001. Xtypedef unsigned char byte;
  1002. X
  1003. X
  1004. X/*
  1005. X * This structure holds information about a specific network type.  The
  1006. X * length of the network hardware address is stored in "hlen".
  1007. X * The string pointed to by "name" is the cononical name of the network.
  1008. X */
  1009. X
  1010. Xstruct hwinfo {
  1011. X    unsigned hlen;
  1012. X    char *name;
  1013. X};
  1014. X
  1015. X
  1016. X
  1017. X/*
  1018. X * Data structure used to hold an arbitrary-lengthed list of IP addresses.
  1019. X * The list may be shared among multiple hosts by setting the linkcount
  1020. X * appropriately.
  1021. X */
  1022. X
  1023. Xstruct in_addr_list {
  1024. X    unsigned        linkcount, addrcount;
  1025. X    struct in_addr    addr[1];        /* Dynamically extended */
  1026. X};
  1027. X
  1028. X
  1029. X/*
  1030. X * Data structures used to hold shared strings and shared binary data.
  1031. X * The linkcount must be set appropriately.
  1032. X */
  1033. X
  1034. Xstruct shared_string {
  1035. X    unsigned        linkcount;
  1036. X    char        string[1];        /* Dynamically extended */
  1037. X};
  1038. X
  1039. Xstruct shared_bindata {
  1040. X    unsigned        linkcount, length;
  1041. X    byte        data[1];        /* Dynamically extended */
  1042. X};
  1043. X
  1044. X
  1045. X/*
  1046. X * Flag structure which indicates which symbols have been defined for a
  1047. X * given host.  This information is used to determine which data should or
  1048. X * should not be reported in the bootp packet vendor info field.
  1049. X */
  1050. X
  1051. Xstruct flag {
  1052. X    unsigned    bootfile    :1,
  1053. X        bootserver    :1,
  1054. X        bootsize    :1,
  1055. X        bootsize_auto    :1,
  1056. X        cookie_server    :1,
  1057. X        domain_server    :1,
  1058. X        gateway        :1,
  1059. X        generic        :1,
  1060. X        haddr        :1,
  1061. X        homedir        :1,
  1062. X        htype        :1,
  1063. X        impress_server    :1,
  1064. X        iaddr        :1,
  1065. X        log_server    :1,
  1066. X        lpr_server    :1,
  1067. X        name_server    :1,
  1068. X        name_switch    :1,
  1069. X        rlp_server    :1,
  1070. X        send_name    :1,
  1071. X        subnet_mask    :1,
  1072. X        tftpdir        :1,
  1073. X        time_offset    :1,
  1074. X        timeoff_auto    :1,
  1075. X        time_server    :1,
  1076. X        vendor_magic    :1,
  1077. X        vm_auto        :1;
  1078. X};
  1079. X
  1080. X
  1081. X
  1082. X/*
  1083. X * The flags structure contains TRUE flags for all the fields which
  1084. X * are considered valid, regardless of whether they were explicitly
  1085. X * specified or indirectly inferred from another entry.
  1086. X *
  1087. X * The gateway and the various server fields all point to a shared list of
  1088. X * IP addresses.
  1089. X *
  1090. X * The hostname, home directory, and bootfile are all shared strings.
  1091. X *
  1092. X * The generic data field is a shared binary data structure.  It is used to
  1093. X * hold future RFC1048 vendor data until bootpd is updated to understand it.
  1094. X *
  1095. X * The vm_cookie field specifies the four-octet vendor magic cookie to use
  1096. X * if it is desired to always send the same response to a given host.
  1097. X *
  1098. X * Hopefully, the rest is self-explanatory.
  1099. X */
  1100. X
  1101. Xstruct host {
  1102. X    struct flag            flags;        /* ALL valid fields */
  1103. X    struct in_addr_list        *cookie_server,
  1104. X                *domain_server,
  1105. X                *gateway,
  1106. X                *impress_server,
  1107. X                *log_server,
  1108. X                *lpr_server,
  1109. X                *name_server,
  1110. X                *rlp_server,
  1111. X                *time_server;
  1112. X    struct shared_string    *bootfile,
  1113. X                *hostname,
  1114. X                *homedir,
  1115. X                *tftpdir;
  1116. X    struct shared_bindata   *generic;
  1117. X    byte            vm_cookie[4],
  1118. X                htype,  /* RFC826 says this should be 16-bits but
  1119. X                       RFC951 only allocates 1 byte. . . */
  1120. X                haddr[MAXHADDRLEN];
  1121. X    long            time_offset;
  1122. X    unsigned int        bootsize;
  1123. X    struct in_addr        bootserver,
  1124. X                iaddr,
  1125. X                subnet_mask;
  1126. X};
  1127. END_OF_FILE
  1128. if test 5535 -ne `wc -c <'bootpd.h'`; then
  1129.     echo shar: \"'bootpd.h'\" unpacked with wrong size!
  1130. fi
  1131. # end of 'bootpd.h'
  1132. fi
  1133. if test -f 'bootptab' -a "${1}" != "-c" ; then 
  1134.   echo shar: Will not clobber existing file \"'bootptab'\"
  1135. else
  1136. echo shar: Extracting \"'bootptab'\" \(2073 characters\)
  1137. sed "s/^X//" >'bootptab' <<'END_OF_FILE'
  1138. X# /etc/bootptab: database for bootp server (/etc/bootpd)
  1139. X# Last update: gwr, Tue Jun  8 09:53:46 EDT 1993
  1140. X# Blank lines and lines beginning with '#' are ignored.
  1141. X#
  1142. X# Legend:    (see bootptab.5)
  1143. X#
  1144. X#    first field -- hostname
  1145. X#            (may be full domain name and probably should be)
  1146. X#
  1147. X#    hd -- home directory (dir relative to /tftpboot)
  1148. X#    hn -- send the client its host name (does this work?)
  1149. X#    bf -- bootfile
  1150. X#    cs -- cookie servers
  1151. X#    ds -- domain name servers
  1152. X#    gw -- gateways
  1153. X#    ha -- hardware address
  1154. X#    ht -- hardware type
  1155. X#    im -- impress servers
  1156. X#    ip -- host IP address
  1157. X#    lg -- log servers
  1158. X#    lp -- LPR servers
  1159. X#    ns -- IEN-116 name servers
  1160. X#    rl -- resource location protocol servers
  1161. X#    sm -- subnet mask
  1162. X#    tc -- template host (points to similar host entry)
  1163. X#    to -- time offset (seconds)
  1164. X#    ts -- time servers
  1165. X
  1166. X#
  1167. X# Be careful about including backslashes where they're needed.  Weird (bad)
  1168. X# things can happen when a backslash is omitted where one is intended.
  1169. X#
  1170. X
  1171. X
  1172. X# First, we define a global entry which specifies the stuff every host uses.
  1173. X
  1174. Xglobal.dummy:\
  1175. X    :td=/tftpboot:\
  1176. X    :hd=/tftpboot:\
  1177. X    :hn:bf=null:
  1178. X
  1179. X# Next, we can define different master entries for each subnet. . .
  1180. X
  1181. Xsubnet16.dummy:\
  1182. X    :tc=global.dummy:\
  1183. X    :sm=255.255.255.0:\
  1184. X    :gw=192.233.16.15:\
  1185. X    :ds=192.233.16.4:
  1186. X
  1187. Xsubnet17.dummy:\
  1188. X    :tc=global.dummy:\
  1189. X    :sm=255.255.255.0:\
  1190. X    :gw=192.233.17.32:\
  1191. X    :ds=192.233.17.28:
  1192. X
  1193. X#
  1194. X# We should be able to use as many levels of indirection as desired.  Use
  1195. X# your imagination. . .
  1196. X#
  1197. X
  1198. X# Individual entries (could also have different servers for some/all of these
  1199. X# hosts, but we don't really use this feature at CMU):
  1200. X
  1201. X# This is for testing the arbitrary tag option:
  1202. X# T14 is the NIS domain name
  1203. X# T15 is the NIS server list
  1204. Xwalnut:tc=subnet16.dummy:ht=ethernet:ha=08.00.20.0E.FF.30:\
  1205. X    :ip=192.233.16.24:bf=boot.sun4c:\
  1206. X    :T14="mc.com":T15=192.233.16.4:
  1207. X
  1208. X# Tadpole 885 board.
  1209. Xtp885:tc=subnet17.dummy:ht=ethernet:ha=08.00.4C.00.2F.74:\
  1210. X    :ip=192.233.17.42:bf=tp885sys1.cfe:
  1211. X
  1212. X# MVME147 VxWorks board.
  1213. Xmvme147:tc=subnet17.dummy:ht=ethernet:ha=08.00.3e.20.da.47:\
  1214. X    :ip=192.233.17.41:bf=mv147vxw.st:
  1215. X
  1216. END_OF_FILE
  1217. if test 2073 -ne `wc -c <'bootptab'`; then
  1218.     echo shar: \"'bootptab'\" unpacked with wrong size!
  1219. fi
  1220. # end of 'bootptab'
  1221. fi
  1222. if test -f 'bootptab.5' -a "${1}" != "-c" ; then 
  1223.   echo shar: Will not clobber existing file \"'bootptab.5'\"
  1224. else
  1225. echo shar: Extracting \"'bootptab.5'\" \(10623 characters\)
  1226. sed "s/^X//" >'bootptab.5' <<'END_OF_FILE'
  1227. X.\" Copyright (c) 1988, 1989, 1991 Carnegie Mellon University
  1228. X.\"
  1229. X.\"    $Header: /afs/andrew.cmu.edu/netdev/src/cmu/bootp-public/RCS/bootpd.8,v 1.1 1991/10/31 19:15:12 ww0n Exp ww0n $
  1230. X.\"
  1231. X.TH BOOTPTAB 5 "October 31, 1991" "Carnegie Mellon University"
  1232. X.UC 6
  1233. X
  1234. X.SH NAME
  1235. Xbootptab \- Internet Bootstrap Protocol server database
  1236. X.SH DESCRIPTION
  1237. XThe
  1238. X.I bootptab
  1239. Xfile is the configuration database file for
  1240. X.IR bootpd ,
  1241. Xthe Internet Bootstrap Protocol server.
  1242. XIt's format is similar to that of
  1243. X.IR termcap (5)
  1244. Xin which two-character case-sensitive tag symbols are used to
  1245. Xrepresent host parameters.  These parameter declarations are separated by
  1246. Xcolons (:), with a general format of:
  1247. X.PP
  1248. X.I "    hostname:tg=value. . . :tg=value. . . :tg=value. . . ."
  1249. X.PP
  1250. Xwhere
  1251. X.I hostname
  1252. Xis the actual name of a bootp client and
  1253. X.I tg
  1254. Xis a two-character tag symbol.  Most tags must be followed by an equals-sign
  1255. Xand a value as above.  Some may also appear in a boolean form with no
  1256. Xvalue (i.e.
  1257. X.RI : tg :).
  1258. XThe currently recognized tags are:
  1259. X.PP
  1260. X.br
  1261. X    bf    Bootfile
  1262. X.br
  1263. X    bs    Bootfile size in 512-octet blocks
  1264. X.br
  1265. X    cs    Cookie server address list
  1266. X.br
  1267. X    ds    Domain name server address list
  1268. X.br
  1269. X    gw    Gateway address list
  1270. X.br
  1271. X    ha    Host hardware address
  1272. X.br
  1273. X    hd    Bootfile home directory
  1274. X.br
  1275. X    hn    Send client's hostname to client
  1276. X.br
  1277. X    ht    Host hardware type (see Assigned Numbers RFC)
  1278. X.br
  1279. X    im    Impress server address list
  1280. X.br
  1281. X    ip    Host IP address
  1282. X.br
  1283. X    lg    Log server address list
  1284. X.br
  1285. X    lp    LPR server address list
  1286. X.br
  1287. X    ns    IEN-116 name server address list
  1288. X.br
  1289. X    rl    Resource location protocol server address list
  1290. X.br
  1291. X    sa    TFTP server address client should use
  1292. X.br
  1293. X    sm    Host subnet mask
  1294. X.br
  1295. X    tc    Table continuation (points to similar "template" host entry)
  1296. X.br
  1297. X    td    TFTP root directory used by "secure" TFTP servers
  1298. X.br
  1299. X    to    Time offset in seconds from UTC
  1300. X.br
  1301. X    ts    Time server address list
  1302. X.br
  1303. X    vm    Vendor magic cookie selector
  1304. X
  1305. X.PP
  1306. XThere is also a generic tag,
  1307. X.RI T n ,
  1308. Xwhere
  1309. X.I n
  1310. Xis an RFC1084 vendor field tag number.  Thus it is possible to immediately
  1311. Xtake advantage of future extensions to RFC1084 without being forced to modify
  1312. X.I bootpd
  1313. Xfirst.  Generic data may be represented as either a stream of hexadecimal
  1314. Xnumbers or as a quoted string of ASCII characters.  The length of the generic
  1315. Xdata is automatically determined and inserted into the proper field(s) of the
  1316. XRFC1084-style bootp reply.
  1317. X.PP
  1318. XThe following tags take a whitespace-separated list of IP addresses:
  1319. X.BR cs ,
  1320. X.BR ds ,
  1321. X.BR gw ,
  1322. X.BR im ,
  1323. X.BR lg ,
  1324. X.BR lp ,
  1325. X.BR ns ,
  1326. X.BR rl ,
  1327. Xand
  1328. X.BR ts .
  1329. XThe
  1330. X.BR ip ,
  1331. X.BR sa ,
  1332. Xand
  1333. X.B sm
  1334. Xtags each take a single IP address.
  1335. XAll IP addresses are specified in standard Internet "dot" notation and may use
  1336. Xdecimal, octal, or hexadecimal numbers (octal numbers begin with 0,
  1337. Xhexadecimal numbers begin with '0x' or '0X').
  1338. X.PP
  1339. XThe
  1340. X.B ht
  1341. Xtag specifies the hardware type code as either an unsigned decimal, octal, or
  1342. Xhexadecimal integer or one of the following symbolic names:
  1343. X.B ethernet
  1344. Xor
  1345. X.B ether
  1346. Xfor 10Mb Ethernet,
  1347. X.B ethernet3
  1348. Xor
  1349. X.B ether3
  1350. Xfor 3Mb experimental Ethernet,
  1351. X.BR ieee802 ,
  1352. X.BR tr ,
  1353. Xor
  1354. X.B token-ring
  1355. Xfor IEEE 802 networks,
  1356. X.B pronet
  1357. Xfor Proteon ProNET Token Ring, or
  1358. X.BR chaos ,
  1359. X.BR arcnet ,
  1360. Xor
  1361. X.B ax.25
  1362. Xfor Chaos, ARCNET, and AX.25 Amateur Radio networks, respectively.
  1363. XThe
  1364. X.B ha
  1365. Xtag takes a hardware address which
  1366. X.I must
  1367. Xbe specified in hexadecimal; optional periods and/or a leading '0x' may be
  1368. Xincluded for readability.  The
  1369. X.B ha
  1370. Xtag must be preceded by the
  1371. X.B ht
  1372. Xtag (either explicitly or implicitly; see
  1373. X.B tc
  1374. Xbelow).
  1375. X.PP
  1376. XThe hostname, home directory, and bootfile are ASCII strings which may be
  1377. Xoptionally surrounded by double quotes (").  The client's request and the
  1378. Xvalues of the
  1379. X.B hd
  1380. Xand
  1381. X.B bf
  1382. Xsymbols determine how the server fills in the bootfile field of the bootp
  1383. Xreply packet.
  1384. X.PP
  1385. XIf the client specifies an absolute pathname and that file exists on the
  1386. Xserver machine, that pathname is returned in the reply packet.  If the file
  1387. Xcannot be found, the request is discarded; no reply is sent.  If the client
  1388. Xspecifies a relative pathname, a full pathname is formed by prepending the
  1389. Xvalue of the
  1390. X.B hd
  1391. Xtag and testing for existence of the file.  If the
  1392. X.B hd
  1393. Xtag is not supplied in the configuration file or if the resulting boot file
  1394. Xcannot be found, then the request is discarded.
  1395. X.PP
  1396. XClients which specify null boot files will always elicit a reply from the
  1397. Xserver.  The exact reply will again depend upon the
  1398. X.B hd
  1399. Xand
  1400. X.B bf
  1401. Xtags.  If the
  1402. X.B bf
  1403. Xtag gives an absolute pathname and the file exists, that pathname is returned
  1404. Xin the reply packet.  Otherwise, if the
  1405. X.B hd
  1406. Xand
  1407. X.B bf
  1408. Xtags together specify an accessible file, that filename is returned in the
  1409. Xreply.  If a complete filename cannot be determined or the file does not
  1410. Xexist, the reply will contain a zeroed-out bootfile field.
  1411. X.PP
  1412. XIn all these cases, existence of the file means that, in addition to actually
  1413. Xbeing present, the file must have its public read access bit set, since this
  1414. Xis required by
  1415. X.IR tftpd (8)
  1416. Xto permit the file transfer.  Also, all filenames are first tried as
  1417. X.I filename.hostname
  1418. Xand then simply as
  1419. X.IR filename ,
  1420. Xthus providing for individual per-host bootfiles.
  1421. X.PP
  1422. XSome newer versions of
  1423. X.I tftpd
  1424. Xprovide a security feature to change their root directory using
  1425. Xthe
  1426. X.IR chroot (2)
  1427. Xsystem call.
  1428. XThe
  1429. X.B td
  1430. Xtag may be used to inform
  1431. X.I bootpd
  1432. Xof this special root directory used by
  1433. X.IR tftpd .
  1434. XThe
  1435. X.B hd
  1436. Xtag is actually relative to the root directory specified by the
  1437. X.B td
  1438. Xtag.
  1439. XFor example, if the real absolute path to your BOOTP client bootfile is
  1440. X/tftpboot/bootfiles/bootimage, and
  1441. X.IR tftpd
  1442. Xuses /tftpboot as its "secure" directory, then specify the following in
  1443. X.IR bootptab :
  1444. X.PP
  1445. X.br
  1446. X    :td=/tftpboot:hd=/bootfiles:bf=bootimage:
  1447. X.PP
  1448. XIf your bootfiles are located directly in /tftpboot, use:
  1449. X.PP
  1450. X.br
  1451. X    :td=/tftpboot:hd=/:bf=bootimage:
  1452. X.PP
  1453. XThe
  1454. X.B sa
  1455. Xtag may be used to specify the IP address of the particular TFTP server
  1456. Xyou wish the client to use.  In the absence of this tag,
  1457. X.I bootpd
  1458. Xwill tell the client to perform TFTP to the same machine
  1459. X.I bootpd
  1460. Xis running on.
  1461. X.PP
  1462. XThe time offset
  1463. X.B to
  1464. Xmay be either a signed decimal integer specifying the client's
  1465. Xtime zone offset in seconds from UTC, or the keyword
  1466. X.B auto
  1467. Xwhich uses the server's time zone offset.  Specifying the
  1468. X.B to
  1469. Xsymbol as a boolean has the same effect as specifying
  1470. X.B auto
  1471. Xas its value.
  1472. X.PP
  1473. XThe bootfile size
  1474. X.B bs
  1475. Xmay be either a decimal, octal, or hexadecimal integer specifying the size of
  1476. Xthe bootfile in 512-octet blocks, or the keyword
  1477. X.B auto
  1478. Xwhich causes the server to automatically calculate the bootfile size at each
  1479. Xrequest.  As with the time offset, specifying the
  1480. X.B bs
  1481. Xsymbol as a boolean has the same effect as specifying
  1482. X.B auto
  1483. Xas its value.
  1484. X.PP
  1485. XThe vendor magic cookie selector (the
  1486. X.B vm
  1487. Xtag) may take one of the following keywords:
  1488. X.B auto
  1489. X(indicating that vendor information is determined by the client's request),
  1490. X.B rfc1048
  1491. Xor
  1492. X.B rfc1084
  1493. X(which always forces an RFC1084-style reply), or
  1494. X.B cmu
  1495. X(which always forces a CMU-style reply).
  1496. X.PP
  1497. XThe
  1498. X.B hn
  1499. Xtag is strictly a boolean tag; it does not take the usual equals-sign and
  1500. Xvalue.  It's presence indicates that the hostname should be sent to RFC1084
  1501. Xclients.
  1502. X.I Bootpd
  1503. Xattempts to send the entire hostname as it is specified in the configuration
  1504. Xfile; if this will not fit into the reply packet, the name is shortened to
  1505. Xjust the host field (up to the first period, if present) and then tried.
  1506. XIn no case is an arbitrarily-truncated hostname sent (if nothing reasonable
  1507. Xwill fit, nothing is sent).
  1508. X.PP
  1509. XOften, many host entries share common values for certain tags (such as name
  1510. Xservers, etc.).  Rather than repeatedly specifying these tags, a full
  1511. Xspecification can be listed for one host entry and shared by others via the
  1512. X.B tc
  1513. X(table continuation) mechanism.
  1514. XOften, the template entry is a dummy host which doesn't actually exist and
  1515. Xnever sends bootp requests.  This feature is similar to the
  1516. X.B tc
  1517. Xfeature of
  1518. X.IR termcap (5)
  1519. Xfor similar terminals.  Note that
  1520. X.I bootpd
  1521. Xallows the
  1522. X.B tc
  1523. Xtag symbol to appear anywhere in the host entry, unlike
  1524. X.I termcap
  1525. Xwhich requires it to be the last tag.  Information explicitly specified for a
  1526. Xhost always overrides information implied by a
  1527. X.B tc
  1528. Xtag symbol, regardless of its location within the entry.  The
  1529. Xvalue of the
  1530. X.B tc
  1531. Xtag may be the hostname or IP address of any host entry
  1532. Xpreviously listed in the configuration file.
  1533. X.PP
  1534. XSometimes it is necessary to delete a specific tag after it has been inferred
  1535. Xvia
  1536. X.BR tc .
  1537. XThis can be done using the construction
  1538. X.IB tag @
  1539. Xwhich removes the effect of
  1540. X.I tag
  1541. Xas in
  1542. X.IR termcap (5).
  1543. XFor example, to completely undo an IEN-116 name server specification, use
  1544. X":ns@:" at an appropriate place in the configuration entry.  After removal
  1545. Xwith
  1546. X.BR @ ,
  1547. Xa tag is eligible to be set again through the
  1548. X.B tc
  1549. Xmechanism.
  1550. X.PP
  1551. XBlank lines and lines beginning with "#" are ignored in the configuration
  1552. Xfile.  Host entries are separated from one another by newlines; a single host
  1553. Xentry may be extended over multiple lines if the lines end with a backslash
  1554. X(\\).  It is also acceptable for lines to be longer than 80 characters.  Tags
  1555. Xmay appear in any order, with the following exceptions:  the hostname must be
  1556. Xthe very first field in an entry, and the hardware type must precede the
  1557. Xhardware address.
  1558. X.PP
  1559. XAn example
  1560. X.I /etc/bootptab
  1561. Xfile follows:
  1562. X.PP
  1563. X
  1564. X.br
  1565. X    # Sample bootptab file
  1566. X
  1567. X.br
  1568. X    default1:\\
  1569. X.br
  1570. X        :hd=/usr/boot:bf=null:\\
  1571. X.br
  1572. X        :ds=128.2.35.50 128.2.13.21:\\
  1573. X.br
  1574. X        :ns=0x80020b4d 0x80020ffd:\\
  1575. X.br
  1576. X        :ts=0x80020b4d 0x80020ffd:\\
  1577. X.br
  1578. X        :sm=255.255.0.0:gw=0x8002fe24:\\
  1579. X.br
  1580. X        :hn:vm=auto:to=-18000:\\
  1581. X.br
  1582. X        :T37=0x12345927AD3BCF:T99="Special ASCII string":
  1583. X
  1584. X.br
  1585. X    carnegie:ht=6:ha=7FF8100000AF:ip=128.2.11.1:tc=default1:
  1586. X.br
  1587. X    baldwin:ht=1:ha=0800200159C3:ip=128.2.11.10:tc=default1:
  1588. X.br
  1589. X    wylie:ht=1:ha=00DD00CADF00:ip=128.2.11.100:tc=default1:
  1590. X.br
  1591. X    arnold:ht=1:ha=0800200102AD:ip=128.2.11.102:tc=default1:
  1592. X.br
  1593. X    bairdford:ht=1:ha=08002B02A2F9:ip=128.2.11.103:tc=default1:
  1594. X.br
  1595. X    bakerstown:ht=1:ha=08002B0287C8:ip=128.2.11.104:tc=default1:
  1596. X
  1597. X.br
  1598. X    # Special domain name server for next host
  1599. X.br
  1600. X    butlerjct:ht=1:ha=08002001560D:ip=128.2.11.108:ds=128.2.13.42:tc=default1:
  1601. X
  1602. X.br
  1603. X    gastonville:ht=6:ha=7FFF81000A47:ip=128.2.11.115:tc=default1:
  1604. X.br
  1605. X    hahntown:ht=6:ha=7FFF81000434:ip=128.2.11.117:tc=default1:
  1606. X.br
  1607. X    hickman:ht=6:ha=7FFF810001BA:ip=128.2.11.118:tc=default1:
  1608. X.br
  1609. X    lowber:ht=1:ha=00DD00CAF000:ip=128.2.11.121:tc=default1:
  1610. X.br
  1611. X    mtoliver:ht=1:ha=00DD00FE1600:ip=128.2.11.122:tc=default1:
  1612. X
  1613. X
  1614. X.SH FILES
  1615. X/etc/bootptab
  1616. X
  1617. X.SH "SEE ALSO"
  1618. X.br
  1619. Xbootpd(8), tftpd(8),
  1620. X.br
  1621. XDARPA Internet Request For Comments RFC951, RFC1048, RFC1084, Assigned Numbers
  1622. END_OF_FILE
  1623. if test 10623 -ne `wc -c <'bootptab.5'`; then
  1624.     echo shar: \"'bootptab.5'\" unpacked with wrong size!
  1625. fi
  1626. # end of 'bootptab.5'
  1627. fi
  1628. if test -f 'gmods' -a "${1}" != "-c" ; then 
  1629.   echo shar: Will not clobber existing file \"'gmods'\"
  1630. else
  1631. echo shar: Extracting \"'gmods'\" \(5070 characters\)
  1632. sed "s/^X//" >'gmods' <<'END_OF_FILE'
  1633. XFolks,
  1634. X
  1635. XHere is a summary of the gateway mods needed for BOOTP (to allow
  1636. Xcross gateway booting), and some pseudo-code.  First the
  1637. XBOOTP packet (which is enclosed in an IP/UDP):
  1638. X
  1639. X====
  1640. X
  1641. X/*
  1642. X * Bootstrap Protocol (BOOTP).  RFC 951.
  1643. X */
  1644. X
  1645. Xstruct bootp {
  1646. X    u_char    bp_op;        /* packet opcode type */
  1647. X#define    BOOTREQUEST    1
  1648. X#define    BOOTREPLY    2
  1649. X    u_char    bp_htype;    /* hardware addr type */
  1650. X    u_char    bp_hlen;    /* hardware addr length */
  1651. X    u_char    bp_hops;    /* gateway hops */
  1652. X    u_long    bp_xid;        /* transaction ID */
  1653. X    u_short    bp_secs;    /* seconds since boot began */    
  1654. X    u_short    bp_unused;
  1655. X    iaddr_t    bp_ciaddr;    /* client IP address */
  1656. X    iaddr_t    bp_yiaddr;    /* 'your' IP address */
  1657. X    iaddr_t    bp_siaddr;    /* server IP address */
  1658. X    iaddr_t    bp_giaddr;    /* gateway IP address */
  1659. X    u_char    bp_chaddr[16];    /* client hardware address */
  1660. X    u_char    bp_sname[64];    /* server host name */
  1661. X    u_char    bp_file[128];    /* boot file name */
  1662. X    u_char    bp_vend[64];    /* vendor-specific area */
  1663. X};
  1664. X
  1665. X#define    IPPORT_BOOTPS        67
  1666. X#define    IPPORT_BOOTPC        68
  1667. X
  1668. X====
  1669. X
  1670. XNext, here is the section from [sri-nic]<rfc>rfc951.txt that has
  1671. Xmost to do with gateway issues.  However you will probably want to
  1672. Xhardcopy the entire document.
  1673. X
  1674. X====
  1675. X
  1676. X
  1677. XRFC 951                                                   September 1985
  1678. XBootstrap Protocol                        [Page 9]
  1679. X
  1680. X
  1681. X8. Booting Through Gateways
  1682. X
  1683. X   This part of the protocol is optional and requires some additional
  1684. X   code in cooperating gateways and servers, but it allows cross-gateway
  1685. X   booting.  This is mainly useful when gateways are diskless machines.
  1686. X   Gateways containing disks (e.g. a UNIX machine acting as a gateway),
  1687. X   might as well run their own BOOTP/TFTP servers.
  1688. X
  1689. X   Gateways listening to broadcast BOOTREQUESTs may decide to forward or
  1690. X   rebroadcast these requests 'when appropriate'.  For example, the
  1691. X   gateway could have, as part of his configuration tables, a list of
  1692. X   other networks or hosts to receive a copy of any broadcast
  1693. X   BOOTREQUESTs.  Even though a 'hops' field exists, it is a poor idea
  1694. X   to simply globally rebroadcast the requests, since broadcast loops
  1695. X   will almost certainly occur.
  1696. X
  1697. X   The forwarding could begin immediately, or wait until the 'secs'
  1698. X   (seconds client has been trying) field passes a certain threshold.
  1699. X
  1700. X   If a gateway does decide to forward the request, it should look at
  1701. X   the 'giaddr' (gateway IP address) field.  If zero, it should plug its
  1702. X   own IP address (on the receiving cable) into this field.  It may also
  1703. X   use the 'hops' field to optionally control how far the packet is
  1704. X   reforwarded. Hops should be incremented on each forwarding.  For
  1705. X   example, if hops passes '3', the packet should probably be discarded.
  1706. X
  1707. X====
  1708. X
  1709. XAnd here is some pseudo-code:
  1710. X
  1711. X
  1712. X/*
  1713. X * Each gateway will probably have a locally configured table
  1714. X * that lists the addresses of hosts (or gateways)
  1715. X * (or net numbers) to which BOOTP's can be
  1716. X * forwarded.  Assume this table is called 'bootplist'.  It
  1717. X * can be initialized at compile time, or via a config file.
  1718. X *
  1719. X * The easiest case will be to use specific host (or gateway)
  1720. X * addresses; if net addresses (e.g. 36.45.0.0) 
  1721. X * are used, that will probably require implementing IP directed
  1722. X * broadcasts.  It is probably best to start with the simple case
  1723. X * of a host list.
  1724. X */
  1725. Xxxxxxxx    bootplist[] = { , , , };
  1726. X
  1727. X
  1728. X/*
  1729. X * "ipreceive" is called with each incoming IP datagram.
  1730. X *
  1731. X * Packet headers for the respective layers are in: ether,ip,udp,bootp.
  1732. X */
  1733. Xipreceive()
  1734. X{
  1735. X    if (ether.dst == broadcast && ether.src == from_our_interfaces)
  1736. X        goto discard;
  1737. X    if (ipchecksum == bad || --ip.ttl <= 0)
  1738. X        goto discard;
  1739. X    if (ip.proto != UDP || udp.port != IPPORT_BOOTPS) 
  1740. X        goto forward;
  1741. X    if (ip.dst != broadcast && ip.dst != one_of_my_interfaces)
  1742. X        goto forward;
  1743. X    /*
  1744. X     * We now have a UDP for the BOOTP Server port.
  1745. X     */
  1746. X    switch (bootp.bp_op) {
  1747. X    case BOOTREQUEST:
  1748. X        if (bootp.bp_secs <= 5 || ++bootp.bp_hops > 5)
  1749. X            goto discard;
  1750. X        if (bootp.bp_giaddr == 0)
  1751. X            ip.src = bootp.bp_giaddr = my IP address;
  1752. X            /* of incoming interface, if possible */
  1753. X        for (each host in bootplist) {
  1754. X            copy_packet_into_new_buffer;
  1755. X            ip.dst = host address;
  1756. X            send_ip;
  1757. X        }
  1758. X        goto discard;    /* discard original packet */
  1759. X
  1760. X    case BOOTREPLY:
  1761. X        if (bootp.bp_yiaddr != directly_accessable)
  1762. X            goto discard;    /* if not 0 hops from me */
  1763. X        /*
  1764. X         * At this point, we need to use one of the methods
  1765. X         * described in RFC951, section 4, to send the reply
  1766. X         * to the client.  Usually this will be: setup a
  1767. X         * temporary arp cache entry for bp_yiaddr at
  1768. X         * hardware address bp_chaddr.
  1769. X         */
  1770. X        set_arp_cache(bootp.bp_yiaddr, bootp.bp_chaddr);
  1771. X        ip.dst = bootp.bp_yiaddr;
  1772. X        udp.port = IPPORT_BOOTPC;    /* for client only now */
  1773. X        goto forward;
  1774. X
  1775. X    default:
  1776. X        goto discard;    /* bad opcode */
  1777. X    }
  1778. X
  1779. Xforward:
  1780. X    if (ether.dst == broadcast || ip.dst == broadcast)
  1781. X        goto discard;
  1782. X    forward_ip;    /* recomputes ip checksum if needed */
  1783. X    return;
  1784. Xdiscard:
  1785. X    discard_packet;
  1786. X    return;
  1787. X}
  1788. X
  1789. X
  1790. X====
  1791. X
  1792. XNotes:
  1793. X
  1794. XThe "if (xxx == broadcast)" tests can use 4 or 6 bytes of all ones
  1795. X(currently).  However if directed broadcasts are eventually implemented,
  1796. Xthe test would be a little different.
  1797. END_OF_FILE
  1798. if test 5070 -ne `wc -c <'gmods'`; then
  1799.     echo shar: \"'gmods'\" unpacked with wrong size!
  1800. fi
  1801. # end of 'gmods'
  1802. fi
  1803. if test -f 'hash.c' -a "${1}" != "-c" ; then 
  1804.   echo shar: Will not clobber existing file \"'hash.c'\"
  1805. else
  1806. echo shar: Extracting \"'hash.c'\" \(10269 characters\)
  1807. sed "s/^X//" >'hash.c' <<'END_OF_FILE'
  1808. X#ifndef _BLURB_
  1809. X#define _BLURB_
  1810. X/************************************************************************
  1811. X          Copyright 1988, 1991 by Carnegie Mellon University
  1812. X
  1813. X                          All Rights Reserved
  1814. X
  1815. XPermission to use, copy, modify, and distribute this software and its
  1816. Xdocumentation for any purpose and without fee is hereby granted, provided
  1817. Xthat the above copyright notice appear in all copies and that both that
  1818. Xcopyright notice and this permission notice appear in supporting
  1819. Xdocumentation, and that the name of Carnegie Mellon University not be used
  1820. Xin advertising or publicity pertaining to distribution of the software
  1821. Xwithout specific, written prior permission.
  1822. X
  1823. XCARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  1824. XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  1825. XIN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  1826. XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  1827. XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  1828. XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1829. XSOFTWARE.
  1830. X************************************************************************/
  1831. X#endif /* _BLURB_ */
  1832. X
  1833. X
  1834. X#ifndef lint
  1835. Xstatic char rcsid[] = "$Header: /afs/andrew.cmu.edu/netdev/src/cmu/bootp-public/RCS/hash.c,v 1.3 1991/11/01 10:02:29 ww0n Exp ww0n $";
  1836. X#endif
  1837. X
  1838. X
  1839. X/*
  1840. X * Generalized hash table ADT
  1841. X *
  1842. X * Provides multiple, dynamically-allocated, variable-sized hash tables on
  1843. X * various data and keys.
  1844. X *
  1845. X * This package attempts to follow some of the coding conventions suggested
  1846. X * by Bob Sidebotham and the AFS Clean Code Committee of the
  1847. X * Information Technology Center at Carnegie Mellon.
  1848. X */
  1849. X
  1850. X
  1851. X#include "hash.h"
  1852. X
  1853. X#ifdef SVR4
  1854. X#define bcopy(a,b,c)    memcpy(b,a,c)
  1855. X#define bzero(p,l)      memset(p,0,l)
  1856. X#define bcmp(a,b,c)     memcmp(a,b,c)
  1857. X#endif
  1858. X
  1859. X#define TRUE        1
  1860. X#define FALSE        0
  1861. X#define NULL        0
  1862. X
  1863. X/*
  1864. X * This can be changed to make internal routines visible to debuggers, etc.
  1865. X */
  1866. X#define PRIVATE static
  1867. X
  1868. X
  1869. X
  1870. X/*
  1871. X * Hash table initialization routine.
  1872. X *
  1873. X * This routine creates and intializes a hash table of size "tablesize"
  1874. X * entries.  Successful calls return a pointer to the hash table (which must
  1875. X * be passed to other hash routines to identify the hash table).  Failed
  1876. X * calls return NULL.
  1877. X */
  1878. X
  1879. Xhash_tbl *hash_Init(tablesize)
  1880. Xunsigned tablesize;
  1881. X{
  1882. X    register hash_tbl *hashtblptr;
  1883. X    register unsigned totalsize;
  1884. X
  1885. X    if (tablesize > 0) {
  1886. X    totalsize = sizeof(hash_tbl)
  1887. X            + sizeof(hash_member *) * (tablesize - 1);
  1888. X    hashtblptr = (hash_tbl *) malloc(totalsize);
  1889. X    if (hashtblptr) {
  1890. X        bzero((char *) hashtblptr, totalsize);
  1891. X        hashtblptr->size = tablesize;        /* Success! */
  1892. X        hashtblptr->bucketnum = 0;
  1893. X        hashtblptr->member = (hashtblptr->table)[0];
  1894. X    }
  1895. X    } else {
  1896. X    hashtblptr = NULL;    /* Disallow zero-length tables */
  1897. X    }
  1898. X    return hashtblptr;        /* NULL if failure */
  1899. X}
  1900. X
  1901. X
  1902. X
  1903. X/*
  1904. X * Recursively frees an entire linked list of bucket members (used in the open
  1905. X * hashing scheme).  Does nothing if the passed pointer is NULL.
  1906. X */
  1907. X
  1908. XPRIVATE void hashi_FreeMember(bucketptr, free_data)
  1909. Xhash_member *bucketptr;
  1910. Xvoid (*free_data)();
  1911. X{
  1912. X    if (bucketptr) {
  1913. X    /*
  1914. X     * Free next member if necessary
  1915. X     */
  1916. X    hashi_FreeMember(bucketptr->next, free_data);
  1917. X    (*free_data)(bucketptr->data);
  1918. X    free((char *) bucketptr);
  1919. X    }
  1920. X}
  1921. X
  1922. X
  1923. X
  1924. X
  1925. X/*
  1926. X * This routine re-initializes the hash table.  It frees all the allocated
  1927. X * memory and resets all bucket pointers to NULL.
  1928. X */
  1929. X
  1930. Xvoid hash_Reset(hashtable, free_data)
  1931. Xhash_tbl *hashtable;
  1932. Xvoid (*free_data)();
  1933. X{
  1934. X    hash_member **bucketptr;
  1935. X    unsigned i;
  1936. X
  1937. X    bucketptr = hashtable->table;
  1938. X    for (i = 0; i < hashtable->size; i++) {
  1939. X    hashi_FreeMember(*bucketptr, free_data);
  1940. X    *bucketptr++ = NULL;
  1941. X    }    
  1942. X    hashtable->bucketnum = 0;
  1943. X    hashtable->member = (hashtable->table)[0];
  1944. X}
  1945. X
  1946. X
  1947. X
  1948. X/*
  1949. X * Generic hash function to calculate a hash code from the given string.
  1950. X *
  1951. X * For each byte of the string, this function left-shifts the value in an
  1952. X * accumulator and then adds the byte into the accumulator.  The contents of
  1953. X * the accumulator is returned after the entire string has been processed.
  1954. X * It is assumed that this result will be used as the "hashcode" parameter in
  1955. X * calls to other functions in this package.  These functions automatically
  1956. X * adjust the hashcode for the size of each hashtable.
  1957. X *
  1958. X * This algorithm probably works best when the hash table size is a prime
  1959. X * number.
  1960. X *
  1961. X * Hopefully, this function is better than the previous one which returned
  1962. X * the sum of the squares of all the bytes.  I'm still open to other
  1963. X * suggestions for a default hash function.  The programmer is more than
  1964. X * welcome to supply his/her own hash function as that is one of the design
  1965. X * features of this package.
  1966. X */
  1967. X
  1968. Xunsigned hash_HashFunction(string, len)
  1969. Xunsigned char *string;
  1970. Xregister unsigned len;
  1971. X{
  1972. X    register unsigned accum;
  1973. X
  1974. X    accum = 0;
  1975. X    for (; len > 0; len--) {
  1976. X    accum <<= 1;
  1977. X    accum += (unsigned) (*string++ & 0xFF);
  1978. X    }
  1979. X    return accum;
  1980. X}
  1981. X
  1982. X
  1983. X
  1984. X/*
  1985. X * Returns TRUE if at least one entry for the given key exists; FALSE
  1986. X * otherwise.
  1987. X */
  1988. X
  1989. Xint hash_Exists(hashtable, hashcode, compare, key)
  1990. Xhash_tbl *hashtable;
  1991. Xunsigned hashcode;
  1992. Xint (*compare)();
  1993. Xhash_datum *key;
  1994. X{
  1995. X    register hash_member *memberptr;
  1996. X
  1997. X    memberptr = (hashtable->table)[hashcode % (hashtable->size)];
  1998. X    while (memberptr) {
  1999. X    if ((*compare)(key, memberptr->data)) {
  2000. X        return TRUE;        /* Entry does exist */
  2001. X    }
  2002. X    memberptr = memberptr->next;
  2003. X    }
  2004. X    return FALSE;            /* Entry does not exist */
  2005. X}
  2006. X
  2007. X
  2008. X
  2009. X/*
  2010. X * Insert the data item "element" into the hash table using "hashcode"
  2011. X * to determine the bucket number, and "compare" and "key" to determine
  2012. X * its uniqueness.
  2013. X *
  2014. X * If the insertion is successful 0 is returned.  If a matching entry
  2015. X * already exists in the given bucket of the hash table, or some other error
  2016. X * occurs, -1 is returned and the insertion is not done.
  2017. X */
  2018. X
  2019. Xint hash_Insert(hashtable, hashcode, compare, key, element)
  2020. Xhash_tbl *hashtable;
  2021. Xunsigned hashcode;
  2022. Xint (*compare)();
  2023. Xhash_datum *key, *element;
  2024. X{
  2025. X    hash_member *memberptr, *temp;
  2026. X    
  2027. X    hashcode %= hashtable->size;
  2028. X    if (hash_Exists(hashtable, hashcode, compare, key)) {
  2029. X    return -1;    /* At least one entry already exists */
  2030. X    }
  2031. X    memberptr = (hashtable->table)[hashcode];
  2032. X    temp = (hash_member *) malloc(sizeof(hash_member));
  2033. X    if (temp) {
  2034. X    (hashtable->table)[hashcode] = temp;
  2035. X    temp->data = element;
  2036. X    temp->next = memberptr;
  2037. X    return 0;    /* Success */
  2038. X    } else {
  2039. X    return -1;    /* malloc failed! */
  2040. X    }
  2041. X}
  2042. X
  2043. X
  2044. X
  2045. X/*
  2046. X * Delete all data elements which match the given key.  If at least one
  2047. X * element is found and the deletion is successful, 0 is returned.
  2048. X * If no matching elements can be found in the hash table, -1 is returned.
  2049. X */
  2050. X
  2051. Xint hash_Delete(hashtable, hashcode, compare, key, free_data)
  2052. Xhash_tbl *hashtable;
  2053. Xunsigned hashcode;
  2054. Xint (*compare)();
  2055. Xhash_datum *key;
  2056. Xvoid (*free_data)();
  2057. X{
  2058. X    hash_member *memberptr, *previous, *tempptr;
  2059. X    int retval;
  2060. X
  2061. X    retval = -1;
  2062. X    hashcode %= hashtable->size;
  2063. X
  2064. X    /*
  2065. X     * Delete the first member of the list if it matches.  Since this moves
  2066. X     * the second member into the first position we have to keep doing this
  2067. X     * over and over until it no longer matches.
  2068. X     */
  2069. X    memberptr = (hashtable->table)[hashcode];
  2070. X    while (memberptr && (*compare)(key, memberptr->data)) {
  2071. X    (hashtable->table)[hashcode] = memberptr->next;
  2072. X    /*
  2073. X     * Stop hashi_FreeMember() from recursively deleting the whole list!
  2074. X     */
  2075. X    memberptr->next = NULL;
  2076. X    hashi_FreeMember(memberptr, free_data);
  2077. X    memberptr = (hashtable->table)[hashcode];
  2078. X    retval = 0;
  2079. X    }
  2080. X
  2081. X    /*
  2082. X     * Now traverse the rest of the list
  2083. X     */
  2084. X    if (memberptr) {
  2085. X    previous = memberptr;
  2086. X    memberptr = memberptr->next;
  2087. X    }
  2088. X    while (memberptr) {
  2089. X    if ((*compare)(key, memberptr->data)) {
  2090. X        tempptr = memberptr;
  2091. X        previous->next = memberptr = memberptr->next;
  2092. X        /*
  2093. X         * Put the brakes on hashi_FreeMember(). . . .
  2094. X         */
  2095. X        tempptr->next = NULL;
  2096. X        hashi_FreeMember(tempptr, free_data);
  2097. X        retval = 0;
  2098. X    } else {
  2099. X        previous = memberptr;
  2100. X        memberptr = memberptr->next;
  2101. X    }
  2102. X    }
  2103. X    return retval;
  2104. X}
  2105. X
  2106. X
  2107. X
  2108. X/*
  2109. X * Locate and return the data entry associated with the given key.
  2110. X *
  2111. X * If the data entry is found, a pointer to it is returned.  Otherwise,
  2112. X * NULL is returned.
  2113. X */
  2114. X
  2115. Xhash_datum *hash_Lookup(hashtable, hashcode, compare, key)
  2116. Xhash_tbl *hashtable;
  2117. Xunsigned hashcode;
  2118. Xint (*compare)();
  2119. Xhash_datum *key;
  2120. X{
  2121. X    hash_member *memberptr;
  2122. X
  2123. X    memberptr = (hashtable->table)[hashcode % (hashtable->size)];
  2124. X    while (memberptr) {
  2125. X    if ((*compare)(key, memberptr->data)) {
  2126. X        return (memberptr->data);
  2127. X    }
  2128. X    memberptr = memberptr->next;
  2129. X    }
  2130. X    return NULL;
  2131. X}
  2132. X
  2133. X
  2134. X
  2135. X/*
  2136. X * Return the next available entry in the hashtable for a linear search
  2137. X */
  2138. X
  2139. Xhash_datum *hash_NextEntry(hashtable)
  2140. Xhash_tbl *hashtable;
  2141. X{
  2142. X    register unsigned bucket;
  2143. X    register hash_member *memberptr;
  2144. X
  2145. X    /*
  2146. X     * First try to pick up where we left off.
  2147. X     */
  2148. X    memberptr = hashtable->member;
  2149. X    if (memberptr) {
  2150. X    hashtable->member = memberptr->next;    /* Set up for next call */
  2151. X    return memberptr->data;            /* Return the data */
  2152. X    }
  2153. X
  2154. X    /*
  2155. X     * We hit the end of a chain, so look through the array of buckets
  2156. X     * until we find a new chain (non-empty bucket) or run out of buckets.
  2157. X     */
  2158. X    bucket = hashtable->bucketnum + 1;
  2159. X    while ((bucket < hashtable->size) && 
  2160. X       !(memberptr = (hashtable->table)[bucket])) {
  2161. X    bucket++;
  2162. X    }
  2163. X
  2164. X    /*
  2165. X     * Check to see if we ran out of buckets.
  2166. X     */
  2167. X    if (bucket >= hashtable->size) {
  2168. X    /*
  2169. X     * Reset to top of table for next call.
  2170. X     */
  2171. X    hashtable->bucketnum = 0;
  2172. X    hashtable->member = (hashtable->table)[0];
  2173. X    /*
  2174. X     * But return end-of-table indication to the caller this time.
  2175. X     */
  2176. X    return NULL;
  2177. X    }
  2178. X
  2179. X    /*
  2180. X     * Must have found a non-empty bucket.
  2181. X     */
  2182. X    hashtable->bucketnum = bucket;
  2183. X    hashtable->member = memberptr->next;    /* Set up for next call */
  2184. X    return memberptr->data;            /* Return the data */
  2185. X}
  2186. X
  2187. X
  2188. X
  2189. X/*
  2190. X * Return the first entry in a hash table for a linear search
  2191. X */
  2192. X
  2193. Xhash_datum *hash_FirstEntry(hashtable)
  2194. Xhash_tbl *hashtable;
  2195. X{
  2196. X    hashtable->bucketnum = 0;
  2197. X    hashtable->member = (hashtable->table)[0];
  2198. X    return hash_NextEntry(hashtable);
  2199. X}
  2200. END_OF_FILE
  2201. if test 10269 -ne `wc -c <'hash.c'`; then
  2202.     echo shar: \"'hash.c'\" unpacked with wrong size!
  2203. fi
  2204. # end of 'hash.c'
  2205. fi
  2206. if test -f 'hash.h' -a "${1}" != "-c" ; then 
  2207.   echo shar: Will not clobber existing file \"'hash.h'\"
  2208. else
  2209. echo shar: Extracting \"'hash.h'\" \(4406 characters\)
  2210. sed "s/^X//" >'hash.h' <<'END_OF_FILE'
  2211. X#ifndef _BLURB_
  2212. X#define _BLURB_
  2213. X/************************************************************************
  2214. X          Copyright 1988, 1991 by Carnegie Mellon University
  2215. X
  2216. X                          All Rights Reserved
  2217. X
  2218. XPermission to use, copy, modify, and distribute this software and its
  2219. Xdocumentation for any purpose and without fee is hereby granted, provided
  2220. Xthat the above copyright notice appear in all copies and that both that
  2221. Xcopyright notice and this permission notice appear in supporting
  2222. Xdocumentation, and that the name of Carnegie Mellon University not be used
  2223. Xin advertising or publicity pertaining to distribution of the software
  2224. Xwithout specific, written prior permission.
  2225. X
  2226. XCARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  2227. XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  2228. XIN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  2229. XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  2230. XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  2231. XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  2232. XSOFTWARE.
  2233. X************************************************************************/
  2234. X#endif /* _BLURB_ */
  2235. X
  2236. X
  2237. X/*
  2238. X * Generalized hash table ADT
  2239. X *
  2240. X * Provides multiple, dynamically-allocated, variable-sized hash tables on
  2241. X * various data and keys.
  2242. X *
  2243. X * This package attempts to follow some of the coding conventions suggested
  2244. X * by Bob Sidebotham and the AFS Clean Code Committee.
  2245. X */
  2246. X
  2247. X
  2248. X/*
  2249. X * The user must supply the following:
  2250. X *
  2251. X *    1.  A comparison function which is declared as:
  2252. X *
  2253. X *        int compare(data1, data2)
  2254. X *        hash_datum *data1, *data2;
  2255. X *
  2256. X *        This function must compare the desired fields of data1 and
  2257. X *        data2 and return TRUE (1) if the data should be considered
  2258. X *        equivalent (i.e. have the same key value) or FALSE (0)
  2259. X *        otherwise.  This function is called through a pointer passed to
  2260. X *        the various hashtable functions (thus pointers to different
  2261. X *        functions may be passed to effect different tests on different
  2262. X *        hash tables).
  2263. X *
  2264. X *        Internally, all the functions of this package always call the
  2265. X *        compare function with the "key" parameter as the first parameter,
  2266. X *        and a full data element as the second parameter.  Thus, the key
  2267. X *        and element arguments to functions such as hash_Lookup() may
  2268. X *        actually be of different types and the programmer may provide a
  2269. X *        compare function which compares the two different object types
  2270. X *        as desired.
  2271. X *
  2272. X *        Example:
  2273. X *
  2274. X *        int compare(key, element)
  2275. X *        char *key;
  2276. X *        struct some_complex_structure *element;
  2277. X *        {
  2278. X *            return !strcmp(key, element->name);
  2279. X *        }
  2280. X *
  2281. X *        key = "John C. Doe"
  2282. X *        element = &some_complex_structure
  2283. X *        hash_Lookup(table, hashcode, compare, key);
  2284. X *
  2285. X *    2.  A hash function yielding an unsigned integer value to be used
  2286. X *        as the hashcode (index into the hashtable).  Thus, the user
  2287. X *        may hash on whatever data is desired and may use several
  2288. X *        different hash functions for various different hash tables.
  2289. X *        The actual hash table index will be the passed hashcode modulo
  2290. X *        the hash table size.
  2291. X *
  2292. X *        A generalized hash function, hash_HashFunction(), is included
  2293. X *        with this package to make things a little easier.  It is not
  2294. X *        guarenteed to use the best hash algorithm in existence. . . .
  2295. X */
  2296. X
  2297. X
  2298. X
  2299. X/*
  2300. X * Various hash table definitions
  2301. X */
  2302. X
  2303. X
  2304. X#ifndef __HASHXYZ973__
  2305. X
  2306. X#define __HASHXYZ973__
  2307. X
  2308. X/*
  2309. X * Define "hash_datum" as a universal data type
  2310. X */
  2311. X#ifdef __STDC__
  2312. Xtypedef void hash_datum;
  2313. X#else
  2314. Xtypedef char hash_datum;
  2315. X#endif
  2316. X
  2317. Xtypedef struct hash_memberstruct  hash_member;
  2318. Xtypedef struct hash_tblstruct     hash_tbl;
  2319. Xtypedef struct hash_tblstruct_hdr hash_tblhdr;
  2320. X
  2321. Xstruct hash_memberstruct {
  2322. X    hash_member *next;
  2323. X    hash_datum  *data;
  2324. X};
  2325. X
  2326. Xstruct hash_tblstruct_hdr {
  2327. X    unsigned    size, bucketnum;
  2328. X    hash_member *member;
  2329. X};
  2330. X
  2331. Xstruct hash_tblstruct {
  2332. X    unsigned    size, bucketnum;
  2333. X    hash_member *member;        /* Used for linear dump */
  2334. X    hash_member    *table[1];        /* Dynamically extended */
  2335. X};
  2336. X
  2337. Xextern hash_tbl      *hash_Init();
  2338. Xextern void       hash_Reset();
  2339. Xextern unsigned       hash_HashFunction();
  2340. Xextern int       hash_Exists();
  2341. Xextern int       hash_Insert();
  2342. Xextern int       hash_Delete();
  2343. Xextern hash_datum *hash_Lookup();
  2344. Xextern hash_datum *hash_FirstEntry();
  2345. Xextern hash_datum *hash_NextEntry();
  2346. X
  2347. X#endif
  2348. END_OF_FILE
  2349. if test 4406 -ne `wc -c <'hash.h'`; then
  2350.     echo shar: \"'hash.h'\" unpacked with wrong size!
  2351. fi
  2352. # end of 'hash.h'
  2353. fi
  2354. if test -f 'newvers.sh' -a "${1}" != "-c" ; then 
  2355.   echo shar: Will not clobber existing file \"'newvers.sh'\"
  2356. else
  2357. echo shar: Extracting \"'newvers.sh'\" \(824 characters\)
  2358. sed "s/^X//" >'newvers.sh' <<'END_OF_FILE'
  2359. X#!/bin/sh -
  2360. X#
  2361. X# Copyright (c) 1987 Regents of the University of California.
  2362. X# All rights reserved.
  2363. X#
  2364. X# Redistribution and use in source and binary forms are permitted
  2365. X# provided that this notice is preserved and that due credit is given
  2366. X# to the University of California at Berkeley. The name of the University
  2367. X# may not be used to endorse or promote products derived from this
  2368. X# software without specific prior written permission. This software
  2369. X# is provided ``as is'' without express or implied warranty.
  2370. X#
  2371. X#    @(#)newvers.sh    4.4 (Berkeley) 3/28/88
  2372. X#
  2373. Xif [ ! -r version ]
  2374. Xthen
  2375. X    echo 0 > version
  2376. Xfi
  2377. Xtouch version
  2378. Xrm -f version.[oc]
  2379. Xv=`cat version` u=${USER-root} d=`pwd` h=`hostname` t=`date`
  2380. Xsed -e "s|%VERSION%|#${v}: ${t}|" -e "s|%WHOANDWHERE%|${u}@${h}:${d}|" \
  2381. X    < Version.c >version.c
  2382. X/bin/echo `expr ${v} + 1` > version
  2383. END_OF_FILE
  2384. if test 824 -ne `wc -c <'newvers.sh'`; then
  2385.     echo shar: \"'newvers.sh'\" unpacked with wrong size!
  2386. fi
  2387. # end of 'newvers.sh'
  2388. fi
  2389. echo shar: End of archive 1 \(of 2\).
  2390. cp /dev/null ark1isdone
  2391. MISSING=""
  2392. for I in 1 2 ; do
  2393.     if test ! -f ark${I}isdone ; then
  2394.     MISSING="${MISSING} ${I}"
  2395.     fi
  2396. done
  2397. if test "${MISSING}" = "" ; then
  2398.     echo You have unpacked both archives.
  2399.     rm -f ark[1-9]isdone
  2400. else
  2401.     echo You still need to unpack the following archives:
  2402.     echo "        " ${MISSING}
  2403. fi
  2404. ##  End of shell archive.
  2405. exit 0
  2406.