@zerodensity/smb-cpp 0.0.0-bootstrap.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (640) hide show
  1. package/README.md +54 -3
  2. package/darwin_arm64/libsmb2.1.dylib +0 -0
  3. package/darwin_arm64/libsmb2.6.1.0.dylib +0 -0
  4. package/darwin_arm64/libsmb2.dylib +0 -0
  5. package/darwin_arm64/smb_server_cpp_darwin_arm64 +0 -0
  6. package/darwin_arm64/third-party/libsmb2/COPYING +24 -0
  7. package/darwin_arm64/third-party/libsmb2/LICENCE-LGPL-2.1.txt +502 -0
  8. package/darwin_arm64/third-party/libsmb2/NOTICE.txt +13 -0
  9. package/darwin_arm64/third-party/libsmb2/README +413 -0
  10. package/darwin_arm64/third-party/libsmb2/source/CMakeLists.txt +205 -0
  11. package/darwin_arm64/third-party/libsmb2/source/COPYING +24 -0
  12. package/darwin_arm64/third-party/libsmb2/source/LICENCE-LGPL-2.1.txt +502 -0
  13. package/darwin_arm64/third-party/libsmb2/source/Makefile.am +15 -0
  14. package/darwin_arm64/third-party/libsmb2/source/Makefile.platform +112 -0
  15. package/darwin_arm64/third-party/libsmb2/source/README +413 -0
  16. package/darwin_arm64/third-party/libsmb2/source/Xbox/libsmb2.sln +25 -0
  17. package/darwin_arm64/third-party/libsmb2/source/Xbox/libsmb2.vcxproj +248 -0
  18. package/darwin_arm64/third-party/libsmb2/source/Xbox/libsmb2.vcxproj.filters +304 -0
  19. package/darwin_arm64/third-party/libsmb2/source/Xbox 360/libsmb2.sln +32 -0
  20. package/darwin_arm64/third-party/libsmb2/source/Xbox 360/libsmb2.vcxproj +327 -0
  21. package/darwin_arm64/third-party/libsmb2/source/Xbox 360/libsmb2.vcxproj.filters +268 -0
  22. package/darwin_arm64/third-party/libsmb2/source/bootstrap +2 -0
  23. package/darwin_arm64/third-party/libsmb2/source/cmake/ConfigureChecks.cmake +63 -0
  24. package/darwin_arm64/third-party/libsmb2/source/cmake/FindSMB2.cmake +37 -0
  25. package/darwin_arm64/third-party/libsmb2/source/cmake/Modules/FindGSSAPI.cmake +30 -0
  26. package/darwin_arm64/third-party/libsmb2/source/cmake/Modules/FindLibKrb5.cmake +44 -0
  27. package/darwin_arm64/third-party/libsmb2/source/cmake/config.h.cmake +126 -0
  28. package/darwin_arm64/third-party/libsmb2/source/cmake/libsmb2.pc.cmake +14 -0
  29. package/darwin_arm64/third-party/libsmb2/source/component.mk +5 -0
  30. package/darwin_arm64/third-party/libsmb2/source/configure.ac +184 -0
  31. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareAdd.yaml +9 -0
  32. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareCheck.yaml +4 -0
  33. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareDel.yaml +5 -0
  34. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareDelSticky.yaml +5 -0
  35. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareEnum.yaml +7 -0
  36. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareGetInfo.yaml +6 -0
  37. package/darwin_arm64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareSetInfo.yaml +11 -0
  38. package/darwin_arm64/third-party/libsmb2/source/examples/CMakeLists.txt +28 -0
  39. package/darwin_arm64/third-party/libsmb2/source/examples/Makefile.am +54 -0
  40. package/darwin_arm64/third-party/libsmb2/source/examples/dcerpc.c +254 -0
  41. package/darwin_arm64/third-party/libsmb2/source/examples/picow/CMakeLists.txt +72 -0
  42. package/darwin_arm64/third-party/libsmb2/source/examples/picow/README.md +2 -0
  43. package/darwin_arm64/third-party/libsmb2/source/examples/picow/main.cpp +119 -0
  44. package/darwin_arm64/third-party/libsmb2/source/examples/picow/smb-ls-sync.c +0 -0
  45. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-CMD-FIND.c +335 -0
  46. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-cat-async.c +183 -0
  47. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-cat-sync.c +105 -0
  48. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-ftruncate-sync.c +87 -0
  49. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-ls-async.c +185 -0
  50. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-ls-epoll.c +234 -0
  51. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-lsa-lookupsids.c +292 -0
  52. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-lseek-sync.c +101 -0
  53. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-notify.c +183 -0
  54. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-put-async.c +175 -0
  55. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-put-sync.c +100 -0
  56. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-raw-fsstat-async.c +353 -0
  57. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-raw-getsd-async.c +401 -0
  58. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-raw-stat-async.c +448 -0
  59. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-readlink.c +80 -0
  60. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-rename-sync.c +80 -0
  61. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-server-sync.c +497 -0
  62. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-share-enum-sync.c +146 -0
  63. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-share-enum.c +208 -0
  64. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-share-info.c +255 -0
  65. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-stat-sync.c +103 -0
  66. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-statvfs-sync.c +85 -0
  67. package/darwin_arm64/third-party/libsmb2/source/examples/smb2-truncate-sync.c +78 -0
  68. package/darwin_arm64/third-party/libsmb2/source/idf_component.yml +5 -0
  69. package/darwin_arm64/third-party/libsmb2/source/include/Makefile.am +15 -0
  70. package/darwin_arm64/third-party/libsmb2/source/include/amiga_os/config.h +139 -0
  71. package/darwin_arm64/third-party/libsmb2/source/include/apple/config.h +139 -0
  72. package/darwin_arm64/third-party/libsmb2/source/include/asprintf.h +65 -0
  73. package/darwin_arm64/third-party/libsmb2/source/include/esp/config.h +139 -0
  74. package/darwin_arm64/third-party/libsmb2/source/include/libsmb2-private.h +670 -0
  75. package/darwin_arm64/third-party/libsmb2/source/include/module.modulemap +21 -0
  76. package/darwin_arm64/third-party/libsmb2/source/include/picow/FreeRTOSConfig.h +143 -0
  77. package/darwin_arm64/third-party/libsmb2/source/include/picow/README.md +2 -0
  78. package/darwin_arm64/third-party/libsmb2/source/include/picow/config.h +139 -0
  79. package/darwin_arm64/third-party/libsmb2/source/include/picow/lwipopts.h +27 -0
  80. package/darwin_arm64/third-party/libsmb2/source/include/picow/lwipopts_examples_common.h +90 -0
  81. package/darwin_arm64/third-party/libsmb2/source/include/portable-endian.h +377 -0
  82. package/darwin_arm64/third-party/libsmb2/source/include/ps3/config.h +139 -0
  83. package/darwin_arm64/third-party/libsmb2/source/include/slist.h +63 -0
  84. package/darwin_arm64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc-lsa.h +172 -0
  85. package/darwin_arm64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc-srvsvc.h +276 -0
  86. package/darwin_arm64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc.h +203 -0
  87. package/darwin_arm64/third-party/libsmb2/source/include/smb2/libsmb2-raw.h +497 -0
  88. package/darwin_arm64/third-party/libsmb2/source/include/smb2/libsmb2.h +1409 -0
  89. package/darwin_arm64/third-party/libsmb2/source/include/smb2/smb2-errors.h +549 -0
  90. package/darwin_arm64/third-party/libsmb2/source/include/smb2/smb2-ioctl.h +83 -0
  91. package/darwin_arm64/third-party/libsmb2/source/include/smb2/smb2.h +1251 -0
  92. package/darwin_arm64/third-party/libsmb2/source/include/xbox/config.h +139 -0
  93. package/darwin_arm64/third-party/libsmb2/source/include/xbox 360/config.h +139 -0
  94. package/darwin_arm64/third-party/libsmb2/source/lib/CMakeLists.txt +260 -0
  95. package/darwin_arm64/third-party/libsmb2/source/lib/Makefile.AMIGA +46 -0
  96. package/darwin_arm64/third-party/libsmb2/source/lib/Makefile.AMIGA_AROS +59 -0
  97. package/darwin_arm64/third-party/libsmb2/source/lib/Makefile.AMIGA_OS3 +59 -0
  98. package/darwin_arm64/third-party/libsmb2/source/lib/Makefile.PS3_PPU +100 -0
  99. package/darwin_arm64/third-party/libsmb2/source/lib/Makefile.am +85 -0
  100. package/darwin_arm64/third-party/libsmb2/source/lib/aes.c +33 -0
  101. package/darwin_arm64/third-party/libsmb2/source/lib/aes.h +29 -0
  102. package/darwin_arm64/third-party/libsmb2/source/lib/aes128ccm.c +185 -0
  103. package/darwin_arm64/third-party/libsmb2/source/lib/aes128ccm.h +28 -0
  104. package/darwin_arm64/third-party/libsmb2/source/lib/aes_apple.c +70 -0
  105. package/darwin_arm64/third-party/libsmb2/source/lib/aes_apple.h +34 -0
  106. package/darwin_arm64/third-party/libsmb2/source/lib/aes_reference.c +560 -0
  107. package/darwin_arm64/third-party/libsmb2/source/lib/aes_reference.h +49 -0
  108. package/darwin_arm64/third-party/libsmb2/source/lib/alloc.c +154 -0
  109. package/darwin_arm64/third-party/libsmb2/source/lib/asn1-ber.c +1078 -0
  110. package/darwin_arm64/third-party/libsmb2/source/lib/asn1-ber.h +161 -0
  111. package/darwin_arm64/third-party/libsmb2/source/lib/compat.c +599 -0
  112. package/darwin_arm64/third-party/libsmb2/source/lib/compat.h +829 -0
  113. package/darwin_arm64/third-party/libsmb2/source/lib/dcerpc-lsa.c +641 -0
  114. package/darwin_arm64/third-party/libsmb2/source/lib/dcerpc-srvsvc.c +885 -0
  115. package/darwin_arm64/third-party/libsmb2/source/lib/dcerpc.c +2513 -0
  116. package/darwin_arm64/third-party/libsmb2/source/lib/dreamcast/vfs.c +328 -0
  117. package/darwin_arm64/third-party/libsmb2/source/lib/dreamcast/vfs.h +15 -0
  118. package/darwin_arm64/third-party/libsmb2/source/lib/errors.c +1192 -0
  119. package/darwin_arm64/third-party/libsmb2/source/lib/hmac-md5.c +84 -0
  120. package/darwin_arm64/third-party/libsmb2/source/lib/hmac-md5.h +42 -0
  121. package/darwin_arm64/third-party/libsmb2/source/lib/hmac.c +245 -0
  122. package/darwin_arm64/third-party/libsmb2/source/lib/init.c +778 -0
  123. package/darwin_arm64/third-party/libsmb2/source/lib/krb5-wrapper.c +1072 -0
  124. package/darwin_arm64/third-party/libsmb2/source/lib/krb5-wrapper.h +134 -0
  125. package/darwin_arm64/third-party/libsmb2/source/lib/libsmb2.c +4292 -0
  126. package/darwin_arm64/third-party/libsmb2/source/lib/libsmb2.syms +168 -0
  127. package/darwin_arm64/third-party/libsmb2/source/lib/md4.h +43 -0
  128. package/darwin_arm64/third-party/libsmb2/source/lib/md4c.c +289 -0
  129. package/darwin_arm64/third-party/libsmb2/source/lib/md5.c +249 -0
  130. package/darwin_arm64/third-party/libsmb2/source/lib/md5.h +76 -0
  131. package/darwin_arm64/third-party/libsmb2/source/lib/ntlmssp.c +1380 -0
  132. package/darwin_arm64/third-party/libsmb2/source/lib/ntlmssp.h +84 -0
  133. package/darwin_arm64/third-party/libsmb2/source/lib/pdu.c +1159 -0
  134. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/TODO +6 -0
  135. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/imports.lst +84 -0
  136. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/irx_imports.h +28 -0
  137. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/ps2smb2.h +35 -0
  138. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/smb2_fio.c +816 -0
  139. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/smb2_fio.h +15 -0
  140. package/darwin_arm64/third-party/libsmb2/source/lib/ps2/smb2man.c +69 -0
  141. package/darwin_arm64/third-party/libsmb2/source/lib/sha-private.h +28 -0
  142. package/darwin_arm64/third-party/libsmb2/source/lib/sha.h +334 -0
  143. package/darwin_arm64/third-party/libsmb2/source/lib/sha1.c +450 -0
  144. package/darwin_arm64/third-party/libsmb2/source/lib/sha224-256.c +611 -0
  145. package/darwin_arm64/third-party/libsmb2/source/lib/sha384-512.c +1059 -0
  146. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-close.c +240 -0
  147. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-create.c +508 -0
  148. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-echo.c +202 -0
  149. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-error.c +157 -0
  150. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-flush.c +207 -0
  151. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-ioctl.c +445 -0
  152. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-lock.c +312 -0
  153. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-logoff.c +190 -0
  154. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-negotiate.c +646 -0
  155. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-notify-change.c +278 -0
  156. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-oplock-break.c +543 -0
  157. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-query-directory.c +580 -0
  158. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-query-info.c +753 -0
  159. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-read.c +391 -0
  160. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-session-setup.c +331 -0
  161. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-set-info.c +361 -0
  162. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-tree-connect.c +278 -0
  163. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-tree-disconnect.c +171 -0
  164. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-cmd-write.c +319 -0
  165. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-data-file-info.c +537 -0
  166. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-data-filesystem-info.c +384 -0
  167. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-data-reparse-point.c +117 -0
  168. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-data-security-descriptor.c +361 -0
  169. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-share-enum.c +181 -0
  170. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-signing.c +279 -0
  171. package/darwin_arm64/third-party/libsmb2/source/lib/smb2-signing.h +51 -0
  172. package/darwin_arm64/third-party/libsmb2/source/lib/smb3-seal.c +165 -0
  173. package/darwin_arm64/third-party/libsmb2/source/lib/smb3-seal.h +43 -0
  174. package/darwin_arm64/third-party/libsmb2/source/lib/socket.c +1502 -0
  175. package/darwin_arm64/third-party/libsmb2/source/lib/spnego-wrapper.c +634 -0
  176. package/darwin_arm64/third-party/libsmb2/source/lib/spnego-wrapper.h +74 -0
  177. package/darwin_arm64/third-party/libsmb2/source/lib/sync.c +988 -0
  178. package/darwin_arm64/third-party/libsmb2/source/lib/timestamps.c +70 -0
  179. package/darwin_arm64/third-party/libsmb2/source/lib/unicode.c +307 -0
  180. package/darwin_arm64/third-party/libsmb2/source/lib/usha.c +345 -0
  181. package/darwin_arm64/third-party/libsmb2/source/libsmb2.pc.in +14 -0
  182. package/darwin_arm64/third-party/libsmb2/source/packaging/RPM/libsmb2.spec.in +135 -0
  183. package/darwin_arm64/third-party/libsmb2/source/packaging/RPM/makerpms.sh +114 -0
  184. package/darwin_arm64/third-party/libsmb2/source/tests/Makefile.am +34 -0
  185. package/darwin_arm64/third-party/libsmb2/source/tests/README +28 -0
  186. package/darwin_arm64/third-party/libsmb2/source/tests/aes128ccm-test.c +119 -0
  187. package/darwin_arm64/third-party/libsmb2/source/tests/functions.sh +11 -0
  188. package/darwin_arm64/third-party/libsmb2/source/tests/ld_sockerr.c +58 -0
  189. package/darwin_arm64/third-party/libsmb2/source/tests/metastat-0202-censored.c +136 -0
  190. package/darwin_arm64/third-party/libsmb2/source/tests/ntlmssp_generate_blob.c +123 -0
  191. package/darwin_arm64/third-party/libsmb2/source/tests/prog_cat.c +188 -0
  192. package/darwin_arm64/third-party/libsmb2/source/tests/prog_cat_cancel.c +203 -0
  193. package/darwin_arm64/third-party/libsmb2/source/tests/prog_ls.c +189 -0
  194. package/darwin_arm64/third-party/libsmb2/source/tests/prog_mkdir.c +85 -0
  195. package/darwin_arm64/third-party/libsmb2/source/tests/prog_rmdir.c +84 -0
  196. package/darwin_arm64/third-party/libsmb2/source/tests/smb2-dcerpc-coder-test.c +635 -0
  197. package/darwin_arm64/third-party/libsmb2/source/tests/test_0100_ls_basic.sh +22 -0
  198. package/darwin_arm64/third-party/libsmb2/source/tests/test_0101_ls_basic_valgrind.sh +23 -0
  199. package/darwin_arm64/third-party/libsmb2/source/tests/test_0102_ls_basic_socket_error.sh +16 -0
  200. package/darwin_arm64/third-party/libsmb2/source/tests/test_0103_ls_basic_valgrind_malloc_error.sh +25 -0
  201. package/darwin_arm64/third-party/libsmb2/source/tests/test_0200_mkdir.sh +15 -0
  202. package/darwin_arm64/third-party/libsmb2/source/tests/test_0201_mkdir_valgrind.sh +15 -0
  203. package/darwin_arm64/third-party/libsmb2/source/tests/test_0210_cp_basic.sh +25 -0
  204. package/darwin_arm64/third-party/libsmb2/source/tests/test_0211_cp_valgrind.sh +26 -0
  205. package/darwin_arm64/third-party/libsmb2/source/tests/test_0212_cp_valgrind_socket_error.sh +29 -0
  206. package/darwin_arm64/third-party/libsmb2/source/tests/test_0300_cat_basic.sh +13 -0
  207. package/darwin_arm64/third-party/libsmb2/source/tests/test_0301_cat_valgrind.sh +13 -0
  208. package/darwin_arm64/third-party/libsmb2/source/tests/test_0302_cat_valgrind_socket_error.sh +18 -0
  209. package/darwin_arm64/third-party/libsmb2/source/tests/test_0310_cancel_pdu.sh +13 -0
  210. package/darwin_arm64/third-party/libsmb2/source/tests/test_0400_overdrawn_0202.sh +25 -0
  211. package/darwin_arm64/third-party/libsmb2/source/tests/test_900_dcerpc.sh +10 -0
  212. package/darwin_arm64/third-party/libsmb2/source/utils/Makefile.am +11 -0
  213. package/darwin_arm64/third-party/libsmb2/source/utils/smb2-cp.c +265 -0
  214. package/darwin_arm64/third-party/libsmb2/source/utils/smb2-ls.c +135 -0
  215. package/linux_x64/libsmb2.so +0 -0
  216. package/linux_x64/libsmb2.so.1 +0 -0
  217. package/linux_x64/libsmb2.so.6.1.0 +0 -0
  218. package/linux_x64/smb_server_cpp_linux_x64 +0 -0
  219. package/linux_x64/third-party/libsmb2/COPYING +24 -0
  220. package/linux_x64/third-party/libsmb2/LICENCE-LGPL-2.1.txt +502 -0
  221. package/linux_x64/third-party/libsmb2/NOTICE.txt +13 -0
  222. package/linux_x64/third-party/libsmb2/README +413 -0
  223. package/linux_x64/third-party/libsmb2/source/CMakeLists.txt +205 -0
  224. package/linux_x64/third-party/libsmb2/source/COPYING +24 -0
  225. package/linux_x64/third-party/libsmb2/source/LICENCE-LGPL-2.1.txt +502 -0
  226. package/linux_x64/third-party/libsmb2/source/Makefile.am +15 -0
  227. package/linux_x64/third-party/libsmb2/source/Makefile.platform +112 -0
  228. package/linux_x64/third-party/libsmb2/source/README +413 -0
  229. package/linux_x64/third-party/libsmb2/source/Xbox/libsmb2.sln +25 -0
  230. package/linux_x64/third-party/libsmb2/source/Xbox/libsmb2.vcxproj +248 -0
  231. package/linux_x64/third-party/libsmb2/source/Xbox/libsmb2.vcxproj.filters +304 -0
  232. package/linux_x64/third-party/libsmb2/source/Xbox 360/libsmb2.sln +32 -0
  233. package/linux_x64/third-party/libsmb2/source/Xbox 360/libsmb2.vcxproj +327 -0
  234. package/linux_x64/third-party/libsmb2/source/Xbox 360/libsmb2.vcxproj.filters +268 -0
  235. package/linux_x64/third-party/libsmb2/source/bootstrap +2 -0
  236. package/linux_x64/third-party/libsmb2/source/cmake/ConfigureChecks.cmake +63 -0
  237. package/linux_x64/third-party/libsmb2/source/cmake/FindSMB2.cmake +37 -0
  238. package/linux_x64/third-party/libsmb2/source/cmake/Modules/FindGSSAPI.cmake +30 -0
  239. package/linux_x64/third-party/libsmb2/source/cmake/Modules/FindLibKrb5.cmake +44 -0
  240. package/linux_x64/third-party/libsmb2/source/cmake/config.h.cmake +126 -0
  241. package/linux_x64/third-party/libsmb2/source/cmake/libsmb2.pc.cmake +14 -0
  242. package/linux_x64/third-party/libsmb2/source/component.mk +5 -0
  243. package/linux_x64/third-party/libsmb2/source/configure.ac +184 -0
  244. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareAdd.yaml +9 -0
  245. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareCheck.yaml +4 -0
  246. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareDel.yaml +5 -0
  247. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareDelSticky.yaml +5 -0
  248. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareEnum.yaml +7 -0
  249. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareGetInfo.yaml +6 -0
  250. package/linux_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareSetInfo.yaml +11 -0
  251. package/linux_x64/third-party/libsmb2/source/examples/CMakeLists.txt +28 -0
  252. package/linux_x64/third-party/libsmb2/source/examples/Makefile.am +54 -0
  253. package/linux_x64/third-party/libsmb2/source/examples/dcerpc.c +254 -0
  254. package/linux_x64/third-party/libsmb2/source/examples/picow/CMakeLists.txt +72 -0
  255. package/linux_x64/third-party/libsmb2/source/examples/picow/README.md +2 -0
  256. package/linux_x64/third-party/libsmb2/source/examples/picow/main.cpp +119 -0
  257. package/linux_x64/third-party/libsmb2/source/examples/picow/smb-ls-sync.c +0 -0
  258. package/linux_x64/third-party/libsmb2/source/examples/smb2-CMD-FIND.c +335 -0
  259. package/linux_x64/third-party/libsmb2/source/examples/smb2-cat-async.c +183 -0
  260. package/linux_x64/third-party/libsmb2/source/examples/smb2-cat-sync.c +105 -0
  261. package/linux_x64/third-party/libsmb2/source/examples/smb2-ftruncate-sync.c +87 -0
  262. package/linux_x64/third-party/libsmb2/source/examples/smb2-ls-async.c +185 -0
  263. package/linux_x64/third-party/libsmb2/source/examples/smb2-ls-epoll.c +234 -0
  264. package/linux_x64/third-party/libsmb2/source/examples/smb2-lsa-lookupsids.c +292 -0
  265. package/linux_x64/third-party/libsmb2/source/examples/smb2-lseek-sync.c +101 -0
  266. package/linux_x64/third-party/libsmb2/source/examples/smb2-notify.c +183 -0
  267. package/linux_x64/third-party/libsmb2/source/examples/smb2-put-async.c +175 -0
  268. package/linux_x64/third-party/libsmb2/source/examples/smb2-put-sync.c +100 -0
  269. package/linux_x64/third-party/libsmb2/source/examples/smb2-raw-fsstat-async.c +353 -0
  270. package/linux_x64/third-party/libsmb2/source/examples/smb2-raw-getsd-async.c +401 -0
  271. package/linux_x64/third-party/libsmb2/source/examples/smb2-raw-stat-async.c +448 -0
  272. package/linux_x64/third-party/libsmb2/source/examples/smb2-readlink.c +80 -0
  273. package/linux_x64/third-party/libsmb2/source/examples/smb2-rename-sync.c +80 -0
  274. package/linux_x64/third-party/libsmb2/source/examples/smb2-server-sync.c +497 -0
  275. package/linux_x64/third-party/libsmb2/source/examples/smb2-share-enum-sync.c +146 -0
  276. package/linux_x64/third-party/libsmb2/source/examples/smb2-share-enum.c +208 -0
  277. package/linux_x64/third-party/libsmb2/source/examples/smb2-share-info.c +255 -0
  278. package/linux_x64/third-party/libsmb2/source/examples/smb2-stat-sync.c +103 -0
  279. package/linux_x64/third-party/libsmb2/source/examples/smb2-statvfs-sync.c +85 -0
  280. package/linux_x64/third-party/libsmb2/source/examples/smb2-truncate-sync.c +78 -0
  281. package/linux_x64/third-party/libsmb2/source/idf_component.yml +5 -0
  282. package/linux_x64/third-party/libsmb2/source/include/Makefile.am +15 -0
  283. package/linux_x64/third-party/libsmb2/source/include/amiga_os/config.h +139 -0
  284. package/linux_x64/third-party/libsmb2/source/include/apple/config.h +139 -0
  285. package/linux_x64/third-party/libsmb2/source/include/asprintf.h +65 -0
  286. package/linux_x64/third-party/libsmb2/source/include/esp/config.h +139 -0
  287. package/linux_x64/third-party/libsmb2/source/include/libsmb2-private.h +670 -0
  288. package/linux_x64/third-party/libsmb2/source/include/module.modulemap +21 -0
  289. package/linux_x64/third-party/libsmb2/source/include/picow/FreeRTOSConfig.h +143 -0
  290. package/linux_x64/third-party/libsmb2/source/include/picow/README.md +2 -0
  291. package/linux_x64/third-party/libsmb2/source/include/picow/config.h +139 -0
  292. package/linux_x64/third-party/libsmb2/source/include/picow/lwipopts.h +27 -0
  293. package/linux_x64/third-party/libsmb2/source/include/picow/lwipopts_examples_common.h +90 -0
  294. package/linux_x64/third-party/libsmb2/source/include/portable-endian.h +377 -0
  295. package/linux_x64/third-party/libsmb2/source/include/ps3/config.h +139 -0
  296. package/linux_x64/third-party/libsmb2/source/include/slist.h +63 -0
  297. package/linux_x64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc-lsa.h +172 -0
  298. package/linux_x64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc-srvsvc.h +276 -0
  299. package/linux_x64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc.h +203 -0
  300. package/linux_x64/third-party/libsmb2/source/include/smb2/libsmb2-raw.h +497 -0
  301. package/linux_x64/third-party/libsmb2/source/include/smb2/libsmb2.h +1409 -0
  302. package/linux_x64/third-party/libsmb2/source/include/smb2/smb2-errors.h +549 -0
  303. package/linux_x64/third-party/libsmb2/source/include/smb2/smb2-ioctl.h +83 -0
  304. package/linux_x64/third-party/libsmb2/source/include/smb2/smb2.h +1251 -0
  305. package/linux_x64/third-party/libsmb2/source/include/xbox/config.h +139 -0
  306. package/linux_x64/third-party/libsmb2/source/include/xbox 360/config.h +139 -0
  307. package/linux_x64/third-party/libsmb2/source/lib/CMakeLists.txt +260 -0
  308. package/linux_x64/third-party/libsmb2/source/lib/Makefile.AMIGA +46 -0
  309. package/linux_x64/third-party/libsmb2/source/lib/Makefile.AMIGA_AROS +59 -0
  310. package/linux_x64/third-party/libsmb2/source/lib/Makefile.AMIGA_OS3 +59 -0
  311. package/linux_x64/third-party/libsmb2/source/lib/Makefile.PS3_PPU +100 -0
  312. package/linux_x64/third-party/libsmb2/source/lib/Makefile.am +85 -0
  313. package/linux_x64/third-party/libsmb2/source/lib/aes.c +33 -0
  314. package/linux_x64/third-party/libsmb2/source/lib/aes.h +29 -0
  315. package/linux_x64/third-party/libsmb2/source/lib/aes128ccm.c +185 -0
  316. package/linux_x64/third-party/libsmb2/source/lib/aes128ccm.h +28 -0
  317. package/linux_x64/third-party/libsmb2/source/lib/aes_apple.c +70 -0
  318. package/linux_x64/third-party/libsmb2/source/lib/aes_apple.h +34 -0
  319. package/linux_x64/third-party/libsmb2/source/lib/aes_reference.c +560 -0
  320. package/linux_x64/third-party/libsmb2/source/lib/aes_reference.h +49 -0
  321. package/linux_x64/third-party/libsmb2/source/lib/alloc.c +154 -0
  322. package/linux_x64/third-party/libsmb2/source/lib/asn1-ber.c +1078 -0
  323. package/linux_x64/third-party/libsmb2/source/lib/asn1-ber.h +161 -0
  324. package/linux_x64/third-party/libsmb2/source/lib/compat.c +599 -0
  325. package/linux_x64/third-party/libsmb2/source/lib/compat.h +829 -0
  326. package/linux_x64/third-party/libsmb2/source/lib/dcerpc-lsa.c +641 -0
  327. package/linux_x64/third-party/libsmb2/source/lib/dcerpc-srvsvc.c +885 -0
  328. package/linux_x64/third-party/libsmb2/source/lib/dcerpc.c +2513 -0
  329. package/linux_x64/third-party/libsmb2/source/lib/dreamcast/vfs.c +328 -0
  330. package/linux_x64/third-party/libsmb2/source/lib/dreamcast/vfs.h +15 -0
  331. package/linux_x64/third-party/libsmb2/source/lib/errors.c +1192 -0
  332. package/linux_x64/third-party/libsmb2/source/lib/hmac-md5.c +84 -0
  333. package/linux_x64/third-party/libsmb2/source/lib/hmac-md5.h +42 -0
  334. package/linux_x64/third-party/libsmb2/source/lib/hmac.c +245 -0
  335. package/linux_x64/third-party/libsmb2/source/lib/init.c +778 -0
  336. package/linux_x64/third-party/libsmb2/source/lib/krb5-wrapper.c +1072 -0
  337. package/linux_x64/third-party/libsmb2/source/lib/krb5-wrapper.h +134 -0
  338. package/linux_x64/third-party/libsmb2/source/lib/libsmb2.c +4292 -0
  339. package/linux_x64/third-party/libsmb2/source/lib/libsmb2.syms +168 -0
  340. package/linux_x64/third-party/libsmb2/source/lib/md4.h +43 -0
  341. package/linux_x64/third-party/libsmb2/source/lib/md4c.c +289 -0
  342. package/linux_x64/third-party/libsmb2/source/lib/md5.c +249 -0
  343. package/linux_x64/third-party/libsmb2/source/lib/md5.h +76 -0
  344. package/linux_x64/third-party/libsmb2/source/lib/ntlmssp.c +1380 -0
  345. package/linux_x64/third-party/libsmb2/source/lib/ntlmssp.h +84 -0
  346. package/linux_x64/third-party/libsmb2/source/lib/pdu.c +1159 -0
  347. package/linux_x64/third-party/libsmb2/source/lib/ps2/TODO +6 -0
  348. package/linux_x64/third-party/libsmb2/source/lib/ps2/imports.lst +84 -0
  349. package/linux_x64/third-party/libsmb2/source/lib/ps2/irx_imports.h +28 -0
  350. package/linux_x64/third-party/libsmb2/source/lib/ps2/ps2smb2.h +35 -0
  351. package/linux_x64/third-party/libsmb2/source/lib/ps2/smb2_fio.c +816 -0
  352. package/linux_x64/third-party/libsmb2/source/lib/ps2/smb2_fio.h +15 -0
  353. package/linux_x64/third-party/libsmb2/source/lib/ps2/smb2man.c +69 -0
  354. package/linux_x64/third-party/libsmb2/source/lib/sha-private.h +28 -0
  355. package/linux_x64/third-party/libsmb2/source/lib/sha.h +334 -0
  356. package/linux_x64/third-party/libsmb2/source/lib/sha1.c +450 -0
  357. package/linux_x64/third-party/libsmb2/source/lib/sha224-256.c +611 -0
  358. package/linux_x64/third-party/libsmb2/source/lib/sha384-512.c +1059 -0
  359. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-close.c +240 -0
  360. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-create.c +508 -0
  361. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-echo.c +202 -0
  362. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-error.c +157 -0
  363. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-flush.c +207 -0
  364. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-ioctl.c +445 -0
  365. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-lock.c +312 -0
  366. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-logoff.c +190 -0
  367. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-negotiate.c +646 -0
  368. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-notify-change.c +278 -0
  369. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-oplock-break.c +543 -0
  370. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-query-directory.c +580 -0
  371. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-query-info.c +753 -0
  372. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-read.c +391 -0
  373. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-session-setup.c +331 -0
  374. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-set-info.c +361 -0
  375. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-tree-connect.c +278 -0
  376. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-tree-disconnect.c +171 -0
  377. package/linux_x64/third-party/libsmb2/source/lib/smb2-cmd-write.c +319 -0
  378. package/linux_x64/third-party/libsmb2/source/lib/smb2-data-file-info.c +537 -0
  379. package/linux_x64/third-party/libsmb2/source/lib/smb2-data-filesystem-info.c +384 -0
  380. package/linux_x64/third-party/libsmb2/source/lib/smb2-data-reparse-point.c +117 -0
  381. package/linux_x64/third-party/libsmb2/source/lib/smb2-data-security-descriptor.c +361 -0
  382. package/linux_x64/third-party/libsmb2/source/lib/smb2-share-enum.c +181 -0
  383. package/linux_x64/third-party/libsmb2/source/lib/smb2-signing.c +279 -0
  384. package/linux_x64/third-party/libsmb2/source/lib/smb2-signing.h +51 -0
  385. package/linux_x64/third-party/libsmb2/source/lib/smb3-seal.c +165 -0
  386. package/linux_x64/third-party/libsmb2/source/lib/smb3-seal.h +43 -0
  387. package/linux_x64/third-party/libsmb2/source/lib/socket.c +1502 -0
  388. package/linux_x64/third-party/libsmb2/source/lib/spnego-wrapper.c +634 -0
  389. package/linux_x64/third-party/libsmb2/source/lib/spnego-wrapper.h +74 -0
  390. package/linux_x64/third-party/libsmb2/source/lib/sync.c +988 -0
  391. package/linux_x64/third-party/libsmb2/source/lib/timestamps.c +70 -0
  392. package/linux_x64/third-party/libsmb2/source/lib/unicode.c +307 -0
  393. package/linux_x64/third-party/libsmb2/source/lib/usha.c +345 -0
  394. package/linux_x64/third-party/libsmb2/source/libsmb2.pc.in +14 -0
  395. package/linux_x64/third-party/libsmb2/source/packaging/RPM/libsmb2.spec.in +135 -0
  396. package/linux_x64/third-party/libsmb2/source/packaging/RPM/makerpms.sh +114 -0
  397. package/linux_x64/third-party/libsmb2/source/tests/Makefile.am +34 -0
  398. package/linux_x64/third-party/libsmb2/source/tests/README +28 -0
  399. package/linux_x64/third-party/libsmb2/source/tests/aes128ccm-test.c +119 -0
  400. package/linux_x64/third-party/libsmb2/source/tests/functions.sh +11 -0
  401. package/linux_x64/third-party/libsmb2/source/tests/ld_sockerr.c +58 -0
  402. package/linux_x64/third-party/libsmb2/source/tests/metastat-0202-censored.c +136 -0
  403. package/linux_x64/third-party/libsmb2/source/tests/ntlmssp_generate_blob.c +123 -0
  404. package/linux_x64/third-party/libsmb2/source/tests/prog_cat.c +188 -0
  405. package/linux_x64/third-party/libsmb2/source/tests/prog_cat_cancel.c +203 -0
  406. package/linux_x64/third-party/libsmb2/source/tests/prog_ls.c +189 -0
  407. package/linux_x64/third-party/libsmb2/source/tests/prog_mkdir.c +85 -0
  408. package/linux_x64/third-party/libsmb2/source/tests/prog_rmdir.c +84 -0
  409. package/linux_x64/third-party/libsmb2/source/tests/smb2-dcerpc-coder-test.c +635 -0
  410. package/linux_x64/third-party/libsmb2/source/tests/test_0100_ls_basic.sh +22 -0
  411. package/linux_x64/third-party/libsmb2/source/tests/test_0101_ls_basic_valgrind.sh +23 -0
  412. package/linux_x64/third-party/libsmb2/source/tests/test_0102_ls_basic_socket_error.sh +16 -0
  413. package/linux_x64/third-party/libsmb2/source/tests/test_0103_ls_basic_valgrind_malloc_error.sh +25 -0
  414. package/linux_x64/third-party/libsmb2/source/tests/test_0200_mkdir.sh +15 -0
  415. package/linux_x64/third-party/libsmb2/source/tests/test_0201_mkdir_valgrind.sh +15 -0
  416. package/linux_x64/third-party/libsmb2/source/tests/test_0210_cp_basic.sh +25 -0
  417. package/linux_x64/third-party/libsmb2/source/tests/test_0211_cp_valgrind.sh +26 -0
  418. package/linux_x64/third-party/libsmb2/source/tests/test_0212_cp_valgrind_socket_error.sh +29 -0
  419. package/linux_x64/third-party/libsmb2/source/tests/test_0300_cat_basic.sh +13 -0
  420. package/linux_x64/third-party/libsmb2/source/tests/test_0301_cat_valgrind.sh +13 -0
  421. package/linux_x64/third-party/libsmb2/source/tests/test_0302_cat_valgrind_socket_error.sh +18 -0
  422. package/linux_x64/third-party/libsmb2/source/tests/test_0310_cancel_pdu.sh +13 -0
  423. package/linux_x64/third-party/libsmb2/source/tests/test_0400_overdrawn_0202.sh +25 -0
  424. package/linux_x64/third-party/libsmb2/source/tests/test_900_dcerpc.sh +10 -0
  425. package/linux_x64/third-party/libsmb2/source/utils/Makefile.am +11 -0
  426. package/linux_x64/third-party/libsmb2/source/utils/smb2-cp.c +265 -0
  427. package/linux_x64/third-party/libsmb2/source/utils/smb2-ls.c +135 -0
  428. package/package.json +10 -4
  429. package/smb2.proto +164 -0
  430. package/win32_x64/smb2.dll +0 -0
  431. package/win32_x64/smb_server_cpp_win32_x64.exe +0 -0
  432. package/win32_x64/third-party/libsmb2/COPYING +24 -0
  433. package/win32_x64/third-party/libsmb2/LICENCE-LGPL-2.1.txt +502 -0
  434. package/win32_x64/third-party/libsmb2/NOTICE.txt +13 -0
  435. package/win32_x64/third-party/libsmb2/README +413 -0
  436. package/win32_x64/third-party/libsmb2/source/CMakeLists.txt +205 -0
  437. package/win32_x64/third-party/libsmb2/source/COPYING +24 -0
  438. package/win32_x64/third-party/libsmb2/source/LICENCE-LGPL-2.1.txt +502 -0
  439. package/win32_x64/third-party/libsmb2/source/Makefile.am +15 -0
  440. package/win32_x64/third-party/libsmb2/source/Makefile.platform +112 -0
  441. package/win32_x64/third-party/libsmb2/source/README +413 -0
  442. package/win32_x64/third-party/libsmb2/source/Xbox/libsmb2.sln +25 -0
  443. package/win32_x64/third-party/libsmb2/source/Xbox/libsmb2.vcxproj +248 -0
  444. package/win32_x64/third-party/libsmb2/source/Xbox/libsmb2.vcxproj.filters +304 -0
  445. package/win32_x64/third-party/libsmb2/source/Xbox 360/libsmb2.sln +32 -0
  446. package/win32_x64/third-party/libsmb2/source/Xbox 360/libsmb2.vcxproj +327 -0
  447. package/win32_x64/third-party/libsmb2/source/Xbox 360/libsmb2.vcxproj.filters +268 -0
  448. package/win32_x64/third-party/libsmb2/source/bootstrap +2 -0
  449. package/win32_x64/third-party/libsmb2/source/cmake/ConfigureChecks.cmake +63 -0
  450. package/win32_x64/third-party/libsmb2/source/cmake/FindSMB2.cmake +37 -0
  451. package/win32_x64/third-party/libsmb2/source/cmake/Modules/FindGSSAPI.cmake +30 -0
  452. package/win32_x64/third-party/libsmb2/source/cmake/Modules/FindLibKrb5.cmake +44 -0
  453. package/win32_x64/third-party/libsmb2/source/cmake/config.h.cmake +126 -0
  454. package/win32_x64/third-party/libsmb2/source/cmake/libsmb2.pc.cmake +14 -0
  455. package/win32_x64/third-party/libsmb2/source/component.mk +5 -0
  456. package/win32_x64/third-party/libsmb2/source/configure.ac +184 -0
  457. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareAdd.yaml +9 -0
  458. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareCheck.yaml +4 -0
  459. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareDel.yaml +5 -0
  460. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareDelSticky.yaml +5 -0
  461. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareEnum.yaml +7 -0
  462. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareGetInfo.yaml +6 -0
  463. package/win32_x64/third-party/libsmb2/source/dcerpc-examples/srvsvc-NetrShareSetInfo.yaml +11 -0
  464. package/win32_x64/third-party/libsmb2/source/examples/CMakeLists.txt +28 -0
  465. package/win32_x64/third-party/libsmb2/source/examples/Makefile.am +54 -0
  466. package/win32_x64/third-party/libsmb2/source/examples/dcerpc.c +254 -0
  467. package/win32_x64/third-party/libsmb2/source/examples/picow/CMakeLists.txt +72 -0
  468. package/win32_x64/third-party/libsmb2/source/examples/picow/README.md +2 -0
  469. package/win32_x64/third-party/libsmb2/source/examples/picow/main.cpp +119 -0
  470. package/win32_x64/third-party/libsmb2/source/examples/picow/smb-ls-sync.c +0 -0
  471. package/win32_x64/third-party/libsmb2/source/examples/smb2-CMD-FIND.c +335 -0
  472. package/win32_x64/third-party/libsmb2/source/examples/smb2-cat-async.c +183 -0
  473. package/win32_x64/third-party/libsmb2/source/examples/smb2-cat-sync.c +105 -0
  474. package/win32_x64/third-party/libsmb2/source/examples/smb2-ftruncate-sync.c +87 -0
  475. package/win32_x64/third-party/libsmb2/source/examples/smb2-ls-async.c +185 -0
  476. package/win32_x64/third-party/libsmb2/source/examples/smb2-ls-epoll.c +234 -0
  477. package/win32_x64/third-party/libsmb2/source/examples/smb2-lsa-lookupsids.c +292 -0
  478. package/win32_x64/third-party/libsmb2/source/examples/smb2-lseek-sync.c +101 -0
  479. package/win32_x64/third-party/libsmb2/source/examples/smb2-notify.c +183 -0
  480. package/win32_x64/third-party/libsmb2/source/examples/smb2-put-async.c +175 -0
  481. package/win32_x64/third-party/libsmb2/source/examples/smb2-put-sync.c +100 -0
  482. package/win32_x64/third-party/libsmb2/source/examples/smb2-raw-fsstat-async.c +353 -0
  483. package/win32_x64/third-party/libsmb2/source/examples/smb2-raw-getsd-async.c +401 -0
  484. package/win32_x64/third-party/libsmb2/source/examples/smb2-raw-stat-async.c +448 -0
  485. package/win32_x64/third-party/libsmb2/source/examples/smb2-readlink.c +80 -0
  486. package/win32_x64/third-party/libsmb2/source/examples/smb2-rename-sync.c +80 -0
  487. package/win32_x64/third-party/libsmb2/source/examples/smb2-server-sync.c +497 -0
  488. package/win32_x64/third-party/libsmb2/source/examples/smb2-share-enum-sync.c +146 -0
  489. package/win32_x64/third-party/libsmb2/source/examples/smb2-share-enum.c +208 -0
  490. package/win32_x64/third-party/libsmb2/source/examples/smb2-share-info.c +255 -0
  491. package/win32_x64/third-party/libsmb2/source/examples/smb2-stat-sync.c +103 -0
  492. package/win32_x64/third-party/libsmb2/source/examples/smb2-statvfs-sync.c +85 -0
  493. package/win32_x64/third-party/libsmb2/source/examples/smb2-truncate-sync.c +78 -0
  494. package/win32_x64/third-party/libsmb2/source/idf_component.yml +5 -0
  495. package/win32_x64/third-party/libsmb2/source/include/Makefile.am +15 -0
  496. package/win32_x64/third-party/libsmb2/source/include/amiga_os/config.h +139 -0
  497. package/win32_x64/third-party/libsmb2/source/include/apple/config.h +139 -0
  498. package/win32_x64/third-party/libsmb2/source/include/asprintf.h +65 -0
  499. package/win32_x64/third-party/libsmb2/source/include/esp/config.h +139 -0
  500. package/win32_x64/third-party/libsmb2/source/include/libsmb2-private.h +670 -0
  501. package/win32_x64/third-party/libsmb2/source/include/module.modulemap +21 -0
  502. package/win32_x64/third-party/libsmb2/source/include/picow/FreeRTOSConfig.h +143 -0
  503. package/win32_x64/third-party/libsmb2/source/include/picow/README.md +2 -0
  504. package/win32_x64/third-party/libsmb2/source/include/picow/config.h +139 -0
  505. package/win32_x64/third-party/libsmb2/source/include/picow/lwipopts.h +27 -0
  506. package/win32_x64/third-party/libsmb2/source/include/picow/lwipopts_examples_common.h +90 -0
  507. package/win32_x64/third-party/libsmb2/source/include/portable-endian.h +377 -0
  508. package/win32_x64/third-party/libsmb2/source/include/ps3/config.h +139 -0
  509. package/win32_x64/third-party/libsmb2/source/include/slist.h +63 -0
  510. package/win32_x64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc-lsa.h +172 -0
  511. package/win32_x64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc-srvsvc.h +276 -0
  512. package/win32_x64/third-party/libsmb2/source/include/smb2/libsmb2-dcerpc.h +203 -0
  513. package/win32_x64/third-party/libsmb2/source/include/smb2/libsmb2-raw.h +497 -0
  514. package/win32_x64/third-party/libsmb2/source/include/smb2/libsmb2.h +1409 -0
  515. package/win32_x64/third-party/libsmb2/source/include/smb2/smb2-errors.h +549 -0
  516. package/win32_x64/third-party/libsmb2/source/include/smb2/smb2-ioctl.h +83 -0
  517. package/win32_x64/third-party/libsmb2/source/include/smb2/smb2.h +1251 -0
  518. package/win32_x64/third-party/libsmb2/source/include/xbox/config.h +139 -0
  519. package/win32_x64/third-party/libsmb2/source/include/xbox 360/config.h +139 -0
  520. package/win32_x64/third-party/libsmb2/source/lib/CMakeLists.txt +260 -0
  521. package/win32_x64/third-party/libsmb2/source/lib/Makefile.AMIGA +46 -0
  522. package/win32_x64/third-party/libsmb2/source/lib/Makefile.AMIGA_AROS +59 -0
  523. package/win32_x64/third-party/libsmb2/source/lib/Makefile.AMIGA_OS3 +59 -0
  524. package/win32_x64/third-party/libsmb2/source/lib/Makefile.PS3_PPU +100 -0
  525. package/win32_x64/third-party/libsmb2/source/lib/Makefile.am +85 -0
  526. package/win32_x64/third-party/libsmb2/source/lib/aes.c +33 -0
  527. package/win32_x64/third-party/libsmb2/source/lib/aes.h +29 -0
  528. package/win32_x64/third-party/libsmb2/source/lib/aes128ccm.c +185 -0
  529. package/win32_x64/third-party/libsmb2/source/lib/aes128ccm.h +28 -0
  530. package/win32_x64/third-party/libsmb2/source/lib/aes_apple.c +70 -0
  531. package/win32_x64/third-party/libsmb2/source/lib/aes_apple.h +34 -0
  532. package/win32_x64/third-party/libsmb2/source/lib/aes_reference.c +560 -0
  533. package/win32_x64/third-party/libsmb2/source/lib/aes_reference.h +49 -0
  534. package/win32_x64/third-party/libsmb2/source/lib/alloc.c +154 -0
  535. package/win32_x64/third-party/libsmb2/source/lib/asn1-ber.c +1078 -0
  536. package/win32_x64/third-party/libsmb2/source/lib/asn1-ber.h +161 -0
  537. package/win32_x64/third-party/libsmb2/source/lib/compat.c +599 -0
  538. package/win32_x64/third-party/libsmb2/source/lib/compat.h +829 -0
  539. package/win32_x64/third-party/libsmb2/source/lib/dcerpc-lsa.c +641 -0
  540. package/win32_x64/third-party/libsmb2/source/lib/dcerpc-srvsvc.c +885 -0
  541. package/win32_x64/third-party/libsmb2/source/lib/dcerpc.c +2513 -0
  542. package/win32_x64/third-party/libsmb2/source/lib/dreamcast/vfs.c +328 -0
  543. package/win32_x64/third-party/libsmb2/source/lib/dreamcast/vfs.h +15 -0
  544. package/win32_x64/third-party/libsmb2/source/lib/errors.c +1192 -0
  545. package/win32_x64/third-party/libsmb2/source/lib/hmac-md5.c +84 -0
  546. package/win32_x64/third-party/libsmb2/source/lib/hmac-md5.h +42 -0
  547. package/win32_x64/third-party/libsmb2/source/lib/hmac.c +245 -0
  548. package/win32_x64/third-party/libsmb2/source/lib/init.c +778 -0
  549. package/win32_x64/third-party/libsmb2/source/lib/krb5-wrapper.c +1072 -0
  550. package/win32_x64/third-party/libsmb2/source/lib/krb5-wrapper.h +134 -0
  551. package/win32_x64/third-party/libsmb2/source/lib/libsmb2.c +4292 -0
  552. package/win32_x64/third-party/libsmb2/source/lib/libsmb2.syms +168 -0
  553. package/win32_x64/third-party/libsmb2/source/lib/md4.h +43 -0
  554. package/win32_x64/third-party/libsmb2/source/lib/md4c.c +289 -0
  555. package/win32_x64/third-party/libsmb2/source/lib/md5.c +249 -0
  556. package/win32_x64/third-party/libsmb2/source/lib/md5.h +76 -0
  557. package/win32_x64/third-party/libsmb2/source/lib/ntlmssp.c +1380 -0
  558. package/win32_x64/third-party/libsmb2/source/lib/ntlmssp.h +84 -0
  559. package/win32_x64/third-party/libsmb2/source/lib/pdu.c +1159 -0
  560. package/win32_x64/third-party/libsmb2/source/lib/ps2/TODO +6 -0
  561. package/win32_x64/third-party/libsmb2/source/lib/ps2/imports.lst +84 -0
  562. package/win32_x64/third-party/libsmb2/source/lib/ps2/irx_imports.h +28 -0
  563. package/win32_x64/third-party/libsmb2/source/lib/ps2/ps2smb2.h +35 -0
  564. package/win32_x64/third-party/libsmb2/source/lib/ps2/smb2_fio.c +816 -0
  565. package/win32_x64/third-party/libsmb2/source/lib/ps2/smb2_fio.h +15 -0
  566. package/win32_x64/third-party/libsmb2/source/lib/ps2/smb2man.c +69 -0
  567. package/win32_x64/third-party/libsmb2/source/lib/sha-private.h +28 -0
  568. package/win32_x64/third-party/libsmb2/source/lib/sha.h +334 -0
  569. package/win32_x64/third-party/libsmb2/source/lib/sha1.c +450 -0
  570. package/win32_x64/third-party/libsmb2/source/lib/sha224-256.c +611 -0
  571. package/win32_x64/third-party/libsmb2/source/lib/sha384-512.c +1059 -0
  572. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-close.c +240 -0
  573. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-create.c +508 -0
  574. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-echo.c +202 -0
  575. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-error.c +157 -0
  576. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-flush.c +207 -0
  577. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-ioctl.c +445 -0
  578. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-lock.c +312 -0
  579. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-logoff.c +190 -0
  580. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-negotiate.c +646 -0
  581. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-notify-change.c +278 -0
  582. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-oplock-break.c +543 -0
  583. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-query-directory.c +580 -0
  584. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-query-info.c +753 -0
  585. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-read.c +391 -0
  586. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-session-setup.c +331 -0
  587. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-set-info.c +361 -0
  588. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-tree-connect.c +278 -0
  589. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-tree-disconnect.c +171 -0
  590. package/win32_x64/third-party/libsmb2/source/lib/smb2-cmd-write.c +319 -0
  591. package/win32_x64/third-party/libsmb2/source/lib/smb2-data-file-info.c +537 -0
  592. package/win32_x64/third-party/libsmb2/source/lib/smb2-data-filesystem-info.c +384 -0
  593. package/win32_x64/third-party/libsmb2/source/lib/smb2-data-reparse-point.c +117 -0
  594. package/win32_x64/third-party/libsmb2/source/lib/smb2-data-security-descriptor.c +361 -0
  595. package/win32_x64/third-party/libsmb2/source/lib/smb2-share-enum.c +181 -0
  596. package/win32_x64/third-party/libsmb2/source/lib/smb2-signing.c +279 -0
  597. package/win32_x64/third-party/libsmb2/source/lib/smb2-signing.h +51 -0
  598. package/win32_x64/third-party/libsmb2/source/lib/smb3-seal.c +165 -0
  599. package/win32_x64/third-party/libsmb2/source/lib/smb3-seal.h +43 -0
  600. package/win32_x64/third-party/libsmb2/source/lib/socket.c +1502 -0
  601. package/win32_x64/third-party/libsmb2/source/lib/spnego-wrapper.c +634 -0
  602. package/win32_x64/third-party/libsmb2/source/lib/spnego-wrapper.h +74 -0
  603. package/win32_x64/third-party/libsmb2/source/lib/sync.c +988 -0
  604. package/win32_x64/third-party/libsmb2/source/lib/timestamps.c +70 -0
  605. package/win32_x64/third-party/libsmb2/source/lib/unicode.c +307 -0
  606. package/win32_x64/third-party/libsmb2/source/lib/usha.c +345 -0
  607. package/win32_x64/third-party/libsmb2/source/libsmb2.pc.in +14 -0
  608. package/win32_x64/third-party/libsmb2/source/packaging/RPM/libsmb2.spec.in +135 -0
  609. package/win32_x64/third-party/libsmb2/source/packaging/RPM/makerpms.sh +114 -0
  610. package/win32_x64/third-party/libsmb2/source/tests/Makefile.am +34 -0
  611. package/win32_x64/third-party/libsmb2/source/tests/README +28 -0
  612. package/win32_x64/third-party/libsmb2/source/tests/aes128ccm-test.c +119 -0
  613. package/win32_x64/third-party/libsmb2/source/tests/functions.sh +11 -0
  614. package/win32_x64/third-party/libsmb2/source/tests/ld_sockerr.c +58 -0
  615. package/win32_x64/third-party/libsmb2/source/tests/metastat-0202-censored.c +136 -0
  616. package/win32_x64/third-party/libsmb2/source/tests/ntlmssp_generate_blob.c +123 -0
  617. package/win32_x64/third-party/libsmb2/source/tests/prog_cat.c +188 -0
  618. package/win32_x64/third-party/libsmb2/source/tests/prog_cat_cancel.c +203 -0
  619. package/win32_x64/third-party/libsmb2/source/tests/prog_ls.c +189 -0
  620. package/win32_x64/third-party/libsmb2/source/tests/prog_mkdir.c +85 -0
  621. package/win32_x64/third-party/libsmb2/source/tests/prog_rmdir.c +84 -0
  622. package/win32_x64/third-party/libsmb2/source/tests/smb2-dcerpc-coder-test.c +635 -0
  623. package/win32_x64/third-party/libsmb2/source/tests/test_0100_ls_basic.sh +22 -0
  624. package/win32_x64/third-party/libsmb2/source/tests/test_0101_ls_basic_valgrind.sh +23 -0
  625. package/win32_x64/third-party/libsmb2/source/tests/test_0102_ls_basic_socket_error.sh +16 -0
  626. package/win32_x64/third-party/libsmb2/source/tests/test_0103_ls_basic_valgrind_malloc_error.sh +25 -0
  627. package/win32_x64/third-party/libsmb2/source/tests/test_0200_mkdir.sh +15 -0
  628. package/win32_x64/third-party/libsmb2/source/tests/test_0201_mkdir_valgrind.sh +15 -0
  629. package/win32_x64/third-party/libsmb2/source/tests/test_0210_cp_basic.sh +25 -0
  630. package/win32_x64/third-party/libsmb2/source/tests/test_0211_cp_valgrind.sh +26 -0
  631. package/win32_x64/third-party/libsmb2/source/tests/test_0212_cp_valgrind_socket_error.sh +29 -0
  632. package/win32_x64/third-party/libsmb2/source/tests/test_0300_cat_basic.sh +13 -0
  633. package/win32_x64/third-party/libsmb2/source/tests/test_0301_cat_valgrind.sh +13 -0
  634. package/win32_x64/third-party/libsmb2/source/tests/test_0302_cat_valgrind_socket_error.sh +18 -0
  635. package/win32_x64/third-party/libsmb2/source/tests/test_0310_cancel_pdu.sh +13 -0
  636. package/win32_x64/third-party/libsmb2/source/tests/test_0400_overdrawn_0202.sh +25 -0
  637. package/win32_x64/third-party/libsmb2/source/tests/test_900_dcerpc.sh +10 -0
  638. package/win32_x64/third-party/libsmb2/source/utils/Makefile.am +11 -0
  639. package/win32_x64/third-party/libsmb2/source/utils/smb2-cp.c +265 -0
  640. package/win32_x64/third-party/libsmb2/source/utils/smb2-ls.c +135 -0
@@ -0,0 +1,2513 @@
1
+ /* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
2
+ /*
3
+ Copyright (C) 2018 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation; either version 2.1 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program 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 the
13
+ 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 program; if not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ #ifdef HAVE_CONFIG_H
19
+ #include "config.h"
20
+ #endif
21
+
22
+ #ifndef _GNU_SOURCE
23
+ #define _GNU_SOURCE
24
+ #endif
25
+
26
+ #ifdef HAVE_STDINT_H
27
+ #include <stdint.h>
28
+ #endif
29
+
30
+ #ifdef HAVE_STDLIB_H
31
+ #include <stdlib.h>
32
+ #endif
33
+
34
+ #ifdef HAVE_STRING_H
35
+ #include <string.h>
36
+ #endif
37
+
38
+ #ifdef STDC_HEADERS
39
+ #include <stddef.h>
40
+ #endif
41
+
42
+ #ifdef HAVE_SYS_TYPES_H
43
+ #include <sys/types.h>
44
+ #endif
45
+
46
+ #ifdef HAVE_SYS_STAT_H
47
+ #include <sys/stat.h>
48
+ #endif
49
+
50
+ #ifdef HAVE_UNISTD_H
51
+ #include <unistd.h>
52
+ #endif
53
+
54
+ #ifdef HAVE_SYS_UNISTD_H
55
+ #include <sys/unistd.h>
56
+ #endif
57
+
58
+ #include "portable-endian.h"
59
+ #include <errno.h>
60
+
61
+ #include "compat.h"
62
+
63
+ #include <stdio.h>
64
+ #include "smb2.h"
65
+ #include "libsmb2.h"
66
+ #include "libsmb2-dcerpc.h"
67
+ #include "libsmb2-raw.h"
68
+ #include "libsmb2-private.h"
69
+
70
+ struct dcerpc_service dcerpc_services[] = {
71
+ {"srvsvc", &srvsvc_interface, srvsvc_procs},
72
+ {NULL, NULL}
73
+ };
74
+
75
+ #define container_of(ptr, type, member) ({ \
76
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
77
+ (type *)(void *)( (char *)__mptr - offsetof(type,member) );})
78
+
79
+ struct dcerpc_deferred_pointer {
80
+ dcerpc_coder coder;
81
+ void *ptr;
82
+ };
83
+
84
+ #define MAX_DEFERRED_PTR 1024
85
+
86
+ #define NDR32_UUID 0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60}
87
+ #define NDR64_UUID 0x71710533, 0xbeba, 0x4937, {0x83, 0x19, 0xb5, 0xdb, 0xef, 0x9c, 0xcc, 0x36}
88
+ /*
89
+ * NDR64 is only supported for LITTLE_ENDIAN encodings:
90
+ * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/b1af93c7-f988-4a1a-ac74-063179942f32
91
+ */
92
+
93
+ p_syntax_id_t ndr32_syntax = {
94
+ {NDR32_UUID}, 2, 0
95
+ };
96
+
97
+ p_syntax_id_t ndr64_syntax = {
98
+ {NDR64_UUID}, 1, 0
99
+ };
100
+
101
+ struct dcerpc_context {
102
+ struct smb2_context *smb2;
103
+ const char *path;
104
+ p_syntax_id_t *syntax;
105
+ smb2_file_id file_id;
106
+
107
+ uint8_t tctx_id; /* 0:NDR32 1:NDR64 */
108
+ uint8_t packed_drep[4];
109
+ uint32_t call_id;
110
+ };
111
+
112
+ struct dcerpc_header {
113
+ uint8_t rpc_vers;
114
+ uint8_t rpc_vers_minor;
115
+ uint8_t PTYPE;
116
+ uint8_t pfc_flags;
117
+ uint8_t packed_drep[4];
118
+ uint16_t frag_length;
119
+ uint16_t auth_length;
120
+ uint32_t call_id;
121
+ };
122
+
123
+ struct p_cont_elem_t {
124
+ uint16_t p_cont_id;
125
+ uint8_t n_transfer_syn; /* number of items */
126
+ uint8_t reserved; /* alignment pad, m.b.z. */
127
+ p_syntax_id_t *abstract_syntax; /* transfer syntax list */
128
+ p_syntax_id_t **transfer_syntaxes;
129
+ };
130
+
131
+ struct dcerpc_bind_pdu {
132
+ uint16_t max_xmit_frag;
133
+ uint16_t max_recv_frag;
134
+ uint32_t assoc_group_id;
135
+
136
+ /* presentation context list */
137
+ uint8_t n_context_elem; /* number of items */
138
+ //u_int8 reserved; /* alignment pad, m.b.z. */
139
+ //u_short reserved2; /* alignment pad, m.b.z. */
140
+ struct p_cont_elem_t *p_cont_elem;
141
+ //p_cont_elem_t [size_is(n_cont_elem)] p_cont_elem[];
142
+ //p_syntax_id_t *abstract_syntax;
143
+ };
144
+
145
+ #define ACK_RESULT_ACCEPTANCE 0
146
+ #define ACK_RESULT_USER_REJECTION 1
147
+ #define ACK_RESULT_PROVIDER_REJECTION 2
148
+
149
+ #define ACK_REASON_REASON_NOT_SPECIFIED 0
150
+ #define ACK_REASON_ABSTRACT_SYNTAX_NOT_SUPPORTED 1
151
+ #define ACK_REASON_PROPOSED_TRANSFER_SYNTAXES_NOT_SUPPORTED 2
152
+ #define ACK_REASON_PROTOCOL_VERSION_NOT_SUPPORTED 4
153
+
154
+ struct dcerpc_bind_context_results {
155
+ uint16_t ack_result;
156
+ uint16_t ack_reason;
157
+ dcerpc_uuid_t uuid;
158
+ uint32_t syntax_version;
159
+ };
160
+
161
+ #define MAX_ACK_RESULTS 4
162
+ struct dcerpc_bind_ack_pdu {
163
+ uint16_t max_xmit_frag;
164
+ uint16_t max_recv_frag;
165
+ uint32_t assoc_group_id;
166
+
167
+ /* presentation context list */
168
+ uint8_t num_results;
169
+ struct dcerpc_bind_context_results results[MAX_ACK_RESULTS];
170
+ };
171
+
172
+ struct dcerpc_request_pdu {
173
+ uint32_t alloc_hint;
174
+ uint16_t context_id;
175
+ uint16_t opnum;
176
+
177
+ /* optional field for request, only present if the PFC_OBJECT_UUID
178
+ * field is non-zero */
179
+ /* dcerpc_uuid_t object; 24:16 object UID */
180
+
181
+ /* stub data, 8-octet aligned
182
+ .
183
+ .
184
+ . */
185
+ };
186
+
187
+ struct dcerpc_response_pdu {
188
+ uint32_t alloc_hint;
189
+ uint16_t context_id;
190
+ uint8_t cancel_count;
191
+ uint8_t reserved;
192
+ /* stub data, 8-octet aligned
193
+ .
194
+ .
195
+ . */
196
+ };
197
+
198
+ /* PDU Types */
199
+ #define PDU_TYPE_REQUEST 0
200
+ #define PDU_TYPE_PING 1
201
+ #define PDU_TYPE_RESPONSE 2
202
+ #define PDU_TYPE_FAULT 3
203
+ #define PDU_TYPE_WORKING 4
204
+ #define PDU_TYPE_NOCALL 5
205
+ #define PDU_TYPE_REJECT 6
206
+ #define PDU_TYPE_ACK 7
207
+ #define PDU_TYPE_CL_CANCEL 8
208
+ #define PDU_TYPE_FACK 9
209
+ #define PDU_TYPE_CANCEL_ACK 10
210
+ #define PDU_TYPE_BIND 11
211
+ #define PDU_TYPE_BIND_ACK 12
212
+ #define PDU_TYPE_BIND_NAK 13
213
+ #define PDU_TYPE_ALTER_CONTEXT 14
214
+ #define PDU_TYPE_ALTER_CONTEXT_RESP 15
215
+ #define PDU_TYPE_SHUTDOWN 17
216
+ #define PDU_TYPE_CO_CANCEL 18
217
+ #define PDU_TYPE_ORPHANED 19
218
+
219
+
220
+ /* Flags */
221
+ #define PFC_FIRST_FRAG 0x01
222
+ #define PFC_LAST_FRAG 0x02
223
+ #define PFC_PENDING_CANCEL 0x04
224
+ #define PFC_RESERVED_1 0x08
225
+ #define PFC_CONC_MPX 0x10
226
+ #define PFC_DID_NOT_EXECUTE 0x20
227
+ #define PFC_MAYBE 0x40
228
+ #define PFC_OBJECT_UUID 0x80
229
+
230
+ #define NSE_BUF_SIZE 128*1024
231
+
232
+ struct dcerpc_cb_data {
233
+ struct dcerpc_context *dce;
234
+ dcerpc_cb cb;
235
+ void *cb_data;
236
+ };
237
+
238
+ struct dcerpc_pdu {
239
+ struct dcerpc_header hdr;
240
+
241
+ union {
242
+ struct dcerpc_bind_pdu bind;
243
+ struct dcerpc_bind_ack_pdu bind_ack;
244
+ struct dcerpc_request_pdu req;
245
+ struct dcerpc_response_pdu rsp;
246
+ };
247
+
248
+ /* optional authentication verifier */
249
+ /* following fields present iff auth_length != 0 */
250
+ #if 0
251
+ auth_verifier_co_t auth_verifier;
252
+ #endif
253
+ struct dcerpc_context *dce;
254
+ dcerpc_cb cb;
255
+ void *cb_data;
256
+
257
+ dcerpc_coder coder;
258
+ int decode_size;
259
+ void *payload;
260
+
261
+ int top_level;
262
+ uint64_t ptr_id;
263
+
264
+ int cur_ptr;
265
+ int max_ptr;
266
+ struct dcerpc_deferred_pointer ptrs[MAX_DEFERRED_PTR];
267
+ int direction;
268
+ enum dcerpc_encoding encoding;
269
+ void *request;
270
+
271
+ /* All items are parsed twice, first to handle the conformance
272
+ * fields and a second time to handle the data itself.
273
+ * During the first run we also check what the maximum alignment
274
+ * of the fields are.
275
+ */
276
+ int is_conformance_run;
277
+ int max_alignment;
278
+
279
+ int size_is; /* Passing size_is() value through a pointer */
280
+ int switch_is; /* Passing switch_is() value through a pointer */
281
+
282
+ /* YAML */
283
+ int yaml_indentation;
284
+ int yaml_array_prefix;
285
+ char *yaml_key;
286
+ char *yaml_val;
287
+ };
288
+
289
+ /*
290
+ * NDR
291
+ */
292
+ #define RPTR 0x5270747272747052
293
+ #define UPTR 0x5570747272747055
294
+ static int ndr_do_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
295
+ struct smb2_iovec *iov, int *offset, void *ptr, dcerpc_coder coder);
296
+ int ndr_uint32_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
297
+ struct smb2_iovec *iov, int *offset, void *ptr);
298
+ int ndr_uint16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
299
+ struct smb2_iovec *iov, int *offset, void *ptr);
300
+ int ndr_uint8_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
301
+ struct smb2_iovec *iov, int *offset, void *ptr);
302
+ int ndr_uint3264_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
303
+ struct smb2_iovec *iov, int *offset, void *ptr);
304
+ static int ndr_conformance_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
305
+ struct smb2_iovec *iov, int *offset, void *ptr);
306
+ static int ndr_encode_ptr(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
307
+ struct smb2_iovec *iov, int *offset, void *ptr,
308
+ enum ptr_type type, dcerpc_coder coder);
309
+ static int ndr_decode_ptr(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
310
+ struct smb2_iovec *iov, int *offset, void *ptr,
311
+ enum ptr_type type, dcerpc_coder coder);
312
+ int ndr_carray_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
313
+ struct smb2_iovec *iov, int *offset,
314
+ int num, void *ptr, int elem_size, dcerpc_coder coder);
315
+ int ndr_union_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
316
+ struct smb2_iovec *iov, int *offset,
317
+ uint32_t *switch_is, void *ptr, dcerpc_coder coder);
318
+ int ndr_struct_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
319
+ struct smb2_iovec *iov, int *offset, void *ptr, dcerpc_coder coder);
320
+ int ndr_ptr_coder(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
321
+ struct smb2_iovec *iov, int *offset, void *ptr,
322
+ enum ptr_type type, dcerpc_coder coder);
323
+ static int ndr_encode_utf16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
324
+ struct smb2_iovec *iov, int *offset, void *ptr, int nult);
325
+ static int ndr_decode_utf16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
326
+ struct smb2_iovec *iov, int *offset, void *ptr, int nult);
327
+ int _ndr_utf16z_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
328
+ struct smb2_iovec *iov, int *offset, void *ptr, int nult);
329
+ int ndr_utf16z_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
330
+ struct smb2_iovec *iov, int *offset, void *ptr);
331
+ int ndr_utf16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
332
+ struct smb2_iovec *iov, int *offset, void *ptr);
333
+ int ndr_uuid_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
334
+ struct smb2_iovec *iov, int *offset, dcerpc_uuid_t *uuid);
335
+ int ndr_context_handle_coder(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
336
+ struct smb2_iovec *iov, int *offset, void *ptr);
337
+
338
+ /*
339
+ * YAML
340
+ */
341
+ static int yaml_uint32_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
342
+ struct smb2_iovec *iov, int *offset, void *ptr);
343
+ static int yaml_carray_coder(char *name, struct dcerpc_context *ctx,
344
+ struct dcerpc_pdu *pdu,
345
+ struct smb2_iovec *iov, int *offset,
346
+ int num, void *ptr, int elem_size, dcerpc_coder coder);
347
+ static int yaml_union_coder(char *name, struct dcerpc_context *ctx,
348
+ struct dcerpc_pdu *pdu,
349
+ struct smb2_iovec *iov, int *offset,
350
+ uint32_t *switch_is, void *ptr, dcerpc_coder coder);
351
+ static int yaml_ptr_coder(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
352
+ struct smb2_iovec *iov, int *offset, void *ptr,
353
+ enum ptr_type type, dcerpc_coder coder);
354
+ static int yaml_utf16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
355
+ struct smb2_iovec *iov, int *offset,
356
+ void *ptr);
357
+ static int yaml_struct_coder(char *name, struct dcerpc_context *ctx,
358
+ struct dcerpc_pdu *pdu,
359
+ struct smb2_iovec *iov, int *offset,
360
+ void *ptr, dcerpc_coder coder);
361
+ static int yaml_do_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
362
+ struct smb2_iovec *iov,
363
+ int *offset, void *ptr,
364
+ dcerpc_coder coder);
365
+
366
+
367
+ int
368
+ dcerpc_set_uint8(struct dcerpc_context *ctx, struct smb2_iovec *iov,
369
+ int *offset, uint8_t value)
370
+ {
371
+ if (*offset + sizeof(uint8_t) > iov->len) {
372
+ return -1;
373
+ }
374
+ *(uint8_t *)(iov->buf + *offset) = value;
375
+ *offset += 1;
376
+ return 0;
377
+ }
378
+
379
+ static int
380
+ dcerpc_set_uint16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
381
+ struct smb2_iovec *iov, int *offset, uint16_t value)
382
+ {
383
+ *offset = (*offset + 1) & ~1;
384
+
385
+ if (*offset + sizeof(uint16_t) > iov->len) {
386
+ return -1;
387
+ }
388
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
389
+ *(uint16_t *)(void *)(iov->buf + *offset) = htobe16(value);
390
+ } else {
391
+ *(uint16_t *)(void *)(iov->buf + *offset) = htole16(value);
392
+ }
393
+ *offset += 2;
394
+
395
+ return 0;
396
+ }
397
+
398
+ static int
399
+ dcerpc_set_uint32(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
400
+ struct smb2_iovec *iov, int *offset, uint32_t value)
401
+ {
402
+ *offset = (*offset + 3) & ~3;
403
+
404
+ if (*offset + sizeof(uint32_t) > iov->len) {
405
+ return -1;
406
+ }
407
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
408
+ *(uint32_t *)(void *)(iov->buf + *offset) = htobe32(value);
409
+ } else {
410
+ *(uint32_t *)(void *)(iov->buf + *offset) = htole32(value);
411
+ }
412
+ *offset += 4;
413
+ return 0;
414
+ }
415
+
416
+ static int
417
+ dcerpc_set_uint64(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
418
+ struct smb2_iovec *iov, int *offset, uint64_t value)
419
+ {
420
+ *offset = (*offset + 7) & ~7;
421
+
422
+ if (*offset + sizeof(uint64_t) > iov->len) {
423
+ return -1;
424
+ }
425
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
426
+ *(uint64_t *)(void *)(iov->buf + *offset) = htobe64(value);
427
+ } else {
428
+ *(uint64_t *)(void *)(iov->buf + *offset) = htole64(value);
429
+ }
430
+ *offset += 8;
431
+ return 0;
432
+ }
433
+
434
+ static int
435
+ dcerpc_get_uint8(struct dcerpc_context *ctx, struct smb2_iovec *iov,
436
+ int *offset, uint8_t *value)
437
+ {
438
+ if (*offset + sizeof(uint8_t) > iov->len) {
439
+ return -1;
440
+ }
441
+ *value = iov->buf[*offset];
442
+ *offset += 1;
443
+ return 0;
444
+ }
445
+
446
+ static int
447
+ dcerpc_get_uint16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
448
+ struct smb2_iovec *iov, int *offset, uint16_t *value)
449
+ {
450
+ uint16_t val;
451
+
452
+ *offset = (*offset + 1) & ~1;
453
+
454
+ if (*offset + sizeof(uint16_t) > iov->len) {
455
+ return -1;
456
+ }
457
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
458
+ val = be16toh(*(uint16_t *)(void *)(iov->buf + *offset));
459
+ } else {
460
+ val = le16toh(*(uint16_t *)(void *)(iov->buf + *offset));
461
+ }
462
+ *value = val;
463
+ *offset += 2;
464
+ return 0;
465
+ }
466
+
467
+ static int
468
+ dcerpc_get_uint32(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
469
+ struct smb2_iovec *iov, int *offset, uint32_t *value)
470
+ {
471
+ uint32_t val;
472
+
473
+ *offset = (*offset + 3) & ~3;
474
+
475
+ if (*offset + sizeof(uint32_t) > iov->len) {
476
+ return -1;
477
+ }
478
+
479
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
480
+ val = be32toh(*(uint32_t *)(void *)(iov->buf + *offset));
481
+ } else {
482
+ val = le32toh(*(uint32_t *)(void *)(iov->buf + *offset));
483
+ }
484
+ *value = val;
485
+ *offset += 4;
486
+ return 0;
487
+ }
488
+
489
+ static int
490
+ dcerpc_get_uint64(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
491
+ struct smb2_iovec *iov, int *offset, uint64_t *value)
492
+ {
493
+ uint64_t val;
494
+
495
+ *offset = (*offset + 7) & ~7;
496
+
497
+ if (*offset + sizeof(uint64_t) > iov->len) {
498
+ return -1;
499
+ }
500
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
501
+ val = be64toh(*(uint64_t *)(void *)(iov->buf + *offset));
502
+ } else {
503
+ val = le64toh(*(uint64_t *)(void *)(iov->buf + *offset));
504
+ }
505
+ *value = val;
506
+ *offset += 8;
507
+ return 0;
508
+ }
509
+
510
+ int
511
+ dcerpc_uint64_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
512
+ struct smb2_iovec *iov, int *offset, void *ptr)
513
+ {
514
+ if (pdu->is_conformance_run) {
515
+ if (pdu->max_alignment < 8) {
516
+ pdu->max_alignment = 8;
517
+ }
518
+ return 0;
519
+ }
520
+
521
+ if (pdu->direction == DCERPC_DECODE) {
522
+ return dcerpc_get_uint64(ctx, pdu, iov, offset, ptr);
523
+ } else {
524
+ return dcerpc_set_uint64(ctx, pdu, iov, offset, *(uint32_t *)ptr);
525
+ }
526
+ }
527
+
528
+ struct smb2_context *
529
+ dcerpc_get_smb2_context(struct dcerpc_context *dce)
530
+ {
531
+ return dce->smb2;
532
+ }
533
+
534
+ void *
535
+ dcerpc_get_pdu_payload(struct dcerpc_pdu *pdu)
536
+ {
537
+ return pdu->payload;
538
+ }
539
+
540
+ struct dcerpc_context *
541
+ dcerpc_create_context(struct smb2_context *smb2)
542
+ {
543
+ struct dcerpc_context *ctx;
544
+
545
+ ctx = calloc(1, sizeof(struct dcerpc_context));
546
+ if (ctx == NULL) {
547
+ smb2_set_error(smb2, "Failed to allocate dcercp context.");
548
+ return NULL;
549
+ }
550
+
551
+ ctx->smb2 = smb2;
552
+ ctx->packed_drep[0] |= DCERPC_DR_LITTLE_ENDIAN;
553
+ return ctx;
554
+ }
555
+
556
+ int
557
+ dcerpc_connect_context_async(struct dcerpc_context *dce, const char *path,
558
+ p_syntax_id_t *syntax,
559
+ dcerpc_cb cb, void *cb_data)
560
+ {
561
+ dce->call_id = 2;
562
+ dce->path = strdup(path);
563
+ if (dce->path == NULL) {
564
+ smb2_set_error(dce->smb2, "Failed to allocate path for "
565
+ "dcercp context.");
566
+ return -ENOMEM;
567
+ }
568
+ dce->syntax = syntax;
569
+ dce->packed_drep[0] = DCERPC_DR_ASCII;
570
+ if (!dce->smb2->endianness) {
571
+ dce->packed_drep[0] |= DCERPC_DR_LITTLE_ENDIAN;
572
+ }
573
+
574
+ if (dcerpc_open_async(dce, cb, cb_data) != 0) {
575
+ return -1;
576
+ }
577
+
578
+ return 0;
579
+ }
580
+
581
+ void
582
+ dcerpc_destroy_context(struct dcerpc_context *dce)
583
+ {
584
+ if (dce == NULL) {
585
+ return;
586
+ }
587
+ free(discard_const(dce->path));
588
+ free(dce);
589
+ }
590
+
591
+ void
592
+ dcerpc_free_pdu(struct dcerpc_context *dce, struct dcerpc_pdu *pdu)
593
+ {
594
+ if (pdu == NULL) {
595
+ return;
596
+ }
597
+
598
+ if (pdu->payload) {
599
+ smb2_free_data(dce->smb2, pdu->payload);
600
+ }
601
+ free(pdu);
602
+ }
603
+
604
+ struct dcerpc_pdu *
605
+ dcerpc_allocate_pdu(struct dcerpc_context *dce, enum dcerpc_encoding encoding,
606
+ int direction, int payload_size)
607
+ {
608
+ struct dcerpc_pdu *pdu;
609
+
610
+ pdu = calloc(1, sizeof(struct dcerpc_pdu));
611
+ if (pdu == NULL) {
612
+ smb2_set_error(dce->smb2, "Failed to allocate DCERPC PDU");
613
+ return NULL;
614
+ }
615
+
616
+ pdu->dce = dce;
617
+ pdu->hdr.call_id = dce->call_id++;
618
+ pdu->encoding = encoding;
619
+ pdu->direction = direction;
620
+ pdu->top_level = 1;
621
+ pdu->payload = smb2_alloc_init(dce->smb2, payload_size);
622
+ if (pdu->payload == NULL) {
623
+ smb2_set_error(dce->smb2, "Failed to allocate PDU Payload");
624
+ dcerpc_free_pdu(dce, pdu);
625
+ return NULL;
626
+ }
627
+
628
+ return pdu;
629
+ }
630
+
631
+ static void
632
+ dcerpc_add_deferred_pointer(struct dcerpc_context *ctx,
633
+ struct dcerpc_pdu *pdu,
634
+ dcerpc_coder coder, void *ptr)
635
+ {
636
+ pdu->ptrs[pdu->max_ptr].coder = coder;
637
+ pdu->ptrs[pdu->max_ptr].ptr = ptr;
638
+ pdu->max_ptr++;
639
+ }
640
+
641
+ int
642
+ dcerpc_do_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
643
+ struct smb2_iovec *iov,
644
+ int *offset, void *ptr,
645
+ dcerpc_coder coder)
646
+ {
647
+ switch(pdu->encoding) {
648
+ case ENCODING_NDR:
649
+ return ndr_do_coder(name, ctx, pdu, iov, offset, ptr, coder);
650
+ case ENCODING_YAML:
651
+ return yaml_do_coder(name, ctx, pdu, iov, offset, ptr, coder);
652
+ };
653
+ return -1;
654
+ }
655
+
656
+ static int
657
+ dcerpc_process_deferred_pointers(struct dcerpc_context *ctx,
658
+ struct dcerpc_pdu *pdu,
659
+ struct smb2_iovec *iov,
660
+ int *offset)
661
+ {
662
+ struct dcerpc_deferred_pointer *dp;
663
+ int idx;
664
+
665
+ while (pdu->cur_ptr != pdu->max_ptr) {
666
+ idx = pdu->cur_ptr++;
667
+ dp = &pdu->ptrs[idx];
668
+ if (ndr_do_coder("DEFERRED", ctx, pdu, iov, offset, dp->ptr, dp->coder)) {
669
+ return -1;
670
+ }
671
+ }
672
+ return 0;
673
+ }
674
+
675
+ int
676
+ dcerpc_uint32_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
677
+ struct smb2_iovec *iov, int *offset, void *ptr)
678
+ {
679
+ switch(pdu->encoding) {
680
+ case ENCODING_NDR:
681
+ return ndr_uint32_coder(name, ctx, pdu, iov, offset, ptr);
682
+ case ENCODING_YAML:
683
+ return yaml_uint32_coder(name, ctx, pdu, iov, offset, ptr);
684
+ }
685
+ return -1;
686
+ }
687
+
688
+ int
689
+ dcerpc_carray_coder(char *name, struct dcerpc_context *ctx,
690
+ struct dcerpc_pdu *pdu,
691
+ struct smb2_iovec *iov, int *offset,
692
+ int num, void *ptr, int elem_size, dcerpc_coder coder)
693
+ {
694
+ switch(pdu->encoding) {
695
+ case ENCODING_NDR:
696
+ return ndr_carray_coder(name, ctx, pdu, iov, offset,
697
+ num, ptr, elem_size, coder);
698
+ case ENCODING_YAML:
699
+ return yaml_carray_coder(name, ctx, pdu, iov, offset,
700
+ num, ptr, elem_size, coder);
701
+ }
702
+ return -1;
703
+ }
704
+
705
+ int dcerpc_union_coder(char *name, struct dcerpc_context *ctx,
706
+ struct dcerpc_pdu *pdu,
707
+ struct smb2_iovec *iov, int *offset,
708
+ uint32_t *switch_is, void *ptr, dcerpc_coder coder)
709
+ {
710
+ switch(pdu->encoding) {
711
+ case ENCODING_NDR:
712
+ return ndr_union_coder(name, ctx, pdu, iov, offset,
713
+ switch_is, ptr, coder);
714
+ case ENCODING_YAML:
715
+ return yaml_union_coder(name, ctx, pdu, iov, offset,
716
+ switch_is, ptr, coder);
717
+ }
718
+ return -1;
719
+ }
720
+
721
+ int dcerpc_struct_coder(char *name, struct dcerpc_context *ctx,
722
+ struct dcerpc_pdu *pdu,
723
+ struct smb2_iovec *iov, int *offset,
724
+ void *ptr, dcerpc_coder coder)
725
+ {
726
+ switch(pdu->encoding) {
727
+ case ENCODING_NDR:
728
+ return ndr_struct_coder(name, ctx, pdu, iov, offset,
729
+ ptr, coder);
730
+ case ENCODING_YAML:
731
+ return yaml_struct_coder(name, ctx, pdu, iov, offset,
732
+ ptr, coder);
733
+ }
734
+ return -1;
735
+ }
736
+
737
+ int
738
+ dcerpc_ptr_coder(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
739
+ struct smb2_iovec *iov, int *offset, void *ptr,
740
+ enum ptr_type type, dcerpc_coder coder)
741
+ {
742
+ switch(pdu->encoding) {
743
+ case ENCODING_NDR:
744
+ return ndr_ptr_coder(name, dce, pdu, iov, offset, ptr,
745
+ type, coder);
746
+ case ENCODING_YAML:
747
+ return yaml_ptr_coder(name, dce, pdu, iov, offset, ptr,
748
+ type, coder);
749
+ }
750
+ return -1;
751
+ }
752
+
753
+ int
754
+ dcerpc_utf16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
755
+ struct smb2_iovec *iov, int *offset,
756
+ void *ptr)
757
+ {
758
+ switch(pdu->encoding) {
759
+ case ENCODING_NDR:
760
+ return ndr_utf16_coder(name, ctx, pdu, iov, offset, ptr);
761
+ case ENCODING_YAML:
762
+ return yaml_utf16_coder(name, ctx, pdu, iov, offset, ptr);
763
+ }
764
+ return -1;
765
+ }
766
+ int
767
+ dcerpc_utf16z_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
768
+ struct smb2_iovec *iov, int *offset,
769
+ void *ptr)
770
+ {
771
+ switch(pdu->encoding) {
772
+ case ENCODING_NDR:
773
+ return ndr_utf16z_coder(name, ctx, pdu, iov, offset, ptr);
774
+ case ENCODING_YAML:
775
+ return yaml_utf16_coder(name, ctx, pdu, iov, offset, ptr);
776
+ }
777
+ return -1;
778
+ }
779
+
780
+
781
+ int
782
+ dcerpc_header_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
783
+ struct smb2_iovec *iov, int *offset,
784
+ struct dcerpc_header *hdr)
785
+ {
786
+ /* Major Version */
787
+ if (ndr_uint8_coder("RpcVersion", ctx, pdu, iov, offset, &hdr->rpc_vers)) {
788
+ return -1;
789
+ }
790
+ /* Minor Version */
791
+ if (ndr_uint8_coder("RpcVersionMinor", ctx, pdu, iov, offset, &hdr->rpc_vers_minor)) {
792
+ return -1;
793
+ }
794
+ /* Packet Type */
795
+ if (ndr_uint8_coder("PType", ctx, pdu, iov, offset, &hdr->PTYPE)) {
796
+ return -1;
797
+ }
798
+ /* Flags */
799
+ if (ndr_uint8_coder("PFCFlags", ctx, pdu, iov, offset, &hdr->pfc_flags)) {
800
+ return -1;
801
+ }
802
+
803
+ /* Data Representation */
804
+ if (ndr_uint8_coder("DREP", ctx, pdu, iov, offset, &hdr->packed_drep[0])) {
805
+ return -1;
806
+ }
807
+ if (ndr_uint8_coder("DREP", ctx, pdu, iov, offset, &hdr->packed_drep[1])) {
808
+ return -1;
809
+ }
810
+ if (ndr_uint8_coder("DREP", ctx, pdu, iov, offset, &hdr->packed_drep[2])) {
811
+ return -1;
812
+ }
813
+ if (ndr_uint8_coder("DREP", ctx, pdu, iov, offset, &hdr->packed_drep[3])) {
814
+ return -1;
815
+ }
816
+
817
+ /* Fragment len */
818
+ if (ndr_uint16_coder("FragmentLength", ctx, pdu, iov, offset, &hdr->frag_length)) {
819
+ return -1;
820
+ }
821
+
822
+ /* Auth len */
823
+ if (ndr_uint16_coder("AuthLength", ctx, pdu, iov, offset, &hdr->auth_length)) {
824
+ return -1;
825
+ }
826
+
827
+ /* Call id */
828
+ if (ndr_uint32_coder("CallId", ctx, pdu, iov, offset, &hdr->call_id)) {
829
+ return -1;
830
+ }
831
+
832
+ return 0;
833
+ }
834
+
835
+ static int
836
+ dcerpc_bind_coder(struct dcerpc_context *ctx,
837
+ struct dcerpc_pdu *pdu,
838
+ struct dcerpc_bind_pdu *bind,
839
+ struct smb2_iovec *iov, int *offset)
840
+ {
841
+ int oo, i, j;
842
+ uint16_t v;
843
+
844
+ /* Max Xmit Frag */
845
+ if (ndr_uint16_coder("MaxXmitFrag", ctx, pdu, iov, offset, &bind->max_xmit_frag)) {
846
+ return -1;
847
+ }
848
+
849
+ /* Max Recv Frag */
850
+ if (ndr_uint16_coder("MaxRecvFrag", ctx, pdu, iov, offset, &bind->max_recv_frag)) {
851
+ return -1;
852
+ }
853
+
854
+ /* Association Group */
855
+ if (ndr_uint32_coder("AssociationGroup", ctx, pdu, iov, offset, &bind->assoc_group_id)) {
856
+ return -1;
857
+ }
858
+
859
+ /* Number Of Context Items */
860
+ if (ndr_uint8_coder("NumContextElement", ctx, pdu, iov, offset, &bind->n_context_elem)) {
861
+ return -1;
862
+ }
863
+ *offset += 3;
864
+
865
+ //qqq TODO allocate p_cont_elem on decode
866
+ for (i = 0; i < bind->n_context_elem; i++) {
867
+ if (ndr_uint16_coder("PContId", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].p_cont_id)) {
868
+ return -1;
869
+ }
870
+ if (ndr_uint8_coder("NumTransferSyntax", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].n_transfer_syn)) {
871
+ return -1;
872
+ }
873
+ *offset += 1;
874
+ /* Abstract Syntax */
875
+ //qqq TODO allocate abstract_syntax on decode
876
+ if (ndr_uuid_coder("SyntaxUUID", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].abstract_syntax->uuid)) {
877
+ return -1;
878
+ }
879
+ if (ndr_uint16_coder("AbstractSyntax", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].abstract_syntax->vers)) {
880
+ return -1;
881
+ }
882
+ if (ndr_uint16_coder("VersMinor", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].abstract_syntax->vers_minor)) {
883
+ return -1;
884
+ }
885
+ //qqq TODO allocate transfer_syntaxes on decode
886
+ for (j = 0; j < pdu->bind.p_cont_elem[i].n_transfer_syn; j++) {
887
+ if (ndr_uuid_coder("TransferSyntax", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].transfer_syntaxes[j]->uuid)) {
888
+ return -1;
889
+ }
890
+ if (ndr_uint16_coder("Version", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].transfer_syntaxes[j]->vers)) {
891
+ return -1;
892
+ }
893
+ if (ndr_uint16_coder("VersionMinor", ctx, pdu, iov, offset, &pdu->bind.p_cont_elem[i].transfer_syntaxes[j]->vers_minor)) {
894
+ return -1;
895
+ }
896
+ }
897
+
898
+ }
899
+ /* Fixup fragment length */
900
+ oo = 8;
901
+ v = *offset;
902
+ if (ndr_uint16_coder("v", ctx, pdu, iov, &oo, &v)) {
903
+ return -1;
904
+ }
905
+
906
+ return 0;
907
+ }
908
+
909
+ static int
910
+ dcerpc_request_coder(struct dcerpc_context *ctx,
911
+ struct dcerpc_pdu *pdu,
912
+ struct dcerpc_request_pdu *req,
913
+ struct smb2_iovec *iov, int *offset)
914
+ {
915
+ /* Alloc Hint */
916
+ if (ndr_uint32_coder("AllocHint", ctx, pdu, iov, offset, &req->alloc_hint)) {
917
+ return -1;
918
+ }
919
+
920
+ /* Context ID */
921
+ if (ndr_uint16_coder("ContextId", ctx, pdu, iov, offset, &req->context_id)) {
922
+ return -1;
923
+ }
924
+
925
+ /* Opnum */
926
+ if (ndr_uint16_coder("OpNum", ctx, pdu, iov, offset, &req->opnum)) {
927
+ return -1;
928
+ }
929
+
930
+ return 0;
931
+ }
932
+
933
+ static int
934
+ dcerpc_bind_ack_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
935
+ struct dcerpc_bind_ack_pdu *bind_ack,
936
+ struct smb2_iovec *iov, int *offset)
937
+ {
938
+ int i;
939
+ uint16_t sec_addr_len;
940
+
941
+ /* Max Xmit Frag */
942
+ if (ndr_uint16_coder("MaxXmitFrag", ctx, pdu, iov, offset, &bind_ack->max_xmit_frag)) {
943
+ return -1;
944
+ }
945
+
946
+ /* Max Recv Frag */
947
+ if (ndr_uint16_coder("MaxRecvFrag", ctx, pdu, iov, offset, &bind_ack->max_recv_frag)) {
948
+ return -1;
949
+ }
950
+
951
+ /* Association Group */
952
+ if (ndr_uint32_coder("AssociationGroup", ctx, pdu, iov, offset, &bind_ack->assoc_group_id)) {
953
+ return -1;
954
+ }
955
+
956
+ /* Secondary Address Length */
957
+ if (ndr_uint16_coder("SecondaryAddressLength", ctx, pdu, iov, offset, &sec_addr_len)) {
958
+ return -1;
959
+ }
960
+
961
+ /* Skip the secondary address and realign to 32bit */
962
+ /* TODO: we need to handle the encode case.
963
+ * it is something like "\\PIPE\\srvsvc"
964
+ */
965
+ *offset += sec_addr_len;
966
+ *offset = (*offset + 3) & ~3;
967
+
968
+ /* Number Of Results */
969
+ if (ndr_uint8_coder("NumResults", ctx, pdu, iov, offset, &bind_ack->num_results)) {
970
+ return -1;
971
+ }
972
+ *offset += 3;
973
+
974
+ for (i = 0; i < bind_ack->num_results; i++) {
975
+ if (ndr_uint16_coder("AckResult", ctx, pdu, iov, offset, &bind_ack->results[i].ack_result)) {
976
+ return -1;
977
+ }
978
+
979
+ if (ndr_uint16_coder("AckReason", ctx, pdu, iov, offset, &bind_ack->results[i].ack_reason)) {
980
+ return -1;
981
+ }
982
+
983
+ if (ndr_uuid_coder("UUID", ctx, pdu, iov, offset,
984
+ &bind_ack->results[i].uuid)) {
985
+ return -1;
986
+ }
987
+
988
+ if (ndr_uint32_coder("SyntaxVersion", ctx, pdu, iov, offset, &bind_ack->results[i].syntax_version)) {
989
+ return -1;
990
+ }
991
+ }
992
+
993
+ return 0;
994
+ }
995
+
996
+ static int
997
+ dcerpc_response_coder(struct dcerpc_context *ctx,
998
+ struct dcerpc_response_pdu *rsp,
999
+ struct smb2_iovec *iov, int *offset)
1000
+ {
1001
+ #ifndef _MSC_VER
1002
+ struct dcerpc_pdu *pdu = container_of(rsp, struct dcerpc_pdu, rsp);
1003
+ #else
1004
+ const char* __mptr = (const char*)rsp;
1005
+ struct dcerpc_pdu *pdu = (struct dcerpc_pdu*)((char *)__mptr - offsetof(struct dcerpc_pdu, rsp));
1006
+ #endif /* !_MSC_VER */
1007
+
1008
+ if (*offset < 0) {
1009
+ return -1;
1010
+ }
1011
+
1012
+ /* Alloc Hint */
1013
+ if (ndr_uint32_coder("AllocationHint", ctx, pdu, iov, offset, &rsp->alloc_hint)) {
1014
+ return -1;
1015
+ }
1016
+
1017
+ if (rsp->alloc_hint > 16*1024*1024) {
1018
+ smb2_set_error(ctx->smb2, "DCERPC RESPONSE alloc_hint out "
1019
+ "of range.");
1020
+ return -1;
1021
+ }
1022
+
1023
+ /* Context Id */
1024
+ if (ndr_uint16_coder("ContextId", ctx, pdu, iov, offset, &rsp->context_id)) {
1025
+ return -1;
1026
+ }
1027
+
1028
+ /* Cancel Count */
1029
+ if (ndr_uint8_coder("CancelCount", ctx, pdu, iov, offset, &rsp->cancel_count)) {
1030
+ return -1;
1031
+ }
1032
+ *offset += 1;
1033
+
1034
+
1035
+ /* decode the blob */
1036
+ pdu->top_level = 1;
1037
+ if (pdu->coder("Response", ctx, pdu, iov, offset, pdu->payload) < 0) {
1038
+ return -1;
1039
+ }
1040
+
1041
+ *offset += rsp->alloc_hint;
1042
+
1043
+ return 0;
1044
+ }
1045
+
1046
+ static int
1047
+ dcerpc_pdu_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1048
+ struct smb2_iovec *iov, int *offset)
1049
+ {
1050
+ if (dcerpc_header_coder(ctx, pdu, iov, offset, &pdu->hdr)) {
1051
+ return -1;
1052
+ }
1053
+
1054
+ switch (pdu->hdr.PTYPE) {
1055
+ case PDU_TYPE_BIND:
1056
+ if (dcerpc_bind_coder(ctx, pdu, &pdu->bind, iov, offset)) {
1057
+ return -1;
1058
+ }
1059
+ break;
1060
+ case PDU_TYPE_BIND_ACK:
1061
+ if (dcerpc_bind_ack_coder(ctx, pdu, &pdu->bind_ack, iov, offset)) {
1062
+ return -1;
1063
+ }
1064
+ break;
1065
+ case PDU_TYPE_REQUEST:
1066
+ if (dcerpc_request_coder(ctx, pdu, &pdu->req, iov, offset)) {
1067
+ return -1;
1068
+ }
1069
+ break;
1070
+ case PDU_TYPE_RESPONSE:
1071
+ if (dcerpc_response_coder(ctx, &pdu->rsp, iov, offset)) {
1072
+ return -1;
1073
+ }
1074
+ break;
1075
+ default:
1076
+ smb2_set_error(ctx->smb2, "DCERPC No decoder for PDU type %d",
1077
+ pdu->hdr.PTYPE);
1078
+ return -1;
1079
+ }
1080
+
1081
+ return 0;
1082
+ }
1083
+
1084
+ static void
1085
+ dce_unfragment_ioctl(struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
1086
+ struct smb2_iovec *iov)
1087
+ {
1088
+ int offset = 0;
1089
+ int unfragment_len;
1090
+ struct dcerpc_header hdr, next_hdr;
1091
+ struct smb2_iovec tmpiov _U_;
1092
+ int o;
1093
+
1094
+ o = 0;
1095
+ if (dcerpc_header_coder(dce, pdu, iov, &o, &hdr)) {
1096
+ return;
1097
+ }
1098
+ if (hdr.rpc_vers != 5 || hdr.rpc_vers_minor != 0 ||
1099
+ hdr.PTYPE != PDU_TYPE_RESPONSE) {
1100
+ return;
1101
+ }
1102
+
1103
+ if (hdr.pfc_flags & PFC_LAST_FRAG) {
1104
+ return;
1105
+ }
1106
+
1107
+ offset += hdr.frag_length;
1108
+ unfragment_len = hdr.frag_length;
1109
+ do {
1110
+ /* We must have at least a DCERPC header plus a
1111
+ * RESPONSE header
1112
+ */
1113
+ if (iov->len - offset < 24) {
1114
+ return;
1115
+ }
1116
+
1117
+ tmpiov.buf = iov->buf + offset;
1118
+ tmpiov.len = iov->len - offset;
1119
+ o = 0;
1120
+ if (dcerpc_header_coder(dce, pdu, &tmpiov, &o, &next_hdr)) {
1121
+ return;
1122
+ }
1123
+
1124
+ memmove(iov->buf + unfragment_len, iov->buf + offset + 24,
1125
+ next_hdr.frag_length - 24);
1126
+ unfragment_len += next_hdr.frag_length - 24;
1127
+ offset += next_hdr.frag_length;
1128
+
1129
+ hdr.frag_length += next_hdr.frag_length;
1130
+ if (next_hdr.pfc_flags & PFC_LAST_FRAG) {
1131
+ hdr.pfc_flags |= PFC_LAST_FRAG;
1132
+ }
1133
+ o = 0;
1134
+ if (dcerpc_header_coder(dce, pdu, iov, &o, &hdr)) {
1135
+ return;
1136
+ }
1137
+ } while (!(next_hdr.pfc_flags & PFC_LAST_FRAG));
1138
+ iov->len = unfragment_len;
1139
+ }
1140
+
1141
+ static void
1142
+ dcerpc_send_pdu_cb_and_free(struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
1143
+ int status, void *command_data)
1144
+ {
1145
+ dcerpc_cb pdu_cb = pdu->cb;
1146
+ void *pdu_cb_data = pdu->cb_data;
1147
+
1148
+ dcerpc_free_pdu(dce, pdu);
1149
+ pdu_cb(dce, status, command_data, pdu_cb_data);
1150
+ }
1151
+
1152
+ static void
1153
+ dcerpc_call_cb(struct smb2_context *smb2, int status,
1154
+ void *command_data, void *private_data)
1155
+ {
1156
+ struct dcerpc_pdu *pdu = private_data;
1157
+ struct dcerpc_context *dce = pdu->dce;
1158
+ struct smb2_iovec iov _U_;
1159
+ struct smb2_ioctl_reply *rep = command_data;
1160
+ void *payload;
1161
+ int offset = 0;
1162
+
1163
+ pdu->direction = DCERPC_DECODE;
1164
+
1165
+ if (status != SMB2_STATUS_SUCCESS) {
1166
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -nterror_to_errno(status), NULL);
1167
+ return;
1168
+ }
1169
+
1170
+ smb2_free_data(dce->smb2, pdu->payload);
1171
+ pdu->payload = NULL;
1172
+
1173
+ pdu->payload = smb2_alloc_init(dce->smb2, pdu->decode_size);
1174
+ if (pdu->payload == NULL) {
1175
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -ENOMEM, NULL);
1176
+ return;
1177
+ }
1178
+
1179
+ iov.buf = rep->output;
1180
+ iov.len = rep->output_count;
1181
+ iov.free = NULL;
1182
+
1183
+ dce_unfragment_ioctl(dce, pdu, &iov);
1184
+
1185
+ if (dcerpc_pdu_coder(dce, pdu, &iov, &offset)) {
1186
+ smb2_free_data(dce->smb2, rep->output);
1187
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -EINVAL, NULL);
1188
+ return;
1189
+ }
1190
+ smb2_free_data(dce->smb2, rep->output);
1191
+
1192
+ if (pdu->hdr.PTYPE != PDU_TYPE_RESPONSE) {
1193
+ smb2_set_error(dce->smb2, "DCERPC response was not a RESPONSE");
1194
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -EINVAL, NULL);
1195
+ return;
1196
+ }
1197
+
1198
+ payload = pdu->payload;
1199
+ pdu->payload = NULL;
1200
+ dcerpc_send_pdu_cb_and_free(dce, pdu, 0, payload);
1201
+ }
1202
+
1203
+ int
1204
+ dcerpc_call_async(struct dcerpc_context *dce,
1205
+ int opnum,
1206
+ dcerpc_coder req_coder, void *req,
1207
+ dcerpc_coder rep_coder, int decode_size,
1208
+ dcerpc_cb cb, void *cb_data)
1209
+ {
1210
+ struct dcerpc_pdu *pdu;
1211
+ struct smb2_pdu *smb2_pdu;
1212
+ struct smb2_ioctl_request smb2_req;
1213
+ struct smb2_iovec iov;
1214
+ int offset = 0, o;
1215
+ uint32_t v;
1216
+
1217
+ pdu = dcerpc_allocate_pdu(dce, ENCODING_NDR, DCERPC_ENCODE, NSE_BUF_SIZE);
1218
+ if (pdu == NULL) {
1219
+ return -ENOMEM;
1220
+ }
1221
+
1222
+ pdu->hdr.rpc_vers = 5;
1223
+ pdu->hdr.rpc_vers_minor = 0;
1224
+ pdu->hdr.PTYPE = PDU_TYPE_REQUEST;
1225
+ pdu->hdr.pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG;
1226
+ pdu->hdr.packed_drep[0] = dce->packed_drep[0];
1227
+ pdu->hdr.frag_length = 0;
1228
+ pdu->hdr.auth_length = 0;
1229
+ pdu->req.alloc_hint = 0;
1230
+ pdu->req.context_id = dce->tctx_id;
1231
+ pdu->req.opnum = opnum;
1232
+
1233
+ pdu->coder = rep_coder;
1234
+ pdu->decode_size = decode_size;
1235
+ pdu->cb = cb;
1236
+ pdu->cb_data = cb_data;
1237
+
1238
+ iov.buf = pdu->payload;
1239
+ iov.len = NSE_BUF_SIZE;
1240
+ iov.free = NULL;
1241
+ if (dcerpc_pdu_coder(dce, pdu, &iov, &offset)) {
1242
+ dcerpc_free_pdu(dce, pdu);
1243
+ return -ENOMEM;
1244
+ }
1245
+
1246
+ /* encode the blob */
1247
+ pdu->top_level = 1;
1248
+ /* Remember the request in case we need to dereference it from the reply */
1249
+ dcerpc_set_request(pdu, req);
1250
+ if (req_coder("Request", dce, pdu, &iov, &offset, req)) {
1251
+ return -1;
1252
+ }
1253
+
1254
+ iov.len = offset;
1255
+
1256
+ /* Fixup frag_length and alloc_hint */
1257
+ o = 8;
1258
+ if (dcerpc_set_uint16(dce, pdu, &iov, &o, offset)) {
1259
+ return -1;
1260
+ }
1261
+ o = 16;
1262
+ v = offset - 24;
1263
+ if (ndr_uint32_coder("v", dce, pdu, &iov, &o, &v)) {
1264
+ return -1;
1265
+ }
1266
+
1267
+ memset(&smb2_req, 0, sizeof(struct smb2_ioctl_request));
1268
+ smb2_req.ctl_code = SMB2_FSCTL_PIPE_TRANSCEIVE;
1269
+ memcpy(smb2_req.file_id, dce->file_id, SMB2_FD_SIZE);
1270
+ smb2_req.input_count = (uint32_t)iov.len;
1271
+ smb2_req.input = iov.buf;
1272
+ smb2_req.flags = SMB2_0_IOCTL_IS_FSCTL;
1273
+
1274
+ smb2_pdu = smb2_cmd_ioctl_async(dce->smb2, &smb2_req, dcerpc_call_cb, pdu);
1275
+ if (smb2_pdu == NULL) {
1276
+ dcerpc_free_pdu(dce, pdu);
1277
+ return -ENOMEM;
1278
+ }
1279
+ smb2_queue_pdu(dce->smb2, smb2_pdu);
1280
+
1281
+ return 0;
1282
+ }
1283
+
1284
+ static void
1285
+ dcerpc_bind_cb(struct dcerpc_context *dce, int status,
1286
+ void *command_data, void *cb_data)
1287
+ {
1288
+ struct dcerpc_cb_data *data = cb_data;
1289
+
1290
+ if (status != SMB2_STATUS_SUCCESS) {
1291
+ data->cb(dce, status, NULL, data->cb_data);
1292
+ free(data);
1293
+ return;
1294
+ }
1295
+
1296
+ data->cb(dce, 0, NULL, data->cb_data);
1297
+ free(data);
1298
+ }
1299
+
1300
+ static void
1301
+ smb2_bind_cb(struct smb2_context *smb2, int status,
1302
+ void *command_data, void *private_data)
1303
+ {
1304
+ struct dcerpc_pdu *pdu = private_data;
1305
+ struct dcerpc_context *dce = pdu->dce;
1306
+ struct smb2_iovec iov _U_;
1307
+ struct smb2_ioctl_reply *rep = command_data;
1308
+ int i;
1309
+ int offset = 0;
1310
+
1311
+ pdu->direction = DCERPC_DECODE;
1312
+
1313
+ if (status != SMB2_STATUS_SUCCESS) {
1314
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -nterror_to_errno(status), NULL);
1315
+ return;
1316
+ }
1317
+
1318
+ iov.buf = rep->output;
1319
+ iov.len = rep->output_count;
1320
+ iov.free = NULL;
1321
+ if (dcerpc_pdu_coder(dce, pdu, &iov, &offset)) {
1322
+ smb2_free_data(dce->smb2, rep->output);
1323
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -EINVAL, NULL);
1324
+ return;
1325
+ }
1326
+ smb2_free_data(dce->smb2, rep->output);
1327
+
1328
+ if (pdu->hdr.PTYPE != PDU_TYPE_BIND_ACK) {
1329
+ smb2_set_error(dce->smb2, "DCERPC response was not a BIND_ACK");
1330
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -EINVAL, NULL);
1331
+ return;
1332
+ }
1333
+
1334
+ if (pdu->bind_ack.num_results < 1) {
1335
+ smb2_set_error(smb2, "No results in BIND ACK");
1336
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -EINVAL, NULL);
1337
+ return;
1338
+ }
1339
+ for (i = 0; i < pdu->bind_ack.num_results; i++) {
1340
+ if (pdu->bind_ack.results[i].ack_result !=
1341
+ ACK_RESULT_ACCEPTANCE) {
1342
+ continue;
1343
+ }
1344
+
1345
+ switch (smb2->ndr) {
1346
+ case 0:
1347
+ dce->tctx_id = i;
1348
+ break;
1349
+ case 1:
1350
+ dce->tctx_id = 0;
1351
+ break;
1352
+ case 2:
1353
+ dce->tctx_id = 1;
1354
+ break;
1355
+ }
1356
+ break;
1357
+ }
1358
+ if (i == pdu->bind_ack.num_results) {
1359
+ smb2_set_error(smb2, "Bind rejected all contexts");
1360
+ dcerpc_send_pdu_cb_and_free(dce, pdu, -EINVAL, NULL);
1361
+ return;
1362
+ }
1363
+
1364
+ dcerpc_send_pdu_cb_and_free(dce, pdu, 0, NULL);
1365
+ }
1366
+
1367
+ static int
1368
+ dcerpc_bind_async(struct dcerpc_context *dce, dcerpc_cb cb,
1369
+ void *cb_data)
1370
+ {
1371
+ struct dcerpc_pdu *pdu;
1372
+ struct smb2_pdu *smb2_pdu;
1373
+ struct smb2_ioctl_request req;
1374
+ struct smb2_iovec iov _U_;
1375
+ int offset = 0;
1376
+ struct p_cont_elem_t *pce;
1377
+
1378
+ pdu = dcerpc_allocate_pdu(dce, ENCODING_NDR, DCERPC_ENCODE, NSE_BUF_SIZE);
1379
+ if (pdu == NULL) {
1380
+ return -ENOMEM;
1381
+ }
1382
+
1383
+ pdu->hdr.rpc_vers = 5;
1384
+ pdu->hdr.rpc_vers_minor = 0;
1385
+ pdu->hdr.PTYPE = PDU_TYPE_BIND;
1386
+ pdu->hdr.pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG;
1387
+ pdu->hdr.packed_drep[0] = dce->packed_drep[0];
1388
+ pdu->hdr.frag_length = 0;
1389
+ pdu->hdr.auth_length = 0;
1390
+ pdu->bind.max_xmit_frag = 32768;
1391
+ pdu->bind.max_recv_frag = 32768;
1392
+ pdu->bind.assoc_group_id = 0;
1393
+ pdu->bind.n_context_elem = dce->smb2->ndr ? 1 : 2;
1394
+ pdu->bind.p_cont_elem = smb2_alloc_data(dce->smb2, pdu->payload,
1395
+ pdu->bind.n_context_elem * sizeof(struct p_cont_elem_t));
1396
+ if (pdu->bind.p_cont_elem == NULL) {
1397
+ smb2_set_error(dce->smb2, "Failed to allocate p_cont_elem");
1398
+ dcerpc_free_pdu(dce, pdu);
1399
+ return -ENOMEM;
1400
+ }
1401
+ pce = pdu->bind.p_cont_elem;
1402
+ if (dce->smb2->ndr == 0 || dce->smb2->ndr == 1) {
1403
+ pce->p_cont_id = 0;
1404
+ pce->n_transfer_syn = 1;
1405
+ pce->abstract_syntax = dce->syntax;
1406
+ pce->transfer_syntaxes = smb2_alloc_data(
1407
+ dce->smb2, pdu->payload,
1408
+ pce->n_transfer_syn * sizeof(struct p_cont_elem_t *));
1409
+ if (pce->transfer_syntaxes == NULL) {
1410
+ smb2_set_error(dce->smb2, "Failed to allocate transfer_syntaxes");
1411
+ dcerpc_free_pdu(dce, pdu);
1412
+ return -ENOMEM;
1413
+ }
1414
+ pce->transfer_syntaxes[0] = &ndr32_syntax;
1415
+ pce++;
1416
+ }
1417
+ if (dce->smb2->ndr == 0 || dce->smb2->ndr == 2) {
1418
+ pce->p_cont_id = 1;
1419
+ pce->n_transfer_syn = 1;
1420
+ pce->abstract_syntax = dce->syntax;
1421
+ pce->transfer_syntaxes = smb2_alloc_data(
1422
+ dce->smb2, pdu->payload,
1423
+ pce->n_transfer_syn * sizeof(struct p_cont_elem_t *));
1424
+ if (pce->transfer_syntaxes == NULL) {
1425
+ smb2_set_error(dce->smb2, "Failed to allocate transfer_syntaxes");
1426
+ dcerpc_free_pdu(dce, pdu);
1427
+ return -ENOMEM;
1428
+ }
1429
+ pce->transfer_syntaxes[0] = &ndr64_syntax;
1430
+ }
1431
+
1432
+ pdu->cb = cb;
1433
+ pdu->cb_data = cb_data;
1434
+
1435
+ iov.buf = pdu->payload;
1436
+ iov.len = NSE_BUF_SIZE;
1437
+ iov.free = NULL;
1438
+ if (dcerpc_pdu_coder(dce, pdu, &iov, &offset)) {
1439
+ dcerpc_free_pdu(dce, pdu);
1440
+ return -ENOMEM;
1441
+ }
1442
+ iov.len = offset;
1443
+
1444
+ memset(&req, 0, sizeof(struct smb2_ioctl_request));
1445
+ req.ctl_code = SMB2_FSCTL_PIPE_TRANSCEIVE;
1446
+ memcpy(req.file_id, dce->file_id, SMB2_FD_SIZE);
1447
+ req.input_count = (uint32_t)iov.len;
1448
+ req.input = iov.buf;
1449
+ req.flags = SMB2_0_IOCTL_IS_FSCTL;
1450
+
1451
+ smb2_pdu = smb2_cmd_ioctl_async(dce->smb2, &req, smb2_bind_cb, pdu);
1452
+ if (smb2_pdu == NULL) {
1453
+ dcerpc_free_pdu(dce, pdu);
1454
+ return -ENOMEM;
1455
+ }
1456
+ smb2_queue_pdu(dce->smb2, smb2_pdu);
1457
+
1458
+ return 0;
1459
+ }
1460
+
1461
+ static void
1462
+ smb2_open_cb(struct smb2_context *smb2, int status,
1463
+ void *command_data, void *private_data)
1464
+ {
1465
+ struct dcerpc_cb_data *data = private_data;
1466
+ struct smb2_create_reply *rep = command_data;
1467
+ struct dcerpc_context *dce = data->dce;
1468
+
1469
+ if (status != SMB2_STATUS_SUCCESS) {
1470
+ data->cb(dce, -nterror_to_errno(status),
1471
+ NULL, data->cb_data);
1472
+ free(data);
1473
+ return;
1474
+ }
1475
+
1476
+ memcpy(dce->file_id, rep->file_id, SMB2_FD_SIZE);
1477
+
1478
+ status = dcerpc_bind_async(dce, dcerpc_bind_cb, data);
1479
+ if (status) {
1480
+ data->cb(dce, status, NULL, data->cb_data);
1481
+ free(data);
1482
+ return;
1483
+ }
1484
+
1485
+ return;
1486
+ }
1487
+
1488
+ int
1489
+ dcerpc_open_async(struct dcerpc_context *dce, dcerpc_cb cb,
1490
+ void *cb_data)
1491
+ {
1492
+ struct smb2_create_request req;
1493
+ struct smb2_pdu *pdu;
1494
+ struct dcerpc_cb_data *data;
1495
+
1496
+ data = calloc(1, sizeof(struct dcerpc_cb_data));
1497
+ if (data == NULL) {
1498
+ smb2_set_error(dce->smb2, "Failed to allocate dcerpc callback "
1499
+ "data");
1500
+ return -ENOMEM;
1501
+ }
1502
+ data->dce = dce;
1503
+ data->cb = cb;
1504
+ data->cb_data = cb_data;
1505
+
1506
+ memset(&req, 0, sizeof(struct smb2_create_request));
1507
+ req.requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
1508
+ req.impersonation_level = SMB2_IMPERSONATION_IMPERSONATION;
1509
+ req.desired_access = SMB2_FILE_READ_DATA |
1510
+ SMB2_FILE_WRITE_DATA |
1511
+ SMB2_FILE_APPEND_DATA |
1512
+ SMB2_FILE_READ_EA |
1513
+ SMB2_FILE_READ_ATTRIBUTES |
1514
+ SMB2_FILE_WRITE_EA |
1515
+ SMB2_FILE_WRITE_ATTRIBUTES |
1516
+ SMB2_READ_CONTROL |
1517
+ SMB2_SYNCHRONIZE;
1518
+ req.file_attributes = 0;
1519
+ req.share_access = SMB2_FILE_SHARE_READ |
1520
+ SMB2_FILE_SHARE_WRITE |
1521
+ SMB2_FILE_SHARE_DELETE;
1522
+ req.create_disposition = SMB2_FILE_OPEN;
1523
+ req.create_options = 0;
1524
+ req.name = dce->path;
1525
+
1526
+ pdu = smb2_cmd_create_async(dce->smb2, &req, smb2_open_cb, data);
1527
+ if (pdu == NULL) {
1528
+ free(data);
1529
+ return -ENOMEM;
1530
+ }
1531
+ smb2_queue_pdu(dce->smb2, pdu);
1532
+
1533
+ return 0;
1534
+ }
1535
+
1536
+ const char *
1537
+ dcerpc_get_error(struct dcerpc_context *dce)
1538
+ {
1539
+ return smb2_get_error(dcerpc_get_smb2_context(dce));
1540
+ }
1541
+
1542
+ void
1543
+ dcerpc_free_data(struct dcerpc_context *dce, void *data)
1544
+ {
1545
+ smb2_free_data(dcerpc_get_smb2_context(dce), data);
1546
+ }
1547
+
1548
+ int
1549
+ dcerpc_pdu_direction(struct dcerpc_pdu *pdu)
1550
+ {
1551
+ return pdu->direction;
1552
+ }
1553
+
1554
+ int
1555
+ dcerpc_align_3264(struct dcerpc_context *ctx, int offset)
1556
+ {
1557
+ if (offset < 0) {
1558
+ return offset;
1559
+ }
1560
+
1561
+ if (ctx->tctx_id) {
1562
+ offset = (offset + 7) & ~7;
1563
+ } else {
1564
+ offset = (offset + 3) & ~3;
1565
+ }
1566
+ return offset;
1567
+ }
1568
+
1569
+ /* Used for testing. Override/force the transfer syntax. */
1570
+ void ndr_set_tctx(struct dcerpc_context *ctx, int tctx)
1571
+ {
1572
+ ctx->tctx_id = tctx;
1573
+ }
1574
+
1575
+ /* Used for testing. Override/force the transfer syntax. */
1576
+ void ndr_set_endian(struct dcerpc_pdu *pdu, int little_endian)
1577
+ {
1578
+ if (little_endian) {
1579
+ pdu->hdr.packed_drep[0] |= DCERPC_DR_LITTLE_ENDIAN;
1580
+ } else {
1581
+ pdu->hdr.packed_drep[0] &= ~DCERPC_DR_LITTLE_ENDIAN;
1582
+ }
1583
+ }
1584
+ int dcerpc_get_cr(struct dcerpc_pdu *pdu)
1585
+ {
1586
+ return pdu->is_conformance_run;
1587
+ }
1588
+
1589
+ void dcerpc_set_size_is(struct dcerpc_pdu *pdu, int size_is)
1590
+ {
1591
+ pdu->size_is = size_is;
1592
+ }
1593
+
1594
+ int dcerpc_get_size_is(struct dcerpc_pdu *pdu)
1595
+ {
1596
+ return pdu->size_is;
1597
+ }
1598
+
1599
+ void dcerpc_set_switch_is(struct dcerpc_pdu *pdu, int switch_is)
1600
+ {
1601
+ pdu->switch_is = switch_is;
1602
+ }
1603
+
1604
+ int dcerpc_get_switch_is(struct dcerpc_pdu *pdu)
1605
+ {
1606
+ return pdu->switch_is;
1607
+ }
1608
+
1609
+ void dcerpc_set_request(struct dcerpc_pdu *pdu, void *request)
1610
+ {
1611
+ pdu->request = request;
1612
+ }
1613
+
1614
+ void *dcerpc_get_request(struct dcerpc_pdu *pdu)
1615
+ {
1616
+ return pdu->request;
1617
+ }
1618
+
1619
+ /*
1620
+ * NDR
1621
+ */
1622
+ static int
1623
+ ndr_do_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1624
+ struct smb2_iovec *iov,
1625
+ int *offset, void *ptr,
1626
+ dcerpc_coder coder)
1627
+ {
1628
+ pdu->max_alignment = 1;
1629
+ pdu->is_conformance_run = 1;
1630
+ if (coder(name, ctx, pdu, iov, offset, ptr)) {
1631
+ return -1;
1632
+ }
1633
+ *offset = (*offset + (pdu->max_alignment - 1)) & ~(pdu->max_alignment - 1);
1634
+ pdu->is_conformance_run = 0;
1635
+ if (coder(name, ctx, pdu, iov, offset, ptr)) {
1636
+ return -1;
1637
+ }
1638
+ return 0;
1639
+ }
1640
+
1641
+ int
1642
+ ndr_uint32_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1643
+ struct smb2_iovec *iov, int *offset, void *ptr)
1644
+ {
1645
+ if (pdu->is_conformance_run) {
1646
+ if (pdu->max_alignment < 4) {
1647
+ pdu->max_alignment = 4;
1648
+ }
1649
+ return 0;
1650
+ }
1651
+ if (pdu->direction == DCERPC_DECODE) {
1652
+ return dcerpc_get_uint32(ctx, pdu, iov, offset, ptr);
1653
+ } else {
1654
+ return dcerpc_set_uint32(ctx, pdu, iov, offset, *(uint32_t *)ptr);
1655
+ }
1656
+ }
1657
+
1658
+ int
1659
+ ndr_uint16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1660
+ struct smb2_iovec *iov, int *offset, void *ptr)
1661
+ {
1662
+ if (pdu->is_conformance_run) {
1663
+ if (pdu->max_alignment < 2) {
1664
+ pdu->max_alignment = 2;
1665
+ }
1666
+ return 0;
1667
+ }
1668
+
1669
+ if (pdu->direction == DCERPC_DECODE) {
1670
+ return dcerpc_get_uint16(ctx, pdu, iov, offset, ptr);
1671
+ } else {
1672
+ return dcerpc_set_uint16(ctx, pdu, iov, offset, *(uint16_t *)ptr);
1673
+ }
1674
+ }
1675
+
1676
+ int
1677
+ ndr_uint8_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1678
+ struct smb2_iovec *iov, int *offset, void *ptr)
1679
+ {
1680
+ if (pdu->is_conformance_run) {
1681
+ if (pdu->max_alignment < 1) {
1682
+ pdu->max_alignment = 1;
1683
+ }
1684
+ return 0;
1685
+ }
1686
+ if (pdu->direction == DCERPC_DECODE) {
1687
+ return dcerpc_get_uint8(ctx, iov, offset, ptr);
1688
+ } else {
1689
+ return dcerpc_set_uint8(ctx, iov, offset, *(uint8_t *)ptr);
1690
+ }
1691
+
1692
+ return 0;
1693
+ }
1694
+
1695
+ /* Encode words that vary in size depending on the transport syntax */
1696
+ int
1697
+ ndr_uint3264_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1698
+ struct smb2_iovec *iov, int *offset, void *ptr)
1699
+ {
1700
+ uint32_t u32 = 0;
1701
+ uint64_t val = *(uint64_t *)ptr;
1702
+
1703
+ if (pdu->is_conformance_run) {
1704
+ if (ctx->tctx_id) {
1705
+ if (pdu->max_alignment < 8) {
1706
+ pdu->max_alignment = 8;
1707
+ }
1708
+ } else {
1709
+ if (pdu->max_alignment < 4) {
1710
+ pdu->max_alignment = 4;
1711
+ }
1712
+ }
1713
+ return 0;
1714
+ }
1715
+ if (pdu->direction == DCERPC_DECODE) {
1716
+ if (ctx->tctx_id) {
1717
+ if (dcerpc_get_uint64(ctx, pdu, iov, offset, ptr)) {
1718
+ return -1;
1719
+ }
1720
+ } else {
1721
+ if (dcerpc_get_uint32(ctx, pdu, iov, offset, &u32)) {
1722
+ return -1;
1723
+ }
1724
+ *(uint64_t *)ptr = u32;
1725
+ }
1726
+ } else {
1727
+ if (ctx->tctx_id) {
1728
+ if (dcerpc_set_uint64(ctx, pdu, iov, offset, val)) {
1729
+ return -1;
1730
+ }
1731
+ } else {
1732
+ if (dcerpc_set_uint32(ctx, pdu, iov, offset, (uint32_t)val)) {
1733
+ return -1;
1734
+ }
1735
+ }
1736
+ }
1737
+ return 0;
1738
+ }
1739
+
1740
+ static int
1741
+ ndr_conformance_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
1742
+ struct smb2_iovec *iov, int *offset, void *ptr)
1743
+ {
1744
+ uint32_t u32 = 0;
1745
+ uint64_t val = *(uint64_t *)ptr;
1746
+
1747
+ if (!pdu->is_conformance_run) {
1748
+ return 0;
1749
+ }
1750
+
1751
+ if (pdu->direction == DCERPC_DECODE) {
1752
+ if (ctx->tctx_id) {
1753
+ if (dcerpc_get_uint64(ctx, pdu, iov, offset, ptr)) {
1754
+ return -1;
1755
+ }
1756
+ } else {
1757
+ if (dcerpc_get_uint32(ctx, pdu, iov, offset, &u32)) {
1758
+ return -1;
1759
+ }
1760
+ *(uint64_t *)ptr = u32;
1761
+ }
1762
+ } else {
1763
+ if (ctx->tctx_id) {
1764
+ if (dcerpc_set_uint64(ctx, pdu, iov, offset, val)) {
1765
+ return -1;
1766
+ }
1767
+ } else {
1768
+ if (dcerpc_set_uint32(ctx, pdu, iov, offset, val)) {
1769
+ return -1;
1770
+ }
1771
+ }
1772
+ }
1773
+ return 0;
1774
+ }
1775
+
1776
+ static int
1777
+ ndr_encode_ptr(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
1778
+ struct smb2_iovec *iov,
1779
+ int *offset, void *ptr,
1780
+ enum ptr_type type, dcerpc_coder coder)
1781
+ {
1782
+ int top_level = pdu->top_level;
1783
+ uint64_t val;
1784
+
1785
+ if (pdu->is_conformance_run) {
1786
+ if (dce->tctx_id) {
1787
+ if (pdu->max_alignment < 8) {
1788
+ pdu->max_alignment = 8;
1789
+ }
1790
+ } else {
1791
+ if (pdu->max_alignment < 4) {
1792
+ pdu->max_alignment = 4;
1793
+ }
1794
+ }
1795
+ return 0;
1796
+ }
1797
+
1798
+ switch (type) {
1799
+ case PTR_REF:
1800
+ if (pdu->top_level) {
1801
+ pdu->top_level = 0;
1802
+ if (ndr_do_coder(name, dce, pdu, iov, offset, ptr, coder)) {
1803
+ return -1;
1804
+ }
1805
+ pdu->top_level = top_level;
1806
+ goto out;
1807
+ }
1808
+
1809
+ val = RPTR;
1810
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &val)) {
1811
+ return -1;
1812
+ }
1813
+ dcerpc_add_deferred_pointer(dce, pdu, (dcerpc_coder)coder, ptr);
1814
+ break;
1815
+ case PTR_FULL:
1816
+ if (ptr == NULL) {
1817
+ val = 0;
1818
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &val)) {
1819
+ return -1;
1820
+ }
1821
+ goto out;
1822
+ }
1823
+
1824
+ pdu->ptr_id++;
1825
+ val = pdu->ptr_id;
1826
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &val)) {
1827
+ return -1;
1828
+ }
1829
+ if (pdu->top_level) {
1830
+ pdu->top_level = 0;
1831
+ if (ndr_do_coder(name, dce, pdu, iov, offset, ptr, coder)) {
1832
+ return -1;
1833
+ }
1834
+ pdu->top_level = top_level;
1835
+ } else {
1836
+ dcerpc_add_deferred_pointer(dce, pdu, (dcerpc_coder)coder, ptr);
1837
+ }
1838
+ break;
1839
+ case PTR_UNIQUE:
1840
+ if (ptr == NULL) {
1841
+ val = 0;
1842
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &val)) {
1843
+ return -1;
1844
+ }
1845
+ goto out;
1846
+ }
1847
+
1848
+ val = UPTR;
1849
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &val)) {
1850
+ return -1;
1851
+ }
1852
+ if (pdu->top_level) {
1853
+ pdu->top_level = 0;
1854
+ if (ndr_do_coder(name, dce, pdu, iov, offset, ptr, coder)) {
1855
+ return -1;
1856
+ }
1857
+ pdu->top_level = top_level;
1858
+ } else {
1859
+ dcerpc_add_deferred_pointer(dce, pdu, (dcerpc_coder)coder, ptr);
1860
+ }
1861
+ break;
1862
+ }
1863
+
1864
+ out:
1865
+ if (pdu->top_level) {
1866
+ pdu->top_level = 0;
1867
+ if (dcerpc_process_deferred_pointers(dce, pdu, iov, offset)) {
1868
+ return -1;
1869
+ }
1870
+ pdu->top_level = top_level;
1871
+ }
1872
+ return 0;
1873
+ }
1874
+
1875
+ /* TODO conformance split
1876
+ * during the conformance run we need to do the alignment in all the
1877
+ coders, even for the coders that do not have any conformance data.
1878
+ */
1879
+ static int
1880
+ ndr_decode_ptr(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
1881
+ struct smb2_iovec *iov, int *offset, void *ptr,
1882
+ enum ptr_type type, dcerpc_coder coder)
1883
+ {
1884
+ int top_level = pdu->top_level;
1885
+ uint64_t p;
1886
+
1887
+ if (pdu->is_conformance_run) {
1888
+ if (!(type==PTR_REF && pdu->top_level)) {
1889
+ if (dce->tctx_id) {
1890
+ if (pdu->max_alignment < 8) {
1891
+ pdu->max_alignment = 8;
1892
+ }
1893
+ } else {
1894
+ if (pdu->max_alignment < 4) {
1895
+ pdu->max_alignment = 4;
1896
+ }
1897
+ }
1898
+ }
1899
+ return 0;
1900
+ }
1901
+
1902
+ switch (type) {
1903
+ case PTR_REF:
1904
+ if (pdu->top_level) {
1905
+ pdu->top_level = 0;
1906
+ if (ndr_do_coder(name, dce, pdu, iov, offset, ptr, coder)) {
1907
+ return -1;
1908
+ }
1909
+ pdu->top_level = top_level;
1910
+ goto out;
1911
+ }
1912
+
1913
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &p)) {
1914
+ return -1;
1915
+ }
1916
+ dcerpc_add_deferred_pointer(dce, pdu, (dcerpc_coder)coder, ptr);
1917
+ break;
1918
+ case PTR_UNIQUE:
1919
+ if (ndr_uint3264_coder("ReferentId", dce, pdu, iov, offset, &p)) {
1920
+ return -1;
1921
+ }
1922
+ if (p == 0 || ptr == NULL) {
1923
+ return 0;
1924
+ }
1925
+
1926
+ if (pdu->top_level) {
1927
+ pdu->top_level = 0;
1928
+ if (ndr_do_coder(name, dce, pdu, iov, offset, ptr, coder)) {
1929
+ return -1;
1930
+ }
1931
+ pdu->top_level = top_level;
1932
+ } else {
1933
+ dcerpc_add_deferred_pointer(dce, pdu, (dcerpc_coder)coder, ptr);
1934
+ }
1935
+ break;
1936
+ case PTR_FULL:
1937
+ /* not implemented yet */
1938
+ break;
1939
+ }
1940
+
1941
+ out:
1942
+ if (pdu->top_level) {
1943
+ pdu->top_level = 0;
1944
+ if (dcerpc_process_deferred_pointers(dce, pdu, iov, offset)) {
1945
+ return -1;
1946
+ }
1947
+ pdu->top_level = top_level;
1948
+ }
1949
+ return 0;
1950
+ }
1951
+
1952
+ int
1953
+ ndr_carray_coder(char *name, struct dcerpc_context *ctx,
1954
+ struct dcerpc_pdu *pdu,
1955
+ struct smb2_iovec *iov, int *offset,
1956
+ int num, void *ptr, int elem_size, dcerpc_coder coder)
1957
+ {
1958
+ int i;
1959
+ uint64_t p;
1960
+ uint8_t *data = ptr;
1961
+
1962
+ /* Conformance */
1963
+ p = num;
1964
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &p)) {
1965
+ return -1;
1966
+ }
1967
+ if (p != num) {
1968
+ return -1;
1969
+ }
1970
+
1971
+ /* Data */
1972
+ for (i = 0; i < p; i++) {
1973
+ if (coder(name, ctx, pdu, iov, offset, &data[i * elem_size])) {
1974
+ return -1;
1975
+ }
1976
+ }
1977
+
1978
+ return 0;
1979
+ }
1980
+
1981
+ int ndr_union_coder(char *name, struct dcerpc_context *ctx,
1982
+ struct dcerpc_pdu *pdu,
1983
+ struct smb2_iovec *iov, int *offset,
1984
+ uint32_t *switch_is, void *ptr, dcerpc_coder coder)
1985
+ {
1986
+ uint64_t p;
1987
+
1988
+ /* Conformance */
1989
+ p = *switch_is;
1990
+ if (ndr_uint3264_coder("", ctx, pdu, iov, offset, &p)) {
1991
+ return -1;
1992
+ }
1993
+ *switch_is = p;
1994
+
1995
+ /* Data */
1996
+ dcerpc_set_switch_is(pdu, p);
1997
+ if (coder(name, ctx, pdu, iov, offset, ptr)) {
1998
+ return -1;
1999
+ }
2000
+
2001
+ return 0;
2002
+ }
2003
+
2004
+ int ndr_struct_coder(char *name, struct dcerpc_context *ctx,
2005
+ struct dcerpc_pdu *pdu,
2006
+ struct smb2_iovec *iov, int *offset,
2007
+ void *ptr, dcerpc_coder coder)
2008
+ {
2009
+ return coder(name, ctx, pdu, iov, offset, ptr);
2010
+ }
2011
+
2012
+ int
2013
+ ndr_ptr_coder(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
2014
+ struct smb2_iovec *iov, int *offset, void *ptr,
2015
+ enum ptr_type type, dcerpc_coder coder)
2016
+ {
2017
+ if (pdu->direction == DCERPC_DECODE) {
2018
+ return ndr_decode_ptr(name, dce, pdu, iov, offset, ptr,
2019
+ type, coder);
2020
+ } else {
2021
+ return ndr_encode_ptr(name, dce, pdu, iov, offset, ptr,
2022
+ type, coder);
2023
+ }
2024
+ }
2025
+
2026
+ static int
2027
+ ndr_encode_utf16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2028
+ struct smb2_iovec *iov, int *offset,
2029
+ void *ptr, int nult)
2030
+ {
2031
+ struct dcerpc_utf16 *s = ptr;
2032
+ int i;
2033
+ uint64_t val;
2034
+ uint16_t zero = 0;
2035
+
2036
+ /* Conformance part */
2037
+ if (pdu->is_conformance_run) {
2038
+ if (s->utf8) {
2039
+ s->utf16 = smb2_utf8_to_utf16(s->utf8);
2040
+ } else {
2041
+ s->utf16 = smb2_utf8_to_utf16("");
2042
+ }
2043
+ if (s->utf16 == NULL) {
2044
+ return -1;
2045
+ }
2046
+
2047
+ if (nult) {
2048
+ val = s->utf16->len + 1;
2049
+ } else {
2050
+ val = s->utf16->len;
2051
+ }
2052
+ s->actual_count = (uint32_t)val;
2053
+ if (!nult) {
2054
+ if (val & 0x01) val++;
2055
+ }
2056
+ s->max_count = (uint32_t)val;
2057
+ s->offset = 0;
2058
+
2059
+ val = s->max_count;
2060
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &val)) {
2061
+ return -1;
2062
+ }
2063
+ val = s->offset;
2064
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &val)) {
2065
+ return -1;
2066
+ }
2067
+ val = s->actual_count;
2068
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &val)) {
2069
+ return -1;
2070
+ }
2071
+ if (pdu->max_alignment < 2) {
2072
+ pdu->max_alignment = 2;
2073
+ }
2074
+ return 0;
2075
+ }
2076
+
2077
+ /* Data part */
2078
+ for (i = 0; i < s->utf16->len; i++) {
2079
+ if (ndr_uint16_coder("Utf16", ctx, pdu, iov, offset, &s->utf16->val[i])) {
2080
+ return -1;
2081
+ }
2082
+ }
2083
+ if (nult) {
2084
+ if (ndr_uint16_coder("Nult", ctx, pdu, iov, offset, &zero)) {
2085
+ return -1;
2086
+ }
2087
+ }
2088
+ free(s->utf16);
2089
+ return 0;
2090
+ }
2091
+
2092
+ static int
2093
+ ndr_decode_utf16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2094
+ struct smb2_iovec *iov, int *offset,
2095
+ void *ptr, int nult)
2096
+ {
2097
+ struct dcerpc_utf16 *s = ptr;
2098
+ uint64_t val; /* Any fundament of this? */
2099
+ char *str;
2100
+ const char *tmp;
2101
+
2102
+ /* Conformance part */
2103
+ if (pdu->is_conformance_run) {
2104
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &val)) {
2105
+ return -1;
2106
+ }
2107
+ s->max_count = (uint32_t)val;
2108
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &val)) {
2109
+ return -1;
2110
+ }
2111
+ s->offset = (uint32_t)val;
2112
+ if (ndr_conformance_coder(ctx, pdu, iov, offset, &val)) {
2113
+ return -1;
2114
+ }
2115
+ s->actual_count = (uint32_t)val;
2116
+ if (pdu->max_alignment < 2) {
2117
+ pdu->max_alignment = 2;
2118
+ }
2119
+ return 0;
2120
+ }
2121
+
2122
+ /* Data part */
2123
+ if (*offset + s->actual_count * 2 > iov->len) {
2124
+ return -1;
2125
+ }
2126
+ if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
2127
+ int i, o;
2128
+ uint16_t v;
2129
+ for (i = 0; i < s->actual_count; i++) {
2130
+ o = *offset + i *2;
2131
+ if (dcerpc_get_uint16(ctx, pdu, iov, &o, &v)) {
2132
+ return -1;
2133
+ }
2134
+ *(uint16_t *)(void *)&iov->buf[*offset + i * 2] = v;
2135
+ }
2136
+ }
2137
+ tmp = smb2_utf16_to_utf8((uint16_t *)(void *)(&iov->buf[*offset]), (size_t)s->actual_count);
2138
+ *offset += (int)s->actual_count * 2;
2139
+
2140
+ str = smb2_alloc_data(ctx->smb2, pdu->payload, strlen(tmp) + 1);
2141
+ if (str == NULL) {
2142
+ free(discard_const(tmp));
2143
+ return -1;
2144
+ }
2145
+ strcat(str, tmp);
2146
+ free(discard_const(tmp));
2147
+
2148
+ s->utf8 = str;
2149
+
2150
+ return 0;
2151
+ }
2152
+
2153
+ /* ptr is char ** */
2154
+ int
2155
+ _ndr_utf16z_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2156
+ struct smb2_iovec *iov, int *offset,
2157
+ void *ptr, int nult)
2158
+ {
2159
+ struct dcerpc_utf16 **u = ptr;
2160
+ struct dcerpc_utf16 *utf16;
2161
+ const char **s = ptr;
2162
+ const char *str;
2163
+ int ret = -1;
2164
+
2165
+ if (pdu->is_conformance_run) {
2166
+ /* Swap the char * pointer to dcerpc_utf16 * */
2167
+ utf16 = calloc(1, sizeof(struct dcerpc_utf16));
2168
+ if (utf16 == NULL) {
2169
+ return -1;
2170
+ }
2171
+ utf16->utf8 = *s;
2172
+ *u = utf16;
2173
+ ptr = utf16;
2174
+ } else {
2175
+ ptr = *u;
2176
+ }
2177
+
2178
+ if (pdu->direction == DCERPC_DECODE) {
2179
+ ret = ndr_decode_utf16(ctx, pdu, iov, offset, ptr, nult);
2180
+ } else {
2181
+ ret = ndr_encode_utf16(ctx, pdu, iov, offset, ptr, nult);
2182
+ }
2183
+
2184
+ if (!pdu->is_conformance_run) {
2185
+ /* swap the pointer back */
2186
+ utf16 = *u;
2187
+ str = utf16->utf8;
2188
+ *s = str;
2189
+ free(utf16);
2190
+ }
2191
+
2192
+ return ret;
2193
+ }
2194
+
2195
+ /* Handle \0 terminated utf16 strings */
2196
+ /* ptr is char ** */
2197
+ int
2198
+ ndr_utf16z_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2199
+ struct smb2_iovec *iov, int *offset,
2200
+ void *ptr)
2201
+ {
2202
+ return _ndr_utf16z_coder(name, ctx, pdu, iov, offset, ptr, 1);
2203
+ }
2204
+
2205
+ /* Handle utf16 strings that are NOT \0 terminated */
2206
+ /* ptr is char ** */
2207
+ int
2208
+ ndr_utf16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2209
+ struct smb2_iovec *iov, int *offset,
2210
+ void *ptr)
2211
+ {
2212
+ return _ndr_utf16z_coder(name, ctx, pdu, iov, offset, ptr, 0);
2213
+ }
2214
+
2215
+ int
2216
+ ndr_uuid_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2217
+ struct smb2_iovec *iov, int *offset,
2218
+ dcerpc_uuid_t *uuid)
2219
+ {
2220
+ int i;
2221
+
2222
+ if (ndr_uint32_coder("V1", ctx, pdu, iov, offset, &uuid->v1)) {
2223
+ return -1;
2224
+ }
2225
+ if (ndr_uint16_coder("V2", ctx, pdu, iov, offset, &uuid->v2)) {
2226
+ return -1;
2227
+ }
2228
+ if (ndr_uint16_coder("V3", ctx, pdu, iov, offset, &uuid->v3)) {
2229
+ return -1;
2230
+ }
2231
+ for (i = 0; i < 8; i++) {
2232
+ if (ndr_uint8_coder("V4", ctx, pdu, iov, offset, &uuid->v4[i])) {
2233
+ return -1;
2234
+ }
2235
+ }
2236
+
2237
+ return 0;
2238
+ }
2239
+
2240
+ /**********************
2241
+ * typedef struct ndr_context_handle {
2242
+ * unsigned32 context_handle_attributes;
2243
+ * dcerpc_uuid_t context_handle_uuid;
2244
+ * } ndr_context_handle;
2245
+ **********************/
2246
+ int
2247
+ ndr_context_handle_coder(char *name, struct dcerpc_context *dce,
2248
+ struct dcerpc_pdu *pdu,
2249
+ struct smb2_iovec *iov, int *offset,
2250
+ void *ptr)
2251
+ {
2252
+ struct ndr_context_handle *handle = ptr;
2253
+
2254
+ if (ndr_uint32_coder("ContextHandleAttributes", dce, pdu, iov, offset, &handle->context_handle_attributes)) {
2255
+ return -1;
2256
+ }
2257
+ if (ndr_uuid_coder("UUID", dce, pdu, iov, offset,
2258
+ &handle->context_handle_uuid)) {
2259
+ return -1;
2260
+ }
2261
+
2262
+ return 0;
2263
+ }
2264
+
2265
+ /*
2266
+ * YAML
2267
+ */
2268
+ static void
2269
+ yaml_print_preamble(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2270
+ struct smb2_iovec *iov, int *offset)
2271
+ {
2272
+ int i;
2273
+
2274
+ for(i = 0; i < pdu->yaml_indentation; i++) {
2275
+ if (*offset + 3 < iov->len) {
2276
+ strncat((char *)&iov->buf[*offset], " ", iov->len - *offset);
2277
+ *offset += 2;
2278
+ }
2279
+ }
2280
+ if (pdu->yaml_array_prefix) {
2281
+ if (*offset + 3 < iov->len) {
2282
+ strncat((char *)&iov->buf[*offset], "- ", iov->len - *offset);
2283
+ *offset += 2;
2284
+ }
2285
+ pdu->yaml_array_prefix = 0;
2286
+ }
2287
+ }
2288
+
2289
+ int
2290
+ yamp_next_kv(struct dcerpc_pdu *pdu, struct smb2_iovec *iov, int *offset)
2291
+ {
2292
+ char *str;
2293
+
2294
+ if (pdu->yaml_key) {
2295
+ return 0;
2296
+ }
2297
+
2298
+ str = (char *)&iov->buf[*offset];
2299
+ while (iov->buf[*offset] != '\0') {
2300
+ if (iov->buf[*offset] == '\n') {
2301
+ iov->buf[(*offset)++] = 0;
2302
+ break;
2303
+ }
2304
+ (*offset)++;
2305
+ }
2306
+
2307
+ pdu->yaml_indentation = 0;
2308
+ while (*str == ' ') {
2309
+ str++;
2310
+ pdu->yaml_indentation++;
2311
+ }
2312
+
2313
+ pdu->yaml_key = str;
2314
+ str = strchr(str, ':');
2315
+ if (str == NULL) {
2316
+ pdu->yaml_val = NULL;
2317
+ return 0;
2318
+ }
2319
+ *str++ = 0;
2320
+ while (*str == ' ') {
2321
+ str++;
2322
+ }
2323
+ pdu->yaml_val = str;
2324
+
2325
+ return 0;
2326
+ }
2327
+
2328
+ static int
2329
+ yaml_uint32_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2330
+ struct smb2_iovec *iov, int *offset, void *ptr)
2331
+ {
2332
+ if (pdu->direction == DCERPC_DECODE) {
2333
+ yamp_next_kv(pdu, iov, offset);
2334
+ if (strcmp(pdu->yaml_key, name)) {
2335
+ printf("Wrong YAML key encountered for uint32. Expected %s but got %s\n",
2336
+ name, pdu->yaml_key);
2337
+ return -1;
2338
+ }
2339
+ pdu->yaml_key = NULL;
2340
+ *(uint32_t *)ptr = strtol(pdu->yaml_val, NULL, 0);
2341
+ yamp_next_kv(pdu, iov, offset);
2342
+ return 0;
2343
+ } else {
2344
+ yaml_print_preamble(ctx, pdu, iov, offset);
2345
+ if (*offset + 256 < iov->len) {
2346
+ *offset += snprintf((char *)&iov->buf[*offset], iov->len - *offset, "%s: %u\n", name, *(uint32_t *)ptr);
2347
+ }
2348
+ return 0;
2349
+ }
2350
+ }
2351
+
2352
+ static int
2353
+ yaml_carray_coder(char *name, struct dcerpc_context *ctx,
2354
+ struct dcerpc_pdu *pdu,
2355
+ struct smb2_iovec *iov, int *offset,
2356
+ int num, void *ptr, int elem_size, dcerpc_coder coder)
2357
+ {
2358
+ int i;
2359
+ uint8_t *data = ptr;
2360
+
2361
+ if (pdu->direction == DCERPC_DECODE) {
2362
+ printf("yaml carray not supported for %s\n", name);
2363
+ exit(9);
2364
+ } else {
2365
+ yaml_print_preamble(ctx, pdu, iov, offset);
2366
+ if (*offset + 256 < iov->len) {
2367
+ *offset += snprintf((char *)&iov->buf[*offset], iov->len - *offset, "%s:\n", name);
2368
+ }
2369
+
2370
+ pdu->yaml_indentation++;
2371
+ for (i = 0; i < num; i++) {
2372
+ pdu->yaml_array_prefix = 1;
2373
+ if (coder(name, ctx, pdu, iov, offset, &data[i * elem_size])) {
2374
+ return -1;
2375
+ }
2376
+ }
2377
+ pdu->yaml_indentation--;
2378
+ }
2379
+ return 0;
2380
+ }
2381
+
2382
+ static int
2383
+ yaml_union_coder(char *name, struct dcerpc_context *ctx,
2384
+ struct dcerpc_pdu *pdu,
2385
+ struct smb2_iovec *iov, int *offset,
2386
+ uint32_t *switch_is, void *ptr, dcerpc_coder coder)
2387
+ {
2388
+ int ret;
2389
+
2390
+ if (pdu->direction == DCERPC_DECODE) {
2391
+ if (strcmp(pdu->yaml_key, name)) {
2392
+ printf("Wrong YAML key encountered for union. Expected %s but got %s\n",
2393
+ name, pdu->yaml_key);
2394
+ return -1;
2395
+ }
2396
+ pdu->yaml_key = NULL;
2397
+ yamp_next_kv(pdu, iov, offset);
2398
+ name = pdu->yaml_key;
2399
+ ret = coder(name, ctx, pdu, iov, offset, ptr);
2400
+ } else {
2401
+ yaml_print_preamble(ctx, pdu, iov, offset);
2402
+ if (*offset + 256 < iov->len) {
2403
+ *offset += snprintf((char *)&iov->buf[*offset], iov->len - *offset, "%s:\n", name);
2404
+ }
2405
+
2406
+ pdu->yaml_indentation++;
2407
+ dcerpc_set_switch_is(pdu, *switch_is);
2408
+ ret = coder(name, ctx, pdu, iov, offset, ptr);
2409
+ pdu->yaml_indentation--;
2410
+ }
2411
+ return ret;
2412
+ }
2413
+
2414
+ static int
2415
+ yaml_ptr_coder(char *name, struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
2416
+ struct smb2_iovec *iov, int *offset, void *ptr,
2417
+ enum ptr_type type, dcerpc_coder coder)
2418
+ {
2419
+ if (ptr == NULL) {
2420
+ return 0;
2421
+ }
2422
+ if (pdu->direction == DCERPC_DECODE) {
2423
+ yamp_next_kv(pdu, iov, offset);
2424
+ if (strcmp(pdu->yaml_key, name)) {
2425
+ if (type == PTR_UNIQUE) {
2426
+ return 0;
2427
+ }
2428
+ printf("Wrong YAML key encountered for ptr. Expected %s but got %s\n",
2429
+ name, pdu->yaml_key);
2430
+ return -1;
2431
+ }
2432
+ return coder(name, dce, pdu, iov, offset, ptr);
2433
+ } else {
2434
+ return coder(name, dce, pdu, iov, offset, ptr);
2435
+ }
2436
+ }
2437
+
2438
+ static int
2439
+ yaml_utf16_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2440
+ struct smb2_iovec *iov, int *offset,
2441
+ void *ptr)
2442
+ {
2443
+ if (pdu->direction == DCERPC_DECODE) {
2444
+ yamp_next_kv(pdu, iov, offset);
2445
+ if (strcmp(pdu->yaml_key, name)) {
2446
+ printf("Wrong YAML key encountered for ptr. Expected %s but got %s\n",
2447
+ name, pdu->yaml_key);
2448
+ return -1;
2449
+ }
2450
+ pdu->yaml_key = NULL;
2451
+ *(char **)ptr = pdu->yaml_val;
2452
+ yamp_next_kv(pdu, iov, offset);
2453
+ return 0;
2454
+ } else {
2455
+ yaml_print_preamble(ctx, pdu, iov, offset);
2456
+ if (*offset + 256 < iov->len) {
2457
+ *offset += snprintf((char *)&iov->buf[*offset], iov->len - *offset, "%s: %s\n", name, *(char **)ptr);
2458
+ }
2459
+ return 0;
2460
+ }
2461
+ return -1;
2462
+ }
2463
+
2464
+ static int
2465
+ yaml_struct_coder(char *name, struct dcerpc_context *ctx,
2466
+ struct dcerpc_pdu *pdu,
2467
+ struct smb2_iovec *iov, int *offset,
2468
+ void *ptr, dcerpc_coder coder)
2469
+ {
2470
+ int ret;
2471
+
2472
+ if (pdu->direction == DCERPC_DECODE) {
2473
+ yamp_next_kv(pdu, iov, offset);
2474
+ if (strcmp(pdu->yaml_key, name)) {
2475
+ printf("Wrong YAML key encountered for struct. Expected %s but got %s\n",
2476
+ name, pdu->yaml_key);
2477
+ return -1;
2478
+ }
2479
+ pdu->yaml_key = NULL;
2480
+ yamp_next_kv(pdu, iov, offset);
2481
+ ret = coder(name, ctx, pdu, iov, offset, ptr);
2482
+ } else {
2483
+ yaml_print_preamble(ctx, pdu, iov, offset);
2484
+ *offset += snprintf((char *)&iov->buf[*offset], iov->len - *offset, "%s: %s\n", name, pdu->yaml_val);
2485
+ pdu->yaml_val = "";
2486
+
2487
+ pdu->yaml_indentation++;
2488
+ ret = coder(name, ctx, pdu, iov, offset, ptr);
2489
+ pdu->yaml_indentation--;
2490
+ }
2491
+ return ret;
2492
+ }
2493
+
2494
+ int
2495
+ yaml_do_coder(char *name, struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
2496
+ struct smb2_iovec *iov,
2497
+ int *offset, void *ptr,
2498
+ dcerpc_coder coder)
2499
+ {
2500
+ if (pdu->direction == DCERPC_DECODE) {
2501
+ yamp_next_kv(pdu, iov, offset);
2502
+ if (strcmp(pdu->yaml_key, name)) {
2503
+ printf("Wrong YAML key encountered for do. Expected %s but got %s\n",
2504
+ name, pdu->yaml_key);
2505
+ return -1;
2506
+ }
2507
+ return yaml_struct_coder(name,ctx, pdu, iov, offset, ptr, coder);
2508
+ } else {
2509
+ pdu->yaml_val = dcerpc_get_request(pdu) ? "Response" : "Request";
2510
+ return yaml_struct_coder(name,ctx, pdu, iov, offset, ptr, coder);
2511
+ }
2512
+ }
2513
+