smb_defs.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*****************************************************************************
  2. * __________________ _________ _____ _____ .__ ._.
  3. * \______ \______ \ / _____/ / \ / _ \ |__| ____ | |
  4. * | | _/| | \ \_____ \ / \ / \ / /_\ \| _/ __ \ | |
  5. * | | \| ` \/ / Y \ / | | \ ___/ \|
  6. * |______ /_______ /_______ \____|__ / /\ \____|__ |__|\___ | __
  7. * \/ \/ \/ \/ )/ \/ \/ \/
  8. *
  9. * This file is part of liBDSM. Copyright © 2014-2015 VideoLabs SAS
  10. *
  11. * Author: Julien 'Lta' BALLET <contact@lta.io>
  12. *
  13. * liBDSM is released under LGPLv2.1 (or later) and is also available
  14. * under a commercial license.
  15. *****************************************************************************
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU Lesser General Public License as published by
  18. * the Free Software Foundation; either version 2.1 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Lesser General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Lesser General Public License
  27. * along with this program; if not, write to the Free Software Foundation,
  28. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  29. *****************************************************************************/
  30. /**
  31. * @file smb_defs.h
  32. * @brief SMB usefull constants
  33. */
  34. #ifndef __BSDM_SMB_DEFS_H_
  35. #define __BSDM_SMB_DEFS_H_
  36. #define SMB_DEFAULT_BUFSIZE (8192)
  37. enum
  38. {
  39. /// SMB with Direct-TCP connection (OSX supports only this)
  40. SMB_TRANSPORT_TCP = 1,
  41. /// SMB with Netbios over TCP (older mechanism)
  42. SMB_TRANSPORT_NBT = 2
  43. };
  44. //-----------------------------------------------------------------------------/
  45. // SMB Session states
  46. //-----------------------------------------------------------------------------/
  47. enum
  48. {
  49. /// Error state, there was an error somewhere
  50. SMB_STATE_ERROR = -1,
  51. /// The SMB session has just been created
  52. SMB_STATE_NEW = 0,
  53. /// A Netbios session has been successfully established.
  54. SMB_STATE_NETBIOS_OK = 1,
  55. /// Dialect was successfully negotiated
  56. SMB_STATE_DIALECT_OK = 2,
  57. /// Session Authentication was successfull, you can become nasty
  58. SMB_STATE_SESSION_OK = 3
  59. };
  60. //-----------------------------------------------------------------------------/
  61. // smb_fseek() operations
  62. //-----------------------------------------------------------------------------/
  63. // smb_fseek operations
  64. enum
  65. {
  66. /// Set the read pointer at the given position
  67. SMB_SEEK_SET = 0,
  68. /// Adjusts the read pointer relatively to the actual position
  69. SMB_SEEK_CUR = 1
  70. };
  71. enum smb_session_supports_what
  72. {
  73. SMB_SESSION_XSEC = 0,
  74. };
  75. //-----------------------------------------------------------------------------/
  76. // File access rights (used when smb_open() files)
  77. //-----------------------------------------------------------------------------/
  78. /// Flag for smb_file_open. Request right for reading
  79. #define SMB_MOD_READ (1 << 0)
  80. /// Flag for smb_file_open. Request right for writing
  81. #define SMB_MOD_WRITE (1 << 1)
  82. /// Flag for smb_file_open. Request right for appending
  83. #define SMB_MOD_APPEND (1 << 2)
  84. /// Flag for smb_file_open. Request right for extended read (?)
  85. #define SMB_MOD_READ_EXT (1 << 3)
  86. /// Flag for smb_file_open. Request right for extended write (?)
  87. #define SMB_MOD_WRITE_EXT (1 << 4)
  88. /// Flag for smb_file_open. Request right for execution (?)
  89. #define SMB_MOD_EXEC (1 << 5)
  90. /// Flag for smb_file_open. Request right for child removal (?)
  91. #define SMB_MOD_RMCHILD (1 << 6)
  92. /// Flag for smb_file_open. Request right for reading file attributes
  93. #define SMB_MOD_READ_ATTR (1 << 7)
  94. /// Flag for smb_file_open. Request right for writing file attributes
  95. #define SMB_MOD_WRITE_ATTR (1 << 8)
  96. /// Flag for smb_file_open. Request right for removing file
  97. #define SMB_MOD_RM (1 << 16)
  98. /// Flag for smb_file_open. Request right for reading ACL
  99. #define SMB_MOD_READ_CTL (1 << 17)
  100. /// Flag for smb_file_open. Request right for writing ACL
  101. #define SMB_MOD_WRITE_DAC (1 << 18)
  102. /// Flag for smb_file_open. Request right for changing owner
  103. #define SMB_MOD_CHOWN (1 << 19)
  104. /// Flag for smb_file_open. (??)
  105. #define SMB_MOD_SYNC (1 << 20)
  106. /// Flag for smb_file_open. (??)
  107. #define SMB_MOD_SYS (1 << 24)
  108. /// Flag for smb_file_open. (??)
  109. #define SMB_MOD_MAX_ALLOWED (1 << 25)
  110. /// Flag for smb_file_open. Request all generic rights (??)
  111. #define SMB_MOD_GENERIC_ALL (1 << 28)
  112. /// Flag for smb_file_open. Request generic exec right (??)
  113. #define SMB_MOD_GENERIC_EXEC (1 << 29)
  114. /// Flag for smb_file_open. Request generic read right (??)
  115. #define SMB_MOD_GENERIC_READ (1 << 30)
  116. /// Flag for smb_file_open. Request generic write right (??)
  117. #define SMB_MOD_GENERIC_WRITE (1 << 31)
  118. /**
  119. * @brief Flag for smb_file_open. Default R/W mode
  120. * @details A few flags OR'ed
  121. */
  122. #define SMB_MOD_RW (SMB_MOD_READ | SMB_MOD_WRITE | SMB_MOD_APPEND \
  123. | SMB_MOD_READ_EXT | SMB_MOD_WRITE_EXT \
  124. | SMB_MOD_READ_ATTR | SMB_MOD_WRITE_ATTR \
  125. | SMB_MOD_READ_CTL )
  126. /**
  127. * @brief Flag for smb_file_open. Default R/O mode
  128. * @details A few flags OR'ed
  129. */
  130. #define SMB_MOD_RO (SMB_MOD_READ | SMB_MOD_READ_EXT \
  131. | SMB_MOD_READ_ATTR | SMB_MOD_READ_CTL )
  132. //-----------------------------------------------------------------------------/
  133. // NTSTATUS & internal return codes
  134. //-----------------------------------------------------------------------------/
  135. #define NT_STATUS_SUCCESS 0x00000000
  136. #define NT_STATUS_INVALID_SMB 0x00010002
  137. #define NT_STATUS_SMB_BAD_TID 0x00050002
  138. #define NT_STATUS_SMB_BAD_UID 0x005b0002
  139. #define NT_STATUS_NOT_IMPLEMENTED 0xc0000002
  140. #define NT_STATUS_INVALID_DEVICE_REQUEST 0xc0000010
  141. #define NT_STATUS_NO_SUCH_DEVICE 0xc000000e
  142. #define NT_STATUS_NO_SUCH_FILE 0xc000000f
  143. #define NT_STATUS_MORE_PROCESSING_REQUIRED 0xc0000016
  144. #define NT_STATUS_INVALID_LOCK_SEQUENCE 0xc000001e
  145. #define NT_STATUS_INVALID_VIEW_SIZE 0xc000001f
  146. #define NT_STATUS_ALREADY_COMMITTED 0xc0000021
  147. #define NT_STATUS_ACCESS_DENIED 0xc0000022
  148. #define NT_STATUS_OBJECT_NAME_NOT_FOUND 0xc0000034
  149. #define NT_STATUS_OBJECT_NAME_COLLISION 0xc0000035
  150. #define NT_STATUS_OBJECT_PATH_INVALID 0xc0000039
  151. #define NT_STATUS_OBJECT_PATH_NOT_FOUND 0xc000003a
  152. #define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0xc000003b
  153. #define NT_STATUS_PORT_CONNECTION_REFUSED 0xc0000041
  154. #define NT_STATUS_THREAD_IS_TERMINATING 0xc000004b
  155. #define NT_STATUS_DELETE_PENDING 0xc0000056
  156. #define NT_STATUS_PRIVILEGE_NOT_HELD 0xc0000061
  157. #define NT_STATUS_LOGON_FAILURE 0xc000006D
  158. #define NT_STATUS_DFS_EXIT_PATH_FOUND 0xc000009b
  159. #define NT_STATUS_MEDIA_WRITE_PROTECTED 0xc00000a2
  160. #define NT_STATUS_ILLEGAL_FUNCTION 0xc00000af
  161. #define NT_STATUS_FILE_IS_A_DIRECTORY 0xc00000ba
  162. #define NT_STATUS_FILE_RENAMED 0xc00000d5
  163. #define NT_STATUS_REDIRECTOR_NOT_STARTED 0xc00000fb
  164. #define NT_STATUS_DIRECTORY_NOT_EMPTY 0xc0000101
  165. #define NT_STATUS_PROCESS_IS_TERMINATING 0xc000010a
  166. #define NT_STATUS_TOO_MANY_OPENED_FILES 0xc000011f
  167. #define NT_STATUS_CANNOT_DELETE 0xc0000121
  168. #define NT_STATUS_FILE_DELETED 0xc0000123
  169. #define NT_STATUS_INSUFF_SERVER_RESOURCES 0xc0000205
  170. #define DSM_SUCCESS (0)
  171. #define DSM_ERROR_GENERIC (-1)
  172. #define DSM_ERROR_NT (-2) /* see smb_session_get_nt_status */
  173. #define DSM_ERROR_NETWORK (-3)
  174. #define DSM_ERROR_CHARSET (-4)
  175. #endif