diff options
author | Ermal <eri@pfsense.org> | 2012-06-07 09:25:05 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2012-06-07 09:25:05 +0000 |
commit | 901bab70c88280e15b162f1e65b7cfe35b2e91df (patch) | |
tree | f657fe8174fee33d7ea60cfe14707c3c1db2785c /config | |
parent | c533da31d810a5e6e8e96864b6e96271985d423a (diff) | |
download | pfsense-packages-901bab70c88280e15b162f1e65b7cfe35b2e91df.tar.gz pfsense-packages-901bab70c88280e15b162f1e65b7cfe35b2e91df.tar.bz2 pfsense-packages-901bab70c88280e15b162f1e65b7cfe35b2e91df.zip |
Say hello to olsrd as a package.
Diffstat (limited to 'config')
-rw-r--r-- | config/olsrd.inc | 296 | ||||
-rw-r--r-- | config/olsrd.xml | 141 |
2 files changed, 437 insertions, 0 deletions
diff --git a/config/olsrd.inc b/config/olsrd.inc new file mode 100644 index 00000000..9db79f1f --- /dev/null +++ b/config/olsrd.inc @@ -0,0 +1,296 @@ +<?php +/* COPYRIGHT */ + +require_once("config.inc"); + +function setup_wireless_olsr() { + global $config, $g; + + if ($g['platform'] == 'jail' || !$config['installedpackages']['olsrd'] || !$config['installedpackages']) + return; + if(isset($config['system']['developerspew'])) { + $mt = microtime(); + echo "setup_wireless_olsr($interface) being called $mt\n"; + } + conf_mount_rw(); + + foreach($config['installedpackages']['olsrd']['config'] as $olsrd) { + $olsr_enable = $olsrd['enable']; + if ($olsr_enable <> "on") { + if (is_process_running("olsrd")) + mwexec("/usr/bin/killall olsrd", true); + return; + } + $fd = fopen("{$g['varetc_path']}/olsr.conf", "w"); + + if($olsrd['announcedynamicroute'] or $olsrd['enableannounce'] == "on") { + $enableannounce .= "\nHna4\n"; + $enableannounce .= "{\n"; + if($olsrd['announcedynamicroute']) + $enableannounce .= "\t{$olsrd['announcedynamicroute']}\n"; + if($olsrd['enableannounce'] == "on") + $enableannounce .= "0.0.0.0 0.0.0.0"; + $enableannounce .= "\n}\n"; + } else { + $enableannounce = ""; + } + + $olsr .= <<<EODA +# +# olsr.org OLSR daemon config file +# +# Lines starting with a # are discarded +# +# This file was generated by setup_wireless_olsr() in services.inc +# + +# This file is an example of a typical +# configuration for a mostly static +# network(regarding mobility) using +# the LQ extention + +# Debug level(0-9) +# If set to 0 the daemon runs in the background + +DebugLevel 2 + +# IP version to use (4 or 6) + +IpVersion 4 + +# Clear the screen each time the internal state changes + +ClearScreen yes + +{$enableannounce} + +# Should olsrd keep on running even if there are +# no interfaces available? This is a good idea +# for a PCMCIA/USB hotswap environment. +# "yes" OR "no" + +AllowNoInt yes + +# TOS(type of service) value for +# the IP header of control traffic. +# If not set it will default to 16 + +#TosValue 16 + +# The fixed willingness to use(0-7) +# If not set willingness will be calculated +# dynamically based on battery/power status +# if such information is available + +#Willingness 4 + +# Allow processes like the GUI front-end +# to connect to the daemon. + +IpcConnect +{ + # Determines how many simultaneously + # IPC connections that will be allowed + # Setting this to 0 disables IPC + + MaxConnections 0 + + # By default only 127.0.0.1 is allowed + # to connect. Here allowed hosts can + # be added + + Host 127.0.0.1 + #Host 10.0.0.5 + + # You can also specify entire net-ranges + # that are allowed to connect. Multiple + # entries are allowed + + #Net 192.168.1.0 255.255.255.0 +} + +# Wether to use hysteresis or not +# Hysteresis adds more robustness to the +# link sensing but delays neighbor registration. +# Used by default. 'yes' or 'no' + +UseHysteresis no + +# Hysteresis parameters +# Do not alter these unless you know +# what you are doing! +# Set to auto by default. Allowed +# values are floating point values +# in the interval 0,1 +# THR_LOW must always be lower than +# THR_HIGH. + +#HystScaling 0.50 +#HystThrHigh 0.80 +#HystThrLow 0.30 + + +# Link quality level +# 0 = do not use link quality +# 1 = use link quality for MPR selection +# 2 = use link quality for MPR selection and routing +# Defaults to 0 + +LinkQualityLevel {$olsrd['enablelqe']} + +# Link quality window size +# Defaults to 10 + +LinkQualityWinSize 10 + +# Polling rate in seconds(float). +# Default value 0.05 sec + +Pollrate 0.05 + + +# TC redundancy +# Specifies how much neighbor info should +# be sent in TC messages +# Possible values are: +# 0 - only send MPR selectors +# 1 - send MPR selectors and MPRs +# 2 - send all neighbors +# +# defaults to 0 + +TcRedundancy 2 + +# +# MPR coverage +# Specifies how many MPRs a node should +# try select to reach every 2 hop neighbor +# +# Can be set to any integer >0 +# +# defaults to 1 + +MprCoverage 3 + +# Example plugin entry with parameters: + +EODA; + +if($olsrd['enablehttpinfo'] == "on") { + $olsr .= <<<EODB + +LoadPlugin "/usr/local/lib/olsrd_httpinfo.so.0.1" +{ + PlParam "port" "{$olsrd['port']}" + PlParam "Net" "{$olsrd['allowedhttpinfohost']} {$olsrd['allowedhttpinfosubnet']}" +} + +EODB; + +} + +if($olsrd['enabledsecure'] == "on") { + @file_put_contents("{$g['tmp_path']}/olsrkey.txt", $olsrd['securekey']); + $olsr .= <<<EODC + +LoadPlugin "/usr/local/lib/olsrd_secure.so.0.5" +{ + PlParam "Keyfile" "{$g['tmp_path']}/olsrkey.txt" +} + +EODC; + +} + +if($olsrd['enabledyngw'] == "on") { + + /* unset default route, olsr auto negotiates */ + mwexec("/sbin/route delete default"); + + $olsr .= <<<EODE + +LoadPlugin "/usr/local/lib/olsrd_dyn_gw.so.0.4" +{ + # how often to look for a inet gw, in seconds + # defaults to 5 secs, if commented out + PlParam "Interval" "{$olsrd['polling']}" + + # if one or more IPv4 addresses are given, do a ping on these in + # descending order to validate that there is not only an entry in + # routing table, but also a real internet connection. If any of + # these addresses could be pinged successfully, the test was + # succesful, i.e. if the ping on the 1st address was successful,the + # 2nd won't be pinged + PlParam "Ping" "{$olsrd['ping']}" + #PlParam "HNA" "192.168.81.0 255.255.255.0" +} + +EODE; + +} + +foreach($config['installedpackages']['olsrd']['config'] as $conf) { + $interfaces = explode(',', $conf['iface_array']); + foreach($interfaces as $interface) { + $realinterface = convert_friendly_interface_to_real_interface_name($interface); +$olsr .= <<<EODAD +Interface "{$realinterface}" +{ + + # Hello interval in seconds(float) + HelloInterval 2.0 + + # HELLO validity time + HelloValidityTime 20.0 + + # TC interval in seconds(float) + TcInterval 5.0 + + # TC validity time + TcValidityTime 30.0 + + # MID interval in seconds(float) + MidInterval 5.0 + + # MID validity time + MidValidityTime 30.0 + + # HNA interval in seconds(float) + HnaInterval 5.0 + + # HNA validity time + HnaValidityTime 30.0 + + # When multiple links exist between hosts + # the weight of interface is used to determine + # the link to use. Normally the weight is + # automatically calculated by olsrd based + # on the characteristics of the interface, + # but here you can specify a fixed value. + # Olsrd will choose links with the lowest value. + + # Weight 0 + + +} + +EODAD; + + } + break; +} + fwrite($fd, $olsr); + fclose($fd); + } + + if (is_process_running("olsrd")) + mwexec("/usr/bin/killall olsrd", true); + + sleep(2); + + mwexec_bg("/usr/local/sbin/olsrd -f {$g['varetc_path']}/olsr.conf"); + + conf_mount_ro(); +} + +?> diff --git a/config/olsrd.xml b/config/olsrd.xml new file mode 100644 index 00000000..9709392d --- /dev/null +++ b/config/olsrd.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="utf-8" ?> +<packagegui> + <name>olsrd</name> + <version>1.0</version> + <title>OLSRD</title> + <include_file>/usr/local/pkg/olsrd.inc</include_file> + <!-- Menu is where this packages menu will appear --> + <menu> + <name>OLSRD</name> + <section>Services</section> + <configfile>olsrd.xml</configfile> + </menu> + <service> + <name>OLSRD</name> + <rcfile>/usr/local/sbin/olsrd -f /var/etc/olsr.conf</rcfile> + </service> + <tabs> + <tab> + <text>OLSRD Settings</text> + <url>/pkg_edit.php?xml=olsrd.xml&id=0</url> + <active/> + </tab> + </tabs> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/olsrd.inc</item> + </additional_files_needed> + <!-- configpath gets expanded out automatically and config items will be + stored in that location --> + <configpath>['installedpackages']['OLSRD']['config']</configpath> + <!-- fields gets invoked when the user adds or edits a item. the following items + will be parsed and rendered for the user as a gui with input, and selectboxes. --> + <fields> + <field> + <fielddescr>Enable OLSR</fielddescr> + <fieldname>enable</fieldname> + <description>Enables the dynamic mesh linking daemon</description> + <type>checkbox</type> + </field> + <field> + <fielddescr>Link Quality Level</fielddescr> + <fieldname>enablelqe</fieldname> + <type>select</type> + <size>1</size> + <options> + <option><value>2</value><name>2</name></option> + <option><value>0</value><name>0</name></option> + <option><value>1</value><name>1</name></option> + </options> + </field> + <field> + <fielddescr>Interfaces</fielddescr> + <fieldname>iface_array</fieldname> + <value>lan</value> + <multiple>true</multiple> + <size>3</size> + <type>interfaces_selection</type> + <description>Select the interfaces that OLSR will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> + </field> + <field> + <fielddescr>Enable HTTPInfo Plugin</fielddescr> + <fieldname>enablehttpinfo</fieldname> + <description>Enables the OLSR stats web server</description> + <type>checkbox</type> + </field> + <field> + <fielddescr>HTTPInfo Port</fielddescr> + <fieldname>port</fieldname> + <description>Port that HTTPInfo will listen on</description> + <type>input</type> + </field> + <field> + <fielddescr>Allowed host(s)</fielddescr> + <fieldname>allowedhttpinfohost</fieldname> + <description>Hosts that are allowed to access the HTTPInfo web service.</description> + <type>input</type> + </field> + <field> + <fielddescr>Allowed host(s) subnet</fielddescr> + <fieldname>allowedhttpinfosubnet</fieldname> + <description>Enter the subnet mask in form 255.255.255.0</description> + <type>input</type> + </field> + <field> + <fielddescr>Enable Dynamic Gateway</fielddescr> + <fieldname>enabledyngw</fieldname> + <description>Enables the OLSR Dynamic Gateways feature</description> + <type>checkbox</type> + </field> + <field> + <fielddescr>Announce self as Dynamic Gateway</fielddescr> + <fieldname>enableannounce</fieldname> + <description>Enables the OLSR Dynamic Gateways Announcing feature</description> + <type>checkbox</type> + </field> + <field> + <fielddescr>Announce Dynamic local route</fielddescr> + <fieldname>announcedynamicroute</fieldname> + <description>Enter the IP/Netmask</description> + <type>textarea</type> + <rows>3</rows> + <cols>50</cols> + </field> + <field> + <fielddescr>Ping</fielddescr> + <fieldname>ping</fieldname> + <description>Pings this host to ensure connectivity</description> + <type>input</type> + </field> + <field> + <fielddescr>Poll</fielddescr> + <fieldname>polling</fieldname> + <description>How often to look for a inet gw, in seconds.</description> + <type>input</type> + </field> + <field> + <fielddescr>Enable Secure Mode</fielddescr> + <fieldname>enabledsecure</fieldname> + <description>Enables the secure mode</description> + <type>checkbox</type> + </field> + <field> + <fielddescr>Key</fielddescr> + <fieldname>securekey</fieldname> + <description>Paste the secure key information here.</description> + <type>textarea</type> + <rows>5</rows> + <cols>50</cols> + </field> + </fields> + <custom_delete_php_command> + </custom_delete_php_command> + <custom_php_resync_config_command> + setup_wireless_olsr($if); + </custom_php_resync_config_command> + <custom_php_install_command> + </custom_php_install_command> + <custom_php_deinstall_command> + </custom_php_deinstall_command> +</packagegui> |