I've been busy so another attempt to solve a problem had to wait a bit.
But here it is.
I've set up PHP script that loads encap.txt, parses it and then can
generate encap data in various formats. For testing two formats are
available:
simple: contains coma delimited network and gateway. This reduces file
size significantly
Example:
http://www.uzice.net/ampr/encap/?format=simple
mikrotik45: contains Mikrotik version 4.5 script that sets IPIP
interfaces and routes. Mikrotik version is specified as I developed
script on RouterBoard with that version and I am not sure if it will run
on newer versions.
http://www.uzice.net/ampr/encap/?format=mikrotik45
It is easy to add other formats as needed.
Idea is to have cashing for generated data, so it is not created on each
user call, but only when there are changes. As generated data is not
user specific (the same file works for all users), cashe should be
refreshed only if encap.txt changes. That would keep server resource
usage at minimum.
Users could be instructed to download generated files directly so they
would not even run script. Script should run via cron, then.
...
For Mikrotik, generated script is universal, meaning, the same script
can be run on any Mikrotik and it will set up what is needed.
As there is some customization needed, this script should not be
executed directly but via other Mikrotik script that is set up locally
on Mikrotik router. That script should set custom parameters and then
download and execute encap script.
Here is an example of local script:
{
#######################################
#
# AMPRNet Route Loader for Mikrotik 5.4
# version 0.0.2
#
#
# by YT9TP, Pedja,
http://yt9tp.iz.rs
#
#######################################
# PARAMETERS
#######################################
# download url for enc.txt file
:local downloadURL "http://www.uzice.net/ampr/encap/index-mikrotik54.php";
# local public IP address of AMPR gateway
:global localAddr "192.168.1.1" ;
# custom contents fora a comment on created IPIP tunnel interface
:global ipipComment "";
# custom parameters to add to /interface add command
:global ipipCustomParams "";
# custom contents fora a comment on created route
:global routeComment "";
# custom parameters to add to /ip route add command
:global routeCustomParams "routing-mark=amprs";
# identificator to be added to comments or names which is used to
identify settings added by this script (to be auto deleted when needed)
:global scriptIdentificator "amprs-d";
########################################
########################################
# DO NOT EDIT BELOW THIS LINE !!!
########################################
:put ("\n\rAMPRNet route loader \n\r");
# download cmd file
:put ("\n\rDownloading file " . $downloadURL . "\n\r");
/tool fetch url=$downloadURL dst-path=amprnet.rsc mode=http
:delay 5 ;
/import file-name=amprnet.rsc
}
There are some limitations. As encap contains lot of information,
genereted script end up pretty large. Mikrotik router has to have enough
free space to save downloaded file before execution. I guess PC with
large hard disk or RouterBoard with additional memory card is required.
I have everything packed in one ZIP file for those who would like to
check it out or try on their own:
https://dl.dropboxusercontent.com/u/12258621/hamradio/amprnet/simplified-en…
Pedja
YT9TP