-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frame.js
38 lines (33 loc) · 812 Bytes
/
Frame.js
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
const ARPMessage = require('./ARPMessage.js');
module.exports= class Frame
{
dest;
src;
type;
payload;
constructor(buffer)
{
this.dest = buffer.AsMACAddress(0);
this.src = buffer.AsMACAddress(6);
this.type = {};
this.type.id = buffer.AsHexString(12, 2);
this.type.name = buffer.AsFrameTypeName(12);
switch(this.type.name)
{
case "ARP":
this.payload = new ARPMessage(buffer);
break;
}
}
ConvertToReply(myMac, buffer)
{
console.log("changing dest from " + this.dest + " to " + this.src);
this.dest = this.src;
console.log("changing src from " + this.src + " to " + myMac);
this.src = myMac;
console.log("setting buffer to dest: " + this.dest);
buffer.SetMac(0, this.dest);
console.log("setting buffer to src: " + this.src);
buffer.SetMac(6, this.src);
}
}