1 |
1a978734
|
Scott Ullrich
|
#!/usr/local/bin/php -f
|
2 |
|
|
<?php
|
3 |
|
|
/*
|
4 |
7a221543
|
Scott Ullrich
|
rc.linkup - devd hotplug actions
|
5 |
adab3c25
|
Scott Ullrich
|
part of pfSense
|
6 |
1a978734
|
Scott Ullrich
|
|
7 |
|
|
Copyright (C) 2003-2005 Scott Ullrich <sullrich@gmail.com>.
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
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 |
|
|
|
20 |
|
|
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 |
4367b5f6
|
Ermal Luçi
|
/* parse the configuration and include all functions used below */
|
33 |
|
|
require_once("globals.inc");
|
34 |
|
|
require_once("config.inc");
|
35 |
5f2d078e
|
Scott Ullrich
|
require_once("filter.inc");
|
36 |
|
|
require_once("shaper.inc");
|
37 |
a55e9c70
|
Ermal Lu?i
|
require_once("interfaces.inc");
|
38 |
1a978734
|
Scott Ullrich
|
|
39 |
5b70c17e
|
Ermal Lu?i
|
function handle_argument_group($iface, $argument2) {
|
40 |
4367b5f6
|
Ermal Luçi
|
global $config;
|
41 |
4476d447
|
Ermal Luçi
|
|
42 |
5b70c17e
|
Ermal Lu?i
|
$ipaddr = $config['interfaces'][$iface]['ipaddr'];
|
43 |
69695597
|
Ermal
|
if (is_ipaddr($ipaddr) || empty($ipaddr)) {
|
44 |
58a52416
|
Chris Buechler
|
log_error("Hotplug event detected for {$iface} but ignoring since interface is configured with static IP ({$ipaddr})");
|
45 |
8ee623f3
|
jim-p
|
interfaces_staticarp_configure($iface);
|
46 |
5b70c17e
|
Ermal Lu?i
|
$iface = get_real_interface($iface);
|
47 |
a798fd3e
|
Ermal
|
interfaces_bring_up($iface);
|
48 |
b7d56b64
|
Ermal
|
if ($argument2 == "start" || $argument2 == "up")
|
49 |
|
|
send_event("interface newip {$iface}");
|
50 |
4367b5f6
|
Ermal Luçi
|
} else {
|
51 |
|
|
switch ($argument2) {
|
52 |
|
|
case "stop":
|
53 |
|
|
case "down":
|
54 |
5b70c17e
|
Ermal Lu?i
|
log_error("DEVD Ethernet detached event for {$iface}");
|
55 |
|
|
interface_bring_down($iface);
|
56 |
|
|
break;
|
57 |
4367b5f6
|
Ermal Luçi
|
case "start":
|
58 |
ae39786e
|
Chris Buechler
|
log_error("DEVD Ethernet attached event for {$iface}");
|
59 |
8ee623f3
|
jim-p
|
interfaces_staticarp_configure($iface);
|
60 |
ae39786e
|
Chris Buechler
|
log_error("HOTPLUG: Configuring interface {$iface}");
|
61 |
7413cbfd
|
Ermal
|
// Do not try to readd to bridge otherwise em(4) has problems
|
62 |
|
|
interface_configure($iface, false, true);
|
63 |
ae39786e
|
Chris Buechler
|
break;
|
64 |
4367b5f6
|
Ermal Luçi
|
case "up":
|
65 |
5b70c17e
|
Ermal Lu?i
|
log_error("DEVD Ethernet attached event for {$iface}");
|
66 |
8ee623f3
|
jim-p
|
interfaces_staticarp_configure($iface);
|
67 |
5b70c17e
|
Ermal Lu?i
|
log_error("HOTPLUG: Configuring interface {$iface}");
|
68 |
|
|
interface_configure($iface);
|
69 |
4367b5f6
|
Ermal Luçi
|
break;
|
70 |
a7b5cfbe
|
Scott Ullrich
|
}
|
71 |
4367b5f6
|
Ermal Luçi
|
}
|
72 |
|
|
}
|
73 |
1a978734
|
Scott Ullrich
|
|
74 |
24d5fc0a
|
jim-p
|
global $g;
|
75 |
|
|
if (file_exists("{$g['varrun_path']}/booting")) {
|
76 |
4367b5f6
|
Ermal Luçi
|
/* ignore all linkup events */
|
77 |
|
|
} else {
|
78 |
a3a3a6b1
|
Seth Mos
|
foreach($_SERVER['argv'] as $argv) {
|
79 |
|
|
switch($argv) {
|
80 |
|
|
case "start":
|
81 |
|
|
$action = "start";
|
82 |
|
|
break;
|
83 |
|
|
case "stop":
|
84 |
|
|
$action = "stop";
|
85 |
|
|
break;
|
86 |
|
|
case "/etc/rc.linkup":
|
87 |
|
|
break;
|
88 |
|
|
default:
|
89 |
|
|
$interface = convert_real_interface_to_friendly_interface_name($argv);
|
90 |
|
|
if($interface == "") {
|
91 |
|
|
unset($interface);
|
92 |
|
|
}
|
93 |
|
|
break;
|
94 |
|
|
}
|
95 |
|
|
if(($action) && ($interface)) {
|
96 |
|
|
handle_argument_group($interface, $action);
|
97 |
|
|
unset ($action, $interface);
|
98 |
|
|
}
|
99 |
4367b5f6
|
Ermal Luçi
|
}
|
100 |
|
|
}
|
101 |
f4538770
|
Scott Ullrich
|
|
102 |
a55e9c70
|
Ermal Lu?i
|
?>
|