diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-08-19 15:00:06 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-10-13 10:57:40 +0200 |
commit | a3a59271109c621072f8cc30af4a3762cae769fb (patch) | |
tree | d4826e2bf34a6add54515dd124ca8a85bf91057a /commands | |
parent | 8fe37b4e2eb20ce789a8b5194b14b2818aae7402 (diff) | |
download | barebox-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 'commands')
-rw-r--r-- | commands/net.c | 23 |
1 files changed, 20 insertions, 3 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; |