mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-02 06:04:27 +02:00
global-functions: add $GetRandom
This commit is contained in:
parent
25a22e2e1c
commit
f49b67f5e7
1 changed files with 13 additions and 0 deletions
|
@ -245,3 +245,16 @@
|
||||||
}
|
}
|
||||||
:return $Result;
|
:return $Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# generate random number
|
||||||
|
# Warning: This is a *very* weak algorithm and in *no way*
|
||||||
|
# useful for cryptography or similar!
|
||||||
|
:global GetRandom do={
|
||||||
|
:local Max ([ :tonum $1 ] + 1);
|
||||||
|
:local Sum 0;
|
||||||
|
|
||||||
|
:foreach Interface in=[ /interface find ] do={
|
||||||
|
:set Sum ($Sum + [ /interface get $Interface tx-byte ]);
|
||||||
|
}
|
||||||
|
:return ($Sum % $Max);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue