X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=encap.c;h=4cda535226eff16ba7f84b9924f2f05fc82d869d;hb=e70482b21708ed411b4403c8a155f345a4868fdf;hp=1153e0638e9a6cf4f1498bd7c14521124e6f3263;hpb=5d65c31ba16de1a71d2f54e40f2494e121d6836e;p=dccp2tcp diff --git a/encap.c b/encap.c index 1153e06..4cda535 100644 --- 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 + +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 . +Author: Samuel Jero +Date: 11/2012 ******************************************************************************/ #include "dccp2tcp.h" #include "encap.h" +#include "checksums.h" #include #include @@ -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);