Class: TCWrapper::Filter

Inherits:
Wrapper show all
Defined in:
lib/distem/wrapper/tc/filter.rb

Direct Known Subclasses

FilterU32

Constant Summary

WTYPE =
"filter"

Constants inherited from Wrapper

Wrapper::CMDBIN

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Wrapper

#add_param, #get_params

Constructor Details

- (Filter) initialize(iface, parent, dest, protocol, prio, type, params)

Returns a new instance of Filter



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/distem/wrapper/tc/filter.rb', line 9

def initialize(iface,parent,dest,protocol,prio,type,params)
  super(iface,WTYPE,type,params)
  @parent = parent
  @dest = dest
  @protocol = protocol
  @prio = prio
  @filterparams = {}

  @id = Id.new(@parent.id.major,@parent.id.next_minor_id)
  @parentid = @parent.id
  if (@dest.kind_of? Qdisc)
    @destid = @dest.parentid
  else
    @destid = @dest.id
  end
end

Instance Attribute Details

- (Object) id (readonly)

Returns the value of attribute id



7
8
9
# File 'lib/distem/wrapper/tc/filter.rb', line 7

def id
  @id
end

- (Object) parentid (readonly)

Returns the value of attribute parentid



7
8
9
# File 'lib/distem/wrapper/tc/filter.rb', line 7

def parentid
  @parentid
end

Instance Method Details

- (Object) add_filter_param(name, val)



41
42
43
# File 'lib/distem/wrapper/tc/filter.rb', line 41

def add_filter_param(name,val)
  @filterparams[name] = val
end

- (Object) get_cmd(*args)



26
27
28
29
30
31
32
33
# File 'lib/distem/wrapper/tc/filter.rb', line 26

def get_cmd(*args)
  super(*args) \
    + ((@parent.kind_of? QdiscRoot) ? \
       "root" : "parent " + @parentid.to_s) \
       + " protocol " + @protocol + (@prio > 0 ? " prio " + @prio.to_s : "") \
       + " " + @type + " " + get_filter_params + " flowid " + @destid.to_s \
       + " " + get_params
end

- (Object) get_filter_params



35
36
37
38
39
# File 'lib/distem/wrapper/tc/filter.rb', line 35

def get_filter_params
  ret = ""
  @filterparams.each{ |name,val| ret += name + " " + val.to_s + " "}
  return ret
end