Project

General

Profile

Download (3.35 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php-cgi -f
2
<?php
3
/*
4
	rc.banner
5
	part of pfSense
6
	Copyright (C) 2005 Scott Ullrich and Colin Smith
7
	Copyright (C) 2009 Ermal Luçi
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
	/* parse the configuration and include all functions used below */
33
	require_once("config.inc");
34
	require_once("gwlb.inc");
35
	require_once("interfaces.inc");
36

    
37
	$platform = trim(file_get_contents("{$g['etc_path']}/platform"));
38
	$hostname = $config['system']['hostname'];
39
	$product = $g['product_name'];
40
	$machine = trim(`uname -m`);
41
	$hideplatform = $g['hideplatform'];
42

    
43
	if (!$hideplatform) {
44
		$platformbanner = "-{$platform}";
45
	}
46

    
47
	print "*** Welcome to {$product} {$g['product_version']}{$platformbanner} ({$machine}) on {$hostname} ***\n";
48

    
49
	$iflist = get_configured_interface_with_descr(false, true);
50
	foreach ($iflist as $ifname => $friendly) {
51
		/* point to this interface's config */
52
		$ifconf = $config['interfaces'][$ifname];
53
		/* look for 'special cases' */
54
		switch ($ifconf['ipaddr']) {
55
			case "dhcp":
56
				$class = "/DHCP4";
57
				break;
58
			case "pppoe":
59
				$class = "/PPPoE";
60
				break;
61
			case "pptp":
62
				$class = "/PPTP";
63
				break;
64
			case "l2tp":
65
				$class = "/L2TP";
66
				break;
67
			default:
68
				$class = "";
69
				break;
70
		}
71
		switch ($ifconf['ipaddrv6']) {
72
			case "dhcp6":
73
				$class6 = "/DHCP6";
74
				break;
75
			case "slaac":
76
				$class6 = "/SLAAC";
77
				break;
78
			case "6rd":
79
				$class6 = "/6RD";
80
				break;
81
			case "6to4":
82
				$class6 = "/6to4";
83
				break;
84
			case "track6":
85
				$class6 = "/t6";
86
				break;
87
			default:
88
				$class6 = "";
89
				break;
90
		}
91
		$ipaddr = get_interface_ip($ifname);
92
		$subnet = get_interface_subnet($ifname);
93
		$ipaddr6 = get_interface_ipv6($ifname);
94
		$subnet6 = get_interface_subnetv6($ifname);
95
		$realif = get_real_interface($ifname);
96
		$tobanner = "{$friendly} ({$ifname})";
97

    
98
		printf("\n %-15s -> %-10s -> ",
99
			$tobanner,
100
			$realif
101
		);
102
		$v6first = false;
103
		if (!empty($ipaddr) && !empty($subnet)) {
104
			printf("v4%s: %s/%s",
105
				$class,
106
				$ipaddr,
107
				$subnet
108
			);
109
		} else {
110
			$v6first = true;
111
		}
112
		if (!empty($ipaddr6) && !empty($subnet6)) {
113
			if (!$v6first) {
114
				printf("\n%s", str_repeat(" ", 34));
115
			}
116
			printf("v6%s: %s/%s",
117
				$class6,
118
				$ipaddr6,
119
				$subnet6
120
			);
121
		}
122
	}
123
	printf("\n");
124
?>
(26-26/94)