Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable plugin based fgn extensions #1

Open
dfranusic opened this issue Dec 20, 2016 · 1 comment
Open

Enable plugin based fgn extensions #1

dfranusic opened this issue Dec 20, 2016 · 1 comment
Assignees

Comments

@dfranusic
Copy link
Owner

dfranusic commented Dec 20, 2016

  • create pluggable interface for easier implementation of custom user functions (callable from fgn's advanced matching mode)
  • plugins are more suitable for funtions that depend on custom daemons and operate asynchronously(e.g. RRP based real-time rating module), or when low level system functions are needed for implementation of custom logic
@dfranusic
Copy link
Owner Author

dfranusic commented Dec 23, 2016

An example of a simple fgn plugin:

pm_plg_fgn_example.h
// header guard
#ifndef PM_FGN_MODULE_EXAMPLE_H
#define PM_FGN_MODULE_EXAMPLE_H

// fgn plugin macros
#include <pm_fgn_plugins.h>

// module name (pm_plg_fgn_example)
#define PM_FGN_MODULE pm_plg_fgn_example

// declare module init method
PM_FGN_MODULE_INIT_DECLARE(PM_FGN_MODULE)

// declare "pm_plg_fgn_example.example_test" method
PM_FGN_MODULE_METHOD_DECLARE(example_test)

#endif //PM_FGN_MODULE_EXAMPLE_H
pm_plg_fgn_example.cpp
// pm_plg_fgn_example plugin header
#include "pm_plg_fgn_example.h"

// define module init (start)
PM_FGN_MODULE_INIT_DEFINE(
    // module name
    PM_FGN_MODULE,
    // add method "example_test" to module "example"
    PM_FGN_MODULE_ADD_METHOD(example_test)
)

// define example.example_test method
PM_FGN_MODULE_METHOD_DEFINE(example_test){
    // get fgn payload (pointer to fgn::FgnPayload)
    PM_FGN_PLD_GET(pld);
    // get GT called address
    char* GT = pld->params.get_cstr(PT::_pt_sccp_called_pa_gt_address);
    // if GT address == 123456, return true
    if(GT && strcmp(GT, "123456") == 0) PM_FGN_MODULE_RET_BOOL(1);
    // default return (false)
    PM_FGN_MODULE_RET_BOOL(0);
}
example.lua
-- pmink module
local F = require('pmink')(...)
-- example plugin
local P = require('pm_plg_fgn_example')(...)
-- call test method
return P.example_test()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant