-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathSegment.js
More file actions
40 lines (32 loc) · 1.01 KB
/
Segment.js
File metadata and controls
40 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
/* A node for IPv4Reassembler */
function Segment(begin, end, previousSegment, nextSegment) {
this.begin = begin;
this.end = end;
if(previousSegment === undefined || previousSegment === null) {
this.previousSegment = null;
} else {
this.previousSegment = previousSegment;
previousSegment.nextSegment = this;
//assert(previousSegment.end === this.begin);
}
if(nextSegment === undefined || nextSegment === null) {
this.nextSegment = null;
} else {
this.nextSegment = nextSegment;
nextSegment.previousSegment = this;
//assert(nextSegment.begin === this.end);
}
this.payload = null;
}
Segment.prototype.isEmpty = function() {
return this.payload === null;
}
/* For debug only */
Segment.prototype.toString = function() {
return "Begin: " + this.begin + "\n" +
"End: " + this.end + "\n" +
"Status: " +
(this.payload ? "BUSY" : "FREE") + "\n";
}
module.exports = Segment;