blob: e219143cc3f84d1778e93c510c5de669cb90710f [file] [log] [blame]
Russ Dill61fb4892002-10-14 21:41:28 +00001/* dhcpd.h */
2#ifndef _DHCPD_H
3#define _DHCPD_H
4
5#include <netinet/ip.h>
6#include <netinet/udp.h>
7
Russ Dill61fb4892002-10-14 21:41:28 +00008#include "leases.h"
Russ Dill61fb4892002-10-14 21:41:28 +00009
10/************************************/
11/* Defaults _you_ may want to tweak */
12/************************************/
13
14/* the period of time the client is allowed to use that address */
15#define LEASE_TIME (60*60*24*10) /* 10 days of seconds */
16
17/* where to find the DHCP server configuration file */
18#define DHCPD_CONF_FILE "/etc/udhcpd.conf"
19
20/*****************************************************************/
21/* Do not modify below here unless you know what you are doing!! */
22/*****************************************************************/
23
24/* DHCP protocol -- see RFC 2131 */
25#define SERVER_PORT 67
26#define CLIENT_PORT 68
27
28#define DHCP_MAGIC 0x63825363
29
30/* DHCP option codes (partial list) */
31#define DHCP_PADDING 0x00
32#define DHCP_SUBNET 0x01
33#define DHCP_TIME_OFFSET 0x02
34#define DHCP_ROUTER 0x03
35#define DHCP_TIME_SERVER 0x04
36#define DHCP_NAME_SERVER 0x05
37#define DHCP_DNS_SERVER 0x06
38#define DHCP_LOG_SERVER 0x07
39#define DHCP_COOKIE_SERVER 0x08
40#define DHCP_LPR_SERVER 0x09
41#define DHCP_HOST_NAME 0x0c
42#define DHCP_BOOT_SIZE 0x0d
43#define DHCP_DOMAIN_NAME 0x0f
44#define DHCP_SWAP_SERVER 0x10
45#define DHCP_ROOT_PATH 0x11
46#define DHCP_IP_TTL 0x17
47#define DHCP_MTU 0x1a
48#define DHCP_BROADCAST 0x1c
49#define DHCP_NTP_SERVER 0x2a
50#define DHCP_WINS_SERVER 0x2c
51#define DHCP_REQUESTED_IP 0x32
52#define DHCP_LEASE_TIME 0x33
53#define DHCP_OPTION_OVER 0x34
54#define DHCP_MESSAGE_TYPE 0x35
55#define DHCP_SERVER_ID 0x36
56#define DHCP_PARAM_REQ 0x37
57#define DHCP_MESSAGE 0x38
58#define DHCP_MAX_SIZE 0x39
59#define DHCP_T1 0x3a
60#define DHCP_T2 0x3b
61#define DHCP_VENDOR 0x3c
62#define DHCP_CLIENT_ID 0x3d
63
64#define DHCP_END 0xFF
65
66
67#define BOOTREQUEST 1
68#define BOOTREPLY 2
69
70#define ETH_10MB 1
71#define ETH_10MB_LEN 6
72
73#define DHCPDISCOVER 1
74#define DHCPOFFER 2
75#define DHCPREQUEST 3
76#define DHCPDECLINE 4
77#define DHCPACK 5
78#define DHCPNAK 6
79#define DHCPRELEASE 7
80#define DHCPINFORM 8
81
82#define BROADCAST_FLAG 0x8000
83
84#define OPTION_FIELD 0
85#define FILE_FIELD 1
86#define SNAME_FIELD 2
87
88/* miscellaneous defines */
89#define MAC_BCAST_ADDR (unsigned char *) "\xff\xff\xff\xff\xff\xff"
90#define OPT_CODE 0
91#define OPT_LEN 1
92#define OPT_DATA 2
93
94struct option_set {
95 unsigned char *data;
96 struct option_set *next;
97};
98
99struct server_config_t {
100 u_int32_t server; /* Our IP, in network order */
101 u_int32_t start; /* Start address of leases, network order */
102 u_int32_t end; /* End of leases, network order */
103 struct option_set *options; /* List of DHCP options loaded from the config file */
104 char *interface; /* The name of the interface to use */
105 int ifindex; /* Index number of the interface to use */
106 unsigned char arp[6]; /* Our arp address */
107 unsigned long lease; /* lease time in seconds (host order) */
108 unsigned long max_leases; /* maximum number of leases (including reserved address) */
109 char remaining; /* should the lease file be interpreted as lease time remaining, or
110 * as the time the lease expires */
111 unsigned long auto_time; /* how long should udhcpd wait before writing a config file.
112 * if this is zero, it will only write one on SIGUSR1 */
113 unsigned long decline_time; /* how long an address is reserved if a client returns a
114 * decline message */
115 unsigned long conflict_time; /* how long an arp conflict offender is leased for */
116 unsigned long offer_time; /* how long an offered address is reserved */
117 unsigned long min_lease; /* minimum lease a client can request*/
118 char *lease_file;
119 char *pidfile;
120 char *notify_file; /* What to run whenever leases are written */
121 u_int32_t siaddr; /* next server bootp option */
122 char *sname; /* bootp server name */
123 char *boot_file; /* bootp boot file option */
124};
125
126extern struct server_config_t server_config;
127extern struct dhcpOfferedAddr *leases;
128
129
130#endif