Community discussions

MikroTik App
 
mpixel
newbie
Topic Author
Posts: 34
Joined: Wed Jun 24, 2009 9:58 pm

Array of mac addresses? is it possible ???

Mon Jan 16, 2012 12:03 pm

I want create array of all mac addresses from firewall. If I use array for processing, script could be faster.
How can I do it?
Following script is only my suggestion, but it doesnt work.
variable "pole" should be array.
{
:local pole                # I want variable "pole" to be an array of mac addresses.
:local filtermac
:local i
:local j

    :local fpravidla [/ip firewall filter find]
    :set i 0
    :foreach j in $fpravidla do={
        :set filtermac [/ip firewall filter get $j value-name=src-mac-address]
        :set i ($i+1)
        :set pole[$i] $filtermac      # how can I write this?    
      }
}
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Array of mac addresses? is it possible ???

Thu Apr 26, 2012 11:23 pm

The syntax for adding elements to an array can be found here:
http://wiki.mikrotik.com/wiki/Manual:Sc ... _Operators

This script loops through the filter rules and adds the src-mac addresses to the array. Tested in RouterOS v5.7.
{
	:local pole;
	:foreach j in=[/ip firewall filter find] do={
		:set pole ( $pole , [/ip firewall filter get $j src-mac-address]);
	}
}

Who is online

Users browsing this forum: No registered users and 50 guests