Neale Ranns | 2dd6852 | 2017-02-16 03:38:59 -0800 | [diff] [blame] | 1 | #ifndef included_vnet_dhcp4_packet_h |
| 2 | #define included_vnet_dhcp4_packet_h |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 3 | |
| 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 kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 22 | typedef struct |
| 23 | { |
Eyal Bari | d3d4241 | 2018-11-05 13:29:25 +0200 | [diff] [blame] | 24 | u8 option; |
| 25 | u8 length; |
| 26 | union |
| 27 | { |
| 28 | u8 data[0]; |
| 29 | u32 data_as_u32[0]; |
| 30 | }; |
| 31 | } __attribute__ ((packed)) dhcp_option_t; |
| 32 | |
| 33 | typedef struct |
| 34 | { |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 35 | u8 opcode; /* 1 = request, 2 = reply */ |
| 36 | u8 hardware_type; /* 1 = ethernet */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 37 | u8 hardware_address_length; |
| 38 | u8 hops; |
| 39 | u32 transaction_identifier; |
| 40 | u16 seconds; |
| 41 | u16 flags; |
| 42 | #define DHCP_FLAG_BROADCAST (1<<15) |
| 43 | ip4_address_t client_ip_address; |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 44 | ip4_address_t your_ip_address; /* use this one */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | ip4_address_t server_ip_address; |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 46 | ip4_address_t gateway_ip_address; /* use option 3, not this one */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 47 | u8 client_hardware_address[16]; |
| 48 | u8 server_name[64]; |
| 49 | u8 boot_filename[128]; |
| 50 | ip4_address_t magic_cookie; |
Eyal Bari | d3d4241 | 2018-11-05 13:29:25 +0200 | [diff] [blame] | 51 | dhcp_option_t options[0]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 52 | } dhcp_header_t; |
| 53 | |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 54 | typedef enum |
| 55 | { |
| 56 | DHCP_PACKET_DISCOVER = 1, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 57 | DHCP_PACKET_OFFER, |
| 58 | DHCP_PACKET_REQUEST, |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 59 | DHCP_PACKET_ACK = 5, |
Dave Barach | 43ebe29 | 2018-03-21 13:45:12 -0400 | [diff] [blame] | 60 | DHCP_PACKET_NAK, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 61 | } dhcp_packet_type_t; |
| 62 | |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 63 | typedef enum dhcp_packet_option_t_ |
| 64 | { |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 65 | DHCP_PACKET_OPTION_MSG_TYPE = 53, |
Eyal Bari | d3d4241 | 2018-11-05 13:29:25 +0200 | [diff] [blame] | 66 | DHCP_PACKET_OPTION_END = 0xff, |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 67 | } dhcp_packet_option_t; |
| 68 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 69 | /* charming antique: 99.130.83.99 is the dhcp magic cookie */ |
| 70 | #define DHCP_MAGIC (clib_host_to_net_u32(0x63825363)) |
| 71 | |
Neale Ranns | 2dd6852 | 2017-02-16 03:38:59 -0800 | [diff] [blame] | 72 | #endif /* included_vnet_dhcp4_packet_h */ |
khemendra kumar | 34719e3 | 2017-12-08 18:06:52 +0530 | [diff] [blame] | 73 | |
| 74 | /* |
| 75 | * fd.io coding-style-patch-verification: ON |
| 76 | * |
| 77 | * Local Variables: |
| 78 | * eval: (c-set-style "gnu") |
| 79 | * End: |
| 80 | */ |