Class: Dcmgr::VNet::Netfilter::EbtablesRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/dcmgr/vnet/netfilter/ebtables_rule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table = nil, chain = nil, protocol = nil, bound = nil, rule = nil) ⇒ EbtablesRule

Returns a new instance of EbtablesRule.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 15

def initialize(table = nil, chain = nil,  protocol = nil, bound = nil, rule = nil)
  super()
  raise ArgumentError, "table does not exist: #{table}" unless EbtablesChain.pre_made.keys.member?(table)
  self.table = table
  self.chain = chain
  self.protocol = protocol
  self.bound = bound
  self.rule = rule
end

Instance Attribute Details

#boundObject

Should be either :incoming or :outgoing



12
13
14
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 12

def bound
  @bound
end

#chainObject

Override the chain getter to allow us to handle premade chains with symbols instead of all caps strings. ie, :forward instead of “FORWARD”



27
28
29
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 27

def chain
  @chain
end

#protocolObject

Returns the value of attribute protocol.



13
14
15
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 13

def protocol
  @protocol
end

#ruleObject

Returns the value of attribute rule.



10
11
12
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 10

def rule
  @rule
end

#tableObject

Returns the value of attribute table.



8
9
10
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 8

def table
  @table
end

Class Method Details

.log_arp(prefix) ⇒ Object

Little static method that returns the part of an ebtables rule required for logging arp



36
37
38
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 36

def self.log_arp(prefix)
  "--log-ip --log-arp --log-prefix '#{prefix}'"
end

.protocolsObject

Getter for a hashmap of ebtables protocols



41
42
43
44
45
46
47
48
# File 'lib/dcmgr/vnet/netfilter/ebtables_rule.rb', line 41

def self.protocols
  {
    'ip4'  => 'ip4',
    'arp'  => 'arp',
    #'ip6'  => 'ip6',
    #'rarp' => '0x8035',
  }
end