]> sjero.net Git - dccp2tcp/blobdiff - encap.c
Cleanup types throughout code
[dccp2tcp] / encap.c
diff --git a/encap.c b/encap.c
index 1153e0638e9a6cf4f1498bd7c14521124e6f3263..4cda535226eff16ba7f84b9924f2f05fc82d869d 100644 (file)
--- a/encap.c
+++ b/encap.c
@@ -1,13 +1,28 @@
 /******************************************************************************
-Author: Samuel Jero
+Utility to convert a DCCP flow to a TCP flow for DCCP analysis via
+               tcptrace. Encapsulation Functions for DCCP conversion to TCP.
 
-Date: 11/2012
+Copyright (C) 2012  Samuel Jero <sj323707@ohio.edu>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
-Description: Encapsulation Functions for DCCP conversion to TCP
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+Author: Samuel Jero <sj323707@ohio.edu>
+Date: 11/2012
 ******************************************************************************/
 #include "dccp2tcp.h"
 #include "encap.h"
+#include "checksums.h"
 #include <pcap/sll.h>
 #include <netinet/ip6.h>
 
@@ -171,7 +186,7 @@ int ipv6_encap(struct packet *new, const struct const_packet *old)
                }
 
                /*Adjust IPv6 header to account for packet's total length*/
-               iph->ip6_ctlun.ip6_un1.ip6_un1_plen=htons(new->length);
+               iph->ip6_ctlun.ip6_un1.ip6_un1_plen=htons(nnew.length);
 
                /*Adjust length*/
                new->length=nnew.length + sizeof(struct ip6_hdr);
@@ -258,6 +273,10 @@ int ipv4_encap(struct packet *new, const struct const_packet *old)
                /*Adjust IPv4 header to account for packet's total length*/
                iph->tot_len=htons(new->length);
 
+               /*Compute IPv4 Checksum*/
+               iph->check=0;
+               iph->check=ipv4_chksum(new->data,iph->ihl*4);
+
                /*Cleanup*/
                free(nnew.src_id);
                free(nnew.dest_id);