VlanInfo: Parse the new protocol attribute

This commit is contained in:
nick
2013-11-13 17:52:32 +00:00
parent 610a70fe12
commit 0281a5e4eb
2 changed files with 7 additions and 5 deletions

View File

@@ -122,6 +122,7 @@ module Netlink
:unpack => lambda { |str,obj| VlanFlags.parse(str) } :unpack => lambda { |str,obj| VlanFlags.parse(str) }
rtattr :egress_qos, IFLA_VLAN_EGRESS_QOS rtattr :egress_qos, IFLA_VLAN_EGRESS_QOS
rtattr :ingress_qos, IFLA_VLAN_INGRESS_QOS rtattr :ingress_qos, IFLA_VLAN_INGRESS_QOS
rtattr :protocol, IFLA_VLAN_PROTOCOL, :ushort
end end
module Route module Route

View File

@@ -8,12 +8,12 @@ module Netlink
def clear_cache def clear_cache
# No cache # No cache
end end
def list(filter={}, &blk) def list(filter={}, &blk)
@rtsocket.link.list(filter.merge(:kind=>"vlan")) @rtsocket.link.list(filter.merge(:kind=>"vlan"))
end end
alias :each :list alias :each :list
# Higher-level API to manipulate VLAN interface. # Higher-level API to manipulate VLAN interface.
# nl.vlans.add( # nl.vlans.add(
# :link=>"lo", # :link=>"lo",
@@ -24,15 +24,15 @@ module Netlink
def add(opt) def add(opt)
@rtsocket.link.add(vlan_options(opt)) @rtsocket.link.add(vlan_options(opt))
end end
def change(opt) def change(opt)
@rtsocket.link.change(vlan_options(opt)) @rtsocket.link.change(vlan_options(opt))
end end
def replace(opt) def replace(opt)
@rtsocket.link.replace(vlan_options(opt)) @rtsocket.link.replace(vlan_options(opt))
end end
# Delete vlan given :link and :vlan_id. If you want to delete # Delete vlan given :link and :vlan_id. If you want to delete
# by :index then call link.delete instead. # by :index then call link.delete instead.
def delete(opt) def delete(opt)
@@ -59,6 +59,7 @@ module Netlink
end end
li.data.egress_qos = opt.delete(:egress_qos) if opt.has_key?(:egress_qos) li.data.egress_qos = opt.delete(:egress_qos) if opt.has_key?(:egress_qos)
li.data.ingress_qos = opt.delete(:ingress_qos) if opt.has_key?(:ingress_qos) li.data.ingress_qos = opt.delete(:ingress_qos) if opt.has_key?(:ingress_qos)
li.data.protocol = opt.delete(:protocol) if opt.has_key?(:protocol)
opt opt
end end
end end