Class: Packetnom::Packet::Eth

Inherits:
Object
  • Object
show all
Defined in:
lib/packet/eth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ Eth

Initialize the packet



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/packet/eth.rb', line 13

def initialize( bytes )       
    # Layer 2
    @dst = bytes[0..5].join(':')
    @src = bytes[6..11].join(':')
    @type = bytes[12..13].join # http://en.wikipedia.org/wiki/EtherType

    # WHY DOES THIS HAVE PADDING ON ETHERTYPE ON REPLAY?!
    if @type.eql? '0000'
        @type = bytes[13..14].join
    end
    
end

Instance Attribute Details

#dstObject

Attributes



8
9
10
# File 'lib/packet/eth.rb', line 8

def dst
  @dst
end

#srcObject

Returns the value of attribute src.



9
10
11
# File 'lib/packet/eth.rb', line 9

def src
  @src
end

#typeObject Also known as: ethertype

Returns the value of attribute type.



10
11
12
# File 'lib/packet/eth.rb', line 10

def type
  @type
end

Instance Method Details

#type?(is) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/packet/eth.rb', line 26

def type? (is)
    if type.eql? type
        return true
    end

    false
end