summaryrefslogtreecommitdiff
path: root/src/api/plugin_api.h.in
blob: f040912d585d52d4c9548a558257729f438cf6b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//------------------------------------------------------------------------------
// Author: Dzianis Huznou
// Description: Unique Plugin-API interface header.
// Aggregated all definitions for plugins' development
// Copyright (c) 2013 EPAM Systems
//------------------------------------------------------------------------------
/*
    This file is part of Nfstrace.

    Nfstrace is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 2 of the License.

    Nfstrace is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Nfstrace.  If not, see <http://www.gnu.org/licenses/>.
*/
//------------------------------------------------------------------------------
#ifndef PLUGIN_API_H
#define PLUGIN_API_H
//------------------------------------------------------------------------------
#include <iostream>

#include "ianalyzer_type.h"
#include "nfs_types.h"
#include "nfs3_types_rpcgen.h"
#include "nfs4_types_rpcgen.h"
//------------------------------------------------------------------------------
#define NST_PUBLIC __attribute__ ((visibility("default")))
#define NST_PLUGIN_ENTRY_POINTS(U, C, D)            \
NST_PUBLIC                                          \
const plugin_entry_points* nst_get_entry_points()   \
{                                                   \
    static const plugin_entry_points entry_points   \
    {NST_PLUGIN_API_VERSION, sizeof(plugin_entry_points), U, C, D }; \
    return &entry_points;                           \
}
//------------------------------------------------------------------------------
using namespace NST::API;
//------------------------------------------------------------------------------
extern "C"
{
// These calls implemented by nfstrace
const char* print_nfs3_procedures(const ProcEnumNFS3::NFSProcedure proc);
const char* print_nfs4_procedures(const ProcEnumNFS4::NFSProcedure proc);
void print_session(std::ostream& out, const Session& session);
void print_nfs_fh(std::ostream& out, const char* const val, const uint32_t len);
}

// These functions must be implemented by pluggable analysis module
// Pointers to these functions must be passed to NST_PLUGIN_ENTRY_POINTS() macro
using plugin_usage_func   = const char* (*)();            // return description of options for create(opts)
using plugin_create_func  = IAnalyzer*  (*)(const char*); // create an instance of an Analyzer
using plugin_destroy_func = void        (*)(IAnalyzer*);  // destroy instance of an Analyzer

struct plugin_entry_points
{
    const uint32_t      vers;
    const size_t        size;
    plugin_usage_func   usage;
    plugin_create_func  create;
    plugin_destroy_func destroy;
};

// The NST_PLUGIN_ENTRY_POINTS macro defines this function
using plugin_get_entry_points_func = const plugin_entry_points* (*)();

constexpr uint32_t NST_PLUGIN_API_VERSION = @NST_V_MAJOR@ * 1000
                                          + @NST_V_MINOR@ * 100
                                          + @NST_V_PATCH@;

//------------------------------------------------------------------------------
#endif //PLUGIN_API_H
//------------------------------------------------------------------------------