/******************************************************************************
Author: Samuel Jero
-Date: 7/2011
+Date: 11/2011
Description: Program to convert a DCCP flow to a TCP flow for DCCP analysis via
tcptrace.
1)CCID2 ONLY
2)DCCP MUST use 48 bit sequence numbers
3)Checksums are not computed (they are zeroed)
- 4)Only implements those packet types normally used in a session
+ 4)DCCP DATA packets are not implemented (Linux doesn't use them)
5)DCCP Ack packets show up as TCP packets containing one byte
- 6)Very little error checking of packet headers
******************************************************************************/
#include "dccp2tcp.h"
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);
/*loop through commandline options*/
for(int i=1; i < argc; i++){
- if(argv[i][0]!='-'){
- if(dfile==NULL){ /*assign first non-dash argument to the dccp file*/
+ if(argv[i][0]!='-' || (argv[i][0]=='-' && strlen(argv[i])==1)){
+ if(dfile==NULL || argv[i][0]=='-'){
+ /*assign first non-dash (or only dash) argument to the dccp file*/
dfile=argv[i];
}else{
if(tfile==NULL){
/*close files*/
pcap_close(in);
pcap_dump_close(out);
+
+ /*Delete all connections*/
+ cleanup_connections();
return 0;
}
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;
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;
/* 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;
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;
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*/
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*/