|
@@ -130,43 +130,57 @@ static void ibft_set_ipaddr ( struct ibft_ipaddr *ipaddr, struct in_addr in ) {
|
130
|
130
|
*/
|
131
|
131
|
static void ibft_set_ipaddr_option ( struct ibft_ipaddr *ipaddr,
|
132
|
132
|
unsigned int tag ) {
|
133
|
|
- struct in_addr in;
|
134
|
|
- find_global_dhcp_ipv4_option ( tag, &in );
|
|
133
|
+ struct in_addr in = { 0 };
|
|
134
|
+ fetch_ipv4_setting ( NULL, tag, &in );
|
135
|
135
|
ibft_set_ipaddr ( ipaddr, in );
|
136
|
136
|
}
|
137
|
137
|
|
138
|
138
|
|
139
|
|
- * Fill in a string field within iBFT
|
|
139
|
+ * Allocate a string within iBFT
|
140
|
140
|
*
|
141
|
141
|
* @v strings iBFT string block descriptor
|
142
|
|
- * @v string String field
|
143
|
|
- * @v data String to fill in
|
144
|
|
- * @v len Length of string to fill in
|
|
142
|
+ * @v string String field to fill in
|
|
143
|
+ * @v len Length of string to allocate (excluding NUL)
|
145
|
144
|
* @ret rc Return status code
|
146
|
145
|
*/
|
147
|
|
-static int ibft_set_string ( struct ibft_string_block *strings,
|
148
|
|
- struct ibft_string *string,
|
149
|
|
- const void *data, size_t len ) {
|
|
146
|
+static int ibft_alloc_string ( struct ibft_string_block *strings,
|
|
147
|
+ struct ibft_string *string, size_t len ) {
|
150
|
148
|
char *dest;
|
151
|
|
- char *end;
|
152
|
149
|
unsigned int remaining;
|
153
|
150
|
|
154
|
151
|
dest = ( ( ( char * ) strings->table ) + strings->offset );
|
155
|
|
- end = ( ( ( char * ) strings->table ) + strings->table->acpi.length );
|
156
|
|
- remaining = ( end - dest );
|
157
|
|
-
|
|
152
|
+ remaining = ( strings->table->acpi.length - strings->offset );
|
158
|
153
|
if ( len >= remaining )
|
159
|
154
|
return -ENOMEM;
|
160
|
155
|
|
161
|
|
- memcpy ( dest, data, len );
|
162
|
|
- dest[len] = '\0';
|
163
|
|
-
|
164
|
156
|
string->offset = strings->offset;
|
165
|
157
|
string->length = len;
|
166
|
158
|
strings->offset += ( len + 1 );
|
167
|
159
|
return 0;
|
168
|
160
|
}
|
169
|
161
|
|
|
162
|
+
|
|
163
|
+ * Fill in a string field within iBFT
|
|
164
|
+ *
|
|
165
|
+ * @v strings iBFT string block descriptor
|
|
166
|
+ * @v string String field
|
|
167
|
+ * @v data String to fill in
|
|
168
|
+ * @ret rc Return status code
|
|
169
|
+ */
|
|
170
|
+static int ibft_set_string ( struct ibft_string_block *strings,
|
|
171
|
+ struct ibft_string *string, const char *data ) {
|
|
172
|
+ size_t len = strlen ( data );
|
|
173
|
+ char *dest;
|
|
174
|
+ int rc;
|
|
175
|
+
|
|
176
|
+ if ( ( rc = ibft_alloc_string ( strings, string, len ) ) != 0 )
|
|
177
|
+ return rc;
|
|
178
|
+ dest = ( ( ( char * ) strings->table ) + string->offset );
|
|
179
|
+ strcpy ( dest, data );
|
|
180
|
+
|
|
181
|
+ return 0;
|
|
182
|
+}
|
|
183
|
+
|
170
|
184
|
|
171
|
185
|
* Fill in a string field within iBFT from DHCP option
|
172
|
186
|
*
|
|
@@ -178,17 +192,22 @@ static int ibft_set_string ( struct ibft_string_block *strings,
|
178
|
192
|
static int ibft_set_string_option ( struct ibft_string_block *strings,
|
179
|
193
|
struct ibft_string *string,
|
180
|
194
|
unsigned int tag ) {
|
181
|
|
- struct dhcp_option *option;
|
|
195
|
+ int len;
|
|
196
|
+ char *dest;
|
|
197
|
+ int rc;
|
182
|
198
|
|
183
|
|
- option = find_global_dhcp_option ( tag );
|
184
|
|
- if ( ! option ) {
|
|
199
|
+ len = fetch_setting_len ( NULL, tag );
|
|
200
|
+ if ( len < 0 ) {
|
185
|
201
|
string->offset = 0;
|
186
|
202
|
string->length = 0;
|
187
|
203
|
return 0;
|
188
|
204
|
}
|
189
|
205
|
|
190
|
|
- return ibft_set_string ( strings, string, option->data.string,
|
191
|
|
- option->len );
|
|
206
|
+ if ( ( rc = ibft_alloc_string ( strings, string, len ) ) != 0 )
|
|
207
|
+ return rc;
|
|
208
|
+ dest = ( ( ( char * ) strings->table ) + string->offset );
|
|
209
|
+ fetch_string_setting ( NULL, tag, dest, ( len + 1 ) );
|
|
210
|
+ return 0;
|
192
|
211
|
}
|
193
|
212
|
|
194
|
213
|
|
|
@@ -202,7 +221,7 @@ static int ibft_set_string_option ( struct ibft_string_block *strings,
|
202
|
221
|
static int ibft_fill_nic ( struct ibft_nic *nic,
|
203
|
222
|
struct ibft_string_block *strings,
|
204
|
223
|
struct net_device *netdev ) {
|
205
|
|
- struct in_addr netmask_addr;
|
|
224
|
+ struct in_addr netmask_addr = { 0 };
|
206
|
225
|
unsigned int netmask_count = 0;
|
207
|
226
|
int rc;
|
208
|
227
|
|
|
@@ -215,7 +234,7 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
|
215
|
234
|
return rc;
|
216
|
235
|
|
217
|
236
|
|
218
|
|
- find_global_dhcp_ipv4_option ( DHCP_SUBNET_MASK, &netmask_addr );
|
|
237
|
+ fetch_ipv4_setting ( NULL, DHCP_SUBNET_MASK, &netmask_addr );
|
219
|
238
|
while ( netmask_addr.s_addr ) {
|
220
|
239
|
if ( netmask_addr.s_addr & 0x1 )
|
221
|
240
|
netmask_count++;
|
|
@@ -244,8 +263,7 @@ static int ibft_fill_initiator ( struct ibft_initiator *initiator,
|
244
|
263
|
int rc;
|
245
|
264
|
|
246
|
265
|
if ( ( rc = ibft_set_string ( strings, &initiator->initiator_name,
|
247
|
|
- initiator_iqn,
|
248
|
|
- strlen ( initiator_iqn ) ) ) != 0)
|
|
266
|
+ initiator_iqn ) ) != 0 )
|
249
|
267
|
return rc;
|
250
|
268
|
|
251
|
269
|
return 0;
|
|
@@ -270,19 +288,16 @@ static int ibft_fill_target ( struct ibft_target *target,
|
270
|
288
|
ibft_set_ipaddr ( &target->ip_address, sin_target->sin_addr );
|
271
|
289
|
target->socket = ntohs ( sin_target->sin_port );
|
272
|
290
|
if ( ( rc = ibft_set_string ( strings, &target->target_name,
|
273
|
|
- iscsi->target_iqn,
|
274
|
|
- strlen ( iscsi->target_iqn ) ) ) != 0 )
|
|
291
|
+ iscsi->target_iqn ) ) != 0 )
|
275
|
292
|
return rc;
|
276
|
293
|
if ( iscsi->username ) {
|
277
|
294
|
if ( ( rc = ibft_set_string ( strings, &target->chap_name,
|
278
|
|
- iscsi->username,
|
279
|
|
- strlen ( iscsi->username ) ))!=0)
|
|
295
|
+ iscsi->username ) ) != 0 )
|
280
|
296
|
return rc;
|
281
|
297
|
}
|
282
|
298
|
if ( iscsi->password ) {
|
283
|
299
|
if ( ( rc = ibft_set_string ( strings, &target->chap_secret,
|
284
|
|
- iscsi->password,
|
285
|
|
- strlen ( iscsi->password ) ))!=0)
|
|
300
|
+ iscsi->password ) ) != 0 )
|
286
|
301
|
return rc;
|
287
|
302
|
target->chap_type = IBFT_CHAP_ONE_WAY;
|
288
|
303
|
}
|