int main(void) { const unsigned int FrameLen = 36; unsigned char *macframe = malloc(FrameLen); // alloc MAC header until frame body // fill header with junk, to make this more interesting for (unsigned int i = 0; i < FrameLen; i++) { macframe[i] = 0xde; } set_proto_version(macframe, 0); set_type(macframe, 1); set_subtype(macframe, 1); set_to_ds(macframe, 1); set_from_ds(macframe, 0); set_retry(macframe, 0); set_more_data(macframe, 0); print_header(macframe); printf("Protocol version: %d\n", get_proto_version(macframe)); printf("Type: %d\n", get_type(macframe)); printf("Subtype: %d\n", get_subtype(macframe)); printf("Flags: To DS: %d From DS: %d Retry: %d More Data: %d\n", get_to_ds(macframe) != 0, get_from_ds(macframe) != 0, get_retry(macframe) != 0, get_more_data(macframe) != 0); free(macframe); }
END_TEST START_TEST(test_set_header) { unsigned char buf[36] = { 0 }; set_proto_version(buf, 1); if (buf[0] != 0x40) { fail("[Task 6.3.b] After setting proto_version to 1, the first byte should be 0x%02x, you have: 0x%02x", 0x40, buf[0]); } buf[0] = 0; set_type(buf, 2); if (buf[0] != 0x20) { fail("[Task 6.3.b] After setting type to 2, the first byte should be 0x%02x, you have: 0x%02x", 0x20, buf[0]); } buf[0] = 0; set_subtype(buf, 6); if (buf[0] != 0x6) { fail("[Task 6.3.b] After setting subtype to 6, the first byte should be 0x%02x, you have: 0x%02x", 0x6, buf[0]); } buf[1] = 0; set_to_ds(buf, 1); if (buf[1] != 0x80) { fail("[Task 6.3.b] After setting to_ds to 1, the second byte should be 0x%02x, you have: 0x%02x", 0x80, buf[1]); } }
void parse(fuse_args &args, Config &config) { const struct fuse_opt opts[] = { FUSE_OPT_KEY("-h",MERGERFS_OPT_HELP), FUSE_OPT_KEY("--help",MERGERFS_OPT_HELP), FUSE_OPT_KEY("-v",MERGERFS_OPT_VERSION), FUSE_OPT_KEY("-V",MERGERFS_OPT_VERSION), FUSE_OPT_KEY("--version",MERGERFS_OPT_VERSION), {NULL,-1U,0} }; fuse_opt_parse(&args, &config, opts, ::option_processor); set_fsname(args,config.srcmounts); set_subtype(args); }