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.4-1.5 (requested by martti):
details: https://anonhg.NetBSD.org/src/rev/45f3fce8f67e
branches: netbsd-1-5
changeset: 492684:45f3fce8f67e
user: he <he%NetBSD.org@localhost>
date: Sat Feb 09 16:55:50 2002 +0000
description:
Pull up revisions 1.4-1.5 (requested by martti):
Updated IPFilter to 3.4.23
diffstat:
dist/ipf/ipfs.c | 71 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 53 insertions(+), 18 deletions(-)
diffs (203 lines):
diff -r 1dba54ffd14e -r 45f3fce8f67e dist/ipf/ipfs.c
--- a/dist/ipf/ipfs.c Sat Feb 09 16:55:47 2002 +0000
+++ b/dist/ipf/ipfs.c Sat Feb 09 16:55:50 2002 +0000
@@ -1,14 +1,18 @@
-/* $NetBSD: ipfs.c,v 1.3 2000/05/11 19:54:35 veego Exp $ */
+/* $NetBSD: ipfs.c,v 1.3.4.1 2002/02/09 16:55:50 he Exp $ */
/*
- * Copyright (C) 1999 by Darren Reed.
+ * Copyright (C) 1999-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.
*/
#ifdef __FreeBSD__
-# include <osreldate.h>
+# ifndef __FreeBSD_cc_version
+# include <osreldate.h>
+# else
+# if __FreeBSD_cc_version < 430000
+# include <osreldate.h>
+# endif
+# endif
#endif
#include <stdio.h>
#include <unistd.h>
@@ -43,12 +47,19 @@
#include "ipf.h"
#if !defined(lint)
-static const char rcsid[] = "@(#)Id: ipfs.c,v 2.6.2.1 2000/05/06 00:11:18 darrenr Exp";
+static const char rcsid[] = "@(#)Id: ipfs.c,v 2.6.2.8 2001/09/14 18:52:21 darrenr Exp";
#endif
#ifndef IPF_SAVEDIR
# define IPF_SAVEDIR "/var/db/ipf"
#endif
+#ifndef IPF_NATFILE
+# define IPF_NATFILE "ipnat.ipf"
+#endif
+#ifndef IPF_STATEFILE
+# define IPF_STATEFILE "ipstate.ipf"
+#endif
+
#if !defined(__SVR4) && defined(__GNUC__)
extern char *index __P((const char *, int));
#endif
@@ -228,13 +239,13 @@
opts |= OPT_DONOTHING;
break;
case 'N' :
- if ((ns > 0) || dirname || (rw != -1) || set)
+ if ((ns >= 0) || dirname || (rw != -1) || set)
usage();
ns = 0;
set = 1;
break;
case 'r' :
- if ((ns > 0) || dirname || (rw != -1))
+ if ((ns >= 0) || dirname || (rw != -1))
usage();
rw = 0;
set = 1;
@@ -244,7 +255,7 @@
set = 1;
break;
case 'S' :
- if ((ns > 0) || dirname || (rw != -1) || set)
+ if ((ns >= 0) || dirname || (rw != -1) || set)
usage();
ns = 1;
set = 1;
@@ -259,7 +270,7 @@
opts |= OPT_VERBOSE;
break;
case 'w' :
- if ((ns > 0) || dirname || (rw != -1) || (ns == -1))
+ if (dirname || (rw != -1) || (ns == -1))
usage();
rw = 1;
set = 1;
@@ -273,8 +284,14 @@
usage();
}
- if (ifs)
- return changestateif(ifs, filename);
+ if (ifs) {
+ if (!filename || ns < 0)
+ usage();
+ if (ns == 0)
+ return changenatif(ifs, filename);
+ else
+ return changestateif(ifs, filename);
+ }
if ((ns >= 0) || (lock >= 0)) {
if (lock >= 0)
@@ -365,6 +382,9 @@
ipstate_save_t ips, *ipsp;
int wfd = -1;
+ if (!file)
+ file = IPF_STATEFILE;
+
wfd = open(file, O_WRONLY|O_TRUNC|O_CREAT, 0600);
if (wfd == -1) {
fprintf(stderr, "%s ", file);
@@ -406,6 +426,9 @@
ipstate_save_t ips, *is, *ipshead = NULL, *is1, *ipstail = NULL;
int sfd = -1, i;
+ if (!file)
+ file = IPF_STATEFILE;
+
sfd = open(file, O_RDONLY, 0600);
if (sfd == -1) {
fprintf(stderr, "%s ", file);
@@ -434,6 +457,11 @@
return 1;
}
is = (ipstate_save_t *)malloc(sizeof(*is));
+ if(!is) {
+ fprintf(stderr, "malloc failed\n");
+ return 1;
+ }
+
bcopy((char *)&ips, (char *)is, sizeof(ips));
/*
@@ -499,6 +527,9 @@
int nfd = -1, i;
nat_t *nat;
+ if (!file)
+ file = IPF_NATFILE;
+
nfd = open(file, O_RDONLY);
if (nfd == -1) {
fprintf(stderr, "%s ", file);
@@ -507,6 +538,7 @@
}
bzero((char *)&ipn, sizeof(ipn));
+ ipnp = &ipn;
/*
* 1. Read all state information in.
@@ -548,7 +580,7 @@
}
} else
in = (nat_save_t *)malloc(sizeof(*in));
- bcopy((char *)&ipnp, (char *)in, sizeof(ipn));
+ bcopy((char *)ipnp, (char *)in, sizeof(ipn));
/*
* Check to see if this is the first state entry that will
@@ -617,6 +649,9 @@
int nfd = -1;
natget_t ng;
+ if (!file)
+ file = IPF_NATFILE;
+
nfd = open(file, O_WRONLY|O_TRUNC|O_CREAT, 0600);
if (nfd == -1) {
fprintf(stderr, "%s ", file);
@@ -701,14 +736,14 @@
devfd = opendevice(IPL_STATE);
if (devfd == -1)
return 1;
- if (writestate(devfd, "ipstate.ipf"))
+ if (writestate(devfd, NULL))
return 1;
close(devfd);
devfd = opendevice(IPL_NAT);
if (devfd == -1)
return 1;
- if (writenat(devfd, "ipnat.ipf"))
+ if (writenat(devfd, NULL))
return 1;
close(devfd);
@@ -745,14 +780,14 @@
devfd = opendevice(IPL_STATE);
if (devfd == -1)
return 1;
- if (readstate(devfd, "ipstate.ipf"))
+ if (readstate(devfd, NULL))
return 1;
close(devfd);
devfd = opendevice(IPL_NAT);
if (devfd == -1)
return 1;
- if (readnat(devfd, "ipnat.ipf"))
+ if (readnat(devfd, NULL))
return 1;
close(devfd);
Home |
Main Index |
Thread Index |
Old Index