Source-Changes-HG archive

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

[src/netbsd-1-5]: src/dist/ipf Pull up revisions 1.1.1.3-1.1.1.4 (requested b...



details:   https://anonhg.NetBSD.org/src/rev/05338175c80f
branches:  netbsd-1-5
changeset: 492678:05338175c80f
user:      he <he%NetBSD.org@localhost>
date:      Sat Feb 09 16:55:28 2002 +0000

description:
Pull up revisions 1.1.1.3-1.1.1.4 (requested by martti):
  Updated IPFilter to 3.4.23

diffstat:

 dist/ipf/common.c |  76 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 32 deletions(-)

diffs (172 lines):

diff -r 4221f053904d -r 05338175c80f dist/ipf/common.c
--- a/dist/ipf/common.c Sat Feb 09 16:55:26 2002 +0000
+++ b/dist/ipf/common.c Sat Feb 09 16:55:28 2002 +0000
@@ -1,11 +1,9 @@
-/*     $NetBSD: common.c,v 1.1.1.2 2000/05/11 19:49:13 veego Exp $     */
+/*     $NetBSD: common.c,v 1.1.1.2.4.1 2002/02/09 16:55:28 he Exp $    */
 
 /*
- * Copyright (C) 1993-2000 by Darren Reed.
+ * Copyright (C) 1993-2001 by Darren Reed.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and due credit is given
- * to the original author and the contributors.
+ * See the IPFILTER.LICENCE file for details on licencing.
  */
 #include <sys/types.h>
 #if !defined(__SVR4) && !defined(__svr4__)
@@ -48,19 +46,16 @@
 
 extern struct  ipopt_names     ionames[], secclass[];
 extern int     opts;
-#ifdef USE_INET6
 extern int     use_inet6;
-#endif
 
 
 char   *proto = NULL;
-char   flagset[] = "FSRPAU";
-u_char flags[] = { TH_FIN, TH_SYN, TH_RST, TH_PUSH, TH_ACK, TH_URG };
+char   flagset[] = "FSRPAUEC";
+u_char flags[] = { TH_FIN, TH_SYN, TH_RST, TH_PUSH, TH_ACK, TH_URG,
+                   TH_ECN, TH_CWR };
 
-#ifdef USE_INET6
 void fill6bits __P((int, u_32_t *));
 int count6bits __P((u_32_t *));
-#endif
 
 static char    thishost[MAXHOSTNAMELEN];
 
@@ -98,30 +93,24 @@
                 * set x most significant bits
                 */
                bits = (int)strtol(msk, &endptr, 0);
-#ifdef USE_INET6
                if ((*endptr != '\0') ||
                    ((bits > 32) && !use_inet6) || (bits < 0) ||
                    ((bits > 128) && use_inet6))
-#else
-               if (*endptr != '\0' || bits > 32 || bits < 0)
-#endif
                        return -1;
-#ifdef USE_INET6
                if (use_inet6)
                        fill6bits(bits, mskp);
-               else
-#endif
-               if (bits == 0)
-                       *mskp = 0;
-               else
-                       *mskp = htonl(0xffffffff << (32 - bits));
+               else {
+                       if (bits == 0)
+                               *mskp = 0;
+                       else
+                               *mskp = htonl(0xffffffff << (32 - bits));
+               }
        }
        return 0;
 }
 
 
 
-#ifdef USE_INET6
 void fill6bits(bits, msk)
 int bits;
 u_32_t *msk;
@@ -137,7 +126,6 @@
        while (i < 4)
                msk[i++] = 0;
 }
-#endif
 
 
 /*
@@ -200,7 +188,6 @@
                        return -1;
                }
                (*seg)++;
-#ifdef USE_INET6
                if (use_inet6) {
                        u_32_t k = 0;
                        if (sa[0] || sa[1] || sa[2] || sa[3])
@@ -208,8 +195,7 @@
                        msk[0] = msk[1] = msk[2] = msk[3] = k;
                }
                else
-#endif
-               *msk = *sa ? 0xffffffff : 0;
+                       *msk = *sa ? 0xffffffff : 0;
                return ports(seg, pp, cp, tp, linenum);
        }
        fprintf(stderr, "%d: bad host (%s)\n", linenum, **seg);
@@ -276,7 +262,7 @@
                return 0;
        if (!strcasecmp(**seg, "port") && *(*seg + 1) && *(*seg + 2)) {
                (*seg)++;
-               if (isdigit(***seg) && *(*seg + 2)) {
+               if (isalnum(***seg) && *(*seg + 2)) {
                        if (portnum(**seg, pp, linenum) == 0)
                                return -1;
                        (*seg)++;
@@ -411,8 +397,12 @@
        if (s && *s == '0')
                tcpfm = strtol(s, NULL, 0);
 
-       if (!tcpfm)
-               tcpfm = 0xff;
+       if (!tcpfm) {
+               if (tcpf == TH_SYN)
+                       tcpfm = 0xff & ~(TH_ECN|TH_CWR);
+               else
+                       tcpfm = 0xff & ~(TH_ECN);
+       }
        *mask = tcpfm;
        return tcpf;
 }
@@ -447,7 +437,6 @@
 }
 
 
-#ifdef USE_INET6
 int count6bits(msk)
 u_32_t *msk;
 {
@@ -464,7 +453,6 @@
                }
        return i;
 }
-#endif
 
 
 char   *portname(pr, port)
@@ -595,3 +583,27 @@
                        break;
        }
 }
+
+
+
+char *hostname(v, ip)
+int v;
+void *ip;
+{
+#ifdef  USE_INET6
+       static char hostbuf[MAXHOSTNAMELEN+1];
+#endif
+       struct in_addr ipa;
+
+       if (v == 4) {
+               ipa.s_addr = *(u_32_t *)ip;
+               return inet_ntoa(ipa);
+       }
+#ifdef  USE_INET6
+       (void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf) - 1);
+       hostbuf[MAXHOSTNAMELEN] = '\0';
+       return hostbuf;
+#else
+       return "IPv6";
+#endif
+}



Home | Main Index | Thread Index | Old Index