New IPv6 integration
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 22 Jan 2013 10:44:16 +0000 (10:44 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 22 Jan 2013 10:44:16 +0000 (10:44 +0000)
libs/core/luasrc/model/network.lua
modules/admin-full/luasrc/controller/admin/network.lua
modules/admin-full/luasrc/model/cbi/admin_network/ipv6.lua [new file with mode: 0644]
protocols/6x4/luasrc/model/cbi/admin_network/proto_6in4.lua
protocols/6x4/luasrc/model/cbi/admin_network/proto_6to4.lua
protocols/core/luasrc/model/cbi/admin_network/proto_dhcp.lua
protocols/core/luasrc/model/cbi/admin_network/proto_dhcpv6.lua [new file with mode: 0644]
protocols/core/luasrc/model/cbi/admin_network/proto_static.lua

index 09a58d74249bb5f6dba1ea791dccfc2f9d6b57a3..f251411ec776cd04768acef8975e1521108a238c 100644 (file)
@@ -749,6 +749,8 @@ function protocol.get_i18n(self)
                return lng.translate("Static address")
        elseif p == "dhcp" then
                return lng.translate("DHCP client")
+       elseif p == "dhcpv6" then
+               return lng.translate("DHCPv6 client")
        else
                return lng.translate("Unknown")
        end
@@ -1546,8 +1548,15 @@ end
 -- setup base protocols
 _M:register_protocol("static")
 _M:register_protocol("dhcp")
+
+local dhcpv6 = _M:register_protocol("dhcpv6")
+function dhcpv6.is_installed(self)
+       return nfs.access("/lib/netifd/proto/dhcpv6.sh")
+end
+
 _M:register_protocol("none")
 
+
 -- load protocol extensions
 local exts = nfs.dir(utl.libpath() .. "/model/network")
 if exts then
index f401ecd185151560a2585c77c3353b570b9e9cfc..54afa1b380e4e626bcf44e05d1c500145dd68e14 100644 (file)
@@ -138,6 +138,13 @@ function index()
                        page.order  = 40
                end
 
+               if nixio.fs.access("/etc/config/6relayd") then
+                       page = node("admin", "network", "ipv6")
+                       page.target = cbi("admin_network/ipv6")
+                       page.title  = _("IPv6 RA and DHCPv6")
+                       page.order  = 45
+               end
+
                page  = node("admin", "network", "routes")
                page.target = cbi("admin_network/routes")
                page.title  = _("Static Routes")
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ipv6.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ipv6.lua
new file mode 100644 (file)
index 0000000..951b607
--- /dev/null
@@ -0,0 +1,66 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2013 Steven Barth <steven@midlink.org>
+
+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
+
+$Id$
+]]--
+
+local m = Map("6relayd", translate("IPv6 RA and DHCPv6"),
+       translate("6relayd is a lightweight router advertisement daemon and provides " ..
+        "stateless DHCPv6 service where size matters. It can also be used as a relay " ..
+        "for the aforementioned services."))
+
+local s = m:section(TypedSection, "server", translate("Server Settings"))
+s.addremove = true
+
+
+
+local o = s:option(DynamicList, "network", translate("Service Interfaces"),
+       translate("Interfaces to provide services on or to relay services to."))
+o.widget = "checkbox"
+o.template = "cbi/network_netlist"
+o.nocreate = true
+o.nobridges = true
+o.novirtual = true
+o.optional = false
+
+o = s:option(ListValue, "rd", translate("Router Advertisement-Service"))
+o:value("", translate("disabled"))
+o:value("server", translate("server mode"))
+o:value("relay", translate("relay mode"))
+
+o = s:option(ListValue, "dhcpv6", translate("DHCPv6-Service"))
+o:value("", translate("disabled"))
+o:value("server", translate("server mode"))
+o:value("relay", translate("relay mode"))
+
+o = s:option(ListValue, "ndp", translate("NDP-Proxy"))
+o:value("", translate("disabled"))
+o:value("relay", translate("relay mode"))
+
+o = s:option(MultiValue, "fallback_relay", translate("Fallback to relay"),
+       translate("Relay services from master to server interfaces when there is no public prefix available."))
+o:value("rd", translate("Router Advertisement"))
+o:value("dhcpv6", translate("DHCPV6"))
+o:value("ndp", translate("NDP-Proxy"))
+
+o = s:option(Value, "master", translate("Master Interface"),
+       translate("Specifies the master interface for services that are relayed."))
+o.template = "cbi/network_netlist"
+o.nocreate = true
+
+o = s:option(Flag, "always_rewrite_dns", translate("Always announce local DNS"),
+       translate("Announce the local router as DNS server even in relay mode."))
+
+o = s:option(Flag, "always_assume_default", translate("Always announce default router"),
+       translate("Announce as default router even if no public prefix is available."))
+o:depends("rd", "server")
+
+return m
index 5571cb07fda76a53659fe3ecd6547e1dcc10b72c..0b1f31ce78d57eb5c630afbcaa1d326abd03b147 100644 (file)
@@ -38,6 +38,13 @@ ip6addr = s:taboption("general", Value, "ip6addr",
 ip6addr.datatype = "ip6addr"
 
 
+local ip6prefix = s:taboption("general", Value, "ip6prefix",
+       translate("IPv6 routed prefix"),
+       translate("This is the prefix routed to you by the tunnel broker for use by clients"))
+
+ip6prefix.datatype = "ip6addr"
+
+
 local update = section:taboption("general", Flag, "_update",
        translate("Dynamic tunnel"),
        translate("Enable HE.net dynamic endpoint update"))
index 7258cbc91801f71469fcb9293296854554eb7e4a..d9d7b01a942df757fa2b6157ecebd4cd2340d8be 100644 (file)
@@ -12,8 +12,7 @@ You may obtain a copy of the License at
 
 local map, section, net = ...
 
-local ipaddr, adv_interface, adv_subnet
-local adv_valid_lifetime, adv_preferred_lifetime, defaultroute, metric, ttl, mtu
+local ipaddr, defaultroute, metric, ttl, mtu
 
 
 ipaddr = section:taboption("general", Value, "ipaddr",
@@ -22,67 +21,6 @@ ipaddr = section:taboption("general", Value, "ipaddr",
 
 ipaddr.datatype = "ip4addr"
 
-
-adv_interface = section:taboption("general", Value, "adv_interface", translate("Advertise IPv6 on network"))
-adv_interface.widget = "checkbox"
-adv_interface.exclude = arg[1]
-adv_interface.default = "lan"
-adv_interface.template = "cbi/network_netlist"
-adv_interface.nocreate = true
-adv_interface.nobridges = true
-adv_interface.novirtual = true
-
-function adv_interface.write(self, section, value)
-       if type(value) == "table" then
-               Value.write(self, section, table.concat(value, " "))
-       else
-               Value.write(self, section, value)
-       end
-end
-
-function adv_interface.remove(self, section)
-       self:write(section, " ")
-end
-
-adv_subnet  = section:taboption("general", Value, "adv_subnet",
-       translate("Advertised network ID"),
-       translate("Allowed range is 1 to 65535"))
-
-adv_subnet.placeholder = "1"
-adv_subnet.datatype    = "range(1,65535)"
-
-function adv_subnet.cfgvalue(self, section)
-       local v = Value.cfgvalue(self, section)
-       return v and tonumber(v, 16)
-end
-
-function adv_subnet .write(self, section, value)
-       value = tonumber(value) or 1
-
-       if value > 65535 then value = 65535
-       elseif value < 1 then value = 1 end
-
-       Value.write(self, section, "%X" % value)
-end
-
-
-adv_valid_lifetime = section:taboption("advanced", Value, "adv_valid_lifetime",
-       translate("Use valid lifetime"),
-       translate("Specifies the advertised valid prefix lifetime in seconds"))
-
-adv_valid_lifetime.placeholder = "300"
-adv_valid_lifetime.datatype    = "uinteger"
-
-
-adv_preferred_lifetime = section:taboption("advanced", Value, "adv_preferred_lifetime",
-       translate("Use preferred lifetime"),
-       translate("Specifies the advertised preferred prefix lifetime in seconds"))
-
-adv_preferred_lifetime.placeholder = "120"
-adv_preferred_lifetime.datatype    = "uinteger"
-
-
-
 defaultroute = section:taboption("advanced", Flag, "defaultroute",
        translate("Use default gateway"),
        translate("If unchecked, no default route is configured"))
index 8d2bcc6f69260ff204c883447eefa2cb30a5e260..19d177ef114a6b1acb4c7937dec7f93ea8c7adf8 100644 (file)
@@ -24,18 +24,6 @@ hostname.placeholder = luci.sys.hostname()
 hostname.datatype    = "hostname"
 
 
-if luci.model.network:has_ipv6() then
-
-       accept_ra = s:taboption("general", Flag, "accept_ra", translate("Accept router advertisements"))
-       accept_ra.default = accept_ra.enabled
-
-
-       send_rs = s:taboption("general", Flag, "send_rs", translate("Send router solicitations"))
-       send_rs.default = send_rs.disabled
-       send_rs:depends("accept_ra", "")
-
-end
-
 bcast = section:taboption("advanced", Flag, "broadcast",
        translate("Use broadcast flag"),
        translate("Required for certain ISPs, e.g. Charter with DOCSIS 3"))
diff --git a/protocols/core/luasrc/model/cbi/admin_network/proto_dhcpv6.lua b/protocols/core/luasrc/model/cbi/admin_network/proto_dhcpv6.lua
new file mode 100644 (file)
index 0000000..ad2430a
--- /dev/null
@@ -0,0 +1,62 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2013 Steven Barth <steven@midlink.org>
+
+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
+]]--
+
+local map, section, net = ...
+
+
+local o = section:taboption("general", ListValue, "reqaddress",
+       translate("Request IPv6-address"))
+o:value("try")
+o:value("force")
+o:value("none", "disabled")
+o.default = "try"
+
+
+o = section:taboption("general", Value, "reqprefix",
+       translate("Request IPv6-prefix of length"))
+o:value("auto", translate("automatic"))
+o:value("no", translate("disabled"))
+o:value("48")
+o:value("52")
+o:value("56")
+o:value("60")
+o:value("64")
+o.default = "auto"
+
+
+o = section:taboption("advanced", Flag, "defaultroute",
+       translate("Use default gateway"),
+       translate("If unchecked, no default route is configured"))
+o.default = o.enabled
+
+
+o = section:taboption("advanced", Flag, "peerdns",
+       translate("Use DNS servers advertised by peer"),
+       translate("If unchecked, the advertised DNS server addresses are ignored"))
+o.default = o.enabled
+
+
+o = section:taboption("advanced", DynamicList, "dns",
+       translate("Use custom DNS servers"))
+o:depends("peerdns", "")
+o.datatype = "list(ip6addr)"
+o.cast     = "string"
+
+
+o = section:taboption("advanced", Value, "clientid",
+       translate("Client ID to send when requesting DHCP"))
+
+luci.tools.proto.opt_macaddr(section, ifc, translate("Override MAC address"))
+
+o = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
+o.placeholder = "1500"
+o.datatype    = "max(1500)"
index e6bfcbbe31ea08668ee604a42153adb385bcafbc..bc43a8d438a7694df0d874e5703f574dcd432809 100644 (file)
@@ -47,23 +47,24 @@ dns.cast     = "string"
 
 if luci.model.network:has_ipv6() then
 
-       accept_ra = s:taboption("general", Flag, "accept_ra", translate("Accept router advertisements"))
-       accept_ra.default = accept_ra.disabled
-
-
-       send_rs = s:taboption("general", Flag, "send_rs", translate("Send router solicitations"))
-       send_rs.default = send_rs.enabled
-       send_rs:depends("accept_ra", "")
+       local ip6assign = section:taboption("general", Value, "ip6assign", translate("IPv6 assignment length"),
+               translate("Assign a part of given length of every public IPv6-prefix to this interface"))
+       ip6assign:value("", translate("disabled"))
+       ip6assign:value("64")
+       ip6assign.datatype = "max(64)"
 
 
        ip6addr = section:taboption("general", Value, "ip6addr", translate("IPv6 address"))
        ip6addr.datatype = "ip6addr"
-       ip6addr:depends("accept_ra", "")
 
 
        ip6gw = section:taboption("general", Value, "ip6gw", translate("IPv6 gateway"))
        ip6gw.datatype = "ip6addr"
-       ip6gw:depends("accept_ra", "")
+
+
+       local ip6prefix = s:taboption("general", Value, "ip6prefix", translate("IPv6 routed prefix"),
+               translate("Public prefix routed to this device for distribution to clients."))
+       ip6prefix.datatype = "ip6addr"
 
 end