smb_defs.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. #define SMB_TR2_FIND_FIRST 0x0001
  41. #define SMB_TR2_QUERY_PATH 0x0005
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //// Flags definitions
  44. // Many aren't use in libdsm but are here for possible later use
  45. // Protocol negotiation flags (flags field in spec)
  46. #define SMB_FLAG_RESPONSE (1 << 7)
  47. #define SMB_FLAG_NOTIFY (1 << 6)
  48. #define SMB_FLAG_OPLOCK (1 << 5)
  49. #define SMB_FLAG_CANONIC (1 << 4)
  50. #define SMB_FLAG_CASELESS (1 << 3)
  51. #define SMB_FLAG_BUFFER_POSTED (1 << 1)
  52. #define SMB_FLAG_LOCK_AND_READ (1 << 0)
  53. // More Protocol negotiation flags (flags2 field in spec)
  54. #define SMB_FLAG_UNICODE (1 << (15 + 8))
  55. #define SMB_FLAG_NT_ERRORS (1 << (14 + 8))
  56. #define SMB_FLAG_EXECUTE_ONLY (1 << (13 + 8))
  57. #define SMB_FLAG_DFS (1 << (12 + 8))
  58. #define SMB_FLAG_EXT_SEC (1 << (11 + 8))
  59. #define SMB_FLAG_REPARSE_PATH (1 << (10 + 8))
  60. #define SMB_FLAG_LONG_NAMES (1 << (6 + 8))
  61. #define SMB_FLAG_SIGN_REQUIRED (1 << (4 + 8))
  62. #define SMB_FLAG_COMPRESSED (1 << (3 + 8))
  63. #define SMB_FLAG_SIGN_SUPPORT (1 << (2 + 8))
  64. #define SMB_FLAG_EXT_ATTR (1 << (1 + 8))
  65. #define SMB_FLAG_LONG_NAMES_OK (1 << (0 + 8))
  66. // File creation/open flags
  67. #define SMB_CREATE_OPLOCK (1 << 1)
  68. #define SMB_CREATE_BATCH_OPLOCK (1 << 2)
  69. #define SMB_CREATE_MKDIR (1 << 3)
  70. #define SMB_CREATE_EXT_RESP (1 << 4)
  71. #define SMB_CREATE_DEFAULTS (0)
  72. // File access rights
  73. #define SMB_MOD_READ (1 << 0)
  74. #define SMB_MOD_WRITE (1 << 1)
  75. #define SMB_MOD_APPEND (1 << 2)
  76. #define SMB_MOD_READ_EXT (1 << 3)
  77. #define SMB_MOD_WRITE_EXT (1 << 4)
  78. #define SMB_MOD_EXEC (1 << 5)
  79. #define SMB_MOD_RMCHILD (1 << 6)
  80. #define SMB_MOD_READ_ATTR (1 << 7)
  81. #define SMB_MOD_WRITE_ATTR (1 << 8)
  82. #define SMB_MOD_RM (1 << 16)
  83. #define SMB_MOD_READ_CTL (1 << 17)
  84. #define SMB_MOD_WRITE_DAC (1 << 18)
  85. #define SMB_MOD_CHOWN (1 << 19)
  86. #define SMB_MOD_SYNC (1 << 20)
  87. #define SMB_MOD_SYS (1 << 24)
  88. #define SMB_MOD_MAX_ALLOWED (1 << 25)
  89. #define SMB_MOD_GENERIC_ALL (1 << 28)
  90. #define SMB_MOD_GENERIC_EXEC (1 << 29)
  91. #define SMB_MOD_GENERIC_READ (1 << 30)
  92. #define SMB_MOD_GENERIC_WRITE (1 << 31)
  93. #define SMB_MOD_RW (SMB_MOD_READ | SMB_MOD_WRITE | SMB_MOD_APPEND \
  94. | SMB_MOD_READ_EXT | SMB_MOD_WRITE_EXT \
  95. | SMB_MOD_READ_ATTR | SMB_MOD_WRITE_ATTR \
  96. | SMB_MOD_READ_CTL )
  97. #define SMB_MOD_RO (SMB_MOD_READ | SMB_MOD_READ_EXT \
  98. | SMB_MOD_READ_ATTR | SMB_MOD_READ_CTL )
  99. // File attributes
  100. #define SMB_ATTR_RO (1 << 0)
  101. #define SMB_ATTR_HIDDEN (1 << 1)
  102. #define SMB_ATTR_SYS (1 << 2)
  103. #define SMB_ATTR_VOLID (1 << 3) // Volume ID
  104. #define SMB_ATTR_DIR (1 << 4)
  105. #define SMB_ATTR_ARCHIVE (1 << 5) // Modified since last archive (!?)
  106. #define SMB_ATTR_DEVICE (1 << 6)
  107. #define SMB_ATTR_NORMAL (1 << 7)
  108. #define SMB_ATTR_TEMP (1 << 8)
  109. #define SMB_ATTR_SPARSE (1 << 9)
  110. #define SMB_ATTR_REPARSE_PT (1 << 10)
  111. #define SMB_ATTR_COMPRESSED (1 << 11)
  112. #define SMB_ATTR_OFFLINE (1 << 12)
  113. #define SMB_ATTR_INDEXED (1 << 13) // Not set = May be indexed
  114. #define SMB_ATTR_ENCRYPTED (1 << 14)
  115. // Share access flags
  116. #define SMB_SHARE_READ (1 << 0)
  117. #define SMB_SHARE_WRITE (1 << 1)
  118. #define SMB_SHARE_DELETE (1 << 2)
  119. // Trans 2 flags
  120. //// Find First 2
  121. #define SMB_FIND2_ATTR_RO (1 << 0) // Include RO files in result
  122. #define SMB_FIND2_ATTR_HIDDEN (1 << 1) // Include hidden files
  123. #define SMB_FIND2_ATTR_SYSTEM (1 << 2) // Include system files
  124. #define SMB_FIND2_ATTR_VOLUME (1 << 3) // Include volume ID ?
  125. #define SMB_FIND2_ATTR_DIR (1 << 4) // Include directory ?
  126. #define SMB_FIND2_ATTR_ARCHIVE (1 << 5) // Include archive ?
  127. #define SMB_FIND2_ATTR_DEFAULT (SMB_FIND2_ATTR_RO | SMB_FIND2_ATTR_HIDDEN | \
  128. SMB_FIND2_ATTR_SYSTEM | SMB_FIND2_ATTR_DIR)
  129. #define SMB_FIND2_FLAG_CLOSE (1 << 0) // Close search after request ?
  130. #define SMB_FIND2_FLAG_CLOSE_EOS (1 << 1) // Close after End Of Search ?
  131. #define SMB_FIND2_FLAG_RESUME (1 << 2) // Send resume keys ?
  132. #define SMB_FIND2_FLAG_CONTINUE (1 << 3) // not set == new search
  133. #define SMB_FIND2_FLAG_BACKUP (1 << 3) // Backup intent ?
  134. #define SMB_FIND2_FLAG_DEFAULT (SMB_FIND2_FLAG_CLOSE_EOS | \
  135. SMB_FIND2_FLAG_RESUME)
  136. #define SMB_NTLM_HASH_SIZE 16
  137. #define SMB_NTLM2_BLOB_SIZE 64
  138. #define SMB_LM2_BLOB_SIZE 8
  139. #define SMB_OS "Unix"
  140. #define SMB_LANMAN "libdsm-dev"
  141. #define NT_STATUS_SUCCESS 0x00000000
  142. #define NT_STATUS_MORE_PROCESSING_REQUIRED 0xc0000016
  143. #define NT_STATUS_ACCESS_DENIED 0xc0000022
  144. #endif