⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gentest.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 5 页
字号:
					     MAX(parm[0].readx.in.mincnt, parm[0].readx.in.maxcnt));	GEN_COPY_PARM;	GEN_SET_FNUM_SMB(readx.in.file.fnum);	GEN_CALL_SMB(smb_raw_read(tree, &parm[i]));	CHECK_EQUAL(readx.out.remaining);	CHECK_EQUAL(readx.out.compaction_mode);	CHECK_EQUAL(readx.out.nread);	return true;}/*  generate writex operations*/static bool handler_smb_writex(int instance){	union smb_write parm[NSERVERS];	NTSTATUS status[NSERVERS];	parm[0].writex.level = RAW_WRITE_WRITEX;	parm[0].writex.in.file.fnum = gen_fnum(instance);	parm[0].writex.in.offset = gen_offset();	parm[0].writex.in.wmode = gen_bits_mask(0xFFFF);	parm[0].writex.in.remaining = gen_io_count();	parm[0].writex.in.count = gen_io_count();	parm[0].writex.in.data = talloc_zero_array(current_op.mem_ctx, uint8_t, parm[0].writex.in.count);	GEN_COPY_PARM;	GEN_SET_FNUM_SMB(writex.in.file.fnum);	GEN_CALL_SMB(smb_raw_write(tree, &parm[i]));	CHECK_EQUAL(writex.out.nwritten);	CHECK_EQUAL(writex.out.remaining);	return true;}/*  generate lockingx operations*/static bool handler_smb_lockingx(int instance){	union smb_lock parm[NSERVERS];	NTSTATUS status[NSERVERS];	int n, nlocks;	parm[0].lockx.level = RAW_LOCK_LOCKX;	parm[0].lockx.in.file.fnum = gen_fnum(instance);	parm[0].lockx.in.mode = gen_lock_mode();	parm[0].lockx.in.timeout = gen_timeout();	do {		/* make sure we don't accidentially generate an oplock		   break ack - otherwise the server can just block forever */		parm[0].lockx.in.ulock_cnt = gen_lock_count();		parm[0].lockx.in.lock_cnt = gen_lock_count();		nlocks = parm[0].lockx.in.ulock_cnt + parm[0].lockx.in.lock_cnt;	} while (nlocks == 0);	if (nlocks > 0) {		parm[0].lockx.in.locks = talloc_array(current_op.mem_ctx,							struct smb_lock_entry,							nlocks);		for (n=0;n<nlocks;n++) {			parm[0].lockx.in.locks[n].pid = gen_pid();			parm[0].lockx.in.locks[n].offset = gen_offset();			parm[0].lockx.in.locks[n].count = gen_io_count();		}	}	GEN_COPY_PARM;	GEN_SET_FNUM_SMB(lockx.in.file.fnum);	GEN_CALL_SMB(smb_raw_lock(tree, &parm[i]));	return true;}#if 0/*  generate a fileinfo query structure*/static void gen_setfileinfo(int instance, union smb_setfileinfo *info){	int i;	#undef LVL	#define LVL(v) {RAW_SFILEINFO_ ## v, "RAW_SFILEINFO_" #v}	struct {		enum smb_setfileinfo_level level;		const char *name;	}  levels[] = {#if 0		/* disabled until win2003 can handle them ... */		LVL(EA_SET), LVL(BASIC_INFO), LVL(DISPOSITION_INFO), 		LVL(STANDARD), LVL(ALLOCATION_INFO), LVL(END_OF_FILE_INFO), #endif		LVL(SETATTR), LVL(SETATTRE), LVL(BASIC_INFORMATION),		LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION), 		LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),		LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION), 		LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040)	};	do {		i = gen_int_range(0, ARRAY_SIZE(levels)-1);	} while (ignore_pattern(levels[i].name));	info->generic.level = levels[i].level;	switch (info->generic.level) {	case RAW_SFILEINFO_SETATTR:		info->setattr.in.attrib = gen_attrib();		info->setattr.in.write_time = gen_timet();		break;	case RAW_SFILEINFO_SETATTRE:		info->setattre.in.create_time = gen_timet();		info->setattre.in.access_time = gen_timet();		info->setattre.in.write_time = gen_timet();		break;	case RAW_SFILEINFO_STANDARD:		info->standard.in.create_time = gen_timet();		info->standard.in.access_time = gen_timet();		info->standard.in.write_time = gen_timet();		break;	case RAW_SFILEINFO_EA_SET: {		static struct ea_struct ea;		info->ea_set.in.num_eas = 1;		info->ea_set.in.eas = &ea;		info->ea_set.in.eas[0] = gen_ea_struct();	}		break;	case RAW_SFILEINFO_BASIC_INFO:	case RAW_SFILEINFO_BASIC_INFORMATION:		info->basic_info.in.create_time = gen_nttime();		info->basic_info.in.access_time = gen_nttime();		info->basic_info.in.write_time = gen_nttime();		info->basic_info.in.change_time = gen_nttime();		info->basic_info.in.attrib = gen_attrib();		break;	case RAW_SFILEINFO_DISPOSITION_INFO:	case RAW_SFILEINFO_DISPOSITION_INFORMATION:		info->disposition_info.in.delete_on_close = gen_bool();		break;	case RAW_SFILEINFO_ALLOCATION_INFO:	case RAW_SFILEINFO_ALLOCATION_INFORMATION:		info->allocation_info.in.alloc_size = gen_alloc_size();		break;	case RAW_SFILEINFO_END_OF_FILE_INFO:	case RAW_SFILEINFO_END_OF_FILE_INFORMATION:		info->end_of_file_info.in.size = gen_offset();		break;	case RAW_SFILEINFO_RENAME_INFORMATION:	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:		info->rename_information.in.overwrite = gen_bool();		info->rename_information.in.root_fid = gen_root_fid(instance);		info->rename_information.in.new_name = gen_fname_open(instance);		break;	case RAW_SFILEINFO_POSITION_INFORMATION:		info->position_information.in.position = gen_offset();		break;	case RAW_SFILEINFO_MODE_INFORMATION:		info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF);		break;	case RAW_SFILEINFO_GENERIC:	case RAW_SFILEINFO_SEC_DESC:	case RAW_SFILEINFO_UNIX_BASIC:	case RAW_SFILEINFO_UNIX_LINK:	case RAW_SFILEINFO_UNIX_HLINK:	case RAW_SFILEINFO_1023:	case RAW_SFILEINFO_1025:	case RAW_SFILEINFO_1029:	case RAW_SFILEINFO_1032:	case RAW_SFILEINFO_1039:	case RAW_SFILEINFO_1040:	case RAW_SFILEINFO_UNIX_INFO2:		/* Untested */		break;	}}#endif/*  generate a fileinfo query structure*/static void gen_setfileinfo(int instance, union smb_setfileinfo *info){	int i;	#undef LVL	#define LVL(v) {RAW_SFILEINFO_ ## v, "RAW_SFILEINFO_" #v}	struct levels {		enum smb_setfileinfo_level level;		const char *name;	};	struct levels smb_levels[] = {		LVL(EA_SET), LVL(BASIC_INFO), LVL(DISPOSITION_INFO), 		LVL(STANDARD), LVL(ALLOCATION_INFO), LVL(END_OF_FILE_INFO), 		LVL(SETATTR), LVL(SETATTRE), LVL(BASIC_INFORMATION),		LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION), 		LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),		LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION), 		LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040),	};	struct levels smb2_levels[] = {		LVL(BASIC_INFORMATION),		LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION), 		LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),		LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION), 		LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040)	};	struct levels *levels = options.smb2?smb2_levels:smb_levels;	uint32_t num_levels = options.smb2?ARRAY_SIZE(smb2_levels):ARRAY_SIZE(smb_levels);	do {		i = gen_int_range(0, num_levels-1);	} while (ignore_pattern(levels[i].name));		info->generic.level = levels[i].level;	switch (info->generic.level) {	case RAW_SFILEINFO_SETATTR:		info->setattr.in.attrib = gen_attrib();		info->setattr.in.write_time = gen_timet();		break;	case RAW_SFILEINFO_SETATTRE:		info->setattre.in.create_time = gen_timet();		info->setattre.in.access_time = gen_timet();		info->setattre.in.write_time = gen_timet();		break;	case RAW_SFILEINFO_STANDARD:		info->standard.in.create_time = gen_timet();		info->standard.in.access_time = gen_timet();		info->standard.in.write_time = gen_timet();		break;	case RAW_SFILEINFO_EA_SET: {		static struct ea_struct ea;		info->ea_set.in.num_eas = 1;		info->ea_set.in.eas = &ea;		info->ea_set.in.eas[0] = gen_ea_struct();		break;	}	case RAW_SFILEINFO_BASIC_INFO:	case RAW_SFILEINFO_BASIC_INFORMATION:		info->basic_info.in.create_time = gen_nttime();		info->basic_info.in.access_time = gen_nttime();		info->basic_info.in.write_time = gen_nttime();		info->basic_info.in.change_time = gen_nttime();		info->basic_info.in.attrib = gen_attrib();		break;	case RAW_SFILEINFO_DISPOSITION_INFO:	case RAW_SFILEINFO_DISPOSITION_INFORMATION:		info->disposition_info.in.delete_on_close = gen_bool();		break;	case RAW_SFILEINFO_ALLOCATION_INFO:	case RAW_SFILEINFO_ALLOCATION_INFORMATION:		info->allocation_info.in.alloc_size = gen_alloc_size();		break;	case RAW_SFILEINFO_END_OF_FILE_INFO:	case RAW_SFILEINFO_END_OF_FILE_INFORMATION:		info->end_of_file_info.in.size = gen_offset();		break;	case RAW_SFILEINFO_RENAME_INFORMATION:	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:		info->rename_information.in.overwrite = gen_bool();		info->rename_information.in.root_fid = gen_root_fid(instance);		info->rename_information.in.new_name = gen_fname_open(instance);		break;	case RAW_SFILEINFO_POSITION_INFORMATION:		info->position_information.in.position = gen_offset();		break;	case RAW_SFILEINFO_MODE_INFORMATION:		info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF);		break;	case RAW_SFILEINFO_GENERIC:	case RAW_SFILEINFO_SEC_DESC:	case RAW_SFILEINFO_1023:	case RAW_SFILEINFO_1025:	case RAW_SFILEINFO_1029:	case RAW_SFILEINFO_1032:	case RAW_SFILEINFO_1039:	case RAW_SFILEINFO_1040:	case RAW_SFILEINFO_UNIX_BASIC:	case RAW_SFILEINFO_UNIX_INFO2:	case RAW_SFILEINFO_UNIX_LINK:	case RAW_SFILEINFO_UNIX_HLINK:		/* Untested */		break;	}}/*  generate a fileinfo query structure*/static void gen_fileinfo_smb(int instance, union smb_fileinfo *info){	int i;	#undef LVL	#define LVL(v) {RAW_FILEINFO_ ## v, "RAW_FILEINFO_" #v}	struct {		enum smb_fileinfo_level level;		const char *name;	}  levels[] = {		LVL(GETATTR), LVL(GETATTRE), LVL(STANDARD),		LVL(EA_SIZE), LVL(ALL_EAS), LVL(IS_NAME_VALID),		LVL(BASIC_INFO), LVL(STANDARD_INFO), LVL(EA_INFO),		LVL(NAME_INFO), LVL(ALL_INFO), LVL(ALT_NAME_INFO),		LVL(STREAM_INFO), LVL(COMPRESSION_INFO), LVL(BASIC_INFORMATION),		LVL(STANDARD_INFORMATION), LVL(INTERNAL_INFORMATION), LVL(EA_INFORMATION),		LVL(ACCESS_INFORMATION), LVL(NAME_INFORMATION), LVL(POSITION_INFORMATION),		LVL(MODE_INFORMATION), LVL(ALIGNMENT_INFORMATION), LVL(ALL_INFORMATION),		LVL(ALT_NAME_INFORMATION), LVL(STREAM_INFORMATION), LVL(COMPRESSION_INFORMATION),		LVL(NETWORK_OPEN_INFORMATION), LVL(ATTRIBUTE_TAG_INFORMATION)	};	do {		i = gen_int_range(0, ARRAY_SIZE(levels)-1);	} while (ignore_pattern(levels[i].name));	info->generic.level = levels[i].level;}/*  generate qpathinfo operations*/static bool handler_smb_qpathinfo(int instance){	union smb_fileinfo parm[NSERVERS];	NTSTATUS status[NSERVERS];	parm[0].generic.in.file.path = gen_fname_open(instance);	gen_fileinfo_smb(instance, &parm[0]);	GEN_COPY_PARM;	GEN_CALL_SMB(smb_raw_pathinfo(tree, current_op.mem_ctx, &parm[i]));	return cmp_fileinfo(instance, parm, status);}/*  generate qfileinfo operations*/static bool handler_smb_qfileinfo(int instance){	union smb_fileinfo parm[NSERVERS];	NTSTATUS status[NSERVERS];	parm[0].generic.in.file.fnum = gen_fnum(instance);	gen_fileinfo_smb(instance, &parm[0]);	GEN_COPY_PARM;	GEN_SET_FNUM_SMB(generic.in.file.fnum);	GEN_CALL_SMB(smb_raw_fileinfo(tree, current_op.mem_ctx, &parm[i]));	return cmp_fileinfo(instance, parm, status);}/*  generate setpathinfo operations*/static bool handler_smb_spathinfo(int instance){	union smb_setfileinfo parm[NSERVERS];	NTSTATUS status[NSERVERS];	parm[0].generic.in.file.path = gen_fname_open(instance);	gen_setfileinfo(instance, &parm[0]);	GEN_COPY_PARM;	/* a special case for the fid in a RENAME */	if (parm[0].generic.level == RAW_SFILEINFO_RENAME_INFORMATION &&	    parm[0].rename_information.in.root_fid != 0) {		GEN_SET_FNUM_SMB(rename_information.in.root_fid);	}	GEN_CALL_SMB(smb_raw_setpathinfo(tree, &parm[i]));	return true;}/*  generate setfileinfo operations*/static bool handler_smb_sfileinfo(int instance){	union smb_setfileinfo parm[NSERVERS];	NTSTATUS status[NSERVERS];	parm[0].generic.in.file.fnum = gen_fnum(instance);	gen_setfileinfo(instance, &parm[0]);	GEN_COPY_PARM;	GEN_SET_FNUM_SMB(generic.in.file.fnum);	GEN_CALL_SMB(smb_raw_setfileinfo(tree, &parm[i]));	return true;}/*  this is called when a change notify reply comes in*/static void async_notify_smb(struct smbcli_request *req){	union smb_notify notify;	NTSTATUS status;	int i, j;	uint16_t tid;	struct smbcli_transport *transport = req->transport;	tid = SVAL(req->in.hdr, HDR_TID);	notify.nttrans.level = RAW_NOTIFY_NTTRANS;	status = smb_raw_changenotify_recv(req, current_op.mem_ctx, &notify);	if (NT_STATUS_IS_OK(status) && notify.nttrans.out.num_changes > 0) {		printf("notify tid=%d num_changes=%d action=%d name=%s\n", 		       tid, 		       notify.nttrans.out.num_changes,		       notify.nttrans.out.changes[0].action,		       notify.nttrans.out.changes[0].name.s);	}	for (i=0;i<NSERVERS;i++) {		for (j=0;j<NINSTANCES;j++) {			if (transport == servers[i].smb_tree[j]->session->transport &&			    tid == servers[i].smb_tree[j]->tid) {				notifies[i][j].notify_count++;				notifies[i][j].status = status;				notifies[i][j].notify = notify;			}		}	}}/*  generate change notify operations*/static bool handler_smb_notify(int instance){	union smb_notify parm[NSERVERS];	int n;	ZERO_STRUCT(parm[0]);	parm[0].nttrans.level			= RAW_NOTIFY_NTTRANS;	parm[0].nttrans.in.buffer_size		= gen_io_count();	parm[0].nttrans.in.completion_filter	= gen_bits_mask(0xFF);	parm[0].nttrans.in.file.fnum		= gen_fnum(instance);	parm[0].nttrans.in.recursive		= gen_bool();	GEN_COPY_PARM;	GEN_SET_FNUM_SMB(nttrans.in.file.fnum);	for (n=0;n<NSERVERS;n++) {		struct smbcli_request *req;		req = smb_raw_changenotify_send(servers[n].smb_tree[instance], &parm[n]);		req->async.fn = async_notify_smb;	}	return true;}/*  generate ntcreatex operations*/static bool handler_smb2_create(int instance){	struct smb2_create parm[NSERVERS];	NTSTATUS status[NSERVERS];	ZERO_STRUCT(parm[0]);	parm[0].in.security_flags             = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFF);	parm[0].in.oplock_level               = gen_bits_levels(3, 90, 0x0, 70, 0x9, 100, 0xFF);	parm[0].in.impersonation_level        = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFFFFFFFF);	parm[0].in.create_flags               = gen_reserved64();	parm[0].in.reserved                   = gen_reserved64();	parm[0].in.desired_access             = gen_access_mask();	parm[0].in.file_attributes            = gen_attrib();	parm[0].in.share_access               = gen_bits_mask2(0x7, 0xFFFFFFFF);	parm[0].in.create_disposition         = gen_open_disp();	parm[0].in.create_options             = gen_create_options();	parm[0].in.fname                      = gen_fname_open(instance);	parm[0].in.eas			      = gen_ea_list();	parm[0].in.alloc_size		      = gen_alloc_size();	parm[0].in.durable_open		      = gen_bool();	parm[0].in.query_maximal_access	      = gen_bool();	parm[0].in.timewarp		      = gen_timewarp();	parm[0].in.query_on_disk_id	      = gen_bool();	parm[0].in.sec_desc		      = gen_sec_desc();	if (!options.use_oplocks) {		/* mask out oplocks */		parm[0].in.oplock_level = 0;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -