Changeset 6440

Show
Ignore:
Timestamp:
11/16/10 00:00:53 (3 years ago)
Author:
jow
Message:

modules/admin-full: readd atm bridge config

Location:
luci/trunk/modules/admin-full/luasrc
Files:
1 removed
3 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/modules/admin-full/luasrc/controller/admin/network.lua

    r6435 r6440  
    6262    end 
    6363 
    64     page = entry({"admin", "network", "network"}, arcombine(template("admin_network/iface_overview"), cbi("admin_network/ifaces")), i18n("Interfaces"), 10) 
     64    page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("Interfaces"), 10) 
    6565    page.leaf   = true 
    6666    page.subindex = true 
  • luci/trunk/modules/admin-full/luasrc/model/cbi/admin_network/network.lua

    r6322 r6440  
    1414]]-- 
    1515 
    16 local sys = require "luci.sys" 
    17 local wa  = require "luci.tools.webadmin" 
    18 local fs  = require "nixio.fs" 
     16local fs = require "nixio.fs" 
    1917 
    20 local netstate = luci.model.uci.cursor_state():get_all("network") 
    2118m = Map("network", translate("Interfaces")) 
    22  
    23 local created 
    24 local netstat = sys.net.deviceinfo() 
    25  
    26 s = m:section(TypedSection, "interface", "") 
    27 s.addremove = true 
    28 s.anonymous = false 
    29 s.extedit   = luci.dispatcher.build_url("admin", "network", "network") .. "/%s" 
    30 s.template  = "cbi/tblsection" 
    31 s.override_scheme = true 
    32  
    33 function s.filter(self, section) 
    34     return section ~= "loopback" and section 
    35 end 
    36  
    37 function s.create(self, section) 
    38     if TypedSection.create(self, section) then 
    39         created = section 
    40     else 
    41         self.invalid_cts = true 
    42     end 
    43 end 
    44  
    45 function s.parse(self, ...) 
    46     TypedSection.parse(self, ...) 
    47     if created then 
    48         m.uci:save("network") 
    49         luci.http.redirect(luci.dispatcher.build_url("admin", "network", "network") 
    50          .. "/" .. created) 
    51     end 
    52 end 
    53  
    54 up = s:option(Flag, "up") 
    55 function up.cfgvalue(self, section) 
    56     return netstate[section] and netstate[section].up or "0" 
    57 end 
    58  
    59 function up.write(self, section, value) 
    60     local call 
    61     if value == "1" then 
    62         call = "ifup" 
    63     elseif value == "0" then 
    64         call = "ifdown" 
    65     end 
    66     os.execute(call .. " " .. section .. " >/dev/null 2>&1") 
    67 end 
    68  
    69 ifname = s:option(DummyValue, "ifname", translate("Device")) 
    70 function ifname.cfgvalue(self, section) 
    71     return netstate[section] and netstate[section].ifname 
    72 end 
    73  
    74 ifname.titleref = luci.dispatcher.build_url("admin", "network", "vlan") 
    75  
    76  
    77 if luci.model.uci.cursor():load("firewall") then 
    78     zone = s:option(DummyValue, "_zone", translate("Zone")) 
    79     zone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones") 
    80  
    81     function zone.cfgvalue(self, section) 
    82         return table.concat(wa.network_get_zones(section) or { "-" }, ", ") 
    83     end 
    84 end 
    85  
    86 hwaddr = s:option(DummyValue, "_hwaddr", 
    87     translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"), 
    88         translate("Hardware Address")) 
    89  
    90 function hwaddr.cfgvalue(self, section) 
    91     local ix = self.map:get(section, "ifname") or "" 
    92           ix = (type(ix) == "table") and ix[1] or ix 
    93  
    94     local mac = fs.readfile("/sys/class/net/" .. ix .. "/address") 
    95  
    96     if not mac then 
    97         mac = luci.util.exec("ifconfig " .. ix) 
    98         mac = mac and mac:match(" ([A-F0-9:]+)%s*\n") 
    99     end 
    100  
    101     if mac and #mac > 0 then 
    102         return mac:upper() 
    103     end 
    104  
    105     return "?" 
    106 end 
    107  
    108  
    109 ipaddr = s:option(DummyValue, "ipaddr", 
    110     translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>" .. 
    111         "-Address")) 
    112 function ipaddr.cfgvalue(self, section) 
    113     return table.concat(wa.network_get_addresses(section), ", ") 
    114 end 
    115  
    116 txrx = s:option(DummyValue, "_txrx", translate("Traffic"), 
    117     translate("transmitted / received")) 
    118  
    119 function txrx.cfgvalue(self, section) 
    120     local ix = self.map:get(section, "ifname") 
    121  
    122     local rx = netstat and netstat[ix] and netstat[ix][1] 
    123     rx = rx and wa.byte_format(tonumber(rx)) or "-" 
    124  
    125     local tx = netstat and netstat[ix] and netstat[ix][9] 
    126     tx = tx and wa.byte_format(tonumber(tx)) or "-" 
    127  
    128     return string.format("%s / %s", tx, rx) 
    129 end 
    130  
    131 errors = s:option(DummyValue, "_err", translate("Errors"), 
    132     translate("TX / RX")) 
    133  
    134 function errors.cfgvalue(self, section) 
    135     local ix = self.map:get(section, "ifname") 
    136  
    137     local rx = netstat and netstat[ix] and netstat[ix][3] 
    138     local tx = netstat and netstat[ix] and netstat[ix][11] 
    139  
    140     rx = rx and tostring(rx) or "-" 
    141     tx = tx and tostring(tx) or "-" 
    142  
    143     return string.format("%s / %s", tx, rx) 
    144 end 
     19m:section(SimpleSection).template = "admin_network/iface_overview" 
    14520 
    14621-- Show ATM bridge section if we have the capabilities 
     
    19166    payload:value("bridged", translate("bridged")) 
    19267    payload:value("routed", translate("routed")) 
     68else 
     69    m.pageaction = false 
    19370end 
    19471 
  • luci/trunk/modules/admin-full/luasrc/view/admin_network/iface_overview.htm

    r6438 r6440  
    2424    end 
    2525-%> 
    26  
    27 <%+header%> 
    2826 
    2927<script type="text/javascript" src="<%=resource%>/cbi.js"></script> 
     
    171169]]></script> 
    172170 
    173 <h2><a id="content" name="content"><%:Interface Overview%></a></h2> 
    174  
    175171<fieldset class="cbi-section" style="display:none"> 
    176172    <legend><%:Reconnecting interface%></legend> 
     
    181177<div class="cbi-map"> 
    182178    <fieldset class="cbi-section"> 
     179        <legend><%:Interface Overview%></legend> 
     180 
    183181        <table class="cbi-section-table" style="margin:10px; empty-cells:hide"> 
    184182            <tr class="cbi-section-table-titles"> 
     
    216214            <% end %> 
    217215        </table> 
     216 
     217        <form action="<%=luci.dispatcher.build_url("admin/network/iface_add")%>" method="post"> 
     218            <input type="submit" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" /> 
     219        </form> 
    218220    </fieldset> 
    219  
    220     <form action="<%=luci.dispatcher.build_url("admin/network/iface_add")%>" method="post"> 
    221         <br /> 
    222         <input type="submit" class="cbi-button cbi-button-apply" value="<%:Add new interface...%>" /> 
    223     </form> 
    224221</div> 
    225  
    226 <%+footer%>