Class: Mu::Pcap::SCTP::Chunk::Data
Constant Summary
collapse
- FLAG_LAST_SEG =
0x01
- FLAG_FIRST_SEG =
0x02
- FLAG_UNORDERED =
0x04
Constants inherited
from Packet
Packet::IGNORE_UDP_PORTS
Instance Attribute Summary collapse
#flags, #size, #type
Attributes inherited from Packet
#payload, #payload_raw
Class Method Summary
collapse
Instance Method Summary
collapse
dummy_chunk, #padded_size
Methods inherited from Packet
#==, #deepdup, #flow_id, isolate_l7, normalize, #payload_bytes, #to_bytes
Constructor Details
#initialize ⇒ Data
Returns a new instance of Data.
17
18
19
20
21
22
23
24
25
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 17
def initialize
super
@type = CHUNK_DATA
@tsn = 0
@sid = 0
@ssn = 0
@ppid = 0
end
|
Instance Attribute Details
#ppid ⇒ Object
Returns the value of attribute ppid.
15
16
17
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 15
def ppid
@ppid
end
|
#sid ⇒ Object
Returns the value of attribute sid.
15
16
17
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 15
def sid
@sid
end
|
#ssn ⇒ Object
Returns the value of attribute ssn.
15
16
17
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 15
def ssn
@ssn
end
|
#tsn ⇒ Object
Returns the value of attribute tsn.
15
16
17
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 15
def tsn
@tsn
end
|
Class Method Details
.from_bytes(flags, size, bytes) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 27
def self.from_bytes flags, size, bytes
Pcap.assert(bytes.length >= 12,
"Truncated data chunk header: 12 > #{bytes.length}")
tsn, sid, ssn, ppid = bytes.unpack('NnnN')
data = Data.new
data.flags = flags
data.size = size
data.tsn = tsn
data.sid = sid
data.ssn = ssn
data.ppid = ppid
data.payload_raw = data.payload = bytes[12..size - 5]
return data
end
|
Instance Method Details
#complete_segment? ⇒ Boolean
92
93
94
95
96
97
98
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 92
def complete_segment?
if 1 == @flags[1] and 1 == @flags[0]
return true
else
return false
end
end
|
#first_segment? ⇒ Boolean
76
77
78
79
80
81
82
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 76
def first_segment?
if 1 == @flags[1] and 0 == @flags[0]
return true
else
return false
end
end
|
#last_segment? ⇒ Boolean
84
85
86
87
88
89
90
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 84
def last_segment?
if 0 == @flags[1] and 1 == @flags[0]
return true
else
return false
end
end
|
#ordered? ⇒ Boolean
68
69
70
71
72
73
74
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 68
def ordered?
if 0 == @flags[2]
return true
else
return false
end
end
|
#to_s ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 100
def to_s
flags_s = '['
if ordered?
flags_s += 'ordered, '
else
flags_s += 'unordered, '
end
if complete_segment?
flags_s += 'complete segment'
elsif first_segment?
flags_s += 'first segment'
elsif last_segment?
flags_s += 'last segment'
else
flags_s += 'middle segment'
end
flags_s += ']'
return "data(%s, %d, %d, %d, %d, %d, %s)" % [flags_s,
@size,
@tsn,
@sid,
@ssn,
@ppid,
@payload.inspect]
end
|
#write(io, ip) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/mu/pcap/sctp/chunk/data.rb', line 51
def write io, ip
= [@type, @flags, @size].pack('CCn')
= [@tsn, @sid, @ssn, @ppid].pack('NnnN')
io.write()
io.write()
io.write(@payload_raw)
if size < padded_size
(padded_size - size).times do
io.write("\x00")
end
end
end
|