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