2017-02-16 03:38:59 -08:00
|
|
|
#ifndef included_vnet_dhcp4_packet_h
|
|
|
|
|
#define included_vnet_dhcp4_packet_h
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* DHCP packet format
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2013 Cisco and/or its affiliates.
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
#include <vnet/ip/ip4_packet.h>
|
|
|
|
|
|
2018-11-05 13:29:25 +02:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
u8 option;
|
|
|
|
|
u8 length;
|
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
u8 data[0];
|
|
|
|
|
u32 data_as_u32[0];
|
|
|
|
|
};
|
|
|
|
|
} __attribute__ ((packed)) dhcp_option_t;
|
|
|
|
|
|
2017-12-08 18:06:52 +05:30
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
u8 opcode; /* 1 = request, 2 = reply */
|
|
|
|
|
u8 hardware_type; /* 1 = ethernet */
|
2015-12-08 15:45:58 -07:00
|
|
|
u8 hardware_address_length;
|
|
|
|
|
u8 hops;
|
|
|
|
|
u32 transaction_identifier;
|
|
|
|
|
u16 seconds;
|
|
|
|
|
u16 flags;
|
|
|
|
|
#define DHCP_FLAG_BROADCAST (1<<15)
|
|
|
|
|
ip4_address_t client_ip_address;
|
2017-12-08 18:06:52 +05:30
|
|
|
ip4_address_t your_ip_address; /* use this one */
|
2015-12-08 15:45:58 -07:00
|
|
|
ip4_address_t server_ip_address;
|
2017-12-08 18:06:52 +05:30
|
|
|
ip4_address_t gateway_ip_address; /* use option 3, not this one */
|
2015-12-08 15:45:58 -07:00
|
|
|
u8 client_hardware_address[16];
|
|
|
|
|
u8 server_name[64];
|
|
|
|
|
u8 boot_filename[128];
|
|
|
|
|
ip4_address_t magic_cookie;
|
2018-11-05 13:29:25 +02:00
|
|
|
dhcp_option_t options[0];
|
2015-12-08 15:45:58 -07:00
|
|
|
} dhcp_header_t;
|
|
|
|
|
|
2019-10-15 15:47:55 +00:00
|
|
|
extern u8 *format_dhcp_header (u8 * s, va_list * args);
|
|
|
|
|
|
2017-12-08 18:06:52 +05:30
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
DHCP_PACKET_DISCOVER = 1,
|
2015-12-08 15:45:58 -07:00
|
|
|
DHCP_PACKET_OFFER,
|
|
|
|
|
DHCP_PACKET_REQUEST,
|
2017-12-08 18:06:52 +05:30
|
|
|
DHCP_PACKET_ACK = 5,
|
2018-03-21 13:45:12 -04:00
|
|
|
DHCP_PACKET_NAK,
|
2015-12-08 15:45:58 -07:00
|
|
|
} dhcp_packet_type_t;
|
|
|
|
|
|
2019-10-15 15:47:55 +00:00
|
|
|
extern u8 *format_dhcp_packet_type (u8 * s, va_list * args);
|
|
|
|
|
|
2017-02-16 07:45:03 -08:00
|
|
|
typedef enum dhcp_packet_option_t_
|
|
|
|
|
{
|
2017-12-08 18:06:52 +05:30
|
|
|
DHCP_PACKET_OPTION_MSG_TYPE = 53,
|
2018-11-05 13:29:25 +02:00
|
|
|
DHCP_PACKET_OPTION_END = 0xff,
|
2017-02-16 07:45:03 -08:00
|
|
|
} dhcp_packet_option_t;
|
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* charming antique: 99.130.83.99 is the dhcp magic cookie */
|
|
|
|
|
#define DHCP_MAGIC (clib_host_to_net_u32(0x63825363))
|
|
|
|
|
|
2017-02-16 03:38:59 -08:00
|
|
|
#endif /* included_vnet_dhcp4_packet_h */
|
2017-12-08 18:06:52 +05:30
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* fd.io coding-style-patch-verification: ON
|
|
|
|
|
*
|
|
|
|
|
* Local Variables:
|
|
|
|
|
* eval: (c-set-style "gnu")
|
|
|
|
|
* End:
|
|
|
|
|
*/
|