Contents
Overview: creating IPC channels
There are two methods for creating IPC channels: static and dynamic.
Static creation of IPC channels is simpler to implement because you can use the init description for this purpose.
Dynamic creation of IPC channels lets you change the topology of interaction between processes on the fly. This is necessary if it is unknown which specific server contains the endpoint required by the client. For example, you may not know which specific drive you will need to write data to.
Statically creating an IPC channel
The static method has the following distinguishing characteristics:
- The client and server are in the stopped state when the IPC channel is created.
- Creation of this channel is initiated by the parent process that starts the client and server (this is normally Einit).
- The created IPC channel cannot be deleted.
- To get the IPC handle and endpoint ID (riid) after the IPC channel is created, the client and server must use the endpoint locator interface (
coresrv/sl/sl_api.h
).
Dynamically creating an IPC channel
The dynamic method has the following distinguishing characteristics:
- The client and server are already running at the time of creating the IPC channel.
- Creation of the channel is initiated jointly by the client and server.
- The created IPC channel can be deleted.
- The client and server get the IPC handle and endpoint ID (riid) immediately after the IPC channel is successfully created.
Creating IPC channels using init.yaml
This section contains init descriptions that demonstrate the specific features of creating IPC channels. Examples of defining properties and arguments of processes via init descriptions are examined in a separate article.
Examples in KasperskyOS Community Edition may utilize a macro-containing init description format (init.yaml.in
).
The file containing an init description is usually named init.yaml
, but it can have any name.
Connecting and starting a client process and server process
In the next example, two processes will be started: one process of the Client
class and one process of the Server
class. The names of the processes are not specified, so they will match the names of their respective process classes. The names of the executable files are not specified either, so they will also match the names of their respective classes. The processes will be connected by an IPC channel named server_connection
.
init.yaml
entities:
- name: Client
connections:
- target: Server
id: server_connection
- name: Server
Dynamically created IPC channels
A dynamically created IPC channel uses the following functions:
- Name Server interface
- Connection Manager interface
An IPC channel is dynamically created according to the following scenario:
- The following processes are started: client, server, and name server.
- The server connects to the name server by using the
NsCreate()
call and publishes the server name, interface name, and endpoint name by using theNsPublishService()
call. - The client uses the
NsCreate()
call to connect to the name server and then uses theNsEnumServices()
call to search for the server name and endpoint name based on the interface name. - The client uses the
KnCmConnect()
call to request access to the endpoint and passes the found server name and endpoint name as arguments. - The server calls the
KnCmListen()
function to check for requests to access the endpoint. - The server accepts the client request to access the endpoint by using the
KnCmAccept()
call and passes the client name and endpoint name received from theKnCmListen()
call as arguments.
Steps 2 and 3 can be skipped if the client already knows the server name and endpoint name in advance.
The server can use the NsUnPublishService()
call to unpublish endpoints that were previously published on the name server.
The server can use the KnCmDrop()
call to reject requests to access endpoints.
To use a name server, the solution security policy must allow interaction between a process of the kl.core.NameServer
class and processes between which IPC channels must be dynamically created.