X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=dccp2tcp.c;h=dbd90dfc39832683cacbefdefdd7202add5f7f63;hb=55c388bacaff0cff07ddebc423a16c7d728acba3;hp=9b1990f42ca6fa5e5e8ee4fc22b23bd0cd36c60d;hpb=2fe0f8f190fb8f52d9f213d84f34059df2247941;p=dccp2tcp diff --git a/dccp2tcp.c b/dccp2tcp.c index 9b1990f..dbd90df 100644 --- a/dccp2tcp.c +++ b/dccp2tcp.c @@ -33,7 +33,7 @@ void process_packets(); void handle_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes); int convert_packet(struct packet *new, const struct const_packet* old); unsigned int interp_ack_vect(u_char* hdr); -u_int32_t initialize_seq(struct host *seq, __be16 source, __be32 initial); +u_int32_t initialize_seq(struct host *seq, __be32 initial); u_int32_t add_new_seq(struct host *seq, __be32 num, int size, enum dccp_pkt_type type); u_int32_t convert_ack(struct host *seq, __be32 num); int acked_packet_size(struct host *seq, __be32 num); @@ -131,6 +131,9 @@ int main(int argc, char *argv[]) /*close files*/ pcap_close(in); pcap_dump_close(out); + + /*Delete all connections*/ + cleanup_connections(); return 0; } @@ -260,7 +263,7 @@ int convert_packet(struct packet *new, const struct const_packet* old) tcph->window=htons(0); } tcph->ack_seq=htonl(0); - tcph->seq=htonl(initialize_seq(h1, dccph->dccph_sport, ntohl(dccphex->dccph_seq_low))); + tcph->seq=htonl(initialize_seq(h1, ntohl(dccphex->dccph_seq_low))); tcph->syn=1; tcph->ack=0; tcph->fin=0; @@ -287,7 +290,7 @@ int convert_packet(struct packet *new, const struct const_packet* old) if(yellow){ tcph->window=htons(0); } - tcph->seq=htonl(initialize_seq(h1, dccph->dccph_sport, ntohl(dccphex->dccph_seq_low))); + tcph->seq=htonl(initialize_seq(h1, ntohl(dccphex->dccph_seq_low))); tcph->syn=1; tcph->ack=1; tcph->fin=0; @@ -570,7 +573,7 @@ return additional; /* Setup Sequence Number Structure*/ -u_int32_t initialize_seq(struct host *seq, __be16 source, __be32 initial) +u_int32_t initialize_seq(struct host *seq, __be32 initial) { /*set default values*/ seq->cur=0; @@ -604,13 +607,18 @@ u_int32_t add_new_seq(struct host *seq, __be32 num, int size, enum dccp_pkt_type if(seq->table==NULL){ dbgprintf(1, "Warning: Connection uninitialized\n"); - return initialize_seq(seq, 0, num); + return initialize_seq(seq, num); } /*account for missing packets*/ + if(num - seq->table[seq->cur].old +1 >=100){ + dbgprintf(1,"Missing more than 100 packets!\n"); + } while(seq->table[seq->cur].old +1 < num && seq->table[seq->cur].old +1 > 0){ prev=seq->cur; - dbgprintf(1,"Missing Packet: %X\n",seq->table[prev].new+1); + if(num - seq->table[seq->cur].old +1 <100){ + dbgprintf(1,"Missing Packet: %X\n",seq->table[prev].new+1); + } seq->cur=(seq->cur+1)%(seq->size);/*find next available table slot*/ seq->table[seq->cur].old=seq->table[prev].old+1; seq->table[seq->cur].new=seq->table[prev].new + seq->table[prev].size; @@ -651,7 +659,7 @@ u_int32_t convert_ack(struct host *seq, __be32 num) if(seq->table==NULL){ dbgprintf(1, "Warning: Connection uninitialized\n"); - initialize_seq(seq, 0, num); + initialize_seq(seq, num); } /*loop through table looking for the DCCP ack number*/ @@ -676,7 +684,7 @@ int acked_packet_size(struct host *seq, __be32 num) if(seq->table==NULL){ dbgprintf(1, "Warning: Connection uninitialized\n"); - initialize_seq(seq, 0, num); + initialize_seq(seq, num); } /*loop through table looking for the DCCP ack number*/