X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2FNetTest_Runner%2Fip.c;fp=Tools%2FNetTest_Runner%2Fip.c;h=628fdbe8e88ab57e1b113a646605b6d449a63b71;hb=d2f1a4c62225533351551870cbe44d94a4ec4fab;hp=bebcf73924ad1cd4bbc7faa06a972baf7a0ea73a;hpb=f08ffb4a09855859328b73127ad5a62505564612;p=tpg%2Facess2.git diff --git a/Tools/NetTest_Runner/ip.c b/Tools/NetTest_Runner/ip.c index bebcf739..628fdbe8 100644 --- a/Tools/NetTest_Runner/ip.c +++ b/Tools/NetTest_Runner/ip.c @@ -94,8 +94,19 @@ bool IP_Pkt_Check(size_t len, const void *data, size_t *ofs_out, int AF, const v tIPv4Hdr hdr; memcpy(&hdr, (const uint8_t*)data + ofs, sizeof(hdr)); TEST_ASSERT_REL(hdr.VerLen >> 4, ==, 4); + TEST_ASSERT_REL(IP_Checksum(IP_CHECKSUM_START, sizeof(hdr), &hdr), ==, 0); + + TEST_ASSERT_REL(ntohs(hdr.TotalLength), <=, len - ofs); + TEST_ASSERT_REL(ntohs(hdr.FragmentInfo), ==, 0); + + 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 ); - return false; + *ofs_out = ofs + (hdr.VerLen & 0xF) * 4; + return true; } else { TEST_WARN("Invalid AF(%i) in IP_Pkt_Check", AF);