|
|
|
@ -877,6 +877,41 @@ mod tests {
|
|
|
|
|
assert_eq!(compound_ops.commands[2], req_close);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_nfs4_request_setclientid() {
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
|
let buf: &[u8] = &[
|
|
|
|
|
0x00, 0x00, 0x00, 0x23, /*opcode*/
|
|
|
|
|
0x59, 0x1b, 0x09, 0x04, 0x28, 0x9c, 0x5d, 0x10, /*_verifier*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x2d, 0x4c, 0x69, 0x6e, 0x75, /*client_id*/
|
|
|
|
|
0x78, 0x20, 0x4e, 0x46, 0x53, 0x76, 0x34, 0x2e,
|
|
|
|
|
0x30, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x39, 0x33,
|
|
|
|
|
0x2e, 0x36, 0x37, 0x2e, 0x32, 0x32, 0x35, 0x2f,
|
|
|
|
|
0x31, 0x30, 0x2e, 0x31, 0x39, 0x33, 0x2e, 0x36,
|
|
|
|
|
0x37, 0x2e, 0x32, 0x31, 0x39, 0x20, 0x74, 0x63,
|
|
|
|
|
0x70, 0x00, 0x00, 0x00,
|
|
|
|
|
0x40, 0x00, 0x00, 0x00, /*_cb_program*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x03, 0x74, 0x63, 0x70, 0x00, /*r_netid*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x14, 0x31, 0x30, 0x2e, 0x31, /*r_addr*/
|
|
|
|
|
0x39, 0x33, 0x2e, 0x36, 0x37, 0x2e, 0x32, 0x32,
|
|
|
|
|
0x35, 0x2e, 0x31, 0x34, 0x30, 0x2e, 0x31, 0x38,
|
|
|
|
|
0x00, 0x00, 0x00, 0x01, /*_cb_id*/
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let (_, req_client_id) = nfs4_parse_nfsstring(&buf[12..64]).unwrap();
|
|
|
|
|
let (_, req_r_netid) = nfs4_parse_nfsstring(&buf[68 ..76]).unwrap();
|
|
|
|
|
let (_, req_r_adrr) = nfs4_parse_nfsstring(&buf[76..100]).unwrap();
|
|
|
|
|
|
|
|
|
|
let (_, resquest) = nfs4_req_setclientid(&buf[4..]).unwrap();
|
|
|
|
|
match resquest {
|
|
|
|
|
Nfs4RequestContent::SetClientId( req_setclientid ) => {
|
|
|
|
|
assert_eq!(req_setclientid.client_id, req_client_id);
|
|
|
|
|
assert_eq!(req_setclientid.r_netid, req_r_netid);
|
|
|
|
|
assert_eq!(req_setclientid.r_addr, req_r_adrr);
|
|
|
|
|
}
|
|
|
|
|
_ => { panic!("Failure"); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_nfs4_request_open() {
|
|
|
|
@ -1288,4 +1323,95 @@ mod tests {
|
|
|
|
|
_ => { panic!("Failure, {:?}", result); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_nfs4_response_readdir() {
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
|
let buf: &[u8] = &[
|
|
|
|
|
0x00, 0x00, 0x00, 0x1a, /*opcode*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, /*Status: 0*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*_verifier*/
|
|
|
|
|
// directory_listing
|
|
|
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x55, 0xeb, 0x42, 0x33, /*entry0*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x06, 0x43, 0x65, 0x6e, 0x74, 0x4f, 0x53, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x02, 0x00, 0x18, 0x09, 0x1a, 0x00, 0xb0, 0xa2, 0x3a,
|
|
|
|
|
0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x02, 0xaf, 0x8f, 0x9b, 0x4e,
|
|
|
|
|
0x29, 0xc4, 0xa2, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
|
|
|
|
|
0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x52, 0x00,
|
|
|
|
|
0xb0, 0x33, 0xf7, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x0b,
|
|
|
|
|
0x00, 0x00, 0x01, 0xfd, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x12,
|
|
|
|
|
0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x40, 0x66, 0x69, 0x61, 0x6e, 0x65,
|
|
|
|
|
0x2e, 0x69, 0x6e, 0x74, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
|
|
|
|
|
0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x40, 0x66, 0x69, 0x61, 0x6e, 0x65,
|
|
|
|
|
0x2e, 0x69, 0x6e, 0x74, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x4e, 0x1f, 0x17, 0xbc, 0x28, 0x86, 0x38, 0x31,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x4e, 0x9b, 0x8f, 0xaf, 0x1d, 0xa2, 0xc4, 0x29,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x4e, 0x9b, 0x8f, 0xaf, 0x1d, 0xa2, 0xc4, 0x29,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x0b,
|
|
|
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, /*entry1*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x04, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x02,
|
|
|
|
|
0x00, 0x18, 0x09, 0x1a, 0x00, 0xb0, 0xa2, 0x3a, 0x00, 0x00, 0x00, 0xb0,
|
|
|
|
|
0x00, 0x00, 0x00, 0x02, 0x83, 0x66, 0x9c, 0x4e, 0x25, 0x80, 0x82, 0x07,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x01, 0x01,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, 0x00, 0xad, 0x37, 0xad, 0x2c,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x02, 0x00, 0x00, 0x03, 0xff,
|
|
|
|
|
0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x10, 0x72, 0x6f, 0x6f, 0x74,
|
|
|
|
|
0x40, 0x66, 0x69, 0x61, 0x6e, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x61,
|
|
|
|
|
0x00, 0x00, 0x00, 0x10, 0x72, 0x6f, 0x6f, 0x74, 0x40, 0x66, 0x69, 0x61,
|
|
|
|
|
0x6e, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x4d, 0x6a, 0x97, 0xdb, 0x33, 0x89, 0xba, 0x2d,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x4e, 0x9c, 0x66, 0x83, 0x07, 0x82, 0x80, 0x25,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x4e, 0x9c, 0x66, 0x83, 0x07, 0x82, 0x80, 0x25,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x02,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, /*value_follows*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x01, /*EOF: YES*/
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let entry0_buf = &buf[16..240];
|
|
|
|
|
let entry1_buf = &buf[240..452];
|
|
|
|
|
|
|
|
|
|
let (_, res_entry0) = nfs4_res_readdir_entry_do(&entry0_buf[4..]).unwrap();
|
|
|
|
|
assert_eq!(res_entry0.name, "CentOS".as_bytes());
|
|
|
|
|
|
|
|
|
|
let (_, res_entry1) = nfs4_res_readdir_entry_do(&entry1_buf[4..]).unwrap();
|
|
|
|
|
assert_eq!(res_entry1.name, "data".as_bytes());
|
|
|
|
|
|
|
|
|
|
let (_, res_rd) = nfs4_res_readdir_ok(&buf[8..]).unwrap();
|
|
|
|
|
assert_eq!(res_rd.eof, true);
|
|
|
|
|
assert_eq!(res_rd.listing, [Some(res_entry0), Some(res_entry1)]);
|
|
|
|
|
|
|
|
|
|
let (_, response) = nfs4_res_readdir(&buf[4..]).unwrap();
|
|
|
|
|
match response {
|
|
|
|
|
Nfs4ResponseContent::ReadDir(status, rd) => {
|
|
|
|
|
assert_eq!(status, 0);
|
|
|
|
|
assert_eq!(rd, Some(res_rd));
|
|
|
|
|
}
|
|
|
|
|
_ => { panic!("Failure!"); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_nfs4_response_setclientid() {
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
|
let buf: &[u8] = &[
|
|
|
|
|
0x00, 0x00, 0x00, 0x23, /*opcode*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, /*status*/
|
|
|
|
|
0x14, 0x67, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x01, /*_clientid*/
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*_verifier*/
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let (_, response) = nfs4_res_setclientid(&buf[4..]).unwrap();
|
|
|
|
|
match response {
|
|
|
|
|
Nfs4ResponseContent::SetClientId(status) => {
|
|
|
|
|
assert_eq!(status, 0);
|
|
|
|
|
}
|
|
|
|
|
_ => { panic!("Failure"); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|