Project

General

Profile

Download (3.01 KB) Statistics
| Branch: | Tag: | Revision:
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 4367b5f6 Ermal Luçi
	if (is_ipaddr($ipaddr)) {
44 58a52416 Chris Buechler
		log_error("Hotplug event detected for {$iface} but ignoring since interface is configured with static IP ({$ipaddr})");
45 5b70c17e Ermal Lu?i
		$iface = get_real_interface($iface);
46
		exec("/usr/sbin/arp -d -i {$iface} -a");
47 4367b5f6 Ermal Luçi
	} else {
48
		switch ($argument2) {
49
		case "stop":
50
		case "down":
51 5b70c17e Ermal Lu?i
			log_error("DEVD Ethernet detached event for {$iface}");
52
			interface_bring_down($iface);
53
			break;
54 4367b5f6 Ermal Luçi
		case "start":
55
		case "up":
56 5b70c17e Ermal Lu?i
			log_error("DEVD Ethernet attached event for {$iface}");
57
			$riface = get_real_interface($iface);
58
			exec("/usr/sbin/arp -d -i {$riface} -a");
59
			log_error("HOTPLUG: Configuring interface {$iface}");
60
			interface_configure($iface);
61 4367b5f6 Ermal Luçi
			break;
62 a7b5cfbe Scott Ullrich
		}
63 4367b5f6 Ermal Luçi
	}
64
}
65 1a978734 Scott Ullrich
66 4367b5f6 Ermal Luçi
if ($g['booting'] == true) {
67
	/* ignore all linkup events */
68
} else {
69 a3a3a6b1 Seth Mos
	foreach($_SERVER['argv'] as $argv) {
70
		switch($argv) {
71
			case "start":
72
				$action = "start";
73
				break;
74
			case "stop":
75
				$action = "stop";
76
				break;
77
			case "/etc/rc.linkup":
78
				break;
79
			default:
80
				$interface = convert_real_interface_to_friendly_interface_name($argv);
81
				if($interface == "") {
82
					unset($interface);
83
				}
84
				break;
85
		}
86
		if(($action) && ($interface)) {
87
			handle_argument_group($interface, $action);
88
			unset ($action, $interface);
89
		}
90 4367b5f6 Ermal Luçi
	}
91
}
92 f4538770 Scott Ullrich
93 a55e9c70 Ermal Lu?i
?>