Class: Mu::Pcap::IP
Constant Summary
collapse
- IPPROTO_TCP =
6
- IPPROTO_UDP =
17
- IPPROTO_HOPOPTS =
0
- IPPROTO_ROUTING =
43
- IPPROTO_FRAGMENT =
44
- IPPROTO_AH =
51
- IPPROTO_NONE =
59
- IPPROTO_DSTOPTS =
60
- IPPROTO_SCTP =
132
Constants inherited
from Packet
Packet::IGNORE_UDP_PORTS
Instance Attribute Summary collapse
Attributes inherited from Packet
#payload, #payload_raw
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Packet
#deepdup, #flow_id, isolate_l7, normalize, #payload_bytes, #to_bytes
Constructor Details
#initialize(src = nil, dst = nil) ⇒ IP
Returns a new instance of IP.
21
22
23
24
25
|
# File 'lib/mu/pcap/ip.rb', line 21
def initialize src=nil, dst=nil
super()
@src = src
@dst = dst
end
|
Instance Attribute Details
#dst ⇒ Object
Returns the value of attribute dst.
19
20
21
|
# File 'lib/mu/pcap/ip.rb', line 19
def dst
@dst
end
|
#src ⇒ Object
Returns the value of attribute src.
19
20
21
|
# File 'lib/mu/pcap/ip.rb', line 19
def src
@src
end
|
Class Method Details
.checksum(bytes) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/mu/pcap/ip.rb', line 49
def self.checksum bytes
if bytes.size & 1 == 1
bytes = bytes + "\0"
end
sum = 0
bytes.unpack("n*").each {|n| sum += n }
sum = (sum & 0xffff) + (sum >> 16 & 0xffff)
~sum & 0xffff
end
|
Instance Method Details
#==(other) ⇒ Object
43
44
45
46
47
|
# File 'lib/mu/pcap/ip.rb', line 43
def == other
return super &&
self.src == other.src &&
self.dst == other.dst
end
|
#proto ⇒ Object
35
36
37
|
# File 'lib/mu/pcap/ip.rb', line 35
def proto
raise NotImplementedError
end
|
39
40
41
|
# File 'lib/mu/pcap/ip.rb', line 39
def payload_length
raise NotImplementedError
end
|
#v4? ⇒ Boolean
27
28
29
|
# File 'lib/mu/pcap/ip.rb', line 27
def v4?
return false
end
|
#v6? ⇒ Boolean
31
32
33
|
# File 'lib/mu/pcap/ip.rb', line 31
def v6?
return false
end
|