Hello,

Based on kamailio-basic-kemi.cfg and kamailio-basic-kemi-lua.lua,
I’m trying to get a simple test to go through using SIPp built-in UAC and UAS scenarios, using LUA config:

Commented out all the registration blocks and trying to run a simple proxy for now, but I can’t seem able to change the URI.

SIPp UAC: 192.168.1.12:5060
SIPp UAS: 192.168.1.12:5062
Kamailio 5.5.2: 192.168.15.:5060

Part of the Kamailio.lua config:

-- wrapper around tm relay function
function ksr_route_relay()
-- enable additional event routes for forwarded requests
-- - serial forking, RTP relaying handling, a.s.o.
if KSR.is_method_in("IBSU") then
if KSR.tm.t_is_set("branch_route")<0 then
KSR.dbg("EP: ksr_route_relay Set for branch_route\n");
KSR.tm.t_on_branch("ksr_branch_manage");
end
end
if KSR.is_method_in("ISU") then
if KSR.tm.t_is_set("onreply_route")<0 then
KSR.dbg("EP: ksr_route_relay Set for onreply_route\n");
KSR.tm.t_on_reply("ksr_onreply_manage");
end
end

if KSR.is_INVITE() then
if KSR.tm.t_is_set("failure_route")<0 then
KSR.dbg("EP: ksr_route_relay Set for failure\n");
KSR.tm.t_on_failure("ksr_failure_manage");
end
end

if KSR.tm.t_relay()<0 then
KSR.dbg("EP: ksr_route_relay Set for reply_error\n");
KSR.sl.sl_reply_error();
end
-- EP: Base route
KSR.dbg("EP: ksr_route_relay Check for Base Route\n");
if KSR.is_INVITE() then
KSR.dbg("EP: ksr_route_relay Base Route (DU)\n");
--KSR.sl.send_reply("503", "Debug");
KSR.setdsturi("sip:192.168.1.12:5062");
KSR.pv.sets("$du", "sip:192.168.1.12:5062");
end

KSR.dbg("EP: ksr_route_relay exit\n");
KSR.x.exit();
end

What’s happening here is that instead of forwarding the INVITE to the SIPp UAC, it creates a loop. Tried KSR.setdsturi() only (KSR.pv.sets commented out) and it’s still the same.
If I comment out the 503 reply, then that’s what the UAC gets back.

Here’s the log when calling ksr_route_relay:

Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/msg_translator.c:162]: check_via_address(): (192.168.1.12, 192.168.1.12, 0)
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:489]: sr_lua_reload_script(): No need to reload [/etc/kamailio/kamaili
o.lua] is version 0
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:673]: app_lua_run_ex(): executing Lua function: [[ksr_onsend_route]]
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:675]: app_lua_run_ex(): lua top index is: 0
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: tm [t_funcs.c:376]: t_relay_to(): new transaction forwarded
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[0] for: dbg is str: EP: ksr_r
oute_relay Check for Base Route
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/kemi.c:85]: sr_kemi_core_dbg(): EP: ksr_route_relay Check for Base Route
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[0] for: dbg is str: EP: ksr_r
oute_relay Base Route (DU)
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/kemi.c:85]: sr_kemi_core_dbg(): EP: ksr_route_relay Base Route (DU)
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[0] for: setdsturi is str: sip
:192.168.1.12:5062
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[0] for: sets is str: $du
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[1] for: sets is str: sip:192.
168.1.12:5062
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/kemi.c:2906]: sr_kemi_pv_sets(): pv set: $du
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/pvapi.c:371]: pv_cache_add(): pvar [$du] added in cache
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[0] for: dbg is str: EP: ksr_r
oute_relay exit
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/kemi.c:85]: sr_kemi_core_dbg(): EP: ksr_route_relay exit
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:1837]: sr_kemi_lua_exit(): script exit call
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_api.c:729]: app_lua_run_ex(): ksr error call from Lua: ~~ksr~exit~~
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: app_lua [app_lua_mod.c:167]: sr_kemi_config_engine_lua(): execution of route type 1 with no n
ame returned 1
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) INFO: LUA {INVITE}: <core> [core/receive.c:515]: receive_msg(): request-route executed in: 1335 usec
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/usr_avp.c:637]: destroy_avp_list(): destroying list (nil)
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/xavp.c:541]: xavp_destroy_list(): destroying xavp list (nil)
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: LUA {INVITE}: <core> [core/receive.c:606]: receive_msg(): cleaning up
Oct 17 23:42:48 ol-vm1 kamailio[2416]: 3(2419) DEBUG: <core> [core/udp_server.c:493]: udp_rcv_loop(): received on udp socket: (112/100/661) [[INVITE sip:service@
192.168.1.15:5060 SIP/2.0 0D  0A Record-Route: <sip:192.168.1.15;lr=on> 0D  0A Via: SIP/2.0/U]]

Any idea how we can route this message?

Thanks!