summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-06-13 16:13:12 -0700
committerGerrit <chrome-bot@google.com>2011-11-17 14:51:33 -0800
commit32c71f6b9f2b4f26636f093e167f2267522cb672 (patch)
treeb6aed1cdfb6a827eecfcc6105ade0732e0cd939d /net
parent7d5c776688d48d9ee2a38f4d7af076f48b92578e (diff)
UPSTREAM: Put common autoload code into auto_load() function
This is a small clean-up patch. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Eric BĂ©nard <eric@eukrea.com> (cherry picked from commit 093498669e77597635a24f326f11efeab213d394) Change-Id: Ib052e50e7e520c9d5c8c5344e94a4404b2ba0d30 Reviewed-on: https://gerrit.chromium.org/gerrit/11793 Commit-Ready: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'net')
-rw-r--r--net/bootp.c76
1 files changed, 33 insertions, 43 deletions
diff --git a/net/bootp.c b/net/bootp.c
index 043f9e0ed42..ab03d2ea1a4 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -138,6 +138,36 @@ static int truncate_sz (const char *name, int maxlen, int curlen)
return (curlen);
}
+/*
+ * Check if autoload is enabled. If so, use either NFS or TFTP to download
+ * the boot file.
+ */
+static void auto_load(void)
+{
+ const char *s = getenv("autoload");
+
+ if (s != NULL) {
+ if (*s == 'n') {
+ /*
+ * Just use BOOTP to configure system;
+ * Do not use TFTP to load the bootfile.
+ */
+ NetState = NETLOOP_SUCCESS;
+ return;
+ }
+#if defined(CONFIG_CMD_NFS)
+ if (strcmp(s, "NFS") == 0) {
+ /*
+ * Use NFS to load the bootfile.
+ */
+ NfsStart();
+ return;
+ }
+#endif
+ TftpStart();
+ }
+}
+
#if !defined(CONFIG_CMD_DHCP)
static void BootpVendorFieldProcess (u8 * ext)
@@ -279,6 +309,7 @@ static void BootpVendorProcess (u8 * ext, int size)
if (NetBootFileSize)
debug("NetBootFileSize: %d\n", NetBootFileSize);
}
+
/*
* Handle a BOOTP received packet.
*/
@@ -287,7 +318,6 @@ BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len)
{
Bootp_t *bp;
- char *s;
debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
src, dest, len, sizeof (Bootp_t));
@@ -315,26 +345,7 @@ BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("Got good BOOTP\n");
- if ((s = getenv("autoload")) != NULL) {
- if (*s == 'n') {
- /*
- * Just use BOOTP to configure system;
- * Do not use TFTP to load the bootfile.
- */
- NetState = NETLOOP_SUCCESS;
- return;
-#if defined(CONFIG_CMD_NFS)
- } else if (strcmp(s, "NFS") == 0) {
- /*
- * Use NFS to load the bootfile.
- */
- NfsStart();
- return;
-#endif
- }
- }
-
- TftpStart();
+ auto_load();
}
#endif
@@ -909,8 +920,6 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("DHCP State: REQUESTING\n");
if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
- char *s;
-
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
BootpCopyNetParams(bp); /* Store net params from reply */
@@ -918,26 +927,7 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
printf ("DHCP client bound to address %pI4\n", &NetOurIP);
bootstage_mark(BOOTSTAGE_BOOTP_STOP, "bootp_stop");
- /* Obey the 'autoload' setting */
- if ((s = getenv("autoload")) != NULL) {
- if (*s == 'n') {
- /*
- * Just use BOOTP to configure system;
- * Do not use TFTP to load the bootfile.
- */
- NetState = NETLOOP_SUCCESS;
- return;
-#if defined(CONFIG_CMD_NFS)
- } else if (strcmp(s, "NFS") == 0) {
- /*
- * Use NFS to load the bootfile.
- */
- NfsStart();
- return;
-#endif
- }
- }
- TftpStart();
+ auto_load();
return;
}
break;