bootpc-0.64.orig/ 40700 1750 1750 0 6675060164 13322 5ustar herbertgreathanbootpc-0.64.orig/ChangeLog100600 1750 1750 14423 6636312727 15221 0ustar herbertgreathan## Last updated : Mon Sep 23 16:32:51 1996 Tidy up rc.bootp script to use "hostname -S" and "mv -f", when setting up the resolver code. JSP 23/02/94 Added the in2host code to bootpc.c (new --in2host option) and reworked rc.bootp to use this to get the DOMAIN if the bootp reply doesn't set it following discussion with bootp server manager about meaning of DOMAIN field being unclear. This code attempts to guess the DOMAIN from the gethostbyaddr() lookup for the IP address by removing the leaf component. Also tidied up code a little, bumped version to 0.20. JSP 17/02/94 Fix bug in TAG 1 handling (added wrong increment to cookie counter), also fixed handling of TAGs 128 to 254 as per RFC1497. JSP 27/05/94 Fix default boot image to ask for from "linux" to "", since it was reported to cause problems. JSP 17/06/94 Fix for new kernels change low level ifreq.ifr_hwaddr changes. JSP 18/06/94 Added --server
option to allow better testing and in case anyone wants to force the lookup from a particular server, or a particular network (it might just happen...) JSP 18/06/94 Rewrite large chunks of rc.bootp to take account of changes suggested by various people (setting up loopback, and tidying up the code. JSP 18/06/94 Changed detection of NET3 code as suggested by A.Cox, added extra checks for device being ethernet type (on NET3 only) which is only type currently supported. JSP 20/06/94 Removed old -S option from hostname command in rc.bootp and rearranged a few lines. Changed rc.bootp to use --server anyway (as an example.) Changed --in2host to generate DONEIN2HOST line and changed rc.bootp accordingly. JSP 20/06/94 Added -m486 to the CFLAGS line in the Makefile. JSP 20/06/94 Minor tidyups to comments in rc.bootp and bootpc.c for next release (which is very late!) JSP 16/08/94 Added new --hwaddr option to ask for a MAC address other than ours (doesn't work on some (most?) bootp servers since they reply to the MAC address quoted not to the one we sent from.) JSP 17/08/94 Fixed rc.bootp to remove the route it makes before taking the network down after the bootp request. This is just cleanliness. JSP 18/08/94 Added code to FatalError() to print the errno and a message about the looping is --debug is set. JSP 18/08/94 Added new WHEN-IT-FAILS file with some information on how to look for common problems and report faults with the bootpc code. JSP 18/08/94 Added code to cat an existing hosts.local file onto the end of hosts in the rc.bootp. JSP 06/09/94 Merged in SLIP special case code from ramana@VNET.IBM.COM JSP 27/09/94 Added alpha version of ping sanity test code to bootpc. JSP 28/09/94 Added searchpath stuff for new resolver support, and checked it works at least for .ac.uk sites (well for us anyway.) JSP 28/09/94 Rewrote MAC address handling to just use the NET3 features where available and removed the SLIP code (which broke ethernet usage.) JSP 28/09/94 Removed some broken code from the ping routine and fixed a minor problem with it's packet setup. JSP 07/10/94 Rewrote rc.bootp code for paranoid checks to use the NETWORK address as the sender when performing the pings as we don't see any replies if we send from 0.0.0.0 (something wrong somewhere else.) JSP 08/10/94 Corrected my e-mail address to our new official one (Rah Rah!!) :-) JSP 08/10/94 Rolled in patches from "Andre Schroeter" about the TAG_TIME_OFFSET, TAG_BOOTSIZE, and bootfile stuff, and fixed the rc.bootp accordingly. JSP 27/02/95 Added fix from B.A.McCauley@bham.ac.uk to set the "broadcast reply" flag when sending out for a MAC address other than our own. According to the RFC1542 a bootp server should broadcast the reply when this is set so we can still pick it up. Doesn't work with some broken bootp servers though. JSP 02/04/95 Minor typos corrected and version bumped up to v0.44. Some more testing done (few live tests at moment). Updated README to mention that DIP does native bootp for those who want bootp and DIP. JSP 28/06/95 Added ARCNET patch from Tomasz Motylewski which doesn't follow the convention about hardware addresses (at least not when talking to a Novell Server. Bumped version to v0.45. JSP 1995-08-02 Fixed TAG_SWAP_SERVER to add correct offset, and fix the code the an unknown TAG as suggested by Peter Wong Jr JSP 1995-08-11 Added patches for new TAGs from Charles Lopes , changed the cookie parser to take the lenth code out of the switch. Added 2 new options --returniffails and --timeoutwait to cause bootpc to return if it can't find an address and to set how long in total (roughly) to wait in seconds. Fixed the rc.bootp code for setting up the hosts file. JSP 1995-09-08 Removed -m486 from makefile CFLAGS since we may not be on a 486 anymore. JSP 1995-12-20 Finally removed old NET2 code (need NET3 now), and bumped up version to 0.48 ready for new release. Also changed some "long"s to "int32"s. JSP 1995-12-21 Changed bootpc code for printing options out to be more careful about printing characters which might cause problems for the thing reading the output. Also tidied up code for generating a DNS search string, and updated WHEN-IT-FAILS to mention more stuff, and updated rc.bootp to cope with --returniffail etc. Bumped version number up to 0.49. JSP 1996-03-11 Added distrib target to Makefile, and put everything under RCS to stop me losing more edits! JSP 1996-04-16 Fixed a couple of bugs in cleanup of bootpc.c relating to "waitformore" handling. It still doesn't wait exactly as long as you ask, but this is a minore problem. Bumped version numbers of everything to V0.50. I'll need to write a man page soon! Removed test in bptypes.h for 32/63 bitness as it apparently didn't work on alphas anyway. Trust that int is 32bits for now. Also fixes a couple of %d to %ld in printf's. JSP 1996-04-17 Changed make distrib to keep version numbers consistent, see VERSION for version number now. JSP 1996-04-17 Split functionality of bootpc.c into bootpc.c and mail.c, main.c handles the command line and calling the routines from bootpc.c. This is to allow bootpc.o to be linked into other code, e.g. the RedHat install program or a dhcp client. Removed the old ping code and all mention of it. Bumped version number up to 0.60 (to show that a fair bit has changes). JSP 1996-Sep-23 bootpc-0.64.orig/DHCP100600 1750 1750 405 6636312727 14043 0ustar herbertgreathan## Last updated : Mon Mar 11 16:33:45 1996 There is currently no DHCP support here, though I am working on adding bits of it as time permits. If you want to add some let me know what changes you make and I'll try to add them to my DHCP client code. -- Jon bootpc-0.64.orig/LSM100600 1750 1750 1253 6636312727 14002 0ustar herbertgreathanBegin3 Title: Linux Bootp Client Version: 0.64 Entered-date: 17DEC98 Description: This is a boot protocol client used to grab the machines ip number, set up DNS nameservers and other useful information. Now can ask for server to bradcast replies which is useful for testing, and seems to be needed on Linux 2.1.x Keywords: bootp bootpc client net util Author: ceh@eng.cam.ac.uk (Charles Hawkins) Maintained-by: J.S.Peatfield@damtp.cam.ac.uk (Jon Peatfield) Primary-site: http://www.damtp.cam.ac.uk/linux/bootpc/bootpc-0.64.tar.gz Alternate-site: ftp://metalab.unc.edu/pub/Linux/system/Network/admin/bootpc-0.64.tar.gz Copying-policy: GPL End bootpc-0.64.orig/NOTICE100600 1750 1750 1620 6636312727 14326 0ustar herbertgreathanBOOTPC bootp client from Linux ------------------------------ Copyright (c) 1996,1998 University of Cambridge This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -- Jon Peatfield, Computer Officer, the DAMTP, University of Cambridge Telephone: +44 1223 3 37852 Mail: J.S.Peatfield@damtp.cam.ac.uk bootpc-0.64.orig/LICENCE100600 1750 1750 43076 6636312730 14434 0ustar herbertgreathan GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. bootpc-0.64.orig/MANIFEST100600 1750 1750 233 6636312730 14524 0ustar herbertgreathanChangeLog DHCP LSM bootpc-0.64.lsm NOTICE LICENCE MANIFEST Makefile README VERSION WHEN-IT-FAILS bootp.h bootpc.c bootpc.h log.h main.c bptypes.h rc.bootp bootpc-0.64.orig/Makefile100600 1750 1750 2572 6636312730 15063 0ustar herbertgreathan# Last updated : Tue Dec 15 03:38:58 1998 # Version 0.64 # # $Revision: 1.9 $ # PROG=bootpc CFLAGS=-O2 -Wall # list the Cfiles here CFILES=bootpc.c main.c # List the header files here CHEADS=bootpc.h bootp.h bptypes.h log.h # Other files we want to have arround in distrib MISC=Makefile MANIFEST LICENCE NOTICE LSM DHCP README WHEN-IT-FAILS VERSION \ ChangeLog rc.bootp VERSION # the delete command RM=/bin/rm SED=/usr/bin/sed # we generate this from the list of C files above OBJS=$(CFILES:.c=.o) %.o: %.c $(CHEADS) $(CC) $(CFLAGS) -c $(*).c all: $(PROG) clean: ${RM} -f ${OBJS} ${PROG} *~ *.tar *.tar.gz *.tgz ${PROG}: ${OBJS} ${CC} -o ${PROG} ${CFLAGS} ${OBJS} strip ${PROG} ${PROG}-static: ${OBJS} ${CC} -static -o ${PROG} ${CFLAGS} ${OBJS} strip ${PROG} # Make up a distribution file from the bits we want people to see distrib: $(CFILES) $(CHEADS) $(MISC) set `cat VERSION` ;\ rdate=`date '+%d%h%y'|tr '[a-z]' '[A-Z]'`; \ distname=bootpc-$$1 ; \ rm -fr $$distname $$distname.tar $$distname.tar.gz; \ mkdir $$distname; \ chmod 755 $$distname; \ for i in `cat MANIFEST` ; do \ [ -f $$i ] && sed -e "s/0.64/$$1/g;s/17DEC98/$$rdate/g" $$i > $$distname/$$i && echo $$i; \ done; \ ln -s LSM $$distname/$$distname.lsm; \ cp $$distname/$$distname.lsm .; \ chmod -R a+rx $$distname; \ tar -cvf $$distname.tar $$distname; \ gzip -9v $$distname.tar; \ rm -fr $$distname bootpc-0.64.orig/README100600 1750 1750 7536 6636312730 14310 0ustar herbertgreathan# Last updated : Tue Apr 16 17:27:46 1996 # $Revision: 1.3 $ # $Date: 1996/04/17 23:12:42 $ # This code is based on the bootp client written by Charles Hawkins and tidied up a little by me. I've added a few things to make it conform to RFC1542 and it now parses RFC1497 BOOTP magic cookies. The Magic cookie parser is not complete, it ignores the following TAGS: (2) Time of Day, (13) BOOTP file size, (14) Merit dump filename (17) root pathname to mount (18) extentions, file to TFTP with more cookie in it. Of there only (2) and (17) seem worth adding at this point. (18) is a real pain as it requires a TFTP client in the bootp setup. I've not had access to a bootpd which provides any of these so I can't easily test them. It does seem to correctly parse the rest as far as I've been able to test with the bootp servers I've got access to. The script rc.bootp is an example only. It sets up the IP layer from the bootp packet results, and is based loosely on the startup script provided by Charles Hawkins , but with additions for the bootp cookies. Hopefully now all the locations of the binaries it uses are configurable at the top of rc.bootp saving people the effort of trying to guess what needs changing for their distribution. The setting up of the resolv.conf file is done if enough info can be got from the bootp reply and/or the inverse lookup of the IP address we were allocated (for those servers which supply DNS server info but not the DNS domain name.) For the reverse lookup to work (and DNS in general), you must of course already have the order line include the "bind" keyword in your host.conf file. If all the domain name lookups fail, but you still have an existing resolv.conf file, the script will update the nameservers lines, leaving the domain/search line alone. ********************************************************************** ** I'll repeat that. set up /etc/host.conf or this bit won't work. ** ********************************************************************** * For glibc 2.0 base systems you will need to set up /etc/nsswitch.conf * to use the DNS for hosts lookup. e.g. a line like: * * hosts: files dns * * will need adding instead of the hosts.conf stuff. There are a few options near the top of rc.bootp which you may want to alter for your setup: Note that if you want the bootpc to give up after it fails, then you need the --returniffail option to tell it to do so. If this is set then the return code signifies success or failure (0 for success, 1 for failure). For testing bootp servers you may also want to check out the --waitformore option. This causes bootpc to wait for multple replies and tell you about each of them. e.g. I find that with the options: ./bootpc --server 131.111.255.255 --waitformore 20 I get multiple replies for some machines. (131.111.255.255 is MY broadcast address, use your own!, the 20 is how long to wait). This is handy with the --hwaddr option to see who would reply for a request from a given MAC address. If you are on a machine which will not see the unicast replies and you have a server which supports the bpboradcast bit (most seem to), then use the new --serverbcast option. This is needed on Linux 2.1.x for recent x (certainly for 130 and newer). If you have problems then please read the WHEN-IT-FAILS file, and failing that please mail me. This code is provided as-is, with no warrenty, share and enjoy. Please report any bugs or problems and I'll try to fix them. I have nothing but ethernet here, so I've got little experience with using bootpc on other types of network. I've had some success reports (and patches sent back, so it must work for some people). -- Jon Peatfield (DAMTP unix network admin) Jon Peatfield, Computer Officer, the DAMTP, University of Cambridge Telephone: +44 1223 3 37852 Mail: J.S.Peatfield@damtp.cam.ac.uk bootpc-0.64.orig/VERSION100600 1750 1750 5 6636312730 14400 0ustar herbertgreathan0.64 bootpc-0.64.orig/WHEN-IT-FAILS100600 1750 1750 6740 6636312730 15256 0ustar herbertgreathan## Last updated : Tue Dec 15 03:57:57 1998 When the bootpc code fails to find a suitable server or reply it prints a message like: > Unable to locate an IP address for this host. > ***Please report this problem** > > [Unable to continue] > The client then goes into a loop forwever sleeping. The reason for this is that carrying on is probably foolish so it waits for a human to interrupt it and sort out the problem. If you really know what you are doing then you can set --returniffail to cause it to return. Using bootpc like this you can tell if your machine is connected to the network. I use this for machines which are sometimes on the net, but get taken home by their users sometimes. If it fails try running --debug --verbose to see if this sheds any light on the problem. The reasons it can fail that I've encountered are: o You are running on a 2.1.x Linux kernel which will not pass the bootp reply back to the client since the dest address doesn't match ours (yet). x Try the --serverbcast flag. It is a hack but seems to work with most of the common bootp servers and gets round the problem for now. A proper fix would either require kernel changes (which AC and ANK disaprove of), or reading the packets at a lower level and re-implementing most of the IP/UDP stuff in userland. If the --serverbcast flag doesn't work you *might* want to try using the kernel REDIRECT code from the firewall. I've not tested this. o No bootp server is serving this client on this network x Set one up. If you want to disable networking if there is no reply to bootp see the --returniffails option. There is support for this in rc.bootp now. o Your default network card doesn't get you to the local network, or is filtered or firewalled and not letting bootp packets through. x Try using --server IPaddress of the server, check the routes you have set allow all broadcast route to the local network. o You are using --server to point to a server which doesn't run a bootp server x Try not using it. o Packets from bootpc don't reach the server, watching the network they seem to go somewhere else. x You have a default route set up which doesn't reach the bootp server. E.g. testing bootpc on a live system with the default route pointing at your external router. The rc.bootp script sets up a simple default route to the local net. If you can't see the bootp server from this you need a router which understands the bootp gateway protocol. For testing, just set --server to point at your local subnet's broadcast address. e.g. I use 131.111.16.255. o You are using --hwaddr and the bootp server responds directly to the MAC address quoted not to the machine generating the request. x Try not using it. In modern bootp servers you can tell it to broadcast the replies or reply to a known other address, this can be helpful for debugging. o The server doesn't understand RFC1497 cookies (you get not all the information back and a "WARNING bp_xid mismatch" probably.) x Install a newer bootp server, or make do with the information you can get from the old one. If these don't seem to be the problem, use strace to trace the execution with --debug and --verbose and mail me the output, repeat also with --server IPaddress so I can try to see what went wrong. e-mail them to J.S.Peatfield@damtp.cam.ac.uk, I'll try to reply with suggestions or more questions pretty soon. -- Jon bootpc-0.64.orig/bootp.h100600 1750 1750 23445 6636312730 14741 0ustar herbertgreathan/************************************************************************ Copyright 1988, 1991 by Carnegie Mellon University All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Carnegie Mellon University not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ************************************************************************/ /* * Bootstrap Protocol (BOOTP). RFC951 and RFC1395. * * $Id: bootp.h,v 1.1 1996/04/16 14:09:03 jp107 Exp $ * * * This file specifies the "implementation-independent" BOOTP protocol * information which is common to both client and server. * */ #include "bptypes.h" /* for int32, u_int32 */ #define BP_CHADDR_LEN 16 #define BP_SNAME_LEN 64 #define BP_FILE_LEN 128 #define BP_VEND_LEN 64 #define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */ struct bootp { unsigned char bp_op; /* packet opcode type */ unsigned char bp_htype; /* hardware addr type */ unsigned char bp_hlen; /* hardware addr length */ unsigned char bp_hops; /* gateway hops */ unsigned int32 bp_xid; /* transaction ID */ unsigned short bp_secs; /* seconds since boot began */ unsigned short bp_flags; /* RFC1532 broadcast, etc. */ struct in_addr bp_ciaddr; /* client IP address */ struct in_addr bp_yiaddr; /* 'your' IP address */ struct in_addr bp_siaddr; /* server IP address */ struct in_addr bp_giaddr; /* gateway IP address */ unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */ char bp_sname[BP_SNAME_LEN]; /* server host name */ char bp_file[BP_FILE_LEN]; /* boot file name */ unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */ /* note that bp_vend can be longer, extending to end of packet. */ }; /* * UDP port numbers, server and client. */ #define IPPORT_BOOTPS 67 #define IPPORT_BOOTPC 68 #define BOOTREPLY 2 #define BOOTREQUEST 1 /* * Hardware types from Assigned Numbers RFC. */ #define HTYPE_ETHERNET 1 #define HTYPE_EXP_ETHERNET 2 #define HTYPE_AX25 3 #define HTYPE_PRONET 4 #define HTYPE_CHAOS 5 #define HTYPE_IEEE802 6 #define HTYPE_ARCNET 7 /* * Vendor magic cookie (v_magic) for CMU */ #define VM_CMU "CMU" /* * Vendor magic cookie (v_magic) for RFC1048 */ #define VM_RFC1048 { 99, 130, 83, 99 } /* * Tag values used to specify what information is being supplied in * the vendor (options) data area of the packet. */ /* RFC 1048 */ /* End of cookie */ #define TAG_END ((unsigned char) 255) /* padding for alignment */ #define TAG_PAD ((unsigned char) 0) /* Subnet mask */ #define TAG_SUBNET_MASK ((unsigned char) 1) /* Time offset from UTC for this system */ #define TAG_TIME_OFFSET ((unsigned char) 2) /* List of routers on this subnet */ #define TAG_GATEWAY ((unsigned char) 3) /* List of rfc868 time servers available to client */ #define TAG_TIME_SERVER ((unsigned char) 4) /* List of IEN 116 name servers */ #define TAG_NAME_SERVER ((unsigned char) 5) /* List of DNS name servers */ #define TAG_DOMAIN_SERVER ((unsigned char) 6) /* List of MIT-LCS UDL log servers */ #define TAG_LOG_SERVER ((unsigned char) 7) /* List of rfc865 cookie servers */ #define TAG_COOKIE_SERVER ((unsigned char) 8) /* List of rfc1179 printer servers (in order to try) */ #define TAG_LPR_SERVER ((unsigned char) 9) /* List of Imagen Impress servers (in prefered order) */ #define TAG_IMPRESS_SERVER ((unsigned char) 10) /* List of rfc887 Resourse Location servers */ #define TAG_RLP_SERVER ((unsigned char) 11) /* Hostname of client */ #define TAG_HOST_NAME ((unsigned char) 12) /* boot file size */ #define TAG_BOOT_SIZE ((unsigned char) 13) /* RFC 1395 */ /* path to dump to in case of crash */ #define TAG_DUMP_FILE ((unsigned char) 14) /* domain name for use with the DNS */ #define TAG_DOMAIN_NAME ((unsigned char) 15) /* IP address of the swap server for this machine */ #define TAG_SWAP_SERVER ((unsigned char) 16) /* The path name to the root filesystem for this machine */ #define TAG_ROOT_PATH ((unsigned char) 17) /* RFC 1497 */ /* filename to tftp with more options in it */ #define TAG_EXTEN_FILE ((unsigned char) 18) /* RFC 1533 */ /* The following are in rfc1533 and may be used by BOOTP/DHCP */ /* IP forwarding enable/disable */ #define TAG_IP_FORWARD ((unsigned char) 19) /* Non-Local source routing enable/disable */ #define TAG_IP_NLSR ((unsigned char) 20) /* List of pairs of addresses/masks to allow non-local source routing to */ #define TAG_IP_POLICY_FILTER ((unsigned char) 21) /* Maximum size of datagrams client should be prepared to reassemble */ #define TAG_IP_MAX_DRS ((unsigned char) 22) /* Default IP TTL */ #define TAG_IP_TTL ((unsigned char) 23) /* Timeout in seconds to age path MTU values found with rfc1191 */ #define TAG_IP_MTU_AGE ((unsigned char) 24) /* Table of MTU sizes to use when doing rfc1191 MTU discovery */ #define TAG_IP_MTU_PLAT ((unsigned char) 25) /* MTU to use on this interface */ #define TAG_IP_MTU ((unsigned char) 26) /* All subnets are local option */ #define TAG_IP_SNARL ((unsigned char) 27) /* broadcast address */ #define TAG_IP_BROADCAST ((unsigned char) 28) /* perform subnet mask discovery using ICMP */ #define TAG_IP_SMASKDISC ((unsigned char) 29) /* act as a subnet mask server using ICMP */ #define TAG_IP_SMASKSUPP ((unsigned char) 30) /* perform rfc1256 router discovery */ #define TAG_IP_ROUTERDISC ((unsigned char) 31) /* address to send router solicitation requests */ #define TAG_IP_ROUTER_SOL_ADDR ((unsigned char) 32) /* list of static routes to addresses (addr, router) pairs */ #define TAG_IP_STATIC_ROUTES ((unsigned char) 33) /* use trailers (rfc893) when using ARP */ #define TAG_IP_TRAILER_ENC ((unsigned char) 34) /* timeout in seconds for ARP cache entries */ #define TAG_ARP_TIMEOUT ((unsigned char) 35) /* use either Ethernet version 2 (rfc894) or IEEE 802.3 (rfc1042) */ #define TAG_ETHER_IEEE ((unsigned char) 36) /* default TCP TTL when sending TCP segments */ #define TAG_IP_TCP_TTL ((unsigned char) 37) /* time for client to wait before sending a keepalive on a TCP connection */ #define TAG_IP_TCP_KA_INT ((unsigned char) 38) /* don't send keepalive with an octet of garbage for compatability */ #define TAG_IP_TCP_KA_GARBAGE ((unsigned char) 39) /* NIS domainname */ #define TAG_NIS_DOMAIN ((unsigned char) 40) /* list of NIS servers */ #define TAG_NIS_SERVER ((unsigned char) 41) /* list of NTP servers */ #define TAG_NTP_SERVER ((unsigned char) 42) /* and stuff vendors may want to add */ #define TAG_VEND_SPECIFIC ((unsigned char) 43) /* NetBios over TCP/IP name server */ #define TAG_NBNS_SERVER ((unsigned char) 44) /* NetBios over TCP/IP NBDD servers (rfc1001/1002) */ #define TAG_NBDD_SERVER ((unsigned char) 45) /* NetBios over TCP/IP node type option for use with above */ #define TAG_NBOTCP_OTPION ((unsigned char) 46) /* NetBios over TCP/IP scopt option for use with above */ #define TAG_NB_SCOPE ((unsigned char) 47) /* list of X Window system font servers */ #define TAG_XFONT_SERVER ((unsigned char) 48) /* list of systems running X Display Manager (xdm) available to this client */ #define TAG_XDISPLAY_SERVER ((unsigned char) 49) /* While the following are only allowed for DHCP */ /* DHCP requested IP address */ #define TAG_DHCP_REQ_IP ((unsigned char) 50) /* DHCP time for lease of IP address */ #define TAG_DHCP_LEASE_TIME ((unsigned char) 51) /* DHCP options overload */ #define TAG_DHCP_OPTOVER ((unsigned char) 52) /* DHCP message type */ #define TAG_DHCP_MESS_TYPE ((unsigned char) 53) /* DHCP server identification */ #define TAG_DHCP_SERVER_ID ((unsigned char) 54) /* DHCP ordered list of requested parameters */ #define TAG_DHCP_PARM_REQ_LIST ((unsigned char) 55) /* DHCP reply message */ #define TAG_DHCP_TEXT_MESSAGE ((unsigned char) 56) /* DHCP maximum packet size willing to accept */ #define TAG_DHCP_MAX_MSGSZ ((unsigned char) 57) /* DHCP time 'til client needs to renew */ #define TAG_DHCP_RENEWAL_TIME ((unsigned char) 58) /* DHCP time 'til client needs to rebind */ #define TAG_DHCP_REBIND_TIME ((unsigned char) 59) /* DHCP class identifier */ #define TAG_DHCP_CLASSID ((unsigned char) 60) /* DHCP client unique identifier */ #define TAG_DHCP_CLIENTID ((unsigned char) 61) /* XXX - Add new tags here */ /* * "vendor" data permitted for CMU bootp clients. */ struct cmu_vend { char v_magic[4]; /* magic number */ unsigned int32 v_flags; /* flags/opcodes, etc. */ struct in_addr v_smask; /* Subnet mask */ struct in_addr v_dgate; /* Default gateway */ struct in_addr v_dns1, v_dns2; /* Domain name servers */ struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ struct in_addr v_ts1, v_ts2; /* Time servers */ int32 v_unused[6]; /* currently unused */ }; /* v_flags values */ #define VF_SMASK 1 /* Subnet mask field contains valid data */ bootpc-0.64.orig/bootpc.c100600 1750 1750 50470 6636312730 15075 0ustar herbertgreathan/* Last updated : Mon Sep 16 15:20:57 1996 Modified by JSP from code by Charles Hawkins , J.S.Peatfield@damtp.cam.ac.uk Copyright (c) University of Cambridge, 1993-1996 See the file NOTICE for conditions of use and distribution. $Revision: 1.11 $ $Date: 1998/12/15 03:42:28 $ */ /* Standard headers */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* local headers */ #include "bootpc.h" /* My global variables */ int bootp_verbose = 0 ; /* verbose mode or not 10/02/94 JSP */ int bootp_debug = 0 ; /* debug mode or not 14/02/94 JSP */ static int returniffail ; /* Return to the user if we fail */ static int printflag; /* Print control */ static int sockfd; int performBootp(char *device, char *server, char *bootfile, int timeout_wait, int givenhwaddr, struct ifreq *their_ifr, int waitformore, int bp_rif, int bp_pr, int broadcast) { struct ifreq ifr; struct sockaddr_in cli_addr, serv_addr; struct bootp *bootp_xmit, *bootp_recv; fd_set rfds, wfds, xfds; struct timeval timeout ; int32 rancopy ; int cookielength ; long plen ; int retry_wait, waited=0 ; int one=1, i ; struct timeval tp; int received_packet = 0 ; /* See RFC1497, RFC1542 09/02/94 JSP */ unsigned char mincookie[] = {99,130,83,99,255} ; returniffail=bp_rif ; printflag=bp_pr ; /* zero structure before use */ memset((char *) &serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr(server) ; serv_addr.sin_port = htons(IPPORT_BOOTPS); if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("bootpc: socket failed"); return BootpFatal(); } if (setsockopt(sockfd,SOL_SOCKET,SO_BROADCAST,&one,sizeof(one))==-1) { perror("bootpc: setsockopt failed"); return BootpFatal(); } memset((char *) &cli_addr, 0, sizeof(cli_addr)); cli_addr.sin_family = AF_INET; cli_addr.sin_addr.s_addr = htonl(INADDR_ANY); cli_addr.sin_port = htons(IPPORT_BOOTPC); if(bind(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr)) < 0) { perror("bootpc: bind failed"); return BootpFatal(); } /* allocate bootp packet before we use it */ bootp_xmit = (struct bootp *) malloc(BUFSIZ) ; memset((char *) bootp_xmit, 0, BUFSIZ) ; bootp_recv = (struct bootp *) malloc(BUFSIZ) ; memset((char *) bootp_recv, 0, BUFSIZ) ; /* Server needs to broadcast for me to see it */ if (broadcast || givenhwaddr) bootp_xmit->bp_flags |= htons(BPFLAG_BROADCAST); /* Don't do this if we were given the MAC address to use. 27/09/94 JSP */ if (givenhwaddr) { /* Assuming ETHER if given HW */ ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER ; ifr.ifr_hwaddr = their_ifr->ifr_hwaddr ; } else { /* Get the hardware address, and family information */ memcpy(ifr.ifr_name, device, strlen(device)+1); if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) { perror("bootpc: ioctl failed"); return BootpFatal(); } } /* Check the network family if in NET3 or later, before NET3 you couldn't examine this info (as far as I know.) */ /* set the htype field from the sa.family of the hardware address, if this doesn't work for your interface type let me know please. */ bootp_xmit->bp_htype = ifr.ifr_hwaddr.sa_family; bootp_xmit->bp_hlen = IFHWADDRLEN ; /* All MAC addresses are the same length */ if (bootp_debug) logMessage("Got family=%d (Ether=%d)", bootp_xmit->bp_htype, ARPHRD_ETHER); /* If we have the time seed with it xor the hardware address, otherwise use the hardware address 12/02/94 JSP */ if (gettimeofday(&tp, NULL) == -1) rancopy = 0 ; else rancopy = tp.tv_sec + tp.tv_usec ; /* Do the XOR */ for (i=0; i < IFHWADDRLEN ; ++i) { ((unsigned char *)&rancopy)[ i % sizeof(rancopy) ] ^= ((unsigned char *)(ifr.use_hwaddr))[i] ; } /* and set the seed */ srand(rancopy) ; if(bootp_debug) { logMessage("hardware addr is :") ; for (i=0; i < bootp_xmit->bp_hlen ; ++i) logMessage("%2.2X ", ((unsigned char *)(ifr.use_hwaddr))[i]) ; } /* Now fill in the packet. */ bootp_xmit->bp_op = BOOTREQUEST ; /* Now with my understanding of the bootp protocol we *should* just need to copy the hwaddr over, but it seems that at least ARCNET bootb servers are wird in this respect. So here is a switch in case of other weirdness. JSP */ switch(bootp_xmit->bp_htype) { /* ARCNET uses a "fake" ethernet address, with the ARCNET address at the wrong end. At least the Novell bootp server on ARCNET assumes this. Thanks to Tomasz Motylewski for reporting this. */ case ARPHRD_ARCNET : memcpy(bootp_xmit->bp_chaddr+IFHWADDRLEN-1, (char *)(ifr.use_hwaddr), 1) ; bootp_xmit->bp_htype=ARPHRD_ETHER; bootp_xmit->bp_hlen=IFHWADDRLEN; break ; /* Add other network weirdness here */ /* For sensible networks the rest is normal */ default : memcpy(bootp_xmit->bp_chaddr, (char *)(ifr.use_hwaddr), bootp_xmit->bp_hlen) ; } /* Must start with zero here, see RFC1542 09/02/94 JSP */ bootp_xmit->bp_secs = 0; /* Put in the minimal RFC1497 Magic cookie 09/02/94 JSP */ memcpy(bootp_xmit->bp_vend, mincookie, sizeof(mincookie)); /* Put the user precified bootfile name in place 12/02/94 */ memcpy(bootp_xmit->bp_file, bootfile, strlen(bootfile)+1); /* put a random value in here, but keep a copy to check later 09/02/94 JSP */ bootp_xmit->bp_xid = rancopy = rand() ; retry_wait = 2 ; if (bootp_verbose) logMessage("BOOTPclient broadcast..."); while (((waited <= timeout_wait) && !received_packet) || ((waited <= waitformore) && received_packet)) { if (!received_packet) { /* Move this to a sendpacket function */ /* set time of this timeout 09/02/94 JSP */ bootp_xmit->bp_secs = waited ; if (bootp_verbose) { logMessage("."); fflush(stderr); } if (bootp_debug) { logMessage("Size = %ld", (long)sizeof(struct bootp)) ; } if(sendto(sockfd, bootp_xmit, sizeof(struct bootp), 0, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { perror("bootpc: sendto"); return BootpFatal(); } } /* Move rest of this loop to a receivepacket function */ FD_ZERO(&rfds); /* The above was missing, thanks to Gilles Detillieux for pointing it out */ FD_SET(sockfd,&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); /* Randomise the delays a little as suggested in RFC1542 09/02/94 JSP */ timeout.tv_sec = retry_wait + (1+(rand() & (retry_wait-1))) ; timeout.tv_usec = 0; waited += timeout.tv_sec ; /* Add this to the total time we have waited */ if(select(sockfd+1, &rfds, &wfds, &xfds, &timeout)<0) { perror("bootpc: select"); return BootpFatal(); } if(!FD_ISSET(sockfd, &rfds)) { retry_wait = retry_wait*2; } else { if ((plen = recvfrom(sockfd, bootp_recv, BUFSIZ, 0, (struct sockaddr *)NULL, (int *)NULL)) < 0){ perror("bootpc: recvfrom"); return BootpFatal(); } if (bootp_debug) { logMessage("plen = %ld plen - sizeof(struct bootp) = %ld", (long)plen, (long)(plen - sizeof(struct bootp))) ; } cookielength = 64 + plen - sizeof(struct bootp) ; if (bootp_recv->bp_xid == rancopy) { /* is xid right */ if (!received_packet) { /* If we haven't already recieved a packet then set the time to wait further to be now + time user specified */ waitformore += waited ; received_packet = 1 ; } else { /* To make it look a bit prettier */ if (printflag & BP_PRINT_OUT) printf("\n") ; } /* Pass the cookie info, the mincookie to look for and our address to the cookie parser. It needs our address to get the network and broadcast bits right if the SUBNET is defined in the cookie. 10/02/94 JSP */ ParsePacket(bootp_recv, cookielength, mincookie) ; } else { /* xid mismatch so normally silently ignore */ if (bootp_verbose) { logMessage("WARNING bp_xid mismatch got 0x%lx sent 0x%lx", (long)bootp_recv->bp_xid, (long)rancopy) ; } } } } if (!received_packet) { logMessage("No response from BOOTP server"); return BootpFatal(); } if (sockfd) close (sockfd) ; return 0 ; /* Normal exit */ } int BootpFatal() { if (sockfd) close (sockfd) ; if (bootp_debug) logMessage("In BootpFatal(), errno was %d", errno) ; if (returniffail) { logMessage("bootpc failed to locate a network address") ; return 1 ; } logMessage(" Unable to locate an IP address for this host.\n" " ***Please report this problem**\n\n" " [Unable to continue]\n"); if (bootp_debug) logMessage("Will now loop forerver, break out of this to fix") ; while(1) { /* your eyes are getting heavy.... */ sleep(1000) ; } } /* Parse Magic cookies as specified in RFC1497, well only the bits we are actually interested in... 09/02/94 JSP */ void ParsePacket(struct bootp * bootp_recv, int cookielength, unsigned char *match) { int i=0, len, tag ; int subnet = 0 ; struct in_addr temp ; unsigned char *cookie = (unsigned char *)(bootp_recv->bp_vend) ; struct in_addr temp_addr, my_addr ; temp_addr.s_addr = bootp_recv->bp_siaddr.s_addr ; OutString("SERVER", (unsigned char *)inet_ntoa(temp_addr), -1); my_addr.s_addr = bootp_recv->bp_yiaddr.s_addr ; OutString("IPADDR", (unsigned char *)inet_ntoa(my_addr), -1); if (bootp_verbose) { logMessage("bp_file len is %d", strlen(bootp_recv->bp_file)) ; } OutString("BOOTFILE", (unsigned char *)bootp_recv->bp_file, -1) ; if (bootp_debug) { /* dump cookie contents in HEX 10/02/94 JSP */ for (i=0; i cookielength) { if (bootp_verbose) logMessage("TAG %d at %d. len %d, overrun %d", cookie[i], i, len, i + len - cookielength) ; /* And truncate in any case even with no warning */ len = cookielength - i ; } switch (cookie[i]) { /* The monster switch statement ... */ /* PAD cookie */ case TAG_PAD : i++ ; break ; /* SUBNET we are in */ case TAG_SUBNET_MASK : if (bootp_verbose && len != 4) logMessage("WARNING len of tag 1 is %d not 4", len) ; memcpy((char *)&temp, cookie + i + 2, 4) ; OutString("NETMASK", (unsigned char *)inet_ntoa(temp), -1) ; /* Both values are in network order so this doesn't care about the ordering 10/02/94 JSP */ my_addr.s_addr &= temp.s_addr ; OutString("NETWORK", (unsigned char *)inet_ntoa(my_addr), -1) ; my_addr.s_addr |= ~temp.s_addr ; OutString("BROADCAST", (unsigned char *)inet_ntoa(my_addr), -1) ; /* defined so we know later that subnet info has been printed 11/02/94 JSP */ subnet = 1 ; i += len + 2 ; break ; /* Time of day */ case TAG_TIME_OFFSET : /* ignored */ i += len + 2 ; break ; /* IP Gateways (routers) */ case TAG_GATEWAY : OutList("GATEWAYS", cookie+i+2, len) ; i += len + 2 ; break ; /* Timeservers (see RFC-868) */ case TAG_TIME_SERVER : OutList("TIMESRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* IEN-116 Nameservers */ case TAG_NAME_SERVER : OutList("IEN116SRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* DNS Nameservers */ case TAG_DOMAIN_SERVER : OutList("DNSSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* LOGGING servers */ case TAG_LOG_SERVER : OutList("LOGSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* Quote of day/Cookie servers */ case TAG_COOKIE_SERVER : OutList("QODSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* LPR servers */ case TAG_LPR_SERVER : OutList("LPRSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* Impress (Imogen) servers */ case TAG_IMPRESS_SERVER : OutList("IMPRESSSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* Remote Location Protocol servers */ case TAG_RLP_SERVER : OutList("RLPSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* HOSTNAME (may be fqdn or leaf) */ case TAG_HOST_NAME : OutString("HOSTNAME", cookie+i+2, len) ; i += len + 2 ; break ; /* BOOT File Size (ignored) */ case TAG_BOOT_SIZE : i += len + 2 ; break ; /* Merit DUMP File name (ignored) */ case TAG_DUMP_FILE : i += len + 2 ; break ; /* DOMAIN */ case TAG_DOMAIN_NAME : OutString("DOMAIN", cookie+i+2, len) ; OutSearch("SEARCH", cookie+i+2, len) ; i += len + 2 ; break ; /* SWAPServer address */ case TAG_SWAP_SERVER : OutList("SWAPSRVR", cookie+i+2, len) ; i += len + 2 ; break ; /* Root pathname to mount as root filesystem */ case TAG_ROOT_PATH : OutString("ROOT_PATH", cookie+i+2, len) ; i += len + 2 ; break ; /* Extensions. Name of further Cookie data */ case TAG_EXTEN_FILE : OutString("EXTEN_FILE", cookie+i+2, len) ; i += len + 2 ; break ; /* NIS (formerly YP) domain name */ case TAG_NIS_DOMAIN : OutString("YPDOMAIN", cookie+i+2, len) ; i += len + 2 ; break ; /* NIS (formerly YP) server */ case TAG_NIS_SERVER : OutList("YPSRVR", cookie+i+2, len) ; i += len + 2 ; break ; /* Time servers */ case TAG_NTP_SERVER : OutList("NTPSRVS", cookie+i+2, len) ; i += len + 2 ; break ; /* END of cookie (phew) */ case TAG_END : if (bootp_verbose) logMessage("end of cookie parsing, END tag found") ; return ; default: { char name[30] ; if (bootp_verbose) { if (tag >= 128 && tag <= 254) /* reserved */ logMessage("Reserved TAG %d at %d (len %d)", tag, i, len) ; else logMessage("Unknown TAG %d at %d (len %d)", tag, i, len) ; } sprintf(name, "T%3.3d", tag) ; OutString(name, cookie+i+2, len) ; i += 2 + len ; } break ; } } /* No SUBNET TAG in the cookie so we fake guess here, if this is wrong then fix your bootp server to tell us the answer rather than hacking this code. */ if (!subnet) { struct in_addr netmask ; int type ; if (bootp_verbose) logMessage("Guessing netmask from IP address range") ; type = ntohl(temp_addr.s_addr) ; if ((type & 0x80000000) == 0) { /* Class A */ netmask.s_addr = htonl(0xFF000000) ; } else if ((type & 0x40000000) == 0) { /* Class B */ netmask.s_addr = htonl(0xFFFF0000) ; } else if ((type & 0x20000000) == 0) { /* Class C */ netmask.s_addr = htonl(0xFFFFFF00) ; } else { /* GOD KNOWS... other classes are weird */ if (bootp_verbose) logMessage("IP number not Class A,B or C. Setting NETMASK to zero") ; netmask.s_addr = htonl(0x00000000) ; } OutString("NETMASK", (unsigned char *)inet_ntoa(netmask), -1); temp_addr.s_addr &= netmask.s_addr ; OutString("NETWORK", (unsigned char *)inet_ntoa(temp_addr), -1); temp_addr.s_addr |= ~netmask.s_addr ; OutString("BROADCAST", (unsigned char *)inet_ntoa(temp_addr), -1); } } /* Print out a list of IP addresses */ void OutList(char *name, unsigned char *cookie, int len) { struct in_addr temp ; char lenv[BUFSIZ], *ptr ; int n, c, i; if (bootp_verbose) logMessage("%s found len=%d", name, len) ; if ((len % 4) != 0) { if (bootp_verbose) logMessage("ERROR %s length (%d) not 4 div", name, len) ; return ; } if (len == 0) /* Nothing to do 10/02/94 JSP */ return ; for (n=0,i=1 ; len; len -= 4, cookie += 4, i++) { char lbuf[BUFSIZ] ; memcpy((char *)&temp, cookie, 4) ; ptr = inet_ntoa(temp) ; c = strlen(ptr) ; sprintf(lbuf, "%s_%d", name, i) ; OutString(lbuf, (unsigned char *)ptr, c) ; strncpy(lenv+n, ptr, c) ; n += c ; if (len > 4) lenv[n++] = ' '; } lenv[n] = 0 ; doOut(name, lenv) ; } /* Prints the string passed */ void OutString(char *name, unsigned char *cookie, int len) { char lenv[BUFSIZ]; if (len == -1) len = strlen((char *)cookie) ; safecopy((unsigned char *)lenv, cookie, len); doOut(name, lenv) ; } /* Prints the string as usable in a DNS search. This is doing the same as the old default BIND (pre 4.9.3) did with a DOMAIN line, for backwards compatibility, and since BOOTP doesn't allow a way to specify the search path explicitly */ void OutSearch(char *name, unsigned char *cookie, int len) { unsigned char *ptr, *nptr ; unsigned char buf[258] ; /* Max len is 255 */ char lenv[BUFSIZ] ; int n=0; strncpy((char *)buf, (char *)(cookie), len) ; buf[ len + 1 ] = 0 ; /* Null terminate it */ ptr = buf ; while (len) { safecopy((unsigned char *)(lenv+n), ptr, len) ; n += len ; /* Goto next bit */ nptr = (unsigned char *)strchr((char *)ptr, '.') ; /* Cast cast cast */ if (nptr == NULL) { len = 0 ; /* End of string I hope */ } else { if (strchr((char *)nptr + 1, '.') == NULL) { /* Trad to not use last component */ len = 0 ; } else { len -= (nptr - ptr) + 1 ; ptr = nptr + 1 ; lenv[n++] = ' ' ; } } } lenv[n] = 0 ; doOut(name, lenv) ; } /* Takes an address and returns useful bits of the name after lookup, this was a seperate program, but it is more compact to have both together. 17/02/94 JSP */ int in2host(char *address, int bp_pr) { struct in_addr sin_addr; struct hostent *hp; char *c ; printflag=bp_pr ; /* convert to standard network form */ sin_addr.s_addr = inet_addr(address); /* perform lookup, must have DNS running or have local hosts file at this point */ hp = gethostbyaddr((char *)&sin_addr, sizeof(sin_addr), AF_INET) ; if (hp == NULL) { perror ("bootpc: gethostbyaddr") ; return -1; } /* Print out a known name to stop repeated calls */ OutString("DONEIN2HOST",(unsigned char *)"1", -1) ; /* Print out full name as returned by the call */ OutString("HOSTFULL", (unsigned char *)(hp->h_name), -1) ; for(c=(char *)hp->h_name; *c ; ++c) if(*c == '.') { /* Zap first 'dot' to give leaf and domain names */ OutString("HOSTDOMAIN", (unsigned char *)(c+1), -1) ; OutSearch("HOSTSEARCH", (unsigned char *)(c+1), strlen(c+1)) ; *c = 0 ; OutString("HOSTLEAF", (unsigned char *)(hp->h_name), -1) ; return 0 ; } return 0 ; } /* Copy those bits of a string which are alphanumeric or in a "safe" list of characters. */ void safecopy(unsigned char *out, unsigned char *string, int len) { char safe[] = "./:-_=+[]~()%&*^#@! " ; int i, c ; for (i =0 ; i < len; ++i) { c = string[i] ; if (isalnum(c)) out[i] = c ; /* alphanumeric */ else { /* Not alphanumeric */ if (strchr(safe, c) != NULL) { out[i] = c ; /* but safe */ } else { out[i] = '?' ; /* NOT safe */ if (bootp_verbose) logMessage("Illegal char 0x%2.2X", c) ; } } } out[i] = 0 ; } void doOut(char *name, char *lenv) { if (printflag & BP_PRINT_OUT) { printf("%s='%s'\n", name, lenv) ; } if (printflag & BP_PUT_ENV) { char envb[BUFSIZ], *envp ; sprintf(envb, "BOOTP_%s=%s", name, lenv) ; envp = strdup(envb) ; if (bootp_debug) logMessage("ENV setting :%s:", envp) ; putenv(envp) ; } } bootpc-0.64.orig/bootpc.h100600 1750 1750 3762 6636312730 15064 0ustar herbertgreathan/* Last updated : Fri Sep 13 22:04:22 1996 J.S.Peatfield@damtp.cam.ac.uk Copyright (c) University of Cambridge, 1993-1996 See the file NOTICE for conditions of use and distribution. $Revision: 1.4 $ $Date: 1998/12/15 03:24:05 $ */ #define BPCVERSION "BOOTPclient V0.64" /* Tell the server to broadcast to reach me flag */ #define BPFLAG_BROADCAST ( 1 << 15 ) /* Back in NET2 (and before?) the ifreq.ifr_hwaddr was a char array, but in NET3 it is now a "sockaddr", and we need the data part. The code to work on older kernels has now been removed as it caused problems on some systems where this test no longer works (e.g. the AlphaLinux). Is anyone really running 1.1.13 or earlier kernels anymore? If you still have an old kernel and need bootpc stick with version 0.45 which is the last release to support the NET2 code. */ /* local headers */ #include "bootp.h" #include "log.h" /* for extracting the right part... */ #define use_hwaddr ifr_hwaddr.sa_data /* Needed for getopt stuff */ extern char *optarg; extern int optind, opterr, optopt; /* declarations */ int BootpFatal(); void ParsePacket(struct bootp *bootp_recv, int cookielength, unsigned char *match) ; void OutList(char *name, unsigned char *cookie, int len) ; void OutString(char *name, unsigned char *cookie, int len) ; void OutSearch(char *name, unsigned char *cookie, int len) ; void safecopy(unsigned char *out, unsigned char *string, int len) ; void doOut(char *name, char *lenv) ; int in2host(char *address, int print) ; int performBootp(char *device, char *server, char *bootfile, int timeout_wait, int givenhwaddr, struct ifreq *ifr, int waitformore, int returniffail, int print, int broadcast) ; /* My global variables */ extern int bootp_verbose ; /* verbose mode or not 10/02/94 JSP */ extern int bootp_debug ; /* debug mode or not 14/02/94 JSP */ #define BP_PRINT_OUT (1) #define BP_PUT_ENV (2) bootpc-0.64.orig/log.h100600 1750 1750 367 6636312730 14335 0ustar herbertgreathan#ifndef _H_LOG #define _H_LOG #include extern FILE * log; extern int logfd; extern int testing; extern int hackDisk; #define logMessage doLogMessage void doLogMessage(char * s, ...); void openLog(void); void closeLog(void); #endif bootpc-0.64.orig/main.c100600 1750 1750 10635 6636312730 14532 0ustar herbertgreathan/* Last updated : Mon Sep 23 16:22:27 1996 Modified by JSP from code by Charles Hawkins , J.S.Peatfield@damtp.cam.ac.uk Copyright (c) University of Cambridge, 1993-1996 See the file NOTICE for conditions of use and distribution. $Revision: 1.3 $ $Date: 1998/12/15 03:43:00 $ */ /* Standard headers */ #include #include #include #include #include #include #include "bootpc.h" FILE * logfile = stderr ; int main(int argc, char *argv[]) { struct ifreq ifr; int timeout_wait = 70; int waitformore=-1 ; /* How long to wait after 1st reply for more replies */ int givenhwaddr, i, serverbcast=0; char *device, *bootfile, *server ; int returniffail=0, printflag = BP_PRINT_OUT ; /* defaults unless overridden by command line options 10/02/94 JSP */ device = "eth0" ; /* first ethernet card */ bootfile = "" ; /* No bootfile by default */ server = "255.255.255.255" ; /* i.e broadcast to everyone */ givenhwaddr = 0 ; /* i.e. use our real HW address */ while (1) { int option_index = 0, option ; static struct option long_options[] = { {"bootfile", 1, 0, 1}, {"dev", 1, 0, 2}, {"verbose", 0, 0, 3}, {"debug", 0, 0, 4}, {"server", 1, 0, 5}, {"hwaddr", 1, 0, 6}, {"returniffail", 0, 0, 7}, {"timeoutwait", 1, 0, 8}, {"waitformore",1, 0, 9}, {"in2host", 1, 0, 10}, {"serverbcast",0, 0, 11}, {"help", 0, 0, 100}, {0, 0, 0, 0}, } ; option = getopt_long (argc, argv, "", long_options, &option_index); if (option == -1) break ; switch (option) { case 1: /* New bootfile */ bootfile = optarg ; if (strlen(bootfile) > 127) { /* buffer space for 128 only */ if (bootp_verbose) logMessage("Bootfile %s too long, truncating", bootfile) ; bootfile[127] = 0; } break ; case 2: /* New device */ device = optarg ; if (strlen(device) > IFNAMSIZ-1) { /* only IFNAMSIZ space in struct */ if (bootp_verbose) logMessage("device name %s too long, truncating", device) ; device[IFNAMSIZ -1] = 0; } break ; case 3: bootp_verbose = 1 ; break ; case 4: bootp_debug = 1 ; break ; case 5: server = optarg ; break ; case 6: /* This MAY be useful for some types of bootp_debugging, however all the bootpd programs I have reply to the hardware address given here, thus we never see the replies. Other bootpds may not so it may be possible to use this to test a bootpd will respond for another HW address. 17/08/94 JSP */ { int error, count ; unsigned int value ; for (i=0; i < IFHWADDRLEN; ++i) { /* get the MAC address from user */ error = sscanf(optarg, "%2x%n%*[ :.]%n", &value,&count,&count) ; ifr.use_hwaddr[i] = value ; if (error <= 0) { /* Not enough given */ if (bootp_debug) logMessage("Ran out of numbers in hwaddr, ignoring") ; break ; } optarg += count ; } givenhwaddr = 1 ; } break ; case 7: returniffail = 1 ; break ; case 8: timeout_wait = atoi(optarg) ; break ; case 9: waitformore = atoi(optarg) ; break ; case 10: /* used for the reverse lookup to hostname */ return in2host(optarg, printflag) ; break ; case 11: serverbcast = 1 ; break ; case 100: logMessage("%s is used to find the IP number and other setup\n" "information for a machine", argv[0]) ; default: logMessage("\t%s", BPCVERSION) ; logMessage( "Usage: %s\t[--dev device] [--bootfile file] [--bootp_verbose]\n" "\t\t[--server address] [--hwaddr mac-address]\n" "\t\t[--timeoutwait seconds] [--serverbcast]\n" "\t\t[--waitformore seconds]\n" "\t\t[--in2host address]\n" "\t\t[--help] [--returniffail]", argv[0]) ; exit (1) ; } } if (bootp_verbose) { logMessage("\t%s\n\tdevice=%s bootfile=%s timeout=%d\n", BPCVERSION, device, bootfile, timeout_wait ) ; } return performBootp(device, server, bootfile, timeout_wait, givenhwaddr, &ifr, waitformore, returniffail, printflag, serverbcast) ; } #include void doLogMessage(char * s, ...) { va_list args; va_start(args, s); fprintf(logfile, "* "); vfprintf(logfile, s, args); fprintf(logfile, "\n"); va_end(args); } bootpc-0.64.orig/bptypes.h100600 1750 1750 750 6636312730 15236 0ustar herbertgreathan/* bptypes.h */ #ifndef BPTYPES_H #define BPTYPES_H /* * 32 bit integers are different types on various architectures */ /* I hope that this test actually works! */ #ifndef int32 /* Assume that int is 32bits -- we can't test better than this in cpp If this is wrong, then define int32 externally to override this */ # define int32 int #endif typedef unsigned int32 u_int32; /* * Nice typedefs. . . */ typedef int boolean; typedef unsigned char byte; #endif /* BPTYPES_H */ bootpc-0.64.orig/rc.bootp100600 1750 1750 21117 6636312730 15110 0ustar herbertgreathan#!/bin/sh # # Copyright (c) University of Cambridge, 1993-1996 # See the file NOTICE for conditions of use and distribution. # # Written to simply set the IP stuff up from the # bootpc data. # # Last updated : Mon Sep 23 16:18:30 1996 # Jon Peatfield # # with modifications as suggested by Austin Donnelly, Chris Hall, # Donal K Fellows and choltje@ux1.cso.uiuc.edu. # # Setup of hosts file modified as suggested by Carl Olson # to get the local IP address right when using some # resolver options... # # $Revision: 1.7 $ # # Release Version 0.64 #set -x ## The following options are policy decisions you may want to choose ## for the machines on your site. i.e. if you don't edit it you get ## what I use! -- Jon # If you prefer FQDN names rather than leafnames set to 'y'; # This causes the code to ignore the HOSTNAME returned by the BOOTP # server and do a gethostbyname() on the IP number we were given. # This will only work if the resolver can be set up or you have the # correct entry in /etc/hosts (!) FORCEFQDN='y' # If you want to add any extra options to ifconfig (e.g. pointopoint) # The first is used before the bootp the 2nd afterwards and is # expanded using `eval echo ${IFCONFOPTS2}` so will expand variables # then (when they are known) not now. ##IFCONFOPTS1='mtu 400 pointopoint' ##IFCONFOPTS2='mtu 400 pointopoint $SERVER' # Put search not domain line in resolv.conf for 4.9.3 based resolver # code (still works with older code too) if you like the old 4.8.3 # search rules with the new resolver code then set to 'y' MAKESEARCH='y' ## YOU MAY NEED TO EDIT THESE FOR DIFFERENT DISTRIBUTIONS # Location of the bootpc program BOOTPC=/usr/local/sbin/bootpc # location of ifconfig IFCONFIG=/sbin/ifconfig # location of route ROUTE=/sbin/route # location of hostname binary BINHOST=/bin/hostname ## Details of bootp to perform # What device to do the bootp on DEV=eth0 # What address to send bootp request to (broadcast by default) ASKSERVER="255.255.255.255" # To set the time we are willing to wait for a reply (roughly) # This defaults to 70 seconds anyway in the code. TW="--timeoutwait 70" # If you want bootpc to exit on failure and take down networking then # uncomment these line: RIF="--returniffail" RIFMESSAGE="Bootp failed -- disabling network." ## Shouldn't change location, but... # The location of the resolver config file RCONF=/etc/resolv.conf # location of the hosts file EHOSTS=/etc/hosts # location of the local hosts file.. LHOSTS=/etc/hosts.local ## Location of tmp file for storing options TMPFILE=/tmp/bootp-results.$$ # For testing purposes I uncomment these They probably arn't usefult # to you. -- Jon #BOOTPC=./bootpc #IFCONFIG='echo ifconfig' #ROUTE='echo route' #BINHOST='echo hostname' #RCONF=/tmp/resolv.conf #EHOSTS=/tmp/hosts #LHOSTS=/dev/null #ASKSERVER="131.111.255.255" #TW="--timeoutwait 20" ## This will fail when testing as we reply to our own PING... #set -x ## Start of the functions # Stick the nameserver lines in the resolver file. setservers() { # Insert the DNS servers themselves for i in $1 do echo "nameserver $i" >> ${RCONF} done } # A function for setting the DNS stuff if we have all the info setresolv() { [ -f ${RCONF} ] && mv -f ${RCONF} ${RCONF}.old # Insert provided information if [ "${MAKESEARCH}" = 'y' ]; then echo "search $2" > ${RCONF} else echo "domain $1" > ${RCONF} fi setservers "$3" } # A function for setting the DNS stuff if we don't know out domainname fakeresolv() { [ -f ${RCONF} ] && mv -f ${RCONF} ${RCONF}.fake # This means nothing, but provides a domain line (some(old) revolvers # break if there isn't one present.) echo "domain ." > ${RCONF} setservers "$1" } # And putting the original back if it exists unfakeresolv() { [ -f ${RCONF}.fake ] && mv -f ${RCONF}.fake ${RCONF} } # update the DNSSERVERS but not the domainname, in case of # reverse lookup failure. updateresolv() { [ -f ${RCONF} ] && mv -f ${RCONF} ${RCONF}.old # Copy over the domainname from the old file egrep 'domain|search' ${RCONF}.old > ${RCONF} setservers "$1" } # Remove the networking by taking down the interface netdown() { ${ROUTE} del default ${IFCONFIG} ${DEV} down } ## End of the functions ## Start of the actual work # Bring up minimal networking use 0.0.0.0 as our address as we don't # know it yet (Means "Me but I don't know my address or network") ${IFCONFIG} ${DEV} up ${IFCONFOPTS1} 0.0.0.0 ${ROUTE} add default dev ${DEV} # Perform the bootp -- doesn't return unless it gets an answer if ${BOOTPC} --dev ${DEV} --server ${ASKSERVER} ${RIF} ${TW} > ${TMPFILE} then # Take down networking (use the 0.0.0.0 for as short a time as possible) netdown # Read in the values eval `cat ${TMPFILE}` # And delete the temporary file rm ${TMPFILE} else # Take down networking (use the 0.0.0.0 for as short a time as possible) netdown # give message and quit echo ${RIFMESSAGE} exit 1 fi # Only SERVER and IPADDR are guarenteed by the bootp (assuming # It works), so check the rest. # Start the loopback interface and add a route to it ${IFCONFIG} lo 127.0.0.1 ${ROUTE} add -net 127.0.0.0 # Setup of IP stuff needs doing first # if [ -z "${NETMASK}" ] ; then # No netmask info, all this is guessed from the IP number # If this is wrong for your network FIX the bootpd to know # what it should send in the RFC1497 cookie! 11/02/94 JSP # ${IFCONFIG} ${DEV} up ${IPADDR} broadcast ${BROADCAST} `eval echo ${IFCONFOPTS2}` ${ROUTE} -n add -net ${NETWORK} dev ${DEV} else # We will have NETMASK, BROADCAST, and NETWORK defined ${IFCONFIG} ${DEV} up ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK} `eval echo ${IFCONFOPTS2}` ${ROUTE} -n add -net ${NETWORK} dev ${DEV} fi # Gateways need IP to be able to add the (primary) route. # if [ -z "${GATEWAYS}" ] ; then # No gateways defined echo "No IP gateways defined in rc.bootp setup" else # First one listed is supposedly our best, so only use it. ( set - ${GATEWAYS} ; ${ROUTE} add default gw ${1} ) fi # May need Gateways if the DNS servers are on the other side of the # gateways, this needs IP to be up. # # Can we set up DNS? if [ ! -z "${DNSSRVS}" ]; then if [ ! -z "${DOMAIN}" ]; then setresolv "${DOMAIN}" "${SEARCH}" "${DNSSRVS}" else # At least we have DNS, so use reverse lookup to get the information # Fake the resolver setup to do the reverse lookup. fakeresolv "${DNSSRVS}" eval `${BOOTPC} --in2host ${IPADDR}` unfakeresolv if [ ! -z "${HOSTDOMAIN}" ]; then # Got a domain, so use it setresolv "${HOSTDOMAIN}" "${HOSTSEARCH}" "${DNSSRVS}" else # We have DNSSRVS but no DOMAIN, and reverse lookup failed # If the resolver file is there use it's domainname if [ -f ${RCONF} ] ; then echo "Using old value from /etc/resolve.conf for domain/search" updateresolv "${DNSSRVS}" else echo "No BOOTP DOMAIN supplied" echo " reverse lookup failed" echo " and no existing resolver file" echo "=> resolver setup failed" fi fi fi else echo "No DNSSRVS supplied, resolver setup not possible" fi # May need DNS lookups if not provided by bootpd # # Set the hostname from what we got via bootp or reverse lookup echo "127.0.0.1 loopback localhost">${EHOSTS} if [ ! -z "${HOSTNAME}" -a "${FORCEFQDN}" != 'y' ]; then ${BINHOST} "${HOSTNAME}" echo "${IPADDR} ${HOSTNAME}" >>${EHOSTS} else if [ -z "${DONEIN2HOST}" ] ; then eval `${BOOTPC} --in2host ${IPADDR}` fi if [ -z "${FORCEFQDN}" ]; then # Use the leafname from the result if [ ! -z "${HOSTLEAF}" ]; then ${BINHOST} "${HOSTLEAF}" echo "${IPADDR} ${HOSTLEAF} ${HOSTFULL}">>${EHOSTS} fi else # Use the FQDN from the result if [ ! -z "${HOSTFULL}" ]; then ${BINHOST} "${HOSTFULL}" echo "${IPADDR} ${HOSTFULL} ${HOSTLEAF}">>${EHOSTS} fi fi fi # # And add the local hosts file (if any in too) # if [ -f ${LHOSTS} ]; then cat ${LHOSTS} >> ${EHOSTS} fi # None of this is relevant to IP startup but may be handy for some people # # Tell them about other info we got back, but don't use it # 'cos I'm too lazy to write code for this... # # Print out a value if present JSP printifhere() { [ ! -z "$2" ] && echo "$1 = $2" } printifhere TIMESRVS "${TIMESRVS}" printifhere IEN116SRVS "${IEN116SRVS}" printifhere LOGSRVS "${LOGSRVS}" printifhere QODSRVS "${QODSRVS}" printifhere LPRSRVS "${LPRSRVS}" printifhere IMPRESSSRVS "${IMPRESSSRVS}" printifhere RLPSRVS "${RLPSRVS}" printifhere SWAPSRVR "${SWAPSRVR}" printifhere BOOTFILE "${BOOTFILE}" printifhere TIMEOFFSET "${TIMEOFFSET}" printifhere BOOTSIZE "${BOOTSIZE}" printifhere YPDOMAIN "${YPDOMAIN}" printifhere YPSRVR "${YPSRVR}" printifhere NTPSRVS "${NTPSRVS}" # # ## End of the main work