X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2FNetTest_Runner%2Fip.c;h=13de5bc724ae3a27391cded4b4b9203275dda663;hb=9c4eedf4893f851bd1ba60ce541c8d098a9ef7f7;hp=eb53f7ed82acd6b6418f593f04fefd807198d41a;hpb=e9b63a7cc8abab8dfc2b491ef3841dfbeb22703d;p=tpg%2Facess2.git diff --git a/Tools/NetTest_Runner/ip.c b/Tools/NetTest_Runner/ip.c index eb53f7ed..13de5bc7 100644 --- a/Tools/NetTest_Runner/ip.c +++ b/Tools/NetTest_Runner/ip.c @@ -92,7 +92,7 @@ void IP_Send(int IfNum, int AF, const void *Src, const void *Dst, uint8_t proto, } } -bool IP_Pkt_Check(size_t len, const void *data, size_t *ofs_out, int AF, const void *Src, const void *Dst, uint8_t proto) +bool IP_Pkt_Check(size_t len, const void *data, size_t *ofs_out, size_t *len_out, int AF, const void *Src, const void *Dst, uint8_t proto) { size_t ofs; if( AF == 4 ) { @@ -105,6 +105,7 @@ bool IP_Pkt_Check(size_t len, const void *data, size_t *ofs_out, int AF, const v 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.TotalLength), >, (hdr.VerLen & 0xF) * 4); TEST_ASSERT_REL(ntohs(hdr.FragmentInfo), ==, 0); TEST_ASSERT_REL(hdr.TTL, >, 1); // >1 because there's no intervening hops @@ -112,7 +113,8 @@ bool IP_Pkt_Check(size_t len, const void *data, size_t *ofs_out, int AF, const v if(Src) TEST_ASSERT( memcmp(hdr.SrcAddr, Src, 4) == 0 ); if(Dst) TEST_ASSERT( memcmp(hdr.DstAddr, Dst, 4) == 0 ); - + + *len_out = ntohs(hdr.TotalLength) - sizeof(hdr); *ofs_out = ofs + (hdr.VerLen & 0xF) * 4; return true; }