summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-08-19 15:00:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-10-13 10:57:40 +0200
commita3a59271109c621072f8cc30af4a3762cae769fb (patch)
treed4826e2bf34a6add54515dd124ca8a85bf91057a /net
parent8fe37b4e2eb20ce789a8b5194b14b2818aae7402 (diff)
downloadbarebox-a3a59271109c621072f8cc30af4a3762cae769fb.tar.gz
barebox-a3a59271109c621072f8cc30af4a3762cae769fb.tar.xz
net: remove switch/case in NetLoop()
Instead of having a big switch/case for every protocol, do the right things in the individual functions before callong NetLoop(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-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
6 files changed, 10 insertions, 57 deletions
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__ */