aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-09-03 16:19:23 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-09-03 16:22:14 +0200
commitd68a1def31e9001e4f7fdbab4a99443777cad3f2 (patch)
treeeb0396f7e856302025fcfc056147c229c4248f03
parent434590d20707856e3aa01687efce369bbae93b2a (diff)
add script 'accesslist-duplicates'
-rw-r--r--Makefile2
-rw-r--r--accesslist-duplicates.capsman27
-rw-r--r--accesslist-duplicates.local27
-rw-r--r--accesslist-duplicates.template28
4 files changed, 83 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 4f12e6d..b5f49af 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-GENERATE = collect-wireless-mac.capsman collect-wireless-mac.local dhcp-lease-comment.capsman dhcp-lease-comment.local
+GENERATE = *.capsman *.local
all: $(GENERATE) README.html
diff --git a/accesslist-duplicates.capsman b/accesslist-duplicates.capsman
new file mode 100644
index 0000000..9d1642e
--- /dev/null
+++ b/accesslist-duplicates.capsman
@@ -0,0 +1,27 @@
+#
+# RouterOS script: accesslist-duplicates.capsman
+# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
+#
+# print duplicate antries in wireless access list
+#
+# !! Do not edit this file, it is generated from template!
+
+:local seen [ :toarray "" ];
+:local shown [ :toarray "" ];
+
+:foreach acclist in=[ / caps-man access-list find where mac-address!="00:00:00:00:00:00" ] do={
+ :local mac [ / caps-man access-list get $acclist mac-address ];
+ :foreach "seen-mac" in=$seen do={
+ :if ($"seen-mac" = $mac) do={
+ :local skip 0;
+ :foreach "shown-mac" in=$shown do={
+ :if ($"shown-mac" = $mac) do={ :set skip 1; }
+ }
+ :if ($skip = 0) do={
+ / caps-man access-list print where mac-address=$mac;
+ :set $shown ( $shown , $mac );
+ }
+ }
+ }
+ :set $seen ( $seen , $mac );
+}
diff --git a/accesslist-duplicates.local b/accesslist-duplicates.local
new file mode 100644
index 0000000..3eca046
--- /dev/null
+++ b/accesslist-duplicates.local
@@ -0,0 +1,27 @@
+#
+# RouterOS script: accesslist-duplicates.local
+# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
+#
+# print duplicate antries in wireless access list
+#
+# !! Do not edit this file, it is generated from template!
+
+:local seen [ :toarray "" ];
+:local shown [ :toarray "" ];
+
+:foreach acclist in=[ / interface wireless access-list find where mac-address!="00:00:00:00:00:00" ] do={
+ :local mac [ / interface wireless access-list get $acclist mac-address ];
+ :foreach "seen-mac" in=$seen do={
+ :if ($"seen-mac" = $mac) do={
+ :local skip 0;
+ :foreach "shown-mac" in=$shown do={
+ :if ($"shown-mac" = $mac) do={ :set skip 1; }
+ }
+ :if ($skip = 0) do={
+ / interface wireless access-list print where mac-address=$mac;
+ :set $shown ( $shown , $mac );
+ }
+ }
+ }
+ :set $seen ( $seen , $mac );
+}
diff --git a/accesslist-duplicates.template b/accesslist-duplicates.template
new file mode 100644
index 0000000..3c56c83
--- /dev/null
+++ b/accesslist-duplicates.template
@@ -0,0 +1,28 @@
+#
+# RouterOS script: accesslist-duplicates%TEMPL%
+# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
+#
+# print duplicate antries in wireless access list
+#
+# !! This is just a template! Replace '%PATH%' with 'caps-man'
+# !! or 'interface wireless'!
+
+:local seen [ :toarray "" ];
+:local shown [ :toarray "" ];
+
+:foreach acclist in=[ / %PATH% access-list find where mac-address!="00:00:00:00:00:00" ] do={
+ :local mac [ / %PATH% access-list get $acclist mac-address ];
+ :foreach "seen-mac" in=$seen do={
+ :if ($"seen-mac" = $mac) do={
+ :local skip 0;
+ :foreach "shown-mac" in=$shown do={
+ :if ($"shown-mac" = $mac) do={ :set skip 1; }
+ }
+ :if ($skip = 0) do={
+ / %PATH% access-list print where mac-address=$mac;
+ :set $shown ( $shown , $mac );
+ }
+ }
+ }
+ :set $seen ( $seen , $mac );
+}