summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/eth.c23
-rw-r--r--net/net.c72
-rw-r--r--net/nfs.c24
-rw-r--r--net/tftp.c10
4 files changed, 92 insertions, 37 deletions
diff --git a/net/eth.c b/net/eth.c
index 29c24c8827a..61862aaba9e 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -52,7 +52,7 @@ extern int rtl8139_initialize(bd_t*);
extern int rtl8169_initialize(bd_t*);
extern int scc_initialize(bd_t*);
extern int skge_initialize(bd_t*);
-extern int tsec_initialize(bd_t*, int);
+extern int tsec_initialize(bd_t*, int, char *);
static struct eth_device *eth_devices, *eth_current;
@@ -155,13 +155,28 @@ int eth_initialize(bd_t *bis)
skge_initialize(bis);
#endif
#if defined(CONFIG_MPC85XX_TSEC1)
- tsec_initialize(bis, 0);
+ tsec_initialize(bis, 0, CONFIG_MPC85XX_TSEC1_NAME);
+#elif defined(CONFIG_MPC83XX_TSEC1)
+ tsec_initialize(bis, 0, CONFIG_MPC83XX_TSEC1_NAME);
#endif
#if defined(CONFIG_MPC85XX_TSEC2)
- tsec_initialize(bis, 1);
+ tsec_initialize(bis, 1, CONFIG_MPC85XX_TSEC2_NAME);
+#elif defined(CONFIG_MPC83XX_TSEC2)
+ tsec_initialize(bis, 1, CONFIG_MPC83XX_TSEC2_NAME);
#endif
#if defined(CONFIG_MPC85XX_FEC)
- tsec_initialize(bis, 2);
+ tsec_initialize(bis, 2, CONFIG_MPC85XX_FEC_NAME);
+#else
+# if defined(CONFIG_MPC85XX_TSEC3)
+ tsec_initialize(bis, 2, CONFIG_MPC85XX_TSEC3_NAME);
+# elif defined(CONFIG_MPC83XX_TSEC3)
+ tsec_initialize(bis, 2, CONFIG_MPC83XX_TSEC3_NAME);
+# endif
+# if defined(CONFIG_MPC85XX_TSEC4)
+ tsec_initialize(bis, 3, CONFIG_MPC85XX_TSEC4_NAME);
+# elif defined(CONFIG_MPC83XX_TSEC4)
+ tsec_initialize(bis, 3, CONFIG_MPC83XX_TSEC4_NAME);
+# endif
#endif
#if defined(CONFIG_AU1X00)
au1x00_enet_initialize(bis);
diff --git a/net/net.c b/net/net.c
index 5b064956894..00217be0810 100644
--- a/net/net.c
+++ b/net/net.c
@@ -40,10 +40,10 @@
*
* DHCP:
*
- * Prerequisites: - own ethernet address
- * We want: - IP, Netmask, ServerIP, Gateway IP
- * - bootfilename, lease time
- * Next step: - TFTP
+ * Prerequisites: - own ethernet address
+ * We want: - IP, Netmask, ServerIP, Gateway IP
+ * - bootfilename, lease time
+ * Next step: - TFTP
*
* TFTP:
*
@@ -67,7 +67,7 @@
*
* SNTP:
*
- * Prerequisites: - own ethernet address
+ * Prerequisites: - own ethernet address
* - own IP address
* We want: - network time
* Next step: none
@@ -185,7 +185,7 @@ static int net_check_prereq (proto_t protocol);
IPaddr_t NetArpWaitPacketIP;
IPaddr_t NetArpWaitReplyIP;
uchar *NetArpWaitPacketMAC; /* MAC address of waiting packet's destination */
-uchar *NetArpWaitTxPacket; /* THE transmit packet */
+uchar *NetArpWaitTxPacket; /* THE transmit packet */
int NetArpWaitTxPacketSize;
uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
@@ -212,8 +212,8 @@ void ArpRequest (void)
arp->ar_pln = 4;
arp->ar_op = htons (ARPOP_REQUEST);
- memcpy (&arp->ar_data[0], NetOurEther, 6); /* source ET addr */
- NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP); /* source IP addr */
+ memcpy (&arp->ar_data[0], NetOurEther, 6); /* source ET addr */
+ NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP); /* source IP addr */
for (i = 10; i < 16; ++i) {
arp->ar_data[i] = 0; /* dest ET addr = 0 */
}
@@ -372,11 +372,11 @@ restart:
*/
NetOurIP = 0;
NetServerIP = getenv_IPaddr ("serverip");
- NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */
- NetOurNativeVLAN = getenv_VLAN("nvlan");
- case CDP:
- NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */
- NetOurNativeVLAN = getenv_VLAN("nvlan");
+ NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */
+ NetOurNativeVLAN = getenv_VLAN("nvlan");
+ case CDP:
+ NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */
+ NetOurNativeVLAN = getenv_VLAN("nvlan");
break;
default:
break;
@@ -1410,7 +1410,7 @@ NetReceive(volatile uchar * inpkt, int len)
puts (" ICMP Host Redirect to ");
print_IPaddr(icmph->un.gateway);
putc(' ');
- break;
+ return;
#if (CONFIG_COMMANDS & CFG_CMD_PING)
case ICMP_ECHO_REPLY:
/*
@@ -1418,7 +1418,7 @@ NetReceive(volatile uchar * inpkt, int len)
*/
/* XXX point to ip packet */
(*packetHandler)((uchar *)ip, 0, 0, 0);
- break;
+ return;
#endif
default:
return;
@@ -1427,6 +1427,46 @@ NetReceive(volatile uchar * inpkt, int len)
return;
}
+#ifdef CONFIG_UDP_CHECKSUM
+ if (ip->udp_xsum != 0) {
+ ulong xsum;
+ ushort *sumptr;
+ ushort sumlen;
+
+ xsum = ip->ip_p;
+ xsum += (ntohs(ip->udp_len));
+ xsum += (ntohl(ip->ip_src) >> 16) & 0x0000ffff;
+ xsum += (ntohl(ip->ip_src) >> 0) & 0x0000ffff;
+ xsum += (ntohl(ip->ip_dst) >> 16) & 0x0000ffff;
+ xsum += (ntohl(ip->ip_dst) >> 0) & 0x0000ffff;
+
+ sumlen = ntohs(ip->udp_len);
+ sumptr = (ushort *) &(ip->udp_src);
+
+ while (sumlen > 1) {
+ ushort sumdata;
+
+ sumdata = *sumptr++;
+ xsum += ntohs(sumdata);
+ sumlen -= 2;
+ }
+ if (sumlen > 0) {
+ ushort sumdata;
+
+ sumdata = *(unsigned char *) sumptr;
+ sumdata = (sumdata << 8) & 0xff00;
+ xsum += sumdata;
+ }
+ while ((xsum >> 16) != 0) {
+ xsum = (xsum & 0x0000ffff) + ((xsum >> 16) & 0x0000ffff);
+ }
+ if ((xsum != 0x00000000) && (xsum != 0x0000ffff)) {
+ printf(" UDP wrong checksum %08x %08x\n", xsum, ntohs(ip->udp_xsum));
+ return;
+ }
+ }
+#endif
+
#ifdef CONFIG_NETCONSOLE
nc_input_packet((uchar *)ip +IP_HDR_SIZE,
ntohs(ip->udp_dst),
@@ -1477,7 +1517,7 @@ static int net_check_prereq (proto_t protocol)
return (1);
}
#if (CONFIG_COMMANDS & (CFG_CMD_PING | CFG_CMD_SNTP))
- common:
+ common:
#endif
if (NetOurIP == 0) {
diff --git a/net/nfs.c b/net/nfs.c
index 2d94c08f760..de789e1f848 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -44,6 +44,7 @@ static int nfs_len;
static char dirfh[NFS_FHSIZE]; /* file handle of directory */
static char filefh[NFS_FHSIZE]; /* file handle of kernel image */
+static int NfsDownloadState;
static IPaddr_t NfsServerIP;
static int NfsSrvMountPort;
static int NfsSrvNfsPort;
@@ -63,7 +64,7 @@ static char *nfs_filename;
static char *nfs_path;
static char nfs_path_buff[2048];
-static __inline__ void
+static __inline__ int
store_block (uchar * src, unsigned offset, unsigned len)
{
ulong newsize = offset + len;
@@ -82,8 +83,7 @@ store_block (uchar * src, unsigned offset, unsigned len)
rc = flash_write ((uchar *)src, (ulong)(load_addr+offset), len);
if (rc) {
flash_perror (rc);
- NetState = NETLOOP_FAIL;
- return;
+ return -1;
}
} else
#endif /* CFG_DIRECT_FLASH_NFS */
@@ -93,6 +93,7 @@ store_block (uchar * src, unsigned offset, unsigned len)
if (NetBootFileXferSize < (offset+len))
NetBootFileXferSize = newsize;
+ return 0;
}
static char*
@@ -573,7 +574,8 @@ nfs_read_reply (uchar *pkt, unsigned len)
}
rlen = ntohl(rpc_pkt.u.reply.data[18]);
- store_block ((uchar *)pkt+sizeof(rpc_pkt.u.reply), nfs_offset, rlen);
+ if ( store_block ((uchar *)pkt+sizeof(rpc_pkt.u.reply), nfs_offset, rlen) )
+ return -9999;
return rlen;
}
@@ -632,7 +634,7 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
NetState = NETLOOP_FAIL;
} else {
puts ("\ndone\n");
- NetState = NETLOOP_SUCCESS;
+ NetState = NfsDownloadState;
}
break;
@@ -678,6 +680,7 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
NfsState = STATE_READLINK_REQ;
NfsSend ();
} else {
+ if ( ! rlen ) NfsDownloadState = NETLOOP_SUCCESS;
NfsState = STATE_UMOUNT_REQ;
NfsSend ();
}
@@ -692,6 +695,7 @@ NfsStart (void)
#ifdef NFS_DEBUG
printf ("%s\n", __FUNCTION__);
#endif
+ NfsDownloadState = NETLOOP_FAIL;
NfsServerIP = NetServerIP;
nfs_path = (char *)nfs_path_buff;
@@ -703,13 +707,11 @@ NfsStart (void)
}
if (BootFile[0] == '\0') {
- IPaddr_t OurIP = ntohl (NetOurIP);
-
sprintf (default_filename, "/nfsroot/%02lX%02lX%02lX%02lX.img",
- OurIP & 0xFF,
- (OurIP >> 8) & 0xFF,
- (OurIP >> 16) & 0xFF,
- (OurIP >> 24) & 0xFF );
+ NetOurIP & 0xFF,
+ (NetOurIP >> 8) & 0xFF,
+ (NetOurIP >> 16) & 0xFF,
+ (NetOurIP >> 24) & 0xFF );
strcpy (nfs_path, default_filename);
printf ("*** Warning: no boot file name; using '%s'\n",
diff --git a/net/tftp.c b/net/tftp.c
index 5a5ae22ac85..64a5576663c 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -302,13 +302,11 @@ void
TftpStart (void)
{
if (BootFile[0] == '\0') {
- IPaddr_t OurIP = ntohl(NetOurIP);
-
sprintf(default_filename, "%02lX%02lX%02lX%02lX.img",
- OurIP & 0xFF,
- (OurIP >> 8) & 0xFF,
- (OurIP >> 16) & 0xFF,
- (OurIP >> 24) & 0xFF );
+ NetOurIP & 0xFF,
+ (NetOurIP >> 8) & 0xFF,
+ (NetOurIP >> 16) & 0xFF,
+ (NetOurIP >> 24) & 0xFF );
tftp_filename = default_filename;
printf ("*** Warning: no boot file name; using '%s'\n",