iec61850_server.h 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803
  1. /*
  2. * iec61850_server.h
  3. *
  4. * IEC 61850 server API for libiec61850.
  5. *
  6. * Copyright 2013-2022 Michael Zillgith
  7. *
  8. * This file is part of libIEC61850.
  9. *
  10. * libIEC61850 is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * libIEC61850 is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * See COPYING file for the complete license text.
  24. *
  25. */
  26. #ifndef IED_SERVER_API_H_
  27. #define IED_SERVER_API_H_
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /** \defgroup server_api_group IEC 61850/MMS server API
  32. * @{
  33. */
  34. #include "mms_server.h"
  35. #include "iec61850_dynamic_model.h"
  36. #include "iec61850_model.h"
  37. #include "hal_filesystem.h"
  38. #include "iso_connection_parameters.h"
  39. #include "iec61850_config_file_parser.h"
  40. /**
  41. * \brief Configuration object to configure IEC 61850 stack features
  42. */
  43. typedef struct sIedServerConfig* IedServerConfig;
  44. struct sIedServerConfig
  45. {
  46. /** size of the report buffer associated with a buffered report control block */
  47. int reportBufferSize;
  48. /** size of the report buffer associated with an unbuffered report control block */
  49. int reportBufferSizeURCBs;
  50. /** Base path (directory where the file service serves files */
  51. char* fileServiceBasepath;
  52. /** when true (default) enable MMS file service */
  53. bool enableFileService;
  54. /** when true (default) enable dynamic data set services for MMS */
  55. bool enableDynamicDataSetService;
  56. /** the maximum number of allowed association specific data sets */
  57. int maxAssociationSpecificDataSets;
  58. /** the maximum number of allowed domain specific data sets */
  59. int maxDomainSpecificDataSets;
  60. /** maximum number of data set entries of dynamic data sets */
  61. int maxDataSetEntries;
  62. /** when true (default) enable log service */
  63. bool enableLogService;
  64. /** when true (default) the integrated GOOSE publisher is used */
  65. bool useIntegratedGoosePublisher;
  66. /** IEC 61850 edition (0 = edition 1, 1 = edition 2, 2 = edition 2.1, ...) */
  67. uint8_t edition;
  68. /** maximum number of MMS (TCP) connections */
  69. int maxMmsConnections;
  70. /** enable EditSG service (default: true) */
  71. bool enableEditSG;
  72. /** enable visibility of SGCB.ResvTms (default: true) */
  73. bool enableResvTmsForSGCB;
  74. /** BRCB has resvTms attribute - only edition 2 (default: true) */
  75. bool enableResvTmsForBRCB;
  76. /** RCB has owner attribute (default: true) */
  77. bool enableOwnerForRCB;
  78. };
  79. /**
  80. * \brief Create a new configuration object
  81. *
  82. * \return a new configuration object with default configuration values
  83. */
  84. LIB61850_API IedServerConfig
  85. IedServerConfig_create(void);
  86. /**
  87. * \brief Destroy the configuration object
  88. */
  89. LIB61850_API void
  90. IedServerConfig_destroy(IedServerConfig self);
  91. /**
  92. * \brief Set the IEC 61850 standard edition to use (default is edition 2)
  93. *
  94. * \param edition IEC_61850_EDITION_1, IEC_61850_EDITION_2, or IEC_61850_EDITION_2_1
  95. */
  96. LIB61850_API void
  97. IedServerConfig_setEdition(IedServerConfig self, uint8_t edition);
  98. /**
  99. * \brief Get the configued IEC 61850 standard edition
  100. *
  101. * \returns IEC_61850_EDITION_1, IEC_61850_EDITION_2, or IEC_61850_EDITION_2_1
  102. */
  103. LIB61850_API uint8_t
  104. IedServerConfig_getEdition(IedServerConfig self);
  105. /**
  106. * \brief Set the report buffer size for buffered reporting
  107. *
  108. * \param reportBufferSize the buffer size for each buffered report control block
  109. */
  110. LIB61850_API void
  111. IedServerConfig_setReportBufferSize(IedServerConfig self, int reportBufferSize);
  112. /**
  113. * \brief Gets the report buffer size for buffered reporting
  114. *
  115. * \return the buffer size for each buffered report control block
  116. */
  117. LIB61850_API int
  118. IedServerConfig_getReportBufferSize(IedServerConfig self);
  119. /**
  120. * \brief Set the report buffer size for unbuffered reporting
  121. *
  122. * \param reportBufferSize the buffer size for each unbuffered report control block
  123. */
  124. LIB61850_API void
  125. IedServerConfig_setReportBufferSizeForURCBs(IedServerConfig self, int reportBufferSize);
  126. /**
  127. * \brief Gets the report buffer size for unbuffered reporting
  128. *
  129. * \return the buffer size for each unbuffered report control block
  130. */
  131. LIB61850_API int
  132. IedServerConfig_getReportBufferSizeForURCBs(IedServerConfig self);
  133. /**
  134. * \brief Set the maximum number of MMS (TCP) connections the server accepts
  135. *
  136. * NOTE: Parameter has to be smaller than CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS if
  137. * CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS != -1
  138. *
  139. * \param maxConnection maximum number of TCP connections
  140. */
  141. LIB61850_API void
  142. IedServerConfig_setMaxMmsConnections(IedServerConfig self, int maxConnections);
  143. /**
  144. * \brief Get the maximum number of MMS (TCP) connections the server accepts
  145. *
  146. * \return maximum number of TCP connections
  147. */
  148. LIB61850_API int
  149. IedServerConfig_getMaxMmsConnections(IedServerConfig self);
  150. /**
  151. * \brief Set the basepath of the file services
  152. *
  153. * NOTE: the basepath specifies the local directory that is served by MMS file services
  154. *
  155. * \param basepath new file service base path
  156. */
  157. LIB61850_API void
  158. IedServerConfig_setFileServiceBasePath(IedServerConfig self, const char* basepath);
  159. /**
  160. * \brief Get the basepath of the file services
  161. */
  162. LIB61850_API const char*
  163. IedServerConfig_getFileServiceBasePath(IedServerConfig self);
  164. /**
  165. * \brief Enable/disable the MMS file service support
  166. *
  167. * \param[in] enable set true to enable the file services, otherwise false
  168. */
  169. LIB61850_API void
  170. IedServerConfig_enableFileService(IedServerConfig self, bool enable);
  171. /**
  172. * \brief Is the MMS file service enabled or disabled
  173. *
  174. * \return true if enabled, false otherwise
  175. */
  176. LIB61850_API bool
  177. IedServerConfig_isFileServiceEnabled(IedServerConfig self);
  178. /**
  179. * \brief Enable/disable the dynamic data set service for MMS
  180. *
  181. * \param[in] enable set true to enable dynamic data set service, otherwise false
  182. */
  183. LIB61850_API void
  184. IedServerConfig_enableDynamicDataSetService(IedServerConfig self, bool enable);
  185. /**
  186. * \brief Is the dynamic data set service for MMS enabled or disabled
  187. *
  188. * \return true if enabled, false otherwise
  189. */
  190. LIB61850_API bool
  191. IedServerConfig_isDynamicDataSetServiceEnabled(IedServerConfig self);
  192. /**
  193. * \brief Set the maximum allowed number of association specific (non-permanent) data sets
  194. *
  195. * NOTE: This specifies the maximum number of non-permanent data sets per connection. When
  196. * the connection is closed these data sets are deleted automatically.
  197. *
  198. * \param maxDataSets maximum number of allowed data sets.
  199. */
  200. LIB61850_API void
  201. IedServerConfig_setMaxAssociationSpecificDataSets(IedServerConfig self, int maxDataSets);
  202. /**
  203. * \brief Get the maximum allowed number of association specific (non-permanent) data sets
  204. *
  205. * \return maximum number of allowed data sets.
  206. */
  207. LIB61850_API int
  208. IedServerConfig_getMaxAssociationSpecificDataSets(IedServerConfig self);
  209. /**
  210. * \brief Set the maximum allowed number of domain specific (permanent) data sets
  211. *
  212. * \param maxDataSets maximum number of allowed data sets.
  213. */
  214. LIB61850_API void
  215. IedServerConfig_setMaxDomainSpecificDataSets(IedServerConfig self, int maxDataSets);
  216. /**
  217. * \brief Get the maximum allowed number of domain specific (permanent) data sets
  218. *
  219. * \return maximum number of allowed data sets.
  220. */
  221. LIB61850_API int
  222. IedServerConfig_getMaxDomainSpecificDataSets(IedServerConfig self);
  223. /**
  224. * \brief Set the maximum number of entries in dynamic data sets
  225. *
  226. * NOTE: this comprises the base data set entries (can be simple or complex variables).
  227. * When the client tries to create a data set with more member the request will be
  228. * rejected and the data set will not be created.
  229. *
  230. * \param maxDataSetEntries the maximum number of entries allowed in a data set
  231. */
  232. LIB61850_API void
  233. IedServerConfig_setMaxDataSetEntries(IedServerConfig self, int maxDataSetEntries);
  234. /**
  235. * \brief Get the maximum number of entries in dynamic data sets
  236. *
  237. * \return the maximum number of entries allowed in a data sets
  238. */
  239. LIB61850_API int
  240. IedServerConfig_getMaxDatasSetEntries(IedServerConfig self);
  241. /**
  242. * \brief Enable/disable the log service for MMS
  243. *
  244. * \param[in] enable set true to enable log service, otherwise false
  245. */
  246. LIB61850_API void
  247. IedServerConfig_enableLogService(IedServerConfig self, bool enable);
  248. /**
  249. * \brief Enable/disable the EditSG service to allow clients to change setting groups (default is enabled)
  250. *
  251. * NOTE: When disabled SGCB.ResvTms is not available online and the setting of \ref IedServerConfig_enableResvTmsForSGCB
  252. * is ignored.
  253. *
  254. * \param[in] enable set true to enable, otherwise false (default value it true)
  255. */
  256. LIB61850_API void
  257. IedServerConfig_enableEditSG(IedServerConfig self, bool enable);
  258. /**
  259. * \brief Enable/disable the SGCB.ResvTms when EditSG is enabled
  260. *
  261. * NOTE: When EditSG is disabled (see \ref IedServerConfig_enableEditSG) then this setting is ignored.
  262. *
  263. * \param[in] enable set true to enable, otherwise false (default value it true)
  264. */
  265. LIB61850_API void
  266. IedServerConfig_enableResvTmsForSGCB(IedServerConfig self, bool enable);
  267. /**
  268. * \brief Enable/disable the presence of BRCB.ResvTms (default value is true)
  269. *
  270. * \param[in] enable set true to enable, otherwise false
  271. */
  272. LIB61850_API void
  273. IedServerConfig_enableResvTmsForBRCB(IedServerConfig self, bool enable);
  274. /**
  275. * \brief ResvTms for BRCB enabled (visible)
  276. *
  277. * \return true if enabled, false otherwise
  278. */
  279. LIB61850_API bool
  280. IedServerConfig_isResvTmsForBRCBEnabled(IedServerConfig self);
  281. /**
  282. * \brief Enable/disable the presence of owner in report control blocks (default value is false);
  283. *
  284. * \param[in] enable set true to enable, otherwise false
  285. */
  286. LIB61850_API void
  287. IedServerConfig_enableOwnerForRCB(IedServerConfig self, bool enable);
  288. /**
  289. * \brief Owner for RCBs enabled (visible)
  290. *
  291. * \return true if enabled, false otherwise
  292. */
  293. LIB61850_API bool
  294. IedServerConfig_isOwnerForRCBEnabled(IedServerConfig self);
  295. /**
  296. * \brief Enable/disable using the integrated GOOSE publisher for configured GoCBs
  297. *
  298. * This is enabled by default. Disable it when you want to use a separate GOOSE publisher
  299. *
  300. * \param[in] enable set true to enable the integrated GOOSE publisher, otherwise false
  301. */
  302. LIB61850_API void
  303. IedServerConfig_useIntegratedGoosePublisher(IedServerConfig self, bool enable);
  304. /**
  305. * \brief Is the log service for MMS enabled or disabled
  306. *
  307. * \return true if enabled, false otherwise
  308. */
  309. LIB61850_API bool
  310. IedServerConfig_isLogServiceEnabled(IedServerConfig self);
  311. /**
  312. * An opaque handle for an IED server instance
  313. */
  314. typedef struct sIedServer* IedServer;
  315. /**
  316. * An opaque handle for a client connection
  317. */
  318. typedef struct sClientConnection* ClientConnection;
  319. /**
  320. * @defgroup IEC61850_SERVER_GENERAL General server setup and management functions
  321. *
  322. * @{
  323. */
  324. /**
  325. * \brief Create a new IedServer instance
  326. *
  327. * \param dataModel reference to the IedModel data structure to be used as IEC 61850 data model of the device
  328. *
  329. * \return the new IedServer instance
  330. */
  331. LIB61850_API IedServer
  332. IedServer_create(IedModel* dataModel);
  333. /**
  334. * \brief Create a new IedServer with TLS support
  335. *
  336. * \param dataModel reference to the IedModel data structure to be used as IEC 61850 data model of the device
  337. * \param tlsConfiguration TLS configuration object, or NULL to not use TLS
  338. *
  339. * \return the new IedServer instance
  340. */
  341. LIB61850_API IedServer
  342. IedServer_createWithTlsSupport(IedModel* dataModel, TLSConfiguration tlsConfiguration);
  343. /**
  344. * \brief Create new new IedServer with extended configurations parameters
  345. *
  346. * \param dataModel reference to the IedModel data structure to be used as IEC 61850 data model of the device
  347. * \param tlsConfiguration TLS configuration object, or NULL to not use TLS
  348. * \param serverConfiguration IED server configuration object for advanced server configuration
  349. */
  350. LIB61850_API IedServer
  351. IedServer_createWithConfig(IedModel* dataModel, TLSConfiguration tlsConfiguration, IedServerConfig serverConfiguration);
  352. /**
  353. * \brief Destroy an IedServer instance and release all resources (memory, TCP sockets)
  354. *
  355. * \param self the instance of IedServer to operate on.
  356. */
  357. LIB61850_API void
  358. IedServer_destroy(IedServer self);
  359. /**
  360. * \brief Add a new local access point (server will listen to provided IP/port combination)
  361. *
  362. * \param self the instance of IedServer to operate on.
  363. * \param ipAddr the local IP address to listen on
  364. * \param tcpPort the local TCP port to listen on or -1 to use the standard TCP port
  365. * \oaram tlsConfiguration the TLS configuration or NULL when TLS is not used for this access point
  366. *
  367. * \return true in case of success, false otherwise
  368. */
  369. LIB61850_API bool
  370. IedServer_addAccessPoint(IedServer self, const char* ipAddr, int tcpPort, TLSConfiguration tlsConfiguration);
  371. /**
  372. * \brief Set the local IP address to listen on
  373. *
  374. * \param self the IedServer instance
  375. * \param localIpAddress the local IP address as C string (an internal copy will be created)
  376. */
  377. LIB61850_API void
  378. IedServer_setLocalIpAddress(IedServer self, const char* localIpAddress);
  379. /**
  380. * \brief Set the identify for the MMS identify service
  381. *
  382. * CONFIG_IEC61850_SUPPORT_SERVER_IDENTITY required
  383. *
  384. * \param self the IedServer instance
  385. * \param vendor the IED vendor name
  386. * \param model the IED model name
  387. * \param revision the IED revision/version number
  388. */
  389. LIB61850_API void
  390. IedServer_setServerIdentity(IedServer self, const char* vendor, const char* model, const char* revision);
  391. /**
  392. * \brief Set the virtual filestore basepath for the MMS file services
  393. *
  394. * All external file service accesses will be mapped to paths relative to the base directory.
  395. * NOTE: This function is only available when the CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME
  396. * option in stack_config.h is set.
  397. *
  398. * \param self the IedServer instance
  399. * \param basepath the new virtual filestore basepath
  400. */
  401. LIB61850_API void
  402. IedServer_setFilestoreBasepath(IedServer self, const char* basepath);
  403. /**
  404. * \brief Start handling client connections
  405. *
  406. * \param self the instance of IedServer to operate on.
  407. * \param tcpPort the TCP port the server is listening (-1 for using the default MMS or secure MMS port)
  408. */
  409. LIB61850_API void
  410. IedServer_start(IedServer self, int tcpPort);
  411. /**
  412. * \brief Stop handling client connections
  413. *
  414. * \param self the instance of IedServer to operate on.
  415. */
  416. LIB61850_API void
  417. IedServer_stop(IedServer self);
  418. /**
  419. * \brief Start handling client connection for non-threaded mode
  420. *
  421. * This function will instruct the TCP(IP stack to listen for incoming connections.
  422. * In order to accept new connection the function IedServer_processIncomingData has to
  423. * be called periodically.
  424. *
  425. * \param self the instance of IedServer to operate on.
  426. * \param tcpPort the TCP port the server is listening (-1 for using the default MMS or secure MMS port)
  427. */
  428. LIB61850_API void
  429. IedServer_startThreadless(IedServer self, int tcpPort);
  430. /**
  431. * \brief Wait until a server connection is ready (with timeout)
  432. *
  433. * The function will wait until a server connection is ready (data available) or the
  434. * timeout elapsed. This function is intended for the non-threaded mode. Its use is optional.
  435. * It is equivalent of using select on sockets on Linux. If the return value is != 0 the
  436. * IedServer_processIncomingData function should be called.
  437. *
  438. * \param self the IedServer instance
  439. * \param timeoutMs the timeout to wait when no connection is ready
  440. *
  441. * \return 0 if no connection is ready; otherwise at least one connection is ready
  442. */
  443. LIB61850_API int
  444. IedServer_waitReady(IedServer self, unsigned int timeoutMs);
  445. /**
  446. * \brief handle incoming TCP data in non-threaded mode
  447. *
  448. * The function should be called periodically. If the function is called more often
  449. * the response time for incoming messages will be faster. As an alternative the
  450. * function may only be called if new TCP data is available.
  451. *
  452. * \param self the instance of IedServer to operate on.
  453. */
  454. LIB61850_API void
  455. IedServer_processIncomingData(IedServer self);
  456. /**
  457. * \brief perform periodic background tasks in non-threaded mode
  458. *
  459. * The function should be called periodically. If the function is called more often
  460. * the more accurate are internal timeouts (e.g. for reports).
  461. *
  462. * \param self the instance of IedServer to operate on.
  463. */
  464. LIB61850_API void
  465. IedServer_performPeriodicTasks(IedServer self);
  466. /**
  467. * \brief Stop handling client connections for non-threaded mode
  468. *
  469. * \param self the instance of IedServer to operate on.
  470. */
  471. LIB61850_API void
  472. IedServer_stopThreadless(IedServer self);
  473. /**
  474. * \brief Return the data model of the server
  475. *
  476. * \param self the instance of IedServer to operate on.
  477. *
  478. * \return the IedModel* instance of the server
  479. */
  480. LIB61850_API IedModel*
  481. IedServer_getDataModel(IedServer self);
  482. /**
  483. * \brief Check if IedServer instance is listening for client connections
  484. *
  485. * \param self the instance of IedServer to operate on.
  486. *
  487. * \return true if IedServer instance is listening for client connections
  488. */
  489. LIB61850_API bool
  490. IedServer_isRunning(IedServer self);
  491. /**
  492. * \brief Get number of open MMS connections
  493. *
  494. * \param self the instance of IedServer to operate on
  495. *
  496. * \return the number of open and accepted MMS connections
  497. */
  498. LIB61850_API int
  499. IedServer_getNumberOfOpenConnections(IedServer self);
  500. /**
  501. * \brief Get access to the underlying MmsServer instance.
  502. *
  503. * This function should be handled with care. Since direct interaction with the
  504. * MmsServer can interfere with the IedServer.
  505. *
  506. * \param self the instance of IedServer to operate on.
  507. *
  508. * \return MmsServer instance that is used by the IedServer
  509. */
  510. LIB61850_API MmsServer
  511. IedServer_getMmsServer(IedServer self);
  512. /**
  513. * \brief Enable all GOOSE control blocks.
  514. *
  515. * This will set the GoEna attribute of all configured GOOSE control blocks
  516. * to true. If this method is not called at the startup or reset of the server
  517. * then configured GOOSE control blocks keep inactive until a MMS client enables
  518. * them by writing to the GOOSE control block.
  519. *
  520. * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  521. *
  522. * \param self the instance of IedServer to operate on.
  523. */
  524. LIB61850_API void
  525. IedServer_enableGoosePublishing(IedServer self);
  526. /**
  527. * \brief Disable all GOOSE control blocks.
  528. *
  529. * This will set the GoEna attribute of all configured GOOSE control blocks
  530. * to false. This will stop GOOSE transmission.
  531. *
  532. * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  533. *
  534. * \param self the instance of IedServer to operate on.
  535. */
  536. LIB61850_API void
  537. IedServer_disableGoosePublishing(IedServer self);
  538. /**
  539. * \brief Set the Ethernet interface to be used by GOOSE publishing
  540. *
  541. * This function can be used to set the GOOSE interface ID. If not used or set to NULL the
  542. * default interface ID from stack_config.h is used. Note the interface ID is operating system
  543. * specific!
  544. *
  545. * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  546. *
  547. * \param self the instance of IedServer to operate on.
  548. * \param interfaceId the ID of the ethernet interface to be used for GOOSE publishing
  549. */
  550. LIB61850_API void
  551. IedServer_setGooseInterfaceId(IedServer self, const char* interfaceId);
  552. /**
  553. * \brief Set the Ethernet interface to be used by GOOSE publishing
  554. *
  555. * This function can be used to set the GOOSE interface ID forG all CBs (parameter ln = NULL) or for
  556. * a specific GCB specified by the logical node instance and the GCB name.
  557. *
  558. * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  559. *
  560. * \param self the instance of IedServer to operate on.
  561. * \param ln the logical node that contains the GCB or NULL to set the ethernet interface ID for all GCBs
  562. * \param gcbName the name (not object reference!) of the GCB
  563. * \param interfaceId the ID of the ethernet interface to be used for GOOSE publishing
  564. */
  565. LIB61850_API void
  566. IedServer_setGooseInterfaceIdEx(IedServer self, LogicalNode* ln, const char* gcbName, const char* interfaceId);
  567. /**
  568. * \brief Enable/disable the use of VLAN tags in GOOSE messages
  569. *
  570. * This function can be used to enable/disable VLAN tagging for all GCBs (parameter ln = NULL) or for
  571. * a specific GCB specified by the logical node instance and the GCB name.
  572. *
  573. * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  574. *
  575. * \param self the instance of IedServer to operate on
  576. * \param ln the logical node that contains the GCB or NULL to enable/disable VLAN tagging for all GCBs
  577. * \param gcbName the name (not object reference!) of the GCB
  578. * \param useVlanTag true to enable VLAN tagging, false otherwise
  579. */
  580. LIB61850_API void
  581. IedServer_useGooseVlanTag(IedServer self, LogicalNode* ln, const char* gcbName, bool useVlanTag);
  582. /**@}*/
  583. /**
  584. * @defgroup IEC61850_SERVER_CONNECTION_HANDLING Connection handling and client authentication
  585. *
  586. * @{
  587. */
  588. /**
  589. * \brief set the authenticator for this server
  590. *
  591. * This function sets a user specified authenticator that is used to identify and authenticate clients that
  592. * wants to connect. The authenticator is called on each connection attempt. Depending on the return value
  593. * of the authenticator the client connection is accepted or refused. If no authenticator is set all client
  594. * connections are accepted.
  595. *
  596. * \param self the instance of IedServer to operate on.
  597. * \param authenticator the user provided authenticator callback
  598. * \param authenticatorParameter user provided parameter that is passed to the authenticator
  599. */
  600. LIB61850_API void
  601. IedServer_setAuthenticator(IedServer self, AcseAuthenticator authenticator, void* authenticatorParameter);
  602. /**
  603. * \brief get the peer address of this connection as string
  604. *
  605. * Note: the returned string is only valid as long as the client connection exists. It is save to use
  606. * the string inside of the connection indication callback function.
  607. *
  608. * \param self the ClientConnection instance
  609. * \return peer address as C string.
  610. */
  611. LIB61850_API const char*
  612. ClientConnection_getPeerAddress(ClientConnection self);
  613. /**
  614. * \brief get the local address of this connection as string
  615. *
  616. * Note: the returned string is only valid as long as the client connection exists. It is save to use
  617. * the string inside of the connection indication callback function.
  618. *
  619. * \param self the ClientConnection instance
  620. * \return local address as C string.
  621. */
  622. LIB61850_API const char*
  623. ClientConnection_getLocalAddress(ClientConnection self);
  624. /**
  625. * \brief Get the security token associated with this connection
  626. *
  627. * The security token is an opaque handle that is associated with the connection. It is provided by the
  628. * authenticator (if one is present). If no security token is used then this function returns NULL
  629. *
  630. * \param self the ClientConnection instance
  631. *
  632. * \return the security token or NULL
  633. */
  634. LIB61850_API void*
  635. ClientConnection_getSecurityToken(ClientConnection self);
  636. /**
  637. * \brief User provided callback function that is invoked whenever a new client connects or an existing connection is closed
  638. * or detected as lost.
  639. *
  640. * \param self the instance of IedServer where the connection event occured.
  641. * \param connection the new or closed client connect object
  642. * \param connected true if a new connection is indicated, false if the connection has been closed or detected as lost.
  643. * \param parameter a user provided parameter
  644. */
  645. typedef void (*IedConnectionIndicationHandler) (IedServer self, ClientConnection connection, bool connected, void* parameter);
  646. /**
  647. * \brief set a callback function that will be called on connection events (open or close).
  648. *
  649. * \param self the instance of IedServer to operate on.
  650. * \param handler the user provided callback function
  651. * \param parameter a user provided parameter that is passed to the callback function.
  652. */
  653. LIB61850_API void
  654. IedServer_setConnectionIndicationHandler(IedServer self, IedConnectionIndicationHandler handler, void* parameter);
  655. /**@}*/
  656. /**
  657. * @defgroup IEC61850_SERVER_DATA_MODEL_ACCESS Data model access and data update
  658. *
  659. * @{
  660. */
  661. /**
  662. * \brief Lock the data model for data update.
  663. *
  664. * This function should be called before the data model is updated.
  665. * After updating the data model the function \ref IedServer_unlockDataModel should be called.
  666. * Client requests will be postponed until the lock is removed.
  667. *
  668. * NOTE: This method should never be called inside of a library callback function. In the context of
  669. * a library callback the data model is always already locked! Calling this function inside of a
  670. * library callback may lead to a deadlock condition.
  671. *
  672. * \param self the instance of IedServer to operate on.
  673. */
  674. LIB61850_API void
  675. IedServer_lockDataModel(IedServer self);
  676. /**
  677. * \brief Unlock the data model and process pending client requests.
  678. *
  679. * NOTE: This method should never be called inside of a library callback function. In the context of
  680. * a library callback the data model is always already locked!
  681. *
  682. * \param self the instance of IedServer to operate on.
  683. */
  684. LIB61850_API void
  685. IedServer_unlockDataModel(IedServer self);
  686. /**
  687. * \brief Get data attribute value
  688. *
  689. * Get the MmsValue object of an MMS Named Variable that is part of the device model.
  690. * You should not manipulate the received object directly. Instead you should use
  691. * the IedServer_updateValue method.
  692. *
  693. * \param self the instance of IedServer to operate on.
  694. * \param dataAttribute the data attribute handle
  695. *
  696. * \return MmsValue object of the MMS Named Variable or NULL if the value does not exist.
  697. */
  698. LIB61850_API MmsValue*
  699. IedServer_getAttributeValue(IedServer self, DataAttribute* dataAttribute);
  700. /**
  701. * \brief Get data attribute value of a boolean data attribute
  702. *
  703. * Get the value of a data attribute of type MMS_BOOLEAN. If the data attribute
  704. * is of a different type the returned value is undefined.
  705. *
  706. * \param self the instance of IedServer to operate on.
  707. * \param dataAttribute the data attribute handle
  708. *
  709. * \return true or false
  710. */
  711. LIB61850_API bool
  712. IedServer_getBooleanAttributeValue(IedServer self, const DataAttribute* dataAttribute);
  713. /**
  714. * \brief Get data attribute value of an integer data attribute
  715. *
  716. * Get the value of a data attribute of type MMS_INTEGER. If the data attribute
  717. * is of a different type the returned value is undefined.
  718. *
  719. * \param self the instance of IedServer to operate on.
  720. * \param dataAttribute the data attribute handle
  721. *
  722. * \return the value as 32 bit integer
  723. */
  724. LIB61850_API int32_t
  725. IedServer_getInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute);
  726. /**
  727. * \brief Get data attribute value of an integer data attribute
  728. *
  729. * Get the value of a data attribute of type MMS_INTEGER. If the data attribute
  730. * is of a different type the returned value is undefined.
  731. *
  732. * \param self the instance of IedServer to operate on.
  733. * \param dataAttribute the data attribute handle
  734. *
  735. * \return the value as 64 bit integer
  736. */
  737. LIB61850_API int64_t
  738. IedServer_getInt64AttributeValue(IedServer self, const DataAttribute* dataAttribute);
  739. /**
  740. * \brief Get data attribute value of an unsigned integer data attribute
  741. *
  742. * Get the value of a data attribute of type MMS_UNSIGNED. If the data attribute
  743. * is of a different type the returned value is undefined.
  744. *
  745. * \param self the instance of IedServer to operate on.
  746. * \param dataAttribute the data attribute handle
  747. *
  748. * \return the value as 32 bit unsigned integer
  749. */
  750. LIB61850_API uint32_t
  751. IedServer_getUInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute);
  752. /**
  753. * \brief Get data attribute value of a floating point data attribute
  754. *
  755. * Get the value of a data attribute of type MMS_FLOAT. If the data attribute
  756. * is of a different type the returned value is undefined.
  757. *
  758. * \param self the instance of IedServer to operate on.
  759. * \param dataAttribute the data attribute handle
  760. *
  761. * \return the value as 32 bit float
  762. */
  763. LIB61850_API float
  764. IedServer_getFloatAttributeValue(IedServer self, const DataAttribute* dataAttribute);
  765. /**
  766. * \brief Get data attribute value of a UTC time data attribute
  767. *
  768. * Get the value of a data attribute of type MMS_UTC_TIME. If the data attribute
  769. * is of a different type the returned value is undefined.
  770. *
  771. * \param self the instance of IedServer to operate on.
  772. * \param dataAttribute the data attribute handle
  773. *
  774. * \return the value as 64 bit unsigned integer representing the time in milliseconds since Epoch
  775. */
  776. LIB61850_API uint64_t
  777. IedServer_getUTCTimeAttributeValue(IedServer self, const DataAttribute* dataAttribute);
  778. /**
  779. * \brief Get data attribute value of a bit string data attribute as integer value
  780. *
  781. * Get the value of a data attribute of type MMS_BIT_STRING. If the data attribute
  782. * is of a different type the returned value is undefined.
  783. * NOTE: The returned integer is determined by calculating the according the follwing
  784. * formula: bit0^0 + bit1^1 + ... + bitn^n
  785. * It is not specified in the IEC 61850 specifications how a bit string can be interpreted
  786. * as an integer. Therefore this function has to be used with care.
  787. *
  788. * \param self the instance of IedServer to operate on.
  789. * \param dataAttribute the data attribute handle
  790. *
  791. * \return the value a 32 bit integer.
  792. */
  793. LIB61850_API uint32_t
  794. IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);
  795. /**
  796. * \brief Get data attribute value of a string type data attribute
  797. *
  798. * Get the value of a data attribute of type MMS_STRING or MMS_VISIBLE_STRING. If the data attribute
  799. * is of a different type the returned value is undefined.
  800. *
  801. * \param self the instance of IedServer to operate on.
  802. * \param dataAttribute the data attribute handle
  803. *
  804. * \return the value as a C string (null terminated string)
  805. */
  806. LIB61850_API const char*
  807. IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);
  808. /**
  809. * \brief Get the MmsValue object related to a FunctionalConstrainedData object
  810. *
  811. * Get the MmsValue from the server cache that is associated with the Functional Constrained Data (FCD)
  812. * object that is specified by the DataObject and the given Function Constraint (FC).
  813. * Accessing the value will directly influence the values presented by the server. This kind of direct
  814. * access will also bypass the report notification mechanism (i.e. changes will not cause a report!).
  815. * Therefore this function should be used with care. It could be useful to access arrays of DataObjects.
  816. *
  817. * \param self the instance of IedServer to operate on.
  818. * \param dataObject the data object to specify the FCD
  819. * \param fc the FC to specify the FCD
  820. *
  821. * \return MmsValue object cached by the server.
  822. */
  823. LIB61850_API MmsValue*
  824. IedServer_getFunctionalConstrainedData(IedServer self, DataObject* dataObject, FunctionalConstraint fc);
  825. /**
  826. * \brief Update the MmsValue object of an IEC 61850 data attribute.
  827. *
  828. * The data attribute handle of type DataAttribute* are imported with static_model.h in the case when
  829. * the static data model is used.
  830. * You should use this function instead of directly operating on the MmsValue instance
  831. * that is hold by the MMS server. Otherwise the IEC 61850 server is not aware of the
  832. * changed value and will e.g. not generate a report.
  833. *
  834. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  835. * control block is enabled.
  836. *
  837. * \param self the instance of IedServer to operate on.
  838. * \param dataAttribute the data attribute handle
  839. * \param value MmsValue object used to update the value cached by the server.
  840. */
  841. LIB61850_API void
  842. IedServer_updateAttributeValue(IedServer self, DataAttribute* dataAttribute, MmsValue* value);
  843. /**
  844. * \brief Update the value of an IEC 61850 float data attribute.
  845. *
  846. * Update the value of a float data attribute without handling with MmsValue instances.
  847. *
  848. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  849. * control block is enabled.
  850. *
  851. * \param self the instance of IedServer to operate on.
  852. * \param dataAttribute the data attribute handle
  853. * \param value the new float value of the data attribute.
  854. */
  855. LIB61850_API void
  856. IedServer_updateFloatAttributeValue(IedServer self, DataAttribute* dataAttribute, float value);
  857. /**
  858. * \brief Update the value of an IEC 61850 integer32 data attribute.
  859. *
  860. * Update the value of a integer data attribute without handling with MmsValue instances.
  861. *
  862. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  863. * control block is enabled.
  864. *
  865. * \param self the instance of IedServer to operate on.
  866. * \param dataAttribute the data attribute handle
  867. * \param value the new integer value of the data attribute.
  868. */
  869. LIB61850_API void
  870. IedServer_updateInt32AttributeValue(IedServer self, DataAttribute* dataAttribute, int32_t value);
  871. /**
  872. * \brief Update the value of an IEC 61850 Dbpos (double point/position) data attribute.
  873. *
  874. * Update the value of a integer data attribute without handling with MmsValue instances.
  875. *
  876. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  877. * control block is enabled.
  878. *
  879. * \param self the instance of IedServer to operate on.
  880. * \param dataAttribute the data attribute handle
  881. * \param value the new Dbpos value of the data attribute.
  882. */
  883. LIB61850_API void
  884. IedServer_updateDbposValue(IedServer self, DataAttribute* dataAttribute, Dbpos value);
  885. /**
  886. * \brief Update the value of an IEC 61850 integer64 data attribute (like BCR actVal)
  887. *
  888. * Update the value of a integer data attribute without handling with MmsValue instances.
  889. *
  890. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  891. * control block is enabled.
  892. *
  893. * \param self the instance of IedServer to operate on.
  894. * \param dataAttribute the data attribute handle
  895. * \param value the new 64 bit integer value of the data attribute.
  896. */
  897. LIB61850_API void
  898. IedServer_updateInt64AttributeValue(IedServer self, DataAttribute* dataAttribute, int64_t value);
  899. /**
  900. * \brief Update the value of an IEC 61850 unsigned integer data attribute.
  901. *
  902. * Update the value of a unsigned data attribute without handling with MmsValue instances.
  903. *
  904. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  905. * control block is enabled.
  906. *
  907. * \param self the instance of IedServer to operate on.
  908. * \param dataAttribute the data attribute handle
  909. * \param value the new unsigned integer value of the data attribute.
  910. */
  911. LIB61850_API void
  912. IedServer_updateUnsignedAttributeValue(IedServer self, DataAttribute* dataAttribute, uint32_t value);
  913. /**
  914. * \brief Update the value of an IEC 61850 bit string data attribute.
  915. *
  916. * Update the value of a bit string data attribute without handling with MmsValue instances.
  917. *
  918. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  919. * control block is enabled.
  920. *
  921. * \param self the instance of IedServer to operate on.
  922. * \param dataAttribute the data attribute handle
  923. * \param value the new bit string integer value of the data attribute.
  924. */
  925. LIB61850_API void
  926. IedServer_updateBitStringAttributeValue(IedServer self, DataAttribute* dataAttribute, uint32_t value);
  927. /**
  928. * \brief Update the value of an IEC 61850 boolean data attribute.
  929. *
  930. * Update the value of a boolean data attribute without handling with MmsValue instances.
  931. *
  932. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  933. * control block is enabled.
  934. *
  935. * \param self the instance of IedServer to operate on.
  936. * \param dataAttribute the data attribute handle
  937. * \param value the new boolean value of the data attribute.
  938. */
  939. LIB61850_API void
  940. IedServer_updateBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute, bool value);
  941. /**
  942. * \brief Update the value of an IEC 61850 visible string data attribute.
  943. *
  944. * Update the value of a visible string data attribute without handling MmsValue instances.
  945. *
  946. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  947. * control block is enabled.
  948. *
  949. * \param self the instance of IedServer to operate on.
  950. * \param dataAttribute the data attribute handle
  951. * \param value the new visible string value of the data attribute.
  952. */
  953. LIB61850_API void
  954. IedServer_updateVisibleStringAttributeValue(IedServer self, DataAttribute* dataAttribute, char *value);
  955. /**
  956. * \brief Update the value of an IEC 61850 UTC time (timestamp) data attribute.
  957. *
  958. * Update the value of a UTC time data attribute without handling MmsValue instances.
  959. *
  960. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  961. * control block is enabled.
  962. *
  963. * \param self the instance of IedServer to operate on.
  964. * \param dataAttribute the data attribute handle
  965. * \param value the new UTC time value of the data attribute as a ms timestamp
  966. */
  967. LIB61850_API void
  968. IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute, uint64_t value);
  969. /**
  970. * \brief Update the value of an IEC 61850 UTC time (timestamp) data attribute.
  971. *
  972. * Update the value of a UTC time data attribute without handling MmsValue instances.
  973. *
  974. * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
  975. * control block is enabled.
  976. *
  977. * \param self the instance of IedServer to operate on.
  978. * \param dataAttribute the data attribute handle
  979. * \param value the new UTC time value of the data attribute as a Timestamp
  980. */
  981. LIB61850_API void
  982. IedServer_updateTimestampAttributeValue(IedServer self, DataAttribute* dataAttribute, Timestamp* timestamp);
  983. /**
  984. * \brief Update a quality ("q") IEC 61850 data attribute.
  985. *
  986. * This is a specialized function to handle Quality data attributes. It can be used instead of the more
  987. * generic IedServer_updateAttributeValue function.
  988. *
  989. * This function will also check if the quality change (qchg) trigger condition is satisfied and inform a
  990. * report control block accordingly.
  991. *
  992. * \param self the instance of IedServer to operate on.
  993. * \param dataAttribute the data attribute handle
  994. * \param quality the new quality value
  995. *
  996. */
  997. LIB61850_API void
  998. IedServer_updateQuality(IedServer self, DataAttribute* dataAttribute, Quality quality);
  999. /**@}*/
  1000. LIB61850_API void
  1001. IedServer_setLogStorage(IedServer self, const char* logRef, LogStorage logStorage);
  1002. /**
  1003. * @defgroup IEC61850_SERVER_SETTING_GROUPS Server side setting group handling
  1004. *
  1005. * @{
  1006. */
  1007. /**
  1008. * \brief Change active setting group
  1009. *
  1010. * Inform the IedServer that the active setting group has changed due to an internal event.
  1011. * Before calling this function the user should update the relevant data attributes with FC=SG!
  1012. *
  1013. * \param self the instance of IedServer to operate on.
  1014. * \param sgcb the handle of the setting group control block of the setting group
  1015. * \param newActiveSg the number of the new active setting group
  1016. */
  1017. LIB61850_API void
  1018. IedServer_changeActiveSettingGroup(IedServer self, SettingGroupControlBlock* sgcb, uint8_t newActiveSg);
  1019. /**
  1020. * \brief Get the active setting group number
  1021. *
  1022. * \param self the instance of IedServer to operate on.
  1023. * \param sgcb the handle of the setting group control block of the setting group
  1024. *
  1025. * \return the number of the active setting group
  1026. */
  1027. LIB61850_API uint8_t
  1028. IedServer_getActiveSettingGroup(IedServer self, SettingGroupControlBlock* sgcb);
  1029. /**
  1030. * \brief Callback handler that is invoked when the active setting group is about to be changed by an
  1031. * external client.
  1032. *
  1033. * This function is called BEFORE the active setting group is changed. The user can reject to change the
  1034. * active setting group by returning false.
  1035. *
  1036. * \param user provided parameter
  1037. * \param sgcb the setting group control block of the setting group that is about to be changed
  1038. * \param newActSg the new active setting group
  1039. * \param connection the client connection that requests the change
  1040. *
  1041. * \return true if the change is accepted, false otherwise.
  1042. *
  1043. */
  1044. typedef bool (*ActiveSettingGroupChangedHandler) (void* parameter, SettingGroupControlBlock* sgcb,
  1045. uint8_t newActSg, ClientConnection connection);
  1046. /**
  1047. * \brief Set the callback handler for the SetActSG event
  1048. *
  1049. * \param self the instance of IedServer to operate on.
  1050. * \param sgcb the handle of the setting group control block of the setting group.
  1051. * \param handler the user provided callback handler.
  1052. * \param parameter a user provided parameter that is passed to the control handler.
  1053. */
  1054. LIB61850_API void
  1055. IedServer_setActiveSettingGroupChangedHandler(IedServer self, SettingGroupControlBlock* sgcb,
  1056. ActiveSettingGroupChangedHandler handler, void* parameter);
  1057. /**
  1058. * \brief Callback handler that is invoked when the edit setting group is about to be changed by an
  1059. * external client.
  1060. *
  1061. * In this function the user should update all SE data attributes
  1062. * associated with the given SettingGroupControlBlock.
  1063. * This function is called BEFORE the active setting group is changed. The user can reject to change the
  1064. * edit setting group by returning false. This can be used to implement RBAC.
  1065. *
  1066. * \param user provided parameter
  1067. * \param sgcb the setting group control block of the setting group that is about to be changed
  1068. * \param newEditSg the new edit setting group
  1069. * \param connection the client connection that requests the change
  1070. *
  1071. * \return true if the change is accepted, false otherwise.
  1072. *
  1073. */
  1074. typedef bool (*EditSettingGroupChangedHandler) (void* parameter, SettingGroupControlBlock* sgcb,
  1075. uint8_t newEditSg, ClientConnection connection);
  1076. /**
  1077. * \brief Set the callback handler for the SetEditSG event
  1078. *
  1079. * \param self the instance of IedServer to operate on.
  1080. * \param sgcb the handle of the setting group control block of the setting group.
  1081. * \param handler the user provided callback handler.
  1082. * \param parameter a user provided parameter that is passed to the control handler.
  1083. */
  1084. LIB61850_API void
  1085. IedServer_setEditSettingGroupChangedHandler(IedServer self, SettingGroupControlBlock* sgcb,
  1086. EditSettingGroupChangedHandler handler, void* parameter);
  1087. /**
  1088. * \brief Callback handler that is invoked when the edit setting group has been confirmed by an
  1089. * external client.
  1090. *
  1091. * \param user provided parameter
  1092. * \param sgcb the setting group control block of the setting group that is about to be changed
  1093. * \param editSg the edit setting group that has been confirmed
  1094. *
  1095. */
  1096. typedef void (*EditSettingGroupConfirmationHandler) (void* parameter, SettingGroupControlBlock* sgcb,
  1097. uint8_t editSg);
  1098. /**
  1099. * \brief Set the callback handler for the COnfEditSG event
  1100. *
  1101. * \param self the instance of IedServer to operate on.
  1102. * \param sgcb the handle of the setting group control block of the setting group.
  1103. * \param handler the user provided callback handler.
  1104. * \param parameter a user provided parameter that is passed to the control handler.
  1105. */
  1106. LIB61850_API void
  1107. IedServer_setEditSettingGroupConfirmationHandler(IedServer self, SettingGroupControlBlock* sgcb,
  1108. EditSettingGroupConfirmationHandler handler, void* parameter);
  1109. /**@}*/
  1110. /**
  1111. * @defgroup IEC61850_SERVER_CONTROL Server side control model handling
  1112. *
  1113. * @{
  1114. */
  1115. /**
  1116. * \brief result code for ControlPerformCheckHandler
  1117. */
  1118. typedef enum {
  1119. CONTROL_ACCEPTED = -1, /**< check passed */
  1120. CONTROL_WAITING_FOR_SELECT = 0, /**< select operation in progress - handler will be called again later */
  1121. CONTROL_HARDWARE_FAULT = 1, /**< check failed due to hardware fault */
  1122. CONTROL_TEMPORARILY_UNAVAILABLE = 2, /**< control is already selected or operated */
  1123. CONTROL_OBJECT_ACCESS_DENIED = 3, /**< check failed due to access control reason - access denied for this client or state */
  1124. CONTROL_OBJECT_UNDEFINED = 4, /**< object not visible in this security context ??? */
  1125. CONTROL_VALUE_INVALID = 11 /**< ctlVal out of range */
  1126. } CheckHandlerResult;
  1127. /**
  1128. * \brief result codes for control handler (ControlWaitForExecutionHandler and ControlHandler)
  1129. */
  1130. typedef enum {
  1131. CONTROL_RESULT_FAILED = 0, /**< check or operation failed */
  1132. CONTROL_RESULT_OK = 1, /**< check or operation was successful */
  1133. CONTROL_RESULT_WAITING = 2 /**< check or operation is in progress */
  1134. } ControlHandlerResult;
  1135. typedef void* ControlAction;
  1136. /**
  1137. * \brief Sets the error code for the next command termination or application error message
  1138. *
  1139. * \param self the control action instance
  1140. * \param error the error code
  1141. */
  1142. LIB61850_API void
  1143. ControlAction_setError(ControlAction self, ControlLastApplError error);
  1144. /**
  1145. * \brief Sets the add cause for the next command termination or application error message
  1146. *
  1147. * \param self the control action instance
  1148. * \param addCause the additional cause
  1149. */
  1150. LIB61850_API void
  1151. ControlAction_setAddCause(ControlAction self, ControlAddCause addCause);
  1152. /**
  1153. * \brief Gets the originator category provided by the client
  1154. *
  1155. * \param self the control action instance
  1156. *
  1157. * \return the originator category
  1158. */
  1159. LIB61850_API int
  1160. ControlAction_getOrCat(ControlAction self);
  1161. /**
  1162. * \brief Gets the originator identifier provided by the client
  1163. *
  1164. * \param self the control action instance
  1165. *
  1166. * \return the originator identifier
  1167. */
  1168. LIB61850_API uint8_t*
  1169. ControlAction_getOrIdent(ControlAction self, int* orIdentSize);
  1170. /**
  1171. * \brief Get the ctlNum attribute send by the client
  1172. *
  1173. * \param self the control action instance
  1174. *
  1175. * \return the ctlNum value
  1176. */
  1177. LIB61850_API int
  1178. ControlAction_getCtlNum(ControlAction self);
  1179. /**
  1180. * \brief Check if the control callback is called by a select or operate command
  1181. *
  1182. * \param self the control action instance
  1183. *
  1184. * \return true, when called by select, false for operate
  1185. */
  1186. LIB61850_API bool
  1187. ControlAction_isSelect(ControlAction self);
  1188. /**
  1189. * \brief Gets the client object associated with the client that caused the control action
  1190. *
  1191. * \param self the control action instance
  1192. *
  1193. * \return client connection instance
  1194. */
  1195. LIB61850_API ClientConnection
  1196. ControlAction_getClientConnection(ControlAction self);
  1197. /**
  1198. * \brief Gets the control object that is subject to this action
  1199. *
  1200. * \param self the control action instance
  1201. *
  1202. * \return the controllable data object instance
  1203. */
  1204. LIB61850_API DataObject*
  1205. ControlAction_getControlObject(ControlAction self);
  1206. /**
  1207. * \brief Gets the time of the control, if it's a timeActivatedControl, returns 0, if it's not.
  1208. *
  1209. * \param self the control action instance
  1210. *
  1211. * \return the controllable data object instance
  1212. */
  1213. LIB61850_API uint64_t
  1214. ControlAction_getControlTime(ControlAction self);
  1215. /**
  1216. * \brief Control model callback to perform the static tests (optional).
  1217. *
  1218. * NOTE: Signature changed in version 1.4!
  1219. *
  1220. * User provided callback function for the control model. It will be invoked after
  1221. * a control operation has been invoked by the client. This callback function is
  1222. * intended to perform the static tests. It should check if the interlock conditions
  1223. * are met if the interlockCheck parameter is true.
  1224. * This handler can also be check if the client has the required permissions to execute the
  1225. * operation and allow or deny the operation accordingly.
  1226. *
  1227. * \param action the control action parameter that provides access to additional context information
  1228. * \param parameter the parameter that was specified when setting the control handler
  1229. * \param ctlVal the control value of the control operation.
  1230. * \param test indicates if the operate request is a test operation
  1231. * \param interlockCheck the interlockCheck parameter provided by the client
  1232. *
  1233. * \return CONTROL_ACCEPTED if the static tests had been successful, one of the error codes otherwise
  1234. */
  1235. typedef CheckHandlerResult (*ControlPerformCheckHandler) (ControlAction action, void* parameter, MmsValue* ctlVal, bool test, bool interlockCheck);
  1236. /**
  1237. * \brief Control model callback to perform the dynamic tests (optional).
  1238. *
  1239. * NOTE: Signature changed in version 1.4!
  1240. *
  1241. * User provided callback function for the control model. It will be invoked after
  1242. * a control operation has been invoked by the client. This callback function is
  1243. * intended to perform the dynamic tests. It should check if the synchronization conditions
  1244. * are met if the synchroCheck parameter is set to true.
  1245. * NOTE: Since version 0.7.9 this function is intended to return immediately. If the operation
  1246. * cannot be performed immediately the function SHOULD return CONTROL_RESULT_WAITING and the
  1247. * handler will be invoked again later.
  1248. *
  1249. * \param action the control action parameter that provides access to additional context information
  1250. * \param parameter the parameter that was specified when setting the control handler
  1251. * \param ctlVal the control value of the control operation.
  1252. * \param test indicates if the operate request is a test operation
  1253. * \param synchroCheck the synchroCheck parameter provided by the client
  1254. *
  1255. * \return CONTROL_RESULT_OK if the dynamic tests had been successful, CONTROL_RESULT_FAILED otherwise,
  1256. * CONTROL_RESULT_WAITING if the test is not yet finished
  1257. */
  1258. typedef ControlHandlerResult (*ControlWaitForExecutionHandler) (ControlAction action, void* parameter, MmsValue* ctlVal, bool test, bool synchroCheck);
  1259. /**
  1260. * \brief Control model callback to actually perform the control operation.
  1261. *
  1262. * NOTE: Signature changed in version 1.4!
  1263. *
  1264. * User provided callback function for the control model. It will be invoked when
  1265. * a control operation happens (Oper). Here the user should perform the control operation
  1266. * (e.g. by setting an digital output or switching a relay).
  1267. * NOTE: Since version 0.7.9 this function is intended to return immediately. If the operation
  1268. * cannot be performed immediately the function SHOULD return CONTROL_RESULT_WAITING and the
  1269. * handler will be invoked again later.
  1270. *
  1271. * \param action the control action parameter that provides access to additional context information
  1272. * \param parameter the parameter that was specified when setting the control handler
  1273. * \param ctlVal the control value of the control operation.
  1274. * \param test indicates if the operate request is a test operation
  1275. *
  1276. * \return CONTROL_RESULT_OK if the control action bas been successful, CONTROL_RESULT_FAILED otherwise,
  1277. * CONTROL_RESULT_WAITING if the test is not yet finished
  1278. */
  1279. typedef ControlHandlerResult (*ControlHandler) (ControlAction action, void* parameter, MmsValue* ctlVal, bool test);
  1280. /**
  1281. * \brief Reason why a select state of a control object changed
  1282. */
  1283. typedef enum {
  1284. SELECT_STATE_REASON_SELECTED, /**< control has been selected */
  1285. SELECT_STATE_REASON_CANCELED, /**< cancel received for the control */
  1286. SELECT_STATE_REASON_TIMEOUT, /**< unselected due to timeout (sboTimeout) */
  1287. SELECT_STATE_REASON_OPERATED, /**< unselected due to successful operate */
  1288. SELECT_STATE_REASON_OPERATE_FAILED, /**< unselected due to failed operate */
  1289. SELECT_STATE_REASON_DISCONNECTED /**< unselected due to disconnection of selecting client */
  1290. } SelectStateChangedReason;
  1291. /**
  1292. * \brief Control model callback that is called when the select state of a control changes
  1293. *
  1294. * New in version 1.5
  1295. *
  1296. * \param action the control action parameter that provides access to additional context information
  1297. * \param parameter the parameter that was specified when setting the control handler
  1298. * \param isSelected true when the control is selected, false otherwise
  1299. * \param reason reason why the select state changed
  1300. */
  1301. typedef void (*ControlSelectStateChangedHandler) (ControlAction action, void* parameter, bool isSelected, SelectStateChangedReason reason);
  1302. /**
  1303. * \brief Set control handler for controllable data object
  1304. *
  1305. * This functions sets a user provided control handler for a data object. The data object
  1306. * has to be an instance of a controllable CDC (Common Data Class) like e.g. SPC, DPC or APC.
  1307. * The control handler is a callback function that will be called by the IEC server when a
  1308. * client invokes a control operation on the data object.
  1309. *
  1310. * \param self the instance of IedServer to operate on.
  1311. * \param node the controllable data object handle
  1312. * \param handler a callback function of type ControlHandler
  1313. * \param parameter a user provided parameter that is passed to the control handler.
  1314. */
  1315. LIB61850_API void
  1316. IedServer_setControlHandler(IedServer self, DataObject* node, ControlHandler handler, void* parameter);
  1317. /**
  1318. * \brief Set a handler for a controllable data object to perform operative tests
  1319. *
  1320. * This functions sets a user provided handler that should perform the operative tests for a control operation.
  1321. * Setting this handler is not required. If not set the server assumes that the checks will always be successful.
  1322. * The handler has to return true upon a successful test of false if the test fails. In the later case the control
  1323. * operation will be aborted.
  1324. *
  1325. * \param self the instance of IedServer to operate on.
  1326. * \param node the controllable data object handle
  1327. * \param handler a callback function of type ControlHandler
  1328. * \param parameter a user provided parameter that is passed to the control handler.
  1329. *
  1330. */
  1331. LIB61850_API void
  1332. IedServer_setPerformCheckHandler(IedServer self, DataObject* node, ControlPerformCheckHandler handler, void* parameter);
  1333. /**
  1334. * \brief Set a handler for a controllable data object to perform dynamic tests
  1335. *
  1336. * This functions sets a user provided handler that should perform the dynamic tests for a control operation.
  1337. * Setting this handler is not required. If not set the server assumes that the checks will always be successful.
  1338. * The handler has to return true upon a successful test of false if the test fails. In the later case the control
  1339. * operation will be aborted.
  1340. *
  1341. * \param self the instance of IedServer to operate on.
  1342. * \param node the controllable data object handle
  1343. * \param handler a callback function of type ControlHandler
  1344. * \param parameter a user provided parameter that is passed to the control handler.
  1345. *
  1346. */
  1347. LIB61850_API void
  1348. IedServer_setWaitForExecutionHandler(IedServer self, DataObject* node, ControlWaitForExecutionHandler handler, void* parameter);
  1349. /**
  1350. * \brief Set a callback handler for a controllable data object to track select state changes
  1351. *
  1352. * The callback is called whenever the select state of a control changes. Reason for changes can be:
  1353. * - a successful select or select-with-value by a client
  1354. * - select timeout
  1355. * - operate or failed operate
  1356. * - cancel request by a client
  1357. * - the client that selected the control has been disconnected
  1358. *
  1359. * \param self the instance of IedServer to operate on.
  1360. * \param node the controllable data object handle
  1361. * \param handler a callback function of type ControlHandler
  1362. * \param parameter a user provided parameter that is passed to the callback handler.
  1363. */
  1364. LIB61850_API void
  1365. IedServer_setSelectStateChangedHandler(IedServer self, DataObject* node, ControlSelectStateChangedHandler handler, void* parameter);
  1366. /**
  1367. * \brief Update the control model for the specified controllable data object with the given value and
  1368. * update "ctlModel" attribute value.
  1369. *
  1370. * NOTE: The corresponding control structures for the control model have to be present in the data model!
  1371. *
  1372. * \param self the instance of IedServer to operate on.
  1373. * \param ctlObject the controllable data object handle
  1374. * \param value the new control model value
  1375. */
  1376. LIB61850_API void
  1377. IedServer_updateCtlModel(IedServer self, DataObject* ctlObject, ControlModel value);
  1378. /**@}*/
  1379. /**
  1380. * @defgroup IEC61850_SERVER_RCB Server side report control block (RCB) handling
  1381. *
  1382. * @{
  1383. */
  1384. typedef enum {
  1385. RCB_EVENT_GET_PARAMETER, /* << parameter read by client (not implemented) */
  1386. RCB_EVENT_SET_PARAMETER, /* << parameter set by client */
  1387. RCB_EVENT_UNRESERVED, /* << RCB reservation canceled */
  1388. RCB_EVENT_RESERVED, /* << RCB reserved */
  1389. RCB_EVENT_ENABLE, /* << RCB enabled */
  1390. RCB_EVENT_DISABLE, /* << RCB disabled */
  1391. RCB_EVENT_GI, /* << GI report triggered */
  1392. RCB_EVENT_PURGEBUF /* << Purge buffer procedure executed */
  1393. } IedServer_RCBEventType;
  1394. /**
  1395. * \brief Callback that is called in case of RCB event
  1396. *
  1397. * \param parameter user provided parameter
  1398. * \param rcb affected report control block
  1399. * \param connection client connection that is involved
  1400. * \param event event type
  1401. * \param parameterName name of the parameter in case of RCB_EVENT_SET_PARAMETER
  1402. * \param serviceError service error in case of RCB_EVENT_SET_PARAMETER
  1403. */
  1404. typedef void (*IedServer_RCBEventHandler) (void* parameter, ReportControlBlock* rcb, ClientConnection connection, IedServer_RCBEventType event, const char* parameterName, MmsDataAccessError serviceError);
  1405. /**
  1406. * \brief Set a handler for report control block (RCB) events
  1407. *
  1408. * \param self the instance of IedServer to operate on.
  1409. * \param handler the event handler to be used
  1410. * \param parameter a user provided parameter that is passed to the handler.
  1411. */
  1412. LIB61850_API void
  1413. IedServer_setRCBEventHandler(IedServer self, IedServer_RCBEventHandler handler, void* parameter);
  1414. /**@}*/
  1415. /**
  1416. * @defgroup IEC61850_SERVER_SVCB Server side sampled values control block (SVCB) handling
  1417. *
  1418. * @{
  1419. */
  1420. /** Control block has been enabled by client */
  1421. #define IEC61850_SVCB_EVENT_ENABLE 1
  1422. /** Control block has been disabled by client */
  1423. #define IEC61850_SVCB_EVENT_DISABLE 0
  1424. /**
  1425. * \brief callback handler for SVCB events.
  1426. *
  1427. * \param svcb the related SVCB instance
  1428. * \param the event type
  1429. * \param user defined parameter
  1430. */
  1431. typedef void (*SVCBEventHandler) (SVControlBlock* svcb, int event, void* parameter);
  1432. /**
  1433. * \brief Set a handler for SVCB control block events (enable/disable)
  1434. *
  1435. * \param self the instance of IedServer to operate on.
  1436. * \param svcb the SVCB control block instance
  1437. * \param handler the event handler to be used
  1438. * \param parameter a user provided parameter that is passed to the handler.
  1439. */
  1440. LIB61850_API void
  1441. IedServer_setSVCBHandler(IedServer self, SVControlBlock* svcb, SVCBEventHandler handler, void* parameter);
  1442. /**@}*/
  1443. /**
  1444. * @defgroup IEC61850_SERVER_GOCB Server side GOOSE control block (GoCB) handling
  1445. *
  1446. * @{
  1447. */
  1448. typedef struct sMmsGooseControlBlock* MmsGooseControlBlock;
  1449. /** Control block has been enabled by client */
  1450. #define IEC61850_GOCB_EVENT_ENABLE 1
  1451. /** Control block has been disabled by client */
  1452. #define IEC61850_GOCB_EVENT_DISABLE 0
  1453. typedef void (*GoCBEventHandler) (MmsGooseControlBlock goCb, int event, void* parameter);
  1454. /**
  1455. * \brief Set a callback handler for GoCB events (enabled/disabled)
  1456. *
  1457. * The callback handler is called whenever a GOOSE control block is enabled or disabled.
  1458. * It can be used to integrate the external GOOSE publisher with the IEC 61850/MMS server.
  1459. *
  1460. * \param self the instance of IedServer to operate on.
  1461. * \param handler the callback handler
  1462. * \param parameter user provided parameter that is passed to the callback handler
  1463. */
  1464. LIB61850_API void
  1465. IedServer_setGoCBHandler(IedServer self, GoCBEventHandler handler, void* parameter);
  1466. LIB61850_API char*
  1467. MmsGooseControlBlock_getName(MmsGooseControlBlock self);
  1468. LIB61850_API LogicalNode*
  1469. MmsGooseControlBlock_getLogicalNode(MmsGooseControlBlock self);
  1470. LIB61850_API DataSet*
  1471. MmsGooseControlBlock_getDataSet(MmsGooseControlBlock self);
  1472. LIB61850_API bool
  1473. MmsGooseControlBlock_getGoEna(MmsGooseControlBlock self);
  1474. LIB61850_API int
  1475. MmsGooseControlBlock_getMinTime(MmsGooseControlBlock self);
  1476. LIB61850_API int
  1477. MmsGooseControlBlock_getMaxTime(MmsGooseControlBlock self);
  1478. LIB61850_API bool
  1479. MmsGooseControlBlock_getFixedOffs(MmsGooseControlBlock self);
  1480. LIB61850_API bool
  1481. MmsGooseControlBlock_getNdsCom(MmsGooseControlBlock self);
  1482. /**@}*/
  1483. /**
  1484. * @defgroup IEC61850_SERVER_EXTERNAL_ACCESS Handle external access to data model and access control
  1485. *
  1486. * @{
  1487. */
  1488. /***************************************************************************
  1489. * Access control
  1490. **************************************************************************/
  1491. /**
  1492. * \brief callback handler to intercept/control client write access to data attributes
  1493. *
  1494. * User provided callback function to intercept/control MMS client access to
  1495. * IEC 61850 data attributes. The application can install the same handler
  1496. * multiple times and distinguish data attributes by the dataAttribute parameter.
  1497. * This handler can be used to perform write access control do data attributes.
  1498. * One application can be to allow write access only from a specific client. Another
  1499. * application could be to check if the value is in the allowed range before the write
  1500. * is accepted.
  1501. * When the callback returns DATA_ACCESS_ERROR_SUCCESS the write access is accepted and the stack will
  1502. * update the value automatically.
  1503. * When the callback returns DATA_ACCESS_ERROR_SUCCESS_NO_UPDATE the write access is accepted but the
  1504. * stack will not update the value automatically.
  1505. *
  1506. * \param the data attribute that has been written by an MMS client.
  1507. * \param the value the client want to write to the data attribute
  1508. * \param connection the connection object of the client connection that invoked the write operation
  1509. * \param parameter the user provided parameter
  1510. *
  1511. * \return DATA_ACCESS_ERROR_SUCCESS, or DATA_ACCESS_ERROR_SUCCESS_NO_UPDATE if access is accepted, DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED if access is denied.
  1512. */
  1513. typedef MmsDataAccessError
  1514. (*WriteAccessHandler) (DataAttribute* dataAttribute, MmsValue* value, ClientConnection connection, void* parameter);
  1515. /**
  1516. * \brief Install a WriteAccessHandler for a data attribute.
  1517. *
  1518. * This instructs the server to monitor write attempts by MMS clients to specific
  1519. * data attributes. If a client tries to write to the monitored data attribute the
  1520. * handler is invoked. The handler can decide if the write access will be allowed
  1521. * or denied. If a WriteAccessHandler is set for a specific data attribute - the
  1522. * default write access policy will not be performed for that data attribute.
  1523. *
  1524. * NOTE: If the data attribute has sub data attributes, the WriteAccessHandler is not
  1525. * set for the sub data attributes and will not be called when the sub data attribute is
  1526. * written directly!
  1527. *
  1528. * \param self the instance of IedServer to operate on.
  1529. * \param dataAttribute the data attribute to monitor
  1530. * \param handler the callback function that is invoked if a client tries to write to
  1531. * the monitored data attribute.
  1532. * \param parameter a user provided parameter that is passed to the WriteAccessHandler when called.
  1533. */
  1534. LIB61850_API void
  1535. IedServer_handleWriteAccess(IedServer self, DataAttribute* dataAttribute,
  1536. WriteAccessHandler handler, void* parameter);
  1537. /**
  1538. * \brief Install a WriteAccessHandler for a data attribute and for all sub data attributes
  1539. *
  1540. * This instructs the server to monitor write attempts by MMS clients to specific
  1541. * data attributes. If a client tries to write to the monitored data attribute the
  1542. * handler is invoked. The handler can decide if the write access will be allowed
  1543. * or denied. If a WriteAccessHandler is set for a specific data attribute - the
  1544. * default write access policy will not be performed for that data attribute.
  1545. *
  1546. * When the data attribute is a complex attribute then the handler will also be installed
  1547. * for all sub data attributes. When the data attribute is a basic data attribute then
  1548. * this function behaves like \ref IedServer_handleWriteAccess.
  1549. *
  1550. * \param self the instance of IedServer to operate on.
  1551. * \param dataAttribute the data attribute to monitor
  1552. * \param handler the callback function that is invoked if a client tries to write to
  1553. * the monitored data attribute.
  1554. * \param parameter a user provided parameter that is passed to the WriteAccessHandler when called.
  1555. */
  1556. LIB61850_API void
  1557. IedServer_handleWriteAccessForComplexAttribute(IedServer self, DataAttribute* dataAttribute,
  1558. WriteAccessHandler handler, void* parameter);
  1559. typedef enum {
  1560. ACCESS_POLICY_ALLOW,
  1561. ACCESS_POLICY_DENY
  1562. } AccessPolicy;
  1563. /**
  1564. * \brief Change the default write access policy for functional constraint data with a specific FC.
  1565. *
  1566. * \param self the instance of IedServer to operate on.
  1567. * \param fc the FC for which to change the default write access policy.
  1568. * \param policy the new policy to apply.
  1569. *
  1570. */
  1571. LIB61850_API void
  1572. IedServer_setWriteAccessPolicy(IedServer self, FunctionalConstraint fc, AccessPolicy policy);
  1573. /**
  1574. * \brief callback handler to control client read access to data attributes
  1575. *
  1576. * User provided callback function to control MMS client read access to IEC 61850
  1577. * data objects. The application is to allow read access to data objects for specific clients only.
  1578. * It can be used to implement a role based access control (RBAC).
  1579. *
  1580. * \param ld the logical device the client wants to access
  1581. * \param ln the logical node the client wants to access
  1582. * \param dataObject the data object the client wants to access
  1583. * \param fc the functional constraint of the access
  1584. * \param connection the client connection that causes the access
  1585. * \param parameter the user provided parameter
  1586. *
  1587. * \return DATA_ACCESS_ERROR_SUCCESS if access is accepted, DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED if access is denied.
  1588. */
  1589. typedef MmsDataAccessError
  1590. (*ReadAccessHandler) (LogicalDevice* ld, LogicalNode* ln, DataObject* dataObject, FunctionalConstraint fc, ClientConnection connection, void* parameter);
  1591. /**
  1592. * \brief Install the global read access handler
  1593. *
  1594. * The read access handler will be called for every read access before the server grants access to the client.
  1595. *
  1596. * \param self the instance of IedServer to operate on.
  1597. * \param handler the callback function that is invoked if a client tries to read a data object.
  1598. * \param parameter a user provided parameter that is passed to the callback function.
  1599. */
  1600. LIB61850_API void
  1601. IedServer_setReadAccessHandler(IedServer self, ReadAccessHandler handler, void* parameter);
  1602. /**@}*/
  1603. /**@}*/
  1604. #ifdef __cplusplus
  1605. }
  1606. #endif
  1607. #endif /* IED_SERVER_API_H_ */