Project

General

Profile

Download (9.19 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_ntpd_pps.php
5

    
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	Copyright (C) 2013	Dagorlad
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
	pfSense_MODULE:	ntpd_pps
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-services-ntpd-pps
37
##|*NAME=Services: NTP PPS page
38
##|*DESCR=Allow access to the 'Services: NTP PPS' page..
39
##|*MATCH=services_ntpd_pps.php*
40
##|-PRIV
41

    
42
require_once("guiconfig.inc");
43

    
44
if (!is_array($config['ntpd']))
45
	$config['ntpd'] = array();
46
if (!is_array($config['ntpd']['pps']))
47
	$config['ntpd']['pps'] = array();
48

    
49
if ($_POST) {
50

    
51
	unset($input_errors);
52

    
53
	if (!$input_errors) {
54
		if (!empty($_POST['ppsport']) && file_exists('/dev/'.$_POST['ppsport']))
55
			$config['ntpd']['pps']['port'] = $_POST['ppsport'];
56
		/* if port is not set, remove all the pps config */
57
		else unset($config['ntpd']['pps']);
58

    
59
		if (!empty($_POST['ppsfudge1']))
60
			$config['ntpd']['pps']['fudge1'] = $_POST['ppsfudge1'];
61
		elseif (isset($config['ntpd']['pps']['fudge1']))
62
			unset($config['ntpd']['pps']['fudge1']);
63

    
64
		if (!empty($_POST['ppsstratum']) && ($_POST['ppsstratum']) < 17 )
65
			$config['ntpd']['pps']['stratum'] = $_POST['ppsstratum'];
66
		elseif (isset($config['ntpd']['pps']['stratum']))
67
			unset($config['ntpd']['pps']['stratum']);
68

    
69
		if (!empty($_POST['ppsselect']))
70
			$config['ntpd']['pps']['noselect'] = $_POST['ppsselect'];
71
		elseif (isset($config['ntpd']['pps']['noselect']))
72
			unset($config['ntpd']['pps']['noselect']);
73

    
74
		if (!empty($_POST['ppsflag2']))
75
			$config['ntpd']['pps']['flag2'] = $_POST['ppsflag2'];
76
		elseif (isset($config['ntpd']['pps']['flag2']))
77
			unset($config['ntpd']['pps']['flag2']);
78

    
79
		if (!empty($_POST['ppsflag3']))
80
			$config['ntpd']['pps']['flag3'] = $_POST['ppsflag3'];
81
		elseif (isset($config['ntpd']['pps']['flag3']))
82
			unset($config['ntpd']['pps']['flag3']);
83

    
84
		if (!empty($_POST['ppsflag4']))
85
			$config['ntpd']['pps']['flag4'] = $_POST['ppsflag4'];
86
		elseif (isset($config['ntpd']['pps']['flag4']))
87
			unset($config['ntpd']['pps']['flag4']);
88

    
89
		if (!empty($_POST['ppsrefid']))
90
			$config['ntpd']['pps']['refid'] = $_POST['ppsrefid'];
91
		elseif (isset($config['ntpd']['pps']['refid']))
92
			unset($config['ntpd']['pps']['refid']);
93
			
94
		write_config("Updated NTP PPS Settings");
95

    
96
		$retval = 0;
97
		$retval = system_ntp_configure();
98
		$savemsg = get_std_save_message($retval);
99
	}
100
}
101
$pconfig = &$config['ntpd']['pps'];
102

    
103
$pgtitle = array(gettext("Services"),gettext("NTP PPS"));
104
$shortcut_section = "ntp";
105
include("head.inc");
106
?>
107

    
108
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
109
<?php include("fbegin.inc"); ?>
110
<form action="services_ntpd_pps.php" method="post" name="iform" id="iform">
111
<?php if ($input_errors) print_input_errors($input_errors); ?>
112
<?php if ($savemsg) print_info_box($savemsg); ?>
113

    
114
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="ntpd pps">
115
  <tr>
116
	<td>
117
<?php
118
	$tab_array = array();
119
	$tab_array[] = array(gettext("NTP"), false, "services_ntpd.php");
120
	$tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php");
121
	$tab_array[] = array(gettext("PPS"), true, "services_ntpd_pps.php");
122
	display_top_tabs($tab_array);
123
?>
124
	</td>
125
  </tr>
126
  <tr>
127
	<td>
128
	<div id="mainarea">
129
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
130
		<tr>
131
			<td colspan="2" valign="top" class="listtopic"><?=gettext("NTP PPS Configuration"); ?></td>
132
		</tr>
133
		<tr>
134
			<td width="22%" valign="top" class="vncellreq">
135
			</td>
136
			<td width="78%" class="vtable"><?php echo gettext("Devices with a Pulse Per Second output such as radios that receive a time signal from DCF77 (DE), JJY (JP), MSF (GB) or WWVB (US) may be used as a PPS reference for NTP.");?> 
137
			<?php echo gettext("A serial GPS may also be used, but the serial GPS driver would usually be the better option.");?> 
138
			<?php echo gettext("A PPS signal only provides a reference to the change of a second, so at least one other source to number the seconds is required.");?>
139
			<br />
140
			<br /><strong><?php echo gettext("Note");?>:</strong> <?php echo gettext("At least 3 additional time sources should be configured under"); ?> <a href="services_ntpd.php"><?php echo gettext("Services > NTP"); ?></a> <?php echo gettext("to reliably supply the time of each PPS pulse."); ?>
141
			</td>
142
		</tr>
143
<?php $serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE); ?>
144
<?php if (!empty($serialports)): ?>
145
		<tr>
146
			<td width="22%" valign="top" class="vncellreq">Serial port</td>
147
			<td width="78%" class="vtable">
148
				<select name="ppsport" class="formselect">
149
					<option value="">none</option>
150
					<?php foreach ($serialports as $port):
151
						$shortport = substr($port,5);
152
						$selected = ($shortport == $pconfig['port']) ? " selected=\"selected\"" : "";?>
153
						<option value="<?php echo $shortport;?>"<?php echo $selected;?>><?php echo $shortport;?></option>
154
					<?php endforeach; ?>
155
				</select>&nbsp;
156
				<?php echo gettext("All serial ports are listed, be sure to pick the port with the PPS source attached."); ?>
157
			</td>
158
		</tr>
159
<?php endif; ?>
160
		<tr>
161
			<td width="22%" valign="top" class="vncellreq">Fudge time</td>
162
			<td width="78%" class="vtable">
163
				<input name="ppsfudge1" type="text" class="formfld unknown" id="ppsfudge1" min="-1" max="1" size="20" value="<?=htmlspecialchars($pconfig['fudge1']);?>" />(<?php echo gettext("seconds");?>)<br />
164
				<?php echo gettext("Fudge time is used to specify the PPS signal offset from the actual second such as the transmission delay between the transmitter and the receiver.");?> (<?php echo gettext("default");?>: 0.0).</td>
165
		</tr>
166
		<tr>
167
			<td width="22%" valign="top" class="vncellreq">Stratum</td>
168
			<td width="78%" class="vtable">
169
				<input name="ppsstratum" type="text" class="formfld unknown" id="ppsstratum" max="16" size="20" value="<?=htmlspecialchars($pconfig['stratum']);?>" /><?php echo gettext("(0-16)");?><br />
170
				<?php echo gettext("This may be used to change the PPS Clock stratum");?> (<?php echo gettext("default");?>: 0). <?php echo gettext("This may be useful if, for some reason, you want ntpd to prefer a different clock and just monitor this source."); ?></td>
171
		</tr>
172
		<tr>
173
			<td width="22%" valign="top" class="vncellreq">Flags</td>
174
			<td width="78%" class="vtable">
175
				<table summary="flags">
176
					<tr>
177
						<td>
178
				<?php echo gettext("Normally there should be no need to change these options from the defaults."); ?><br />
179
						</td>
180
					</tr>
181
				</table>
182
				<table>
183
					<tr>
184
						<td>
185
							<input name="ppsflag2" type="checkbox" class="formcheckbox" id="ppsflag2"<?php if($pconfig['flag2']) echo " checked=\"checked\""; ?> />
186
						</td>
187
						<td>
188
							<span class="vexpl"><?php echo gettext("Enable falling edge PPS signal processing (default: rising edge)."); ?></span>
189
						</td>
190
					</tr>
191
					<tr>
192
						<td>
193
							<input name="ppsflag3" type="checkbox" class="formcheckbox" id="ppsflag3"<?php if($pconfig['flag3']) echo " checked=\"checked\""; ?> />
194
						</td>
195
						<td>
196
							<span class="vexpl"><?php echo gettext("Enable kernel PPS clock discipline (default: disabled)."); ?></span>
197
						</td>
198
					</tr>
199
					<tr>
200
						<td>
201
							<input name="ppsflag4" type="checkbox" class="formcheckbox" id="ppsflag4"<?php if($pconfig['flag4']) echo " checked=\"checked\""; ?> />
202
						</td>
203
						<td>
204
							<span class="vexpl"><?php echo gettext("Record a timestamp once for each second, useful for constructing Allan deviation plots (default: disabled)."); ?></span>
205
						</td>
206
					</tr>
207
				</table>
208
			</td>
209
		</tr>
210
		<tr>
211
			<td width="22%" valign="top" class="vncellreq">Clock ID</td>
212
			<td width="78%" class="vtable">
213
				<input name="ppsrefid" type="text" class="formfld unknown" id="ppsrefid" maxlength= "4" size="20" value="<?php htmlspecialchars($pconfig['refid']);?>" /><?php echo gettext("(1 to 4 charactors)");?><br />
214
				<?php echo gettext("This may be used to change the PPS Clock ID");?> (<?php echo gettext("default");?>: PPS).</td>
215
		</tr>
216
		<tr>
217
			<td width="22%" valign="top">&nbsp;</td>
218
			<td width="78%">
219
			<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
220
			</td>
221
		</tr>
222
	</table>
223
</div>
224
</td>
225
</tr>
226
</table>
227
</form>
228
<?php include("fend.inc"); ?>
229
</body>
230
</html>
(165-165/256)