(data, srcIP, dstIP, ipHeader)
| 477 | } |
| 478 | |
| 479 | handleICMP(data, srcIP, dstIP, ipHeader) { |
| 480 | const type = data[0]; |
| 481 | if (type === 8) { // Echo Request |
| 482 | // Reply |
| 483 | const reply = Buffer.alloc(data.length); |
| 484 | data.copy(reply); |
| 485 | reply[0] = 0; // Echo Reply |
| 486 | reply[2] = 0; reply[3] = 0; // Clear checksum |
| 487 | |
| 488 | const ck = this.calculateChecksum(reply); |
| 489 | reply.writeUInt16BE(ck, 2); |
| 490 | |
| 491 | this.sendIP(reply, IP_PROTO_ICMP, dstIP, srcIP); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | sendIP(payload, protocol, srcIP, dstIP) { |
| 496 | const header = Buffer.alloc(20); |
no test coverage detected