1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright (C) 2013 Intel Corporation. All rights reserved.
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include <netinet/udp.h>
25 #include <netinet/ip.h>
29 #include "sparse-endian.h"
49 typedef struct DHCPMessage DHCPMessage;
57 typedef struct DHCPPacket DHCPPacket;
59 #define DHCP_IP_SIZE (int32_t)(sizeof(struct iphdr))
60 #define DHCP_IP_UDP_SIZE (int32_t)(sizeof(struct udphdr) + DHCP_IP_SIZE)
61 #define DHCP_MESSAGE_SIZE (int32_t)(sizeof(DHCPMessage))
62 #define DHCP_MIN_OPTIONS_SIZE 308
63 #define DHCP_MAGIC_COOKIE (uint32_t)(0x63825363)
66 DHCP_PORT_SERVER = 67,
67 DHCP_PORT_CLIENT = 68,
72 DHCP_STATE_SELECTING = 1,
73 DHCP_STATE_INIT_REBOOT = 2,
74 DHCP_STATE_REBOOTING = 3,
75 DHCP_STATE_REQUESTING = 4,
77 DHCP_STATE_RENEWING = 6,
78 DHCP_STATE_REBINDING = 7,
79 DHCP_STATE_STOPPED = 8,
82 typedef enum DHCPState DHCPState;
100 DHCP_OVERLOAD_FILE = 1,
101 DHCP_OVERLOAD_SNAME = 2,
106 DHCP_OPTION_SUBNET_MASK = 1,
107 DHCP_OPTION_ROUTER = 3,
108 DHCP_OPTION_DOMAIN_NAME_SERVER = 6,
109 DHCP_OPTION_HOST_NAME = 12,
110 DHCP_OPTION_DOMAIN_NAME = 15,
111 DHCP_OPTION_ROOT_PATH = 17,
112 DHCP_OPTION_INTERFACE_MTU = 26,
113 DHCP_OPTION_NTP_SERVER = 42,
114 DHCP_OPTION_REQUESTED_IP_ADDRESS = 50,
115 DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51,
116 DHCP_OPTION_OVERLOAD = 52,
117 DHCP_OPTION_MESSAGE_TYPE = 53,
118 DHCP_OPTION_SERVER_IDENTIFIER = 54,
119 DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
120 DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
121 DHCP_OPTION_RENEWAL_T1_TIME = 58,
122 DHCP_OPTION_REBINDING_T2_TIME = 59,
123 DHCP_OPTION_CLIENT_IDENTIFIER = 61,
124 DHCP_OPTION_END = 255,