smb_defs.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //---------------------------------------------------------------------------
  2. // __________________ _________ _____ _____ .__ ._.
  3. // \______ \______ \ / _____/ / \ / _ \ |__| ____ | |
  4. // | | _/| | \ \_____ \ / \ / \ / /_\ \| _/ __ \ | |
  5. // | | \| ` \/ / Y \ / | | \ ___/ \|
  6. // |______ /_______ /_______ \____|__ / /\ \____|__ |__|\___ | __
  7. // \/ \/ \/ \/ )/ \/ \/ \/
  8. //
  9. // This file is part of libdsm. Copyright © 2014 VideoLabs SAS
  10. //
  11. // Author: Julien 'Lta' BALLET <contact@lta.io>
  12. //
  13. // This program is free software. It comes without any warranty, to the extent
  14. // permitted by applicable law. You can redistribute it and/or modify it under
  15. // the terms of the Do What The Fuck You Want To Public License, Version 2, as
  16. // published by Sam Hocevar. See the COPYING file for more details.
  17. //----------------------------------------------------------------------------
  18. #ifndef __BSDM_SMB_DEFS_H_
  19. #define __BSDM_SMB_DEFS_H_
  20. #include <bdsm/smb_packets.h>
  21. #define SMB_MAGIC { 0xff, 0x53, 0x4d, 0x42 } // aka "\xffSMB"
  22. #define SMB_DIALECTS { \
  23. "\2Samba", \
  24. "\2NT LM 0.12", \
  25. NULL \
  26. }
  27. // Dialect values must match position on SMB_DIALECTS array
  28. #define SMB_DIALECT_SAMBA 0
  29. #define SMB_DIALECT_NTLM 1
  30. #define SMB_CMD_CLOSE 0x04
  31. #define SMD_CMD_TRANS 0x25
  32. #define SMB_CMD_TRANS2 0x32
  33. #define SMB_CMD_TREE_DISCONNECT 0x71
  34. #define SMB_CMD_NEGOTIATE 0x72
  35. #define SMB_CMD_SETUP 0x73 // Session Setup AndX
  36. #define SMB_CMD_TREE_CONNECT 0x75 // Tree Connect AndX
  37. #define SMB_CMD_ECHO 0x2b
  38. #define SMB_CMD_READ 0x2e // Read AndX
  39. #define SMB_CMD_CREATE 0xa2 // NT Create AndX
  40. ///////////////////////////////////////////////////////////////////////////////
  41. //// Flags definitions
  42. // Many aren't use in libdsm but are here for possible later use
  43. // Protocol negotiation flags (flags field in spec)
  44. #define SMB_FLAG_RESPONSE (1 << 7)
  45. #define SMB_FLAG_NOTIFY (1 << 6)
  46. #define SMB_FLAG_OPLOCK (1 << 5)
  47. #define SMB_FLAG_CANONIC (1 << 4)
  48. #define SMB_FLAG_CASELESS (1 << 3)
  49. #define SMB_FLAG_BUFFER_POSTED (1 << 1)
  50. #define SMB_FLAG_LOCK_AND_READ (1 << 0)
  51. // More Protocol negotiation flags (flags2 field in spec)
  52. #define SMB_FLAG_UNICODE (1 << (15 + 8))
  53. #define SMB_FLAG_NT_ERRORS (1 << (14 + 8))
  54. #define SMB_FLAG_EXECUTE_ONLY (1 << (13 + 8))
  55. #define SMB_FLAG_DFS (1 << (12 + 8))
  56. #define SMB_FLAG_EXT_SEC (1 << (11 + 8))
  57. #define SMB_FLAG_REPARSE_PATH (1 << (10 + 8))
  58. #define SMB_FLAG_LONG_NAMES (1 << (6 + 8))
  59. #define SMB_FLAG_SIGN_REQUIRED (1 << (4 + 8))
  60. #define SMB_FLAG_COMPRESSED (1 << (3 + 8))
  61. #define SMB_FLAG_SIGN_SUPPORT (1 << (2 + 8))
  62. #define SMB_FLAG_EXT_ATTR (1 << (1 + 8))
  63. #define SMB_FLAG_LONG_NAMES_OK (1 << (0 + 8))
  64. // File creation/open flags
  65. #define SMB_CREATE_OPLOCK (1 << 1)
  66. #define SMB_CREATE_BATCH_OPLOCK (1 << 2)
  67. #define SMB_CREATE_MKDIR (1 << 3)
  68. #define SMB_CREATE_EXT_RESP (1 << 4)
  69. #define SMB_CREATE_DEFAULTS (0)
  70. // File access rights
  71. #define SMB_MOD_READ (1 << 0)
  72. #define SMB_MOD_WRITE (1 << 1)
  73. #define SMB_MOD_APPEND (1 << 2)
  74. #define SMB_MOD_READ_EXT (1 << 3)
  75. #define SMB_MOD_WRITE_EXT (1 << 4)
  76. #define SMB_MOD_EXEC (1 << 5)
  77. #define SMB_MOD_RMCHILD (1 << 6)
  78. #define SMB_MOD_READ_ATTR (1 << 7)
  79. #define SMB_MOD_WRITE_ATTR (1 << 8)
  80. #define SMB_MOD_RM (1 << 16)
  81. #define SMB_MOD_READ_CTL (1 << 17)
  82. #define SMB_MOD_WRITE_DAC (1 << 18)
  83. #define SMB_MOD_CHOWN (1 << 19)
  84. #define SMB_MOD_SYNC (1 << 20)
  85. #define SMB_MOD_SYS (1 << 24)
  86. #define SMB_MOD_MAX_ALLOWED (1 << 25)
  87. #define SMB_MOD_GENERIC_ALL (1 << 28)
  88. #define SMB_MOD_GENERIC_EXEC (1 << 29)
  89. #define SMB_MOD_GENERIC_READ (1 << 30)
  90. #define SMB_MOD_GENERIC_WRITE (1 << 31)
  91. #define SMB_MOD_RW (SMB_MOD_READ | SMB_MOD_WRITE | SMB_MOD_APPEND \
  92. | SMB_MOD_READ_EXT | SMB_MOD_WRITE_EXT \
  93. | SMB_MOD_READ_ATTR | SMB_MOD_WRITE_ATTR \
  94. | SMB_MOD_READ_CTL )
  95. #define SMB_MOD_RO (SMB_MOD_READ | SMB_MOD_READ_EXT \
  96. | SMB_MOD_READ_ATTR | SMB_MOD_READ_CTL )
  97. // File attributes
  98. #define SMB_ATTR_RO (1 << 0)
  99. #define SMB_ATTR_HIDDEN (1 << 1)
  100. #define SMB_ATTR_SYS (1 << 2)
  101. #define SMB_ATTR_VOLID (1 << 3) // Volume ID
  102. #define SMB_ATTR_DIR (1 << 4)
  103. #define SMB_ATTR_ARCHIVE (1 << 5) // Modified since last archive (!?)
  104. #define SMB_ATTR_DEVICE (1 << 6)
  105. #define SMB_ATTR_NORMAL (1 << 7)
  106. #define SMB_ATTR_TEMP (1 << 8)
  107. #define SMB_ATTR_SPARSE (1 << 9)
  108. #define SMB_ATTR_REPARSE_PT (1 << 10)
  109. #define SMB_ATTR_COMPRESSED (1 << 11)
  110. #define SMB_ATTR_OFFLINE (1 << 12)
  111. #define SMB_ATTR_INDEXED (1 << 13) // Not set = May be indexed
  112. #define SMB_ATTR_ENCRYPTED (1 << 14)
  113. // Share access flags
  114. #define SMB_SHARE_READ (1 << 0)
  115. #define SMB_SHARE_WRITE (1 << 1)
  116. #define SMB_SHARE_DELETE (1 << 2)
  117. #define SMB_NTLM_HASH_SIZE 16
  118. #define SMB_NTLM2_BLOB_SIZE 64
  119. #define SMB_LM2_BLOB_SIZE 8
  120. #define SMB_OS "Unix"
  121. #define SMB_LANMAN "libdsm-dev"
  122. #define NT_STATUS_SUCCESS 0x00000000
  123. #define NT_STATUS_MORE_PROCESSING_REQUIRED 0xc0000016
  124. #define NT_STATUS_ACCESS_DENIED 0xc0000022
  125. #endif