[BACK]Return to patch-ai CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / net / sniffit / patches

File: [cvs.NetBSD.org] / pkgsrc / net / sniffit / patches / patch-ai (download)

Revision 1.3, Fri Jan 11 00:02:13 2013 UTC (7 years, 7 months ago) by joerg
Branch: MAIN
CVS Tags: pkgsrc-2020Q2-base, pkgsrc-2020Q2, pkgsrc-2020Q1-base, pkgsrc-2020Q1, pkgsrc-2019Q4-base, pkgsrc-2019Q4, pkgsrc-2019Q3-base, pkgsrc-2019Q3, pkgsrc-2019Q2-base, pkgsrc-2019Q2, pkgsrc-2019Q1-base, pkgsrc-2019Q1, pkgsrc-2018Q4-base, pkgsrc-2018Q4, pkgsrc-2018Q3-base, pkgsrc-2018Q3, pkgsrc-2018Q2-base, pkgsrc-2018Q2, pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1, pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4, pkgsrc-2015Q3-base, pkgsrc-2015Q3, pkgsrc-2015Q2-base, pkgsrc-2015Q2, pkgsrc-2015Q1-base, pkgsrc-2015Q1, pkgsrc-2014Q4-base, pkgsrc-2014Q4, pkgsrc-2014Q3-base, pkgsrc-2014Q3, pkgsrc-2014Q2-base, pkgsrc-2014Q2, pkgsrc-2014Q1-base, pkgsrc-2014Q1, pkgsrc-2013Q4-base, pkgsrc-2013Q4, pkgsrc-2013Q3-base, pkgsrc-2013Q3, pkgsrc-2013Q2-base, pkgsrc-2013Q2, pkgsrc-2013Q1-base, pkgsrc-2013Q1, HEAD
Changes since 1.2: +11 -2 lines

PCAP handler callback is void.

$NetBSD: patch-ai,v 1.3 2013/01/11 00:02:13 joerg Exp $

- use standard headers
- fix signature of signal handler, make it file-static
- fix signature of pcap handler
- make const declarations internally consistent
- CORRUPT_IP/DONT_EXAMINE changes from a long time ago

--- sniffit.0.3.5.c.orig	1997-04-18 09:33:58.000000000 +0000
+++ sniffit.0.3.5.c
@@ -7,6 +7,8 @@
 #include <unistd.h>
 #include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <netdb.h>
 #include <errno.h>
 #include <sys/stat.h>
@@ -93,7 +95,7 @@ printf("    9 -- %s\n",PLUGIN9_NAME);
 exit(0); 
 }
 
-void my_exit (void)	{	exit(0);};
+static void my_exit (int sig)	{	exit(0);};
 
 /* DEBUGGING INFO */
 #ifdef DEBUG
@@ -298,7 +300,7 @@ struct file_info *search_dynam(char *fil
 
 /* Type 0: TELNET  */
 void record_buf(struct file_info *dummy_pointer, unsigned long cur_seq_nr, 
-						     char *data, int len, int type) 
+						     const char *data, int len, int type) 
 {
 int i,j,noloop=0;
 
@@ -337,7 +339,7 @@ for(i=1;i<SCBUF;i++)
 }
 
 void sbuf_update(struct file_info *dummy_pointer, unsigned long cur_seq_nr, 
-							      char *data, int len) 
+							      const char *data, int len) 
 {
 int i;
 
@@ -411,11 +413,17 @@ int check_packet(unsigned long ipaddr,
 	proto=unwrap_packet(sp, info); 
 	if(proto == NO_IP)	return DONT_EXAMINE; /* no use in trying */
 	if(proto == NO_IP_4)	return DONT_EXAMINE; /* no use in trying */
+	if(proto == CORRUPT_IP)	
+	  {printf("Suspicious Packet detected... (Split header)\n");
+	   return DONT_EXAMINE;}
 
         memcpy(&iphead,(sp+PROTO_HEAD),sizeof(struct IP_header));
 	so=(unsigned char *)&(iphead.source);
        	dest=(unsigned char *)&(iphead.destination);
 
+	if(info->FRAG_nf!=0)
+	  {printf("Fragment Skipped...\n"); return DONT_EXAMINE; };
+
 	if((proto==TCP)&&(PROTOCOLS&F_TCP)) 
 		{
 #ifdef DEBUG_ONSCREEN
@@ -823,7 +831,7 @@ printf("Selected: %d\n",selected);
 }
 
 /* Default Processing of packets */
-pcap_handler packethandler(unsigned char *ipaddrpoint, 
+void packethandler(unsigned char *ipaddrpoint, 
 			const struct packetheader *p_header, 
 			const unsigned char *sp) 
 { 
@@ -1220,6 +1228,10 @@ int check_mask (const struct packetheade
 	proto=unwrap_packet(sp, info);
 	if(proto == NO_IP)	return DONT_EXAMINE; /* no use in trying */
 	if(proto == NO_IP_4)	return DONT_EXAMINE; /* no use in trying */
+	if(proto == CORRUPT_IP)	return DONT_EXAMINE; /* no use in trying */
+
+	if(info->FRAG_nf!=0)
+	  {return DONT_EXAMINE; };
 
 	(*IP_nr_of_packets)++;
 	if(proto==ICMP)  
@@ -1272,7 +1284,7 @@ int check_mask (const struct packetheade
 	return TCP_EXAMINE;                            /* interprete packet */
 }
 
-pcap_handler interactive_packethandler(	char *dummy, 
+void interactive_packethandler(	unsigned char *dummy, 
 			 	const struct packetheader *p_header, 
 				const unsigned char *sp) 
 {