9
0
Fork 0

net: split NetLoop in NetLoop and NetLoopInit

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2009-08-19 14:20:13 +02:00
parent 3487f1ee8e
commit 9296260a78
5 changed files with 24 additions and 2 deletions

View File

@ -151,6 +151,9 @@ static int do_dhcp (cmd_tbl_t *cmdtp, int argc, char *argv[])
{
int size;
if (NetLoopInit(DHCP) < 0)
return 1;
if ((size = NetLoop(DHCP)) < 0)
return 1;
@ -217,6 +220,9 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
safe_strncpy (BootFile, remotefile, sizeof(BootFile));
if (NetLoopInit(proto) < 0)
goto out;
if ((size = NetLoop(proto)) < 0) {
rcode = size;
goto out;
@ -256,6 +262,9 @@ static int do_cdp (cmd_tbl_t *cmdtp, int argc, char *argv[])
{
int r;
if (NetLoopInit(CDP) < 0)
return 1;
r = NetLoop(CDP);
if (r < 0) {
printf("cdp failed; perhaps not a CISCO switch?\n");

View File

@ -315,6 +315,9 @@ extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */
extern int NetTimeOffset; /* offset time from UTC */
/* Initialize the network adapter */
int NetLoopInit(proto_t);
/* Do the work */
int NetLoop(proto_t);
/* Shutdown adapters and cleanup */

View File

@ -238,8 +238,7 @@ void ArpTimeoutCheck(void)
* Main network processing loop.
*/
int
NetLoop(proto_t protocol)
int NetLoopInit(proto_t protocol)
{
struct eth_device *eth_current = eth_get_current();
IPaddr_t ip;
@ -292,6 +291,11 @@ NetLoop(proto_t protocol)
NetOurNativeVLAN = getenv_VLAN("nvlan");
NetServerIP = dev_get_param_ip(&eth_current->dev, "serverip");
return 0;
}
int NetLoop(proto_t protocol)
{
/*
* Start the ball rolling with the given start function. From
* here on, this code is a state machine driven by received

View File

@ -97,6 +97,9 @@ int do_ping (cmd_tbl_t *cmdtp, int argc, char *argv[])
return -1;
}
if (NetLoopInit(PING) < 0)
return 1;
if (NetLoop(PING) < 0) {
printf("ping failed; host %s is not alive\n", argv[1]);
return 1;

View File

@ -110,6 +110,9 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (toff == NULL) NetTimeOffset = 0;
else NetTimeOffset = simple_strtol (toff, NULL, 10);
if (NetLoopInit(SNTP) < 0)
return 1;
if (NetLoop(SNTP) < 0) {
printf("SNTP failed: host %s not responding\n", argv[1]);
return 1;