From fc73cf5578f2f8d8cca3b8ffa2a6d5eea412ed69 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 20 Oct 2012 19:43:39 +0000 Subject: Amélioration de la gestion des min/max de la taille de capture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2012-tzsp/trunk@5 147d2d3d-d0bd-48ea-923a-d90ac20f5906 --- pcap2tzsp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pcap2tzsp.c b/pcap2tzsp.c index 50b31c4..ec9264a 100644 --- a/pcap2tzsp.c +++ b/pcap2tzsp.c @@ -26,9 +26,15 @@ /* 70 bytes captured packets will to sent in ~128 bytes frames when encapsulated */ #define UDP_SEND_BUFLEN 1500 -#define MAX_TZSP_PAYLOAD (1500-40-16) +/* MAX_TZSP_PAYLOAD is for not trying to send TZSP packets greater than the interface MTU + MAX_TZSP_PAYLOAD = MTU - IP header - UDP header - TZSP header + I am assuming the following : + - Layer 2 overhead is the same for the captured packet and the transmitted packet + - MTU is assumed to be 1500 for now +*/ +#define MAX_TZSP_PAYLOAD (1500-20-8-16) #define MIN_BYTES_TO_CAPTURE 16 -#define MAX_BYTES_TO_CAPTURE (1500-40-16) +#define MAX_BYTES_TO_CAPTURE (1500-20-8-16) /* @@ -197,7 +203,7 @@ void capture_loop(char pcap_filter[]) { snaplen=atoi(opt_snaplen); if ( snaplen < MIN_BYTES_TO_CAPTURE || snaplen > MAX_BYTES_TO_CAPTURE ) { - fprintf(stderr, "snaplen of %i is not in the allowedrange of [%i..%i]", snaplen, MIN_BYTES_TO_CAPTURE, MAX_BYTES_TO_CAPTURE); + fprintf(stderr, "snaplen of %i is not in the allowed range of [%i..%i]\n", snaplen, MIN_BYTES_TO_CAPTURE, MAX_BYTES_TO_CAPTURE); exit(12); } -- cgit v1.2.3