******************************************************************************/
#include "ltp2tcp.h"
-
+#define LTPTRACE_VERSION 0.3
+#define COPYRIGHT_YEAR 2013
int debug=0;
int MAX_SESSION=500000;
int claim2sack(const u_char* odata, int ses_id, struct ltp_hdr_d* ltph, struct tcphdr *tcph, u_char* tcpopt, int* dlen, int rbuf);
int seq_from_session(struct ltp_hdr_d* ltph, struct tcphdr *tcph);
int ack_from_session(struct ltp_hdr_d* ltph, struct tcphdr *tcph);
+void version();
+void usage();
/*Parse commandline options and open files*/
int tmp;
/*parse commandline options*/
- if(argc<4 || argc > 8){
- printf("Usage: ltp2tcp -t{encapsulation} ltp_file tcp_file [-d] [-b{block_size}]\n");
- exit(1);
+ if(argc < 2){
+ usage();
}
/*loop through commandline options*/
for(int i=1; i < argc; i++){
- if(argv[i][0]!='-'){
- if(lfile==NULL){ /*assign first non-dash argument to the ltp file*/
+ if(argv[i][0]!='-' || (argv[i][0]=='-' && strlen(argv[i])==1)){
+ if(lfile==NULL || argv[i][0]=='-'){
+ /*assign first non-dash (or only dash) argument to the dccp file*/
lfile=argv[i];
}else{
if(tfile==NULL){
tfile=argv[i]; /*assign second non-dash argument to the dccp file*/
}else{
- printf("Usage: ltp2tcp -t{encapsulation} ltp_file tcp_file [-d] [-b{block_size}]\n");
- exit(1);
+ usage();
}
}
}else{
- if(argv[i][1]=='d' && strlen(argv[i])==2){ /*debug option*/
+ if(argv[i][1]=='v' && strlen(argv[i])==2){ /*debug option*/
debug++;
}
+ if(argv[i][1]=='V' && strlen(argv[i])==2){ /*Version option*/
+ version();
+ }
+ if(argv[i][1]=='h'&& strlen(argv[i])==2){ /* help*/
+ usage();
+ }
if(argv[i][1]=='t'){ /*Encapsulation option*/
type=&argv[i][2];
}
if(tmp>0){
MAX_SESSION=tmp;
}else{
- printf("Usage: ltp2tcp -t{encapsulation} ltp_file tcp_file [-d] [-b{block_size}]\n");
- exit(1);
+ usage();
}
}
if(argv[i][1]=='s'){ /*Session range option*/
}
if(lfile==NULL || tfile==NULL || type==NULL){
- printf("Usage: ltp2tcp -t{encapsulation} ltp_file tcp_file [-d] [-b{block_size}]\n");
- exit(1);
+ usage();
}
if(state.ses_min<=0 || state.ses_max<=0){
/*all options validated*/
if(debug){
- dbgprintf(1,"Debug On\n");
dbgprintf(1,"Input file: %s\n", lfile);
dbgprintf(1,"Output file: %s\n", tfile);
dbgprintf(1,"Encapsulation: %s\n", type);
return 0;
}
+void version()
+{
+ dbgprintf(0, "ltp2tcp version %.1f\n",LTPTRACE_VERSION);
+ dbgprintf(0, "Copyright (C) %i Samuel Jero <sj323707@ohio.edu>\n",COPYRIGHT_YEAR);
+ dbgprintf(0, "This program comes with ABSOLUTELY NO WARRANTY.\n");
+ dbgprintf(0, "This is free software, and you are welcome to\n");
+ dbgprintf(0, "redistribute it under certain conditions.\n");
+ exit(0);
+}
+
+/*Usage information for program*/
+void usage()
+{
+ dbgprintf(0,"Usage: ltp2tcp -t{encapsulation} [-v] [-V] [-h] [-b{block_size}] [-s{start session}-{end session}] ltp_file tcp_file\n");
+ dbgprintf(0, " -v verbose. May be repeated for additional verbosity.\n");
+ dbgprintf(0, " -V Version information\n");
+ dbgprintf(0, " -h Help\n");
+ dbgprintf(0, " -t type of encapsulation (udp,dccp,sll)\n");
+ dbgprintf(0, " -b LTP block size (NOT the bundle size) that is being used over this connection\n");
+ dbgprintf(0, " -s Requests a graph of only the specified range of sessions\n");
+ exit(0);
+}
+
/*Debug Printf*/
void dbgprintf(int level, const char *fmt, ...)
{