make test: unify packet checksum verifications
Change-Id: If9cc7c5e32ebecff398fd38b39e8f485754a4ad4
Signed-off-by: Klement Sekera <ksekera@cisco.com>
diff --git a/test/test_ipsec_nat.py b/test/test_ipsec_nat.py
index 9c22fbb..cebbfc8 100644
--- a/test/test_ipsec_nat.py
+++ b/test/test_ipsec_nat.py
@@ -84,29 +84,10 @@
ICMP(id=self.icmp_id_out, type='echo-request'))
]
- def check_checksum(self, pkt, layer):
- """ Check checksum of the packet on given layer """
- new = pkt.__class__(str(pkt))
- del new[layer].chksum
- new = new.__class__(str(new))
- self.assertEqual(new[layer].chksum, pkt[layer].chksum)
-
- def check_ip_checksum(self, pkt):
- return self.check_checksum(pkt, 'IP')
-
- def check_tcp_checksum(self, pkt):
- return self.check_checksum(pkt, 'TCP')
-
- def check_udp_checksum(self, pkt):
- return self.check_checksum(pkt, 'UDP')
-
- def check_icmp_checksum(self, pkt):
- return self.check_checksum(pkt, 'ICMP')
-
def verify_capture_plain(self, capture):
for packet in capture:
try:
- self.check_ip_checksum(packet)
+ self.assert_packet_checksums_valid(packet)
self.assert_equal(packet[IP].src, self.pg0.remote_ip4,
"decrypted packet source address")
self.assert_equal(packet[IP].dst, self.pg1.remote_ip4,
@@ -117,7 +98,6 @@
"unexpected UDP header in decrypted packet")
self.assert_equal(packet[TCP].dport, self.tcp_port_in,
"decrypted packet TCP destination port")
- self.check_tcp_checksum(packet)
elif packet.haslayer(UDP):
if packet[UDP].payload:
self.assertFalse(
@@ -131,7 +111,6 @@
"unexpected UDP header in decrypted packet")
self.assert_equal(packet[ICMP].id, self.icmp_id_in,
"decrypted packet ICMP ID")
- self.check_icmp_checksum(packet)
except Exception:
self.logger.error(
ppp("Unexpected or invalid plain packet:", packet))