IPC transport tools

To set up interactions between entities, you do not have to implement the correct packaging and unpacking of messages from scratch. In addition, you do not have to write separate code for creating IPC channels.

To resolve these and other problems associated with IPC transport, KasperskyOS provides a special set of tools:

Combined use of these tools is shown in the echo example.

NkKosTransport

NkKosTransport is a convenient wrapper for the Call, Recv and Reply system calls. It lets you work separately with messages’ constant parts and arenas.

The nk_transport_call(), nk_transport_recv() and nk_transport_reply() functions are used to call transport.

Example:

/* The nk_transport_recv () function executes the Recv system call.

* The request received from the client is inserted into req (constant part of the response) and

* req_arena (response arena). */

nk_transport_recv(&transport.base, (struct nk_message *)&req, &req_arena);

The NkKosTransport structure and methods for working with it are declared in the transport-kos.h file:

#include <coresrv/nk/transport-kos.h>

For more details about the constant part and the arena, refer to "IPC message structure".

For more details about using NkKosTransport, refer to "NkKosTransport".

EDL, CDL and IDL descriptions

The EDL, CDL and IDL languages are used to describe interfaces that implement server entities.

For more details, refer to "Description of entities, components and interfaces (EDL, CDL, IDL)".

Description files (*.edl, *.cdl and *.edl) are processed by the NK compiler during the build. This results in the creation of the *.edl.h, *.edl.c, *.cdl.h, *.cdl.c, *.idl.h and *.idl.c files, which contain the transport methods and types used on the client and the server.

NK compiler

Based on the EDL, CDL and IDL descriptions, the NK compiler (nk-gen-c) generates a set of transport methods and types. The transport methods and types are needed for generating, sending, receiving and processing IPC messages.

Most important transport methods:

Most important transport types:

For more details, refer to "Generated methods and types".

Init description and einit tool

The einit tool lets you automate the creation of code of the einit initializing entity. This entity is the first to start when KasperskyOS is loaded. Then it starts the other entities and creates channels (connections) between them.

To enable the einit entity to create a connection between entities A and B during startup, you need to specify the following in the init.yaml file:

init.yaml

# Start B

- name: B

# Start A

- name: A

  connections:

  # Create a connection with server entity B.

  - target: B

  # Name of the new connection: some_connection_to_B

    id: some_connection_to_B

For more details, refer to "Starting entities".

Service Locator

The Service Locator is a library containing the following functions:

The values of the IPC handle and RIID are used during NkKosTransport initialization.

To use Service Locator, you need to connect the sl_api.h file in the entity code:

#include <coresrv/sl/sl_api.h>

For more details, refer to "Service Locator".

Page top