module.lua: Add declare_txdata() fetchable via arg.txdata in handlers. RNS-1674
module.lua: Add declare_txdata() fetchable via arg.txdata in handlers. RNS-1674

    -- Example module code.
    local ibmod = ...

    -- Declare config and txdata for this module.
    local default_config = ibmod:declare_config {
        ibmod:num("cfg_num", 1)
    }
    local default_txdata = ibmod:declare_txdata {
        ibmod:num("tx_num", 1)
    }

    -- Increment tx_num on each call and write debug line.
    local function debug_state(tx)
        local cfg_num = tonumber(tx.config.cfg_num)
        local tx_num = 0;
        if tx.txdata ~= nil then
            tx_num = tonumber(tx.txdata.tx_num)
            tx.txdata.tx_num = tx_num + 1
        end
        io.stderr:write(string.format("LUA HANDLER: cfg_num=%s tx_num=%s\n", cfg_num, tx_num))
        return 0
    end

    -- Register handlers.
    ibmod:handle_request_header_state(debug_state)
    ibmod:handle_request_state(debug_state)
    ibmod:handle_response_header_state(debug_state)
    ibmod:handle_response_state(debug_state)

    -- Return IB_OK.
    return 0

    Prints something like:
    - LUA HANDLER: cfg_num=1 tx_num=1
    - LUA HANDLER: cfg_num=1 tx_num=2
    - LUA HANDLER: cfg_num=1 tx_num=3
    - LUA HANDLER: cfg_num=1 tx_num=4

b1v1r/ironbee,ironbee/ironbee,b1v1r/ironbee,ironbee/ironbee,b1v1r/ironbee,b1v1r/ironbee,ironbee/ironbee,ironbee/ironbee,b1v1r/ironbee,b1v1r/ironbee,b1v1r/ironbee,b1v1r/ironbee,b1v1r/ironbee,b1v1r/ironbee,ironbee/ironbee,b1v1r/ironbee,ironbee/ironbee,ironbee/ironbee,ironbee/ironbee,ironbee/ironbee,ironbee/ironbee,b1v1r/ironbee,ironbee/ironbee,ironbee/ironbee