Tomato 1.28 beta (1808)
[tomato.git] / release / src / router / www / advanced-mac.asp
blobd178cc3c05fb9c48d4cddd590fd2722965d0f4e5
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(); %>] Advanced: MAC Address</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.css'>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <script type='text/javascript' src='debug.js'></script>
23 <script type='text/javascript'>
25 // <% nvram("et0macaddr,mac_wan,mac_wl"); %>
27 defmac = {
28 wan: et0plus(1),
29 wl: et0plus(2)
32 function et0plus(plus)
34 var mac = nvram.et0macaddr.split(':');
35 if (mac.length != 6) return '';
36 while (plus-- > 0) {
37 for (var i = 5; i >= 3; --i) {
38 var n = (parseInt(mac[i], 16) + 1) & 0xFF;
39 mac[i] = n.hex(2);
40 if (n != 0) break;
43 return mac.join(':');
46 function bdefault(which)
48 E('_f_mac_' + which).value = defmac[which];
49 verifyFields(null, true);
52 function brand(which)
54 var mac;
55 var i;
57 mac = ['00'];
58 for (i = 5; i > 0; --i)
59 mac.push(Math.floor(Math.random() * 255).hex(2));
60 E('_f_mac_' + which).value = mac.join(':');
61 verifyFields(null, true);
64 function bclone(which)
66 E('_f_mac_' + which).value = '<% compmac(); %>';
67 verifyFields(null, true);
70 function verifyFields(focused, quiet)
72 if (v_mac('_f_mac_wan', quiet) && v_mac('_f_mac_wl', quiet)) {
73 if (E('_f_mac_wan').value != E('_f_mac_wl').value) return 1;
74 ferror.set('_f_mac_wan', 'Addresses must be unique', quiet);
76 return 0;
79 function save()
81 if (!verifyFields(null, false)) return;
82 if (!confirm("Warning: Changing the MAC address may require that you reboot all devices, computers or modem connected to this router. Continue anyway?")) return
84 var fom = E('_fom');
85 fom.mac_wan.value = (fom._f_mac_wan.value == defmac.wan) ? '' : fom._f_mac_wan.value;
86 fom.mac_wl.value = (fom._f_mac_wl.value == defmac.wl) ? '' : fom._f_mac_wl.value;
87 form.submit(fom, 1);
89 </script>
90 </head>
91 <body>
92 <form id='_fom' method='post' action='tomato.cgi'>
93 <table id='container' cellspacing=0>
94 <tr><td colspan=2 id='header'>
95 <div class='title'>Tomato</div>
96 <div class='version'>Version <% version(); %></div>
97 </td></tr>
98 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
99 <td id='content'>
100 <div id='ident'><% ident(); %></div>
102 <!-- / / / -->
104 <input type='hidden' name='_nextpage' value='advanced-mac.asp'>
105 <input type='hidden' name='_nextwait' value='10'>
106 <input type='hidden' name='_service' value='*'>
108 <input type='hidden' name='mac_wan'>
109 <input type='hidden' name='mac_wl'>
111 <div class='section-title'>MAC Address</div>
112 <div class='section'>
113 <script type='text/javascript'>
114 createFieldTable('', [
115 { title: 'WAN Port', indent: 1, name: 'f_mac_wan', type: 'text', maxlen: 17, size: 20,
116 suffix: ' <input type="button" value="Default" onclick="bdefault(\'wan\')"> <input type="button" value="Random" onclick="brand(\'wan\')"> <input type="button" value="Clone PC" onclick="bclone(\'wan\')">',
117 value: nvram.mac_wan || defmac.wan },
118 { title: 'Wireless Interface', indent: 1, name: 'f_mac_wl', type: 'text', maxlen: 17, size: 20,
119 suffix:' <input type="button" value="Default" onclick="bdefault(\'wl\')"> <input type="button" value="Random" onclick="brand(\'wl\')"> <input type="button" value="Clone PC" onclick="bclone(\'wl\')">',
120 value: nvram.mac_wl || defmac.wl }
122 </script>
123 <br>
124 <table border=0 cellpadding=1>
125 <tr><td>Router's MAC Address:</td><td><b><% nv('et0macaddr'); %></b></td></tr>
126 <tr><td>Computer's MAC Address:</td><td><b><% compmac(); %></b></td></tr>
127 </table>
128 </div>
132 <!-- / / / -->
134 </td></tr>
135 <tr><td id='footer' colspan=2>
136 <span id='footer-msg'></span>
137 <input type='button' value='Save' id='save-button' onclick='save()'>
138 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
139 </td></tr>
140 </table>
141 </form>
142 <script type='text/javascript'>verifyFields(null, 1);</script>
143 </body>
144 </html>