]> sjero.net Git - ltp2tcp/commitdiff
Updated commandline args: Added -V for version, -h for help, changed -d to -v for...
authorSamuel Jero <sj323707@ohio.edu>
Fri, 28 Jun 2013 18:13:16 +0000 (14:13 -0400)
committerSamuel Jero <sj323707@ohio.edu>
Fri, 28 Jun 2013 18:13:16 +0000 (14:13 -0400)
Updated program name to ltp2tcp

.project
LICENSE
Makefile
README
ltp2tcp.c

index 3572e091c5568808024c66f6e7e11d84a0f11e66..0c8d98e197fd8102b1d61725113ade6ca77c8714 100644 (file)
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>ltptrace</name>
+       <name>ltp2tcp</name>
        <comment></comment>
        <projects>
        </projects>
diff --git a/LICENSE b/LICENSE
index 94a9ed024d3859793618152ea559a168bbcbb5e2..e587591e143165eb560c2385f0652ac369fc6595 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -618,57 +618,4 @@ an absolute waiver of all civil liability in connection with the
 Program, unless a warranty or assumption of liability accompanies a
 copy of the Program in return for a fee.
 
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    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.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+                     END OF TERMS AND CONDITIONS
\ No newline at end of file
index 60ca81bae7bfdba2a88188793d89cd5d7b8d24ce..4cb99c2281ceace362b5bd43497061718d93a1c9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
 ###############################################################################
 #Author: Samuel Jero
 #
-# Date: 12/2010
+# Date: 6/2013
 #
-# Makefile for program ltptrace
+# Makefile for program ltp2tcp
 ###############################################################################
 
 CFLAGS= -O2 -Wall -Werror
@@ -20,10 +20,10 @@ BINDIR = /usr/local/bin
 MANDIR = /usr/local/man
 
 
-all: ltptrace
+all: ltp2tcp
 
-ltptrace: main.o ltp.o encap.o udp.o dccp.o sll.o Makefile
-       gcc ${CFLAGS} ${LDLIBS} --std=gnu99 main.o ltp.o encap.o udp.o dccp.o sll.o -oltptrace
+ltp2tcp: main.o ltp.o encap.o udp.o dccp.o sll.o Makefile
+       gcc ${CFLAGS} ${LDLIBS} --std=gnu99 main.o ltp.o encap.o udp.o dccp.o sll.o -oltp2tcp
        
 main.o: ltp2tcp.c ltp2tcp.h
        gcc -c ${CFLAGS} ${LDLIBS} --std=gnu99 ltp2tcp.c -omain.o
@@ -45,12 +45,12 @@ sll.o: sll_encap.c encap.h ltp2tcp.h
 
 
 install: ltptrace
-       install -m 755 -o bin -g bin ltptrace ${BINDIR}/ltptrace
-#      install -m 444 -o bin -g bin ltptrace.1 ${MANDIR}/man1/ltptrace.1
+       install -m 755 -o bin -g bin ltptrace ${BINDIR}/ltp2tcp
+#      install -m 444 -o bin -g bin ltptrace.1 ${MANDIR}/man1/ltp2tcp.1
 
 uninstall:
-       rm -f ${BINDIR}/ltptrace
-#      rm -f ${MANDIR}/man1/ltptrace.1
+       rm -f ${BINDIR}/ltp2tcp
+#      rm -f ${MANDIR}/man1/ltp2tcp.1
 
 clean:
-       rm -f *~ ltptrace core *.o
+       rm -f *~ ltp2tcp core *.o
diff --git a/README b/README
index 32970daafe1cc8923bf2c294d4191be8e2416985..3b95989541b2d24778c9bde2d4874d8d7539d462 100644 (file)
--- a/README
+++ b/README
@@ -8,19 +8,21 @@ In order to build this program, please simply type make at the commandline. I ha
 included a ./configure script at this time. Contact me, if major problems arise.
 
 Usage is as follows:
-ltptrace -t{encapsulation} ltp_file tcp_file [-d] [-b{block_size}] [-s{start session}-{end session}]
-       -d is debug (repeat for additional verbosity)
-       -t specifies what protocol LTP is encapsulated in.  Right now, only udp and dccp are supported.
-       -b specifies the LTP block size (NOT the bundle size) that is being used over this connection.
+ltp2tcp -t{encapsulation} [-v] [-V] [-h] [-b{block_size}] [-s{start session}-{end session}] ltp_file tcp_file
+       -v  verbose (repeat for additional verbosity)
+       -V      Version information
+       -h  Help
+    -t The protocol LTP is encapsulated in.  Right now, only udp, dccp, and sll are supported.
+    -b  The LTP block size (NOT the bundle size) that is being used over this connection.
                This information can't be determined from a packet capture, so if not specified
                it defaults to is 500,000. If you set this value larger than your actual block size, the graph
-               will contain empty spaces between each session, which is handy to separate sessions. However, in that case, tcptrace will report 
-               inaccurate, lost data statistics.
-       -s requests a graph of only the specified range of sessions. Note that the session numbers are just the "session number"
+               will contain empty spaces between each session, which is handy to separate sessions. However, in
+               that case, tcptrace will report inaccurate, lost data statistics.
+       -s  Requests a graph of only the specified range of sessions. Note that the session numbers are just the "session number"
                from wireshark, not the whole session id.
 
 To generate the graphs run:
-       ltptrace -tudp ltp_file.dmp tcp_file.dmp
+       ltp2tcp -tudp ltp_file.dmp tcp_file.dmp
        tcptrace -lGt tcp_file.dmp
        xplot a2b_tsg.xpl
 
@@ -51,25 +53,25 @@ Limitations:
        1)Only handles one LTP "connection". There isn't a good way to separate
                different LTP "connections" from new sessions of the same "connection".
                Use Tcpdump filters to separate connections. Libpcap filtering could also
-               be added in ltptrace.
+               be added in ltp2tcp.
        2)Uses some special types from Linux (u_char, u_int32_t)
 
 
-ltptrace is free software: you can redistribute it and/or modify
+ltp2tcp 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.
 
-ltptrace is distributed in the hope that it will be useful,
+ltp2tcp 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.
 
 You should have received a copy of the GNU General Public License
-along with ltptrace.  If not, see <http://www.gnu.org/licenses/>.
+along with ltp2tcp.  If not, see <http://www.gnu.org/licenses/>.
 
 Samuel Jero
 Internetworking Research Group
 Ohio University
 sj323707@ohio.edu
-2/23/2011
+6/28/2013
index e0a63f08cb127259f8a96117b296fce5b2219443..db8e08866e89badc097cea5f0b3f3286db155c1c 100644 (file)
--- a/ltp2tcp.c
+++ b/ltp2tcp.c
@@ -28,7 +28,8 @@ Notes:
 ******************************************************************************/
 #include "ltp2tcp.h"
 
-
+#define LTPTRACE_VERSION 0.3
+#define COPYRIGHT_YEAR 2013
 
 int debug=0;
 int MAX_SESSION=500000;
@@ -45,6 +46,8 @@ int handle_report(const u_char* odata, struct ltp_hdr_d* ltph, struct tcphdr *tc
 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*/
@@ -59,28 +62,33 @@ int main(int argc, char *argv[])
        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];
                        }
@@ -89,8 +97,7 @@ int main(int argc, char *argv[])
                                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*/
@@ -102,8 +109,7 @@ int main(int argc, char *argv[])
        }
        
        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){
@@ -114,7 +120,6 @@ int main(int argc, char *argv[])
        /*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);
@@ -895,6 +900,29 @@ int ack_from_session(struct ltp_hdr_d* ltph, struct tcphdr *tcph)
 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, ...)
 {