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/clatd.c b/clatd.c
index 8dddc96..a914f02 100644
--- a/clatd.c
+++ b/clatd.c
@@ -333,11 +333,11 @@
   if(ntohs(tun_header->proto) == ETH_P_IP) {
     fd = tunnel->fd6;
     fill_tun_header(&tun_targ, ETH_P_IPV6);
-    iov_len = ipv4_packet(out, POS_IPHDR, packet, packetsize);
+    iov_len = ipv4_packet(out, CLAT_POS_IPHDR, packet, packetsize);
   } else if(ntohs(tun_header->proto) == ETH_P_IPV6) {
     fd = tunnel->fd4;
     fill_tun_header(&tun_targ, ETH_P_IP);
-    iov_len = ipv6_packet(out, POS_IPHDR, packet, packetsize);
+    iov_len = ipv6_packet(out, CLAT_POS_IPHDR, packet, packetsize);
   } else {
     logmsg(ANDROID_LOG_WARN,"packet_handler: unknown packet type = %x",tun_header->proto);
   }