2 * Copyright (C) 2012 Steven Barth <steven@midlink.org>
3 * Copyright (C) 2016 Hans Dedecker <dedeckeh@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License version 2 for more details.
17 #define DHCPV4_CLIENT_PORT 68
18 #define DHCPV4_SERVER_PORT 67
20 #define DHCPV4_FLAG_BROADCAST 0x8000
23 DHCPV4_BOOTREQUEST
= 1,
28 DHCPV4_MSG_DISCOVER
= 1,
30 DHCPV4_MSG_REQUEST
= 3,
31 DHCPV4_MSG_DECLINE
= 4,
34 DHCPV4_MSG_RELEASE
= 7,
35 DHCPV4_MSG_INFORM
= 8,
36 DHCPV4_MSG_FORCERENEW
= 9,
40 DHCPV4_OPT_NETMASK
= 1,
41 DHCPV4_OPT_ROUTER
= 3,
42 DHCPV4_OPT_DNSSERVER
= 6,
43 DHCPV4_OPT_DOMAIN
= 15,
45 DHCPV4_OPT_BROADCAST
= 28,
46 DHCPV4_OPT_NTPSERVER
= 42,
47 DHCPV4_OPT_LEASETIME
= 51,
48 DHCPV4_OPT_MESSAGE
= 53,
49 DHCPV4_OPT_SERVERID
= 54,
50 DHCPV4_OPT_RENEW
= 58,
51 DHCPV4_OPT_REBIND
= 59,
52 DHCPV4_OPT_IPADDRESS
= 50,
53 DHCPV4_OPT_HOSTNAME
= 12,
54 DHCPV4_OPT_REQUEST
= 17,
55 DHCPV4_OPT_USER_CLASS
= 77,
56 DHCPV4_OPT_AUTHENTICATION
= 90,
57 DHCPV4_OPT_SEARCH_DOMAIN
= 119,
58 DHCPV4_OPT_FORCERENEW_NONCE_CAPABLE
= 145,
62 struct dhcpv4_message
{
70 struct in_addr ciaddr
;
71 struct in_addr yiaddr
;
72 struct in_addr siaddr
;
73 struct in_addr giaddr
;
80 struct dhcpv4_auth_forcerenew
{
91 struct dhcpv4_assignment
{
92 struct list_head head
;
93 struct interface
*iface
;
95 struct uloop_timeout fr_timer
;
96 struct odhcpd_ref_ip
*fr_ip
;
110 struct dhcpv4_option
{
117 #define dhcpv4_for_each_option(start, end, opt)\
118 for (opt = (struct dhcpv4_option*)(start); \
119 &opt[1] <= (struct dhcpv4_option*)(end) && \
120 &opt->data[opt->len] <= (end); \
121 opt = (struct dhcpv4_option*)&opt->data[opt->len])