This example demonstrates how to establish a connection via TCP sockets between the client program running in KasperskyOS and the server program running in the host operating system.
Example directory in the SDK
The code of the example and build scripts are available at the following path:
/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/net2_with_separate_vfs
List of programs
Client – application that creates a TCP socket, connects to the server, sends data to the server, and closes the connection.Server – application that accepts the connection request through the TCP socket, receives data from the client, and then closes the connection.VfsNet – system program that supports network protocols.DCM – system program that lets you dynamically create IPC channels.EntropyEntity – system program that implements random number generation.DNetSrv – network card driver.When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:
BSP – Board Support Package that provides cross-platform peripheral configuration for the Radxa ROCK 3A.Bcm2711MboxArmToVc – driver for working with the VideoCore (VC6) coprocessor via mailbox technology for Raspberry Pi 4 B.Initialization description
The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in template. Macros in @INIT_*@ format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.
Security policy description
The security.psl file contains a description of a security policy for a KasperskyOS-based solution and is located in the ./einit/src directory. The declarations in the PSL file are provided with comments that explain the purpose of these declarations.
Resources
The ./resources/xdl/net2_with_separate_vfs directory contains the Client.edl file, which is the EDL description of the Client program.
Operating scenario
The net2_with_separate_vfs example is a modified net_with_separate_vfs example. In contrast to the net_with_separate_vfs example, in this example a program interacts over the network with an external server rather than another program running in KasperskyOS.
This example consists of the Client program running in KasperskyOS and the Server program running in a Linux host operating system. The Client program and Server program are bound by a TCP socket. Standard POSIX functions are used in the code of the Client program.
To connect the Client program and the Server program using a socket, the Client program must interact with the VfsNet program. During the build, the VfsNet program is linked to a network driver that supports interaction with the Server program running in Linux.
The IP address of the Server program is defined in the ./CMakeList.txt file by using the SERVER_IP variable and is set to 10.0.2.2 by default. The default values for the Client program (interface name, address, network mask, and gateway address) are taken from the file /opt/KasperskyOS-Community-Edition-<platform>-<version>/sysroot-aarch64-kos/include/kos_net.h. You can change these values according to the configuration of your network in the client/src/client.c file located in the example directory.
Building and running the example
The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.
To ensure that an example runs correctly, you must run the Server program in a Linux host operating system or on a computer connected to the hardware platform.
If the example is run in QEMU, the Server program will be built and run in the Linux host operating system automatically. After performing the build, the server executable file of the Server program is located in the following directory:
<example nam>/build/host/server/
If the example is run on a hardware platform, you must independently build the executable file of the Server program by running the following commands:
$ export PATH="/opt/KasperskyOS-Community-Edition-<platform>-<version>/toolchain/bin/:$PATH"
$ cd net2_with_separate_vfs/server/
$ cmake -G "Unix Makefiles" -B ./build
$ cmake --build ./build/ --target server
See Building and running examples section.
Page top