smb1ops.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * SMB1 (CIFS) version specific operations
  3. *
  4. * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
  5. *
  6. * This library is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License v2 as published
  8. * by the Free Software Foundation.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include "cifsglob.h"
  20. #include "cifsproto.h"
  21. #include "cifs_debug.h"
  22. /*
  23. * An NT cancel request header looks just like the original request except:
  24. *
  25. * The Command is SMB_COM_NT_CANCEL
  26. * The WordCount is zeroed out
  27. * The ByteCount is zeroed out
  28. *
  29. * This function mangles an existing request buffer into a
  30. * SMB_COM_NT_CANCEL request and then sends it.
  31. */
  32. static int
  33. send_nt_cancel(struct TCP_Server_Info *server, void *buf,
  34. struct mid_q_entry *mid)
  35. {
  36. int rc = 0;
  37. struct smb_hdr *in_buf = (struct smb_hdr *)buf;
  38. /* -4 for RFC1001 length and +2 for BCC field */
  39. in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2);
  40. in_buf->Command = SMB_COM_NT_CANCEL;
  41. in_buf->WordCount = 0;
  42. put_bcc(0, in_buf);
  43. mutex_lock(&server->srv_mutex);
  44. rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
  45. if (rc) {
  46. mutex_unlock(&server->srv_mutex);
  47. return rc;
  48. }
  49. rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
  50. mutex_unlock(&server->srv_mutex);
  51. cFYI(1, "issued NT_CANCEL for mid %u, rc = %d",
  52. in_buf->Mid, rc);
  53. return rc;
  54. }
  55. struct smb_version_operations smb1_operations = {
  56. .send_cancel = send_nt_cancel,
  57. };
  58. struct smb_version_values smb1_values = {
  59. .version_string = SMB1_VERSION_STRING,
  60. };