blob: 9fbeb02fb2b51c2550f81e46ecfaac21926b4492 [file] [log] [blame]
Neale Ranns2dd68522017-02-16 03:38:59 -08001#ifndef included_vnet_dhcp4_packet_h
2#define included_vnet_dhcp4_packet_h
Ed Warnickecb9cada2015-12-08 15:45:58 -07003
4/*
5 * DHCP packet format
6 *
7 * Copyright (c) 2013 Cisco and/or its affiliates.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at:
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20#include <vnet/ip/ip4_packet.h>
21
khemendra kumar34719e32017-12-08 18:06:52 +053022typedef struct
23{
24 u8 opcode; /* 1 = request, 2 = reply */
25 u8 hardware_type; /* 1 = ethernet */
Ed Warnickecb9cada2015-12-08 15:45:58 -070026 u8 hardware_address_length;
27 u8 hops;
28 u32 transaction_identifier;
29 u16 seconds;
30 u16 flags;
31#define DHCP_FLAG_BROADCAST (1<<15)
32 ip4_address_t client_ip_address;
khemendra kumar34719e32017-12-08 18:06:52 +053033 ip4_address_t your_ip_address; /* use this one */
Ed Warnickecb9cada2015-12-08 15:45:58 -070034 ip4_address_t server_ip_address;
khemendra kumar34719e32017-12-08 18:06:52 +053035 ip4_address_t gateway_ip_address; /* use option 3, not this one */
Ed Warnickecb9cada2015-12-08 15:45:58 -070036 u8 client_hardware_address[16];
37 u8 server_name[64];
38 u8 boot_filename[128];
39 ip4_address_t magic_cookie;
40 u8 options[0];
41} dhcp_header_t;
42
khemendra kumar34719e32017-12-08 18:06:52 +053043typedef struct
44{
Ed Warnickecb9cada2015-12-08 15:45:58 -070045 u8 option;
46 u8 length;
khemendra kumar34719e32017-12-08 18:06:52 +053047 union
48 {
Ed Warnickecb9cada2015-12-08 15:45:58 -070049 u8 data[0];
50 u32 data_as_u32[0];
51 };
khemendra kumar34719e32017-12-08 18:06:52 +053052} __attribute__ ((packed)) dhcp_option_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070053
khemendra kumar34719e32017-12-08 18:06:52 +053054typedef enum
55{
56 DHCP_PACKET_DISCOVER = 1,
Ed Warnickecb9cada2015-12-08 15:45:58 -070057 DHCP_PACKET_OFFER,
58 DHCP_PACKET_REQUEST,
khemendra kumar34719e32017-12-08 18:06:52 +053059 DHCP_PACKET_ACK = 5,
Dave Barach43ebe292018-03-21 13:45:12 -040060 DHCP_PACKET_NAK,
Ed Warnickecb9cada2015-12-08 15:45:58 -070061} dhcp_packet_type_t;
62
Neale Ranns3466c302017-02-16 07:45:03 -080063typedef enum dhcp_packet_option_t_
64{
khemendra kumar34719e32017-12-08 18:06:52 +053065 DHCP_PACKET_OPTION_MSG_TYPE = 53,
Neale Ranns3466c302017-02-16 07:45:03 -080066} dhcp_packet_option_t;
67
Ed Warnickecb9cada2015-12-08 15:45:58 -070068/* charming antique: 99.130.83.99 is the dhcp magic cookie */
69#define DHCP_MAGIC (clib_host_to_net_u32(0x63825363))
70
Neale Ranns2dd68522017-02-16 03:38:59 -080071#endif /* included_vnet_dhcp4_packet_h */
khemendra kumar34719e32017-12-08 18:06:52 +053072
73/*
74 * fd.io coding-style-patch-verification: ON
75 *
76 * Local Variables:
77 * eval: (c-set-style "gnu")
78 * End:
79 */