1
2#ifndef _S_DHCPD_H
3#define _S_DHCPD_H
4
5/*
6 * Copyright (c) 2000 Apple Inc. All rights reserved.
7 *
8 * @APPLE_LICENSE_HEADER_START@
9 *
10 * This file contains Original Code and/or Modifications of Original Code
11 * as defined in and that are subject to the Apple Public Source License
12 * Version 2.0 (the 'License'). You may not use this file except in
13 * compliance with the License. Please obtain a copy of the License at
14 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * file.
16 *
17 * The Original Code and all software distributed under the License are
18 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
20 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
22 * Please see the License for the specific language governing rights and
23 * limitations under the License.
24 *
25 * @APPLE_LICENSE_HEADER_END@
26 */
27/*
28 * dhcpd.h
29 * - DHCP server definitions
30 */
31
32#include "dhcplib.h"
33#include "bootpd.h"
34
35void
36dhcp_init();
37
38void
39dhcp_request(request_t * request, dhcp_msgtype_t msgtype,
40	     boolean_t dhcp_allocate);
41
42boolean_t
43dhcp_bootp_allocate(char * idstr, char * hwstr, struct dhcp * rq,
44		    interface_t * if_p, struct timeval * time_in_p,
45		    struct in_addr * iaddr_p, SubnetRef * subnet_p);
46
47#define DHCP_CLIENT_TYPE		"dhcp"
48
49/* default time to leave an ip address pending before re-using it */
50#define DHCP_PENDING_SECS		60
51
52#define DHCP_DECLINE_WAIT_SECS (60 * 10)		/* 10 minutes */
53
54#define TIME_DRIFT_PERCENT		0.99
55
56static __inline__ u_long
57lease_prorate(u_long lease_time)
58{
59    double d = lease_time * TIME_DRIFT_PERCENT;
60
61    return ((u_long)d);
62}
63
64struct dhcp *
65make_dhcp_reply(struct dhcp * reply, int pkt_size,
66		struct in_addr server_id, dhcp_msgtype_t msg,
67		struct dhcp * request, dhcpoa_t * options);
68int
69dhcp_max_message_size(dhcpol_t * client_options);
70
71#endif /* _S_DHCPD_H */
72