summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/net.c23
-rw-r--r--include/net.h2
-rw-r--r--net/bootp.h1
-rw-r--r--net/net.c52
-rw-r--r--net/ping.c4
-rw-r--r--net/rarp.c3
-rw-r--r--net/sntp.c4
-rw-r--r--net/tftp.h3
8 files changed, 31 insertions, 61 deletions
diff --git a/commands/net.c b/commands/net.c
index c079af1329..e3fffc45f7 100644
--- a/commands/net.c
+++ b/commands/net.c
@@ -145,6 +145,7 @@ U_BOOT_CMD_END
* after loading?
* @note This command is available only, if enabled in the menuconfig.
*/
+extern void DhcpRequest(void);
#ifdef CONFIG_NET_DHCP
static int do_dhcp (cmd_tbl_t *cmdtp, int argc, char *argv[])
@@ -154,7 +155,10 @@ static int do_dhcp (cmd_tbl_t *cmdtp, int argc, char *argv[])
if (NetLoopInit(DHCP) < 0)
return 1;
- if ((size = NetLoop(DHCP)) < 0)
+ NetOurIP = 0;
+ DhcpRequest(); /* Basically same as BOOTP */
+
+ if ((size = NetLoop()) < 0)
return 1;
/* NetLoop ok, update environment */
@@ -192,6 +196,9 @@ U_BOOT_CMD_END
int net_store_fd;
+extern void TftpStart(void); /* Begin TFTP get */
+extern void NfsStart(void);
+
static int
netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
{
@@ -223,7 +230,17 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
if (NetLoopInit(proto) < 0)
goto out;
- if ((size = NetLoop(proto)) < 0) {
+ switch (proto) {
+ case TFTP:
+ TftpStart();
+ break;
+ case NFS:
+ NfsStart();
+ default:
+ break;
+ }
+
+ if ((size = NetLoop()) < 0) {
rcode = size;
goto out;
}
@@ -265,7 +282,7 @@ static int do_cdp (cmd_tbl_t *cmdtp, int argc, char *argv[])
if (NetLoopInit(CDP) < 0)
return 1;
- r = NetLoop(CDP);
+ r = NetLoop();
if (r < 0) {
printf("cdp failed; perhaps not a CISCO switch?\n");
return 1;
diff --git a/include/net.h b/include/net.h
index 86c3340005..cdab158dde 100644
--- a/include/net.h
+++ b/include/net.h
@@ -318,7 +318,7 @@ extern int NetTimeOffset; /* offset time from UTC */
int NetLoopInit(proto_t);
/* Do the work */
-int NetLoop(proto_t);
+int NetLoop(void);
/* Shutdown adapters and cleanup */
void NetStop(void);
diff --git a/net/bootp.h b/net/bootp.h
index 4001874791..d5b2233727 100644
--- a/net/bootp.h
+++ b/net/bootp.h
@@ -67,7 +67,6 @@ ulong seed1, seed2; /* seed for random BOOTP delay */
extern void BootpRequest (void);
/****************** DHCP Support *********************/
-extern void DhcpRequest(void);
/* DHCP States */
typedef enum { INIT,
diff --git a/net/net.c b/net/net.c
index f2ef6cd33e..004f53cb05 100644
--- a/net/net.c
+++ b/net/net.c
@@ -299,7 +299,7 @@ int NetLoopInit(proto_t protocol)
return ret;
}
-int NetLoop(proto_t protocol)
+int NetLoop(void)
{
/*
* Start the ball rolling with the given start function. From
@@ -307,56 +307,6 @@ int NetLoop(proto_t protocol)
* packets and timer events.
*/
- switch (protocol) {
-#ifdef CONFIG_NET_TFTP
- case TFTP:
- /* always use ARP to get server ethernet address */
- TftpStart();
- break;
-#endif
-#ifdef CONFIG_NET_DHCP
- case DHCP:
- /* Start with a clean slate... */
- NetOurIP = 0;
- DhcpRequest(); /* Basically same as BOOTP */
- break;
-#endif
-#ifdef CONFIG_NET_BOOTP
- case BOOTP:
- BootpRequest ();
- break;
-#endif
-#ifdef CONFIG_NET_RARP
- case RARP:
- NetOurIP = 0;
- RarpTry = 0;
- RarpRequest ();
- break;
-#endif
-#ifdef CONFIG_NET_PING
- case PING:
- PingStart();
- break;
-#endif
-#ifdef CONFIG_NET_NFS
- case NFS:
- NfsStart();
- break;
-#endif
-#ifdef CONFIG_NETCONSOLE
- case NETCONS:
- NcStart();
- break;
-#endif
-#ifdef CONFIG_NET_SNTP
- case SNTP:
- SntpStart();
- break;
-#endif
- default:
- break;
- }
-
NetBootFileXferSize = 0;
/*
diff --git a/net/ping.c b/net/ping.c
index 26b7778823..fcafe1e2d9 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -100,7 +100,9 @@ int do_ping (cmd_tbl_t *cmdtp, int argc, char *argv[])
if (NetLoopInit(PING) < 0)
return 1;
- if (NetLoop(PING) < 0) {
+ PingStart();
+
+ if (NetLoop() < 0) {
printf("ping failed; host %s is not alive\n", argv[1]);
return 1;
}
diff --git a/net/rarp.c b/net/rarp.c
index b1567a6772..35cd2f24ef 100644
--- a/net/rarp.c
+++ b/net/rarp.c
@@ -71,6 +71,9 @@ RarpRequest (void)
uchar *pkt;
ARP_t * rarp;
+ NetOurIP = 0;
+ RarpTry = 0;
+
printf("RARP broadcast %d\n", ++RarpTry);
pkt = NetTxPacket;
diff --git a/net/sntp.c b/net/sntp.c
index 3be166a372..8d913dd51e 100644
--- a/net/sntp.c
+++ b/net/sntp.c
@@ -113,7 +113,9 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (NetLoopInit(SNTP) < 0)
return 1;
- if (NetLoop(SNTP) < 0) {
+ SntpStart();
+
+ if (NetLoop() < 0) {
printf("SNTP failed: host %s not responding\n", argv[1]);
return 1;
}
diff --git a/net/tftp.h b/net/tftp.h
index e3dfb2628a..7fed2e6b26 100644
--- a/net/tftp.h
+++ b/net/tftp.h
@@ -13,9 +13,6 @@
* Global functions and variables.
*/
-/* tftp.c */
-extern void TftpStart (void); /* Begin TFTP get */
-
/**********************************************************************/
#endif /* __TFTP_H__ */