Skip to content
Eduard Grasa edited this page Aug 29, 2018 · 12 revisions

Table of contents

  1. Introduction
  2. User-space plugins tutorial
    • 2.1 Plugin.cc
    • 2.2 Client-side operations

1. Introduction

The purpose of this section is to present some simple but complete examples that illustrate how to write user-space and kernel-space plugins. These tutorials are aligned to the current version of the SDK.

2. User-space plugins tutorial

Although it is possible to develop user-space plugins within the rinad/ipcp source code tree, the preferred way of contributing custom plugins to the IPC Process user-space implementation is to develop them outside of the rinad/ipcp source tree. Consequently, this tutorial will focus on this case.

A user-space plugin contains the implementation of one or more policy-sets that will be made available to the IPC Process Daemon at runtime by dynamically linking the shared object containing the plugin. The recommended structure of a plugin consists of the following files, that are usually contained in a directory dedicated to the plugin:

  • plugin.cc. The source file containing code that exports the policy-set factories for all the policy-sets contributed by the plugin.
  • implementation.cc. A number of .cc and .h files containing the implementation of the policy-sets contributed by the plugin.
  • plugin-name.manifest. A text file in JSON format that provides information on the policy-sets contributed by the plugin (see Section 4.3).
  • makefiles. A build system to compile, link and install the plugin. For example, it may be a single Makefile, or more files for autoconf/automake ([autoconf],[autoconf]) or CMake.

In order to understand better how all pieces works together, this section will walk through an example of a simple plugin that contributes a single policy-set to the Security-Manager component of the IPCP Daemon. The plugin, which can be found in the plugins/example-smplugin directory of the IRATI repository, is made of the following files:

  • plugin.cc
  • sm-example.cc
  • sm-example.manifest
  • Makefile

2.1 Plugin.cc

#include <string>
#include <sstream>
#define IPCP_MODULE "security-manager-example-ps"
#include "ipcp-logging.h"
#include "components.h"

namespace rinad {

extern "C" rina::IPolicySet * createSecurityManagerExamplePs(rina::ApplicationEntity * ctx);
extern "C" void destroySecurityManagerExamplePs(rina::IPolicySet * ps);
extern "C" int get_factories(std::vector<struct rina::PsFactory>& factories)
{
    struct rina::PsFactory factory;
    factory.info.name = "example";
    factory.info.app_entity = rina::ApplicationEntity::SECURITY_MANAGER_AE_NAME;
    factory.create = createSecurityManagerExamplePs;
    factory.destroy = destroySecurityManagerExamplePs;
    factories.push_back(factory);
    return 0;
}

} // namespace rinad
Clone this wiki locally