/source4/libcli/smb_composite/smb_composite.h

https://bitbucket.org/knarf/samba · C Header · 260 lines · 173 code · 27 blank · 60 comment · 0 complexity · 391e7df4e2f1a1d913ef9224d9943626 MD5 · raw file

  1. /*
  2. Unix SMB/CIFS implementation.
  3. SMB composite request interfaces
  4. Copyright (C) Andrew Tridgell 2005
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /*
  17. this defines the structures associated with "composite"
  18. requests. Composite requests are libcli requests that are internally
  19. implemented as multiple libcli/raw/ calls, but can be treated as a
  20. single call via these composite calls. The composite calls are
  21. particularly designed to be used in async applications
  22. */
  23. #ifndef __SMB_COMPOSITE_H__
  24. #define __SMB_COMPOSITE_H__
  25. #include "libcli/raw/libcliraw.h"
  26. #include "libcli/smb2/smb2.h"
  27. /*
  28. a composite open/read(s)/close request that loads a whole file
  29. into memory. Used as a demo of the composite system.
  30. */
  31. struct smb_composite_loadfile {
  32. struct {
  33. const char *fname;
  34. } in;
  35. struct {
  36. uint8_t *data;
  37. uint32_t size;
  38. } out;
  39. };
  40. struct composite_context *smb_composite_loadfile_send(struct smbcli_tree *tree,
  41. struct smb_composite_loadfile *io);
  42. NTSTATUS smb_composite_loadfile_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
  43. NTSTATUS smb_composite_loadfile(struct smbcli_tree *tree,
  44. TALLOC_CTX *mem_ctx,
  45. struct smb_composite_loadfile *io);
  46. struct smb_composite_fetchfile {
  47. struct {
  48. const char *dest_host;
  49. const char **ports;
  50. const char *called_name;
  51. const char *service;
  52. const char *service_type;
  53. const char *socket_options;
  54. struct cli_credentials *credentials;
  55. const char *workgroup;
  56. const char *filename;
  57. struct smbcli_options options;
  58. struct smbcli_session_options session_options;
  59. struct resolve_context *resolve_ctx;
  60. struct gensec_settings *gensec_settings;
  61. } in;
  62. struct {
  63. uint8_t *data;
  64. uint32_t size;
  65. } out;
  66. };
  67. struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetchfile *io,
  68. struct tevent_context *event_ctx);
  69. NTSTATUS smb_composite_fetchfile_recv(struct composite_context *c,
  70. TALLOC_CTX *mem_ctx);
  71. NTSTATUS smb_composite_fetchfile(struct smb_composite_fetchfile *io,
  72. TALLOC_CTX *mem_ctx);
  73. /*
  74. a composite open/write(s)/close request that saves a whole file from
  75. memory. Used as a demo of the composite system.
  76. */
  77. struct smb_composite_savefile {
  78. struct {
  79. const char *fname;
  80. uint8_t *data;
  81. uint32_t size;
  82. } in;
  83. };
  84. struct composite_context *smb_composite_savefile_send(struct smbcli_tree *tree,
  85. struct smb_composite_savefile *io);
  86. NTSTATUS smb_composite_savefile_recv(struct composite_context *c);
  87. NTSTATUS smb_composite_savefile(struct smbcli_tree *tree,
  88. struct smb_composite_savefile *io);
  89. /*
  90. a composite request for a full connection to a remote server. Includes
  91. - socket establishment
  92. - session request
  93. - negprot
  94. - session setup (if credentials are not NULL)
  95. - tree connect (if service is not NULL)
  96. */
  97. struct smb_composite_connect {
  98. struct {
  99. const char *dest_host;
  100. const char **dest_ports;
  101. const char *socket_options;
  102. const char *called_name;
  103. const char *service;
  104. const char *service_type;
  105. struct cli_credentials *credentials;
  106. bool fallback_to_anonymous;
  107. const char *workgroup;
  108. struct smbcli_options options;
  109. struct smbcli_session_options session_options;
  110. struct gensec_settings *gensec_settings;
  111. } in;
  112. struct {
  113. struct smbcli_tree *tree;
  114. bool anonymous_fallback_done;
  115. } out;
  116. };
  117. struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io,
  118. TALLOC_CTX *mem_ctx,
  119. struct resolve_context *resolve_ctx,
  120. struct tevent_context *event_ctx);
  121. NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
  122. NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx,
  123. struct resolve_context *resolve_ctx,
  124. struct tevent_context *ev);
  125. /*
  126. generic session setup interface that takes care of which
  127. session setup varient to use
  128. */
  129. struct smb_composite_sesssetup {
  130. struct {
  131. uint32_t sesskey;
  132. uint32_t capabilities;
  133. struct cli_credentials *credentials;
  134. const char *workgroup;
  135. struct gensec_settings *gensec_settings;
  136. } in;
  137. struct {
  138. uint16_t vuid;
  139. } out;
  140. };
  141. struct composite_context *smb_composite_sesssetup_send(struct smbcli_session *session,
  142. struct smb_composite_sesssetup *io);
  143. NTSTATUS smb_composite_sesssetup_recv(struct composite_context *c);
  144. NTSTATUS smb_composite_sesssetup(struct smbcli_session *session, struct smb_composite_sesssetup *io);
  145. /*
  146. query file system info
  147. */
  148. struct smb_composite_fsinfo {
  149. struct {
  150. const char *dest_host;
  151. const char **dest_ports;
  152. const char *socket_options;
  153. const char *called_name;
  154. const char *service;
  155. const char *service_type;
  156. struct cli_credentials *credentials;
  157. const char *workgroup;
  158. enum smb_fsinfo_level level;
  159. struct gensec_settings *gensec_settings;
  160. } in;
  161. struct {
  162. union smb_fsinfo *fsinfo;
  163. } out;
  164. };
  165. struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
  166. struct smb_composite_fsinfo *io,
  167. struct resolve_context *resolve_ctx,
  168. struct tevent_context *event_ctx);
  169. NTSTATUS smb_composite_fsinfo_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
  170. NTSTATUS smb_composite_fsinfo(struct smbcli_tree *tree,
  171. TALLOC_CTX *mem_ctx,
  172. struct smb_composite_fsinfo *io,
  173. struct resolve_context *resolve_ctx,
  174. struct tevent_context *ev);
  175. /*
  176. composite call for appending new acl to the file's security descriptor and get
  177. new full acl
  178. */
  179. struct smb_composite_appendacl {
  180. struct {
  181. const char *fname;
  182. const struct security_descriptor *sd;
  183. } in;
  184. struct {
  185. struct security_descriptor *sd;
  186. } out;
  187. };
  188. struct composite_context *smb_composite_appendacl_send(struct smbcli_tree *tree,
  189. struct smb_composite_appendacl *io);
  190. NTSTATUS smb_composite_appendacl_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
  191. NTSTATUS smb_composite_appendacl(struct smbcli_tree *tree,
  192. TALLOC_CTX *mem_ctx,
  193. struct smb_composite_appendacl *io);
  194. /*
  195. a composite API to fire connect() calls to multiple targets, picking the
  196. first one.
  197. */
  198. struct smb_composite_connectmulti {
  199. struct {
  200. int num_dests;
  201. const char **hostnames;
  202. const char **addresses;
  203. int *ports; /* Either NULL for lpcfg_smb_ports() per
  204. * destination or a list of explicit ports */
  205. } in;
  206. struct {
  207. struct smbcli_socket *socket;
  208. } out;
  209. };
  210. struct smbcli_session;
  211. struct resolve_context;
  212. struct composite_context *smb2_composite_unlink_send(struct smb2_tree *tree,
  213. union smb_unlink *io);
  214. NTSTATUS smb2_composite_unlink(struct smb2_tree *tree, union smb_unlink *io);
  215. struct composite_context *smb2_composite_mkdir_send(struct smb2_tree *tree,
  216. union smb_mkdir *io);
  217. NTSTATUS smb2_composite_mkdir(struct smb2_tree *tree, union smb_mkdir *io);
  218. struct composite_context *smb2_composite_rmdir_send(struct smb2_tree *tree,
  219. struct smb_rmdir *io);
  220. NTSTATUS smb2_composite_rmdir(struct smb2_tree *tree, struct smb_rmdir *io);
  221. struct tevent_req *smb2_composite_setpathinfo_send(TALLOC_CTX *mem_ctx,
  222. struct tevent_context *ev,
  223. struct smb2_tree *tree,
  224. const union smb_setfileinfo *io);
  225. NTSTATUS smb2_composite_setpathinfo_recv(struct tevent_req *req);
  226. NTSTATUS smb2_composite_setpathinfo(struct smb2_tree *tree, union smb_setfileinfo *io);
  227. #endif /* __SMB_COMPOSITE_H__ */