diff --git a/ngcp/xavp.lua b/ngcp/xavp.lua index a2e4edd..e60dec9 100644 --- a/ngcp/xavp.lua +++ b/ngcp/xavp.lua @@ -141,6 +141,15 @@ NGCPXAvp_MT = { end end + function NGCPXAvp:all(key) + if key then + local t = sr.xavp.get(self.name, 0, 0) + if t then + return t[key]; + end + end + end + function NGCPXAvp:clean(key) if key then local id = string.format("$xavp(%s[0]=>%s)", self.name, key) diff --git a/tests/ngcp_xavp.lua b/tests/ngcp_xavp.lua index e762090..520bbd2 100644 --- a/tests/ngcp_xavp.lua +++ b/tests/ngcp_xavp.lua @@ -83,6 +83,14 @@ TestNGCPXAvp = {} --class assertItemsEquals(xavp("testid"), "1") end + function TestNGCPXAvp:test_xavp_get_all() + xavp = NGCPXAvp:new("caller", "peer", vals) + sr.pv.sets("$xavp(caller_peer=>testid)", "value") + assertEquals(xavp("testid"), "value") + sr.pv.sets("$xavp(caller_peer=>testid)", "1") + assertItemsEquals(xavp:all("testid"), {"1", "value"}) + end + function TestNGCPXAvp:test_xavp_set() local xavp = NGCPXAvp:new("caller", "peer", vals) local vals = {1,"2",3,nil}