1 /*
2  * Copyright 2017, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 // Ports
19 #define PORT_BOOTP_SERVER 67
20 #define PORT_BOOTP_CLIENT 68
21 
22 // Operations
23 #define OP_BOOTREQUEST 1
24 #define OP_BOOTREPLY   2
25 
26 // Flags
27 #define FLAGS_BROADCAST 0x8000
28 
29 // Hardware address types
30 #define HTYPE_ETHER    1
31 
32 // The first four bytes of options are a cookie to indicate that the payload are
33 // DHCP options as opposed to some other BOOTP extension.
34 #define OPT_COOKIE1          0x63
35 #define OPT_COOKIE2          0x82
36 #define OPT_COOKIE3          0x53
37 #define OPT_COOKIE4          0x63
38 
39 // BOOTP/DHCP options - see RFC 2132
40 #define OPT_PAD              0
41 
42 #define OPT_SUBNET_MASK      1     // 4 <ipaddr>
43 #define OPT_TIME_OFFSET      2     // 4 <seconds>
44 #define OPT_GATEWAY          3     // 4*n <ipaddr> * n
45 #define OPT_DNS              6     // 4*n <ipaddr> * n
46 #define OPT_DOMAIN_NAME      15    // n <domainnamestring>
47 #define OPT_MTU              26    // 2 <mtu>
48 #define OPT_BROADCAST_ADDR   28    // 4 <ipaddr>
49 
50 #define OPT_REQUESTED_IP     50    // 4 <ipaddr>
51 #define OPT_LEASE_TIME       51    // 4 <seconds>
52 #define OPT_MESSAGE_TYPE     53    // 1 <msgtype>
53 #define OPT_SERVER_ID        54    // 4 <ipaddr>
54 #define OPT_PARAMETER_LIST   55    // n <optcode> * n
55 #define OPT_MESSAGE          56    // n <errorstring>
56 #define OPT_T1               58    // 4 <renewal time value>
57 #define OPT_T2               59    // 4 <rebinding time value>
58 #define OPT_CLASS_ID         60    // n <opaque>
59 #define OPT_CLIENT_ID        61    // n <opaque>
60 #define OPT_END              255
61 
62 // DHCP message types
63 #define DHCPDISCOVER         1
64 #define DHCPOFFER            2
65 #define DHCPREQUEST          3
66 #define DHCPDECLINE          4
67 #define DHCPACK              5
68 #define DHCPNAK              6
69 #define DHCPRELEASE          7
70 #define DHCPINFORM           8
71 
72 
73