KasperskyOS Community Edition 1.3

Using the additional API for clients (subscr.h)

The API allows clients to receive notifications about the publishing and unpublishing of endpoint groups. From the client perspective, a group of endpoints is a set of endpoints on one server for which clients can use a single DCM handle to receive notifications about the publishing and unpublishing of those endpoints. However, there is a restriction that prevents a server from providing multiple endpoints with one interface. Multiple servers may provide identical groups of endpoints required by a client. A server may provide multiple groups of endpoints required by a client. A set of endpoints from different groups required by a client may overlap.

Information about API functions is provided in the table below.

To create a DCM handle that enables receipt of notifications about the publishing and unpublishing of endpoints with specific interfaces, call the DcmSetGroupSubscription() function. Use the endpointTypes parameter to define the names of interfaces of grouped endpoints. In the endpointsCount parameter, specify a number of grouped endpoints equal to the number of interfaces defined via the endpointTypes parameter. (Notifications will contain a number of endpoints equal to the number of interfaces because of the restriction dictating that one separate endpoint corresponds to each interface.)

To extract a notification about the publishing or unpublishing of an endpoint group from the notification queue, call the DcmReadGroupPubQueue() function. In the subscrHandle parameter of the DcmReadGroupPubQueue() function, specify the DCM handle that was obtained by calling the DcmSetGroupSubscription() function. In the maxCount parameter of the DcmReadGroupPubQueue() function, specify the number of elements in the array defined via the outEndpoints parameter. The value of this parameter must be greater than or equal to the number of endpoints in the group. The value obtained via the outPubStatus parameter of the DcmReadGroupPubQueue() function indicates that the group of endpoints was published or unpublished. A notification about the publishing of an endpoint group appears in the queue only if the server publishes all endpoints in the group together or one by one. If the server publishes only a portion of the endpoints required by the client, a notification about the publishing of an endpoint group does not appear. If the server terminates or unpublishes at least one endpoint in a published group of endpoints, the client receives a notification about the unpublishing of this endpoint group.

If you no longer need to receive notifications about the publishing and unpublishing of an endpoint group with specific interfaces, the DCM handle that was created by calling the DcmSetGroupSubscription() function must be closed by calling the DcmCloseGroupSubscrHandle() function.

To interrupt a blocking call of the DcmReadGroupPubQueue() function from another thread, call the DcmInterruptGroupSubscrBlockingCall() function.

You can use the DcmSubscribeToGroupSubscrEvent() and DcmUnsubscribeFromGroupSubscrEvent() functions together with the functions from the notice_api.h API to receive notifications about the occurrence of the following events: the server published or depublished an endpoint in DCM (the DCM_PUBLICATION_CHANGED flag), or a blocking call of the DcmReadGroupPubQueue() function was interrupted (the DCM_BLOCKING_CALL_INTERRUPTED flag). (Flags of the event mask and the "resource–event mask" entry ID DCM_EVENT_ID are defined in the header file sysroot-*-kos/include/dcm/dcm_api.h from the KasperskyOS SDK.) The DcmSubscribeToGroupSubscrEvent() and DcmUnsubscribeFromGroupSubscrEvent() functions let you configure the notification receiver by adding or deleting, respectively, tracked objects identified by DCM handles.

subscr.h functions

Function

Information about the function

DcmSetGroupSubscription()

Purpose

Creates a DCM handle that enables receipt of notifications about the publishing and unpublishing of endpoint groups with specific interfaces.

Parameters

  • [in] endpointTypes – pointer to the array containing the names of interfaces of the endpoints being grouped.
  • [in] endpointsCount – number of grouped endpoints. It must match the number of interfaces defined via the endpointTypes parameter.
  • [in,optional] serverName – pointer to the server name, or RTL_NULL to not use notification filtering based on the server name.
  • [in,optional] serverHandle – handle identifying the server, or INVALID_HANDLE to not use notification filtering based on a specific server.
  • [out] outSubscrHandle – pointer to the DCM handle that enables receipt of notifications about the publishing and unpublishing of endpoint groups with specific interfaces.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

DcmReadGroupPubQueue()

Purpose

Extracts a notification about the publishing or unpublishing of an endpoint group from the notification queue.

Parameters

  • [in] subscrHandle – DCM handle that was obtained by calling the DcmSetGroupSubscription() function.
  • [in] msec – time-out before notifications appearing in milliseconds, or INFINITE_TIMEOUT to set an unlimited time-out.
  • [in] maxCount – number of elements in the array defined via the outEndpoints parameter. It must be greater than or equal to the number of endpoints in the group.
  • [out,optional] outServerHandle – pointer to the handle identifying the server, or RTL_NULL if this handle is not required.
  • [out,optional] outServerName – pointer to the buffer for the server name, or RTL_NULL if this name is not required.
  • [in] serverNameSize – size (bytes) for the server name, or 0 if this name is not required.
  • [out] outEndpoints – pointer to the array of structures containing the qualified names of endpoints in the group and the names of interfaces of the group endpoints.
  • [out] outEndpointsCount – pointer to the number of endpoints in the group.
  • [out] outPubStatus – pointer to the value indicating that the group of endpoints was published (DcmEndpointPublished) or unpublished (DcmEndpointUnpublished).

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

If a blocking call was interrupted by calling the DcmInterruptGroupSubscrBlockingCall() function, rcAbort is returned.

Additional information

Non-blocking call if the msec parameter is set to 0.

DcmInterruptGroupSubscrBlockingCall()

Purpose

Interrupts a blocking call of the DcmReadGroupPubQueue() function.

Parameters

  • [in] subscrHandle – DCM handle specified when calling the DcmReadGroupPubQueue() function.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

DcmCloseGroupSubscrHandle()

Purpose

Closes the DCM handle that was obtained by calling the DcmSetGroupSubscription() function.

Parameters

  • [in] subscrHandle – DCM handle.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

DcmSubscribeToGroupSubscrEvent()

Purpose

Configures the notification receiver to receive notifications about events related to the object identified by the defined DCM handle.

Parameters

  • [in] notice – identifier of the notification receiver.
  • [in] subscrHandle – DCM handle that was obtained by calling the DcmSetGroupSubscription() function.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

DcmUnsubscribeFromGroupSubscrEvent()

Purpose

Configures the notification receiver to not receive notifications about events related to the object identified by the defined DCM handle.

Parameters

  • [in] notice – identifier of the notification receiver.
  • [in] subscrHandle – DCM handle that was obtained by calling the DcmSetGroupSubscription() function.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.