libiec61850  1.2.0
mms_server.h
Go to the documentation of this file.
1 /*
2  * mms_server.h
3  *
4  * Copyright 2013, 2014 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 
24 #ifndef MMS_SERVER_H_
25 #define MMS_SERVER_H_
26 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include "mms_device_model.h"
36 #include "mms_value.h"
37 #include "iso_server.h"
38 
39 typedef enum {
42 
43 typedef struct sMmsServer* MmsServer;
44 
45 typedef struct sMmsServerConnection* MmsServerConnection;
46 
47 typedef enum {
52 
53 typedef MmsValue* (*MmsReadVariableHandler)(void* parameter, MmsDomain* domain,
54  char* variableId, MmsServerConnection connection);
55 
56 typedef MmsDataAccessError (*MmsReadAccessHandler) (void* parameter, MmsDomain* domain,
57  char* variableId, MmsServerConnection connection);
58 
59 typedef MmsDataAccessError (*MmsWriteVariableHandler)(void* parameter,
60  MmsDomain* domain, char* variableId, MmsValue* value,
61  MmsServerConnection connection);
62 
63 typedef void (*MmsConnectionHandler)(void* parameter,
64  MmsServerConnection connection, MmsServerEvent event);
65 
66 MmsServer
67 MmsServer_create(MmsDevice* device, TLSConfiguration tlsConfiguration);
68 
69 void
70 MmsServer_destroy(MmsServer self);
71 
72 void
74  void* parameter);
75 
76 void
77 MmsServer_installReadAccessHandler(MmsServer self, MmsReadAccessHandler, void* parameter);
78 
79 void
81  void* parameter);
82 
83 void
84 MmsServer_setLocalIpAddress(MmsServer self, const char* localIpAddress);
85 
86 bool
87 MmsServer_isRunning(MmsServer self);
88 
92 void
94  void* parameter);
95 
96 void
97 MmsServer_setClientAuthenticator(MmsServer self, AcseAuthenticator authenticator, void* authenticatorParameter);
98 
99 MmsDevice*
100 MmsServer_getDevice(MmsServer self);
101 
102 MmsValue*
103 MmsServer_getValueFromCache(MmsServer self, MmsDomain* domain, const char* itemId);
104 
105 bool
106 MmsServer_isLocked(MmsServer self);
107 
120 typedef MmsError (*MmsNamedVariableListChangedHandler)(void* parameter, bool create, MmsVariableListType listType, MmsDomain* domain,
121  char* listName, MmsServerConnection connection);
122 
130 void
132 
144 typedef bool (*MmsObtainFileHandler)(void* parameter, MmsServerConnection connection, const char* sourceFilename, const char* destinationFilename);
145 
155 void
156 MmsServer_installObtainFileHandler(MmsServer self, MmsObtainFileHandler handler, void* parameter);
157 
167 typedef void (*MmsGetFileCompleteHandler)(void* parameter, MmsServerConnection connection, const char* destinationFilename);
168 
177 void
178 MmsServer_installGetFileCompleteHandler(MmsServer self, MmsGetFileCompleteHandler handler, void* parameter);
179 
180 
181 typedef enum {
188 
200 typedef MmsError (*MmsFileAccessHandler) (void* parameter, MmsServerConnection connection, MmsFileServiceType service,
201  const char* localFilename, const char* otherFilename);
202 
203 
212 void
213 MmsServer_installFileAccessHandler(MmsServer self, MmsFileAccessHandler handler, void* parameter);
214 
225 void
226 MmsServer_setFilestoreBasepath(MmsServer self, const char* basepath);
227 
237 void
238 MmsServer_lockModel(MmsServer self);
239 
248 void
249 MmsServer_unlockModel(MmsServer self);
250 
251 void
252 MmsServer_insertIntoCache(MmsServer self, MmsDomain* domain, char* itemId,
253  MmsValue* value);
254 
255 /***************************************************
256  * Functions for multi-threaded operation mode
257  ***************************************************/
258 
265 void
266 MmsServer_startListening(MmsServer self, int tcpPort);
267 
273 void
274 MmsServer_stopListening(MmsServer self);
275 
276 /***************************************************
277  * Functions for threadless operation mode
278  ***************************************************/
279 
286 void
287 MmsServer_startListeningThreadless(MmsServer self, int tcpPort);
288 
296 int
297 MmsServer_waitReady(MmsServer self, unsigned int timeoutMs);
298 
307 void
308 MmsServer_handleIncomingMessages(MmsServer self);
309 
315 void
316 MmsServer_handleBackgroundTasks(MmsServer self);
317 
323 void
324 MmsServer_stopListeningThreadless(MmsServer self);
325 
326 
327 /***************************************************
328  * Functions for MMS identify service
329  ***************************************************/
330 
342 void
343 MmsServer_setServerIdentity(MmsServer self, char* vendorName, char* modelName, char* revision);
344 
351 char*
352 MmsServer_getVendorName(MmsServer self);
353 
360 char*
361 MmsServer_getModelName(MmsServer self);
362 
369 char*
370 MmsServer_getRevision(MmsServer self);
371 
372 /***************************************************
373  * Functions for MMS status service
374  ***************************************************/
375 
376 #define MMS_LOGICAL_STATE_STATE_CHANGES_ALLOWED 0
377 #define MMS_LOGICAL_STATE_NO_STATE_CHANGES_ALLOWED 1
378 #define MMS_LOGICAL_STATE_LIMITED_SERVICES_PERMITTED 2
379 #define MMS_LOGICAL_STATE_SUPPORT_SERVICES_ALLOWED 3
380 
381 #define MMS_PHYSICAL_STATE_OPERATIONAL 0
382 #define MMS_PHYSICAL_STATE_PARTIALLY_OPERATIONAL 1
383 #define MMS_PHYSICAL_STATE_INOPERATIONAL 2
384 #define MMS_PHYSICAL_STATE_NEEDS_COMMISSIONING 3
385 
397 typedef void (*MmsStatusRequestListener)(void* parameter, MmsServer mmsServer, MmsServerConnection connection, bool extendedDerivation);
398 
406 void
407 MmsServer_setVMDStatus(MmsServer self, int vmdLogicalStatus, int vmdPhysicalStatus);
408 
414 int
415 MmsServer_getVMDLogicalStatus(MmsServer self);
416 
422 int
423 MmsServer_getVMDPhysicalStatus(MmsServer self);
424 
436 void
437 MmsServer_setStatusRequestListener(MmsServer self, MmsStatusRequestListener listener, void* parameter);
438 
439 char*
440 MmsServerConnection_getClientAddress(MmsServerConnection self);
441 
443 MmsServerConnection_getIsoConnection(MmsServerConnection self);
444 
445 
448 #ifdef __cplusplus
449 }
450 #endif
451 
452 #endif /* MMS_SERVER_H_ */
void MmsServer_installReadAccessHandler(MmsServer self, MmsReadAccessHandler, void *parameter)
void MmsServer_lockModel(MmsServer self)
lock the cached server data model
bool MmsServer_isLocked(MmsServer self)
void MmsServer_startListeningThreadless(MmsServer self, int tcpPort)
Start a new server in non-threaded operation mode.
MmsDataAccessError(* MmsWriteVariableHandler)(void *parameter, MmsDomain *domain, char *variableId, MmsValue *value, MmsServerConnection connection)
Definition: mms_server.h:59
int MmsServer_getVMDPhysicalStatus(MmsServer self)
get the physical status attribute of the VMD
MmsDevice * MmsServer_getDevice(MmsServer self)
void MmsServer_installReadHandler(MmsServer self, MmsReadVariableHandler, void *parameter)
Definition: mms_server.h:186
void MmsServer_setFilestoreBasepath(MmsServer self, const char *basepath)
Set the virtual filestore basepath for the MMS file services.
MmsServer MmsServer_create(MmsDevice *device, TLSConfiguration tlsConfiguration)
char * MmsServer_getModelName(MmsServer self)
get the model name attribute of the VMD identity
Definition: mms_server.h:40
void MmsServer_setLocalIpAddress(MmsServer self, const char *localIpAddress)
struct sMmsServerConnection * MmsServerConnection
Definition: mms_server.h:45
Definition: mms_server.h:40
char * MmsServer_getVendorName(MmsServer self)
get the vendor name attribute of the VMD identity
struct sIsoConnection * IsoConnection
Definition: iso_server.h:54
void MmsServer_unlockModel(MmsServer self)
unlock the cached server data model
MmsError(* MmsFileAccessHandler)(void *parameter, MmsServerConnection connection, MmsFileServiceType service, const char *localFilename, const char *otherFilename)
MmsFileAccessHandler callback function. Use to monitor and control file access.
Definition: mms_server.h:200
void MmsServer_setVMDStatus(MmsServer self, int vmdLogicalStatus, int vmdPhysicalStatus)
set the VMD state values for the VMD status service
Definition: mms_server.h:49
bool(* AcseAuthenticator)(void *parameter, AcseAuthenticationParameter authParameter, void **securityToken, IsoApplicationReference *appReference)
Callback function to authenticate a client.
Definition: iso_connection_parameters.h:105
void MmsServer_setServerIdentity(MmsServer self, char *vendorName, char *modelName, char *revision)
set the values that the server will give as response for an MMS identify request
int MmsServer_waitReady(MmsServer self, unsigned int timeoutMs)
Wait for the server to come ready in non-threaded operation mode.
MmsFileServiceType
Definition: mms_server.h:181
void MmsServer_startListening(MmsServer self, int tcpPort)
Start a new server thread and listen for incoming connections.
struct sMmsServer * MmsServer
Definition: mms_server.h:43
MmsServerEvent
Definition: mms_server.h:39
MmsDataAccessError(* MmsReadAccessHandler)(void *parameter, MmsDomain *domain, char *variableId, MmsServerConnection connection)
Definition: mms_server.h:56
void(* MmsStatusRequestListener)(void *parameter, MmsServer mmsServer, MmsServerConnection connection, bool extendedDerivation)
User provided handler that is invoked on a MMS status request.
Definition: mms_server.h:397
IsoConnection MmsServerConnection_getIsoConnection(MmsServerConnection self)
bool(* MmsObtainFileHandler)(void *parameter, MmsServerConnection connection, const char *sourceFilename, const char *destinationFilename)
ObtainFile service callback handler.
Definition: mms_server.h:144
MmsVariableListType
Definition: mms_server.h:47
char * MmsServerConnection_getClientAddress(MmsServerConnection self)
int MmsServer_getVMDLogicalStatus(MmsServer self)
get the logical status attribute of the VMD
Definition: mms_server.h:182
MmsValue *(* MmsReadVariableHandler)(void *parameter, MmsDomain *domain, char *variableId, MmsServerConnection connection)
Definition: mms_server.h:53
void MmsServer_insertIntoCache(MmsServer self, MmsDomain *domain, char *itemId, MmsValue *value)
MmsError(* MmsNamedVariableListChangedHandler)(void *parameter, bool create, MmsVariableListType listType, MmsDomain *domain, char *listName, MmsServerConnection connection)
callback handler that is called whenever a named variable list changes
Definition: mms_server.h:120
void MmsServer_handleIncomingMessages(MmsServer self)
Handle client connections (for non-threaded operation mode)
Definition: mms_server.h:48
void MmsServer_installVariableListChangedHandler(MmsServer self, MmsNamedVariableListChangedHandler handler, void *parameter)
Install callback handler that is called when a named variable list changes (is created or deleted) ...
void(* MmsGetFileCompleteHandler)(void *parameter, MmsServerConnection connection, const char *destinationFilename)
Get file complete (obtainFile service terminated) callback handler.
Definition: mms_server.h:167
Definition: mms_server.h:50
Definition: mms_server.h:184
void MmsServer_installGetFileCompleteHandler(MmsServer self, MmsGetFileCompleteHandler handler, void *parameter)
Install callback handler that is invoked when the file upload (obtainFile service) is completed and t...
void(* MmsConnectionHandler)(void *parameter, MmsServerConnection connection, MmsServerEvent event)
Definition: mms_server.h:63
void MmsServer_setStatusRequestListener(MmsServer self, MmsStatusRequestListener listener, void *parameter)
set the MmsStatusRequestListener for this MmsServer
MmsDataAccessError
Definition: mms_value.h:47
Definition: mms_server.h:185
void MmsServer_installWriteHandler(MmsServer self, MmsWriteVariableHandler, void *parameter)
void MmsServer_installFileAccessHandler(MmsServer self, MmsFileAccessHandler handler, void *parameter)
Install a callback handler this is invoked when the client requests a file server. This function can be used to monitor and control file access.
bool MmsServer_isRunning(MmsServer self)
void MmsServer_installObtainFileHandler(MmsServer self, MmsObtainFileHandler handler, void *parameter)
Install callback handler that is invoked when the file upload (obtainFile service) is invoked by the ...
void MmsServer_installConnectionHandler(MmsServer self, MmsConnectionHandler, void *parameter)
MmsValue * MmsServer_getValueFromCache(MmsServer self, MmsDomain *domain, const char *itemId)
void MmsServer_stopListeningThreadless(MmsServer self)
Stop the server (for non-threaded operation mode)
Definition: mms_device_model.h:38
void MmsServer_setClientAuthenticator(MmsServer self, AcseAuthenticator authenticator, void *authenticatorParameter)
void MmsServer_handleBackgroundTasks(MmsServer self)
Handle MmsServer background task.
void MmsServer_destroy(MmsServer self)
char * MmsServer_getRevision(MmsServer self)
get the revision attribute of the VMD identity
MmsError
Definition: mms_common.h:38
void MmsServer_stopListening(MmsServer self)
Stop server thread an all open connection threads.
struct sMmsValue MmsValue
Definition: mms_value.h:68
Definition: mms_server.h:183