OpenWrt Forum Archive

Topic: LuCI app template / luCI app mod for IPv6 6RD

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have been working on building a trunk build that has a IPv6 6RD on/off toggle.  From the command-line I have a working system.  However, I want to add a way to enable/disable this from LuCI.

Either through the Network->WAN setup page in LuCI, a simple checkbox to enable 6RD, which would be a 1 or a 0 option in a /etc/config/6rd file.  Or, having a 6RD tab in LuCI app dedicated to this that would have a checkbox to enable/disable.

the ifup $wan and ifdown $wan are working from the commandline, and I have a script that enables 6RD when the wan comes up, and deletes the IPs from the LAN interface when the wan link goes down, but I have no easy way to set this from LuCI on or off....It would be great to have a web-based way to change this other than SSH...

Any tips/links/ideas?

(Last edited by cconn on 27 Jun 2011, 23:11)

Add it to /usr/lib/lua/luci/model/cbi/admin_network/ifaces.lua

jow wrote:

Add it to /usr/lib/lua/luci/model/cbi/admin_network/ifaces.lua

hmm ok.  Is there a guide or general info as to how to program the LuCI interface?  Any tips or examples/links I should look at to figure out how to add this checkbox?

thx

right so I made a few mods to the ifaces.lua file and I have a working means of enabling/disabling 6RD on a tunnel interface designed for this purpose.

if has_6rd then
        rdenabled = s:taboption("general", Flag, "rdenabled", translate ("Enable 6RD")
        rdenabled.widget = "checkbox"
        rdenabled.default = rdenabled.disabled
        rdenabled.optional = true
end

in /usr/lib/lua/luci/model/cbi/admin_network/ifaces.lua


my question is, is it possible to, in the case where a user were to enable this checkbox in LuCI, to uncheck another option under the WAN interface?    Specifically, I want to disable:

ipv6 = s:taboption("ipv6", Flag, "ipv6", translate("Enable IPv6 on PPP link")

if somebody clicks the rdenabled checkbox.


As well, is it possible to disable an option that is not in /etc/config/network, specifically the dhcp6c enabled?


And conversely, if somebody was to check the "Enable IPv6 on PPP link" option, I would want that to disable the rdenabled checkbox.

Any pointers would be great thx

Hi,

I am also really interested in any instructions on how to add tabs, pages, and generally add to the LuCI configuration. If anybody has a link to the wiki I can read, or has any tips on where I can read any details, please do share them here.

I would like to make a package which depends on asterisk, and when installed adds an additional page to LuCI that allows to do some basic configuration of Asterisk to set up common stuff. How would somebody in my position go about getting that done?

Thanks in advance for any tips!
Iordan

cconn, you would need to override the .write() method of the corresponding option:

m = Map(...)
m:chain("dhcp6c")  -- this tells the system that we also may manipulate dhcp6c
...

s = section(...)
...

foo = s:taboption("blah", Flag, ...)
foo.rmempty = false  -- means if unchecked, the option is written as "option blah 0" instead of being removed
function foo.write(self, section, value)
  -- first do the normal action
  Flag.write(self, section, value)

  -- now manipulate the foreign options:
  m.uci:set("network", "wan", "ipv6", "0")
  m.uci:set("dhcp6c", "basic", "enabled", "0")
end

dancho: here's  the documentation overview: http://luci.subsignal.org/trac/wiki/Documentation
Since the docs are a bit terse, you might also take a look at the existing asterisk stuff here: http://luci.subsignal.org/trac/browser/ … -asterisk/ .
Note that most of this code was made for the "asterisk-uci" package which never got mainlained, so its effectively useless - but it might give some insights into how one could organize it.
Another component that mixes uci with native configuration is samba here: http://luci.subsignal.org/trac/browser/ … luci-samba

jow wrote:

cconn, you would need to override the .write() method of the corresponding option:

m = Map(...)
m:chain("dhcp6c")  -- this tells the system that we also may manipulate dhcp6c
...

s = section(...)
...

foo = s:taboption("blah", Flag, ...)
foo.rmempty = false  -- means if unchecked, the option is written as "option blah 0" instead of being removed
function foo.write(self, section, value)
  -- first do the normal action
  Flag.write(self, section, value)

  -- now manipulate the foreign options:
  m.uci:set("network", "wan", "ipv6", "0")
  m.uci:set("dhcp6c", "basic", "enabled", "0")
end

I am almost there.  I am a bit confused as how the options are written when checked or unchecked, here is a bit of code;

        if has_ipv6 then
                ipv6 = s:taboption("ipv6", Flag, "ipv6", translate("Enable IPv6 on PPP link") )
                ipv6:depends("proto", "ppp")
                ipv6:depends("proto", "pppoa")
                ipv6:depends("proto", "pppoe")
                ipv6:depends("proto", "pptp")
                ipv6:depends("proto", "3g")
                ipv6.rmempty = false
                function ipv6.write(self, section, value)
                        Flag.write(self, section, value)
                        m.uci:set("network", "6rdtun", "rdenabled", "0")
                end
        end
        if has_dhcp6c then
                usedhcp6c = s:taboption("ipv6", Flag, "dhcp6c", translate("Enable DHCP-PD client [dh
                usedhcp6c.rmempty = false
                usedhcp6c:depends("proto", "ppp")
                usedhcp6c:depends("proto", "pppoe")
                function usedhcp6c.write(self, section, value)
                        Flag.write(self, section, value)
                        m.uci:set("network", "wan", "ipv6", "1")
                        m.uci:set("dhcp6c", "basic", "enabled", "1")
                        m.uci:set("network", "6rdtun", "rdenabled", "0")
                end
        end


in essence, if ipv6 is enabled, I want to disable rdenabled on the 6rdtun interface.  if usedhcp6c is enabled but ipv6 is not, I want it to enable ipv6 as well.

conversely, if ipv6 gets disabled on the wan, disable usedhcp6c as well by default.

it would be however fine to disable usedhcp6c but leave ipv6 enabled. 

and finally, disable ipv6 on wan and usedhcp6c when rdenabled is set to true.

something is missing in my code, if I disable usedhcp6c it just gets re-enabled.


As well, I haven't figured out how to not create a "dhcp6c" option in the 'network' 'wan' 'dhcp6c' and just use whatever is set in 'dhcp6c' 'basic' 'enabled'

where can I read about the syntax of the taboption command, and in general, what the m: and s: represent in luci apps?

The discussion might have continued from here.