mms_client_connection.h 55 KB

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