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