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

📄 smbcomtransaction.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include "headers.h"static intsendresponse(void *magic, SmbBuffer *, char **errmsgp){	int rv;	SmbSession *s = magic;	rv = smbresponsesend(s);	if (rv < 0) {		smbstringprint(errmsgp, "sendresponse failed");		return 0;	}	return 1;}SmbTransactionMethod smbtransactionmethod = {	.encoderesponse = smbtransactionencoderesponse,	.sendresponse = sendresponse,};SmbTransactionMethod smbtransactionmethod2 = {	.encoderesponse = smbtransactionencoderesponse2,	.sendresponse = sendresponse,};intsmbcomtransaction(SmbSession *s, SmbHeader *h, uchar *pdata, SmbBuffer *b){	int rv;	char *errmsg;	SmbProcessResult pr = SmbProcessResultDie;	errmsg = nil;	rv = smbtransactiondecodeprimary(&s->transaction, h, pdata, b, &errmsg);	if (rv < 0) {		pr = SmbProcessResultFormat;		goto done;	}	if (rv == 0) {		h->wordcount = 0;		if (smbbufferputack(s->response, h, &s->peerinfo)) {			pr = SmbProcessResultReply;			s->nextcommand = SMB_COM_TRANSACTION_SECONDARY;		}		goto done;	}	smblogprint(h->command, "smbcomtransaction: %s scount %ud tpcount %lud tdcount %lud maxscount %lud maxpcount %lud maxdcount %lud\n",		s->transaction.in.name, s->transaction.in.scount, s->transaction.in.tpcount, s->transaction.in.tdcount,		s->transaction.in.maxscount, s->transaction.in.maxpcount, s->transaction.in.maxdcount);	smbbufferfree(&s->transaction.out.parameters);	smbbufferfree(&s->transaction.out.data);	s->transaction.out.parameters = smbbuffernew(s->transaction.in.maxpcount);	s->transaction.out.data = smbbuffernew(s->transaction.in.maxdcount);	if (strcmp(s->transaction.in.name, smbglobals.pipelanman) == 0)		pr = smbrap2(s);	else {		smbseterror(s, ERRDOS, ERRbadpath);		pr = SmbProcessResultError;		goto done;	}	if (pr == SmbProcessResultReply) {		char *errmsg;		errmsg = nil;		rv = smbtransactionrespond(&s->transaction, h, &s->peerinfo, s->response, &smbtransactionmethod, s, &errmsg);		if (!rv) {			smblogprint(h->command, "smbcomtransaction: failed: %s\n", errmsg);			pr = SmbProcessResultMisc;		}		else			pr = SmbProcessResultOk;	}done:	free(errmsg);	return pr;}intsmbcomtransaction2(SmbSession *s, SmbHeader *h, uchar *pdata, SmbBuffer *b){	int rv;	char *errmsg;	SmbProcessResult pr = SmbProcessResultDie;	ushort op;	errmsg = nil;	rv = smbtransactiondecodeprimary2(&s->transaction, h, pdata, b, &errmsg);	if (rv < 0) {	fmtfail:		pr = SmbProcessResultFormat;		goto done;	}	if (rv == 0) {		h->wordcount = 0;		if (smbbufferputack(s->response, h, &s->peerinfo)) {			pr = SmbProcessResultReply;			s->nextcommand = SMB_COM_TRANSACTION2_SECONDARY;		}		goto done;	}	smblogprint(h->command, "smbcomtransaction2: scount %ud tpcount %lud tdcount %lud maxscount %lud maxpcount %lud maxdcount %lud\n",		s->transaction.in.scount, s->transaction.in.tpcount, s->transaction.in.tdcount,		s->transaction.in.maxscount, s->transaction.in.maxpcount, s->transaction.in.maxdcount);	smbbufferfree(&s->transaction.out.parameters);	smbbufferfree(&s->transaction.out.data);	s->transaction.out.parameters = smbbuffernew(s->transaction.in.maxpcount);	s->transaction.out.data = smbbuffernew(s->transaction.in.maxdcount);	if (s->transaction.in.scount != 1)		goto fmtfail;	op = s->transaction.in.setup[0];	if (op >= smbtrans2optablesize || smbtrans2optable[op].name == nil) {		smblogprint(-1, "smbcomtransaction2: function %d unknown\n", op);		pr = SmbProcessResultUnimp;		goto done;	}	if (smbtrans2optable[op].process == nil) {		smblogprint(-1, "smbcomtransaction2: %s unimplemented\n", smbtrans2optable[op].name);		pr = SmbProcessResultUnimp;		goto done;	}	pr = (*smbtrans2optable[op].process)(s, h);	if (pr == SmbProcessResultReply) {		char *errmsg;		errmsg = nil;		rv = smbtransactionrespond(&s->transaction, h, &s->peerinfo, s->response, &smbtransactionmethod2, s, &errmsg);		if (!rv) {			smblogprint(h->command, "smbcomtransaction2: failed: %s\n", errmsg);			pr = SmbProcessResultMisc;		}		else			pr = SmbProcessResultOk;	}done:	free(errmsg);	return pr;}

⌨️ 快捷键说明

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