You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lua-ngcp-kamailio/ngcp/avp.lua

39 lines
1.0 KiB

#!/usr/bin/env lua5.1
-- class NGCPAvp
NGCPAvp = {
__class__ = 'NGCPAvp'
}
NGCPAvp_MT = {
__index = NGCPAvp,
}
function NGCPAvp:new(id)
local t = { id = "$avp(s:" .. id .. ")" }
NGCPAvp_MT.__call = function(t, value)
if not value then
--print(table.tostring(sr.pv.vars))
--print(t.id)
return sr.pv.get(t.id)
elseif type(value) == "number" then
sr.pv.seti(t.id, value)
elseif type(value) == "string" then
sr.pv.sets(t.id, value)
else
error("value is not a number or string")
end
end
function t.all()
return sr.pv.get("$(avp(" .. id .. ")[*])")
end
return setmetatable( t, NGCPAvp_MT )
end
function NGCPAvp:clean()
--print("NGCPAvp:clean")
--print(table.tostring(getmetatable(self)))
--print(table.tostring(self))
sr.pv.unset(self.id)
end
-- class
--EOF