d33bf0f
diff -aurp open-iscsi-2.0-870.1/include/fw_context.h open-iscsi-2.0-870.1.work/include/fw_context.h
d33bf0f
--- open-iscsi-2.0-870.1/include/fw_context.h	2008-11-22 11:06:46.000000000 -0600
d33bf0f
+++ open-iscsi-2.0-870.1.work/include/fw_context.h	2008-11-25 11:31:09.000000000 -0600
5003024
@@ -23,21 +23,30 @@
5003024
 
5003024
 struct boot_context {
5003024
 #define IQNSZ (223+1)
5003024
+	/* target settings */
5003024
 	int target_port;
5003024
-	char initiatorname[IQNSZ];
5003024
 	char targetname[IQNSZ];
5003024
 	char target_ipaddr[32];
5003024
 	char chap_name[127];
5003024
 	char chap_password[16];
5003024
 	char chap_name_in[127];
5003024
 	char chap_password_in[16];
5003024
+
5003024
+	/* initiator settings */
5003024
+	char isid[10];
5003024
+	char initiatorname[IQNSZ];
5003024
+
5003024
+	/* network settings */
5003024
+	char dhcp[18];
5003024
 	char iface[42];
5003024
 	char mac[18];
5003024
 	char ipaddr[18];
5003024
+	char gateway[18];
5003024
+	char primary_dns[18];
5003024
+	char secondary_dns[18];
5003024
 	char mask[18];
5003024
 	char lun[17];
5003024
 	char vlan[15];
5003024
-	char isid[10];
5003024
 };
5003024
 
5003024
 extern int fw_get_entry(struct boot_context *context, const char *filepath);
d33bf0f
diff -aurp open-iscsi-2.0-870.1/utils/fwparam_ibft/fw_entry.c open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fw_entry.c
d33bf0f
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fw_entry.c	2008-11-25 11:34:56.000000000 -0600
d33bf0f
+++ open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fw_entry.c	2008-11-25 11:34:25.000000000 -0600
d33bf0f
@@ -34,22 +34,13 @@ int fw_get_entry(struct boot_context *co
5003024
 	return ret;
5003024
 }
5003024
 
5003024
-/*
5003024
- * Dump the 8 byte mac address
5003024
- */
5003024
-static void dump_mac(struct boot_context *context)
5003024
-{
5003024
-	if (!strlen(context->mac))
5003024
-		return;
5003024
-
5003024
-	printf("iface.hwaddress = %s\n", context->mac);
5003024
-}
5003024
-
5003024
 static void dump_initiator(struct boot_context *context)
5003024
 {
5003024
-	if (!strlen(context->initiatorname))
5003024
-		return;
5003024
-	printf("iface.initiatorname = %s\n", context->initiatorname);
5003024
+	if (strlen(context->initiatorname))
5003024
+		printf("iface.initiatorname = %s\n", context->initiatorname);
5003024
+
5003024
+	if (strlen(context->isid))
5003024
+		printf("iface.isid = %s\n", context->isid);
5003024
 }
5003024
 
5003024
 static void dump_target(struct boot_context *context)
d33bf0f
@@ -73,11 +64,44 @@ static void dump_target(struct boot_cont
5003024
 	if (strlen(context->chap_password_in))
5003024
 		printf("node.session.auth.password_in = %s\n",
5003024
 		       context->chap_password_in);
5003024
+
5003024
+	if (strlen(context->lun))
5003024
+		printf("node.boot_lun = %s\n", context->lun);
5003024
+}
5003024
+
5003024
+/* TODO: add defines for all the idbm strings in this file and add a macro */
5003024
+static void dump_network(struct boot_context *context)
5003024
+{
5003024
+	/* Dump the 8 byte mac address (not iser support) */
5003024
+	if (strlen(context->mac))
5003024
+		printf("iface.hwaddress = %s\n", context->mac);
5003024
+	/*
5003024
+	 * If this has a valid address then DHCP was used (broadcom sends
5003024
+	 * 0.0.0.0).
5003024
+	 */
5003024
+	if (strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0"))
5003024
+		printf("iface.bootproto = DHCP\n");
5003024
+	else
5003024
+		printf("iface.bootproto = STATIC\n");
5003024
+	if (strlen(context->ipaddr))
5003024
+		printf("iface.ipaddress = %s\n", context->ipaddr);
5003024
+	if (strlen(context->mask))
5003024
+		printf("iface.subnet_mask = %s\n", context->mask);
5003024
+	if (strlen(context->gateway))
5003024
+		printf("iface.gateway = %s\n", context->gateway);
5003024
+	if (strlen(context->primary_dns))
5003024
+		printf("iface.primary_dns = %s\n", context->primary_dns);
5003024
+	if (strlen(context->secondary_dns))
5003024
+		printf("iface.secondary_dns = %s\n", context->secondary_dns);
5003024
+	if (strlen(context->vlan))
5003024
+		printf("iface.vlan = %s\n", context->vlan);
5003024
+	if (strlen(context->iface))
5003024
+		printf("iface.net_ifacename = %s\n", context->iface);
5003024
 }
5003024
 
5003024
 void fw_print_entry(struct boot_context *context)
5003024
 {
5003024
 	dump_initiator(context);
5003024
-	dump_mac(context);
5003024
+	dump_network(context);
5003024
 	dump_target(context);
5003024
 }
d33bf0f
diff -aurp open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c
d33bf0f
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c	2008-11-25 11:34:56.000000000 -0600
d33bf0f
+++ open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c	2008-11-25 11:31:09.000000000 -0600
5003024
@@ -24,11 +24,15 @@
5003024
 #include <unistd.h>
5003024
 #include <fcntl.h>
5003024
 #include <errno.h>
5003024
-#include "fwparam_ibft.h"
5003024
+#include <dirent.h>
5003024
 #include <fw_context.h>
5003024
+#include <sys/types.h>
5003024
+
5003024
+#include "fwparam_ibft.h"
5003024
 
5003024
 #define IBFT_MAX 255
5003024
 #define IBFT_SYSFS_ROOT "/sys/firmware/ibft/"
5003024
+#define IBFT_SYSFS_DE
5003024
 
5003024
 static char *target_list[IBFT_MAX];
5003024
 static char *nic_list[IBFT_MAX];
5003024
@@ -143,6 +147,48 @@ static int find_sysfs_dirs(const char *f
5003024
 	return 0;
5003024
 }
5003024
 
5003024
+static int get_iface_from_device(const char *eth_dir,
5003024
+				 struct boot_context *context)
5003024
+{
5003024
+	char dev_dir[FILENAMESZ];
5003024
+	int rc = ENODEV;
5003024
+	DIR *dirfd;
5003024
+	struct dirent *dent;
5003024
+
5003024
+	memset(dev_dir, 0, FILENAMESZ);
5003024
+	strncat(dev_dir, eth_dir, FILENAMESZ);
5003024
+	strncat(dev_dir, "/device", FILENAMESZ);
5003024
+
5003024
+	if (!file_exist(dev_dir))
5003024
+		return 0;
5003024
+
5003024
+	dirfd = opendir(dev_dir);
5003024
+	if (!dirfd)
5003024
+		return errno;
5003024
+
5003024
+	while ((dent = readdir(dirfd))) {
5003024
+		if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
5003024
+			continue;
5003024
+
5003024
+		if (strncmp(dent->d_name, "net:", 4))
5003024
+			continue;
5003024
+
5003024
+		if ((strlen(dent->d_name) - 4) > (sizeof(context->iface) - 1)) {
5003024
+			rc = EINVAL;
5003024
+			printf("Net device %s too bug for iface buffer.\n",
5003024
+			       dent->d_name);
5003024
+			break;
5003024
+		}
5003024
+
5003024
+		if (sscanf(dent->d_name, "net:%s", context->iface) != 1)
5003024
+			rc = EINVAL;
5003024
+		rc = 0;
5003024
+		break;
5003024
+	}
5003024
+
5003024
+	return rc;
5003024
+}
5003024
+
5003024
 /*
5003024
  * Routines to fill in the context values.
5003024
  */
5003024
@@ -154,7 +200,17 @@ static int fill_nic_context(const char *
5003024
 	rc |= read_data(dir, "/vlan", context->vlan, sizeof(context->vlan));
5003024
 	rc |= read_data(dir, "/ip-addr", context->ipaddr,
5003024
 		sizeof(context->ipaddr));
5003024
-	rc |= read_data(dir, "/mask", context->mask, sizeof(context->mask));
5003024
+	rc |= read_data(dir, "/subnet-mask", context->mask,
5003024
+			sizeof(context->mask));
5003024
+	rc |= read_data(dir, "/gateway", context->gateway,
5003024
+			sizeof(context->gateway));
5003024
+	rc |= read_data(dir, "/primary-dns", context->primary_dns,
5003024
+			sizeof(context->primary_dns));
5003024
+	rc |= read_data(dir, "/secondary-dns", context->secondary_dns,
5003024
+			sizeof(context->secondary_dns));
5003024
+	rc |= read_data(dir, "/dhcp", context->dhcp, sizeof(context->dhcp));
5003024
+
5003024
+	rc |= get_iface_from_device(dir, context);
5003024
 
5003024
 	return rc;
5003024
 }
5003024
@@ -199,7 +255,7 @@ static int fill_tgt_context(const char *
5003024
 static int find_boot_flag(char *list[], ssize_t size, int *boot_idx)
5003024
 {
5003024
 	int rc = -1;
5003024
-	int i, flag = -1;
5003024
+	int i, flag = 0;
5003024
 
5003024
 	for (i = 0; i < size; i++, flag = -1) {
5003024
 		rc = read_int_data(list[i], IBFT_SYSFS_FLAG_NAME, &flag;;
5003024
@@ -208,6 +264,8 @@ static int find_boot_flag(char *list[], 
5003024
 			rc = 0;
5003024
 			break;
5003024
 		}
5003024
+		rc = -1;
5003024
+		flag = 0;
5003024
 
5003024
 	}
5003024