git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tools/NetTest - Fixed ip checksum, pcap packet trace, cleanup
[tpg/acess2.git]
/
Tools
/
NetTest_Runner
/
ip.c
diff --git
a/Tools/NetTest_Runner/ip.c
b/Tools/NetTest_Runner/ip.c
index
628fdbe
..
eb53f7e
100644
(file)
--- a/
Tools/NetTest_Runner/ip.c
+++ b/
Tools/NetTest_Runner/ip.c
@@
-25,8
+25,10
@@
typedef struct {
// === CODE ===
uint16_t IP_Checksum(uint16_t Prev, size_t Length, const void *Data)
{
// === CODE ===
uint16_t IP_Checksum(uint16_t Prev, size_t Length, const void *Data)
{
+ //test_trace_hexdump("IP Checksum", Data, Length);
+
const uint16_t *words = Data;
const uint16_t *words = Data;
- uint32_t ret =
~Prev
;
+ uint32_t ret =
0
;
for( int i = 0; i < Length/2; i ++ )
{
ret += ntohs(*words);
for( int i = 0; i < Length/2; i ++ )
{
ret += ntohs(*words);
@@
-38,6
+40,12
@@
uint16_t IP_Checksum(uint16_t Prev, size_t Length, const void *Data)
while( ret >> 16 )
ret = (ret & 0xFFFF) + (ret >> 16);
while( ret >> 16 )
ret = (ret & 0xFFFF) + (ret >> 16);
+ //test_trace("IP Checksum = %04x + 0x%x", ret, (~Prev) & 0xFFFF);
+
+ ret += (~Prev) & 0xFFFF;
+ while( ret >> 16 )
+ ret = (ret & 0xFFFF) + (ret >> 16);
+
return ~ret;
}
return ~ret;
}
@@
-102,8
+110,8
@@
bool IP_Pkt_Check(size_t len, const void *data, size_t *ofs_out, int AF, const v
TEST_ASSERT_REL(hdr.TTL, >, 1); // >1 because there's no intervening hops
TEST_ASSERT_REL(hdr.Protocol, ==, proto);
TEST_ASSERT_REL(hdr.TTL, >, 1); // >1 because there's no intervening hops
TEST_ASSERT_REL(hdr.Protocol, ==, proto);
- TEST_ASSERT( memcmp(hdr.SrcAddr, Src, 4) == 0 );
- TEST_ASSERT( memcmp(hdr.DstAddr, Dst, 4) == 0 );
+
if(Src)
TEST_ASSERT( memcmp(hdr.SrcAddr, Src, 4) == 0 );
+
if(Dst)
TEST_ASSERT( memcmp(hdr.DstAddr, Dst, 4) == 0 );
*ofs_out = ofs + (hdr.VerLen & 0xF) * 4;
return true;
*ofs_out = ofs + (hdr.VerLen & 0xF) * 4;
return true;
UCC
git Repository :: git.ucc.asn.au