forked from node-pcap/node_pcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethernet_addr.js
23 lines (20 loc) · 706 Bytes
/
ethernet_addr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var util = require("../util");
//Also known as MAC address
function EthernetAddr(raw_packet, offset) {
this.addr = new Array(6);
this.addr[0] = raw_packet[offset];
this.addr[1] = raw_packet[offset + 1];
this.addr[2] = raw_packet[offset + 2];
this.addr[3] = raw_packet[offset + 3];
this.addr[4] = raw_packet[offset + 4];
this.addr[5] = raw_packet[offset + 5];
}
EthernetAddr.prototype.toString = function toString() {
return util.int8_to_hex[this.addr[0]] + ":" +
util.int8_to_hex[this.addr[1]] + ":" +
util.int8_to_hex[this.addr[2]] + ":" +
util.int8_to_hex[this.addr[3]] + ":" +
util.int8_to_hex[this.addr[4]] + ":" +
util.int8_to_hex[this.addr[5]];
};
module.exports = EthernetAddr;