<%# Opennet Firmware Copyright 2010 Rene Ejury Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -%> <%+header%>

<%:Opennet ID%>

<%+cbi/apply_xhr%> <% local uci = require "luci.model.uci" local cursor = uci.cursor() local form_id = luci.http.formvalue("form_id") local devices = { "on_eth_", "on_wifi_" } local show_invalid_id_warning = false if (form_id) then function split_numbers(str) local t = { } str:gsub("%d+", function (w) table.insert(t, tonumber(w)) end) return t end local numbers = split_numbers(form_id) local major local minor local replace_id = true if #numbers == 1 then -- nur eine Zahl: Netzgruppe "1" major = 1 minor = numbers[1] elseif #numbers == 2 then -- zwei Zahlen: beide verwenden major = numbers[1] minor = numbers[2] elseif #numbers == 4 then -- vier Zahlen (192.168.x.y): die letzten beiden verwenden major = numbers[3] minor = numbers[4] else replace_id = false end if replace_id then if (0 <= major) and (major <= 255) and (1 <= minor) and (minor <= 255) then local id_string = major .. "." .. minor on_function("set_opennet_id", {id_string}) else show_invalid_id_warning = true end end end %>

<%:Opennet-ID / Network ID%>

<% if show_invalid_id_warning then %>

<%:The specified opennet ID is invalid. Please try again (input format: 'X.YYY').%>

<% end %>

<%=luci.i18n.translatef('Great that you decided to take part in Opennet. Register the IP of your Access-Point in the %sOpennet-Wiki%s and aquire a free IP-Address. Please read the information %sin the wiki%s for further details.', '', '', '', '')%>

<%:Please enter your Opennet-ID (1.X, 2.X or 3.X etc.) or the IP-Address of your first Opennet-Network-Interface, any change will reconfigure your network settings immediately.%>

<%:related network addresses%>

<% for index = 1, #devices do local count = 0 while (cursor:get_all("network", devices[index]..count)) do local v = cursor:get_all("network", devices[index]..count) %> <% count = count + 1 end end local free = cursor:get_all("network", "free") if free then %> <% end %>

<%=v[".name"]%> (<%:device%> <%=v.ifname%>)

<%=v.ipaddr%> / <%=v.netmask%>

<%=free[".name"]%> (<%:device%> <%=free.ifname%>)

<%=free.ipaddr%> / <%=free.netmask%>
<%+footer%>