Improve checksum calculation and address checking

1. Add a function that calculates the checksum of all the packet
   components starting from the specified position. This
   simplifies the code a bit and makes it easier to translate
   nested packets like ICMP error messages.

2. Don't hardcode IP source and destination addresses. This is
   required to translate ICMP error messages.

Bug: 8276725
Change-Id: I2cae45683ae3943e508608fd0a140180dbc60823
diff --git a/ipv4.c b/ipv4.c
index 1d34e1e..89e47e4 100644
--- a/ipv4.c
+++ b/ipv4.c
@@ -139,6 +139,6 @@
   }
 
   // Set the length.
-  ip6_targ->ip6_plen = htons(payload_length(out, pos));
+  ip6_targ->ip6_plen = htons(packet_length(out, pos));
   return iov_len;
 }