MCPcopy Create free account
hub / github.com/deepclause/agentvm / handleICMP

Method handleICMP

src/network.js:479–493  ·  view source on GitHub ↗
(data, srcIP, dstIP, ipHeader)

Source from the content-addressed store, hash-verified

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);

Callers 1

handleIPMethod · 0.95

Calls 2

calculateChecksumMethod · 0.95
sendIPMethod · 0.95

Tested by

no test coverage detected