From e0c07b868cab405ab4b5335a0247899bfc5ea0b6 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 1 Dec 2008 16:26:20 -0600 Subject: net: Define IP flag field values These defines were pulled from the "Add simple IP/UDP fragmentation support" patch from Frank Haverkamp . Signed-off-by: Peter Tyser Signed-off-by: Ben Warren --- net/net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'net') diff --git a/net/net.c b/net/net.c index 77e83b5bd..cf1f4fa1f 100644 --- a/net/net.c +++ b/net/net.c @@ -735,7 +735,7 @@ int PingSend(void) ip->ip_tos = 0; ip->ip_len = htons(IP_HDR_SIZE_NO_UDP + 8); ip->ip_id = htons(NetIPID++); - ip->ip_off = htons(0x4000); /* No fragmentation */ + ip->ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ ip->ip_ttl = 255; ip->ip_p = 0x01; /* ICMP */ ip->ip_sum = 0; @@ -1399,7 +1399,7 @@ NetReceive(volatile uchar * inpkt, int len) if ((ip->ip_hl_v & 0xf0) != 0x40) { return; } - if (ip->ip_off & htons(0x1fff)) { /* Can't deal w/ fragments */ + if (ip->ip_off & htons(IP_OFFS)) { /* Can't deal w/ fragments */ return; } /* can't deal with headers > 20 bytes */ @@ -1698,7 +1698,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len) ip->ip_tos = 0; ip->ip_len = htons(IP_HDR_SIZE + len); ip->ip_id = htons(NetIPID++); - ip->ip_off = htons(0x4000); /* No fragmentation */ + ip->ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ ip->ip_ttl = 255; ip->ip_p = 17; /* UDP */ ip->ip_sum = 0; -- cgit v1.2.3 From d32c5be50bf0600bfdc54223ef341ee9c63db445 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 1 Dec 2008 16:26:21 -0600 Subject: net: Add additional IP fragmentation check Ignore IP packets which have the "more fragments" flag bit set. This flag indicates the IP packet is fragmented and must be ignored by U-Boot. Signed-off-by: Peter Tyser Signed-off-by: Ben Warren --- net/net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/net.c b/net/net.c index cf1f4fa1f..7354f2c14 100644 --- a/net/net.c +++ b/net/net.c @@ -1399,7 +1399,8 @@ NetReceive(volatile uchar * inpkt, int len) if ((ip->ip_hl_v & 0xf0) != 0x40) { return; } - if (ip->ip_off & htons(IP_OFFS)) { /* Can't deal w/ fragments */ + /* Can't deal with fragments */ + if (ip->ip_off & htons(IP_OFFS | IP_FLAGS_MFRAG)) { return; } /* can't deal with headers > 20 bytes */ -- cgit v1.2.3 From 6a86bb6c25376f0358478219fa28d7c84dd01ed0 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 1 Dec 2008 16:29:38 -0600 Subject: net: Fix TftpStart() ip:filename bug The TftpStart() function modifies the 'BootFile' string when 'BootFile' contains both an IP address and filename (eg 1.2.3.4:/path/file). This causes subsequent calls to TftpStart to incorrectly parse the TFTP filename and server IP address to use. For example: => tftp 0x100000 10.52.0.62:/home/ptyser/non_existant Speed: 100, half duplex Using eTSEC1 device TFTP from server 10.52.0.62; our IP address is 10.52.253.79 ^^^^^^^^^^ CORRECT Filename '/home/ptyser/non_existant'. ^^^^^^^^^^^^^^^^^^^^^^^^^ CORRECT Load address: 0x100000 Loading: * TFTP error: 'File not found' (1) Starting again eTSEC2: No link. Speed: 100, half duplex Using eTSEC1 device TFTP from server 10.52.0.33; our IP address is 10.52.253.79 ^^^^^^^^^^ WRONG Filename '10.52.0.62'. ^^^^^^^^^^ WRONG Load address: 0x100000 Loading: * TFTP error: 'File not found' (1) Starting again TftpStart() was modified to not modify the 'BootFile' string. Signed-off-by: Peter Tyser Signed-off-by: Ben Warren --- net/tftp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'net') diff --git a/net/tftp.c b/net/tftp.c index ce6ea3d9f..3dac3d853 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -499,9 +499,8 @@ TftpStart (void) strncpy(tftp_filename, BootFile, MAX_LEN); tftp_filename[MAX_LEN-1] = 0; } else { - *p++ = '\0'; TftpServerIP = string_to_ip (BootFile); - strncpy(tftp_filename, p, MAX_LEN); + strncpy(tftp_filename, p + 1, MAX_LEN); tftp_filename[MAX_LEN-1] = 0; } } -- cgit v1.2.3