gRPC® (Google Remote Procedure Call) is a high-performance framework for developing distributed systems. It uses HTTP/2 and Protocol Buffers (Protobuf™) as the underlying protocols for data exchange between clients and servers.
This project is an adaptation of gRPC for KasperskyOS. It is based on the original version of grpc 1.48.0 and includes an example that demonstrates its use in KasperskyOS.
For additional details on KasperskyOS, including its limitations and known issues, please refer to the KasperskyOS Community Edition Online Help.
- KasperskyOS modification of gRPC
- Trademarks
- Contributing
- Licensing
Remote Procedure Calls (RPCs) provide a useful abstraction for building distributed applications and services. The libraries in this repository provide a concrete implementation of the gRPC protocol, layered over HTTP/2. These libraries enable communication between clients and servers using any combination of the supported languages.
This repository contains source code for gRPC libraries for multiple languages written on top of shared C core library ./src/core, but the KasperskyOS adaptation is realized only for C++.
Developers using gRPC typically start with the description of an RPC service (a collection of methods), and generate client and server side interfaces which they use on the client-side and implement on the server side.
By default, gRPC uses Protocol Buffers as the gRPC Interface Definition Language (IDL) for describing both the service interface and the structure of the payload messages. It is possible to use other alternatives if desired.
Starting from an interface definition in a *.proto file, gRPC provides Protocol Compiler plugins that generate Client- and
Server-side APIs. gRPC users typically call into these APIs on the Client side and implement the corresponding API on the server side.
Synchronous RPC calls, that block until a response arrives from the server, are the closest approximation to the abstraction of a procedure call that RPC aspires to.
On the other hand, networks are inherently asynchronous and in many scenarios, it is desirable to have the ability to start RPCs without blocking the current thread.
The gRPC programming surface in most languages comes in both synchronous and asynchronous flavors.
gRPC supports streaming semantics, where either the client or the server (or both) sends a stream of messages on a single RPC call. The most general case is Bidirectional Streaming where a single gRPC call establishes a stream where both the client and the server can send a stream of messages to each other. The streamed messages are delivered in the order they were sent.
The gRPC protocol specifies the abstract requirements for communication between clients and servers. A concrete embedding over HTTP/2 completes the picture by fleshing out the details of each of the required operations.
A gRPC comprises of a bidirectional stream of messages, initiated by the client. In the client-to-server direction,
this stream begins with a mandatory Call Header, followed by optional Initial-Metadata, followed by zero or more Payload Messages.
The server-to-client direction contains an optional Initial-Metadata, followed by zero or more Payload Messages terminated
with a mandatory Status and optional Status-Metadata (or Trailing-Metadata).
The abstract gRPC protocol is implemented over HTTP/2.
gRPC bidirectional streams are mapped to HTTP/2 streams.
The contents of Call Header and Initial Metadata are sent as HTTP/2 headers and subject to HPACK compression.
Payload Messages are serialized into a byte stream of length prefixed gRPC frames
which are then fragmented into HTTP/2 frames at the sender and reassembled at the receiver.
Status and Trailing-Metadata are sent as HTTP/2 trailing headers (or trailers).
gRPC inherits the flow control mechanisms in HTTP/2 and uses them to enable fine-grained control of the amount of memory used for buffering in-flight messages.
- Install KasperskyOS Community Edition SDK. You can download the latest version of the KasperskyOS Community Edition for free from os.kaspersky.com. The minimum required version of KasperskyOS Community Edition SDK is 1.3. For more information, see System requirements.
- Clone gRPC for KasperskyOS repository to your project directory (to reduce cloning time you can use
--depth 1option):$ git clone --recurse-submodules --shallow-submodules https://github.com/KasperskyLab/grpc-kos.git
- NTP is a networking protocol for clock synchronization between computer systems.
NTP is necessary to gRPC to ensure ssl-encrypted connections between server and client tasks located on different hardware.
When it is impossible to access external NTP services, it is recommended to run a local NTP service on the host.
The following step shows how to install the NTP server using
apt:$ sudo apt install ntp
gRPC is built using the CMake build system, which is provided in the KasperskyOS Community Edition SDK. In order to use gRPC for KasperskyOS and the host, it is necessary to install gRPC on both platforms. It is recommended to use the same gRPC version for KasperskyOS and other platforms.
By default, gRPC uses protocol buffers, you will need the protoc compiler to generate stub server and client code.
If you compile gRPC from source, the Makefile will automatically try to compile the protoc compiler from the
./third_party directory. This will happen if you have recursively cloned the repository and it detects
that the protoc compiler has not installed on your system yet.
The gRPC is cross-compiled on the host where the KasperskyOS Community Edition SDK is installed.
To compile *.proto files and use gRPC plugins, it is necessary to first build and install gRPC for the host.
The protoc compiler (used to compile *.proto files) must be built with the host toolchain.
This is because the protoc will be run on the host when building solutions for KasperskyOS.
To build and install gRPC for the host, go to the ./kos directory and execute the host-build.sh script.
The environment variable INSTALL_PREFIX specifies the installation path of gRPC for the host.
If not specified, gRPC for the host will be installed in the ./install/host directory.
Syntax for using the host-build.sh script:
$ host-build.sh [-i INSTALL_PREFIX]The parameter -i, --install-prefix INSTALL_PREFIX specifies the installation path of gRPC for the host.
The value specified in this parameter takes precedence over the value of the INSTALL_PREFIX environment variable.
By default, the build type is set to Debug, the build libraries are static,
and the build path is set to ./build/host. To change this, edit the host-build.sh script as needed.
For example:
$ ./host-build.shYou also can build gRPC for corresponding host manually.
To build and install gRPC for KasperskyOS, go to the ./kos directory and execute the cross-build.sh script.
There are environment variables that affect the build and installation of the libraries:
SDK_PREFIXspecifies the path to the installed version of the KasperskyOS Community Edition SDK.INSTALL_PREFIXspecifies the installation path of gRPC for KasperskyOS. If not specified, the libraries will be installed in the./install/kosdirectory.TARGETspecifies the target platform. If not specified, the platform will be determined automatically.
Syntax for using the cross-build.sh script:
$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> [TARGET="aarch64-kos"] ./cross-build.sh [-h] [-s PATH] [-i PATH] [-H PATH] [-j N],
where:
-
versionLatest version number of the KasperskyOS Community Edition SDK.
-
-h, --helpHelp text.
-
-s, --sdk PATHPath to the installed version of the KasperskyOS Community Edition SDK. The path must be set using either the value of the
SDK_PREFIXenvironment variable or the-soption. The value specified in the-soption takes precedence over the value of theSDK_PREFIXenvironment variable. -
-i, --install PATHPath to directory where gRPC for KasperskyOS will be installed. If not specified, the default path
./install/koswill be used. The value specified in the-ioption takes precedence over the value of theINSTALL_PREFIXenvironment variable. -
-H, --host-install PATHPath to the directory where gRPC for the host is installed. If not specified, the default path
./install/hostwill be used. -
-j, --jobs NNumber of jobs for parallel build. If not specified, the default value is 1.
By default, the build type is set to Debug, the build libraries are static,
and the build path is set to ./build/kos. To change this, edit the cross-build.sh script as needed.
For CMake build system to find gRPC for KasperskyOS, make sure that the directory where the libraries were installed
is listed in the CMAKE_FIND_ROOT_PATH environment variable.
The cross-build.sh script builds only runtime libraries.
The host protoc compiler and gRPC plugin are used to generate source files from *.proto files.
The C++ gRPC tests have been adapted to run on KasperskyOS.
The CMake files for building the tests are located in the ./test/kos directory.
The tests have the following limitations:
- Some tests are disabled. See the list at ./test/kos/cmake/grpc_cpp_disabled_tests.cmake.
- Death tests not supported in KasperskyOS.
- Some tests are skipped. See the list at ./test/kos/cmake/tests.cmake.
- Flaky tests:
streaming_throughput_testasync_end2end_testcli_call_testclient_interceptors_end2end_testcontext_allocator_end2end_testdelegating_channel_testgoogle_c2p_resolver_testgrpc_authz_end2end_testservice_config_end2end_testshutdown_testxds_credentials_end2end_test
- C++ unit tests for KasperskyOS are currently available only for QEMU.
Tests use an out-of-source build. The build tree is situated in the generated ./build/kos_tests directory.
For each test suite, a separate image will be created. As it can be taxing on disk space, the tests will run sequentially.
To build and run the tests, go to the ./kos directory and execute the run-tests.sh script.
There are environment variables that affect the build and installation of the tests:
SDK_PREFIXspecifies the path to the installed version of the KasperskyOS Community Edition SDK.TARGETspecifies the target platform. (Currently only theaarch64-kosplatform is supported.)
Syntax for using the run-tests.sh script:
$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> [TARGET="aarch64-kos"] ./run-tests.sh [--help] [-s PATH] [--list] [-n TEST_1] ... [-n TEST_N] [-t SEC] [-o PATH] [-j N] [-H PATH],
where:
-
versionLatest version number of the KasperskyOS Community Edition SDK.
-
-h, --helpHelp text.
-
-s, --sdk PATHPath to the installed version of the KasperskyOS Community Edition SDK. The path must be set using either the value of the
SDK_PREFIXenvironment variable or the-soption. The value specified in the-soption takes precedence over the value of theSDK_PREFIXenvironment variable. -
-l, --listList of tests that can be run.
-
-n, --name TESTTest name to execute. The parameter can be repeated multiple times. If not specified, all tests will be executed.
-
-t, --timeout SECTime, in seconds, allotted to start and execute a single test case. Default value is 3000 seconds.
-
-o, --out PATHPath where the results of the test run will be stored. If not specified, the results will be stored in the
./build/kos_tests/logsdirectory. -
-j, --jobs NNumber of jobs for parallel build. If not specified, the default value obtained from the
nproccommand is used. -
-H, --host-install PATHPath to the directory where gRPC for the host is installed. If not specified, the default path
./install/hostwill be used.
When you develop a KasperskyOS-based solution, use the recommended structure of project directories to simplify usage of CMake scripts.
For more on using gRPC in KasperskyOS, see the README.md file for the project's example.
Registered trademarks and endpoint marks are the property of their respective owners.
gRPC, Kubernetes are registered trademarks of The Linux Foundation in the United States and other countries.
Android, Chromium, Closure, Dart, Firebase, GoogleTest, Google Go, Protobuf, TensorFlow are trademarks of Google LLC.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Raspberry Pi is a trademark of the Raspberry Pi Foundation.
AFS, AIX, IBM, s3 are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.
AMD is a trademark or a registered trademark of Advanced Micro Devices, Inc.
F5 is a trademark of F5 Networks, Inc. in the U.S. and in certain other countries.
FreeBSD is a registered trademark of The FreeBSD Foundation.
MSDN, Microsoft, PowerShell, Visual C++, Visual Studio, Win32, Windows, Windows Server are trademarks of the Microsoft group of companies.
Mac, macOS, Mac OS, OS X, Objective-C, Rosetta, Xcode are trademarks of Apple Inc.
Firefox, Mozilla are trademarks of the Mozilla Foundation in the U.S. and other countries.
Pentium, Intel are trademarks of Intel Corporation or its subsidiaries.
Python is a trademark or registered trademark of the Python Software Foundation.
Fedora, Red Hat are trademarks or registered trademarks of Red Hat, Inc. or its subsidiaries in the United States and other countries.
Symantec is a registered trademark of Symantec Corporation or its affiliates in the U.S. and other countries.
UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited.
IOS is a registered trademark of Cisco Systems, Inc. and/or its affiliates in the United States and certain other countries.
Only KasperskyOS-specific changes can be approved. See CONTRIBUTING.md for detailed instructions on code contribution.
This project is licensed under the terms of the Apache License. See LICENSE for more information.
© 2025 AO Kaspersky Lab