mms_client_connection.h 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. /*
  2. * mms_client_connection.h
  3. *
  4. * Copyright 2013-2018 Michael Zillgith
  5. *
  6. * This file is part of libIEC61850.
  7. *
  8. * libIEC61850 is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * libIEC61850 is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * See COPYING file for the complete license text.
  22. */
  23. #ifndef MMS_CLIENT_CONNECTION_H_
  24. #define MMS_CLIENT_CONNECTION_H_
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /**
  29. * \defgroup mms_client_api_group MMS client API (for IEC 61850 use IEC 61850 client API instead!)
  30. */
  31. /**@{*/
  32. #include "libiec61850_common_api.h"
  33. #include "mms_common.h"
  34. #include "mms_type_spec.h"
  35. #include "mms_value.h"
  36. #include "iso_connection_parameters.h"
  37. #include "linked_list.h"
  38. #include "tls_config.h"
  39. /**
  40. * Contains MMS layer specific parameters
  41. */
  42. typedef struct sMmsConnectionParameters {
  43. int maxServOutstandingCalling;
  44. int maxServOutstandingCalled;
  45. int dataStructureNestingLevel;
  46. int maxPduSize; /* local detail */
  47. uint8_t servicesSupported[11];
  48. } MmsConnectionParameters;
  49. typedef struct {
  50. char* vendorName;
  51. char* modelName;
  52. char* revision;
  53. } MmsServerIdentity;
  54. typedef enum {
  55. MMS_CONNECTION_STATE_CLOSED,
  56. MMS_CONNECTION_STATE_CONNECTING,
  57. MMS_CONNECTION_STATE_CONNECTED,
  58. MMS_CONNECTION_STATE_CLOSING
  59. } MmsConnectionState;
  60. typedef void (*MmsInformationReportHandler) (void* parameter, char* domainName,
  61. char* variableListName, MmsValue* value, bool isVariableListName);
  62. /**
  63. * Opaque handle for MMS client connection instance.
  64. */
  65. typedef struct sMmsConnection* MmsConnection;
  66. /*******************************************************************************
  67. * Connection management functions
  68. *******************************************************************************/
  69. /**
  70. * \brief Create a new MmsConnection instance
  71. *
  72. * \return the newly created instance.
  73. */
  74. LIB61850_API MmsConnection
  75. MmsConnection_create(void);
  76. /**
  77. * \brief Create a new secure (TLS enabled) MmsConnection instance
  78. *
  79. * \param tlsConfig TLS configuration parameters and certificates
  80. *
  81. * \return the newly created instance.
  82. */
  83. LIB61850_API MmsConnection
  84. MmsConnection_createSecure(TLSConfiguration tlsConfig);
  85. /**
  86. * \brief Create a new MmsConnection instance configured for non-threaded mode
  87. *
  88. * NOTE: This constructor doesn't create a background thread for connection handling.
  89. * The user has to call the MmsConnection_tick function periodically to ensure that
  90. * the MMS connection can be handled properly.
  91. *
  92. * \param tlsConfig TLS configuration parameters and certificates or NULL for non-TLS mode.
  93. *
  94. * \return the newly created instance.
  95. */
  96. LIB61850_API MmsConnection
  97. MmsConnection_createNonThreaded(TLSConfiguration tlsConfig);
  98. /**
  99. * \brief Callback function to intercept raw MMS messages
  100. *
  101. * IMPORTANT: the message buffer is only valid in the context of the the callback function. If the
  102. * message data is required elsewhere it has to be copied here!
  103. *
  104. * \param parameter user provided parameter that is passed to the callback function
  105. * \param message buffer of the message.
  106. * \param messageLength length of the message in bytes
  107. * \param received if true message has been received, false when message has been sent.
  108. */
  109. typedef void (*MmsRawMessageHandler) (void* parameter, uint8_t* message, int messageLength, bool received);
  110. /**
  111. * \brief Set the callback handler to intercept the raw MMS messages of the connection
  112. *
  113. * This function can be used to log raw MMS messages. It may be useful for debugging purposes
  114. * or advanced test tools. This function will only work when the flag CONFIG_MMS_RAW_MESSAGE_LOGGING
  115. * it set in stack_config.h
  116. *
  117. * \param self MmsConnection instance to operate on
  118. * \param handler the connection specific callback function
  119. * \param a user provided parameter passed to the callback function (use NULL if not required).
  120. */
  121. LIB61850_API void
  122. MmsConnection_setRawMessageHandler(MmsConnection self, MmsRawMessageHandler handler, void* parameter);
  123. /**
  124. * \brief Set the virtual filestore basepath for the MMS obtain file services
  125. *
  126. * All external file service accesses will be mapped to paths relative to the base directory.
  127. * NOTE: This function is only available when the CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME
  128. * option in stack_config.h is set.
  129. *
  130. * \param self the MmsServer instance
  131. * \param basepath the new virtual filestore basepath
  132. */
  133. LIB61850_API void
  134. MmsConnection_setFilestoreBasepath(MmsConnection self, const char* basepath);
  135. /**
  136. * \brief Set the request timeout in ms for this connection
  137. *
  138. * \param self MmsConnection instance to operate on
  139. * \param timeoutInMs request timeout in milliseconds
  140. */
  141. LIB61850_API void
  142. MmsConnection_setRequestTimeout(MmsConnection self, uint32_t timeoutInMs);
  143. /**
  144. * \brief Set the maximum number outstanding calls allowed for this connection
  145. *
  146. * \param self MmsConnection instance to operate on
  147. * \param calling the maximum outstanding calls allowed by the caller (client)
  148. * \param called the maximum outstanding calls allowed by the called endpoint (server)
  149. */
  150. LIB61850_API void
  151. MmsConnnection_setMaxOutstandingCalls(MmsConnection self, int calling, int called);
  152. /**
  153. * \brief Get the request timeout in ms for this connection
  154. *
  155. * \param self MmsConnection instance to operate on
  156. *
  157. * \return request timeout in milliseconds
  158. */
  159. LIB61850_API uint32_t
  160. MmsConnection_getRequestTimeout(MmsConnection self);
  161. /**
  162. * \brief Set the connect timeout in ms for this connection instance
  163. *
  164. * \param self MmsConnection instance to operate on
  165. * \param timeoutInMs connect timeout in milliseconds
  166. */
  167. LIB61850_API void
  168. MmsConnection_setConnectTimeout(MmsConnection self, uint32_t timeoutInMs);
  169. /**
  170. * \brief Install a handler function for MMS information reports (unsolicited messages from the server).
  171. *
  172. * The handler function will be called whenever the client receives an MMS information report message.
  173. * Note that the API user is responsible to properly free the passed MmsValue object.
  174. *
  175. * \param self MmsConnection instance to operate on
  176. * \param handler the handler function to install for this client connection
  177. * \param parameter a user specified parameter that will be passed to the handler function on each
  178. * invocation.
  179. */
  180. LIB61850_API void
  181. MmsConnection_setInformationReportHandler(MmsConnection self, MmsInformationReportHandler handler,
  182. void* parameter);
  183. /**
  184. * \brief Get the ISO connection parameters for an MmsConnection instance
  185. *
  186. * \param self MmsConnection instance to operate on
  187. * \return params the to be used by this connection
  188. */
  189. LIB61850_API IsoConnectionParameters
  190. MmsConnection_getIsoConnectionParameters(MmsConnection self);
  191. /**
  192. * \brief Get the MMS specific connection parameters for an MmsConnection instance
  193. *
  194. * \param self MmsConnection instance to operate on
  195. * \return params the to be used by this connection
  196. */
  197. LIB61850_API MmsConnectionParameters
  198. MmsConnection_getMmsConnectionParameters(MmsConnection self);
  199. typedef void (*MmsConnectionStateChangedHandler) (MmsConnection connection, void* parameter, MmsConnectionState newState);
  200. LIB61850_API void
  201. MmsConnection_setConnectionStateChangedHandler(MmsConnection self, MmsConnectionStateChangedHandler handler, void* parameter);
  202. /**
  203. * \brief User provided handler function that will be called if the connection to the server is lost
  204. *
  205. * \param connection MmsConnection object of the lost connection
  206. * \param parameter user provided parameter.
  207. */
  208. typedef void (*MmsConnectionLostHandler) (MmsConnection connection, void* parameter);
  209. /**
  210. * \brief Install a callback function that will be called by the client stack if the MMS connection to the server is lost
  211. *
  212. * \param handler the user provided callback function
  213. * \param handlerParameter a parameter that will be passed to the callback function. Can be set to NULL if not required.
  214. */
  215. LIB61850_API void
  216. MmsConnection_setConnectionLostHandler(MmsConnection self, MmsConnectionLostHandler handler, void* handlerParameter);
  217. /**
  218. * \brief Set the ISO connection parameters for a MmsConnection instance
  219. *
  220. * \param self MmsConnection instance to operate on
  221. * \param params the ISO client parameters to use
  222. */
  223. LIB61850_API void
  224. MmsConnection_setIsoConnectionParameters(MmsConnection self, IsoConnectionParameters* params);
  225. /**
  226. * \brief Destroy an MmsConnection instance and release all resources
  227. *
  228. * \param self MmsConnection instance to operate on
  229. */
  230. LIB61850_API void
  231. MmsConnection_destroy(MmsConnection self);
  232. /*******************************************************************************
  233. * Blocking functions for connection establishment and data access
  234. *******************************************************************************/
  235. /**
  236. * \brief Connect to an MMS server.
  237. *
  238. * This will open a new TCP connection and send a MMS initiate request.
  239. *
  240. * \param self MmsConnection instance to operate on
  241. * \param mmsError user provided variable to store error code
  242. * \param serverName hostname or IP address of the server to connect
  243. * \param serverPort TCP port number of the server to connect or -1 to use default port (102 for MMS or 3872 for MMS over TLS)
  244. *
  245. * \return true on success. false if the connection attempt failed.
  246. */
  247. LIB61850_API bool
  248. MmsConnection_connect(MmsConnection self, MmsError* mmsError, const char* serverName, int serverPort);
  249. LIB61850_API void
  250. MmsConnection_connectAsync(MmsConnection self, MmsError* mmsError, const char* serverName, int serverPort);
  251. /**
  252. * \brief Call MmsConnection state machine and connection handling code (for non-threaded mode only)
  253. *
  254. * This function has to be called periodically by the user application in non-threaded mode.
  255. *
  256. * \return true when connection is currently waiting and calling thread can be suspended, false means
  257. * connection is busy and the tick function should be called again as soon as possible.
  258. */
  259. LIB61850_API bool
  260. MmsConnection_tick(MmsConnection self);
  261. /* NOTE: This function is for test purposes! */
  262. LIB61850_API void
  263. MmsConnection_sendRawData(MmsConnection self, MmsError* mmsError, uint8_t* buffer, int bufSize);
  264. /**
  265. * \brief Close the connection - not recommended
  266. *
  267. * This service simply closes the TCP socket without any hand-shaking with the server.
  268. * This behavior is not specified. Use with care!
  269. *
  270. * \param self MmsConnection instance to operate on
  271. */
  272. LIB61850_API void
  273. MmsConnection_close(MmsConnection self);
  274. typedef void
  275. (*MmsConnection_ConcludeAbortHandler) (void* parameter, MmsError mmsError, bool success);
  276. /**
  277. * \brief Uses the MMS/ACSE abort service to close the connection to the server
  278. *
  279. * This service should be used to abruptly interrupt the connection to the server. It is not quite clear what the
  280. * benefit of this service is (simply closing the TCP connection should do the same). Though it is required by
  281. * conformance tests. In case the server doesn't close the connection after the internal timeout interval the
  282. * client will close the TCP connection and set mmsError to MMS_ERROR_SERVICE_TIMEOUT.
  283. *
  284. * \param self MmsConnection instance to operate on
  285. * \param mmsError user provided variable to store error code
  286. */
  287. LIB61850_API void
  288. MmsConnection_abort(MmsConnection self, MmsError* mmsError);
  289. LIB61850_API void
  290. MmsConnection_abortAsync(MmsConnection self, MmsError* mmsError);
  291. /**
  292. * \brief Uses the MMS conclude service to close the connection to the server
  293. *
  294. * This should be used to orderly release the connection to the server. If the server denies the conclude
  295. * request (by sending a concludeError PDU) this service fails with an error (mmsError set accordingly) and
  296. * the connection remains open. In this case the close or abort methods have to be used to close the connection.
  297. * It is not quite clear if this service is really useful but it is required by conformance tests.
  298. *
  299. * \param self MmsConnection instance to operate on
  300. * \param mmsError user provided variable to store error code
  301. */
  302. LIB61850_API void
  303. MmsConnection_conclude(MmsConnection self, MmsError* mmsError);
  304. LIB61850_API void
  305. MmsConnection_concludeAsync(MmsConnection self, MmsError* mmsError, MmsConnection_ConcludeAbortHandler handler, void* parameter);
  306. typedef void
  307. (*MmsConnection_GenericServiceHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, bool success);
  308. typedef void
  309. (*MmsConnection_GetNameListHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, LinkedList nameList, bool moreFollows);
  310. /**
  311. * \brief Get the names of all VMD scope variables of the server.
  312. *
  313. * This will result in a VMD specific GetNameList request.
  314. *
  315. * \param self MmsConnection instance to operate on
  316. * \param mmsError user provided variable to store error code
  317. *
  318. * \return the of VMD specific variable names or NULL if the request failed.
  319. */
  320. LIB61850_API LinkedList /* <char*> */
  321. MmsConnection_getVMDVariableNames(MmsConnection self, MmsError* mmsError);
  322. LIB61850_API void
  323. MmsConnection_getVMDVariableNamesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* continueAfter,
  324. MmsConnection_GetNameListHandler handler, void* parameter);
  325. /**
  326. * \brief Get the domains names for all domains of the server.
  327. *
  328. * This will result in a VMD specific GetNameList request.
  329. *
  330. * \param self MmsConnection instance to operate on
  331. * \param mmsError user provided variaextern "C" {ble to store error code
  332. *
  333. * \return the list of domain names or NULL if the request failed.
  334. *
  335. */
  336. LIB61850_API LinkedList /* <char*> */
  337. MmsConnection_getDomainNames(MmsConnection self, MmsError* mmsError);
  338. /**
  339. * \brief Get the domain names of the server (asynchronous version).
  340. *
  341. * \param[in] self MmsConnection instance to operate on
  342. * \param[out] usedInvokeId the invoke ID of the request
  343. * \param[out] mmsError user provided variable to store error code
  344. * \param[in] continueAfter the name of the last received element when the call is a continuation, or NULL for the first call
  345. * \param[in] result list to store (append) the response names, or NULL to create a new list for the response names
  346. * \param[in] handler will be called when response is received or timed out.
  347. * \param[in] parameter
  348. */
  349. LIB61850_API void
  350. MmsConnection_getDomainNamesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* continueAfter, LinkedList result,
  351. MmsConnection_GetNameListHandler handler, void* parameter);
  352. /**
  353. * \brief Get the names of all variables present in a MMS domain of the server.
  354. *
  355. * This will result in a domain specific GetNameList request.
  356. *
  357. * \param[in] self MmsConnection instance to operate on
  358. * \param[out] mmsError user provided variable to store error code
  359. * \param[in] domainId the domain name for the domain specific request
  360. *
  361. * \return the of domain specific variable names or NULL if the request failed.
  362. */
  363. LIB61850_API LinkedList /* <char*> */
  364. MmsConnection_getDomainVariableNames(MmsConnection self, MmsError* mmsError, const char* domainId);
  365. /**
  366. * \brief Get the names of all variables present in a MMS domain of the server (asynchronous version).
  367. *
  368. * This will result in a domain specific GetNameList request.
  369. *
  370. * \param[in] self MmsConnection instance to operate on
  371. * \param[out] usedInvokeId the invoke ID of the request
  372. * \param[out] mmsError user provided variable to store error code
  373. * \param[in] domainId the domain name for the domain specific request
  374. * \param[in] continueAfter the name of the last received element when the call is a continuation, or NULL for the first call
  375. * \param[in] result list to store (append) the response names, or NULL to create a new list for the response names
  376. * \param[in] handler will be called when response is received or timed out.
  377. * \param[in] parameter
  378. */
  379. LIB61850_API void
  380. MmsConnection_getDomainVariableNamesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId,
  381. const char* continueAfter, LinkedList result, MmsConnection_GetNameListHandler handler, void* parameter);
  382. /**
  383. * \brief Get the names of all named variable lists present in a MMS domain or VMD scope of the server.
  384. *
  385. * This will result in a domain specific GetNameList request.
  386. *
  387. * \param self MmsConnection instance to operate on
  388. * \param mmsError user provided variable to store error code
  389. * \param domainId the domain name for the domain specific request or NULL for a VMD scope request
  390. *
  391. * \return the domain specific named variable list names or NULL if the request failed.
  392. */
  393. LIB61850_API LinkedList /* <char*> */
  394. MmsConnection_getDomainVariableListNames(MmsConnection self, MmsError* mmsError, const char* domainId);
  395. LIB61850_API void
  396. MmsConnection_getDomainVariableListNamesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId,
  397. const char* continueAfter, LinkedList result, MmsConnection_GetNameListHandler handler, void* parameter);
  398. /**
  399. * \brief Get the names of all journals present in a MMS domain of the server
  400. *
  401. * This will result in a domain specific GetNameList request.
  402. *
  403. * \param self MmsConnection instance to operate on
  404. * \param mmsError user provided variable to store error code
  405. * \param domainId the domain name for the domain specific request
  406. *
  407. * \return the domain specific journal names or NULL if the request failed.
  408. */
  409. LIB61850_API LinkedList /* <char*> */
  410. MmsConnection_getDomainJournals(MmsConnection self, MmsError* mmsError, const char* domainId);
  411. LIB61850_API void
  412. MmsConnection_getDomainJournalsAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId,
  413. const char* continueAfter, MmsConnection_GetNameListHandler handler, void* parameter);
  414. /**
  415. * \brief Get the names of all named variable lists associated with this client connection.
  416. *
  417. * This will result in an association specific GetNameList request.
  418. *
  419. * \param self MmsConnection instance to operate on
  420. * \param mmsError user provided variable to store error code
  421. *
  422. * \return the association specific named variable list names or NULL if the request failed.
  423. */
  424. LIB61850_API LinkedList /* <char*> */
  425. MmsConnection_getVariableListNamesAssociationSpecific(MmsConnection self, MmsError* mmsError);
  426. LIB61850_API void
  427. MmsConnection_getVariableListNamesAssociationSpecificAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  428. const char* continueAfter, MmsConnection_GetNameListHandler handler, void* parameter);
  429. /**
  430. * \brief Read a single variable from the server.
  431. *
  432. * \param self MmsConnection instance to operate on
  433. * \param mmsError user provided variable to store error code
  434. * \param domainId the domain name of the variable to be read or NULL to read a VMD specific named variable
  435. * \param itemId name of the variable to be read
  436. *
  437. * \return Returns a MmsValue object or NULL if the request failed. The MmsValue object can
  438. * either be a simple value or a complex value or array. It is also possible that the return value is NULL
  439. * even if mmsError = MMS_ERROR_NON. This is the case when the servers returns an empty result list.
  440. */
  441. LIB61850_API MmsValue*
  442. MmsConnection_readVariable(MmsConnection self, MmsError* mmsError, const char* domainId, const char* itemId);
  443. typedef void
  444. (*MmsConnection_ReadVariableHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, MmsValue* value);
  445. /**
  446. * \brief Read a single variable from the server (asynchronous version)
  447. *
  448. * \param{in] self MmsConnection instance to operate on
  449. * \param[out] usedInvokeId the invoke ID of the request
  450. * \param[out] mmsError user provided variable to store error code
  451. * \param[in] domainId the domain name of the variable to be read or NULL to read a VMD specific named variable
  452. * \param[in] itemId name of the variable to be read
  453. */
  454. LIB61850_API void
  455. MmsConnection_readVariableAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId, const char* itemId,
  456. MmsConnection_ReadVariableHandler handler, void* parameter);
  457. /**
  458. * \brief Read a component of a single variable from the server.
  459. *
  460. * \param self MmsConnection instance to operate on
  461. * \param mmsError user provided variable to store error code
  462. * \param domainId the domain name of the variable to be read or NULL to read a VMD specific named variable
  463. * \param itemId name of the variable to be read
  464. * \param componentId the component name
  465. *
  466. * \return Returns a MmsValue object or NULL if the request failed. The MmsValue object can
  467. * either be a simple value or a complex value or array. It is also possible that the return value is NULL
  468. * even if mmsError = MMS_ERROR_NON. This is the case when the servers returns an empty result list.
  469. */
  470. LIB61850_API MmsValue*
  471. MmsConnection_readVariableComponent(MmsConnection self, MmsError* mmsError,
  472. const char* domainId, const char* itemId, const char* componentId);
  473. /**
  474. * \brief Read a component of a single variable from the server (asynchronous version)
  475. *
  476. * \param[in] self MmsConnection instance to operate on
  477. * \param[out] usedInvokeId the invoke ID of the request
  478. * \param[out] mmsError user provided variable to store error code
  479. * \param[in] domainId the domain name of the variable to be read or NULL to read a VMD specific named variable
  480. * \param[in] itemId name of the variable to be read
  481. * \param[in] componentId the component name
  482. * \param[in] handler
  483. * \param[in] parameter
  484. */
  485. LIB61850_API void
  486. MmsConnection_readVariableComponentAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  487. const char* domainId, const char* itemId, const char* componentId,
  488. MmsConnection_ReadVariableHandler handler, void* parameter);
  489. /**
  490. * \brief Read one or more elements of a single array variable from the server.
  491. *
  492. * \param self MmsConnection instance to operate on
  493. * \param mmsError user provided variable to store error code
  494. * \param domainId the domain name of the variable to be read
  495. * \param itemId name of the variable to be read
  496. * \param startIndex index of element to read or start index if a element range is to be read
  497. * \param numberOfElements Number of elements to read or 0 if a single element is to be read
  498. *
  499. * \return Returns a MmsValue object or NULL if the request failed. The MmsValue object is either
  500. * a simple or complex type if numberOfElements is 0, or an array containing the selected
  501. * array elements of numberOfElements > 0.
  502. */
  503. LIB61850_API MmsValue*
  504. MmsConnection_readArrayElements(MmsConnection self, MmsError* mmsError, const char* domainId, const char* itemId,
  505. uint32_t startIndex, uint32_t numberOfElements);
  506. /**
  507. * \brief Read one or more elements of a single array variable from the server (asynchronous version)
  508. *
  509. * NOTE: The MmsValue object received by the callback function is either a simple or complex type if numberOfElements is 0, or an array
  510. * containing the selected array elements of numberOfElements > 0.
  511. *
  512. * \param[in] self MmsConnection instance to operate on
  513. * \param[out] usedInvokeId the invoke ID of the request
  514. * \param[out] mmsError user provided variable to store error code
  515. * \param[in] domainId the domain name of the variable to be read
  516. * \param[in] itemId name of the variable to be read
  517. * \param[in] startIndex index of element to read or start index if a element range is to be read
  518. * \param[in] numberOfElements Number of elements to read or 0 if a single element is to be read
  519. */
  520. LIB61850_API void
  521. MmsConnection_readArrayElementsAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId, const char* itemId,
  522. uint32_t startIndex, uint32_t numberOfElements,
  523. MmsConnection_ReadVariableHandler handler, void* parameter);
  524. /**
  525. * \brief Read a single element (with optional component specification) from the server
  526. *
  527. * \param self MmsConnection instance to operate on
  528. * \param mmsError user provided variable to store error code
  529. * \param domainId the domain name of the variable to be read
  530. * \param itemId name of the variable to be read
  531. * \param index array element index
  532. * \param componentId array element component name
  533. *
  534. * \return Returns a MmsValue object or NULL if the request failed.
  535. */
  536. LIB61850_API MmsValue*
  537. MmsConnection_readSingleArrayElementWithComponent(MmsConnection self, MmsError* mmsError,
  538. const char* domainId, const char* itemId, uint32_t index, const char* componentId);
  539. LIB61850_API void
  540. MmsConnection_readSingleArrayElementWithComponentAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  541. const char* domainId, const char* itemId,
  542. uint32_t index, const char* componentId,
  543. MmsConnection_ReadVariableHandler handler, void* parameter);
  544. /**
  545. * \brief Read multiple variables of a domain from the server with one request message.
  546. *
  547. * \param self MmsConnection instance to operate on
  548. * \param mmsError user provided variable to store error code
  549. * \param domainId the domain name of the requested variables.
  550. * \param items: LinkedList<char*> is the list of item IDs of the requested variables.
  551. *
  552. * \return Returns a MmsValue object or NULL if the request failed. The MmsValue object is
  553. * is of type MMS_ARRAY and contains the variable values of simple or complex type
  554. * in the order as they appeared in the item ID list.
  555. */
  556. LIB61850_API MmsValue*
  557. MmsConnection_readMultipleVariables(MmsConnection self, MmsError* mmsError, const char* domainId,
  558. LinkedList /*<char*>*/ items);
  559. LIB61850_API void
  560. MmsConnection_readMultipleVariablesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  561. const char* domainId, LinkedList /*<char*>*/items,
  562. MmsConnection_ReadVariableHandler handler, void* parameter);
  563. /**
  564. * \brief Write a single variable to the server.
  565. *
  566. * NOTE: added return value in version 1.1
  567. *
  568. * \param self MmsConnection instance to operate on
  569. * \param mmsError user provided variable to store error code
  570. * \param domainId the domain name of the variable to be written
  571. * \param itemId name of the variable to be written
  572. * \param value value of the variable to be written
  573. *
  574. * \return when successful, the data access error value returned by the server
  575. */
  576. LIB61850_API MmsDataAccessError
  577. MmsConnection_writeVariable(MmsConnection self, MmsError* mmsError,
  578. const char* domainId, const char* itemId, MmsValue* value);
  579. typedef void
  580. (*MmsConnection_WriteVariableHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, MmsDataAccessError accessError);
  581. LIB61850_API void
  582. MmsConnection_writeVariableAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  583. const char* domainId, const char* itemId, MmsValue* value,
  584. MmsConnection_WriteVariableHandler handler, void* parameter);
  585. /**
  586. * \brief Write a single variable to the server (using component alternate access)
  587. *
  588. * \param self MmsConnection instance to operate on
  589. * \param mmsError user provided variable to store error code
  590. * \param domainId the domain name of the variable to be written
  591. * \param itemId name of the variable to be written
  592. * \param componentId the name of the variable component
  593. * \param value value of the variable to be written
  594. *
  595. * \return when successful, the data access error value returned by the server
  596. */
  597. LIB61850_API MmsDataAccessError
  598. MmsConnection_writeVariableComponent(MmsConnection self, MmsError* mmsError,
  599. const char* domainId, const char* itemId,
  600. const char* componentId, MmsValue* value);
  601. /**
  602. * \brief Write a single array element with a component to an array type variable
  603. *
  604. * \param self MmsConnection instance to operate on
  605. * \param mmsError user provided variable to store error code
  606. * \param domainId the domain name of the variable to be written
  607. * \param itemId name of the variable to be written
  608. * \param arrayIndex the index of the array element.
  609. * \param componentId the name of the component of the array element
  610. * \param value value of the array element component to be written.
  611. *
  612. * \return when successful, the data access error value returned by the server
  613. */
  614. LIB61850_API MmsDataAccessError
  615. MmsConnection_writeSingleArrayElementWithComponent(MmsConnection self, MmsError* mmsError,
  616. const char* domainId, const char* itemId,
  617. uint32_t arrayIndex, const char* componentId, MmsValue* value);
  618. LIB61850_API void
  619. MmsConnection_writeSingleArrayElementWithComponentAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  620. const char* domainId, const char* itemId,
  621. uint32_t arrayIndex, const char* componentId, MmsValue* value,
  622. MmsConnection_WriteVariableHandler handler, void* parameter);
  623. LIB61850_API void
  624. MmsConnection_writeVariableComponentAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  625. const char* domainId, const char* itemId, const char* componentId, MmsValue* value,
  626. MmsConnection_WriteVariableHandler handler, void* parameter);
  627. /**
  628. * \brief Write a single array element or a sub array to an array type variable
  629. *
  630. * When a single array element is addressed the MmsValue object value has to be of the type
  631. * of the array elements. When multiple array elements have to be written (index range) the
  632. * MmsValue object value has to be of type MMS_ARRAY containing "numberOfElements" elements.
  633. *
  634. * \param self MmsConnection instance to operate on
  635. * \param mmsError user provided variable to store error code
  636. * \param domainId the domain name of the variable to be written
  637. * \param index the index of the array element or the start index of a index range
  638. * \param numberOfElements the number of array elements to write starting with index. If 0 only one array element is written.
  639. * \param itemId name of the variable to be written
  640. * \param value value of the array element(s) to be written. Has to be of the type of
  641. * the array elements or of type MMS_ARRAY when it is a sub array (index range)
  642. *
  643. * \return when successful, the data access error value returned by the server
  644. */
  645. LIB61850_API MmsDataAccessError
  646. MmsConnection_writeArrayElements(MmsConnection self, MmsError* mmsError,
  647. const char* domainId, const char* itemId, int index, int numberOfElements,
  648. MmsValue* value);
  649. LIB61850_API void
  650. MmsConnection_writeArrayElementsAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  651. const char* domainId, const char* itemId, int index, int numberOfElements,
  652. MmsValue* value,
  653. MmsConnection_WriteVariableHandler handler, void* parameter);
  654. typedef void
  655. (*MmsConnection_WriteMultipleVariablesHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, LinkedList /* <MmsValue*> */ accessResults);
  656. /**
  657. * \brief Write multiple variables to the server.
  658. *
  659. * This function will write multiple variables to the server.
  660. *
  661. * The parameter accessResults is a pointer to a LinkedList reference. The methods will create a new LinkedList
  662. * object that contains the AccessResults of the single variable write attempts. It is up to the user to free this
  663. * objects properly (e.g. with LinkedList_destroyDeep(accessResults, MmsValue_delete)).
  664. *
  665. * \param[in] self MmsConnection instance to operate on
  666. * \param[out] mmsError user provided variable to store error code
  667. * \param[in] domainId the common domain name of all variables to be written
  668. * \param[in] items a linked list containing the names of the variables to be written. The names are C strings.
  669. * \param[out] values values of the variables to be written
  670. * \param[out] the MmsValue objects of type MMS_DATA_ACCESS_ERROR representing the write success of a single variable
  671. * write.
  672. */
  673. LIB61850_API void
  674. MmsConnection_writeMultipleVariables(MmsConnection self, MmsError* mmsError, const char* domainId,
  675. LinkedList /*<char*>*/ items, LinkedList /* <MmsValue*> */ values,
  676. LinkedList* /* <MmsValue*> */ accessResults);
  677. LIB61850_API void
  678. MmsConnection_writeMultipleVariablesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId,
  679. LinkedList /*<char*>*/ items, LinkedList /* <MmsValue*> */ values,
  680. MmsConnection_WriteMultipleVariablesHandler handler, void* parameter);
  681. /**
  682. * \brief Write named variable list values to the server.
  683. *
  684. * The parameter accessResults is a pointer to a LinkedList reference. The methods will create a new LinkedList
  685. * object that contains the AccessResults of the single variable write attempts. It is in the responsibility of
  686. * the user to free this objects properly (e.g. with LinkedList_destroyDeep(accessResults, MmsValue_delete)).
  687. * If accessResult is the to NULL the result will not be stored.
  688. *
  689. * \param[in] self MmsConnection instance to operate on
  690. * \param[out] mmsError user provided variable to store error code
  691. * \param[in] isAssociationSpecifc true if the named variable list is an association specific named variable list
  692. * \param[in] domainId the common domain name of all variables to be written
  693. * \param[out] values values of the variables to be written
  694. * \param[out] the MmsValue objects of type MMS_DATA_ACCESS_ERROR representing the write success of a single variable
  695. * write.
  696. */
  697. LIB61850_API void
  698. MmsConnection_writeNamedVariableList(MmsConnection self, MmsError* mmsError, bool isAssociationSpecific,
  699. const char* domainId, const char* itemId, LinkedList /* <MmsValue*> */values,
  700. LinkedList* /* <MmsValue*> */accessResults);
  701. LIB61850_API void
  702. MmsConnection_writeNamedVariableListAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, bool isAssociationSpecific,
  703. const char* domainId, const char* itemId, LinkedList /* <MmsValue*> */values,
  704. MmsConnection_WriteMultipleVariablesHandler handler, void* parameter);
  705. /**
  706. * \brief Get the variable access attributes of a MMS named variable of the server
  707. *
  708. * \param self MmsConnection instance to operate on
  709. * \param mmsError user provided variable to store error code
  710. * \param domainId the domain name of the variable or NULL for a VMD specific request
  711. * \param itemId name of the variable
  712. *
  713. * \return Returns a MmsTypeSpecification object or NULL if the request failed.
  714. */
  715. LIB61850_API MmsVariableSpecification*
  716. MmsConnection_getVariableAccessAttributes(MmsConnection self, MmsError* mmsError,
  717. const char* domainId, const char* itemId);
  718. typedef void
  719. (*MmsConnection_GetVariableAccessAttributesHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, MmsVariableSpecification* spec);
  720. LIB61850_API void
  721. MmsConnection_getVariableAccessAttributesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  722. const char* domainId, const char* itemId,
  723. MmsConnection_GetVariableAccessAttributesHandler, void* parameter);
  724. /**
  725. * \brief Read the values of a domain specific named variable list
  726. *
  727. * The resulting named variable list will either be of domain scope (when the domainId argument
  728. * is present) or VMD scope when the domainId argument is NULL.
  729. *
  730. * \param self MmsConnection instance to operate on
  731. * \param mmsError user provided variable to store error code
  732. * \param domainId the domain name of the requested variables.
  733. * \param listName the name of the named variable list
  734. * \param specWithResult if specWithResult is set to true, a IEC 61850 compliant request will be sent.
  735. *
  736. * \return Returns a MmsValue object or NULL if the request failed. The MmsValue object is
  737. * is of type MMS_ARRAY and contains the variable values of simple or complex type
  738. * in the order as they appeared in named variable list definition.
  739. */
  740. LIB61850_API MmsValue*
  741. MmsConnection_readNamedVariableListValues(MmsConnection self, MmsError* mmsError, const char* domainId,
  742. const char* listName, bool specWithResult);
  743. LIB61850_API void
  744. MmsConnection_readNamedVariableListValuesAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  745. const char* domainId, const char* listName, bool specWithResult,
  746. MmsConnection_ReadVariableHandler handler, void* parameter);
  747. /**
  748. * \brief Read the values of a association specific named variable list
  749. *
  750. * \param self MmsConnection instance to operate on
  751. * \param mmsError user provided variable to store error code
  752. * \param listName the name of the named variable list
  753. * \param specWithResult if specWithResult is set to true, a IEC 61850 compliant request will be sent.
  754. *
  755. * \return Returns a MmsValue object or NULL if the request failed. The MmsValue object is
  756. * is of type MMS_ARRAY and contains the variable values of simple or complex type
  757. * in the order as they appeared in named variable list definition.
  758. */
  759. LIB61850_API MmsValue*
  760. MmsConnection_readNamedVariableListValuesAssociationSpecific(MmsConnection self, MmsError* mmsError,
  761. const char* listName, bool specWithResult);
  762. LIB61850_API void
  763. MmsConnection_readNamedVariableListValuesAssociationSpecificAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  764. const char* listName, bool specWithResult,
  765. MmsConnection_ReadVariableHandler handler, void* parameter);
  766. /**
  767. * \brief Define a new VMD or domain scoped named variable list at the server.
  768. *
  769. * The resulting named variable list will either be of domain scope (when the domainId argument
  770. * is present) or VMD scope when the domainId argument is NULL.
  771. *
  772. * \param self MmsConnection instance to operate on
  773. * \param mmsError user provided variable to store error code
  774. * \param domainId the domain name of the domain for the new variable list
  775. * \param listName the name of the named variable list
  776. * \param variableSpecs a list of variable specifications for the new variable list. The list
  777. * elements have to be of type MmsVariableAccessSpecification*.
  778. */
  779. LIB61850_API void
  780. MmsConnection_defineNamedVariableList(MmsConnection self, MmsError* mmsError, const char* domainId,
  781. const char* listName, LinkedList variableSpecs);
  782. LIB61850_API void
  783. MmsConnection_defineNamedVariableListAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId,
  784. const char* listName, LinkedList variableSpecs,
  785. MmsConnection_GenericServiceHandler handler, void* parameter);
  786. /**
  787. * \brief Define a new association specific named variable list at the server.
  788. *
  789. * \param self MmsConnection instance to operate on
  790. * \param mmsError user provided variable to store error code
  791. * \param listName the name of the named variable list
  792. * \param variableSpecs list of variable specifications for the new variable list.The list
  793. * elements have to be of type MmsVariableAccessSpecification*.
  794. */
  795. LIB61850_API void
  796. MmsConnection_defineNamedVariableListAssociationSpecific(MmsConnection self, MmsError* mmsError,
  797. const char* listName, LinkedList variableSpecs);
  798. LIB61850_API void
  799. MmsConnection_defineNamedVariableListAssociationSpecificAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  800. const char* listName, LinkedList variableSpecs,
  801. MmsConnection_GenericServiceHandler handler, void* parameter);
  802. /**
  803. * \brief Read the entry list of a named variable list at the server.
  804. *
  805. * The resulting named variable list will either be of domain scope (when the domainId argument
  806. * is present) or VMD scope when the domainId argument is NULL.
  807. *
  808. * \param self MmsConnection instance to operate on
  809. * \param mmsError user provided variable to store error code
  810. * \param domainId the domain name of the domain of the variable list
  811. * \param listName the name of the named variable list
  812. * \param deletable THIS IS A OUTPUT PARAMETER - indicates if the variable list is deletable by the
  813. * client. The user may provide a NULL pointer if the value doesn't matter.
  814. *
  815. * \return List of names of the variable list entries or NULL if the request failed
  816. */
  817. LIB61850_API LinkedList /* <MmsVariableAccessSpecification*> */
  818. MmsConnection_readNamedVariableListDirectory(MmsConnection self, MmsError* mmsError,
  819. const char* domainId, const char* listName, bool* deletable);
  820. typedef void
  821. (*MmsConnection_ReadNVLDirectoryHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, LinkedList /* <MmsVariableAccessSpecification*> */ specs, bool deletable);
  822. LIB61850_API void
  823. MmsConnection_readNamedVariableListDirectoryAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  824. const char* domainId, const char* listName,
  825. MmsConnection_ReadNVLDirectoryHandler handler, void* parameter);
  826. /**
  827. * \brief Read the entry list of an association specific named variable list at the server.
  828. *
  829. * \param self MmsConnection instance to operate on
  830. * \param mmsError user provided variable to store error code
  831. * \param listName the name of the named variable list
  832. *
  833. * \return List of names of the variable list entries or NULL if the request failed
  834. */
  835. LIB61850_API LinkedList /* <MmsVariableAccessSpecification*> */
  836. MmsConnection_readNamedVariableListDirectoryAssociationSpecific(MmsConnection self, MmsError* mmsError,
  837. const char* listName, bool* deletable);
  838. LIB61850_API void
  839. MmsConnection_readNamedVariableListDirectoryAssociationSpecificAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  840. const char* listName,
  841. MmsConnection_ReadNVLDirectoryHandler handler, void* parameter);
  842. /**
  843. * \brief Delete a named variable list at the server.
  844. *
  845. * The resulting named variable list will either be of domain scope (when the domainId argument
  846. * is present) or VMD scope when the domainId argument is NULL.
  847. *
  848. * \param self MmsConnection instance to operate on
  849. * \param mmsError user provided variable to store error code
  850. * \param domainId the domain name of the domain of the variable list
  851. * \param listName the name of the named variable list
  852. *
  853. * \return true if named variable list has been deleted, false otherwise
  854. */
  855. LIB61850_API bool
  856. MmsConnection_deleteNamedVariableList(MmsConnection self, MmsError* mmsError, const char* domainId, const char* listName);
  857. LIB61850_API void
  858. MmsConnection_deleteNamedVariableListAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId, const char* listName,
  859. MmsConnection_GenericServiceHandler handler, void* parameter);
  860. /**
  861. * \brief Delete an association specific named variable list at the server.
  862. *
  863. * \param self MmsConnection instance to operate on
  864. * \param mmsError user provided variable to store error code
  865. * \param listName the name of the named variable list
  866. *
  867. * \return true if named variable list has been deleted, false otherwise
  868. */
  869. LIB61850_API bool
  870. MmsConnection_deleteAssociationSpecificNamedVariableList(MmsConnection self, MmsError* mmsError,
  871. const char* listName);
  872. LIB61850_API void
  873. MmsConnection_deleteAssociationSpecificNamedVariableListAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* listName,
  874. MmsConnection_GenericServiceHandler handler, void* parameter);
  875. /**
  876. * \brief Create a new MmsVariableSpecification that can be used to define named variable lists.
  877. *
  878. * The created object can be deleted with free(). If the parameter strings were dynamically
  879. * allocated the deallocation is in the responsibility of the user.
  880. *
  881. * \param domainId the MMS domain name of the variable
  882. * \param itemId the name for the MMS variable
  883. *
  884. * \return reference to the new MmsVariableSpecfication object
  885. */
  886. LIB61850_API MmsVariableAccessSpecification*
  887. MmsVariableAccessSpecification_create(char* domainId, char* itemId);
  888. /**
  889. * \brief Create a new MmsVariableSpecification that can be used to define named variable lists.
  890. *
  891. * The created object can be deleted with free(). If the parameter strings were dynamically
  892. * allocated the deallocation is in the responsibility of the user. This function should be
  893. * used for named variable list entries that are array elements or components of array elements
  894. * in the case when the array element is of complex (structured) type.
  895. *
  896. * \param domainId the MMS domain name of the variable
  897. * \param itemId the name for the MMS variable
  898. * \param index the array index to describe an array element
  899. * \param componentName the name of the component of the array element. Should be set to NULL
  900. * if the array element is of simple type or the whole array element is required.
  901. *
  902. * \return reference to the new MmsVariableSpecfication object
  903. */
  904. LIB61850_API MmsVariableAccessSpecification*
  905. MmsVariableAccessSpecification_createAlternateAccess(char* domainId, char* itemId, int32_t index,
  906. char* componentName);
  907. /**
  908. * \brief Delete the MmsVariableAccessSpecification data structure
  909. *
  910. * \param self the instance to delete
  911. */
  912. LIB61850_API void
  913. MmsVariableAccessSpecification_destroy(MmsVariableAccessSpecification* self);
  914. /**
  915. * \brief Get the MMS local detail parameter (local detail means maximum MMS PDU size).
  916. *
  917. * This defaults to 65000 (or the value specified in the stack_config.h file.
  918. * This function should not be called after a successful connection attempt.
  919. *
  920. * \param self MmsConnection instance to operate on
  921. * \param localDetail the maximum size of the MMS PDU that will be accepted.
  922. */
  923. LIB61850_API void
  924. MmsConnection_setLocalDetail(MmsConnection self, int32_t localDetail);
  925. LIB61850_API int32_t
  926. MmsConnection_getLocalDetail(MmsConnection self);
  927. /**
  928. * \brief get the identity of the connected server
  929. *
  930. * This function will return the identity of the server if the server supports the MMS identify service.
  931. * The server identity consists of a vendor name, model name, and a revision.
  932. *
  933. * \param self MmsConnection instance to operate on
  934. * \param mmsError user provided variable to store error code
  935. */
  936. LIB61850_API MmsServerIdentity*
  937. MmsConnection_identify(MmsConnection self, MmsError* mmsError);
  938. typedef void
  939. (*MmsConnection_IdentifyHandler) (uint32_t invokeId, void* parameter, MmsError mmsError,
  940. char* vendorName, char* modelName, char* revision);
  941. LIB61850_API void
  942. MmsConnection_identifyAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
  943. MmsConnection_IdentifyHandler handler, void* parameter);
  944. /**
  945. * \brief Destroy (free) an MmsServerIdentity object
  946. *
  947. * \param self the object to destroy
  948. */
  949. LIB61850_API void
  950. MmsServerIdentity_destroy(MmsServerIdentity* self);
  951. /**
  952. * \brief get the VMD status of the connected server (is MMS status service)
  953. *
  954. * This function will return the status of the connected server by invoking the MMS status service.
  955. * The services returns the logical and physical states of the server.
  956. *
  957. * \param[in] self MmsConnection instance to operate on
  958. * \param[out] mmsError user provided variable to store error code
  959. * \param[out] vmdLogicalStatus user provided variable to store the logical state of the VMD
  960. * \param[out] vmdPhysicalStatus user provided variable to store the physical state of the VMD
  961. * \param[in] extendedDerivation instructs the server to invoke self-diagnosis routines to determine server status
  962. */
  963. LIB61850_API void
  964. MmsConnection_getServerStatus(MmsConnection self, MmsError* mmsError, int* vmdLogicalStatus, int* vmdPhysicalStatus,
  965. bool extendedDerivation);
  966. typedef void
  967. (*MmsConnection_GetServerStatusHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, int vmdLogicalStatus, int vmdPhysicalStatus);
  968. LIB61850_API void
  969. MmsConnection_getServerStatusAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, bool extendedDerivation,
  970. MmsConnection_GetServerStatusHandler handler, void* parameter);
  971. /*******************************************************************************
  972. * functions for MMS file services
  973. *******************************************************************************/
  974. typedef void
  975. (*MmsFileDirectoryHandler) (void* parameter, char* filename, uint32_t size, uint64_t lastModified);
  976. /**
  977. * \brief Callback handler for the get file directory service
  978. *
  979. * Will be called once for each file directory entry and after the last entry with \ref filename = NULL to indicate
  980. * with \ref moreFollows set to true when more data is available server side. In case of an error the callback will be called with
  981. * \ref mmsError != MMS_ERROR_NONE and moreFollows = false.
  982. */
  983. typedef void
  984. (*MmsConnection_FileDirectoryHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, char* filename, uint32_t size, uint64_t lastModfified,
  985. bool moreFollows);
  986. typedef void
  987. (*MmsFileReadHandler) (void* parameter, int32_t frsmId, uint8_t* buffer, uint32_t bytesReceived);
  988. /**
  989. * \brief Callback handler for the file read service
  990. *
  991. * Will be called for every received part of the file and when there is an error during reading the file.
  992. *
  993. * \param invokeId invokeID of the response
  994. * \param parameter user provided context parameter
  995. * \param mmsError error code
  996. * \param frsmId ID of the file
  997. * \param buffer buffer where the received bytes are stored
  998. * \param bytesReceived number of bytes received with this response
  999. * \param moreFollows more messages with parts of the file are following
  1000. */
  1001. typedef void
  1002. (*MmsConnection_FileReadHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, int32_t frsmId, uint8_t* buffer, uint32_t byteReceived,
  1003. bool moreFollows);
  1004. /**
  1005. * \brief open a file for read
  1006. *
  1007. * \param self MmsConnection instance to operate on
  1008. * \param mmsError user provided variable to store error code
  1009. *
  1010. * \return the FRSM ID (file read state machine) handle of the opened file
  1011. */
  1012. LIB61850_API int32_t
  1013. MmsConnection_fileOpen(MmsConnection self, MmsError* mmsError, const char* filename, uint32_t initialPosition,
  1014. uint32_t* fileSize, uint64_t* lastModified);
  1015. typedef void
  1016. (*MmsConnection_FileOpenHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, int32_t frsmId, uint32_t fileSize, uint64_t lastModified);
  1017. LIB61850_API void
  1018. MmsConnection_fileOpenAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* filename, uint32_t initialPosition, MmsConnection_FileOpenHandler handler,
  1019. void* parameter);
  1020. /**
  1021. * \brief read the next data block from the file
  1022. *
  1023. * \param self MmsConnection instance to operate on
  1024. * \param mmsError user provided variable to store error code
  1025. * \param frsmId the FRSM ID (file read state machine) handle of the file
  1026. * \param handler callback that is invoked to deliver the received data
  1027. * \param handlerParameter user provided paramter that is passed to the callback function
  1028. *
  1029. * \return true if more data follows, false if last data has been received.
  1030. */
  1031. LIB61850_API bool
  1032. MmsConnection_fileRead(MmsConnection self, MmsError* mmsError, int32_t frsmId, MmsFileReadHandler handler, void* handlerParameter);
  1033. LIB61850_API void
  1034. MmsConnection_fileReadAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, int32_t frsmId, MmsConnection_FileReadHandler handler, void* parameter);
  1035. /**
  1036. * \brief close the file with the specified frsmID
  1037. *
  1038. * \param self MmsConnection instance to operate on
  1039. * \param mmsError user provided variable to store error code
  1040. * \param frsmId id of the file to close
  1041. */
  1042. LIB61850_API void
  1043. MmsConnection_fileClose(MmsConnection self, MmsError* mmsError, int32_t frsmId);
  1044. LIB61850_API void
  1045. MmsConnection_fileCloseAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, uint32_t frsmId, MmsConnection_GenericServiceHandler handler, void* parameter);
  1046. /**
  1047. * \brief delete the file with the specified name
  1048. *
  1049. * \param self MmsConnection instance to operate on
  1050. * \param mmsError user provided variable to store error code
  1051. * \param fileName name of the file to delete
  1052. */
  1053. LIB61850_API void
  1054. MmsConnection_fileDelete(MmsConnection self, MmsError* mmsError, const char* fileName);
  1055. LIB61850_API void
  1056. MmsConnection_fileDeleteAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* fileName,
  1057. MmsConnection_GenericServiceHandler handler, void* parameter);
  1058. /**
  1059. * \brief rename the file with the specified name
  1060. *
  1061. * \param self MmsConnection instance to operate on
  1062. * \param mmsError user provided variable to store error code
  1063. * \param currentFileName name of the file to rename
  1064. * \param newFileName new name of the file
  1065. */
  1066. LIB61850_API void
  1067. MmsConnection_fileRename(MmsConnection self, MmsError* mmsError, const char* currentFileName, const char* newFileName);
  1068. LIB61850_API void
  1069. MmsConnection_fileRenameAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* currentFileName, const char* newFileName,
  1070. MmsConnection_GenericServiceHandler handler, void* parameter);
  1071. /**
  1072. * \brief Send an obtainFile request to the server (used to initiate file download to server)
  1073. *
  1074. * \param self MmsConnection instance to operate on
  1075. * \param mmsError user provided variable to store error code
  1076. * \param sourceFile the name of the source file (client side name)
  1077. * \param destinationFile the name of the destination file (server side name)
  1078. */
  1079. LIB61850_API void
  1080. MmsConnection_obtainFile(MmsConnection self, MmsError* mmsError, const char* sourceFile, const char* destinationFile);
  1081. LIB61850_API void
  1082. MmsConnection_obtainFileAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* sourceFile, const char* destinationFile,
  1083. MmsConnection_GenericServiceHandler handler, void* parameter);
  1084. /**
  1085. * \brief get the file directory of the server.
  1086. *
  1087. * This function will return the directory entries of the given server directory. For each directory entry
  1088. * the provided callback handler is called. If the
  1089. *
  1090. * \param self MmsConnection instance to operate on
  1091. * \param mmsError user provided variable to store error code
  1092. * \param fileSpecification the file specification of the directory to browse or NULL to browse the root directory
  1093. * \param continueAfter continuation point or NULL for the first request. The continuation point is the first entry
  1094. * after the provided continuation file name.
  1095. * \param handler user provided callback handler
  1096. * \param handlerParameter user provided parameter that is passed to the handler
  1097. *
  1098. * \return (more follows) true if more data is available
  1099. */
  1100. LIB61850_API bool
  1101. MmsConnection_getFileDirectory(MmsConnection self, MmsError* mmsError, const char* fileSpecification, const char* continueAfter,
  1102. MmsFileDirectoryHandler handler, void* handlerParameter);
  1103. LIB61850_API void
  1104. MmsConnection_getFileDirectoryAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* fileSpecification, const char* continueAfter,
  1105. MmsConnection_FileDirectoryHandler handler, void* parameter);
  1106. typedef struct sMmsJournalEntry* MmsJournalEntry;
  1107. typedef struct sMmsJournalVariable* MmsJournalVariable;
  1108. struct sMmsJournalEntry {
  1109. MmsValue* entryID; /* type MMS_OCTET_STRING */
  1110. MmsValue* occurenceTime; /* type MMS_BINARY_TIME */
  1111. LinkedList journalVariables;
  1112. };
  1113. struct sMmsJournalVariable {
  1114. char* tag;
  1115. MmsValue* value;
  1116. };
  1117. /**
  1118. * \brief Destroy a single MmsJournalEntry instance.
  1119. *
  1120. * This function will destroy the whole MmsJournalEntry object including the attached list
  1121. * of MmsJournalVariable objects. It is intended to be used in conjunction with the
  1122. * LinkedList_destroyDeep function in order to free the result of MmsConnection_readJournalTimeRange
  1123. * or MmsConnection_readJournalStartAfter
  1124. *
  1125. * LinkedList_destroyDeep(journalEntries, (LinkedListValueDeleteFunction)
  1126. * MmsJournalEntry_destroy);
  1127. *
  1128. * \param self the MmsJournalEntry instance to destroy
  1129. */
  1130. LIB61850_API void
  1131. MmsJournalEntry_destroy(MmsJournalEntry self);
  1132. LIB61850_API MmsValue*
  1133. MmsJournalEntry_getEntryID(MmsJournalEntry self);
  1134. LIB61850_API MmsValue*
  1135. MmsJournalEntry_getOccurenceTime(MmsJournalEntry self);
  1136. LIB61850_API LinkedList /* <MmsJournalVariable> */
  1137. MmsJournalEntry_getJournalVariables(MmsJournalEntry self);
  1138. LIB61850_API const char*
  1139. MmsJournalVariable_getTag(MmsJournalVariable self);
  1140. LIB61850_API MmsValue*
  1141. MmsJournalVariable_getValue(MmsJournalVariable self);
  1142. typedef void
  1143. (*MmsConnection_ReadJournalHandler) (uint32_t invokeId, void* parameter, MmsError mmsError, LinkedList /* <MmsJournalEntry> */ journalEntries, bool moreFollows);
  1144. LIB61850_API LinkedList /* <MmsJournalEntry> */
  1145. MmsConnection_readJournalTimeRange(MmsConnection self, MmsError* mmsError, const char* domainId, const char* itemId,
  1146. MmsValue* startTime, MmsValue* endTime, bool* moreFollows);
  1147. LIB61850_API void
  1148. MmsConnection_readJournalTimeRangeAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId, const char* itemId,
  1149. MmsValue* startTime, MmsValue* endTime, MmsConnection_ReadJournalHandler handler, void* parameter);
  1150. LIB61850_API LinkedList /* <MmsJournalEntry> */
  1151. MmsConnection_readJournalStartAfter(MmsConnection self, MmsError* mmsError, const char* domainId, const char* itemId,
  1152. MmsValue* timeSpecification, MmsValue* entrySpecification, bool* moreFollows);
  1153. LIB61850_API void
  1154. MmsConnection_readJournalStartAfterAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId, const char* itemId,
  1155. MmsValue* timeSpecification, MmsValue* entrySpecification, MmsConnection_ReadJournalHandler handler, void* parameter);
  1156. /**@}*/
  1157. #ifdef __cplusplus
  1158. }
  1159. #endif
  1160. #endif /* MMS_CLIENT_CONNECTION_H_ */