summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/ipfs.c
diff options
context:
space:
mode:
authordarrenr <darrenr@FreeBSD.org>2001-02-04 14:25:38 +0000
committerdarrenr <darrenr@FreeBSD.org>2001-02-04 14:25:38 +0000
commit5e62aa9b3dacb0e670998fad60638b79751aff14 (patch)
tree385e237f9b94bd1f0ddf97318d3ced6f6e85ec8b /contrib/ipfilter/ipfs.c
parent77a62e2a58642d4f2e31e9cfc354994062d9777b (diff)
downloadFreeBSD-src-5e62aa9b3dacb0e670998fad60638b79751aff14.zip
FreeBSD-src-5e62aa9b3dacb0e670998fad60638b79751aff14.tar.gz
Import IP Filter update
Diffstat (limited to 'contrib/ipfilter/ipfs.c')
-rw-r--r--contrib/ipfilter/ipfs.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/contrib/ipfilter/ipfs.c b/contrib/ipfilter/ipfs.c
index 6dc2f02..d43fc56 100644
--- a/contrib/ipfilter/ipfs.c
+++ b/contrib/ipfilter/ipfs.c
@@ -41,12 +41,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.3 2001/01/10 06:20:12 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
@@ -271,8 +278,14 @@ char *argv[];
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)
@@ -363,6 +376,9 @@ char *file;
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);
@@ -404,6 +420,9 @@ char *file;
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);
@@ -432,6 +451,11 @@ char *file;
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));
/*
@@ -497,6 +521,9 @@ char *file;
int nfd = -1, i;
nat_t *nat;
+ if (!file)
+ file = IPF_NATFILE;
+
nfd = open(file, O_RDONLY);
if (nfd == -1) {
fprintf(stderr, "%s ", file);
@@ -615,6 +642,9 @@ char *file;
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);
@@ -699,14 +729,14 @@ char *dirname;
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);
@@ -743,14 +773,14 @@ char *dirname;
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);
OpenPOWER on IntegriCloud