#endif
/* Network loop state */
int NetState;
-#ifdef CONFIG_NET_MULTI
/* Tried all network devices */
int NetRestartWrap;
/* Network loop restarted */
static int NetRestarted;
/* At least one device configured */
static int NetDevExists;
-#endif
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
/* default is without VLAN */
/* update only when the environment has changed */
if (env_changed_id != env_id) {
- NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
+ NetOurIP = getenv_IPaddr("ipaddr");
+ NetCopyIP(&bd->bi_ip_addr, &NetOurIP);
NetOurGatewayIP = getenv_IPaddr("gatewayip");
NetOurSubnetMask = getenv_IPaddr("netmask");
NetServerIP = getenv_IPaddr("serverip");
{
bd_t *bd = gd->bd;
-#ifdef CONFIG_NET_MULTI
NetRestarted = 0;
NetDevExists = 0;
-#endif
/* XXX problem with bss workaround */
NetArpWaitPacketMAC = NULL;
}
eth_halt();
-#ifdef CONFIG_NET_MULTI
eth_set_current();
-#endif
if (eth_init(bd) < 0) {
eth_halt();
- return(-1);
+ return -1;
}
restart:
-#ifdef CONFIG_NET_MULTI
memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
-#else
- eth_getenv_enetaddr("ethaddr", NetOurEther);
-#endif
NetState = NETLOOP_CONTINUE;
case 1:
/* network not configured */
eth_halt();
- return (-1);
+ return -1;
-#ifdef CONFIG_NET_MULTI
case 2:
/* network device not configured */
break;
-#endif /* CONFIG_NET_MULTI */
case 0:
-#ifdef CONFIG_NET_MULTI
NetDevExists = 1;
-#endif
switch (protocol) {
case TFTP:
/* always use ARP to get server ethernet address */
TftpStart();
break;
-
+#ifdef CONFIG_CMD_TFTPSRV
+ case TFTPSRV:
+ TftpStartServer();
+ break;
+#endif
#if defined(CONFIG_CMD_DHCP)
case DHCP:
BootpTry = 0;
if (ctrlc()) {
eth_halt();
puts("\nAbort\n");
- return (-1);
+ return -1;
}
ArpTimeoutCheck();
switch (NetState) {
case NETLOOP_RESTART:
-#ifdef CONFIG_NET_MULTI
NetRestarted = 1;
-#endif
goto restart;
case NETLOOP_SUCCESS:
return NetBootFileXferSize;
case NETLOOP_FAIL:
- return (-1);
+ return -1;
}
}
}
NetTryCount++;
-#ifndef CONFIG_NET_MULTI
- NetSetTimeout(10000UL, startAgainTimeout);
- NetSetHandler(startAgainHandler);
-#else /* !CONFIG_NET_MULTI*/
eth_halt();
#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
eth_try_another(!NetRestarted);
} else {
NetState = NETLOOP_RESTART;
}
-#endif /* CONFIG_NET_MULTI */
}
/**********************************************************************/
static void PingStart(void)
{
-#if defined(CONFIG_NET_MULTI)
printf("Using %s device\n", eth_get_name());
-#endif /* CONFIG_NET_MULTI */
NetSetTimeout(10000UL, PingTimeout);
NetSetHandler(PingHandler);
tlen -= 4;
switch (type) {
- case CDP_DEVICE_ID_TLV:
- break;
- case CDP_ADDRESS_TLV:
- break;
- case CDP_PORT_ID_TLV:
- break;
- case CDP_CAPABILITIES_TLV:
- break;
- case CDP_VERSION_TLV:
- break;
- case CDP_PLATFORM_TLV:
- break;
- case CDP_NATIVE_VLAN_TLV:
- nvlan = *ss;
- break;
- case CDP_APPLIANCE_VLAN_TLV:
- t = (const uchar *)ss;
- while (tlen > 0) {
- if (tlen < 3)
- goto pkt_short;
+ case CDP_DEVICE_ID_TLV:
+ break;
+ case CDP_ADDRESS_TLV:
+ break;
+ case CDP_PORT_ID_TLV:
+ break;
+ case CDP_CAPABILITIES_TLV:
+ break;
+ case CDP_VERSION_TLV:
+ break;
+ case CDP_PLATFORM_TLV:
+ break;
+ case CDP_NATIVE_VLAN_TLV:
+ nvlan = *ss;
+ break;
+ case CDP_APPLIANCE_VLAN_TLV:
+ t = (const uchar *)ss;
+ while (tlen > 0) {
+ if (tlen < 3)
+ goto pkt_short;
- applid = t[0];
- ss = (const ushort *)(t + 1);
+ applid = t[0];
+ ss = (const ushort *)(t + 1);
#ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
- if (applid ==
- CONFIG_CDP_APPLIANCE_VLAN_TYPE)
- vlan = *ss;
+ if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+ vlan = *ss;
#else
- /* XXX will this work; dunno */
- vlan = ntohs(*ss);
+ /* XXX will this work; dunno */
+ vlan = ntohs(*ss);
#endif
- t += 3; tlen -= 3;
- }
- break;
- case CDP_TRIGGER_TLV:
- break;
- case CDP_POWER_CONSUMPTION_TLV:
- break;
- case CDP_SYSNAME_TLV:
- break;
- case CDP_SYSOBJECT_TLV:
- break;
- case CDP_MANAGEMENT_ADDRESS_TLV:
- break;
+ t += 3; tlen -= 3;
+ }
+ break;
+ case CDP_TRIGGER_TLV:
+ break;
+ case CDP_POWER_CONSUMPTION_TLV:
+ break;
+ case CDP_SYSNAME_TLV:
+ break;
+ case CDP_SYSOBJECT_TLV:
+ break;
+ case CDP_MANAGEMENT_ADDRESS_TLV:
+ break;
}
}
static void CDPStart(void)
{
-#if defined(CONFIG_NET_MULTI)
printf("Using %s device\n", eth_get_name());
-#endif
CDPSeq = 0;
CDPOK = 0;
#ifdef CONFIG_MCAST_TFTP
if (Mcast_addr != tmp)
#endif
- return;
+ return;
}
/* Read source IP address for later use */
src_ip = NetReadIP(&ip->ip_src);
* a fragment, and either the complete packet or NULL if
* it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL)
*/
- if (!(ip = NetDefragment(ip, &len)))
+ ip = NetDefragment(ip, &len);
+ if (!ip)
return;
/*
* watch for ICMP host redirects
case PING:
if (NetPingIP == 0) {
puts("*** ERROR: ping address not given\n");
- return (1);
+ return 1;
}
goto common;
#endif
case SNTP:
if (NetNtpServerIP == 0) {
puts("*** ERROR: NTP server address not given\n");
- return (1);
+ return 1;
}
goto common;
#endif
case TFTP:
if (NetServerIP == 0) {
puts("*** ERROR: `serverip' not set\n");
- return (1);
+ return 1;
}
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
/* Fall through */
case NETCONS:
+ case TFTPSRV:
if (NetOurIP == 0) {
puts("*** ERROR: `ipaddr' not set\n");
- return (1);
+ return 1;
}
/* Fall through */
case CDP:
case DHCP:
if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
-#ifdef CONFIG_NET_MULTI
extern int eth_get_dev_index(void);
int num = eth_get_dev_index();
switch (num) {
case -1:
puts("*** ERROR: No ethernet found.\n");
- return (1);
+ return 1;
case 0:
puts("*** ERROR: `ethaddr' not set\n");
break;
}
NetStartAgain();
- return (2);
-#else
- puts("*** ERROR: `ethaddr' not set\n");
- return (1);
-#endif
+ return 2;
}
/* Fall through */
default:
- return (0);
+ return 0;
}
- return (0); /* OK */
+ return 0; /* OK */
}
/**********************************************************************/
xsum += *p++;
xsum = (xsum & 0xffff) + (xsum >> 16);
xsum = (xsum & 0xffff) + (xsum >> 16);
- return (xsum & 0xffff);
+ return xsum & 0xffff;
}
int
memcpy(et->et_dest, addr, 6);
memcpy(et->et_src, NetOurEther, 6);
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
- et->et_protlen = htons(prot);
+ et->et_protlen = htons(prot);
return ETHER_HDR_SIZE;
} else {
VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)xet;
ushort getenv_VLAN(char *var)
{
- return (string_to_VLAN(getenv(var)));
+ return string_to_VLAN(getenv(var));
}