parse_misc.c

来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 1,878 行 · 第 1/4 页

C
1,878
字号
	DEBUG(5,("make_log_info %d\n", __LINE__));	loginfo->undoc_buffer = 1;	init_unistr2(&loginfo->uni_logon_srv, logon_srv, UNI_STR_TERMINATE);	init_unistr2(&loginfo->uni_acct_name, acct_name, UNI_STR_TERMINATE);	loginfo->sec_chan = sec_chan;	init_unistr2(&loginfo->uni_comp_name, comp_name, UNI_STR_TERMINATE);}/******************************************************************* Reads or writes a DOM_LOG_INFO structure.********************************************************************/BOOL smb_io_log_info(const char *desc, DOM_LOG_INFO *loginfo, prs_struct *ps, int depth){	if (loginfo == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_log_info");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint32("undoc_buffer", ps, depth, &loginfo->undoc_buffer))		return False;	if(!smb_io_unistr2("unistr2", &loginfo->uni_logon_srv, True, ps, depth))		return False;	if(!smb_io_unistr2("unistr2", &loginfo->uni_acct_name, True, ps, depth))		return False;	if(!prs_uint16("sec_chan", ps, depth, &loginfo->sec_chan))		return False;	if(!smb_io_unistr2("unistr2", &loginfo->uni_comp_name, True, ps, depth))		return False;	return True;}/******************************************************************* Reads or writes a DOM_CHAL structure.********************************************************************/BOOL smb_io_chal(const char *desc, DOM_CHAL *chal, prs_struct *ps, int depth){	if (chal == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_chal");	depth++;		if(!prs_uint8s (False, "data", ps, depth, chal->data, 8))		return False;	return True;}/******************************************************************* Reads or writes a DOM_CRED structure.********************************************************************/BOOL smb_io_cred(const char *desc,  DOM_CRED *cred, prs_struct *ps, int depth){	if (cred == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_cred");	depth++;	if(!prs_align(ps))		return False;	if(!smb_io_chal ("", &cred->challenge, ps, depth))		return False;	if(!smb_io_utime("", &cred->timestamp, ps, depth))		return False;	return True;}/******************************************************************* Inits a DOM_CLNT_INFO2 structure.********************************************************************/void init_clnt_info2(DOM_CLNT_INFO2 *clnt,				const char *logon_srv, const char *comp_name,				const DOM_CRED *clnt_cred){	DEBUG(5,("make_clnt_info: %d\n", __LINE__));	init_clnt_srv(&clnt->login, logon_srv, comp_name);	if (clnt_cred != NULL) {		clnt->ptr_cred = 1;		memcpy(&clnt->cred, clnt_cred, sizeof(clnt->cred));	} else {		clnt->ptr_cred = 0;	}}/******************************************************************* Reads or writes a DOM_CLNT_INFO2 structure.********************************************************************/BOOL smb_io_clnt_info2(const char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth){	if (clnt == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_clnt_info2");	depth++;	if(!prs_align(ps))		return False;		if(!smb_io_clnt_srv("", &clnt->login, ps, depth))		return False;	if(!prs_align(ps))		return False;		if(!prs_uint32("ptr_cred", ps, depth, &clnt->ptr_cred))		return False;	if(!smb_io_cred("", &clnt->cred, ps, depth))		return False;	return True;}/******************************************************************* Inits a DOM_CLNT_INFO structure.********************************************************************/void init_clnt_info(DOM_CLNT_INFO *clnt,		const char *logon_srv, const char *acct_name,		uint16 sec_chan, const char *comp_name,		const DOM_CRED *cred){	DEBUG(5,("make_clnt_info\n"));	init_log_info(&clnt->login, logon_srv, acct_name, sec_chan, comp_name);	memcpy(&clnt->cred, cred, sizeof(clnt->cred));}/******************************************************************* Reads or writes a DOM_CLNT_INFO structure.********************************************************************/BOOL smb_io_clnt_info(const char *desc,  DOM_CLNT_INFO *clnt, prs_struct *ps, int depth){	if (clnt == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_clnt_info");	depth++;	if(!prs_align(ps))		return False;		if(!smb_io_log_info("", &clnt->login, ps, depth))		return False;	if(!smb_io_cred("", &clnt->cred, ps, depth))		return False;	return True;}/******************************************************************* Inits a DOM_LOGON_ID structure.********************************************************************/void init_logon_id(DOM_LOGON_ID *logonid, uint32 log_id_low, uint32 log_id_high){	DEBUG(5,("make_logon_id: %d\n", __LINE__));	logonid->low  = log_id_low;	logonid->high = log_id_high;}/******************************************************************* Reads or writes a DOM_LOGON_ID structure.********************************************************************/BOOL smb_io_logon_id(const char *desc, DOM_LOGON_ID *logonid, prs_struct *ps, int depth){	if (logonid == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_logon_id");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint32("low ", ps, depth, &logonid->low ))		return False;	if(!prs_uint32("high", ps, depth, &logonid->high))		return False;	return True;}/******************************************************************* Inits an OWF_INFO structure.********************************************************************/void init_owf_info(OWF_INFO *hash, const uint8 data[16]){	DEBUG(5,("init_owf_info: %d\n", __LINE__));		if (data != NULL)		memcpy(hash->data, data, sizeof(hash->data));	else		memset((char *)hash->data, '\0', sizeof(hash->data));}/******************************************************************* Reads or writes an OWF_INFO structure.********************************************************************/BOOL smb_io_owf_info(const char *desc, OWF_INFO *hash, prs_struct *ps, int depth){	if (hash == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_owf_info");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint8s (False, "data", ps, depth, hash->data, 16))		return False;	return True;}/******************************************************************* Reads or writes a DOM_GID structure.********************************************************************/BOOL smb_io_gid(const char *desc,  DOM_GID *gid, prs_struct *ps, int depth){	if (gid == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_gid");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint32("g_rid", ps, depth, &gid->g_rid))		return False;	if(!prs_uint32("attr ", ps, depth, &gid->attr))		return False;	return True;}/******************************************************************* Reads or writes an POLICY_HND structure.********************************************************************/BOOL smb_io_pol_hnd(const char *desc, POLICY_HND *pol, prs_struct *ps, int depth){	if (pol == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_pol_hnd");	depth++;	if(!prs_align(ps))		return False;	if(UNMARSHALLING(ps))		ZERO_STRUCTP(pol);		if (!prs_uint32("data1", ps, depth, &pol->data1))		return False;	if (!prs_uint32("data2", ps, depth, &pol->data2))		return False;	if (!prs_uint16("data3", ps, depth, &pol->data3))		return False;	if (!prs_uint16("data4", ps, depth, &pol->data4))		return False;	if(!prs_uint8s (False, "data5", ps, depth, pol->data5, sizeof(pol->data5)))		return False;	return True;}/******************************************************************* Create a UNISTR3.********************************************************************/void init_unistr3(UNISTR3 *str, const char *buf){	if (buf == NULL) {		str->uni_str_len=0;		str->str.buffer = NULL;		return;	}	str->uni_str_len = strlen(buf) + 1;	str->str.buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, str->uni_str_len);	if (str->str.buffer == NULL)		smb_panic("init_unistr3: malloc fail\n");	rpcstr_push((char *)str->str.buffer, buf, str->uni_str_len * sizeof(uint16), STR_TERMINATE);}/******************************************************************* Reads or writes a UNISTR3 structure.********************************************************************/BOOL smb_io_unistr3(const char *desc, UNISTR3 *name, prs_struct *ps, int depth){	if (name == NULL)		return False;	prs_debug(ps, depth, desc, "smb_io_unistr3");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint32("uni_str_len", ps, depth, &name->uni_str_len))		return False;			/* we're done if there is no string */		if ( name->uni_str_len == 0 )		return True;	/* don't know if len is specified by uni_str_len member... */	/* assume unicode string is unicode-null-terminated, instead */	if(!prs_unistr3(True, "unistr", name, ps, depth))		return False;	return True;}/******************************************************************* Stream a uint64_struct ********************************************************************/BOOL prs_uint64(const char *name, prs_struct *ps, int depth, UINT64_S *data64){	return prs_uint32(name, ps, depth+1, &data64->low) &&		prs_uint32(name, ps, depth+1, &data64->high);}/*******************************************************************reads or writes a BUFHDR2 structure.********************************************************************/BOOL smb_io_bufhdr2(const char *desc, BUFHDR2 *hdr, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "smb_io_bufhdr2");	depth++;	prs_align(ps);	prs_uint32("info_level", ps, depth, &(hdr->info_level));	prs_uint32("length    ", ps, depth, &(hdr->length    ));	prs_uint32("buffer    ", ps, depth, &(hdr->buffer    ));	return True;}/*******************************************************************reads or writes a BUFHDR4 structure.********************************************************************/BOOL smb_io_bufhdr4(const char *desc, BUFHDR4 *hdr, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "smb_io_bufhdr4");	depth++;	prs_align(ps);	prs_uint32("size", ps, depth, &hdr->size);	prs_uint32("buffer", ps, depth, &hdr->buffer);	return True;}/*******************************************************************reads or writes a RPC_DATA_BLOB structure.********************************************************************/BOOL smb_io_rpc_blob(const char *desc, RPC_DATA_BLOB *blob, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "smb_io_rpc_blob");	depth++;	prs_align(ps);	if ( !prs_uint32("buf_len", ps, depth, &blob->buf_len) )		return False;	if ( blob->buf_len == 0 )		return True;	if (UNMARSHALLING(ps)) {		blob->buffer = PRS_ALLOC_MEM(ps, uint8, blob->buf_len);		if (!blob->buffer) {			return False;		}	}	if ( !prs_uint8s(True, "buffer", ps, depth, blob->buffer, blob->buf_len) )		return False;	return True;}/*******************************************************************creates a UNIHDR structure.********************************************************************/BOOL make_uni_hdr(UNIHDR *hdr, int len){	if (hdr == NULL)	{		return False;	}	hdr->uni_str_len = 2 * len;	hdr->uni_max_len = 2 * len;	hdr->buffer      = len != 0 ? 1 : 0;	return True;}/*******************************************************************creates a BUFHDR2 structure.********************************************************************/BOOL make_bufhdr2(BUFHDR2 *hdr, uint32 info_level, uint32 length, uint32 buffer){	hdr->info_level = info_level;	hdr->length     = length;	hdr->buffer     = buffer;	return True;}/*******************************************************************return the length of a UNISTR string.********************************************************************/  uint32 str_len_uni(UNISTR *source){ 	uint32 i=0;	if (!source->buffer)		return 0;	while (source->buffer[i])		i++;	return i;}

⌨️ 快捷键说明

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