1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

s4:libcli/smb2: add smb2_transport_credits_set_charge() to change the CreditsCharge value for the next request

metze
This commit is contained in:
Stefan Metzmacher 2009-07-13 12:25:40 +02:00
parent af3444e611
commit da737f2447
3 changed files with 14 additions and 4 deletions

View File

@ -78,9 +78,11 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
req = talloc(transport, struct smb2_request);
if (req == NULL) return NULL;
seqnum = transport->seqnum++;
if (seqnum == UINT64_MAX) {
seqnum = transport->seqnum++;
seqnum = transport->seqnum;
if (transport->credits.charge > 0) {
transport->seqnum += transport->credits.charge;
} else {
transport->seqnum += 1;
}
req->state = SMB2_REQUEST_INIT;
@ -131,7 +133,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
SIVAL(req->out.hdr, 0, SMB2_MAGIC);
SSVAL(req->out.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
SSVAL(req->out.hdr, SMB2_HDR_EPOCH, 0);
SSVAL(req->out.hdr, SMB2_HDR_EPOCH, transport->credits.charge);
SIVAL(req->out.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->out.hdr, SMB2_HDR_OPCODE, opcode);
SSVAL(req->out.hdr, SMB2_HDR_CREDIT, transport->credits.ask_num);

View File

@ -87,6 +87,7 @@ struct smb2_transport {
} compound;
struct {
uint16_t charge;
uint16_t ask_num;
} credits;

View File

@ -84,6 +84,7 @@ struct smb2_transport *smb2_transport_init(struct smbcli_socket *sock,
transport->socket = talloc_steal(transport, sock);
transport->options = *options;
transport->credits.charge = 0;
transport->credits.ask_num = 1;
/* setup the stream -> packet parser */
@ -552,6 +553,12 @@ void smb2_transport_credits_ask_num(struct smb2_transport *transport,
transport->credits.ask_num = ask_num;
}
void smb2_transport_credits_set_charge(struct smb2_transport *transport,
uint16_t charge)
{
transport->credits.charge = charge;
}
static void idle_handler(struct tevent_context *ev,
struct tevent_timer *te, struct timeval t, void *private_data)
{