Home | History | Annotate | Line # | Download | only in common
bootpd.h revision 1.2
      1 /************************************************************************
      2           Copyright 1988, 1991 by Carnegie Mellon University
      3 
      4                           All Rights Reserved
      5 
      6 Permission to use, copy, modify, and distribute this software and its
      7 documentation for any purpose and without fee is hereby granted, provided
      8 that the above copyright notice appear in all copies and that both that
      9 copyright notice and this permission notice appear in supporting
     10 documentation, and that the name of Carnegie Mellon University not be used
     11 in advertising or publicity pertaining to distribution of the software
     12 without specific, written prior permission.
     13 
     14 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
     15 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
     16 IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
     17 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
     18 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     19 ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     20 SOFTWARE.
     21 ************************************************************************/
     22 
     23 
     24 /*
     25  * bootpd.h -- common header file for all the modules of the bootpd program.
     26  */
     27 
     28 #include "bptypes.h"
     29 #include "hash.h"
     30 #include "hwaddr.h"
     31 
     32 #ifndef TRUE
     33 #define TRUE	1
     34 #endif
     35 #ifndef FALSE
     36 #define FALSE	0
     37 #endif
     38 
     39 #ifndef PRIVATE
     40 #define PRIVATE static
     41 #endif
     42 
     43 #ifndef SIGUSR1
     44 #define SIGUSR1			 30	/* From 4.3 <signal.h> */
     45 #endif
     46 
     47 #define MAXSTRINGLEN		 80	/* Max string length */
     48 
     49 /* Local definitions: */
     50 #define MAX_MSG_SIZE		(3*512) /* Maximum packet size */
     51 
     52 
     53 /*
     54  * Return pointer to static string which gives full network error message.
     55  */
     56 #define get_network_errmsg get_errmsg
     57 
     58 
     59 /*
     60  * Data structure used to hold an arbitrary-lengthed list of IP addresses.
     61  * The list may be shared among multiple hosts by setting the linkcount
     62  * appropriately.
     63  */
     64 
     65 struct in_addr_list {
     66     unsigned int	linkcount, addrcount;
     67     struct in_addr	addr[1];		/* Dynamically extended */
     68 };
     69 
     70 
     71 /*
     72  * Data structures used to hold shared strings and shared binary data.
     73  * The linkcount must be set appropriately.
     74  */
     75 
     76 struct shared_string {
     77     unsigned int	linkcount;
     78     char		string[1];		/* Dynamically extended */
     79 };
     80 
     81 struct shared_bindata {
     82     unsigned int	linkcount, length;
     83     byte		data[1];		/* Dynamically extended */
     84 };
     85 
     86 
     87 /*
     88  * Flag structure which indicates which symbols have been defined for a
     89  * given host.  This information is used to determine which data should or
     90  * should not be reported in the bootp packet vendor info field.
     91  */
     92 
     93 struct flag {
     94     unsigned	bootfile	:1,
     95 		bootserver	:1,
     96 		bootsize	:1,
     97 		bootsize_auto	:1,
     98 		cookie_server	:1,
     99 		domain_server	:1,
    100 		gateway		:1,
    101 		generic		:1,
    102 		haddr		:1,
    103 		homedir		:1,
    104 		htype		:1,
    105 		impress_server	:1,
    106 		iaddr		:1,
    107 		log_server	:1,
    108 		lpr_server	:1,
    109 		name_server	:1,
    110 		name_switch	:1,
    111 		rlp_server	:1,
    112 		send_name	:1,
    113 		subnet_mask	:1,
    114 		tftpdir		:1,
    115 		time_offset	:1,
    116 		time_server	:1,
    117 		dump_file	:1,
    118 		domain_name	:1,
    119 		swap_server	:1,
    120 		root_path	:1,
    121 		exten_file	:1,
    122 		reply_addr	:1,
    123 		nis_domain	:1,
    124 		nis_server	:1,
    125 		ntp_server	:1,
    126 		exec_file	:1,
    127 		msg_size	:1,
    128 		min_wait	:1,
    129 		/* XXX - Add new tags here */
    130 		vm_cookie	:1;
    131 };
    132 
    133 
    134 
    136 /*
    137  * The flags structure contains TRUE flags for all the fields which
    138  * are considered valid, regardless of whether they were explicitly
    139  * specified or indirectly inferred from another entry.
    140  *
    141  * The gateway and the various server fields all point to a shared list of
    142  * IP addresses.
    143  *
    144  * The hostname, home directory, and bootfile are all shared strings.
    145  *
    146  * The generic data field is a shared binary data structure.  It is used to
    147  * hold future RFC1048 vendor data until bootpd is updated to understand it.
    148  *
    149  * The vm_cookie field specifies the four-octet vendor magic cookie to use
    150  * if it is desired to always send the same response to a given host.
    151  *
    152  * Hopefully, the rest is self-explanatory.
    153  */
    154 
    155 struct host {
    156     unsigned		    linkcount;		/* hash list inserts */
    157     struct flag		    flags;		/* ALL valid fields */
    158     struct in_addr_list	    *cookie_server,
    159 			    *domain_server,
    160 			    *gateway,
    161 			    *impress_server,
    162 			    *log_server,
    163 			    *lpr_server,
    164 			    *name_server,
    165 			    *rlp_server,
    166 			    *time_server,
    167 			    *nis_server,
    168 			    *ntp_server;
    169     struct shared_string    *bootfile,
    170 			    *hostname,
    171 			    *domain_name,
    172 			    *homedir,
    173 			    *tftpdir,
    174 			    *dump_file,
    175 			    *exten_file,
    176 			    *root_path,
    177 			    *nis_domain,
    178 			    *exec_file;
    179     struct shared_bindata   *generic;
    180     byte		    vm_cookie[4],
    181 			    htype,  /* RFC826 says this should be 16-bits but
    182 				       RFC951 only allocates 1 byte. . . */
    183 			    haddr[MAXHADDRLEN];
    184     int32		    time_offset;
    185     unsigned int32	    bootsize,
    186 			    msg_size,
    187 			    min_wait;
    188     struct in_addr	    bootserver,
    189 			    iaddr,
    190 			    swap_server,
    191 			    reply_addr,
    192 			    subnet_mask;
    193     /* XXX - Add new tags here (or above as appropriate) */
    194 };
    195 
    196 
    198 
    199 /*
    200  * Variables shared among modules.
    201  */
    202 
    203 extern int debug;
    204 extern char *bootptab;
    205 extern char *progname;
    206 
    207 extern u_char vm_cmu[4];
    208 extern u_char vm_rfc1048[4];
    209 
    210 extern hash_tbl *hwhashtable;
    211 extern hash_tbl *iphashtable;
    212 extern hash_tbl *nmhashtable;
    213 
    214