Project

General

Profile

Download (15.3 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php 
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_snmp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6
	
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
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
require("guiconfig.inc");
33
34
if (!is_array($config['snmpd'])) {
35
	$config['snmpd'] = array();
36
	$config['snmpd']['rocommunity'] = "public";
37 3805bfdd John Fleming
	$config['snmpd']['pollport'] = "161";
38 5b237745 Scott Ullrich
}
39
40 3805bfdd John Fleming
if (!is_array($config['snmpd']['modules'])) {
41
	$config['snmpd']['modules'] = array();
42
	$config['snmpd']['modules']['mibii'] = true;
43
	$config['snmpd']['modules']['netgraph'] = true;
44
	$config['snmpd']['modules']['pf'] = true;
45
}
46 4f4d63d8 John Fleming
$pconfig['enable'] = isset($config['snmpd']['enable']);
47 3805bfdd John Fleming
$pconfig['pollport'] = $config['snmpd']['pollport'];
48 5b237745 Scott Ullrich
$pconfig['syslocation'] = $config['snmpd']['syslocation'];
49
$pconfig['syscontact'] = $config['snmpd']['syscontact'];
50
$pconfig['rocommunity'] = $config['snmpd']['rocommunity'];
51 4f4d63d8 John Fleming
/* disabled until some docs show up on what this does.
52
$pconfig['rwenable'] = isset($config['snmpd']['rwenable']);
53
$pconfig['rwcommunity'] = $config['snmpd']['rwcommunity'];
54
*/
55
$pconfig['trapenable'] = isset($config['snmpd']['trapenable']);
56
$pconfig['trapserver'] = $config['snmpd']['trapserver'];
57
$pconfig['trapserverport'] = $config['snmpd']['trapserverport'];
58 8c3c9dc2 John Fleming
$pconfig['trapstring'] = $config['snmpd']['trapstring'];
59 5b237745 Scott Ullrich
60 3805bfdd John Fleming
$pconfig['mibii'] = isset($config['snmpd']['modules']['mibii']);
61
$pconfig['netgraph'] = isset($config['snmpd']['modules']['netgraph']);
62
$pconfig['pf'] = isset($config['snmpd']['modules']['pf']);
63 7cbad422 Scott Ullrich
$pconfig['bindlan'] = isset($config['snmpd']['bindlan']);
64 3805bfdd John Fleming
65 5b237745 Scott Ullrich
if ($_POST) {
66
67
	unset($input_errors);
68
	$pconfig = $_POST;
69
70
	/* input validation */
71
	if ($_POST['enable']) {
72
		$reqdfields = explode(" ", "rocommunity");
73
		$reqdfieldsn = explode(",", "Community");
74 3805bfdd John Fleming
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
75
76
		$reqdfields = explode(" ", "pollport");
77
		$reqdfieldsn = explode(",", "Polling Port");
78 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
79 a42bf8cd Scott Ullrich
		
80 72b5583c Scott Ullrich
	
81 5b237745 Scott Ullrich
	}
82
83 4f4d63d8 John Fleming
	if ($_POST['trapenable']) {
84
		$reqdfields = explode(" ", "trapserver");
85
		$reqdfieldsn = explode(",", "Trap server");
86
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
87 3805bfdd John Fleming
88 4f4d63d8 John Fleming
		$reqdfields = explode(" ", "trapserverport");
89
		$reqdfieldsn = explode(",", "Trap server port");
90
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
91 3805bfdd John Fleming
92 8c3c9dc2 John Fleming
		$reqdfields = explode(" ", "trapstring");
93
		$reqdfieldsn = explode(",", "Trap string");
94
		do_input_validation($_POST, $reqdfields, $reqdfields, $reqdfieldsn, &$input_errors);
95 4f4d63d8 John Fleming
	}
96
97 8c3c9dc2 John Fleming
98 4f4d63d8 John Fleming
/* disabled until some docs show up on what this does.
99
	if ($_POST['rwenable']) {
100
               $reqdfields = explode(" ", "rwcommunity");
101
               $reqdfieldsn = explode(",", "Write community string");
102
               do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
103
	}
104
*/
105
106
	
107
108 5b237745 Scott Ullrich
	if (!$input_errors) {
109 4f4d63d8 John Fleming
		$config['snmpd']['enable'] = $_POST['enable'] ? true : false;
110 3805bfdd John Fleming
		$config['snmpd']['pollport'] = $_POST['pollport'];
111 3184f4e7 Scott Ullrich
		$config['snmpd']['syslocation'] = $_POST['syslocation'];	
112 5b237745 Scott Ullrich
		$config['snmpd']['syscontact'] = $_POST['syscontact'];
113
		$config['snmpd']['rocommunity'] = $_POST['rocommunity'];
114 4f4d63d8 John Fleming
		/* disabled until some docs show up on what this does.
115
		$config['snmpd']['rwenable'] = $_POST['rwenable'] ? true : false;
116
		$config['snmpd']['rwcommunity'] = $_POST['rwcommunity'];
117
		*/
118
		$config['snmpd']['trapenable'] = $_POST['trapenable'] ? true : false;
119
		$config['snmpd']['trapserver'] = $_POST['trapserver'];
120
		$config['snmpd']['trapserverport'] = $_POST['trapserverport'];
121 8c3c9dc2 John Fleming
		$config['snmpd']['trapstring'] = $_POST['trapstring'];
122 4f4d63d8 John Fleming
		
123 3805bfdd John Fleming
		$config['snmpd']['modules']['mibii'] = $_POST['mibii'] ? true : false;
124
		$config['snmpd']['modules']['netgraph'] = $_POST['netgraph'] ? true : false;
125
		$config['snmpd']['modules']['pf'] = $_POST['pf'] ? true : false;
126 7cbad422 Scott Ullrich
		$config['snmpd']['bindlan'] = $_POST['bindlan'] ? true : false;
127 5b237745 Scott Ullrich
			
128
		write_config();
129
		
130
		$retval = 0;
131 920b3bb0 Scott Ullrich
132
		config_lock();
133
		$retval = services_snmpd_configure();
134
		config_unlock();
135
136 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
137
	}
138
}
139 4df96eff Scott Ullrich
140
$pgtitle = "Services: SNMP";
141
include("head.inc");
142
143 5b237745 Scott Ullrich
?>
144
<script language="JavaScript">
145
<!--
146 4f4d63d8 John Fleming
function enable_change(whichone) {
147
148
	if( whichone.name == "trapenable" )
149
        {
150
	    if( whichone.checked == true )
151
	    {
152
	        document.iform.trapserver.disabled = false;
153
	        document.iform.trapserverport.disabled = false;
154 8c3c9dc2 John Fleming
	        document.iform.trapstring.disabled = false;
155 4f4d63d8 John Fleming
	    }
156
	    else
157
	    {
158
                document.iform.trapserver.disabled = true;
159
                document.iform.trapserverport.disabled = true;
160 8c3c9dc2 John Fleming
                document.iform.trapstring.disabled = true;
161 4f4d63d8 John Fleming
	    }
162
	}
163
164
	/* disabled until some docs show up on what this does.
165
	if( whichone.name == "rwenable"  )
166
	{
167
	    if( whichone.checked == true )
168
	    {
169
		document.iform.rwcommunity.disabled = false;
170
	    }
171
	    else
172
	    {
173
		document.iform.rwcommunity.disabled = true;
174
	    }
175
	}
176
	*/
177
178
	if( document.iform.enable.checked == true )
179
	{
180 3805bfdd John Fleming
	    document.iform.pollport.disabled = false;
181 4f4d63d8 John Fleming
	    document.iform.syslocation.disabled = false;
182
	    document.iform.syscontact.disabled = false;
183
	    document.iform.rocommunity.disabled = false;
184
	    document.iform.trapenable.disabled = false;
185 7cbad422 Scott Ullrich
	    document.iform.bindlan.disabled = false;
186 4f4d63d8 John Fleming
	    /* disabled until some docs show up on what this does.
187
	    document.iform.rwenable.disabled = false;
188
	    if( document.iform.rwenable.checked == true )
189
	    {
190
	        document.iform.rwcommunity.disabled = false;
191
	    }
192
	    else
193
	    {
194
		document.iform.rwcommunity.disabled = true;
195
	    }
196
	    */
197
	    if( document.iform.trapenable.checked == true )
198
	    {
199
                document.iform.trapserver.disabled = false;
200
                document.iform.trapserverport.disabled = false;
201 8c3c9dc2 John Fleming
                document.iform.trapstring.disabled = false;
202 4f4d63d8 John Fleming
	    }
203
	    else
204
	    {
205
                document.iform.trapserver.disabled = true;
206 a21b1cad John Fleming
                document.iform.trapserverport.disabled = true;
207 8c3c9dc2 John Fleming
                document.iform.trapstring.disabled = true;
208 4f4d63d8 John Fleming
	    }
209 3805bfdd John Fleming
	    document.iform.mibii.disabled = false;
210
	    document.iform.netgraph.disabled = false;
211
	    document.iform.pf.disabled = false;
212 4f4d63d8 John Fleming
	}
213
	else
214
	{
215 3805bfdd John Fleming
            document.iform.pollport.disabled = true;
216 4f4d63d8 John Fleming
            document.iform.syslocation.disabled = true;
217
            document.iform.syscontact.disabled = true;
218
            document.iform.rocommunity.disabled = true;
219
	    /* 
220
            document.iform.rwenable.disabled = true;
221
	    document.iform.rwcommunity.disabled = true;
222
	    */
223
            document.iform.trapenable.disabled = true;
224
            document.iform.trapserver.disabled = true;
225
            document.iform.trapserverport.disabled = true;
226 8c3c9dc2 John Fleming
            document.iform.trapstring.disabled = true;
227 3805bfdd John Fleming
228
            document.iform.mibii.disabled = true;
229
            document.iform.netgraph.disabled = true;
230
            document.iform.pf.disabled = true;
231 7cbad422 Scott Ullrich
	    
232
	    document.iform.bindlan.disabled = true;
233 4f4d63d8 John Fleming
	}
234 5b237745 Scott Ullrich
}
235
//-->
236
</script>
237
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
238
<?php include("fbegin.inc"); ?>
239 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
240 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
241
<?php if ($savemsg) print_info_box($savemsg); ?>
242
            <form action="services_snmp.php" method="post" name="iform" id="iform">
243
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
244 4f4d63d8 John Fleming
245 5b237745 Scott Ullrich
                <tr> 
246 4f4d63d8 John Fleming
  		  <td colspan="2" valign="top" class="optsect_t">
247
  			<table border="0" cellspacing="0" cellpadding="0" width="100%">
248
  			<tr><td class="optsect_s"><strong>SNMP Daemon</strong></td>
249
			<td align="right" class="optsect_s"><input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(this)"> <strong>Enable</strong></td></tr>
250
  			</table></td>
251 5b237745 Scott Ullrich
                </tr>
252 3805bfdd John Fleming
253
                <tr>
254
                  <td width="22%" valign="top" class="vncellreq">Polling Port </td>
255
                  <td width="78%" class="vtable">
256
                    <input name="pollport" type="text" class="formfld" id="pollport" size="40" value="<?=$pconfig['pollport'] ? htmlspecialchars($pconfig['pollport']) : htmlspecialchars(161);?>">
257
                    <br>Enter the port to accept polling events on (default 161)</br>
258
		  </td>
259
                </tr>
260
261 5b237745 Scott Ullrich
                <tr> 
262 b8093370 Scott Ullrich
                  <td width="22%" valign="top" class="vncell">System location</td>
263 5b237745 Scott Ullrich
                  <td width="78%" class="vtable"> 
264
                    <input name="syslocation" type="text" class="formfld" id="syslocation" size="40" value="<?=htmlspecialchars($pconfig['syslocation']);?>"> 
265
                  </td>
266
                </tr>
267 3805bfdd John Fleming
268 5b237745 Scott Ullrich
                <tr> 
269 b8093370 Scott Ullrich
                  <td width="22%" valign="top" class="vncell">System contact</td>
270 5b237745 Scott Ullrich
                  <td width="78%" class="vtable"> 
271
                    <input name="syscontact" type="text" class="formfld" id="syscontact" size="40" value="<?=htmlspecialchars($pconfig['syscontact']);?>"> 
272
                  </td>
273
                </tr>
274 3805bfdd John Fleming
275 5b237745 Scott Ullrich
                <tr> 
276 4f4d63d8 John Fleming
                  <td width="22%" valign="top" class="vncellreq">Read Community String</td>
277 5b237745 Scott Ullrich
                  <td width="78%" class="vtable"> 
278
                    <input name="rocommunity" type="text" class="formfld" id="rocommunity" size="40" value="<?=htmlspecialchars($pconfig['rocommunity']);?>"> 
279 3805bfdd John Fleming
                    <br>In most cases, &quot;public&quot; is used here</br>
280
		  </td>
281 5b237745 Scott Ullrich
                </tr>
282 4f4d63d8 John Fleming
283
<?php 
284
			/* disabled until some docs show up on what this does.
285
                <tr>
286
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
287
                  <td width="78%" class="vtable">
288
	 	   <input name="rwenable" type="checkbox" value="yes" <?php if ($pconfig['rwenable']) echo "checked"; ?> onClick="enable_change(this)">
289 3805bfdd John Fleming
                    <strong>Enable Write Community String</strong>
290
		  </td>
291 4f4d63d8 John Fleming
                </tr>
292
293
		<tr>
294
		  <td width="22%" valign="top" class="vncellreq">Write community string</td>
295
          <td width="78%" class="vtable">
296
                    <input name="rwcommunity" type="text" class="formfld" id="rwcommunity" size="40" value="<?=htmlspecialchars($pconfig['rwcommunity']);?>">
297 3805bfdd John Fleming
		    <br>Please use something other then &quot;private&quot; here</br>
298
		  </td>
299 4f4d63d8 John Fleming
                </tr>
300
		    	*/ 
301
?>
302
303 3184f4e7 Scott Ullrich
                <tr> 
304
                  <td width="22%" valign="top">&nbsp;</td>
305
                  <td width="78%"> 
306
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)"> 
307 3805bfdd John Fleming
                  </td>
308 4f4d63d8 John Fleming
                </tr>
309
310 3184f4e7 Scott Ullrich
		<tr><td>&nbsp;</td></tr>
311
312
                <tr> 
313
  		  <td colspan="2" valign="top" class="optsect_t">
314
  			<table border="0" cellspacing="0" cellpadding="0" width="100%">
315 ba73e2a3 Scott Ullrich
  			<tr><td class="optsect_s"><strong>SNMP Traps</strong></td>
316 3184f4e7 Scott Ullrich
			<td align="right" class="optsect_s"><input name="trapenable" type="checkbox" value="yes" <?php if ($pconfig['trapenable']) echo "checked"; ?> onClick="enable_change(this)"> <strong>Enable</strong></td></tr>
317
  			</table></td>
318
                </tr>
319
320
321 4f4d63d8 John Fleming
                <tr>
322
                  <td width="22%" valign="top" class="vncellreq">Trap server</td>
323
                  <td width="78%" class="vtable">
324
                    <input name="trapserver" type="text" class="formfld" id="trapserver" size="40" value="<?=htmlspecialchars($pconfig['trapserver']);?>">
325 3805bfdd John Fleming
                    <br>Enter trap server name</br>
326
		  </td>
327 4f4d63d8 John Fleming
                </tr>
328
329
                <tr>
330
                  <td width="22%" valign="top" class="vncellreq">Trap server port </td>
331
                  <td width="78%" class="vtable">
332
                    <input name="trapserverport" type="text" class="formfld" id="trapserverport" size="40" value="<?=$pconfig['trapserverport'] ? htmlspecialchars($pconfig['trapserverport']) : htmlspecialchars(162);?>">
333 3805bfdd John Fleming
                    <br>Enter the port to send the traps to (default 162)</br>
334
		  </td>
335 4f4d63d8 John Fleming
                </tr>
336 3805bfdd John Fleming
337 8c3c9dc2 John Fleming
                <tr>
338 ba73e2a3 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Enter the SNMP trap string</td>
339 8c3c9dc2 John Fleming
                  <td width="78%" class="vtable">
340
                    <input name="trapstring" type="text" class="formfld" id="trapstring" size="40" value="<?=htmlspecialchars($pconfig['trapstring']);?>">
341 3805bfdd John Fleming
                    <br>Trap string</br>
342
		  </td>
343 8c3c9dc2 John Fleming
                </tr>
344
345 ba73e2a3 Scott Ullrich
                <tr> 
346
                  <td width="22%" valign="top">&nbsp;</td>
347
                  <td width="78%"> 
348
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)"> 
349
                  </td>
350
                </tr>
351
352
		<tr><td>&nbsp;</td></tr>
353
354
                <tr> 
355
  		  <td colspan="2" valign="top" class="optsect_t">
356
  			<table border="0" cellspacing="0" cellpadding="0" width="100%">
357
  			<tr><td class="optsect_s"><strong>Modules</strong></td>
358
			<td align="right" class="optsect_s">&nbsp;</td></tr>
359
  			</table></td>
360
                </tr>
361
362 3805bfdd John Fleming
		<tr>
363
		  <td width="22%" valign="top" class="vncellreq">SNMP Modules</td>
364
		  <td width="78%" class="vtable">
365
		    <input name="mibii" type="checkbox" id="mibii" value="yes" <?php if ($pconfig['mibii']) echo "checked"; ?> >MibII
366 e348dcec Scott Ullrich
		    <br>
367 3805bfdd John Fleming
		    <input name="netgraph" type="checkbox" id="netgraph" value="yes" <?php if ($pconfig['netgraph']) echo "checked"; ?> >Netgraph
368 e348dcec Scott Ullrich
		    <br>
369 3805bfdd John Fleming
		    <input name="pf" type="checkbox" id="pf" value="yes" <?php if ($pconfig['pf']) echo "checked"; ?> >PF
370
		  </td>
371
		</tr>
372 7cbad422 Scott Ullrich
                <tr> 
373
                  <td width="22%" valign="top" class="vtable"></td>
374
                  <td width="78%" class="vtable"> 
375
                    <input name="bindlan" type="checkbox" value="yes" <?php if ($pconfig['bindlan']) echo "checked"; ?>> <strong>Bind to LAN interface only</strong>
376
                    <br>
377
                    This option can be useful when trying to access the SNMP agent
378
                    by the LAN interface's IP address through a VPN tunnel terminated on the WAN interface.</td>
379
                </tr>
380 5b237745 Scott Ullrich
                <tr> 
381
                  <td width="22%" valign="top">&nbsp;</td>
382
                  <td width="78%"> 
383
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)"> 
384
                  </td>
385
                </tr>
386
              </table>
387
</form>
388
<script language="JavaScript">
389
<!--
390 4f4d63d8 John Fleming
enable_change(this);
391 5b237745 Scott Ullrich
//-->
392
</script>
393
<?php include("fend.inc"); ?>
394
</body>
395
</html>