Changeset 7543
- Timestamp:
- 09/24/11 02:57:59 (21 months ago)
- Files:
-
- 1 modified
-
luci/trunk/libs/core/luasrc/model/network.lua (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/core/luasrc/model/network.lua
r7502 r7543 31 31 32 32 33 local ifs, brs, sws, uci_r, uci_s33 local ifs, brs, sws, tns, uci_r, uci_s 34 34 35 35 function _list_del(c, s, o, r) … … 175 175 brs = { } 176 176 sws = { } 177 tns = { } 177 178 178 179 -- read interface information … … 182 183 local prnt = name:match("^([^%.]+)%.") 183 184 184 if _iface_virtual(name) or not _iface_ignore(name) then 185 if _iface_virtual(name) then 186 tns[name] = true 187 end 188 189 if tns[name] or not _iface_ignore(name) then 185 190 ifs[name] = ifs[name] or { 186 191 idx = i.ifindex or n, … … 746 751 function network.get_interface(self) 747 752 if self:is_virtual() then 748 return interface(self:proto() .. "-" .. self.sid) 753 tns[self:proto() .. "-" .. self.sid] = true 754 return interface(self:proto() .. "-" .. self.sid, self) 749 755 elseif self:is_bridge() then 750 return interface("br-" .. self.sid) 756 brs["br-" .. self.sid] = true 757 return interface("br-" .. self.sid, self) 751 758 else 752 759 local ifn = nil … … 754 761 for ifn in utl.imatch(uci_s:get("network", self.sid, "ifname")) do 755 762 ifn = ifn:match("^[^:/]+") 756 return ifn and interface(ifn )763 return ifn and interface(ifn, self) 757 764 end 758 765 ifn = nil … … 767 774 end 768 775 end) 769 return ifn and interface(ifn )776 return ifn and interface(ifn, self) 770 777 end 771 778 end … … 778 785 for ifn in utl.imatch(self:get("ifname")) do 779 786 ifn = ifn:match("^[^:/]+") 780 nfs[ifn] = interface(ifn )787 nfs[ifn] = interface(ifn, self) 781 788 end 782 789 … … 793 800 if s.network == self.sid then 794 801 ifn = "%s.network%d" %{ s.device, num[s.device] } 795 wfs[ifn] = interface(ifn )802 wfs[ifn] = interface(ifn, self) 796 803 end 797 804 end … … 845 852 846 853 interface = utl.class() 847 function interface.__init__(self, ifname )854 function interface.__init__(self, ifname, network) 848 855 local wif = _wifi_lookup(ifname) 849 856 if wif then self.wif = wifinet(wif) end 850 857 851 self.ifname = self.ifname or ifname 852 self.dev = ifs[self.ifname] 858 self.ifname = self.ifname or ifname 859 self.dev = ifs[self.ifname] 860 self.network = network 853 861 end 854 862 … … 858 866 859 867 function interface.mac(self) 860 return self.dev and self.dev.macaddr or "00:00:00:00:00:00"868 return (self.dev and self.dev.macaddr or "00:00:00:00:00:00"):upper() 861 869 end 862 870 … … 874 882 elseif brs[self.ifname] then 875 883 return "bridge" 884 elseif tns[self.ifname] then 885 return "tunnel" 876 886 elseif self.ifname:match("%.") then 877 887 return "vlan" … … 916 926 elseif x == "vlan" then 917 927 return i18n.translate("VLAN Interface") 928 elseif x == "tunnel" then 929 return i18n.translate("Tunnel Interface") 918 930 else 919 931 return i18n.translate("Ethernet Adapter") … … 991 1003 992 1004 function interface.get_network(self) 993 if self.dev and self.dev.network then 994 self.network = _M:get_network(self.dev.network) 1005 if not self.network then 1006 if self.dev and self.dev.network then 1007 self.network = _M:get_network(self.dev.network) 1008 end 995 1009 end 996 1010
