1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
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>
21 <script type='text/javascript' src='debug.js'
></script>
23 <script type='text/javascript' src='wireless.jsx?_http_id=<%
nv(http_id
); %>'
></script>
24 <script type='text/javascript'
>
26 // <% nvram("et0macaddr,mac_wan,wl_macaddr,wl_hwaddr"); %>
28 function et0plus(plus
)
30 var mac
= nvram
.et0macaddr
.split(':');
31 if (mac
.length
!= 6) return '';
33 for (var i
= 5; i
>= 3; --i
) {
34 var n
= (parseInt(mac
[i
], 16) + 1) & 0xFF;
42 function defmac(which
)
47 var u
= which
.substr(2, which
.length
) * 1;
48 return et0plus(2 + u
);
52 function bdefault(which
)
54 E('_f_' + which
+ '_macaddr').value
= defmac(which
);
55 verifyFields(null, true);
64 for (i
= 5; i
> 0; --i
)
65 mac
.push(Math
.floor(Math
.random() * 255).hex(2));
66 E('_f_' + which
+ '_macaddr').value
= mac
.join(':');
67 verifyFields(null, true);
70 function bclone(which
)
72 E('_f_' + which
+ '_macaddr').value
= '<% compmac(); %>';
73 verifyFields(null, true);
76 function findPrevMAC(mac
, maxidx
)
78 if (E('_f_wan_macaddr').value
== mac
) return 1;
80 for (var uidx
= 0; uidx
< maxidx
; ++uidx
) {
81 if (E('_f_wl'+wl_unit(uidx
)+'_macaddr').value
== mac
) return 1;
87 function verifyFields(focused
, quiet
)
91 if (!v_mac('_f_wan_macaddr', quiet
)) return 0;
93 for (uidx
= 0; uidx
< wl_ifaces
.length
; ++uidx
) {
95 a
= E('_f_wl'+u
+'_macaddr');
96 if (!v_mac(a
, quiet
)) return 0;
98 if (findPrevMAC(a
.value
, uidx
)) {
99 ferror
.set(a
, 'Addresses must be unique', quiet
);
111 if (!verifyFields(null, false)) return;
112 if (!confirm("Warning: Changing the MAC address may require that you reboot all devices, computers or modem connected to this router. Continue anyway?")) return;
115 fom
.mac_wan
.value
= (fom
._f_wan_macaddr
.value
== defmac('wan')) ? '' : fom
._f_wan_macaddr
.value
;
117 for (uidx
= 0; uidx
< wl_ifaces
.length
; ++uidx
) {
119 v
= E('_f_wl'+u
+'_macaddr').value
;
120 E('_wl'+u
+'_macaddr').value
= (v
== defmac('wl' + u
)) ? '' : v
;
130 <form id='_fom' method='post' action='tomato.cgi'
>
131 <table id='container' cellspacing=
0>
132 <tr><td colspan=
2 id='header'
>
133 <div class='title'
>Tomato
</div>
134 <div class='version'
>Version <%
version(); %></div>
136 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
138 <div id='ident'
><%
ident(); %></div>
142 <input type='hidden' name='_nextpage' value='advanced-mac.asp'
>
143 <input type='hidden' name='_nextwait' value='
10'
>
144 <input type='hidden' name='_service' value='*'
>
146 <input type='hidden' name='mac_wan'
>
148 <script type='text/javascript'
>
149 for (var uidx
= 0; uidx
< wl_ifaces
.length
; ++uidx
) {
150 var u
= wl_unit(uidx
);
151 W('<input type=\'hidden\' id=\'_wl'+u
+'_macaddr\' name=\'wl'+u
+'_macaddr\'>');
155 <div class='section-title'
>MAC Address
</div>
156 <div class='section'
>
157 <script type='text/javascript'
>
160 { title
: 'WAN Port', indent
: 1, name
: 'f_wan_macaddr', type
: 'text', maxlen
: 17, size
: 20,
161 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\')">',
162 value
: nvram
.mac_wan
|| defmac('wan') }
165 for (var uidx
= 0; uidx
< wl_ifaces
.length
; ++uidx
) {
166 var u
= wl_unit(uidx
);
168 { title
: 'Wireless Interface ' + ((wl_ifaces
.length
> 1) ? wl_ifaces
[uidx
][0] : ''), indent
: 1, name
: 'f_wl'+u
+'_macaddr', type
: 'text', maxlen
: 17, size
: 20,
169 suffix
:' <input type="button" value="Default" onclick="bdefault(\'wl'+u
+'\')"> <input type="button" value="Random" onclick="brand(\'wl'+u
+'\')"> <input type="button" value="Clone PC" onclick="bclone(\'wl'+u
+'\')">',
170 value
: nvram
['wl'+u
+'_macaddr'] || defmac('wl' + u
) }
174 createFieldTable('', f
);
178 <table border=
0 cellpadding=
1>
179 <tr><td>Router's LAN MAC Address:
</td><td><b><%
nv('et0macaddr'); %></b></td></tr>
180 <tr><td>Computer's MAC Address:
</td><td><b><%
compmac(); %></b></td></tr>
189 <tr><td id='footer' colspan=
2>
190 <span id='footer-msg'
></span>
191 <input type='button' value='Save' id='save-button' onclick='save()'
>
192 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>
196 <script type='text/javascript'
>verifyFields(null, 1);</script>