(frame)
| 391 | } |
| 392 | |
| 393 | receive(frame) { |
| 394 | try { |
| 395 | if (frame.length < 14) return; |
| 396 | const etherType = frame.readUInt16BE(12); |
| 397 | const payload = frame.subarray(14); |
| 398 | |
| 399 | // Learn VM MAC |
| 400 | const srcMac = frame.subarray(6, 12); |
| 401 | if (!this.vmMac) { |
| 402 | this.vmMac = Buffer.from(srcMac); |
| 403 | } |
| 404 | |
| 405 | if (etherType === ETH_P_ARP) { |
| 406 | this.handleARP(payload); |
| 407 | } else if (etherType === ETH_P_IP) { |
| 408 | this.handleIP(payload); |
| 409 | } |
| 410 | } catch(err) { |
| 411 | this.emit('error', err); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | handleARP(packet) { |
| 416 | // Simple ARP Reply |
no test coverage detected