Class: Packetman::Clause
- Inherits:
-
Object
- Object
- Packetman::Clause
- Includes:
- ConfigMethods
- Defined in:
- lib/packetman/clause.rb
Instance Attribute Summary collapse
-
#mask ⇒ Object
Returns the value of attribute mask.
-
#search ⇒ Object
Returns the value of attribute search.
-
#start_bit ⇒ Object
Returns the value of attribute start_bit.
Instance Method Summary collapse
-
#data_address ⇒ Object
Full address of the query data (eg. ‘tcp`).
-
#initialize(search, mask, start_bit) ⇒ Clause
constructor
A new instance of Clause.
- #num_bytes ⇒ Object
-
#start_byte ⇒ Object
Address of first byte.
-
#to_s ⇒ Object
The whole filter clause fully assembled.
Methods included from ConfigMethods
Constructor Details
#initialize(search, mask, start_bit) ⇒ Clause
Returns a new instance of Clause.
7 8 9 10 11 |
# File 'lib/packetman/clause.rb', line 7 def initialize(search, mask, start_bit) self.search = search self.mask = mask self.start_bit = start_bit end |
Instance Attribute Details
#mask ⇒ Object
Returns the value of attribute mask.
5 6 7 |
# File 'lib/packetman/clause.rb', line 5 def mask @mask end |
#search ⇒ Object
Returns the value of attribute search.
5 6 7 |
# File 'lib/packetman/clause.rb', line 5 def search @search end |
#start_bit ⇒ Object
Returns the value of attribute start_bit.
5 6 7 |
# File 'lib/packetman/clause.rb', line 5 def start_bit @start_bit end |
Instance Method Details
#data_address ⇒ Object
Full address of the query data (eg. ‘tcp`)
23 24 25 |
# File 'lib/packetman/clause.rb', line 23 def data_address "#{config.transport}[#{start_byte}:#{num_bytes}]" end |
#num_bytes ⇒ Object
18 19 20 |
# File 'lib/packetman/clause.rb', line 18 def num_bytes Filter.bit_length(search)/8 end |
#start_byte ⇒ Object
Address of first byte
14 15 16 |
# File 'lib/packetman/clause.rb', line 14 def start_byte [config.payload_query, (config.offset_bits + start_bit)/8].compact.join(' + ') end |
#to_s ⇒ Object
The whole filter clause fully assembled
28 29 30 |
# File 'lib/packetman/clause.rb', line 28 def to_s "#{data_address} & #{mask} = #{search}" end |