forked from pool/open-iscsi
111 lines
2.8 KiB
Plaintext
111 lines
2.8 KiB
Plaintext
commit 18cbe8c5f68e5e545d02f773da03f52deadfd45b
|
|
Author: Hannes Reinecke <hare@suse.de>
|
|
Date: Wed Mar 12 10:36:30 2008 +0100
|
|
|
|
Fill in initiator values for iBFT context
|
|
|
|
The iBFT context already contains the fields for the initiator,
|
|
so we can as well fill them with something sensible.
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
|
|
diff --git a/include/fw_context.h b/include/fw_context.h
|
|
index 47ac6ae..f6999e3 100644
|
|
--- a/include/fw_context.h
|
|
+++ b/include/fw_context.h
|
|
@@ -33,8 +33,9 @@ struct boot_context {
|
|
char chap_password_in[16];
|
|
char iface[42];
|
|
char mac[18];
|
|
- char ipaddr[18];
|
|
- char mask[18];
|
|
+ char ipaddr[32];
|
|
+ char mask[19];
|
|
+ char gwaddr[32];
|
|
char lun[17];
|
|
char vlan[15];
|
|
char isid[10];
|
|
diff --git a/utils/fwparam_ibft/fwparam_ibft.c b/utils/fwparam_ibft/fwparam_ibft.c
|
|
index 4397f94..3801028 100644
|
|
--- a/utils/fwparam_ibft/fwparam_ibft.c
|
|
+++ b/utils/fwparam_ibft/fwparam_ibft.c
|
|
@@ -150,6 +150,32 @@ format_ipaddr(char *buf, size_t size, uint8_t *ip)
|
|
|
|
}
|
|
|
|
+void
|
|
+format_netmask(char *buf, size_t size, uint8_t mask)
|
|
+{
|
|
+ uint32_t tmp;
|
|
+
|
|
+ tmp = 0xffffffff << (32 - mask);
|
|
+ sprintf(buf,"%d.%d.%d.%d",
|
|
+ (tmp >> 24) & 0xff,
|
|
+ (tmp >> 16) & 0xff,
|
|
+ (tmp >> 8) & 0xff,
|
|
+ tmp & 0xff);
|
|
+}
|
|
+
|
|
+void
|
|
+format_mac(char *buf, size_t size, uint8_t *mac)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < 5; i++) {
|
|
+ sprintf(buf, "%02x:", mac[i]);
|
|
+ buf += 3;
|
|
+ }
|
|
+ sprintf(buf, "%02x", mac[i]);
|
|
+}
|
|
+
|
|
+
|
|
/*
|
|
* Dump the 16 byte ipaddr, as IPV6 or IPV4.
|
|
*/
|
|
@@ -385,6 +411,45 @@ dump_ibft(void *ibft_loc, struct boot_context *context)
|
|
(char *)ibft_loc+initiator->initiator_name_off,
|
|
initiator->initiator_name_len + 1);
|
|
|
|
+ if (nic0 && (nic0->hdr.flags & INIT_FLAG_FW_SEL_BOOT)) {
|
|
+ format_ipaddr(buf, sizeof(buf),
|
|
+ nic0->ip_addr);
|
|
+ strcpy((char *)context->ipaddr, buf);
|
|
+
|
|
+ format_ipaddr(buf, sizeof(buf),
|
|
+ nic0->gateway);
|
|
+ strcpy((char *)context->gwaddr, buf);
|
|
+
|
|
+ format_mac(buf, sizeof(buf),
|
|
+ nic0->mac);
|
|
+ strcpy((char *)context->mac, buf);
|
|
+
|
|
+ format_netmask(buf, sizeof(buf),
|
|
+ nic0->subnet_mask_prefix);
|
|
+ strcpy((char *)context->mask, buf);
|
|
+ }
|
|
+
|
|
+ if (nic1 && (nic1->hdr.flags & INIT_FLAG_FW_SEL_BOOT)) {
|
|
+ format_ipaddr(buf, sizeof(buf),
|
|
+ nic1->ip_addr);
|
|
+ strncpy((char *)context->ipaddr, buf,
|
|
+ sizeof(buf));
|
|
+ format_ipaddr(buf, sizeof(buf),
|
|
+ nic1->gateway);
|
|
+ strncpy((char *)context->gwaddr, buf,
|
|
+ sizeof(buf));
|
|
+
|
|
+ format_mac(buf, sizeof(buf),
|
|
+ nic1->mac);
|
|
+ strncpy((char *)context->mac, buf,
|
|
+ sizeof(buf));
|
|
+
|
|
+ format_netmask(buf, sizeof(buf),
|
|
+ nic1->subnet_mask_prefix);
|
|
+ strncpy((char *)context->mask, buf,
|
|
+ sizeof(buf));
|
|
+ }
|
|
+
|
|
if (tgt0 && (tgt0->hdr.flags & INIT_FLAG_FW_SEL_BOOT)) {
|
|
strncpy((char *)context->targetname,
|
|
(char *)(ibft_loc+tgt0->tgt_name_off),
|