[SR-Users] Fwd: Catching Register 200 OK, then using it to validate other packets.

Richard Edmands thesirdmz at gmail.com
Tue Jan 4 09:18:02 CET 2022

Hey Thanks for that one Alex,

If only I hadn't stopped reading at "will send 200 OK"...

I've been doing some more poking at this one, I was having issues with
it so I simplified it down to the basics with both of these code
blocks next to each other.

I can see the contact appear in kamcmd ul.dump as well as the [MAIN]
REGISTERRESPONSE in the log file. The log file also creates the lines
for all three case statements and the phone gets the 404 not

Not sure why it's not matching in this simplified configuration as the
steps are right after eachother the contact fields should be lining up
without issue.

I've also been playing with these modparams in case they were related,
but I haven't found the right combo if they are the issue.
modparam("registrar", "method_filtering", 0)
modparam("registrar", "gruu_enabled", 0)
#modparam("usrloc", "nat_bflag", 0)
modparam("usrloc", "matching_mode", 0)

# LetsCaptureAnyRegister...
	if (src_ip!=PBXIP) {
		if (is_method("REGISTER")) {
			save("location", "0x02");

# Then lets verify it...
	if ($src_ip!="PBXIP") {
		if (!is_method("REGISTER")) {
			if(!lookup("location")) {    #Try looking up location

			switch($rc) {
			case -1:
		 		xlog("L_INFO", "[MAIN] case -1\n");
			case -2:
		 		xlog("L_INFO", "[MAIN] case -2\n");
			case -3:
		 		xlog("L_INFO", "[MAIN] case -3\n");


                        	sl_reply("404", "User not Registered");
#If looking up location fails reply with 404
  #And exit
            		} else {

I had email digest emailed... I'm guessing this response isn't going
to align correctly on the maillist.

*Alex Balashov*
    abalashov at evaristesys.com
   *Tue Jan  4 06:55:52 CET 2022*

Hi Richard,

If I’ve understood your query correctly, flag 0x02 to save() should
accomplish what you want:

— Alex

---------- Forwarded message ---------
From: Richard Edmands <thesirdmz at gmail.com>
Date: Tue, 4 Jan 2022 at 15:53
Subject: Catching Register 200 OK, then using it to validate other packets.
To: <sr-users at lists.kamailio.org>

Hey Kamailio Users,

I've written a TLS-UDP gateway. It works well, but I want to reduce the
internet noise it pushes through.

I have an idea on what I'd like to try. Wondering if it would be possible
to catch the Register 200 OK, store it and then when receiving packets it
future to then validate them against the data?
I've managed to capture a 200 OK, but the save("location") function says it
will return it's own 200 OK which isn't the plan since we just want to
capture the location.

Anyone done something similar and got some working example code? Is this a
bad idea for some reason?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220104/bc37d985/attachment.htm>

More information about the sr-users mailing list