]>
Commit | Line | Data |
---|---|---|
dcdb9792 TL |
1 | /* sample.h |
2 | ||
3 | Sample config file for clients. | |
4 | ||
5 | This file is provided as a sample in case the system you want to run | |
6 | on is not currently supported. If that is the case, follow the Porting:: | |
49733f31 TL |
7 | comments here and in other files as guides for what to change. Also, |
8 | note that this file hasn't been updated in a lo-o-o-ong time, so it's | |
9 | probably worth looking at the config files for working ports as well. */ | |
dcdb9792 TL |
10 | |
11 | /* | |
98311e4b DH |
12 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
13 | * Copyright (c) 1996-2003 by Internet Software Consortium | |
dcdb9792 | 14 | * |
98311e4b DH |
15 | * Permission to use, copy, modify, and distribute this software for any |
16 | * purpose with or without fee is hereby granted, provided that the above | |
17 | * copyright notice and this permission notice appear in all copies. | |
dcdb9792 | 18 | * |
98311e4b DH |
19 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
20 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
21 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
22 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
23 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
24 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
25 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
dcdb9792 | 26 | * |
98311e4b DH |
27 | * Internet Systems Consortium, Inc. |
28 | * 950 Charter Street | |
29 | * Redwood City, CA 94063 | |
30 | * <info@isc.org> | |
31 | * http://www.isc.org/ | |
49733f31 | 32 | * |
98311e4b | 33 | * This software has been written for Internet Systems Consortium |
49733f31 | 34 | * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. |
98311e4b | 35 | * To learn more about Internet Systems Consortium, see |
49733f31 TL |
36 | * ``http://www.isc.org/''. To learn more about Vixie Enterprises, |
37 | * see ``http://www.vix.com''. To learn more about Nominum, Inc., see | |
38 | * ``http://www.nominum.com''. | |
dcdb9792 TL |
39 | */ |
40 | ||
41 | /* Porting:: | |
42 | ||
43 | Some systems do not define basic integer types as shown below. | |
44 | On some systems, you need to include <bitypes.h> or <sys/bitypes.h>. | |
45 | If you get parse errors in dhcpd.h while compiling dhcpd.conf, try | |
46 | including bitypes.h, and if that fails, use the hard-coded definitions | |
47 | shown below. */ | |
48 | ||
49 | #if 0 | |
50 | #include <sys/bitypes.h> | |
51 | #endif | |
52 | ||
53 | #if 0 | |
54 | #define int8_t char | |
55 | #define int16_t short | |
56 | #define int32_t long | |
57 | ||
58 | #define u_int8_t unsigned char | |
59 | #define u_int16_t unsigned short | |
60 | #define u_int32_t unsigned long | |
61 | #endif | |
62 | ||
63 | #include <sys/types.h> | |
64 | ||
65 | /* Porting:: | |
66 | ||
67 | The jmp_buf type as declared in <setjmp.h> is sometimes a structure | |
68 | and sometimes an array. By default, we assume it's a structure. | |
69 | If it's an array on your system, you may get compile warnings or errors | |
70 | as a result in confpars.c. If so, try including the following definitions, | |
71 | which treat jmp_buf as an array: */ | |
72 | ||
73 | #if 0 | |
74 | #define jbp_decl(x) jmp_buf x | |
75 | #define jref(x) (x) | |
76 | #define jdref(x) (x) | |
77 | #define jrefproto jmp_buf | |
78 | #endif | |
79 | ||
80 | /* Porting:: | |
81 | ||
82 | Some older systems (e.g., Ultrix) still use the 4.2BSD-style syslog | |
83 | API. These differ from later versions of the syslog API in that the | |
84 | openlog system call takes two arguments instead of three, and the | |
85 | facility code (the third argument to modern versions of openlog()) | |
86 | is ORed into the log priority in the syslog() call. | |
87 | ||
88 | If you are running with the 4.2BSD-style syslog interface, define | |
89 | SYSLOG_4_2. */ | |
90 | ||
91 | /* #define SYSLOG_4_2 */ | |
92 | ||
93 | #include <syslog.h> | |
94 | ||
95 | #include <string.h> | |
96 | #include <errno.h> | |
97 | #include <unistd.h> | |
98 | #include <sys/wait.h> | |
99 | #include <signal.h> | |
100 | #include <setjmp.h> | |
101 | #include <limits.h> | |
102 | ||
103 | extern int h_errno; | |
104 | ||
105 | #include <net/if.h> | |
106 | #include <net/if_arp.h> | |
107 | ||
108 | /* Porting:: | |
109 | ||
110 | Some older systems do not have defines for IP type-of-service, | |
111 | or don't define them the way we expect. If you get undefined | |
112 | symbol errors on the following symbols, they probably need to be | |
113 | defined here. */ | |
114 | ||
115 | #if 0 | |
116 | #define IPTOS_LOWDELAY 0x10 | |
117 | #define IPTOS_THROUGHPUT 0x08 | |
118 | #define IPTOS_RELIABILITY 0x04 | |
119 | #endif | |
120 | ||
121 | /* Porting:: | |
122 | ||
123 | Newer BSD derivatives store non-permanent daemon files in a | |
124 | directory called /var/run. If your system has a /var/run, | |
125 | use it; otherwise, use /etc. */ | |
126 | ||
127 | #ifndef _PATH_DHCPD_PID | |
128 | #define _PATH_DHCPD_PID "/etc/dhcpd.pid" | |
129 | #endif | |
d432c972 TL |
130 | #ifndef _PATH_DHCLIENT_PID |
131 | #define _PATH_DHCLIENT_PID "/etc/dhclient.pid" | |
132 | #endif | |
095a7994 TL |
133 | #ifndef _PATH_DHCRELAY_PID |
134 | #define _PATH_DHCRELAY_PID "/etc/dhcrelay.pid" | |
135 | #endif | |
dcdb9792 TL |
136 | |
137 | /* Porting:: | |
138 | ||
139 | If your system supports standard ANSI C, it should provide the file | |
140 | /usr/include/stdarg.h. This contains the ANSI standard declarations | |
141 | for functions which take a variable number of arguments. | |
142 | ||
143 | Older systems with non-ANSI compilers cannot support this interface, | |
144 | and generally use the older varargs interface, defined in <varargs.h>. | |
145 | Some systems only support varargs, but define the interface in | |
146 | <stdarg.h> anyway. | |
147 | ||
148 | You must choose one of the two sets of definitions below. Try | |
149 | stdarg.h first, unless you know it won't work. If you have | |
150 | trouble compiling errwarn.c, try switching to the varargs.h definitions. | |
151 | If that fails, try using stdarg.h with the varargs definitions. */ | |
152 | ||
153 | #if 0 | |
154 | /* Stdarg definitions for ANSI-compliant C compilers. */ | |
155 | #include <stdarg.h> | |
156 | #define VA_DOTDOTDOT ... | |
157 | #define VA_start(list, last) va_start (list, last) | |
158 | #define va_dcl | |
159 | #endif | |
160 | ||
161 | #if 0 | |
162 | /* Varargs definitions, for non-ANSI-compliant C compilers. */ | |
163 | #include <varargs.h> | |
164 | #define VA_DOTDOTDOT va_alist | |
165 | #define VA_start(list, last) va_start (list) | |
166 | #endif | |
167 | ||
168 | /* Porting:: | |
169 | ||
170 | Some systems (notably 4.4BSD derivatives) support versions of the | |
171 | sprintf functions which will deposit a limited number of characters | |
172 | into the buffer; that limit is provided in an extra argument. | |
173 | If your system doesn't support this functionality, you must include | |
98311e4b DH |
174 | the definition below for a dhcp-distribution-local version to be |
175 | built and used: */ | |
dcdb9792 TL |
176 | |
177 | #if 0 | |
dcdb9792 TL |
178 | #define NO_SNPRINTF |
179 | #endif | |
180 | ||
181 | /* Porting:: | |
182 | ||
183 | Some systems provide a function, strerror(), which takes the unix | |
184 | error number (see errno) and returns a pointer to a static buffer | |
185 | containing the corresponding error message. | |
186 | ||
187 | If your system doesn't provide strerror(), define NO_STRERROR | |
188 | as shown below: */ | |
189 | ||
190 | #if 0 | |
191 | #define NO_STRERROR | |
192 | char *strerror PROTO ((int)); | |
193 | #endif | |
194 | ||
195 | /* Porting:: | |
196 | ||
197 | Once dhcpd has initialized itself, it loops forever waiting for | |
198 | packets to come in. Since we need to support multiple input streams | |
199 | in order to support multiple interfaces, dhcpd needs to be able to | |
200 | do a syscall to determine which descriptors have input waiting on | |
201 | them. | |
202 | ||
203 | Normally, dhcpd uses the select() system call, which is a 4.2BSD | |
204 | syscall invented precisely for this purpose. Unfortunately, some | |
205 | System V-based systems do not support select() properly when it | |
206 | operates on streams. The System V interface which does (largely) | |
207 | the same thing as select is called poll(). In some cases, this may | |
208 | work better than select() - if you find that dhcpd is hanging and not | |
209 | responding to packets very consistently, you might try defining | |
210 | USE_POLL and including <poll.h>. */ | |
211 | ||
212 | #if 0 | |
213 | #define USE_POLL | |
214 | #include <poll.h> | |
215 | #endif | |
216 | ||
217 | /* Porting:: | |
218 | ||
219 | You must define the default network API for your port. This | |
220 | will depend on whether one of the existing APIs will work for | |
221 | you, or whether you need to implement support for a new API. | |
222 | Currently, the following APIs are supported: | |
223 | ||
224 | The BSD socket API: define USE_SOCKETS. | |
225 | The Berkeley Packet Filter: define USE_BPF. | |
226 | The Streams Network Interface Tap (NIT): define USE_NIT. | |
227 | Raw sockets: define USE_RAW_SOCKETS | |
228 | ||
229 | If your system supports the BSD socket API and doesn't provide | |
230 | one of the supported interfaces to the physical packet layer, | |
231 | you can either provide support for the low-level API that your | |
232 | system does support (if any) or just use the BSD socket interface. | |
233 | The BSD socket interface doesn't support multiple network interfaces, | |
234 | and on many systems, it does not support the all-ones broadcast | |
235 | address, which can cause problems with some DHCP clients (e.g. | |
236 | Microsoft Windows 95). */ | |
237 | ||
238 | #if defined (USE_DEFAULT_NETWORK) | |
239 | # define USE_SOCKETS | |
240 | #endif | |
241 | ||
242 | /* Porting:: | |
243 | ||
244 | Recent versions of BSD added a new element to the sockaddr structure: | |
245 | sa_len. This indicates the length of the structure, and is used | |
246 | in a variety of places, not the least of which is the SIOCGIFCONF | |
247 | ioctl, which is used to figure out what interfaces are attached to | |
248 | the system. | |
249 | ||
250 | You should be able to determine if your system has an sa_len element | |
251 | by looking at the struct sockaddr definition in /usr/include/sys/socket.h. | |
252 | If it does, you must define HAVE_SA_LEN. Otherwise, you must not. | |
253 | The most obvious symptom that you've got this wrong is either a compile | |
254 | error complaining about the use of the sa_len structure element, or | |
255 | the failure of dhcpd to find any interfaces. */ | |
256 | ||
257 | /* #define HAVE_SA_LEN */ | |
258 | ||
259 | /* Every operating system has its own way of seperating lines in a | |
260 | sequential text file. Most modern systems use a single character, | |
261 | either an ASCII Newline (10) or an ASCII Carriage Return (13). | |
262 | ||
263 | The most notable exception is MS-DOS (and consequently, Windows), | |
264 | which uses an ASCII Carriage Return followed by a Newline to | |
265 | seperate each line. Fortunately, MS-DOS C compiler libraries | |
266 | typically hide this from the programmer, returning just a Newline. | |
267 | ||
268 | Define EOL to be whatever getc() returns for a newline. */ | |
269 | ||
270 | #define EOL '\n' | |
271 | ||
272 | /* Some older C compilers don't support the void pointer type. | |
273 | ANSI C defines void * to be a pointer type that matches | |
274 | any other pointer type. This is handy for returning a pointer | |
275 | which will always need to be cast to a different value. For | |
276 | example, malloc() on an ANSI C-compliant system returns void *. | |
277 | ||
278 | If your compiler doesn't support void pointers, you may need to | |
279 | define VOIDPTR to be char *; otherwise, define it to be void *. */ | |
280 | ||
281 | #define VOIDPTR void * | |
282 | ||
283 | /* Porting:: | |
284 | ||
285 | The following definitions for time should work on any unix machine. | |
286 | They may not work (or at least, may not work well) on a variety of | |
287 | non-unix machines. If you are porting to a non-unix machine, you | |
288 | probably need to change the definitions below and perhaps include | |
289 | different headers. | |
290 | ||
291 | I should note that dhcpd is not yet entirely clean of unix-specific | |
292 | time references, so the list of defines shown below probably isn't | |
293 | good enough if you're porting to a system that really doesn't support | |
294 | unix time. It's probably a reasonable place to start, though. */ | |
295 | ||
296 | #include <time.h> | |
297 | ||
298 | #define TIME time_t | |
299 | #define GET_TIME(x) time ((x)) |