New routers supported
[tomato.git] / release / src / router / www / forward-upnp.asp
bloba6f037fd097daa728ca8ab176afbf250552704f4
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Forwarding: UPnP / NAT-PMP</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <% css(); %>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <style type='text/css'>
22 #upnp-grid .co1, #upnp-grid .co2 {
23 width: 12%;
25 #upnp-grid .co3 {
26 width: 15%;
28 #upnp-grid .co4 {
29 width: 8%;
31 #upnp-grid .co5 {
32 width: 53%;
34 </style>
36 <script type='text/javascript' src='debug.js'></script>
38 <script type='text/javascript'>
40 /* REMOVE-BEGIN
41 !!TB - additional miniupnp settings
42 REMOVE-END */
43 // <% nvram("upnp_enable,upnp_mnp,upnp_clean,upnp_secure,upnp_clean_interval,upnp_clean_threshold,upnp_custom,upnp_lan,upnp_lan1,upnp_lan2,upnp_lan3,lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname,"); %>
45 // <% upnpinfo(); %>
47 nvram.upnp_enable = fixInt(nvram.upnp_enable, 0, 3, 0);
50 function submitDelete(proto, eport)
52 form.submitHidden('upnp.cgi', {
53 remove_proto: proto,
54 remove_eport: eport,
55 _redirect: 'forward-upnp.asp' });
58 function deleteData(data)
60 if (!confirm('Delete ' + data[3] + ' ' + data[0] + ' -> ' + data[2] + ':' + data[1] + ' ?')) return;
61 submitDelete(data[3], data[0]);
64 var ug = new TomatoGrid();
66 ug.onClick = function(cell) {
67 deleteData(cell.parentNode.getRowData());
70 ug.rpDel = function(e) {
71 deleteData(PR(e).getRowData());
75 ug.setup = function() {
76 this.init('upnp-grid', 'sort delete');
77 this.headerSet(['External', 'Internal', 'Internal Address', 'Protocol', 'Description']);
78 ug.populate();
81 ug.populate = function() {
82 var i, j, r, row, data;
84 if (nvram.upnp_enable != 0) {
85 var data = mupnp_data.split('\n');
86 for (i = 0; i < data.length; ++i) {
87 r = data[i].match(/^(UDP|TCP)\s+(\d+)\s+(.+?)\s+(\d+)\s+\[(.*)\](.*)$/);
88 if (r == null) continue;
89 row = this.insertData(-1, [r[2], r[4], r[3], r[1], r[5]]);
91 if (!r[0]) {
92 for (j = 0; j < 5; ++j) {
93 elem.addClass(row.cells[j], 'disabled');
96 for (j = 0; j < 5; ++j) {
97 row.cells[j].title = 'Click to delete';
100 this.sort(2);
102 E('upnp-delete-all').disabled = (ug.getDataCount() == 0);
105 function deleteAll()
107 if (!confirm('Delete all entries?')) return;
108 submitDelete('*', '0');
111 function verifyFields(focused, quiet)
113 /* REMOVE-BEGIN
114 !!TB - additional miniupnp settings
115 REMOVE-END */
116 var enable = E('_f_enable_upnp').checked || E('_f_enable_natpmp').checked;
117 var bc = E('_f_upnp_clean').checked;
119 E('_f_upnp_clean').disabled = (enable == 0);
120 E('_f_upnp_secure').disabled = (enable == 0);
121 E('_upnp_custom').disabled = (enable == 0);
122 E('_f_upnp_mnp').disabled = (E('_f_enable_upnp').checked == 0);
123 E('_upnp_clean_interval').disabled = (enable == 0) || (bc == 0);
124 E('_upnp_clean_threshold').disabled = (enable == 0) || (bc == 0);
125 elem.display(PR(E('_upnp_clean_interval')), (enable != 0) && (bc != 0));
126 elem.display(PR(E('_upnp_clean_threshold')), (enable != 0) && (bc != 0));
128 if ((enable != 0) && (bc != 0)) {
129 if (!v_range('_upnp_clean_interval', quiet, 60, 65535)) return 0;
130 if (!v_range('_upnp_clean_threshold', quiet, 0, 9999)) return 0;
132 else {
133 ferror.clear(E('_upnp_clean_interval'));
134 ferror.clear(E('_upnp_clean_threshold'));
137 E('_f_upnp_lan').disabled = ((nvram.lan_ifname.length < 1) || (enable == 0));
138 if (E('_f_upnp_lan').disabled)
139 E('_f_upnp_lan').checked = false;
140 E('_f_upnp_lan1').disabled = ((nvram.lan1_ifname.length < 1) || (enable == 0));
141 if (E('_f_upnp_lan1').disabled)
142 E('_f_upnp_lan1').checked = false;
143 E('_f_upnp_lan2').disabled = ((nvram.lan2_ifname.length < 1) || (enable == 0));
144 if (E('_f_upnp_lan2').disabled)
145 E('_f_upnp_lan2').checked = false;
146 E('_f_upnp_lan3').disabled = ((nvram.lan3_ifname.length < 1) || (enable == 0));
147 if (E('_f_upnp_lan3').disabled)
148 E('_f_upnp_lan3').checked = false;
149 if ((enable) && (!E('_f_upnp_lan').checked) && (!E('_f_upnp_lan1').checked) && (!E('_f_upnp_lan2').checked) && (!E('_f_upnp_lan3').checked)) {
150 if ((E('_f_enable_natpmp').checked) || (E('_f_enable_upnp').checked)) {
151 var m = 'NAT-PMP or UPnP must be enabled in least one LAN bridge';
152 ferror.set('_f_enable_natpmp', m, quiet);
153 ferror.set('_f_enable_upnp', m, 1);
154 ferror.set('_f_upnp_lan', m, 1);
155 ferror.set('_f_upnp_lan1', m, 1);
156 ferror.set('_f_upnp_lan2', m, 1);
157 ferror.set('_f_upnp_lan3', m, 1);
159 return 0;
160 } else {
161 ferror.clear('_f_enable_natpmp');
162 ferror.clear('_f_enable_upnp');
163 ferror.clear('_f_upnp_lan');
164 ferror.clear('_f_upnp_lan1');
165 ferror.clear('_f_upnp_lan2');
166 ferror.clear('_f_upnp_lan3');
168 return 1;
171 function save()
173 /* REMOVE-BEGIN
174 !!TB - miniupnp
175 REMOVE-END */
176 if (!verifyFields(null, 0)) return;
178 var fom = E('_fom');
179 fom.upnp_enable.value = 0;
180 if (fom.f_enable_upnp.checked) fom.upnp_enable.value = 1;
181 if (fom.f_enable_natpmp.checked) fom.upnp_enable.value |= 2;
183 /* REMOVE-BEGIN
184 !!TB - additional miniupnp settings
185 REMOVE-END */
186 fom.upnp_mnp.value = E('_f_upnp_mnp').checked ? 1 : 0;
187 fom.upnp_clean.value = E('_f_upnp_clean').checked ? 1 : 0;
188 fom.upnp_secure.value = E('_f_upnp_secure').checked ? 1 : 0;
190 fom.upnp_lan.value = E('_f_upnp_lan').checked ? 1 : 0;
191 fom.upnp_lan1.value = E('_f_upnp_lan1').checked ? 1 : 0;
192 fom.upnp_lan2.value = E('_f_upnp_lan2').checked ? 1 : 0;
193 fom.upnp_lan3.value = E('_f_upnp_lan3').checked ? 1 : 0;
194 form.submit(fom, 0);
197 function init()
199 ug.recolor();
202 /* REMOVE-BEGIN
203 !!TB - miniupnp
204 REMOVE-END */
205 function submit_complete()
207 reloadPage();
209 </script>
211 </head>
212 <body onload='init()'>
213 <form id='_fom' method='post' action='tomato.cgi'>
214 <table id='container' cellspacing=0>
215 <tr><td colspan=2 id='header'>
216 <div class='title'>Tomato</div>
217 <div class='version'>Version <% version(); %></div>
218 </td></tr>
219 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
220 <td id='content'>
221 <div id='ident'><% ident(); %></div>
223 <!-- / / / -->
225 <input type='hidden' name='_nextpage' value='forward-upnp.asp'>
226 <input type='hidden' name='_service' value='upnp-restart'>
228 <input type='hidden' name='upnp_enable'>
229 /* REMOVE-BEGIN
230 !!TB - additional miniupnp settings
231 REMOVE-END */
232 <input type='hidden' name='upnp_mnp'>
233 <input type='hidden' name='upnp_clean'>
234 <input type='hidden' name='upnp_secure'>
235 <input type='hidden' name='upnp_lan'>
236 <input type='hidden' name='upnp_lan1'>
237 <input type='hidden' name='upnp_lan2'>
238 <input type='hidden' name='upnp_lan3'>
240 <div class='section-title'>Forwarded Ports</div>
241 <div class='section'>
242 <table id='upnp-grid' class='tomato-grid'></table>
243 <div style='width: 100%; text-align: right'><input type='button' value='Delete All' onclick='deleteAll()' id='upnp-delete-all'> <input type='button' value='Refresh' onclick='javascript:reloadPage();'></div>
244 </div>
246 <div class='section-title'>Settings</div>
247 <div class='section'>
248 <script type='text/javascript'>
249 createFieldTable('', [
250 { title: 'Enable UPnP', name: 'f_enable_upnp', type: 'checkbox', value: (nvram.upnp_enable & 1) },
251 { title: 'Enable NAT-PMP', name: 'f_enable_natpmp', type: 'checkbox', value: (nvram.upnp_enable & 2) },
252 /* REMOVE-BEGIN
253 !!TB - additional miniupnp settings
254 REMOVE-END */
255 { title: 'Inactive Rules Cleaning', name: 'f_upnp_clean', type: 'checkbox', value: (nvram.upnp_clean == '1') },
256 { title: 'Cleaning Interval', indent: 2, name: 'upnp_clean_interval', type: 'text', maxlen: 5, size: 7,
257 suffix: ' <small>seconds</small>', value: nvram.upnp_clean_interval },
258 { title: 'Cleaning Threshold', indent: 2, name: 'upnp_clean_threshold', type: 'text', maxlen: 4, size: 7,
259 suffix: ' <small>redirections</small>', value: nvram.upnp_clean_threshold },
260 { title: 'Secure Mode', name: 'f_upnp_secure', type: 'checkbox',
261 suffix: ' <small>(when enabled, UPnP clients are allowed to add mappings only to their IP)</small>',
262 value: (nvram.upnp_secure == '1') },
263 { title: 'Listen on' },
264 { title: 'LAN', indent: 2, name: 'f_upnp_lan', type: 'checkbox', value: (nvram.upnp_lan == '1') },
265 { title: 'LAN1', indent: 2, name: 'f_upnp_lan1', type: 'checkbox', value: (nvram.upnp_lan1 == '1') },
266 { title: 'LAN2', indent: 2, name: 'f_upnp_lan2', type: 'checkbox', value: (nvram.upnp_lan2 == '1') },
267 { title: 'LAN3', indent: 2, name: 'f_upnp_lan3', type: 'checkbox', value: (nvram.upnp_lan3 == '1') },
268 { title: 'Show In My Network Places', name: 'f_upnp_mnp', type: 'checkbox', value: (nvram.upnp_mnp == '1')},
269 null,
270 { title: 'Miniupnpd</a><br>Custom configuration', name: 'upnp_custom', type: 'textarea', value: nvram.upnp_custom }
272 </script>
273 </div>
276 <!-- / / / -->
278 </td></tr>
279 <tr><td id='footer' colspan=2>
280 <span id='footer-msg'></span>
281 <input type='button' value='Save' id='save-button' onclick='save()'>
282 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
283 </td></tr>
284 </table>
285 </form>
286 /* REMOVE-BEGIN
287 !!TB - added verifyFields
288 REMOVE-END */
289 <script type='text/javascript'>ug.setup();verifyFields(null, 1);</script>
290 </body>
291 </html>