From 35ff384767249096b1acf71a11ed8ca7a966d6f7 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 21 Oct 2012 17:30:40 +0000 Subject: Ajout licence GPL, cleaning du vieux code, ajout options --help -H et -v (verbose) git-svn-id: file:///var/svn/2012-tzsp/trunk@11 147d2d3d-d0bd-48ea-923a-d90ac20f5906 --- pcap2tzsp.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'pcap2tzsp.c') diff --git a/pcap2tzsp.c b/pcap2tzsp.c index e84f5bf..29687bb 100644 --- a/pcap2tzsp.c +++ b/pcap2tzsp.c @@ -1,5 +1,25 @@ -/* Library dependencies : - libpcap (sudo apt-get install libpcap0.8-dev) +/* + + Pcap2tzsp allows to capture ethernet trafic and send all headers + to a defined host using the TaZmen Sniffing Protocol (TZSP). + + Copyright (C) 2012 Ludovic Pouzenc + + 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 . + + + This file is part of Pcap2tzsp. See LICENCE file. */ /* Basics */ @@ -13,8 +33,6 @@ #include /* UDP stuff */ -/*#include -#include no longer used */ #include #include #include @@ -48,10 +66,9 @@ #define NI_MAXHOST_NUMERIC 40 /* TODO List - * Resolution DNS host -> IP (c'est l'ip qu'il faut dans le filtre et pas le host !!) * Implémenter une bwlimit en sortie (ptks/s et/ou bytes/s) - * TZSP over IPv6 (le filter doit avoir le dst qui va bien , pas le nom, l'adresse) - * getopts -v et --help + * Version qui compile sous Windows + * Calcul dynamique de MAX_TZSP_PAYLOAD * Licence GPL */ @@ -117,6 +134,7 @@ int main(int argc, char *argv[]) { {"brief", no_argument, &opt_verbose, 0}, /* These options don't set a flag. We distinguish them by their indices. */ + {"help", no_argument, 0, 'H'}, {"interface", required_argument, 0, 'i'}, {"host", required_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, @@ -126,7 +144,7 @@ int main(int argc, char *argv[]) { /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "i:h:p:s:", long_options, &option_index); + c = getopt_long(argc, argv, "i:h:p:s:v", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; @@ -145,6 +163,8 @@ int main(int argc, char *argv[]) { case 'h': opt_host= strdup(optarg); break; case 'p': opt_port= strdup(optarg); break; case 's': opt_snaplen= strdup(optarg); break; + case 'v': opt_verbose= 1; break; + case 'H': case '?': /* getopt_long already printed an error message. */ usage(basename(argv[0])); @@ -294,6 +314,7 @@ void start_capture_loop(char *pcap_filter) { fprintf(stderr, "ERROR : Couldn't make a socket to %s:%s\n", opt_host, opt_port); exit(10); } + if (opt_verbose) printf("Socket opened with the following destination : %s:%s\n", resolved_address, opt_port); /* pcap init */ if (opt_verbose) printf("Opening device %s for capturing\n", pcap_device); @@ -348,7 +369,6 @@ void start_capture_loop(char *pcap_filter) { pcap_close(pcap_handle); close(process_packet_args.socket); - //XXX freeaddrinfo(target_addrinfo); } -- cgit v1.2.3