Class: Packetnom::Packet::Udp

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ Udp

Initialize the packet



14
15
16
17
18
19
20
# File 'lib/packet/udp.rb', line 14

def initialize( bytes )                
    @src_port = bytes[34..35].join().to_i(16).to_s(10).to_i
    @dst_port = bytes[36..37].join().to_i(16).to_s(10).to_i
    
    @length = bytes[38..39].join().to_i(16).to_s(10).to_i
    @sum = bytes[40..41].join().to_i(16).to_s(10).to_i
end

Instance Attribute Details

#dst_portObject Also known as: dest_port, dport

Returns the value of attribute dst_port.



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

def dst_port
  @dst_port
end

#lengthObject Also known as: len

Returns the value of attribute length.



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

def length
  @length
end

#src_portObject Also known as: source_port, sport

Attributes



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

def src_port
  @src_port
end

#sumObject Also known as: checksum

Returns the value of attribute sum.



11
12
13
# File 'lib/packet/udp.rb', line 11

def sum
  @sum
end