Project

General

Profile

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