1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/*
|
4
|
$Id$
|
5
|
|
6
|
rc.banner
|
7
|
part of pfSense
|
8
|
Copyright (C) 2005 Scott Ullrich and Colin Smith
|
9
|
Copyright (C) 2009 Ermal Lu?i
|
10
|
All rights reserved
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
/* parse the configuration and include all functions used below */
|
35
|
require_once("config.inc");
|
36
|
require_once("gwlb.inc");
|
37
|
require_once("interfaces.inc");
|
38
|
|
39
|
$version = trim(file_get_contents("{$g['etc_path']}/version"));
|
40
|
$platform = trim(file_get_contents("{$g['etc_path']}/platform"));
|
41
|
$hostname = $config['system']['hostname'];
|
42
|
$product = $g['product_name'];
|
43
|
$machine = trim(`uname -m`);
|
44
|
$hideplatform = $g['hideplatform'];
|
45
|
|
46
|
if(!$hideplatform)
|
47
|
$platformbanner = "-{$platform}";
|
48
|
|
49
|
print "*** Welcome to {$product} {$version}{$platformbanner} ({$machine}) on {$hostname} ***\n";
|
50
|
|
51
|
$iflist = get_configured_interface_with_descr(false, true);
|
52
|
foreach($iflist as $ifname => $friendly) {
|
53
|
/* point to this interface's config */
|
54
|
$ifconf = $config['interfaces'][$ifname];
|
55
|
/* look for 'special cases' */
|
56
|
switch($ifconf['ipaddr']) {
|
57
|
case "dhcp":
|
58
|
$class = "/DHCP4";
|
59
|
break;
|
60
|
case "pppoe":
|
61
|
$class = "/PPPoE";
|
62
|
break;
|
63
|
case "pptp":
|
64
|
$class = "/PPTP";
|
65
|
break;
|
66
|
case "l2tp":
|
67
|
$class = "/L2TP";
|
68
|
break;
|
69
|
default:
|
70
|
$class = "";
|
71
|
break;
|
72
|
}
|
73
|
switch($ifconf['ipaddrv6']) {
|
74
|
case "dhcp6":
|
75
|
$class6 = "/DHCP6";
|
76
|
break;
|
77
|
case "slaac":
|
78
|
$class6 = "/SLAAC";
|
79
|
break;
|
80
|
case "6rd":
|
81
|
$class6 = "/6RD";
|
82
|
break;
|
83
|
case "6to4":
|
84
|
$class6 = "/6to4";
|
85
|
break;
|
86
|
case "track6":
|
87
|
$class6 = "/t6";
|
88
|
break;
|
89
|
}
|
90
|
$ipaddr = get_interface_ip($ifname);
|
91
|
$subnet = get_interface_subnet($ifname);
|
92
|
$ipaddr6 = get_interface_ipv6($ifname);
|
93
|
$subnet6 = get_interface_subnetv6($ifname);
|
94
|
$realif = get_real_interface($ifname);
|
95
|
$tobanner = "{$friendly} ({$ifname})";
|
96
|
|
97
|
printf("\n %-15s -> %-10s -> ",
|
98
|
$tobanner,
|
99
|
$realif
|
100
|
);
|
101
|
$v6first = false;
|
102
|
if (!empty($ipaddr) && !empty($subnet)) {
|
103
|
printf("v4%s: %s/%s",
|
104
|
$class,
|
105
|
$ipaddr,
|
106
|
$subnet
|
107
|
);
|
108
|
} else {
|
109
|
$v6first = true;
|
110
|
}
|
111
|
if (!empty($ipaddr6) && !empty($subnet6)) {
|
112
|
if (!$v6first) {
|
113
|
printf("\n%s", str_repeat(" ",34));
|
114
|
}
|
115
|
printf("v6%s: %s/%s",
|
116
|
$class6,
|
117
|
$ipaddr6,
|
118
|
$subnet6
|
119
|
);
|
120
|
}
|
121
|
}
|
122
|
|
123
|
?>
|