INNER CODE UNIT · Rust

unknown_command_round_trips_big_endian

Barre/ZeroFS · zerofs/nbd-proto/src/lib.rs:438

    fn unknown_command_round_trips_big_endian() {
        let mut bytes = NBDRequest {
            magic: NBD_REQUEST_MAGIC,
            flags: 0,
            cmd_type: NBDCommand::Read,
            cookie: 0,
            offset: 0,
            length: 0,
        }
        .to_bytes()
        .unwrap();
        // cmd_type occupies the two bytes after magic (u32) + flags (u16).
        bytes[6] = 0x12;
        bytes[7] = 0x34;
        let decoded = NBDRequest::decode(&bytes).unwrap();
        assert_eq!(decoded.cmd_type, NBDCommand::Unknown(0x1234));
        assert_eq!(decoded.to_bytes().unwrap(), bytes);
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…