(data)
| 258 | // Called when VM writes data to the network interface (FD 3) |
| 259 | // We need to unwrap QEMU framing (4-byte len) -> Frame |
| 260 | writeToNetwork(data) { |
| 261 | this.rxBuffer = Buffer.concat([this.rxBuffer, data]); |
| 262 | |
| 263 | while (this.rxBuffer.length >= 4) { |
| 264 | const frameLen = this.rxBuffer.readUInt32BE(0); |
| 265 | if (this.rxBuffer.length < 4 + frameLen) { |
| 266 | break; // Wait for more data |
| 267 | } |
| 268 | |
| 269 | const frame = this.rxBuffer.subarray(4, 4 + frameLen); |
| 270 | this.receive(frame); // Process the frame |
| 271 | |
| 272 | this.rxBuffer = this.rxBuffer.subarray(4 + frameLen); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | // Called when VM wants to read data from the network interface |
| 277 | readFromNetwork(maxLen) { |
no test coverage detected