summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Makefile14
-rw-r--r--arptables-legacy.8 (renamed from arptables.8)18
-rw-r--r--arptables.c7
-rw-r--r--libarptc/libarptc_incl.c11
5 files changed, 32 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b2ea4a1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.a
+*.o
+/arptables-legacy
+/tags
diff --git a/Makefile b/Makefile
index 139c9ca..62ebdf2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-ARPTABLES_VERSION:=0.0.4
+ARPTABLES_VERSION:=0.0.5
KERNEL_DIR:=./
# default paths
@@ -10,7 +10,7 @@ man8dir=$(MANDIR)/man8
SYSCONFIGDIR:=/etc/sysconfig
DESTDIR:=
-MANS = arptables.8 arptables-save.8 arptables-restore.8
+MANS = arptables-legacy.8 arptables-save.8 arptables-restore.8
COPT_FLAGS:=-O2
CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include/ -Iinclude/ -DARPTABLES_VERSION=\"$(ARPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DARPTC_DEBUG
@@ -21,7 +21,7 @@ endif
include extensions/Makefile
-all: arptables libarptc/libarptc.a
+all: arptables-legacy libarptc/libarptc.a
arptables.o: arptables.c
$(CC) $(CFLAGS) -c -o $@ $<
@@ -35,10 +35,10 @@ libarptc/libarptc.o: libarptc/libarptc.c libarptc/libarptc_incl.c
libarptc/libarptc.a: libarptc/libarptc.o
$(AR) rcs $@ $<
-arptables: arptables-standalone.o arptables.o libarptc/libarptc.o $(EXT_OBJS)
+arptables-legacy: arptables-standalone.o arptables.o libarptc/libarptc.o $(EXT_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-$(DESTDIR)$(BINDIR)/arptables: arptables
+$(DESTDIR)$(BINDIR)/arptables-legacy: arptables-legacy
mkdir -p $(DESTDIR)$(BINDIR)
install -m 0755 $< $@
@@ -58,11 +58,11 @@ install-man: $(MANS)
install -m 0644 $^ $(DESTDIR)$(man8dir)/
.PHONY: install
-install: install-man $(DESTDIR)$(BINDIR)/arptables scripts
+install: install-man $(DESTDIR)$(BINDIR)/arptables-legacy scripts
.PHONY: clean
clean:
- rm -f arptables
+ rm -f arptables-legacy
rm -f *.o *~
rm -f extensions/*.o extensions/*~
rm -f libarptc/*.o libarptc/*~ libarptc/*.a
diff --git a/arptables.8 b/arptables-legacy.8
index 676b884..f8b630f 100644
--- a/arptables.8
+++ b/arptables-legacy.8
@@ -1,4 +1,4 @@
-.TH ARPTABLES 8 "November 2011"
+.TH ARPTABLES 8 "June 2018"
.\"
.\" Man page originally written by Jochen Friedrich <jochen@scram.de>,
.\" maintained by Bart De Schuymer.
@@ -22,7 +22,7 @@
.\"
.\"
.SH NAME
-arptables \- ARP table administration
+arptables \- ARP table administration (legacy)
.SH SYNOPSIS
.BR "arptables " [ "-t table" ] " -" [ AD ] " chain rule-specification " [ options ]
.br
@@ -37,6 +37,18 @@ arptables \- ARP table administration
.BR "arptables " [ "-t table" ] " -E old-chain-name new-chain-name"
.br
.BR "arptables " [ "-t table" ] " -P chain target " [ options ]
+
+.SH LEGACY
+This tool uses the old xtables/setsockopt framework, and is a legacy version
+of arptables. That means that a new, more modern tool exists with the same
+functionality using the nf_tables framework and you are encouraged to migrate now.
+The new binaries (formerly known as -compat) uses the same syntax and
+semantics than this legacy one.
+
+You can still use this legacy tool. You should probably get some specific
+information from your Linux distribution or vendor.
+More docs are available at https://wiki.nftables.org
+
.SH DESCRIPTION
.B arptables
is a user space tool, it is used to set up and maintain the
@@ -198,7 +210,7 @@ of the
.B arptables
kernel table.
-.SS MISCELLANOUS COMMANDS
+.SS MISCELLANEOUS COMMANDS
.TP
.B "-V, --version"
Show the version of the arptables userspace program.
diff --git a/arptables.c b/arptables.c
index 4e9af67..403dae4 100644
--- a/arptables.c
+++ b/arptables.c
@@ -468,7 +468,7 @@ exit_printhelp(void)
struct arptables_target *t = NULL;
int i;
- printf("%s v%s\n\n"
+ printf("%s v%s (legacy)\n\n"
"Usage: %s -[AD] chain rule-specification [options]\n"
" %s -[RI] chain rulenum rule-specification [options]\n"
" %s -D chain rulenum [options]\n"
@@ -844,7 +844,7 @@ parse_interface(const char *arg, char *vianame, unsigned char *mask)
if (!isalnum(vianame[i])
&& vianame[i] != '_'
&& vianame[i] != '.') {
- printf("Warning: wierd character in interface"
+ printf("Warning: weird character in interface"
" `%s' (No aliases, :, ! or *).\n",
vianame);
break;
@@ -2065,8 +2065,7 @@ int do_command(int argc, char *argv[], char **table, arptc_handle_t *handle)
target->t = fw_calloc(1, size);
target->t->u.target_size = size;
- strncpy(target->t->u.user.name, jumpto, sizeof(target->t->u.user.name));
- target->t->u.user.name[sizeof(target->t->u.user.name)-1] = '\0';
+ strncpy(target->t->u.user.name, jumpto, sizeof(target->t->u.user.name) - 1);
target->t->u.user.revision = target->revision;
/*
target->init(target->t, &fw.nfcache);
diff --git a/libarptc/libarptc_incl.c b/libarptc/libarptc_incl.c
index ca23da6..c4d5de3 100644
--- a/libarptc/libarptc_incl.c
+++ b/libarptc/libarptc_incl.c
@@ -191,21 +191,16 @@ alloc_handle(const char *tablename, unsigned int size, unsigned int num_rules)
+ size
+ num_rules * sizeof(struct counter_map);
- if ((h = malloc(len)) == NULL) {
+ if ((h = calloc(1, len)) == NULL) {
errno = ENOMEM;
return NULL;
}
- h->changed = 0;
- h->cache_num_chains = 0;
- h->cache_chain_heads = NULL;
h->counter_map = (void *)h
+ sizeof(STRUCT_TC_HANDLE)
+ size;
- strncpy(h->info.name, tablename, sizeof(h->info.name));
- h->info.name[sizeof(h->info.name)-1] = '\0';
- strncpy(h->entries.name, tablename, sizeof(h->entries.name));
- h->entries.name[sizeof(h->entries.name)-1] = '\0';
+ strncpy(h->info.name, tablename, sizeof(h->info.name) - 1);
+ strncpy(h->entries.name, tablename, sizeof(h->entries.name) - 1);
return h;
}