Diameter -> Diameter IWF Hooks

Diameter -> Diameter IWF Hooks

The Diameter -> Diameter IWF does not include any built-in logic for manipulating the AVPs of inbound Requests (or outbound Answers) before sending on the Request (or Answer) to the next hop.

To manipulate Diameter AVPs, custom Lua hooks are required. A custom Lua hook file is defined by the HOOK_SCRIPT LuaApp global variable in the N2SVCD configuration file.

To define a hook script, use the following template:

local diameter_api = require "n2.n2svcd.diameter_agent"
local n2svcd       = require "n2.n2svcd"

local hooks = {}

--[[---------------------------------------------------------------------------
-- A hook
--
-- Parameters
--  session_id      - The session of the request/answer
--  subscription_id - The first found subscription_id from the AVPs. This may NOT be the MSISDN
--  avps            - The AVPs for the request/answer. Either directly manipulate this list
--                    or build a new list and return it from this function.
--  edr_data        - A table of EDR data. Inject extra data if you want
--
-- Returns
--  A new table if you want to rebuild the AVP list, otherwise you can return
--  nil, and the passed 'avps' table will be reused (with any alterations you've
--  made).
--
--  Returning a new table is the only way to remove AVPs from the original
--  AVP list.
--]]---------------------------------------------------------------------------
local hook_name = "Hook Name"

hooks[hook_name] = function (session_id, subscription_id, avps, edr_data)

    -- Either adjust avps directly
    -- or return a new table of avps, possibly with copied AVPs from the
    -- avps argument to this hook function

end

return hooks

The Hook Name must be in a format that allows the Diameter -> Diameter IWF to choose the hook when appropriate. The Hook Name must be formatted as:

[Command-Name] .. "-" .. [Service-Context-Id] .. "-" .. [CC-Request-Type] .. "-Request"
[Command-Name] .. "-" .. [Service-Context-Id] .. "-" .. [CC-Request-Type] .. "-Answer"

Where:

Multiple hooks can be defined in the same file. Where a Service-Context-Id is not available, it is not used to determine the hook name, and the hook name will become [Command-Name] .. "-" .. [CC-Request-Type] .. "-" with Request or Answer suffixed.