Replacing certain route blocks with KEMI scripts

Dries De Gendt via sr-users <[email protected]> Wed, 18 Mar 2026 14:20:25 -0000
Newsgroups gmane.comp.voip.ser
Message-ID <[email protected]>
Hi,

I was wondering if it is possible of keeping the request_route as native configuration, while replacing certain route blocks such as AUTH/REGISTRAR with python KEMI instead?

The idea is to implement RFC8898, which basically requires me to challenge for bearer token and validate it afterwards if returned by the client. For my convencience, I had defined the AUTH and REGISTRAR block in python KEMI, and was calling them as such:

request_route {
...

	$var(auth_route_ret) = python_exec("ksr_route_auth", "test\n");
	xlog("$var(debug_level)", "[KSR_AUTH] Return code Kamailio is $var(auth_route_ret)");
	if ($var(auth_route_ret) == -255) {
    exit;
	}

...
	$var(registrar_route_ret) = python_exec("ksr_route_registrar", "test\n");
	xlog("$var(debug_level)", "[KSR_REGISTRAR] REGISTRAR return code Kamailio is $var(registrar_route_ret)");
	if ($var(registrar_route_ret) == -255) {
    exit;
	}
...

}

While the register itself seems to work, it seems that other blocks seem to fail as they would likely expect KSR?

ERROR: {1 112367482 INVITE f0af27cd-9d75-123f-79a9-b4e9b8034b4e} <core> [core/kemi.c:3772]: sr_kemi_cbname_lookup_idx(): index 1 is out of range

Any idea if this would be possible, or should I determine wether to go native cfg or KEMI?

Best regards,
Dries
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!