net: split NetLoop in NetLoop and NetLoopInit
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
3487f1ee8e
commit
9296260a78
|
@ -151,6 +151,9 @@ static int do_dhcp (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
if (NetLoopInit(DHCP) < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if ((size = NetLoop(DHCP)) < 0)
|
if ((size = NetLoop(DHCP)) < 0)
|
||||||
return 1;
|
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));
|
safe_strncpy (BootFile, remotefile, sizeof(BootFile));
|
||||||
|
|
||||||
|
if (NetLoopInit(proto) < 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
if ((size = NetLoop(proto)) < 0) {
|
if ((size = NetLoop(proto)) < 0) {
|
||||||
rcode = size;
|
rcode = size;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -256,6 +262,9 @@ static int do_cdp (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
if (NetLoopInit(CDP) < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
r = NetLoop(CDP);
|
r = NetLoop(CDP);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
printf("cdp failed; perhaps not a CISCO switch?\n");
|
printf("cdp failed; perhaps not a CISCO switch?\n");
|
||||||
|
|
|
@ -315,6 +315,9 @@ extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */
|
||||||
extern int NetTimeOffset; /* offset time from UTC */
|
extern int NetTimeOffset; /* offset time from UTC */
|
||||||
|
|
||||||
/* Initialize the network adapter */
|
/* Initialize the network adapter */
|
||||||
|
int NetLoopInit(proto_t);
|
||||||
|
|
||||||
|
/* Do the work */
|
||||||
int NetLoop(proto_t);
|
int NetLoop(proto_t);
|
||||||
|
|
||||||
/* Shutdown adapters and cleanup */
|
/* Shutdown adapters and cleanup */
|
||||||
|
|
|
@ -238,8 +238,7 @@ void ArpTimeoutCheck(void)
|
||||||
* Main network processing loop.
|
* Main network processing loop.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int NetLoopInit(proto_t protocol)
|
||||||
NetLoop(proto_t protocol)
|
|
||||||
{
|
{
|
||||||
struct eth_device *eth_current = eth_get_current();
|
struct eth_device *eth_current = eth_get_current();
|
||||||
IPaddr_t ip;
|
IPaddr_t ip;
|
||||||
|
@ -292,6 +291,11 @@ NetLoop(proto_t protocol)
|
||||||
NetOurNativeVLAN = getenv_VLAN("nvlan");
|
NetOurNativeVLAN = getenv_VLAN("nvlan");
|
||||||
NetServerIP = dev_get_param_ip(ð_current->dev, "serverip");
|
NetServerIP = dev_get_param_ip(ð_current->dev, "serverip");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NetLoop(proto_t protocol)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Start the ball rolling with the given start function. From
|
* Start the ball rolling with the given start function. From
|
||||||
* here on, this code is a state machine driven by received
|
* here on, this code is a state machine driven by received
|
||||||
|
|
|
@ -97,6 +97,9 @@ int do_ping (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NetLoopInit(PING) < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (NetLoop(PING) < 0) {
|
if (NetLoop(PING) < 0) {
|
||||||
printf("ping failed; host %s is not alive\n", argv[1]);
|
printf("ping failed; host %s is not alive\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -110,6 +110,9 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
if (toff == NULL) NetTimeOffset = 0;
|
if (toff == NULL) NetTimeOffset = 0;
|
||||||
else NetTimeOffset = simple_strtol (toff, NULL, 10);
|
else NetTimeOffset = simple_strtol (toff, NULL, 10);
|
||||||
|
|
||||||
|
if (NetLoopInit(SNTP) < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (NetLoop(SNTP) < 0) {
|
if (NetLoop(SNTP) < 0) {
|
||||||
printf("SNTP failed: host %s not responding\n", argv[1]);
|
printf("SNTP failed: host %s not responding\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue