Project

General

Profile

Download (9.12 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / services_ntpd_pps.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	Copyright (C) 2013	Dagorlad
5
	All rights reserved.
6

    
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9

    
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12

    
13
	2. Redistributions in binary form must reproduce the above copyright
14
	   notice, this list of conditions and the following disclaimer in the
15
	   documentation and/or other materials provided with the distribution.
16

    
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28
/*
29
	pfSense_MODULE:	ntpd_pps
30
*/
31

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

    
39
require_once("guiconfig.inc");
40

    
41
if (!is_array($config['ntpd']))
42
	$config['ntpd'] = array();
43
if (!is_array($config['ntpd']['pps']))
44
	$config['ntpd']['pps'] = array();
45

    
46
if ($_POST) {
47

    
48
	unset($input_errors);
49

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

    
56
		if (!empty($_POST['ppsfudge1']))
57
			$config['ntpd']['pps']['fudge1'] = $_POST['ppsfudge1'];
58
		elseif (isset($config['ntpd']['pps']['fudge1']))
59
			unset($config['ntpd']['pps']['fudge1']);
60

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

    
66
		if (!empty($_POST['ppsselect']))
67
			$config['ntpd']['pps']['noselect'] = $_POST['ppsselect'];
68
		elseif (isset($config['ntpd']['pps']['noselect']))
69
			unset($config['ntpd']['pps']['noselect']);
70

    
71
		if (!empty($_POST['ppsflag2']))
72
			$config['ntpd']['pps']['flag2'] = $_POST['ppsflag2'];
73
		elseif (isset($config['ntpd']['pps']['flag2']))
74
			unset($config['ntpd']['pps']['flag2']);
75

    
76
		if (!empty($_POST['ppsflag3']))
77
			$config['ntpd']['pps']['flag3'] = $_POST['ppsflag3'];
78
		elseif (isset($config['ntpd']['pps']['flag3']))
79
			unset($config['ntpd']['pps']['flag3']);
80

    
81
		if (!empty($_POST['ppsflag4']))
82
			$config['ntpd']['pps']['flag4'] = $_POST['ppsflag4'];
83
		elseif (isset($config['ntpd']['pps']['flag4']))
84
			unset($config['ntpd']['pps']['flag4']);
85

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

    
93
		$retval = 0;
94
		$retval = system_ntp_configure();
95
		$savemsg = get_std_save_message($retval);
96
	}
97
}
98
$pconfig = &$config['ntpd']['pps'];
99

    
100
$pgtitle = array(gettext("Services"),gettext("NTP PPS"));
101
$shortcut_section = "ntp";
102
include("head.inc");
103
?>
104

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

    
111
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="ntpd pps">
112
  <tr>
113
	<td>
114
<?php
115
	$tab_array = array();
116
	$tab_array[] = array(gettext("NTP"), false, "services_ntpd.php");
117
	$tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php");
118
	$tab_array[] = array(gettext("PPS"), true, "services_ntpd_pps.php");
119
	display_top_tabs($tab_array);
120
?>
121
	</td>
122
  </tr>
123
  <tr>
124
	<td>
125
	<div id="mainarea">
126
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
127
		<tr>
128
			<td colspan="2" valign="top" class="listtopic"><?=gettext("NTP PPS Configuration"); ?></td>
129
		</tr>
130
		<tr>
131
			<td width="22%" valign="top" class="vncellreq">
132
			</td>
133
			<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.");?> 
134
			<?php echo gettext("A serial GPS may also be used, but the serial GPS driver would usually be the better option.");?> 
135
			<?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.");?>
136
			<br />
137
			<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."); ?>
138
			</td>
139
		</tr>
140
<?php $serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE); ?>
141
<?php if (!empty($serialports)): ?>
142
		<tr>
143
			<td width="22%" valign="top" class="vncellreq">Serial port</td>
144
			<td width="78%" class="vtable">
145
				<select name="ppsport" class="formselect">
146
					<option value="">none</option>
147
					<?php foreach ($serialports as $port):
148
						$shortport = substr($port,5);
149
						$selected = ($shortport == $pconfig['port']) ? " selected=\"selected\"" : "";?>
150
						<option value="<?php echo $shortport;?>"<?php echo $selected;?>><?php echo $shortport;?></option>
151
					<?php endforeach; ?>
152
				</select>&nbsp;
153
				<?php echo gettext("All serial ports are listed, be sure to pick the port with the PPS source attached."); ?>
154
			</td>
155
		</tr>
156
<?php endif; ?>
157
		<tr>
158
			<td width="22%" valign="top" class="vncellreq">Fudge time</td>
159
			<td width="78%" class="vtable">
160
				<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 />
161
				<?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>
162
		</tr>
163
		<tr>
164
			<td width="22%" valign="top" class="vncellreq">Stratum</td>
165
			<td width="78%" class="vtable">
166
				<input name="ppsstratum" type="text" class="formfld unknown" id="ppsstratum" max="16" size="20" value="<?=htmlspecialchars($pconfig['stratum']);?>" /><?php echo gettext("(0-16)");?><br />
167
				<?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>
168
		</tr>
169
		<tr>
170
			<td width="22%" valign="top" class="vncellreq">Flags</td>
171
			<td width="78%" class="vtable">
172
				<table summary="flags">
173
					<tr>
174
						<td>
175
				<?php echo gettext("Normally there should be no need to change these options from the defaults."); ?><br />
176
						</td>
177
					</tr>
178
				</table>
179
				<table>
180
					<tr>
181
						<td>
182
							<input name="ppsflag2" type="checkbox" class="formcheckbox" id="ppsflag2"<?php if($pconfig['flag2']) echo " checked=\"checked\""; ?> />
183
						</td>
184
						<td>
185
							<span class="vexpl"><?php echo gettext("Enable falling edge PPS signal processing (default: rising edge)."); ?></span>
186
						</td>
187
					</tr>
188
					<tr>
189
						<td>
190
							<input name="ppsflag3" type="checkbox" class="formcheckbox" id="ppsflag3"<?php if($pconfig['flag3']) echo " checked=\"checked\""; ?> />
191
						</td>
192
						<td>
193
							<span class="vexpl"><?php echo gettext("Enable kernel PPS clock discipline (default: disabled)."); ?></span>
194
						</td>
195
					</tr>
196
					<tr>
197
						<td>
198
							<input name="ppsflag4" type="checkbox" class="formcheckbox" id="ppsflag4"<?php if($pconfig['flag4']) echo " checked=\"checked\""; ?> />
199
						</td>
200
						<td>
201
							<span class="vexpl"><?php echo gettext("Record a timestamp once for each second, useful for constructing Allan deviation plots (default: disabled)."); ?></span>
202
						</td>
203
					</tr>
204
				</table>
205
			</td>
206
		</tr>
207
		<tr>
208
			<td width="22%" valign="top" class="vncellreq">Clock ID</td>
209
			<td width="78%" class="vtable">
210
				<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 />
211
				<?php echo gettext("This may be used to change the PPS Clock ID");?> (<?php echo gettext("default");?>: PPS).</td>
212
		</tr>
213
		<tr>
214
			<td width="22%" valign="top">&nbsp;</td>
215
			<td width="78%">
216
			<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
217
			</td>
218
		</tr>
219
	</table>
220
</div>
221
</td>
222
</tr>
223
</table>
224
</form>
225
<?php include("fend.inc"); ?>
226
</body>
227
</html>
(165-165/256)