1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
307cd525
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
services.inc
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
a25183c5
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
a25183c5
|
Scott Ullrich
|
|
10 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
a25183c5
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
a25183c5
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
a25183c5
|
Scott Ullrich
|
|
20 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
/* include all configuration functions */
|
33 |
|
|
require_once("functions.inc");
|
34 |
64ed8739
|
Erik Kristensen
|
require_once("dyndns.class");
|
35 |
5b237745
|
Scott Ullrich
|
|
36 |
|
|
function services_dhcpd_configure() {
|
37 |
|
|
global $config, $g;
|
38 |
a25183c5
|
Scott Ullrich
|
|
39 |
5b237745
|
Scott Ullrich
|
/* kill any running dhcpd */
|
40 |
|
|
killbypid("{$g['varrun_path']}/dhcpd.pid");
|
41 |
a25183c5
|
Scott Ullrich
|
|
42 |
5b237745
|
Scott Ullrich
|
$syscfg = $config['system'];
|
43 |
|
|
$dhcpdcfg = $config['dhcpd'];
|
44 |
a25183c5
|
Scott Ullrich
|
|
45 |
5b237745
|
Scott Ullrich
|
/* DHCP enabled on any interfaces? */
|
46 |
|
|
$dhcpdenable = false;
|
47 |
|
|
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
|
48 |
|
|
if (isset($dhcpifconf['enable']) &&
|
49 |
|
|
(($dhcpif == "lan") ||
|
50 |
|
|
(isset($config['interfaces'][$dhcpif]['enable']) &&
|
51 |
|
|
$config['interfaces'][$dhcpif]['if'] && (!$config['interfaces'][$dhcpif]['bridge']))))
|
52 |
|
|
$dhcpdenable = true;
|
53 |
|
|
}
|
54 |
a25183c5
|
Scott Ullrich
|
|
55 |
5b237745
|
Scott Ullrich
|
if (!$dhcpdenable)
|
56 |
|
|
return 0;
|
57 |
a25183c5
|
Scott Ullrich
|
|
58 |
5b237745
|
Scott Ullrich
|
if ($g['booting'])
|
59 |
|
|
echo "Starting DHCP service... ";
|
60 |
|
|
else
|
61 |
|
|
sleep(1);
|
62 |
a25183c5
|
Scott Ullrich
|
|
63 |
5b237745
|
Scott Ullrich
|
/* write dhcpd.conf */
|
64 |
|
|
$fd = fopen("{$g['varetc_path']}/dhcpd.conf", "w");
|
65 |
|
|
if (!$fd) {
|
66 |
|
|
printf("Error: cannot open dhcpd.conf in services_dhcpd_configure().\n");
|
67 |
|
|
return 1;
|
68 |
|
|
}
|
69 |
a25183c5
|
Scott Ullrich
|
|
70 |
5b237745
|
Scott Ullrich
|
$dhcpdconf = <<<EOD
|
71 |
|
|
option domain-name "{$syscfg['domain']}";
|
72 |
|
|
default-lease-time 7200;
|
73 |
|
|
max-lease-time 86400;
|
74 |
|
|
authoritative;
|
75 |
|
|
log-facility local7;
|
76 |
|
|
ddns-update-style none;
|
77 |
|
|
|
78 |
|
|
EOD;
|
79 |
a25183c5
|
Scott Ullrich
|
|
80 |
5b237745
|
Scott Ullrich
|
$dhcpdifs = array();
|
81 |
|
|
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
|
82 |
a25183c5
|
Scott Ullrich
|
|
83 |
5b237745
|
Scott Ullrich
|
$ifcfg = $config['interfaces'][$dhcpif];
|
84 |
a25183c5
|
Scott Ullrich
|
|
85 |
5b237745
|
Scott Ullrich
|
if (!isset($dhcpifconf['enable']) ||
|
86 |
|
|
(($dhcpif != "lan") &&
|
87 |
|
|
(!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
|
88 |
|
|
continue;
|
89 |
a25183c5
|
Scott Ullrich
|
|
90 |
5b237745
|
Scott Ullrich
|
$subnet = gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);
|
91 |
|
|
$subnetmask = gen_subnet_mask($ifcfg['subnet']);
|
92 |
a25183c5
|
Scott Ullrich
|
|
93 |
5b237745
|
Scott Ullrich
|
$dnscfg = "";
|
94 |
a25183c5
|
Scott Ullrich
|
|
95 |
5b237745
|
Scott Ullrich
|
if ($dhcpifconf['domain']) {
|
96 |
|
|
$dnscfg .= " option domain-name \"{$dhcpifconf['domain']}\";\n";
|
97 |
|
|
}
|
98 |
a25183c5
|
Scott Ullrich
|
|
99 |
5b237745
|
Scott Ullrich
|
if (is_array($dhcpifconf['dnsserver']) && ($dhcpifconf['dnsserver'][0])) {
|
100 |
|
|
$dnscfg .= " option domain-name-servers " . join(",", $dhcpifconf['dnsserver']) . ";";
|
101 |
|
|
} else if (isset($config['dnsmasq']['enable'])) {
|
102 |
|
|
$dnscfg .= " option domain-name-servers " . $ifcfg['ipaddr'] . ";";
|
103 |
|
|
} else if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
|
104 |
|
|
$dnscfg .= " option domain-name-servers " . join(",", $syscfg['dnsserver']) . ";";
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
$dhcpdconf .= "subnet $subnet netmask $subnetmask {\n";
|
108 |
|
|
$dhcpdconf .= " pool {\n";
|
109 |
a25183c5
|
Scott Ullrich
|
if (isset($dhcpifconf['denyunknown']))
|
110 |
5b237745
|
Scott Ullrich
|
$dhcpdconf .= " deny unknown clients;\n";
|
111 |
a25183c5
|
Scott Ullrich
|
|
112 |
5b237745
|
Scott Ullrich
|
if ($dhcpifconf['gateway'])
|
113 |
|
|
$routers = $dhcpifconf['gateway'];
|
114 |
|
|
else
|
115 |
|
|
$routers = $ifcfg['ipaddr'];
|
116 |
a25183c5
|
Scott Ullrich
|
|
117 |
5b237745
|
Scott Ullrich
|
$dhcpdconf .= <<<EOD
|
118 |
|
|
range {$dhcpifconf['range']['from']} {$dhcpifconf['range']['to']};
|
119 |
|
|
}
|
120 |
|
|
option routers {$routers};
|
121 |
|
|
$dnscfg
|
122 |
|
|
|
123 |
|
|
EOD;
|
124 |
|
|
|
125 |
|
|
if ($dhcpifconf['defaultleasetime'])
|
126 |
|
|
$dhcpdconf .= " default-lease-time {$dhcpifconf['defaultleasetime']};\n";
|
127 |
|
|
if ($dhcpifconf['maxleasetime'])
|
128 |
|
|
$dhcpdconf .= " max-lease-time {$dhcpifconf['maxleasetime']};\n";
|
129 |
a25183c5
|
Scott Ullrich
|
|
130 |
5b237745
|
Scott Ullrich
|
if (is_array($dhcpifconf['winsserver']) && $dhcpifconf['winsserver'][0]) {
|
131 |
|
|
$dhcpdconf .= " option netbios-name-servers " . join(",", $dhcpifconf['winsserver']) . ";\n";
|
132 |
|
|
$dhcpdconf .= " option netbios-node-type 8;\n";
|
133 |
|
|
}
|
134 |
a25183c5
|
Scott Ullrich
|
|
135 |
5b237745
|
Scott Ullrich
|
if ($dhcpifconf['next-server'])
|
136 |
|
|
$dhcpdconf .= " next-server {$dhcpifconf['next-server']};\n";
|
137 |
|
|
if ($dhcpifconf['filename'])
|
138 |
|
|
$dhcpdconf .= " filename \"{$dhcpifconf['filename']}\";\n";
|
139 |
a25183c5
|
Scott Ullrich
|
|
140 |
5b237745
|
Scott Ullrich
|
$dhcpdconf .= <<<EOD
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
EOD;
|
144 |
|
|
|
145 |
|
|
/* add static mappings */
|
146 |
|
|
if (is_array($dhcpifconf['staticmap'])) {
|
147 |
a25183c5
|
Scott Ullrich
|
|
148 |
5b237745
|
Scott Ullrich
|
$i = 0;
|
149 |
|
|
foreach ($dhcpifconf['staticmap'] as $sm) {
|
150 |
|
|
$dhcpdconf .= <<<EOD
|
151 |
|
|
host s_{$dhcpif}_{$i} {
|
152 |
|
|
hardware ethernet {$sm['mac']};
|
153 |
|
|
|
154 |
|
|
EOD;
|
155 |
|
|
if ($sm['ipaddr'])
|
156 |
|
|
$dhcpdconf .= " fixed-address {$sm['ipaddr']};\n";
|
157 |
a25183c5
|
Scott Ullrich
|
|
158 |
5b237745
|
Scott Ullrich
|
$dhcpdconf .= "}\n";
|
159 |
|
|
$i++;
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
a25183c5
|
Scott Ullrich
|
|
163 |
5b237745
|
Scott Ullrich
|
$dhcpdifs[] = $ifcfg['if'];
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
fwrite($fd, $dhcpdconf);
|
167 |
|
|
fclose($fd);
|
168 |
|
|
|
169 |
|
|
/* create an empty leases database */
|
170 |
|
|
touch("{$g['vardb_path']}/dhcpd.leases");
|
171 |
a25183c5
|
Scott Ullrich
|
|
172 |
5b237745
|
Scott Ullrich
|
/* fire up dhcpd */
|
173 |
a25183c5
|
Scott Ullrich
|
mwexec("/usr/local/sbin/dhcpd -cf {$g['varetc_path']}/dhcpd.conf " .
|
174 |
5b237745
|
Scott Ullrich
|
join(" ", $dhcpdifs));
|
175 |
a25183c5
|
Scott Ullrich
|
|
176 |
fc6b5a4d
|
Scott Ullrich
|
if ($g['booting']) {
|
177 |
deebaae1
|
Scott Ullrich
|
print "done.\n";
|
178 |
5c6d0f65
|
Colin Smith
|
}
|
179 |
a25183c5
|
Scott Ullrich
|
|
180 |
5b237745
|
Scott Ullrich
|
return 0;
|
181 |
|
|
}
|
182 |
|
|
|
183 |
80933129
|
Bill Marquette
|
function interfaces_staticarp_configure($if) {
|
184 |
5c0538e0
|
Bill Marquette
|
global $config, $g;
|
185 |
|
|
|
186 |
80933129
|
Bill Marquette
|
$ifcfg = $config['interfaces'][$if];
|
187 |
5c0538e0
|
Bill Marquette
|
|
188 |
|
|
/* Enable staticarp, if enabled */
|
189 |
80933129
|
Bill Marquette
|
if(isset($config['dhcpd'][$if]['staticarp'])) {
|
190 |
|
|
mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " staticarp " );
|
191 |
5c0538e0
|
Bill Marquette
|
mwexec("/usr/sbin/arp -ad > /dev/null 2>&1 ");
|
192 |
80933129
|
Bill Marquette
|
if (is_array($config['dhcpd'][$if]['staticmap'])) {
|
193 |
5c0538e0
|
Bill Marquette
|
|
194 |
80933129
|
Bill Marquette
|
foreach ($config['dhcpd'][$if]['staticmap'] as $arpent) {
|
195 |
5c0538e0
|
Bill Marquette
|
mwexec("/usr/sbin/arp -s " . escapeshellarg($arpent['ipaddr']) . " " . escapeshellarg($arpent['mac']));
|
196 |
|
|
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
}
|
200 |
|
|
} else {
|
201 |
80933129
|
Bill Marquette
|
mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " -staticarp " );
|
202 |
5c0538e0
|
Bill Marquette
|
mwexec("/usr/sbin/arp -ad > /dev/null 2>&1 ");
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
return 0;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
5b237745
|
Scott Ullrich
|
function services_dhcrelay_configure() {
|
209 |
|
|
global $config, $g;
|
210 |
a25183c5
|
Scott Ullrich
|
|
211 |
5b237745
|
Scott Ullrich
|
/* kill any running dhcrelay */
|
212 |
|
|
killbypid("{$g['varrun_path']}/dhcrelay.pid");
|
213 |
a25183c5
|
Scott Ullrich
|
|
214 |
5b237745
|
Scott Ullrich
|
$dhcrelaycfg = $config['dhcrelay'];
|
215 |
a25183c5
|
Scott Ullrich
|
|
216 |
5b237745
|
Scott Ullrich
|
/* DHCPRelay enabled on any interfaces? */
|
217 |
|
|
$dhcrelayenable = false;
|
218 |
|
|
foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
|
219 |
|
|
if (isset($dhcrelayifconf['enable']) &&
|
220 |
|
|
(($dhcrelayif == "lan") ||
|
221 |
|
|
(isset($config['interfaces'][$dhcrelayif]['enable']) &&
|
222 |
|
|
$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
|
223 |
|
|
$dhcrelayenable = true;
|
224 |
|
|
}
|
225 |
a25183c5
|
Scott Ullrich
|
|
226 |
5b237745
|
Scott Ullrich
|
if (!$dhcrelayenable)
|
227 |
|
|
return 0;
|
228 |
a25183c5
|
Scott Ullrich
|
|
229 |
5b237745
|
Scott Ullrich
|
if ($g['booting'])
|
230 |
|
|
echo "Starting DHCP relay service... ";
|
231 |
|
|
else
|
232 |
|
|
sleep(1);
|
233 |
a25183c5
|
Scott Ullrich
|
|
234 |
5b237745
|
Scott Ullrich
|
$dhcrelayifs = array();
|
235 |
|
|
foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
|
236 |
a25183c5
|
Scott Ullrich
|
|
237 |
5b237745
|
Scott Ullrich
|
$ifcfg = $config['interfaces'][$dhcrelayif];
|
238 |
a25183c5
|
Scott Ullrich
|
|
239 |
5b237745
|
Scott Ullrich
|
if (!isset($dhcrelayifconf['enable']) ||
|
240 |
|
|
(($dhcrelayif != "lan") &&
|
241 |
|
|
(!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
|
242 |
|
|
continue;
|
243 |
a25183c5
|
Scott Ullrich
|
|
244 |
5b237745
|
Scott Ullrich
|
$dhcrelayifs[] = $ifcfg['if'];
|
245 |
|
|
}
|
246 |
|
|
|
247 |
a25183c5
|
Scott Ullrich
|
/* In order for the relay to work, it needs to be active on the
|
248 |
5b237745
|
Scott Ullrich
|
interface in which the destination server sits */
|
249 |
|
|
foreach ($config['interfaces'] as $ifname) {
|
250 |
|
|
$subnet = $ifname['ipaddr'] . "/" . $ifname['subnet'];
|
251 |
a25183c5
|
Scott Ullrich
|
if (ip_in_subnet($dhcrelaycfg['server'],$subnet))
|
252 |
|
|
$destif = $ifname['if'];
|
253 |
5b237745
|
Scott Ullrich
|
}
|
254 |
a25183c5
|
Scott Ullrich
|
|
255 |
|
|
if (!isset($destif))
|
256 |
5b237745
|
Scott Ullrich
|
$destif = $config['interfaces']['wan']['if'];
|
257 |
a25183c5
|
Scott Ullrich
|
|
258 |
5b237745
|
Scott Ullrich
|
$dhcrelayifs[] = $destif;
|
259 |
|
|
$dhcrelayifs = array_unique($dhcrelayifs);
|
260 |
|
|
|
261 |
|
|
/* fire up dhcrelay */
|
262 |
|
|
$cmd = "/usr/local/sbin/dhcrelay -i " . join(" -i ", $dhcrelayifs);
|
263 |
|
|
|
264 |
a25183c5
|
Scott Ullrich
|
if (isset($dhcrelaycfg['agentoption']))
|
265 |
5b237745
|
Scott Ullrich
|
$cmd .= " -a -m replace";
|
266 |
|
|
|
267 |
|
|
$cmd .= " {$dhcrelaycfg['server']}";
|
268 |
|
|
mwexec($cmd);
|
269 |
a25183c5
|
Scott Ullrich
|
|
270 |
5b237745
|
Scott Ullrich
|
if (!$g['booting']) {
|
271 |
e239df5a
|
Scott Ullrich
|
/* set the reload filter dity flag */
|
272 |
f229e20f
|
Scott Ullrich
|
touch("{$g['tmp_path']}/filter_dirty");
|
273 |
5c6d0f65
|
Colin Smith
|
}
|
274 |
a25183c5
|
Scott Ullrich
|
|
275 |
5b237745
|
Scott Ullrich
|
return 0;
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
function services_dyndns_reset() {
|
279 |
|
|
global $config, $g;
|
280 |
|
|
|
281 |
|
|
if (file_exists("{$g['vardb_path']}/ez-ipupdate.cache")) {
|
282 |
|
|
unlink("{$g['vardb_path']}/ez-ipupdate.cache");
|
283 |
a25183c5
|
Scott Ullrich
|
}
|
284 |
|
|
|
285 |
5b237745
|
Scott Ullrich
|
if (file_exists("{$g['conf_path']}/ez-ipupdate.cache")) {
|
286 |
|
|
conf_mount_rw();
|
287 |
|
|
unlink("{$g['conf_path']}/ez-ipupdate.cache");
|
288 |
|
|
conf_mount_ro();
|
289 |
|
|
}
|
290 |
a25183c5
|
Scott Ullrich
|
|
291 |
5b237745
|
Scott Ullrich
|
return 0;
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
function services_dyndns_configure() {
|
295 |
|
|
global $config, $g;
|
296 |
a25183c5
|
Scott Ullrich
|
|
297 |
5b237745
|
Scott Ullrich
|
$dyndnscfg = $config['dyndns'];
|
298 |
9cc8c59e
|
Scott Ullrich
|
$wancfg = $config['interfaces']['wan'];
|
299 |
a25183c5
|
Scott Ullrich
|
|
300 |
5b237745
|
Scott Ullrich
|
if (isset($dyndnscfg['enable'])) {
|
301 |
a25183c5
|
Scott Ullrich
|
|
302 |
5b237745
|
Scott Ullrich
|
if ($g['booting'])
|
303 |
|
|
echo "Starting DynDNS client... ";
|
304 |
|
|
else
|
305 |
|
|
sleep(1);
|
306 |
a25183c5
|
Scott Ullrich
|
|
307 |
64ed8739
|
Erik Kristensen
|
$dns = new updatedns($dnsService = $config['dyndns']['type'],
|
308 |
|
|
$dnsHost = $config['dyndns']['host'],
|
309 |
|
|
$dnsUser = $config['dyndns']['username'],
|
310 |
|
|
$dnsPass = $config['dyndns']['password'],
|
311 |
|
|
$dnsWilcard = $config['dyndns']['wildcard'],
|
312 |
|
|
$dnsMX = $config['dyndns']['mx']);
|
313 |
a25183c5
|
Scott Ullrich
|
|
314 |
5b237745
|
Scott Ullrich
|
if ($g['booting'])
|
315 |
5c6d0f65
|
Colin Smith
|
echo "done.\n";
|
316 |
5b237745
|
Scott Ullrich
|
}
|
317 |
a25183c5
|
Scott Ullrich
|
|
318 |
5b237745
|
Scott Ullrich
|
return 0;
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
function services_dnsmasq_configure() {
|
322 |
|
|
global $config, $g;
|
323 |
|
|
|
324 |
|
|
/* kill any running dnsmasq */
|
325 |
|
|
sigkillbypid("{$g['varrun_path']}/dnsmasq.pid", "TERM");
|
326 |
|
|
|
327 |
|
|
if (isset($config['dnsmasq']['enable'])) {
|
328 |
a25183c5
|
Scott Ullrich
|
|
329 |
5b237745
|
Scott Ullrich
|
if ($g['booting'])
|
330 |
|
|
echo "Starting DNS forwarder... ";
|
331 |
|
|
else
|
332 |
|
|
sleep(1);
|
333 |
|
|
|
334 |
|
|
/* generate hosts file */
|
335 |
|
|
system_hosts_generate();
|
336 |
a25183c5
|
Scott Ullrich
|
|
337 |
5b237745
|
Scott Ullrich
|
$args = "";
|
338 |
a25183c5
|
Scott Ullrich
|
|
339 |
5b237745
|
Scott Ullrich
|
if (isset($config['dnsmasq']['regdhcp'])) {
|
340 |
a25183c5
|
Scott Ullrich
|
|
341 |
|
|
$args .= " -l {$g['vardb_path']}/dhcpd.leases" .
|
342 |
5b237745
|
Scott Ullrich
|
" -s {$config['system']['domain']}";
|
343 |
|
|
}
|
344 |
|
|
|
345 |
0c2b5df7
|
Scott Ullrich
|
if (isset($config['dnsmasq']['domainoverrides']) && is_array($config['dnsmasq']['domainoverrides'])) {
|
346 |
|
|
foreach($config['dnsmasq']['domainoverrides'] as $override) {
|
347 |
|
|
$args .= ' --server=/' . $override['domain'] . '/' . $override['ip'];
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
|
351 |
5b237745
|
Scott Ullrich
|
/* run dnsmasq */
|
352 |
|
|
mwexec("/usr/local/sbin/dnsmasq {$args}");
|
353 |
|
|
|
354 |
|
|
if ($g['booting'])
|
355 |
5c6d0f65
|
Colin Smith
|
echo "done.\n";
|
356 |
5b237745
|
Scott Ullrich
|
}
|
357 |
a25183c5
|
Scott Ullrich
|
|
358 |
5b237745
|
Scott Ullrich
|
if (!$g['booting']) {
|
359 |
|
|
services_dhcpd_configure();
|
360 |
|
|
}
|
361 |
|
|
|
362 |
|
|
return 0;
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
function services_snmpd_configure() {
|
366 |
|
|
global $config, $g;
|
367 |
|
|
|
368 |
|
|
/* kill any running snmpd */
|
369 |
|
|
sigkillbypid("{$g['varrun_path']}/snmpd.pid", "TERM");
|
370 |
|
|
|
371 |
|
|
if (isset($config['snmpd']['enable'])) {
|
372 |
a25183c5
|
Scott Ullrich
|
|
373 |
5b237745
|
Scott Ullrich
|
if ($g['booting'])
|
374 |
5c6d0f65
|
Colin Smith
|
echo "Starting SNMP daemon... ";
|
375 |
5b237745
|
Scott Ullrich
|
|
376 |
|
|
/* generate snmpd.conf */
|
377 |
|
|
$fd = fopen("{$g['varetc_path']}/snmpd.conf", "w");
|
378 |
|
|
if (!$fd) {
|
379 |
|
|
printf("Error: cannot open snmpd.conf in services_snmpd_configure().\n");
|
380 |
|
|
return 1;
|
381 |
|
|
}
|
382 |
a25183c5
|
Scott Ullrich
|
|
383 |
142da8f7
|
John Fleming
|
|
384 |
5b237745
|
Scott Ullrich
|
$snmpdconf = <<<EOD
|
385 |
d47a8a69
|
Scott Ullrich
|
location := "{$config['snmpd']['syslocation']}"
|
386 |
|
|
contact := "{$config['snmpd']['syscontact']}"
|
387 |
|
|
read := "{$config['snmpd']['rocommunity']}"
|
388 |
142da8f7
|
John Fleming
|
|
389 |
|
|
EOD;
|
390 |
|
|
|
391 |
|
|
/* No docs on what write strings do there for disable for now.
|
392 |
|
|
if(isset($config['snmpd']['rwenable']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])){
|
393 |
|
|
$snmpdconf .= <<<EOD
|
394 |
|
|
# write string
|
395 |
|
|
write := "{$config['snmpd']['rwcommunity']}"
|
396 |
|
|
|
397 |
|
|
EOD;
|
398 |
|
|
}
|
399 |
|
|
*/
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
if(isset($config['snmpd']['trapenable']) && preg_match('/^\S+$/', $config['snmpd']['trapserver'])){
|
403 |
|
|
$snmpdconf .= <<<EOD
|
404 |
|
|
# SNMP Trap support.
|
405 |
dbeeb008
|
John Fleming
|
traphost := {$config['snmpd']['trapserver']}
|
406 |
|
|
trapport := {$config['snmpd']['trapserverport']}
|
407 |
|
|
trap := "{$config['snmpd']['trapstring']}"
|
408 |
142da8f7
|
John Fleming
|
|
409 |
|
|
|
410 |
|
|
EOD;
|
411 |
|
|
}
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
$snmpdconf .= <<<EOD
|
415 |
d47a8a69
|
Scott Ullrich
|
system := 1 # pfSense
|
416 |
|
|
%snmpd
|
417 |
|
|
begemotSnmpdDebugDumpPdus = 2
|
418 |
|
|
begemotSnmpdDebugSyslogPri = 7
|
419 |
|
|
begemotSnmpdCommunityString.0.1 = $(read)
|
420 |
142da8f7
|
John Fleming
|
|
421 |
|
|
EOD;
|
422 |
|
|
|
423 |
|
|
/* No docs on what write strings do there for disable for now.
|
424 |
|
|
if(isset($config['snmpd']['rwcommunity']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])){
|
425 |
|
|
$snmpdconf .= <<<EOD
|
426 |
|
|
begemotSnmpdCommunityString.0.2 = $(write)
|
427 |
|
|
|
428 |
|
|
EOD;
|
429 |
|
|
}
|
430 |
|
|
*/
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
if(isset($config['snmpd']['trapenable']) && preg_match('/^\S+$/', $config['snmpd']['trapserver'])){
|
434 |
|
|
$snmpdconf .= <<<EOD
|
435 |
|
|
begemotTrapSinkStatus.[$(traphost)].$(trapport) = 4
|
436 |
|
|
begemotTrapSinkVersion.[$(traphost)].$(trapport) = 2
|
437 |
|
|
begemotTrapSinkComm.[$(traphost)].$(trapport) = $(trap)
|
438 |
|
|
|
439 |
|
|
EOD;
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
|
443 |
|
|
$snmpdconf .= <<<EOD
|
444 |
d47a8a69
|
Scott Ullrich
|
begemotSnmpdCommunityDisable = 1
|
445 |
03ba7a0f
|
John Fleming
|
|
446 |
|
|
EOD;
|
447 |
|
|
|
448 |
|
|
if(is_port( $config['snmpd']['pollport'] )) {
|
449 |
|
|
$snmpdconf .= <<<EOD
|
450 |
|
|
begemotSnmpdPortStatus.0.0.0.0.{$config['snmpd']['pollport']} = 1
|
451 |
|
|
|
452 |
|
|
EOD;
|
453 |
|
|
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
$snmpdconf .= <<<EOD
|
457 |
d47a8a69
|
Scott Ullrich
|
begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1
|
458 |
|
|
begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4
|
459 |
142da8f7
|
John Fleming
|
|
460 |
03ba7a0f
|
John Fleming
|
# These are bsnmp macros not php vars.
|
461 |
9cc8c59e
|
Scott Ullrich
|
sysContact = $(contact)
|
462 |
|
|
sysLocation = $(location)
|
463 |
|
|
sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1.$(system)
|
464 |
142da8f7
|
John Fleming
|
|
465 |
d47a8a69
|
Scott Ullrich
|
snmpEnableAuthenTraps = 2
|
466 |
03ba7a0f
|
John Fleming
|
|
467 |
|
|
EOD;
|
468 |
|
|
|
469 |
|
|
if (is_array( $config['snmpd']['modules'] )) {
|
470 |
|
|
if(isset($config['snmpd']['modules']['mibii'])) {
|
471 |
|
|
$snmpdconf .= <<<EOD
|
472 |
d47a8a69
|
Scott Ullrich
|
begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so"
|
473 |
03ba7a0f
|
John Fleming
|
|
474 |
|
|
EOD;
|
475 |
|
|
}
|
476 |
|
|
|
477 |
|
|
if(isset($config['snmpd']['modules']['netgraph'])) {
|
478 |
|
|
$snmpdconf .= <<<EOD
|
479 |
d47a8a69
|
Scott Ullrich
|
begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so"
|
480 |
|
|
%netgraph
|
481 |
|
|
begemotNgControlNodeName = "snmpd"
|
482 |
03ba7a0f
|
John Fleming
|
|
483 |
|
|
EOD;
|
484 |
|
|
}
|
485 |
|
|
|
486 |
|
|
if(isset($config['snmpd']['modules']['pf'])) {
|
487 |
|
|
$snmpdconf .= <<<EOD
|
488 |
d47a8a69
|
Scott Ullrich
|
begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so"
|
489 |
|
|
# config must end with blank line
|
490 |
5b237745
|
Scott Ullrich
|
|
491 |
03ba7a0f
|
John Fleming
|
|
492 |
5b237745
|
Scott Ullrich
|
EOD;
|
493 |
03ba7a0f
|
John Fleming
|
}
|
494 |
|
|
}
|
495 |
5b237745
|
Scott Ullrich
|
|
496 |
|
|
fwrite($fd, $snmpdconf);
|
497 |
|
|
fclose($fd);
|
498 |
|
|
|
499 |
853e003a
|
Scott Ullrich
|
/* run bsnmpd */
|
500 |
|
|
mwexec("/usr/sbin/bsnmpd -c {$g['varetc_path']}/snmpd.conf" .
|
501 |
|
|
" -p {$g['varrun_path']}/snmpd.pid");
|
502 |
|
|
// mwexec("/usr/local/sbin/snmpd -c {$g['varetc_path']}/snmpd.conf" .
|
503 |
|
|
// " -P {$g['varrun_path']}/snmpd.pid");
|
504 |
5b237745
|
Scott Ullrich
|
|
505 |
|
|
if ($g['booting'])
|
506 |
5c6d0f65
|
Colin Smith
|
echo "done.\n";
|
507 |
5b237745
|
Scott Ullrich
|
}
|
508 |
|
|
|
509 |
|
|
return 0;
|
510 |
|
|
}
|
511 |
|
|
|
512 |
|
|
function services_proxyarp_configure() {
|
513 |
|
|
global $config, $g;
|
514 |
|
|
|
515 |
|
|
/* kill any running choparp */
|
516 |
|
|
killbyname("choparp");
|
517 |
a25183c5
|
Scott Ullrich
|
|
518 |
1425e067
|
Bill Marquette
|
if (isset($config['virtualip']) && is_array($config['virtualip']['vip'])) {
|
519 |
a23d7248
|
Scott Ullrich
|
$paa = array();
|
520 |
a25183c5
|
Scott Ullrich
|
|
521 |
a23d7248
|
Scott Ullrich
|
/* group by interface */
|
522 |
1425e067
|
Bill Marquette
|
foreach ($config['virtualip']['vip'] as $vipent) {
|
523 |
|
|
if ($vipent['mode'] === "proxyarp") {
|
524 |
|
|
if ($vipent['interface'])
|
525 |
|
|
$if = $vipent['interface'];
|
526 |
|
|
else
|
527 |
|
|
$if = "wan";
|
528 |
a23d7248
|
Scott Ullrich
|
|
529 |
1425e067
|
Bill Marquette
|
if (!is_array($paa[$if]))
|
530 |
|
|
$paa[$if] = array();
|
531 |
a23d7248
|
Scott Ullrich
|
|
532 |
1425e067
|
Bill Marquette
|
$paa[$if][] = $vipent;
|
533 |
|
|
}
|
534 |
e4b7e011
|
Bill Marquette
|
}
|
535 |
a23d7248
|
Scott Ullrich
|
|
536 |
1425e067
|
Bill Marquette
|
if (count($paa))
|
537 |
e4b7e011
|
Bill Marquette
|
foreach ($paa as $paif => $paents) {
|
538 |
|
|
if ($paif == "wan" && !(is_ipaddr($config['interfaces']['wan']['ipaddr']) ||
|
539 |
a23d7248
|
Scott Ullrich
|
($config['interfaces']['wan']['ipaddr'] == "dhcp") ||
|
540 |
|
|
($config['interfaces']['wan']['ipaddr'] == "bigpond")))
|
541 |
|
|
continue;
|
542 |
|
|
|
543 |
e4b7e011
|
Bill Marquette
|
$args = $config['interfaces'][$paif]['if'] . " auto";
|
544 |
a23d7248
|
Scott Ullrich
|
|
545 |
e4b7e011
|
Bill Marquette
|
foreach ($paents as $paent) {
|
546 |
a23d7248
|
Scott Ullrich
|
|
547 |
1425e067
|
Bill Marquette
|
if (isset($paent['subnet']))
|
548 |
|
|
$args .= " " . escapeshellarg("{$paent['subnet']}/{$paent['subnet_bits']}");
|
549 |
e4b7e011
|
Bill Marquette
|
else if (isset($paent['range']))
|
550 |
|
|
$args .= " " . escapeshellarg($paent['range']['from'] . "-" .
|
551 |
|
|
$paent['range']['to']);
|
552 |
|
|
}
|
553 |
a25183c5
|
Scott Ullrich
|
|
554 |
e4b7e011
|
Bill Marquette
|
mwexec_bg("/usr/local/sbin/choparp " . $args);
|
555 |
|
|
}
|
556 |
a23d7248
|
Scott Ullrich
|
}
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
function services_dnsupdate_process() {
|
560 |
|
|
global $config, $g;
|
561 |
|
|
|
562 |
|
|
/* Dynamic DNS updating active? */
|
563 |
|
|
if (isset($config['dnsupdate']['enable'])) {
|
564 |
|
|
|
565 |
|
|
$wanip = get_current_wan_address();
|
566 |
|
|
if ($wanip) {
|
567 |
|
|
|
568 |
|
|
$keyname = $config['dnsupdate']['keyname'];
|
569 |
|
|
/* trailing dot */
|
570 |
|
|
if (substr($keyname, -1) != ".")
|
571 |
|
|
$keyname .= ".";
|
572 |
|
|
|
573 |
|
|
$hostname = $config['dnsupdate']['host'];
|
574 |
|
|
/* trailing dot */
|
575 |
|
|
if (substr($hostname, -1) != ".")
|
576 |
|
|
$hostname .= ".";
|
577 |
|
|
|
578 |
|
|
/* write private key file
|
579 |
|
|
this is dumb - public and private keys are the same for HMAC-MD5,
|
580 |
|
|
but nsupdate insists on having both */
|
581 |
|
|
$fd = fopen("{$g['varetc_path']}/K{$keyname}+157+00000.private", "w");
|
582 |
|
|
$privkey .= <<<EOD
|
583 |
|
|
Private-key-format: v1.2
|
584 |
|
|
Algorithm: 157 (HMAC)
|
585 |
|
|
Key: {$config['dnsupdate']['keydata']}
|
586 |
|
|
|
587 |
|
|
EOD;
|
588 |
|
|
fwrite($fd, $privkey);
|
589 |
|
|
fclose($fd);
|
590 |
|
|
|
591 |
|
|
/* write public key file */
|
592 |
|
|
if ($config['dnsupdate']['keytype'] == "zone") {
|
593 |
|
|
$flags = 257;
|
594 |
|
|
$proto = 3;
|
595 |
|
|
} else if ($config['dnsupdate']['keytype'] == "host") {
|
596 |
|
|
$flags = 513;
|
597 |
|
|
$proto = 3;
|
598 |
|
|
} else if ($config['dnsupdate']['keytype'] == "user") {
|
599 |
|
|
$flags = 0;
|
600 |
|
|
$proto = 2;
|
601 |
|
|
}
|
602 |
|
|
|
603 |
|
|
$fd = fopen("{$g['varetc_path']}/K{$keyname}+157+00000.key", "w");
|
604 |
|
|
fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$config['dnsupdate']['keydata']}\n");
|
605 |
|
|
fclose($fd);
|
606 |
|
|
|
607 |
|
|
/* generate update instructions */
|
608 |
|
|
$upinst = "update delete {$config['dnsupdate']['host']} A\n";
|
609 |
|
|
$upinst .= "update add {$config['dnsupdate']['host']} {$config['dnsupdate']['ttl']} A {$wanip}\n";
|
610 |
|
|
$upinst .= "\n"; /* mind that trailing newline! */
|
611 |
|
|
|
612 |
|
|
$fd = fopen("{$g['varetc_path']}/nsupdatecmds", "w");
|
613 |
|
|
fwrite($fd, $upinst);
|
614 |
|
|
fclose($fd);
|
615 |
|
|
|
616 |
|
|
/* invoke nsupdate */
|
617 |
|
|
$cmd = "/usr/sbin/nsupdate -k {$g['varetc_path']}:{$keyname}";
|
618 |
|
|
if (isset($config['dnsupdate']['usetcp']))
|
619 |
|
|
$cmd .= " -v";
|
620 |
|
|
$cmd .= " {$g['varetc_path']}/nsupdatecmds";
|
621 |
|
|
|
622 |
|
|
mwexec_bg($cmd);
|
623 |
|
|
}
|
624 |
|
|
}
|
625 |
|
|
|
626 |
|
|
return 0;
|
627 |
5b237745
|
Scott Ullrich
|
}
|
628 |
|
|
|
629 |
80ce93c6
|
Scott Ullrich
|
function setup_wireless_olsr($interface) {
|
630 |
|
|
$fd = fopen("{$g['varetc_path']}/{$interface}_olsr.conf", "w");
|
631 |
|
|
$olsr .= <<<EOD
|
632 |
|
|
#
|
633 |
|
|
# olsr.org OLSR daemon config file
|
634 |
|
|
#
|
635 |
|
|
# Lines starting with a # are discarded
|
636 |
|
|
#
|
637 |
|
|
# This file was shipped with olsrd 0.4.9
|
638 |
|
|
#
|
639 |
|
|
|
640 |
|
|
# Debug level(0-9)
|
641 |
|
|
# If set to 0 the daemon runs in the background
|
642 |
|
|
|
643 |
|
|
DebugLevel 1
|
644 |
|
|
|
645 |
|
|
# IP version to use (4 or 6)
|
646 |
|
|
|
647 |
|
|
IpVersion 4
|
648 |
|
|
|
649 |
|
|
# Clear the screen each time the internal state changes
|
650 |
|
|
|
651 |
|
|
ClearScreen yes
|
652 |
|
|
|
653 |
|
|
# HNA IPv4 routes
|
654 |
|
|
# syntax: netaddr netmask
|
655 |
|
|
# Example Internet gateway:
|
656 |
|
|
# 0.0.0.0 0.0.0.0
|
657 |
|
|
|
658 |
|
|
Hna4
|
659 |
|
|
{
|
660 |
|
|
# Internet gateway:
|
661 |
|
|
# 0.0.0.0 0.0.0.0
|
662 |
|
|
# more entries can be added:
|
663 |
|
|
# 192.168.1.0 255.255.255.0
|
664 |
|
|
}
|
665 |
|
|
|
666 |
|
|
# HNA IPv6 routes
|
667 |
|
|
# syntax: netaddr prefix
|
668 |
|
|
# Example Internet gateway:
|
669 |
|
|
Hna6
|
670 |
|
|
{
|
671 |
|
|
# Internet gateway:
|
672 |
|
|
# :: 0
|
673 |
|
|
# more entries can be added:
|
674 |
|
|
# fec0:2200:106:: 48
|
675 |
|
|
}
|
676 |
|
|
|
677 |
|
|
|
678 |
|
|
# Should olsrd keep on running even if there are
|
679 |
|
|
# no interfaces available? This is a good idea
|
680 |
|
|
# for a PCMCIA/USB hotswap environment.
|
681 |
|
|
# "yes" OR "no"
|
682 |
|
|
|
683 |
|
|
AllowNoInt yes
|
684 |
|
|
|
685 |
|
|
# TOS(type of service) value for
|
686 |
|
|
# the IP header of control traffic.
|
687 |
|
|
# If not set it will default to 16
|
688 |
|
|
|
689 |
|
|
#TosValue 16
|
690 |
|
|
|
691 |
|
|
# The fixed willingness to use(0-7)
|
692 |
|
|
# If not set willingness will be calculated
|
693 |
|
|
# dynamically based on battery/power status
|
694 |
|
|
# if such information is available
|
695 |
|
|
|
696 |
|
|
#Willingness 4
|
697 |
|
|
|
698 |
|
|
# Allow processes like the GUI front-end
|
699 |
|
|
# to connect to the daemon.
|
700 |
|
|
|
701 |
|
|
IpcConnect
|
702 |
|
|
{
|
703 |
|
|
# Determines how many simultaneously
|
704 |
|
|
# IPC connections that will be allowed
|
705 |
|
|
# Setting this to 0 disables IPC
|
706 |
|
|
|
707 |
|
|
MaxConnections 0
|
708 |
|
|
|
709 |
|
|
# By default only 127.0.0.1 is allowed
|
710 |
|
|
# to connect. Here allowed hosts can
|
711 |
|
|
# be added
|
712 |
|
|
|
713 |
|
|
Host 127.0.0.1
|
714 |
|
|
#Host 10.0.0.5
|
715 |
|
|
|
716 |
|
|
# You can also specify entire net-ranges
|
717 |
|
|
# that are allowed to connect. Multiple
|
718 |
|
|
# entries are allowed
|
719 |
|
|
|
720 |
|
|
#Net 192.168.1.0 255.255.255.0
|
721 |
|
|
}
|
722 |
|
|
|
723 |
|
|
# Wether to use hysteresis or not
|
724 |
|
|
# Hysteresis adds more robustness to the
|
725 |
|
|
# link sensing but delays neighbor registration.
|
726 |
|
|
# Used by default. 'yes' or 'no'
|
727 |
|
|
|
728 |
|
|
UseHysteresis yes
|
729 |
|
|
|
730 |
|
|
# Hysteresis parameters
|
731 |
|
|
# Do not alter these unless you know
|
732 |
|
|
# what you are doing!
|
733 |
|
|
# Set to auto by default. Allowed
|
734 |
|
|
# values are floating point values
|
735 |
|
|
# in the interval 0,1
|
736 |
|
|
# THR_LOW must always be lower than
|
737 |
|
|
# THR_HIGH.
|
738 |
|
|
|
739 |
|
|
HystScaling 0.50
|
740 |
|
|
HystThrHigh 0.80
|
741 |
|
|
HystThrLow 0.30
|
742 |
|
|
|
743 |
|
|
|
744 |
|
|
# Link quality level
|
745 |
|
|
# 0 = do not use link quality
|
746 |
|
|
# 1 = use link quality for MPR selection
|
747 |
|
|
# 2 = use link quality for MPR selection and routing
|
748 |
|
|
# Defaults to 0
|
749 |
|
|
|
750 |
|
|
#LinkQualityLevel 0
|
751 |
|
|
|
752 |
|
|
# Link quality window size
|
753 |
|
|
# Defaults to 10
|
754 |
|
|
|
755 |
|
|
#LinkQualityWinSize 10
|
756 |
|
|
|
757 |
|
|
# Polling rate in seconds(float).
|
758 |
|
|
# Default value 0.05 sec
|
759 |
|
|
|
760 |
|
|
Pollrate 0.05
|
761 |
|
|
|
762 |
|
|
|
763 |
|
|
# TC redundancy
|
764 |
|
|
# Specifies how much neighbor info should
|
765 |
|
|
# be sent in TC messages
|
766 |
|
|
# Possible values are:
|
767 |
|
|
# 0 - only send MPR selectors
|
768 |
|
|
# 1 - send MPR selectors and MPRs
|
769 |
|
|
# 2 - send all neighbors
|
770 |
|
|
#
|
771 |
|
|
# defaults to 0
|
772 |
|
|
|
773 |
|
|
#TcRedundancy 0
|
774 |
|
|
|
775 |
|
|
|
776 |
|
|
#
|
777 |
|
|
# MPR coverage
|
778 |
|
|
# Specifies how many MPRs a node should
|
779 |
|
|
# try select to reach every 2 hop neighbor
|
780 |
|
|
#
|
781 |
|
|
# Can be set to any integer >0
|
782 |
|
|
#
|
783 |
|
|
# defaults to 1
|
784 |
|
|
|
785 |
|
|
#MprCoverage 1
|
786 |
|
|
|
787 |
|
|
|
788 |
|
|
# Olsrd plugins to load
|
789 |
|
|
# This must be the absolute path to the file
|
790 |
|
|
# or the loader will use the following scheme:
|
791 |
|
|
# - Try the paths in the LD_LIBRARY_PATH
|
792 |
|
|
# environment variable.
|
793 |
|
|
# - The list of libraries cached in /etc/ld.so.cache
|
794 |
|
|
# - /lib, followed by /usr/lib
|
795 |
|
|
|
796 |
|
|
# Example plugin entry with parameters:
|
797 |
|
|
|
798 |
|
|
#LoadPlugin "olsrd_dyn_gw.so.0.3"
|
799 |
|
|
#{
|
800 |
|
|
# Here parameters are set to be sent to the
|
801 |
|
|
# plugin. Theese are on the form "key" "value".
|
802 |
|
|
# Parameters ofcause, differs from plugin to plugin.
|
803 |
|
|
# Consult the documentation of your plugin for details.
|
804 |
|
|
|
805 |
|
|
# Example: dyn_gw params
|
806 |
|
|
|
807 |
|
|
# how often to check for Internet connectivity
|
808 |
|
|
# defaults to 5 secs
|
809 |
|
|
# PlParam "Interval" "40"
|
810 |
|
|
|
811 |
|
|
# if one or more IPv4 addresses are given, do a ping on these in
|
812 |
|
|
# descending order to validate that there is not only an entry in
|
813 |
|
|
# routing table, but also a real internet connection. If any of
|
814 |
|
|
# these addresses could be pinged successfully, the test was
|
815 |
|
|
# succesful, i.e. if the ping on the 1st address was successful,the
|
816 |
|
|
# 2nd won't be pinged
|
817 |
|
|
# PlParam "Ping" "141.1.1.1"
|
818 |
|
|
# PlParam "Ping" "194.25.2.129"
|
819 |
|
|
#}
|
820 |
|
|
|
821 |
|
|
|
822 |
|
|
|
823 |
|
|
# Interfaces and their rules
|
824 |
|
|
# Omitted options will be set to the
|
825 |
|
|
# default values. Multiple interfaces
|
826 |
|
|
# can be specified in the same block
|
827 |
|
|
# and multiple blocks can be set.
|
828 |
|
|
|
829 |
|
|
# !!CHANGE THE INTERFACE LABEL(s) TO MATCH YOUR INTERFACE(s)!!
|
830 |
|
|
# (eg. wlan0 or eth1):
|
831 |
|
|
|
832 |
|
|
Interface "{$interface}"
|
833 |
|
|
{
|
834 |
|
|
|
835 |
|
|
# IPv4 broadcast address to use. The
|
836 |
|
|
# one usefull example would be 255.255.255.255
|
837 |
|
|
# If not defined the broadcastaddress
|
838 |
|
|
# every card is configured with is used
|
839 |
|
|
|
840 |
|
|
# Ip4Broadcast 255.255.255.255
|
841 |
|
|
|
842 |
|
|
# IPv6 address scope to use.
|
843 |
|
|
# Must be 'site-local' or 'global'
|
844 |
|
|
|
845 |
|
|
# Ip6AddrType site-local
|
846 |
|
|
|
847 |
|
|
# IPv6 multicast address to use when
|
848 |
|
|
# using site-local addresses.
|
849 |
|
|
# If not defined, ff05::15 is used
|
850 |
|
|
|
851 |
|
|
# Ip6MulticastSite ff05::11
|
852 |
|
|
|
853 |
|
|
# IPv6 multicast address to use when
|
854 |
|
|
# using global addresses
|
855 |
|
|
# If not defined, ff0e::1 is used
|
856 |
|
|
|
857 |
|
|
# Ip6MulticastGlobal ff0e::1
|
858 |
|
|
|
859 |
|
|
|
860 |
|
|
# Emission intervals.
|
861 |
|
|
# If not defined, RFC proposed values will
|
862 |
|
|
# be used in most cases.
|
863 |
|
|
|
864 |
|
|
# Hello interval in seconds(float)
|
865 |
|
|
# HelloInterval 2.0
|
866 |
|
|
|
867 |
|
|
# HELLO validity time
|
868 |
|
|
# HelloValidityTime 6.0
|
869 |
|
|
|
870 |
|
|
# TC interval in seconds(float)
|
871 |
|
|
# TcInterval 5.0
|
872 |
|
|
|
873 |
|
|
# TC validity time
|
874 |
|
|
# TcValidityTime 15.0
|
875 |
|
|
|
876 |
|
|
# MID interval in seconds(float)
|
877 |
|
|
# MidInterval 5.0
|
878 |
|
|
|
879 |
|
|
# MID validity time
|
880 |
|
|
# MidValidityTime 15.0
|
881 |
|
|
|
882 |
|
|
# HNA interval in seconds(float)
|
883 |
|
|
# HnaInterval 5.0
|
884 |
|
|
|
885 |
|
|
# HNA validity time
|
886 |
|
|
# HnaValidityTime 15.0
|
887 |
|
|
|
888 |
|
|
# When multiple links exist between hosts
|
889 |
|
|
# the weight of interface is used to determine
|
890 |
|
|
# the link to use. Normally the weight is
|
891 |
|
|
# automatically calculated by olsrd based
|
892 |
|
|
# on the characteristics of the interface,
|
893 |
|
|
# but here you can specify a fixed value.
|
894 |
|
|
# Olsrd will choose links with the lowest value.
|
895 |
|
|
|
896 |
|
|
# Weight 0
|
897 |
|
|
|
898 |
|
|
|
899 |
|
|
}
|
900 |
|
|
EOD;
|
901 |
|
|
fwrite($fd, $olsr);
|
902 |
|
|
fclose($fd);
|
903 |
|
|
mwexec_bg("/usr/local/sbin/olsrd -f {$g['varetc_path']}/{$interface}_olsr.conf");
|
904 |
|
|
}
|
905 |
|
|
|
906 |
d09f5292
|
Scott Ullrich
|
?>
|