2 * Copyright (C) 2012 Steven Barth <steven@midlink.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License version 2 for more details.
16 #define DHCPV4_CLIENT_PORT 68
17 #define DHCPV4_SERVER_PORT 67
19 #define DHCPV4_FLAG_BROADCAST 0x8000
22 DHCPV4_BOOTREQUEST = 1,
27 DHCPV4_MSG_DISCOVER = 1,
29 DHCPV4_MSG_REQUEST = 3,
30 DHCPV4_MSG_DECLINE = 4,
33 DHCPV4_MSG_RELEASE = 7,
34 DHCPV4_MSG_INFORM = 8,
38 DHCPV4_OPT_NETMASK = 1,
39 DHCPV4_OPT_ROUTER = 3,
40 DHCPV4_OPT_DNSSERVER = 6,
41 DHCPV4_OPT_DOMAIN = 15,
43 DHCPV4_OPT_BROADCAST = 28,
44 DHCPV4_OPT_NTPSERVER = 42,
45 DHCPV4_OPT_LEASETIME = 51,
46 DHCPV4_OPT_MESSAGE = 53,
47 DHCPV4_OPT_SERVERID = 54,
48 DHCPV4_OPT_RENEW = 58,
49 DHCPV4_OPT_REBIND = 59,
50 DHCPV4_OPT_IPADDRESS = 50,
51 DHCPV4_OPT_HOSTNAME = 10,
52 DHCPV4_OPT_REQUEST = 17,
56 struct dhcpv4_message {
64 struct in_addr ciaddr;
65 struct in_addr yiaddr;
66 struct in_addr siaddr;
67 struct in_addr giaddr;
74 struct dhcpv4_assignment {
75 struct list_head head;
82 struct dhcpv4_option {
89 #define dhcpv4_for_each_option(start, end, opt)\
90 for (opt = (struct dhcpv4_option*)(start); \
91 &opt[1] <= (struct dhcpv4_option*)(end) && \
92 &opt->data[opt->len] <= (end); \
93 opt = (struct dhcpv4_option*)&opt->data[opt->len])