@ -110,43 +110,41 @@ connectionHandler (IedServer self, ClientConnection connection, bool connected,
* This handler is called before the rcbEventHandler and can be use to allow or permit read or write access to the RCB
* This handler is called before the rcbEventHandler and can be use to allow or permit read or write access to the RCB
*/
*/
static bool
static bool
rcbAccessHandler( void * parameter , ReportControlBlock * rcb , ClientConnection connection , IedServer_RCBEventType operation )
controlBlockAccessHandler( void * parameter , ClientConnection connection , ACSIClass acsiClass , LogicalDevice * ld , LogicalNode * ln , const char * objectName , const char * subObjectName , IedServer_ControlBlockAccessType accessType )
{
{
printf ( " RCB: %s access: %s\n " , ReportControlBlock_getName ( rcb ) , operation = = RCB_EVENT_GET_PARAMETER ? " READ " : " WRITE " ) ;
printf ( " %s %s access %s/%s.%s.%s\n " , ACSIClassToStr ( acsiClass ) , accessType = = IEC61850_CB_ACCESS_TYPE_WRITE ? " write " : " read " , ld - > name , ln - > name , objectName , subObjectName ) ;
if ( operation = = RCB_EVENT_GET_PARAMETER ) {
/* allow only read access to LCBs */
if ( acsiClass = = ACSI_CLASS_LCB ) {
if ( accessType = = IEC61850_CB_ACCESS_TYPE_READ )
return true ;
return true ;
}
else
else {
return false ;
/* change to false to disallow write access to control block */
return true ;
}
}
}
static bool
/* allow only read access to BRCBs */
lcbAccessHandler ( void * parameter , LogControlBlock * lcb , ClientConnection connection , IedServer_LCBEventType operation )
if ( acsiClass = = ACSI_CLASS_BRCB ) {
{
if ( accessType = = IEC61850_CB_ACCESS_TYPE_READ )
printf ( " LCB: %s access: %s \n " , LogControlBlock_getName ( lcb ) , operation = = LCB_EVENT_GET_PARAMETER ? " READ " : " WRITE " ) ;
if ( operation = = LCB_EVENT_GET_PARAMETER ) {
return true ;
return true ;
}
else
else {
return false ;
return false ;
}
}
/* to all other control blocks allow read and write access */
return true ;
}
}
static void
static void
rcbEventHandler ( void * parameter , ReportControlBlock * rcb , ClientConnection connection , IedServer_RCBEventType event , const char * parameterName , MmsDataAccessError serviceError )
rcbEventHandler ( void * parameter , ReportControlBlock * rcb , ClientConnection connection , IedServer_RCBEventType event , const char * parameterName , MmsDataAccessError serviceError )
{
{
printf ( " RCB: %s event: %i \n " , ReportControlBlock_getName ( rcb ) , event ) ;
if ( ( event = = RCB_EVENT_SET_PARAMETER ) | | ( event = = RCB_EVENT_GET_PARAMETER ) ) {
if ( ( event = = RCB_EVENT_SET_PARAMETER ) | | ( event = = RCB_EVENT_GET_PARAMETER ) ) {
printf ( " RCB: %s event: %i \n " , ReportControlBlock_getName ( rcb ) , event ) ;
printf ( " param: %s \n " , parameterName ) ;
printf ( " param: %s \n " , parameterName ) ;
printf ( " result: %i \n " , serviceError ) ;
printf ( " result: %i \n " , serviceError ) ;
}
}
if ( event = = RCB_EVENT_ENABLE ) {
if ( event = = RCB_EVENT_ENABLE ) {
printf ( " RCB: %s event: %i \n " , ReportControlBlock_getName ( rcb ) , event ) ;
char * rptId = ReportControlBlock_getRptID ( rcb ) ;
char * rptId = ReportControlBlock_getRptID ( rcb ) ;
printf ( " rptID: %s \n " , rptId ) ;
printf ( " rptID: %s \n " , rptId ) ;
char * dataSet = ReportControlBlock_getDataSet ( rcb ) ;
char * dataSet = ReportControlBlock_getDataSet ( rcb ) ;
@ -286,15 +284,12 @@ main(int argc, char** argv)
IedServer_setConnectionIndicationHandler ( iedServer , ( IedConnectionIndicationHandler ) connectionHandler , NULL ) ;
IedServer_setConnectionIndicationHandler ( iedServer , ( IedConnectionIndicationHandler ) connectionHandler , NULL ) ;
/* Install handler to perform access control on RCB */
IedServer_setRCBAccessHandler ( iedServer , rcbAccessHandler , NULL ) ;
/* Install handler to perform access control on LCB */
IedServer_setLCBAccessHandler ( iedServer , lcbAccessHandler , NULL ) ;
/* Install handler to log RCB events */
/* Install handler to log RCB events */
IedServer_setRCBEventHandler ( iedServer , rcbEventHandler , NULL ) ;
IedServer_setRCBEventHandler ( iedServer , rcbEventHandler , NULL ) ;
/* Install handler to control access to control blocks (RCBs, LCBs, GoCBs, SVCBs, SGCBs)*/
IedServer_setControlBlockAccessHandler ( iedServer , controlBlockAccessHandler , NULL ) ;
/* By default access to variables with FC=DC and FC=CF is not allowed.
/* By default access to variables with FC=DC and FC=CF is not allowed.
* This allow to write to simpleIOGenericIO / GGIO1 . NamPlt . vendor variable used
* This allow to write to simpleIOGenericIO / GGIO1 . NamPlt . vendor variable used
* by iec61850_client_example1 .
* by iec61850_client_example1 .