I have a requirement to only accept requests from UAs that are currently registered. And the ip:port from the request must be the same that was used in the registration (received_avp).
So I have written a function registered_from (based on function registered) that will receive parameters location, AOR and URI-received (all required), and will return true if:
- string received="scheme:ip:port" is found inside ucontact->path
or
- ucontact->received equals URI-received
Examples of use:
$var(received) = "sip:" + $si + ":" + $sp;
if(!registered_from("location", "$fu", "$var(received)")) {
sl_send_reply("404", "Request not from registered UA");
exit;
}
if(!registered_from("location", "$fu", "$hdr(User-Received)")) {
sl_send_reply("404", "Request not from registered UA");
exit;
}
I have generated the patch from branch 1.6 which is the one I am currently using but I can regenerate it from trunk if necessary
regards,
Takeshi
Diff generated from http://opensips.svn.sourceforge.net/svnroot/opensips/branches/1.6