Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src Pull up revision 1.10 (requested by martti in ticket #106):



details:   https://anonhg.NetBSD.org/src/rev/822f71851835
branches:  netbsd-3
changeset: 575105:822f71851835
user:      tron <tron%NetBSD.org@localhost>
date:      Mon Apr 04 18:25:11 2005 +0000

description:
Pull up revision 1.10 (requested by martti in ticket #106):
Upgraded IPFilter to 4.1.8

diffstat:

 dist/ipf/ipf.h                |   6 +-
 dist/ipf/tools/ipfstat.c      |  78 ++++++++++++++++++++++++++++++++++++------
 regress/sys/kern/ipf/Makefile |   9 ++--
 3 files changed, 75 insertions(+), 18 deletions(-)

diffs (224 lines):

diff -r c4eaa008ab8c -r 822f71851835 dist/ipf/ipf.h
--- a/dist/ipf/ipf.h    Mon Apr 04 18:25:05 2005 +0000
+++ b/dist/ipf/ipf.h    Mon Apr 04 18:25:11 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipf.h,v 1.9 2005/02/19 21:30:24 martti Exp $   */
+/*     $NetBSD: ipf.h,v 1.9.2.1 2005/04/04 18:25:11 tron Exp $ */
 
 /*
  * Copyright (C) 1993-2001, 2003 by Darren Reed.
@@ -6,7 +6,7 @@
  * See the IPFILTER.LICENCE file for details on licencing.
  *
  * @(#)ipf.h   1.12 6/5/96
- * Id: ipf.h,v 2.71.2.5 2005/02/01 02:44:34 darrenr Exp
+ * Id: ipf.h,v 2.71.2.6 2005/02/21 05:05:29 darrenr Exp
  */
 
 #ifndef        __IPF_H__
@@ -196,7 +196,7 @@
 extern int fac_findname __P((char *));
 extern void fill6bits __P((int, u_int *));
 extern int gethost __P((char *, u_32_t *));
-extern int getport __P((struct frentry *, char *));
+extern int getport __P((struct frentry *, char *, u_short *));
 extern int getportproto __P((char *, int));
 extern int getproto __P((char *));
 extern char *getline __P((char *, size_t, FILE *, int *));
diff -r c4eaa008ab8c -r 822f71851835 dist/ipf/tools/ipfstat.c
--- a/dist/ipf/tools/ipfstat.c  Mon Apr 04 18:25:05 2005 +0000
+++ b/dist/ipf/tools/ipfstat.c  Mon Apr 04 18:25:11 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipfstat.c,v 1.9 2005/02/08 07:01:54 martti Exp $       */
+/*     $NetBSD: ipfstat.c,v 1.9.2.1 2005/04/04 18:25:11 tron Exp $     */
 
 /*
  * Copyright (C) 1993-2001, 2003 by Darren Reed.
@@ -70,7 +70,7 @@
 
 #if !defined(lint)
 static const char sccsid[] = "@(#)fils.c       1.21 4/20/96 (C) 1993-2000 Darren Reed";
-static const char rcsid[] = "@(#)Id: ipfstat.c,v 1.44.2.9 2004/12/09 19:41:26 darrenr Exp";
+static const char rcsid[] = "@(#)Id: ipfstat.c,v 1.44.2.11 2005/03/30 14:09:57 darrenr Exp";
 #endif
 
 #ifdef __hpux
@@ -107,8 +107,10 @@
 #define        STSORT_BYTES    2
 #define        STSORT_TTL      3
 #define        STSORT_SRCIP    4
-#define        STSORT_DSTIP    5
-#define        STSORT_MAX      STSORT_DSTIP
+#define        STSORT_SRCPT    5
+#define        STSORT_DSTIP    6
+#define        STSORT_DSTPT    7
+#define        STSORT_MAX      STSORT_DSTPT
 #define        STSORT_DEFAULT  STSORT_BYTES
 
 
@@ -153,7 +155,9 @@
 static int     sort_bytes __P((const void *, const void *));
 static int     sort_ttl __P((const void *, const void *));
 static int     sort_srcip __P((const void *, const void *));
+static int     sort_srcpt __P((const void *, const void *));
 static int     sort_dstip __P((const void *, const void *));
+static int     sort_dstpt __P((const void *, const void *));
 #endif
 
 
@@ -1175,10 +1179,18 @@
                                qsort(tstable, tsentry + 1,
                                      sizeof(statetop_t), sort_srcip);
                                break;
+                       case STSORT_SRCPT:
+                               qsort(tstable, tsentry +1,
+                                       sizeof(statetop_t), sort_srcpt);
+                               break;
                        case STSORT_DSTIP:
                                qsort(tstable, tsentry + 1,
                                      sizeof(statetop_t), sort_dstip);
                                break;
+                       case STSORT_DSTPT:
+                               qsort(tstable, tsentry + 1,
+                                     sizeof(statetop_t), sort_dstpt);
+                               break;
                        default:
                                break;
                        }
@@ -1257,9 +1269,15 @@
                case STSORT_SRCIP:
                        sprintf(str4, "src ip");
                        break;
+               case STSORT_SRCPT:
+                       sprintf(str4, "src port");
+                       break;
                case STSORT_DSTIP:
                        sprintf(str4, "dest ip");
                        break;
+               case STSORT_DSTPT:
+                       sprintf(str4, "dest port");
+                       break;
                default:
                        sprintf(str4, "unknown");
                        break;
@@ -1273,18 +1291,27 @@
                printw("Src: %s, Dest: %s, Proto: %s, Sorted by: %s\n\n",
                       str1, str2, str3, str4);
 
-               /* need at least 14 + 7 characters */
-               if (srclen < 14)
-                       srclen = 14;
-               if (dstlen < 14)
-                       dstlen = 14;
+               /* 
+                * For an IPv4 IP address we need at most 15 characters,
+                * 4 tuples of 3 digits, separated by 3 dots. Enforce this
+                * length, so the colums do not change positions based
+                * on the size of the IP address. This length makes the
+                * output fit in a 80 column terminal. 
+                * We are lacking a good solution for IPv6 addresses (that
+                * can be longer that 15 characters), so we do not enforce 
+                * a maximum on the IP field size.
+                */
+               if (srclen < 15)
+                       srclen = 15;
+               if (dstlen < 15)
+                       dstlen = 15;
 
                /* print column description */
                winy += 2;
                move(winy,0);
                attron(A_BOLD);
                printw("%-*s %-*s %3s %4s %7s %9s %9s\n",
-                      srclen + 7, "Source IP", dstlen + 7, "Destination IP",
+                      srclen + 6, "Source IP", dstlen + 6, "Destination IP",
                       "ST", "PR", "#pkts", "#bytes", "ttl");
                attroff(A_BOLD);
 
@@ -1313,7 +1340,7 @@
                        }
                        winy++;
                        move(winy, 0);
-                       printw("%-*s %-*s", srclen + 7, str1, dstlen + 7, str2);
+                       printw("%-*s %-*s", srclen + 6, str1, dstlen + 6, str2);
 
                        /* print state */
                        sprintf(str1, "%X/%X", tp->st_state[0],
@@ -1717,6 +1744,20 @@
        return -1;
 }
 
+static int sort_srcpt(a, b)
+const void *a;
+const void *b;
+{
+       register const statetop_t *ap = a;
+       register const statetop_t *bp = b;
+
+       if (htons(ap->st_sport) == htons(bp->st_sport))
+               return 0;
+       else if (htons(ap->st_sport) > htons(bp->st_sport))
+               return 1;
+       return -1;
+}
+
 static int sort_dstip(a, b)
 const void *a;
 const void *b;
@@ -1742,4 +1783,19 @@
        }
        return -1;
 }
+
+static int sort_dstpt(a, b)
+const void *a;
+const void *b;
+{
+       register const statetop_t *ap = a;
+       register const statetop_t *bp = b;
+
+       if (htons(ap->st_dport) == htons(bp->st_dport))
+               return 0;
+       else if (htons(ap->st_dport) > htons(bp->st_dport))
+               return 1;
+       return -1;
+}
+
 #endif
diff -r c4eaa008ab8c -r 822f71851835 regress/sys/kern/ipf/Makefile
--- a/regress/sys/kern/ipf/Makefile     Mon Apr 04 18:25:05 2005 +0000
+++ b/regress/sys/kern/ipf/Makefile     Mon Apr 04 18:25:11 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.9 2005/02/19 21:30:25 martti Exp $
+#      $NetBSD: Makefile,v 1.9.2.1 2005/04/04 18:25:11 tron Exp $
 #
 # (C)opyright 1993-1996 by Darren Reed.
 #
@@ -28,7 +28,7 @@
 
 ntests: n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12
 
-nitests: ni1 ni2 ni3 ni4 ni5 ni6 ni7 ni8 ni9 ni10 ni11 ni12
+nitests: ni1 ni2 ni3 ni4 ni5 ni6 ni7 ni8 ni9 ni10 ni11 ni12 ni13 ni14 ni15 ni16
 
 intests: in1 in2 in3 in4 in5 in6
 
@@ -56,7 +56,7 @@
        @${HOST_SH} ${.CURDIR}/nattest ${.CURDIR} \
                `${AWK} "/^$@ / { print; } " ${.CURDIR}/test.format`
 
-ni1 ni2 ni3 ni4 ni5 ni7 ni8 ni9 ni10 ni11 ni12:
+ni1 ni2 ni3 ni4 ni5 ni7 ni8 ni9 ni10 ni11 ni12 ni13 ni14 ni15 ni16:
        @${HOST_SH} ${.CURDIR}/natipftest ${.CURDIR} single \
                `${AWK} "/^$@ / { print; } " ${.CURDIR}/test.format`
 
@@ -92,7 +92,8 @@
        /bin/rm -f f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17
        /bin/rm -f i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15
        /bin/rm -f n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12
-       /bin/rm -f ni1 ni2 ni3 ni4 ni5 ni6 ni7 ni8 ni9 ni10 ni11 ni12
+       /bin/rm -f ni1 ni2 ni3 ni4 ni5 ni6 ni7 ni8 ni9
+       /bin/rm -f ni10 ni11 ni12 ni13 ni14 ni15 ni16
        /bin/rm -f in1 in2 in3 in4 in5 in6
        /bin/rm -f p1 p2 p3 ip1
        /bin/rm -f l1



Home | Main Index | Thread Index | Old Index