| 373 | |
| 374 | // Send to broadcast MAC (for DHCP etc) |
| 375 | sendBroadcast(payload, proto) { |
| 376 | const broadcastMac = Buffer.from([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]); |
| 377 | |
| 378 | const frame = Buffer.alloc(14 + payload.length); |
| 379 | broadcastMac.copy(frame, 0); // Destination: broadcast |
| 380 | this.gatewayMac.copy(frame, 6); // Source: gateway MAC |
| 381 | frame.writeUInt16BE(proto, 12); |
| 382 | payload.copy(frame, 14); |
| 383 | |
| 384 | // Wrap in QEMU framing |
| 385 | const header = Buffer.alloc(4); |
| 386 | header.writeUInt32BE(frame.length, 0); |
| 387 | |
| 388 | this.txBuffer = Buffer.concat([this.txBuffer, header, frame]); |
| 389 | |
| 390 | this.emit('network-activity'); |
| 391 | } |
| 392 | |
| 393 | receive(frame) { |
| 394 | try { |