@litmusio/miravo-cli-linux-x64 0.0.0-stage → 0.15.10

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 (235) hide show
  1. package/LICENSE +199 -0
  2. package/NOTICE +9 -0
  3. package/README.md +6 -2
  4. package/THIRD_PARTY_LICENSES.txt +15289 -0
  5. package/THIRD_PARTY_NOTICES.md +995 -0
  6. package/console-dist/assets/AnimatePresence-DWGUB15i.js +9 -0
  7. package/console-dist/assets/activity-DruTYzT1.js +1 -0
  8. package/console-dist/assets/api-V5Tf5xfh.js +57 -0
  9. package/console-dist/assets/arrow-up-right-DOENs04V.js +1 -0
  10. package/console-dist/assets/asset-detail-D_icTa2K.js +1 -0
  11. package/console-dist/assets/asset-detail-actions-DIYego9D.js +1 -0
  12. package/console-dist/assets/backup-power-Q84DVs_z.js +1 -0
  13. package/console-dist/assets/badge-CdRB4Nd_.js +1 -0
  14. package/console-dist/assets/boiler-s_q0j7rz.js +1 -0
  15. package/console-dist/assets/by-path-Cm2TEP7z.js +1 -0
  16. package/console-dist/assets/check-BTUv4z-H.js +1 -0
  17. package/console-dist/assets/chevron-down-CqA_2_CH.js +1 -0
  18. package/console-dist/assets/chevron-right-CVrgKBLR.js +1 -0
  19. package/console-dist/assets/chiller-r7DzAhJq.js +1 -0
  20. package/console-dist/assets/chunk-6KYCQHYJ-ga3Yekab.js +3 -0
  21. package/console-dist/assets/circle-x-BRkh0A1P.js +1 -0
  22. package/console-dist/assets/commercial-building-Cezt2R6W.js +1 -0
  23. package/console-dist/assets/compressor-ChZLMC94.js +1 -0
  24. package/console-dist/assets/console-panel-BnSjjW6l.js +1 -0
  25. package/console-dist/assets/dialog-BYkdndf9.js +1 -0
  26. package/console-dist/assets/district-heating-By_6QdGQ.js +1 -0
  27. package/console-dist/assets/dom-BxZbg3NX.js +1 -0
  28. package/console-dist/assets/download-CvjDP5mu.js +1 -0
  29. package/console-dist/assets/fira-code-cyrillic-ext-wght-normal-DhYMMuQd.woff2 +0 -0
  30. package/console-dist/assets/fira-code-cyrillic-wght-normal-Y3u8pIsh.woff2 +0 -0
  31. package/console-dist/assets/fira-code-greek-ext-wght-normal-wWus70Ix.woff2 +0 -0
  32. package/console-dist/assets/fira-code-greek-wght-normal-B2SviObF.woff2 +0 -0
  33. package/console-dist/assets/fira-code-latin-ext-wght-normal-Dvfvaomy.woff2 +0 -0
  34. package/console-dist/assets/fira-code-latin-wght-normal-CHoedHDv.woff2 +0 -0
  35. package/console-dist/assets/fira-code-symbols2-wght-normal-CE6EOz_n.woff2 +0 -0
  36. package/console-dist/assets/floor-page-DIUJBBhh.js +1 -0
  37. package/console-dist/assets/floor-page-E-0txA4z.css +1 -0
  38. package/console-dist/assets/format-YLUJ7AXt.js +1 -0
  39. package/console-dist/assets/genset-C6_EUoFo.js +1 -0
  40. package/console-dist/assets/index-BrlZMcSu.js +15 -0
  41. package/console-dist/assets/index-eZjXAdLh.css +2 -0
  42. package/console-dist/assets/loader-circle-w3T2fxvn.js +1 -0
  43. package/console-dist/assets/login-CpbaxAVs.js +136 -0
  44. package/console-dist/assets/not-found-CZjkulKD.js +1 -0
  45. package/console-dist/assets/pharma-cleanroom-CT2M_Mbh.js +1 -0
  46. package/console-dist/assets/preload-helper-7y9sWmk5.js +1 -0
  47. package/console-dist/assets/react-DRt7cCXI.js +1 -0
  48. package/console-dist/assets/rolldown-runtime-BWaJ3C7D.js +1 -0
  49. package/console-dist/assets/rtu-ByogcRPI.js +1 -0
  50. package/console-dist/assets/runtime-link-D88Db2wY.js +1 -0
  51. package/console-dist/assets/schibsted-grotesk-latin-ext-wght-normal-hsMS0n0O.woff2 +0 -0
  52. package/console-dist/assets/schibsted-grotesk-latin-wght-normal-Bb8VGrTG.woff2 +0 -0
  53. package/console-dist/assets/server-B0q1NVkV.js +1 -0
  54. package/console-dist/assets/shallow-mIK1Qu8X.js +1 -0
  55. package/console-dist/assets/smart-factory-gfMWfMWM.js +1 -0
  56. package/console-dist/assets/source-host-miravo-BW-SKMTe.js +1 -0
  57. package/console-dist/assets/stages-EYRT12Yp.js +1 -0
  58. package/console-dist/assets/status-DQYLUbXs.js +1 -0
  59. package/console-dist/assets/tank-Btg5piqB.js +1 -0
  60. package/console-dist/assets/tooltip-Dfmuq2yz.js +1 -0
  61. package/console-dist/assets/trash-2-BAh5-hxl.js +1 -0
  62. package/console-dist/assets/triangle-alert-3Ab-dBrN.js +1 -0
  63. package/console-dist/assets/use-engine-command-mutation-BmSUqrCp.js +1 -0
  64. package/console-dist/assets/use-transition-navigate-DIfW9U34.js +2 -0
  65. package/console-dist/assets/useQuery-yLeYL5Es.js +1 -0
  66. package/console-dist/assets/utils-D6wrZy-b.js +1 -0
  67. package/console-dist/assets/validation-DEb_QCoK.js +1 -0
  68. package/console-dist/assets/vendor-charts-Bquh2dWE.js +56 -0
  69. package/console-dist/assets/vendor-table-5YnGQUhO.js +4 -0
  70. package/console-dist/assets/vendor-ui-BGeFlRLR.js +1 -0
  71. package/console-dist/assets/water-treatment-DbSVGWoj.js +1 -0
  72. package/console-dist/icon.png +0 -0
  73. package/console-dist/index.html +53 -0
  74. package/console-dist/miravo-logo.webp +0 -0
  75. package/licenses/EPL-2.0.txt +80 -0
  76. package/licenses/GCC-exception-3.1.txt +33 -0
  77. package/licenses/GPL-2.0-only.txt +117 -0
  78. package/licenses/GPL-3.0-only.txt +232 -0
  79. package/licenses/LGPL-2.1-only.txt +176 -0
  80. package/licenses/MPL-2.0.txt +373 -0
  81. package/licenses/OFL-1.1.txt +93 -0
  82. package/licenses/overrides/@headlessui+vue@1.7.23.txt +24 -0
  83. package/licenses/overrides/@next+env@16.4.6.txt +24 -0
  84. package/licenses/overrides/@radix-ui+react-compose-refs@1.1.2.txt +24 -0
  85. package/licenses/overrides/@radix-ui+react-context@1.1.2.txt +24 -0
  86. package/licenses/overrides/@radix-ui+react-direction@1.1.1.txt +24 -0
  87. package/licenses/overrides/@radix-ui+react-id@1.1.1.txt +24 -0
  88. package/licenses/overrides/@radix-ui+react-use-callback-ref@1.1.1.txt +24 -0
  89. package/licenses/overrides/@radix-ui+react-use-escape-keydown@1.1.1.txt +24 -0
  90. package/licenses/overrides/@radix-ui+react-use-layout-effect@1.1.1.txt +24 -0
  91. package/licenses/overrides/@radix-ui+react-use-rect@1.1.1.txt +24 -0
  92. package/licenses/overrides/@radix-ui+react-use-size@1.1.1.txt +24 -0
  93. package/licenses/overrides/@radix-ui+rect@1.1.1.txt +24 -0
  94. package/licenses/overrides/@replit+codemirror-css-color-picker@6.3.0.txt +6 -0
  95. package/licenses/overrides/@scalar+openapi-types@0.8.0.txt +24 -0
  96. package/licenses/overrides/@scalar+openapi-types@0.9.10.txt +24 -0
  97. package/licenses/overrides/@scalar+openapi-types@0.9.7.txt +24 -0
  98. package/licenses/overrides/@scalar+openapi-types@0.9.9.txt +24 -0
  99. package/licenses/overrides/@scalar+postman-to-openapi@0.7.1.txt +24 -0
  100. package/licenses/overrides/@scalar+schemas@0.19.0.txt +24 -0
  101. package/licenses/overrides/@scalar+workspace-store@0.46.3.txt +24 -0
  102. package/licenses/overrides/@scalar+workspace-store@0.75.0.txt +24 -0
  103. package/licenses/overrides/assert-plus@1.0.0.txt +24 -0
  104. package/licenses/overrides/client-only@0.0.1.txt +24 -0
  105. package/licenses/overrides/embla-carousel-react@8.6.0.txt +24 -0
  106. package/licenses/overrides/embla-carousel-reactive-utils@8.6.0.txt +24 -0
  107. package/licenses/overrides/embla-carousel@8.6.0.txt +24 -0
  108. package/licenses/overrides/fastdom@1.0.12.txt +12 -0
  109. package/licenses/overrides/precond@0.2.3.txt +22 -0
  110. package/licenses/overrides/react-remove-scroll-bar@2.3.8.txt +24 -0
  111. package/licenses/overrides/strictdom@1.0.1.txt +12 -0
  112. package/licenses/overrides/victory-vendor@36.9.2.txt +33 -0
  113. package/licenses/runtime/Bun-1.4.3-LICENSE.md +85 -0
  114. package/licenses/runtime/ICU-78.1-LICENSE.txt +568 -0
  115. package/licenses/runtime/bun-components/boringssl.txt +238 -0
  116. package/licenses/runtime/bun-components/brotli.txt +19 -0
  117. package/licenses/runtime/bun-components/c-ares.txt +24 -0
  118. package/licenses/runtime/bun-components/highway.txt +371 -0
  119. package/licenses/runtime/bun-components/libarchive.txt +65 -0
  120. package/licenses/runtime/bun-components/libbase64.txt +28 -0
  121. package/licenses/runtime/bun-components/libdeflate.txt +22 -0
  122. package/licenses/runtime/bun-components/libjpeg-turbo.txt +147 -0
  123. package/licenses/runtime/bun-components/libspng.txt +25 -0
  124. package/licenses/runtime/bun-components/libuv.txt +19 -0
  125. package/licenses/runtime/bun-components/libwebp.txt +30 -0
  126. package/licenses/runtime/bun-components/llvm.txt +311 -0
  127. package/licenses/runtime/bun-components/lol-html.txt +27 -0
  128. package/licenses/runtime/bun-components/ls-hpack.txt +21 -0
  129. package/licenses/runtime/bun-components/ls-qpack.txt +21 -0
  130. package/licenses/runtime/bun-components/lsquic-chrome.txt +32 -0
  131. package/licenses/runtime/bun-components/lsquic.txt +21 -0
  132. package/licenses/runtime/bun-components/mimalloc.txt +21 -0
  133. package/licenses/runtime/bun-components/picohttpparser.txt +24 -0
  134. package/licenses/runtime/bun-components/simdutf-apache.txt +201 -0
  135. package/licenses/runtime/bun-components/simdutf-mit.txt +18 -0
  136. package/licenses/runtime/bun-components/tigerbeetle.txt +177 -0
  137. package/licenses/runtime/bun-components/tinycc.txt +504 -0
  138. package/licenses/runtime/bun-components/typescript-go.txt +55 -0
  139. package/licenses/runtime/bun-components/usockets.txt +201 -0
  140. package/licenses/runtime/bun-components/uucode.txt +30 -0
  141. package/licenses/runtime/bun-components/uwebsockets.txt +201 -0
  142. package/licenses/runtime/bun-components/xxhash.txt +31 -0
  143. package/licenses/runtime/bun-components/zlib-ng.txt +19 -0
  144. package/licenses/runtime/bun-components/zstd-copying.txt +339 -0
  145. package/licenses/runtime/bun-components/zstd.txt +30 -0
  146. package/licenses/runtime/musl-1.2.6-COPYRIGHT.txt +193 -0
  147. package/miravo +4 -0
  148. package/native/S7-NOTICES.txt +11 -0
  149. package/native/miravo-s7.node +0 -0
  150. package/native/s7-source/CMakeLists.txt +23 -0
  151. package/native/s7-source/NODE-SNAP7-LICENSE +24 -0
  152. package/native/s7-source/addon.cpp +124 -0
  153. package/native/s7-source/bridge.cpp +150 -0
  154. package/native/s7-source/node-api-headers/LICENSE +21 -0
  155. package/native/s7-source/node-api-headers/include/js_native_api.h +591 -0
  156. package/native/s7-source/node-api-headers/include/js_native_api_types.h +213 -0
  157. package/native/s7-source/node-api-headers/include/node_api.h +265 -0
  158. package/native/s7-source/node-api-headers/include/node_api_types.h +58 -0
  159. package/native/s7-source/node-api-windows.h +78 -0
  160. package/native/s7-source/snap7/HISTORY.txt +277 -0
  161. package/native/s7-source/snap7/gpl.txt +674 -0
  162. package/native/s7-source/snap7/lgpl-3.0.txt +165 -0
  163. package/native/s7-source/snap7/src/core/miravo_request_validation.h +72 -0
  164. package/native/s7-source/snap7/src/core/s7_client.cpp +503 -0
  165. package/native/s7-source/snap7/src/core/s7_client.h +104 -0
  166. package/native/s7-source/snap7/src/core/s7_firmware.h +1256 -0
  167. package/native/s7-source/snap7/src/core/s7_isotcp.cpp +541 -0
  168. package/native/s7-source/snap7/src/core/s7_isotcp.h +271 -0
  169. package/native/s7-source/snap7/src/core/s7_micro_client.cpp +3328 -0
  170. package/native/s7-source/snap7/src/core/s7_micro_client.h +364 -0
  171. package/native/s7-source/snap7/src/core/s7_partner.cpp +1178 -0
  172. package/native/s7-source/snap7/src/core/s7_partner.h +284 -0
  173. package/native/s7-source/snap7/src/core/s7_peer.cpp +121 -0
  174. package/native/s7-source/snap7/src/core/s7_peer.h +58 -0
  175. package/native/s7-source/snap7/src/core/s7_server.cpp +2161 -0
  176. package/native/s7-source/snap7/src/core/s7_server.h +261 -0
  177. package/native/s7-source/snap7/src/core/s7_text.cpp +788 -0
  178. package/native/s7-source/snap7/src/core/s7_text.h +49 -0
  179. package/native/s7-source/snap7/src/core/s7_types.h +1066 -0
  180. package/native/s7-source/snap7/src/lib/snap7.def +129 -0
  181. package/native/s7-source/snap7/src/lib/snap7_libmain.cpp +1196 -0
  182. package/native/s7-source/snap7/src/lib/snap7_libmain.h +201 -0
  183. package/native/s7-source/snap7/src/sys/snap_msgsock.cpp +958 -0
  184. package/native/s7-source/snap7/src/sys/snap_msgsock.h +339 -0
  185. package/native/s7-source/snap7/src/sys/snap_platform.h +152 -0
  186. package/native/s7-source/snap7/src/sys/snap_sysutils.cpp +73 -0
  187. package/native/s7-source/snap7/src/sys/snap_sysutils.h +39 -0
  188. package/native/s7-source/snap7/src/sys/snap_tcpsrvr.cpp +487 -0
  189. package/native/s7-source/snap7/src/sys/snap_tcpsrvr.h +247 -0
  190. package/native/s7-source/snap7/src/sys/snap_threads.cpp +162 -0
  191. package/native/s7-source/snap7/src/sys/snap_threads.h +45 -0
  192. package/native/s7-source/snap7/src/sys/sol_threads.h +208 -0
  193. package/native/s7-source/snap7/src/sys/unix_threads.h +228 -0
  194. package/native/s7-source/snap7/src/sys/win_threads.h +159 -0
  195. package/nodesets/.ignore +1 -0
  196. package/nodesets/1.02/FTNIR.NodeSet2.xml +819 -0
  197. package/nodesets/1.02/Opc.Ua.Adi.NodeSet2.xml +8301 -0
  198. package/nodesets/1.02/Opc.Ua.Di.NodeSet2.xml +1785 -0
  199. package/nodesets/Opc.ISA95.NodeSet2.xml +3589 -0
  200. package/nodesets/Opc.Ua.AMB.NodeSet2.xml +1395 -0
  201. package/nodesets/Opc.Ua.Adi.NodeSet2.xml +8301 -0
  202. package/nodesets/Opc.Ua.Adi.Types.xsd +104 -0
  203. package/nodesets/Opc.Ua.AutoID.NodeSet2.xml +6062 -0
  204. package/nodesets/Opc.Ua.CNC.NodeSet.xml +15875 -0
  205. package/nodesets/Opc.Ua.CommercialKitchenEquipment.NodeSet2.xml +12096 -0
  206. package/nodesets/Opc.Ua.Di.NodeSet2.xml +6042 -0
  207. package/nodesets/Opc.Ua.Di.Types.xsd +161 -0
  208. package/nodesets/Opc.Ua.Eumabois.Nodeset2.xml +2483 -0
  209. package/nodesets/Opc.Ua.Gds.NodeSet2.xml +8282 -0
  210. package/nodesets/Opc.Ua.Glass.NodeSet2.xml +5100 -0
  211. package/nodesets/Opc.Ua.IA.NodeSet2.xml +1782 -0
  212. package/nodesets/Opc.Ua.IOLink.NodeSet2.xml +4374 -0
  213. package/nodesets/Opc.Ua.IOLinkIODD.NodeSet2.xml +139 -0
  214. package/nodesets/Opc.Ua.IRDI.NodeSet2.xml +2243 -0
  215. package/nodesets/Opc.Ua.Ijt.Base.NodeSet2.xml +19459 -0
  216. package/nodesets/Opc.Ua.Ijt.Tightening.NodeSet2.xml +883 -0
  217. package/nodesets/Opc.Ua.LADS.NodeSet2.xml +7086 -0
  218. package/nodesets/Opc.Ua.MachineTool.NodeSet2.xml +7884 -0
  219. package/nodesets/Opc.Ua.MachineVision.NodeSet2.xml +17324 -0
  220. package/nodesets/Opc.Ua.Machinery.Jobs.Nodeset2.xml +1249 -0
  221. package/nodesets/Opc.Ua.Machinery.NodeSet2.xml +2099 -0
  222. package/nodesets/Opc.Ua.Machinery.ProcessValues.NodeSet2.xml +1858 -0
  223. package/nodesets/Opc.Ua.Machinery_Result.NodeSet2.xml +2640 -0
  224. package/nodesets/Opc.Ua.MetalForming.NodeSet2.xml +1577 -0
  225. package/nodesets/Opc.Ua.NodeSet2.xml +81975 -0
  226. package/nodesets/Opc.Ua.PADIM.NodeSet2.xml +14131 -0
  227. package/nodesets/Opc.Ua.PackML.NodeSet2.xml +3030 -0
  228. package/nodesets/Opc.Ua.Robotics.NodeSet2.xml +7409 -0
  229. package/nodesets/Opc.Ua.Scales.NodeSet2.xml +15817 -0
  230. package/nodesets/Opc.Ua.Types.bsd +3499 -0
  231. package/nodesets/Opc.Ua.Weihenstephan.NodeSet2.xml +821 -0
  232. package/nodesets/Opc.Ua.Woodworking.NodeSet2.xml +17831 -0
  233. package/nodesets/UANodeSet.xsd +497 -0
  234. package/nodesets/opc.ua.isa95-jobcontrol.nodeset2.xml +4594 -0
  235. package/package.json +37 -4
@@ -0,0 +1,541 @@
1
+ /*=============================================================================|
2
+ | PROJECT SNAP7 1.3.0 |
3
+ |==============================================================================|
4
+ | Copyright (C) 2013, 2015 Davide Nardella |
5
+ | All rights reserved. |
6
+ |==============================================================================|
7
+ | SNAP7 is free software: you can redistribute it and/or modify |
8
+ | it under the terms of the Lesser GNU General Public License as published by |
9
+ | the Free Software Foundation, either version 3 of the License, or |
10
+ | (at your option) any later version. |
11
+ | |
12
+ | It means that you can distribute your commercial software linked with |
13
+ | SNAP7 without the requirement to distribute the source code of your |
14
+ | application and without the requirement that your application be itself |
15
+ | distributed under LGPL. |
16
+ | |
17
+ | SNAP7 is distributed in the hope that it will be useful, |
18
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
+ | Lesser GNU General Public License for more details. |
21
+ | |
22
+ | You should have received a copy of the GNU General Public License and a |
23
+ | copy of Lesser GNU General Public License along with Snap7. |
24
+ | If not, see http://www.gnu.org/licenses/ |
25
+ |=============================================================================*/
26
+ #include "s7_isotcp.h"
27
+ //---------------------------------------------------------------------------
28
+ TIsoTcpSocket::TIsoTcpSocket()
29
+ {
30
+ RecvTimeout = 3000; // Some old equipments are a bit slow to answer....
31
+ RemotePort = isoTcpPort;
32
+ // These fields should be $0000 and in any case RFC says that they are not considered.
33
+ // But some equipment...need a non zero value for the source reference.
34
+ DstRef = 0x0000;
35
+ SrcRef = 0x0100;
36
+ // PDU size requested
37
+ IsoPDUSize =1024;
38
+ IsoMaxFragments=MaxIsoFragments;
39
+ LastIsoError=0;
40
+ }
41
+ //---------------------------------------------------------------------------
42
+ TIsoTcpSocket::~TIsoTcpSocket()
43
+ {
44
+ }
45
+ //---------------------------------------------------------------------------
46
+ int TIsoTcpSocket::CheckPDU(void *pPDU, u_char PduTypeExpected)
47
+ {
48
+ PIsoHeaderInfo Info;
49
+ int Size;
50
+ ClrIsoError();
51
+ if (pPDU!=0)
52
+ {
53
+ Info = PIsoHeaderInfo(pPDU);
54
+ Size = PDUSize(pPDU);
55
+ // Performs check
56
+ if (( Size<7 ) || ( Size>IsoPayload_Size ) || // Checks RFC 1006 header length
57
+ ( Info->HLength<sizeof( TCOTP_DT )-1 ) || // Checks ISO 8073 header length
58
+ ( Info->PDUType!=PduTypeExpected)) // Checks PDU Type
59
+ return SetIsoError(errIsoInvalidPDU);
60
+ else
61
+ return noError;
62
+ }
63
+ else
64
+ return SetIsoError(errIsoNullPointer);
65
+ }
66
+ //---------------------------------------------------------------------------
67
+ int TIsoTcpSocket::SetIsoError(int Error)
68
+ {
69
+ LastIsoError = Error | LastTcpError;
70
+ return LastIsoError;
71
+ }
72
+ //---------------------------------------------------------------------------
73
+ void TIsoTcpSocket::ClrIsoError()
74
+ {
75
+ LastIsoError=0;
76
+ LastTcpError=0;
77
+ }
78
+ //---------------------------------------------------------------------------
79
+ int TIsoTcpSocket::BuildControlPDU()
80
+ {
81
+ int ParLen, IsoLen;
82
+
83
+ ClrIsoError();
84
+ FControlPDU.COTP.Params.PduSizeCode=0xC0; // code that identifies TPDU size
85
+ FControlPDU.COTP.Params.PduSizeLen =0x01; // 1 byte this field
86
+ switch(IsoPDUSize)
87
+ {
88
+ case 128:
89
+ FControlPDU.COTP.Params.PduSizeVal =0x07;
90
+ break;
91
+ case 256:
92
+ FControlPDU.COTP.Params.PduSizeVal =0x08;
93
+ break;
94
+ case 512:
95
+ FControlPDU.COTP.Params.PduSizeVal =0x09;
96
+ break;
97
+ case 1024:
98
+ FControlPDU.COTP.Params.PduSizeVal =0x0A;
99
+ break;
100
+ case 2048:
101
+ FControlPDU.COTP.Params.PduSizeVal =0x0B;
102
+ break;
103
+ case 4096:
104
+ FControlPDU.COTP.Params.PduSizeVal =0x0C;
105
+ break;
106
+ case 8192:
107
+ FControlPDU.COTP.Params.PduSizeVal =0x0D;
108
+ break;
109
+ default:
110
+ FControlPDU.COTP.Params.PduSizeVal =0x0B; // Our Default
111
+ };
112
+ // Build TSAPs
113
+ FControlPDU.COTP.Params.TSAP[0]=0xC1; // code that identifies source TSAP
114
+ FControlPDU.COTP.Params.TSAP[1]=2; // source TSAP Len
115
+ FControlPDU.COTP.Params.TSAP[2]=(SrcTSap>>8) & 0xFF; // HI part
116
+ FControlPDU.COTP.Params.TSAP[3]=SrcTSap & 0xFF; // LO part
117
+
118
+ FControlPDU.COTP.Params.TSAP[4]=0xC2; // code that identifies dest TSAP
119
+ FControlPDU.COTP.Params.TSAP[5]=2; // dest TSAP Len
120
+ FControlPDU.COTP.Params.TSAP[6]=(DstTSap>>8) & 0xFF; // HI part
121
+ FControlPDU.COTP.Params.TSAP[7]=DstTSap & 0xFF; // LO part
122
+
123
+ // Params length
124
+ ParLen=11; // 2 Src TSAP (Code+field Len) +
125
+ // 2 Src TSAP len +
126
+ // 2 Dst TSAP (Code+field Len) +
127
+ // 2 Src TSAP len +
128
+ // 3 PDU size (Code+field Len+Val) = 11
129
+ // Telegram length
130
+ IsoLen=sizeof(TTPKT)+ // TPKT Header
131
+ 7 + // COTP Header Size without params
132
+ ParLen; // COTP params
133
+
134
+ FControlPDU.TPKT.Version =isoTcpVersion;
135
+ FControlPDU.TPKT.Reserved =0;
136
+ FControlPDU.TPKT.HI_Lenght=0; // Connection Telegram size cannot exced 255 bytes, so
137
+ // this field is always 0
138
+ FControlPDU.TPKT.LO_Lenght=IsoLen;
139
+
140
+ FControlPDU.COTP.HLength =ParLen + 6; // <-- 6 = 7 - 1 (COTP Header size - 1)
141
+ FControlPDU.COTP.PDUType =pdu_type_CR; // Connection Request
142
+ FControlPDU.COTP.DstRef =DstRef; // Destination reference
143
+ FControlPDU.COTP.SrcRef =SrcRef; // Source reference
144
+ FControlPDU.COTP.CO_R =0x00; // Class + Option : RFC0983 states that it must be always 0x40
145
+ // but for some equipment (S7) must be 0 in disaccord of specifications !!!
146
+ return noError;
147
+ }
148
+ //---------------------------------------------------------------------------
149
+ int TIsoTcpSocket::PDUSize(void *pPDU)
150
+ {
151
+ return PIsoHeaderInfo(pPDU)->TPKT.HI_Lenght*256+PIsoHeaderInfo( pPDU )->TPKT.LO_Lenght;
152
+ }
153
+ //---------------------------------------------------------------------------
154
+ void TIsoTcpSocket::IsoParsePDU(TIsoControlPDU pdu)
155
+ {
156
+ // Currently we accept a connection with any kind of src/dst tsap
157
+ // Override to implement special filters.
158
+ }
159
+ //---------------------------------------------------------------------------
160
+ int TIsoTcpSocket::IsoConfirmConnection(u_char PDUType)
161
+ {
162
+ PIsoControlPDU CPDU = PIsoControlPDU(&PDU);
163
+ u_short TempRef;
164
+
165
+ ClrIsoError();
166
+ PDU.COTP.PDUType=PDUType;
167
+ // Exchange SrcRef<->DstRef, not strictly needed by COTP 8073 but S7PLC as client needs it.
168
+ TempRef=CPDU->COTP.DstRef;
169
+ CPDU->COTP.DstRef=CPDU->COTP.SrcRef;
170
+ CPDU->COTP.SrcRef=0x0100;//TempRef;
171
+
172
+ return SendPacket(&PDU,PDUSize(&PDU));
173
+ }
174
+ //---------------------------------------------------------------------------
175
+ void TIsoTcpSocket::FragmentSkipped(int Size)
176
+ {
177
+ // override for log purpose
178
+ }
179
+ //---------------------------------------------------------------------------
180
+ int TIsoTcpSocket::isoConnect()
181
+ {
182
+ pbyte TmpControlPDU;
183
+ PIsoControlPDU ControlPDU;
184
+ u_int Length;
185
+ int Result;
186
+
187
+ // Build the default connection telegram
188
+ BuildControlPDU();
189
+ ControlPDU =&FControlPDU;
190
+
191
+ // Checks the format
192
+ Result =CheckPDU(ControlPDU, pdu_type_CR);
193
+ if (Result!=0)
194
+ return Result;
195
+
196
+ Result =SckConnect();
197
+ if (Result==noError)
198
+ {
199
+ // Calcs the length
200
+ Length =PDUSize(ControlPDU);
201
+ // Send connection telegram
202
+ SendPacket(ControlPDU, Length);
203
+ if (LastTcpError==0)
204
+ {
205
+ TmpControlPDU = pbyte(ControlPDU);
206
+ // Receives TPKT header (4 bytes)
207
+ RecvPacket(TmpControlPDU, sizeof(TTPKT));
208
+ if (LastTcpError==0)
209
+ {
210
+ // Calc the packet length
211
+ Length =PDUSize(TmpControlPDU);
212
+ // Check if it fits in the buffer and if it's greater then TTPKT size
213
+ if ((Length<=sizeof(TIsoControlPDU)) && (Length>sizeof(TTPKT)))
214
+ {
215
+ // Points to COTP
216
+ TmpControlPDU+=sizeof(TTPKT);
217
+ Length -= sizeof(TTPKT);
218
+ // Receives remainin bytes 4 bytes after
219
+ RecvPacket(TmpControlPDU, Length);
220
+ if (LastTcpError==0)
221
+ {
222
+ // Finally checks the Connection Confirm telegram
223
+ Result =CheckPDU(ControlPDU, pdu_type_CC);
224
+ if (Result!=0)
225
+ LastIsoError=Result;
226
+ }
227
+ else
228
+ Result =SetIsoError(errIsoRecvPacket);
229
+ }
230
+ else
231
+ Result =SetIsoError(errIsoInvalidPDU);
232
+ }
233
+ else
234
+ Result =SetIsoError(errIsoRecvPacket);
235
+ // Flush buffer
236
+ if (Result!=0)
237
+ Purge();
238
+ }
239
+ else
240
+ Result =SetIsoError(errIsoSendPacket);
241
+
242
+ if (Result!=0)
243
+ SckDisconnect();
244
+ }
245
+ return Result;
246
+ }
247
+ //---------------------------------------------------------------------------
248
+ int TIsoTcpSocket::isoSendBuffer(void *Data, int Size)
249
+ {
250
+ int Result;
251
+ u_int IsoSize;
252
+
253
+ ClrIsoError();
254
+ // Total Size = Size + Header Size
255
+ IsoSize =Size+DataHeaderSize;
256
+ // Checks the length
257
+ if ((IsoSize>0) && (IsoSize<=IsoFrameSize))
258
+ {
259
+ // Builds the header
260
+ Result =0;
261
+ // TPKT
262
+ PDU.TPKT.Version = isoTcpVersion;
263
+ PDU.TPKT.Reserved = 0;
264
+ PDU.TPKT.HI_Lenght= (u_short(IsoSize)>> 8) & 0xFF;
265
+ PDU.TPKT.LO_Lenght= u_short(IsoSize) & 0xFF;
266
+ // COPT
267
+ PDU.COTP.HLength =sizeof(TCOTP_DT)-1;
268
+ PDU.COTP.PDUType =pdu_type_DT;
269
+ PDU.COTP.EoT_Num =pdu_EoT;
270
+ // Fill payload
271
+ if (Data!=0) // Data=null ==> use internal buffer PDU.Payload
272
+ memcpy(&PDU.Payload, Data, Size);
273
+ // Send over TCP/IP
274
+ SendPacket(&PDU, IsoSize);
275
+
276
+ if (LastTcpError!=0)
277
+ Result =SetIsoError(errIsoSendPacket);
278
+ }
279
+ else
280
+ Result =SetIsoError(errIsoInvalidDataSize );
281
+ return Result;
282
+ }
283
+ //---------------------------------------------------------------------------
284
+ int TIsoTcpSocket::isoRecvBuffer(void *Data, int & Size)
285
+ {
286
+ int Result;
287
+
288
+ ClrIsoError();
289
+ Size =0;
290
+ Result =isoRecvPDU(&PDU);
291
+ if (Result==0)
292
+ {
293
+ Size =PDUSize( &PDU )-DataHeaderSize;
294
+ if (Data!=0) // Data=NULL ==> a child will consume directly PDY.Payload
295
+ memcpy(Data, &PDU.Payload, Size);
296
+ }
297
+ return Result;
298
+ }
299
+ //---------------------------------------------------------------------------
300
+ int TIsoTcpSocket::isoExchangeBuffer(void *Data, int &Size)
301
+ {
302
+ int Result;
303
+
304
+ ClrIsoError();
305
+ Result =isoSendBuffer(Data, Size);
306
+ if (Result==0)
307
+ Result =isoRecvBuffer(Data, Size);
308
+ return Result;
309
+ }
310
+ //---------------------------------------------------------------------------
311
+ bool TIsoTcpSocket::IsoPDUReady()
312
+ {
313
+ ClrIsoError();
314
+ return PacketReady(sizeof(TCOTP_DT));
315
+ }
316
+ //---------------------------------------------------------------------------
317
+ int TIsoTcpSocket::isoDisconnect(bool OnlyTCP)
318
+ {
319
+ int Result;
320
+
321
+ ClrIsoError();
322
+ if (Connected)
323
+ Purge(); // Flush pending
324
+ LastIsoError=0;
325
+ // OnlyTCP true -> Disconnect Request telegram is not required : only TCP disconnection
326
+ if (!OnlyTCP)
327
+ {
328
+ // if we are connected -> we have a valid connection telegram
329
+ if (Connected)
330
+ FControlPDU.COTP.PDUType =pdu_type_DR;
331
+ // Checks the format
332
+ Result =CheckPDU(&FControlPDU, pdu_type_DR);
333
+ if (Result!=0)
334
+ return Result;
335
+ // Sends Disconnect request
336
+ SendPacket(&FControlPDU, PDUSize(&FControlPDU));
337
+ if (LastTcpError!=0)
338
+ {
339
+ Result =SetIsoError(errIsoSendPacket);
340
+ return Result;
341
+ }
342
+ }
343
+ // TCP disconnect
344
+ SckDisconnect();
345
+ if (LastTcpError!=0)
346
+ Result =SetIsoError(errIsoDisconnect);
347
+ else
348
+ Result =0;
349
+
350
+ return Result;
351
+ }
352
+ //---------------------------------------------------------------------------
353
+ int TIsoTcpSocket::isoSendPDU(PIsoDataPDU Data)
354
+ {
355
+ int Result;
356
+
357
+ ClrIsoError();
358
+ Result=CheckPDU(Data,pdu_type_DT);
359
+ if (Result==0)
360
+ {
361
+ SendPacket(Data,PDUSize(Data));
362
+ if (LastTcpError!=0)
363
+ Result=SetIsoError(errIsoSendPacket);
364
+ }
365
+ return Result;
366
+ }
367
+ //------------------------------------------------------------------------------
368
+ int TIsoTcpSocket::isoRecvFragment(void *From, int Max, int &Size, bool &EoT)
369
+ {
370
+ int DataLength;
371
+
372
+ Size =0;
373
+ EoT =false;
374
+ byte PDUType;
375
+ ClrIsoError();
376
+ // header is received always from beginning
377
+ RecvPacket(&PDU, DataHeaderSize); // TPKT + COPT_DT
378
+ if (LastTcpError==0)
379
+ {
380
+ PDUType=PDU.COTP.PDUType;
381
+ switch (PDUType)
382
+ {
383
+ case pdu_type_CR:
384
+ case pdu_type_DR:
385
+ EoT=true;
386
+ break;
387
+ case pdu_type_DT:
388
+ EoT = (PDU.COTP.EoT_Num & 0x80) == 0x80; // EoT flag
389
+ break;
390
+ default:
391
+ return SetIsoError(errIsoInvalidPDU);
392
+ }
393
+
394
+ DataLength = PDUSize(&PDU) - DataHeaderSize;
395
+ if (CheckPDU(&PDU, PDUType)!=0)
396
+ return LastIsoError;
397
+ // Checks for data presence
398
+ if (DataLength>0) // payload present
399
+ {
400
+ // Check if the data fits in the buffer
401
+ if(DataLength<=Max)
402
+ {
403
+ RecvPacket(From, DataLength);
404
+ if (LastTcpError!=0)
405
+ return SetIsoError(errIsoRecvPacket);
406
+ else
407
+ Size =DataLength;
408
+ }
409
+ else
410
+ return SetIsoError(errIsoPduOverflow);
411
+ }
412
+ }
413
+ else
414
+ return SetIsoError(errIsoRecvPacket);
415
+
416
+ return LastIsoError;
417
+ }
418
+ //---------------------------------------------------------------------------
419
+ // Fragments Recv schema
420
+ //------------------------------------------------------------------------------
421
+ //
422
+ // packet 1 packet 2 packet 3
423
+ // +--------+------------+ +--------+------------+ +--------+------------+
424
+ // | HEADER | FRAGMENT 1 | | HEADER | FRAGMENT 2 | | HEADER | FRAGMENT 3 |
425
+ // +--------+------------+ +--------+------------+ +--------+------------+
426
+ // | | |
427
+ // | +-----------+ |
428
+ // | | |
429
+ // | | +------------------------+
430
+ // | | | (Packet 3 has EoT Flag set)
431
+ // V V V
432
+ // +--------+------------+------------+------------+
433
+ // | HEADER | FRAGMENT 1 : FRAGMENT 2 : FRAGMENT 3 |
434
+ // +--------+------------+------------+------------+
435
+ // ^
436
+ // |
437
+ // +-- A new header is built with updated info
438
+ //
439
+ //------------------------------------------------------------------------------
440
+ int TIsoTcpSocket::isoRecvPDU(PIsoDataPDU Data)
441
+ {
442
+ int Result;
443
+ int Size;
444
+ pbyte pData;
445
+ int max;
446
+ int Offset;
447
+ int Received;
448
+ int NumParts;
449
+ bool Complete;
450
+
451
+ NumParts =1;
452
+ Offset =0;
453
+ Complete =false;
454
+ ClrIsoError();
455
+ pData = pbyte(&PDU.Payload);
456
+ do {
457
+ pData=pData+Offset;
458
+ max =IsoPayload_Size-Offset; // Maximum packet allowed
459
+ if (max>0)
460
+ {
461
+ Result =isoRecvFragment(pData, max, Received, Complete);
462
+ if((Result==0) && !Complete)
463
+ {
464
+ ++NumParts;
465
+ Offset += Received;
466
+ if (NumParts>IsoMaxFragments)
467
+ Result =SetIsoError(errIsoTooManyFragments);
468
+ }
469
+ }
470
+ else
471
+ Result =SetIsoError(errIsoTooManyFragments);
472
+ } while ((!Complete) && (Result==0));
473
+
474
+
475
+ if (Result==0)
476
+ {
477
+ // Add to offset the header size
478
+ Size =Offset+Received+DataHeaderSize;
479
+ // Adjust header
480
+ PDU.TPKT.HI_Lenght =(u_short(Size)>>8) & 0xFF;
481
+ PDU.TPKT.LO_Lenght =u_short(Size) & 0xFF;
482
+ // Copies data if target is not the local PDU
483
+ if (Data!=&PDU)
484
+ memcpy(Data, &PDU, Size);
485
+ }
486
+ else
487
+ if (LastTcpError!=WSAECONNRESET)
488
+ Purge();
489
+ return Result;
490
+ }
491
+ //---------------------------------------------------------------------------
492
+ int TIsoTcpSocket::isoExchangePDU(PIsoDataPDU Data)
493
+ {
494
+ int Result;
495
+ ClrIsoError();
496
+ Result=isoSendPDU(Data);
497
+ if (Result==0)
498
+ Result=isoRecvPDU(Data);
499
+ return Result;
500
+ }
501
+ //---------------------------------------------------------------------------
502
+ void TIsoTcpSocket::IsoPeek(void *pPDU, TPDUKind &PduKind)
503
+ {
504
+ PIsoHeaderInfo Info;
505
+ u_int IsoLen;
506
+
507
+ Info=PIsoHeaderInfo(pPDU);
508
+ IsoLen=PDUSize(Info);
509
+
510
+ // Check for empty fragment : size of PDU = size of header and nothing else
511
+ if (IsoLen==DataHeaderSize )
512
+ {
513
+ // We don't need to check the EoT flag since the PDU is empty....
514
+ PduKind=pkEmptyFragment;
515
+ return;
516
+ };
517
+ // Check for invalid packet : size of PDU < size of header
518
+ if (IsoLen<DataHeaderSize )
519
+ {
520
+ PduKind=pkInvalidPDU;
521
+ return;
522
+ };
523
+ // Here IsoLen>DataHeaderSize : check the PDUType
524
+ switch (Info->PDUType)
525
+ {
526
+ case pdu_type_CR:
527
+ PduKind=pkConnectionRequest;
528
+ break;
529
+ case pdu_type_DR:
530
+ PduKind=pkDisconnectRequest;
531
+ break;
532
+ case pdu_type_DT:
533
+ PduKind=pkValidData;
534
+ break;
535
+ default:
536
+ PduKind=pkUnrecognizedType;
537
+ };
538
+ }
539
+
540
+
541
+