- if ((conn->protocol >= PROTOCOL_SMB2_22) && (op != NULL)) {
- int cmp = channel_sequence - op->global->channel_sequence;
- bool overflow = false;
-
- if (abs(cmp) > INT16_MAX) {
- /*
- * we like to handle an 16-bit overflow here.
- *
- * If the difference between the numbers
- * if more than 15-bit, it is likely to be an overflow.
- */
- overflow = true;
- cmp *= -1;
- }
-
- if (!(flags & SMB2_HDR_FLAG_REPLAY_OPERATION)) {
- if (cmp == 0) {
- op->request_count += 1;
- } else if (cmp > 0) {
- op->pre_request_count += op->request_count;
- op->request_count = 0;
- op->request_count += 1;
- op->global->channel_sequence = channel_sequence;
- update_open = true;
- } else if (call->modify) {
- return smbd_smb2_request_error(req,
- NT_STATUS_FILE_NOT_AVAILABLE);
- }
- } else {
- if (cmp == 0) {
- if (op->pre_request_count == 0) {
- op->request_count += 1;
- } else if (call->modify) {
- return smbd_smb2_request_error(req,
- NT_STATUS_FILE_NOT_AVAILABLE);
- }
- } else if (cmp > 0) {
- if (op->pre_request_count == 0) {
- op->request_count += 1;
- op->global->channel_sequence =
- channel_sequence;
- update_open = true;
- } else if (call->modify) {
- return smbd_smb2_request_error(req,
- NT_STATUS_FILE_NOT_AVAILABLE);
- }
- } else {
- if (call->modify) {
- return smbd_smb2_request_error(req,
- NT_STATUS_FILE_NOT_AVAILABLE);
- }
- }
- }
- }
-