@@ -45,6 +45,20 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
45
45
#define DHCP6_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'S')
46
46
#define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I')
47
47
48
+ #define DHCP6_PACKET_ALL 0
49
+ #define DHCP6_PACKET_STATEFUL 1
50
+ #define DHCP6_PACKET_STATELESS 2
51
+
52
+ #define DHCP6_BASE_PACKET_SIZE 1024
53
+
54
+ #define DHCP6_PORT_CLIENT 546
55
+ #define DHCP6_PORT_SERVER 547
56
+
57
+ #define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
58
+
59
+ #define DHCP6_INSTANCE_FROM_THIS (Instance ) CR ((Instance), DHCP6_INSTANCE, Dhcp6, DHCP6_INSTANCE_SIGNATURE)
60
+ #define DHCP6_SERVICE_FROM_THIS (Service ) CR ((Service), DHCP6_SERVICE, ServiceBinding, DHCP6_SERVICE_SIGNATURE)
61
+
48
62
//
49
63
// For more information on DHCP options see RFC 8415, Section 21.1
50
64
//
@@ -59,12 +73,10 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
59
73
// | (option-len octets) |
60
74
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61
75
//
62
- #define DHCP6_SIZE_OF_OPT_CODE (sizeof(UINT16 ))
63
- #define DHCP6_SIZE_OF_OPT_LEN (sizeof(UINT16 ))
76
+ #define DHCP6_SIZE_OF_OPT_CODE (sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpCode ))
77
+ #define DHCP6_SIZE_OF_OPT_LEN (sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpLen ))
64
78
65
- //
66
79
// Combined size of Code and Length
67
- //
68
80
#define DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN (DHCP6_SIZE_OF_OPT_CODE + \
69
81
DHCP6_SIZE_OF_OPT_LEN)
70
82
@@ -73,34 +85,122 @@ STATIC_ASSERT (
73
85
"Combined size of Code and Length must be 4 per RFC 8415"
74
86
);
75
87
76
- //
77
88
// Offset to the length is just past the code
78
- //
79
- #define DHCP6_OPT_LEN_OFFSET (a ) (a + DHCP6_SIZE_OF_OPT_CODE)
89
+ #define DHCP6_OFFSET_OF_OPT_LEN (a ) (a + DHCP6_SIZE_OF_OPT_CODE)
80
90
STATIC_ASSERT (
81
- DHCP6_OPT_LEN_OFFSET (0 ) == 2 ,
91
+ DHCP6_OFFSET_OF_OPT_LEN (0 ) == 2 ,
82
92
"Offset of length is + 2 past start of option"
83
93
);
84
94
85
- #define DHCP6_OPT_DATA_OFFSET (a ) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN)
95
+ #define DHCP6_OFFSET_OF_OPT_DATA (a ) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN)
86
96
STATIC_ASSERT (
87
- DHCP6_OPT_DATA_OFFSET (0 ) == 4 ,
97
+ DHCP6_OFFSET_OF_OPT_DATA (0 ) == 4 ,
88
98
"Offset to option data should be +4 from start of option"
89
99
);
100
+ //
101
+ // Identity Association options (both NA (Non-Temporary) and TA (Temporary Association))
102
+ // are defined in RFC 8415 and are a deriviation of a TLV stucture
103
+ // For more information on IA_NA see Section 21.4
104
+ // For more information on IA_TA see Section 21.5
105
+ //
106
+ //
107
+ // The format of IA_NA and IA_TA option:
108
+ //
109
+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
110
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111
+ // | OPTION_IA_NA | option-len |
112
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
113
+ // | IAID (4 octets) |
114
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
115
+ // | T1 (only for IA_NA) |
116
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
117
+ // | T2 (only for IA_NA) |
118
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119
+ // | |
120
+ // . IA_NA-options/IA_TA-options .
121
+ // . .
122
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
123
+ //
124
+ #define DHCP6_SIZE_OF_IAID (sizeof(UINT32))
125
+ #define DHCP6_SIZE_OF_TIME_INTERVAL (sizeof(UINT32))
90
126
91
- #define DHCP6_PACKET_ALL 0
92
- #define DHCP6_PACKET_STATEFUL 1
93
- #define DHCP6_PACKET_STATELESS 2
127
+ // Combined size of IAID, T1, and T2
128
+ #define DHCP6_SIZE_OF_COMBINED_IAID_T1_T2 (DHCP6_SIZE_OF_IAID + \
129
+ DHCP6_SIZE_OF_TIME_INTERVAL + \
130
+ DHCP6_SIZE_OF_TIME_INTERVAL)
131
+ STATIC_ASSERT (
132
+ DHCP6_SIZE_OF_COMBINED_IAID_T1_T2 == 12 ,
133
+ "Combined size of IAID, T1, T2 must be 12 per RFC 8415"
134
+ );
94
135
95
- #define DHCP6_BASE_PACKET_SIZE 1024
136
+ // This is the size of IA_TA without options
137
+ #define DHCP6_MIN_SIZE_OF_IA_TA (DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + \
138
+ DHCP6_SIZE_OF_IAID)
139
+ STATIC_ASSERT (
140
+ DHCP6_MIN_SIZE_OF_IA_TA == 8 ,
141
+ "Minimum combined size of IA_TA per RFC 8415"
142
+ );
96
143
97
- #define DHCP6_PORT_CLIENT 546
98
- #define DHCP6_PORT_SERVER 547
144
+ // Offset to a IA_TA inner option
145
+ #define DHCP6_OFFSET_OF_IA_TA_INNER_OPT (a ) (a + DHCP6_MIN_SIZE_OF_IA_TA)
146
+ STATIC_ASSERT (
147
+ DHCP6_OFFSET_OF_IA_TA_INNER_OPT (0 ) == 8 ,
148
+ "Offset of IA_TA Inner option is + 8 past start of option"
149
+ );
99
150
100
- #define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
151
+ // This is the size of IA_NA without options (16)
152
+ #define DHCP6_MIN_SIZE_OF_IA_NA DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + \
153
+ DHCP6_SIZE_OF_COMBINED_IAID_T1_T2
154
+ STATIC_ASSERT (
155
+ DHCP6_MIN_SIZE_OF_IA_NA == 16 ,
156
+ "Minimum combined size of IA_TA per RFC 8415"
157
+ );
101
158
102
- #define DHCP6_INSTANCE_FROM_THIS (Instance ) CR ((Instance), DHCP6_INSTANCE, Dhcp6, DHCP6_INSTANCE_SIGNATURE)
103
- #define DHCP6_SERVICE_FROM_THIS (Service ) CR ((Service), DHCP6_SERVICE, ServiceBinding, DHCP6_SERVICE_SIGNATURE)
159
+ #define DHCP6_OFFSET_OF_IA_NA_INNER_OPT (a ) (a + DHCP6_MIN_SIZE_OF_IA_NA)
160
+ STATIC_ASSERT (
161
+ DHCP6_OFFSET_OF_IA_NA_INNER_OPT (0 ) == 16 ,
162
+ "Offset of IA_NA Inner option is + 16 past start of option"
163
+ );
164
+
165
+ #define DHCP6_OFFSET_OF_IA_NA_T1 (a ) (a + \
166
+ DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + \
167
+ DHCP6_SIZE_OF_IAID)
168
+ STATIC_ASSERT (
169
+ DHCP6_OFFSET_OF_IA_NA_T1 (0 ) == 8 ,
170
+ "Offset of IA_NA Inner option is + 8 past start of option"
171
+ );
172
+
173
+ #define DHCP6_OFFSET_OF_IA_NA_T2 (a ) (a + \
174
+ DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN +\
175
+ DHCP6_SIZE_OF_IAID + \
176
+ DHCP6_SIZE_OF_TIME_INTERVAL)
177
+ STATIC_ASSERT (
178
+ DHCP6_OFFSET_OF_IA_NA_T2 (0 ) == 12 ,
179
+ "Offset of IA_NA Inner option is + 12 past start of option"
180
+ );
181
+
182
+ //
183
+ // For more information see RFC 8415 Section 21.13
184
+ //
185
+ // The format of the Status Code Option:
186
+ //
187
+ // 0 1 2 3
188
+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
189
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190
+ // | OPTION_STATUS_CODE | option-len |
191
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
192
+ // | status-code | |
193
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
194
+ // . .
195
+ // . status-message .
196
+ // . .
197
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198
+ //
199
+ #define DHCP6_OFFSET_OF_STATUS_CODE (a ) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN)
200
+ STATIC_ASSERT (
201
+ DHCP6_OFFSET_OF_STATUS_CODE (0 ) == 4 ,
202
+ "Offset of status is + 4 past start of option"
203
+ );
104
204
105
205
extern EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress ;
106
206
extern EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate ;
0 commit comments