Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registrar: adding tcpconn_id to xavp_cfg #3430

Merged
merged 2 commits into from May 9, 2023

Conversation

jchavanton
Copy link
Member

@jchavanton jchavanton commented Apr 28, 2023

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • No commits to README files for modules (changes must be done to docbook files
    in doc/ subfolder, the README file is autogenerated)

Type Of Change

  • New feature (non-breaking change which adds new functionality)

Checklist:

  • Tested changes locally

Description

This is adding the variable tcpconn_id to xavp_cfg

When using Kamailio as a "mid registrar", we need to save the contact in the reply-route (once we have the confirmation from the registrar), one problem I faced was that the tcpconid was the one of the response message coming from the registrar.
I needed a way to save the one of the original request message.

mid registrar config example where we need/use the tcpconnid

modparam("registrar", "xavp_cfg", "reg")

route[REGISTER] {
    ...
    t_on_reply("ON_REPLY_REGISTER");
    $xavp(reg=>tcpconn_id) = $conid; // set the TCP connection id to be saved on the reply
   ....
}

onreply_route[ON_REPLY_REGISTER] {
        if (t_check_status("200")) {
                if (is_present_hf("Expires") && $hdr(Expires) == "0") {
                        xinfo("[ON_REPLY_REGISTER][$rm][$ci] registrar remove[$var(ret)]\n");
                        $var(ret) = unregister("location", "$tu");
                } else {
                        xinfo("[ON_REPLY_REGISTER][$rm][$ci] registrar save[$var(ret)]\n");
                        $var(ret) = save("location", "0x02");
                }
        }
}

route[INVITE] {
    ...
    if(reg_fetch_contacts("location", "$ru", "caller"))  {
         if(!tcp_conid_alive("$var(conid)")) {
                 xinfo("[RELAY][$ci] using tcp connection inactive [$var(conid)] suspend/push\n");
                 route(PUSH_SUSPEND);
         } else {
                  xinfo("[RELAY][$ci] using tcp connection [$var(conid)]\n");
         }
     }
     ...
}

@jchavanton jchavanton force-pushed the jchavanton/registrar_tcpconnid branch 2 times, most recently from 016059f to f7e618e Compare April 28, 2023 18:49
@jchavanton jchavanton force-pushed the jchavanton/registrar_tcpconnid branch from f7e618e to 4b70bd8 Compare May 1, 2023 15:34
Co-authored-by: Bastian Triller <bastian.triller@gmail.com>
@miconda
Copy link
Member

miconda commented May 9, 2023

Thanks!

@miconda miconda merged commit 439a1c7 into master May 9, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants