Message ID | 1307718251-15947-5-git-send-email-sjg@chromium.org |
---|---|
State | New, archived |
Headers | show |
Hi Simon, On 10/06/2011 17:04, Simon Glass wrote: > This is a small clean-up patch. > > Signed-off-by: Simon Glass<sjg@chromium.org> > --- > net/bootp.c | 75 +++++++++++++++++++++++++--------------------------------- > 1 files changed, 32 insertions(+), 43 deletions(-) > > diff --git a/net/bootp.c b/net/bootp.c > index 4db63cb..4774624 100644 > --- a/net/bootp.c > +++ b/net/bootp.c > @@ -138,6 +138,35 @@ 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(); > +} a "}" is missing here Eric
On Fri, Jun 10, 2011 at 2:53 PM, Eric Bénard <eric@eukrea.com> wrote: > Hi Simon, > > On 10/06/2011 17:04, Simon Glass wrote: >> >> This is a small clean-up patch. >> >> Signed-off-by: Simon Glass<sjg@chromium.org> >> --- >> net/bootp.c | 75 >> +++++++++++++++++++++++++--------------------------------- >> 1 files changed, 32 insertions(+), 43 deletions(-) >> >> diff --git a/net/bootp.c b/net/bootp.c >> index 4db63cb..4774624 100644 >> --- a/net/bootp.c >> +++ b/net/bootp.c >> @@ -138,6 +138,35 @@ 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(); >> +} > > a "}" is missing here > > Eric > Thanks Eric, done. -Simon
diff --git a/net/bootp.c b/net/bootp.c index 4db63cb..4774624 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -138,6 +138,35 @@ 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 +308,7 @@ static void BootpVendorProcess (u8 * ext, int size) if (NetBootFileSize) debug("NetBootFileSize: %d\n", NetBootFileSize); } + /* * Handle a BOOTP received packet. */ @@ -287,7 +317,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)); @@ -314,26 +343,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 @@ -907,34 +917,13 @@ 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 */ dhcp_state = BOUND; printf ("DHCP client bound to address %pI4\n", &NetOurIP); - /* 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;
This is a small clean-up patch. Signed-off-by: Simon Glass <sjg@chromium.org> --- net/bootp.c | 75 +++++++++++++++++++++++++--------------------------------- 1 files changed, 32 insertions(+), 43 deletions(-)