Skip to content

Instantly share code, notes, and snippets.

@whosgonna
Last active November 23, 2021 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whosgonna/bd6086e9193bc65abafa3d6ba057e9e7 to your computer and use it in GitHub Desktop.
Save whosgonna/bd6086e9193bc65abafa3d6ba057e9e7 to your computer and use it in GitHub Desktop.
#!KAMAILIO
## The following example will result in each subsequent transaction having it's rURI ADDED to the
## contact header, causing it to grow. For example, this would be the contact header of the third
## reply to this message:
## Contact: <sip:+16127359309@127.0.0.1:5050>, <sip:+16127359309@127.0.0.1:5050>, <sip:+16127359309@127.0.0.1:5050>
## Tested against Kamilio version:
## version: kamailio 5.5.2 (x86_64/linux)
## flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK,
## SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT,
## USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
## ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
## poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
## id: unknown
## compiled on 23:35:51 Nov 2 2021 with gcc 10.3.1
loadmodule "corex"
loadmodule "tm"
loadmodule "sl"
loadmodule "xlog"
loadmodule "pv"
loadmodule "ctl"
loadmodule "textops"
loadmodule "tmx"
loadmodule "siputils"
loadmodule "http_async_client"
loadmodule "jansson"
loadmodule "uuid"
loadmodule "cfgutils"
!!defenv CNAM_URL
#modparam("http_async_client", "curl_verbose", 1)
force_rport = yes
# ------------------------- request routing logic -------------------
route {
xlogl( "L_INFO", "[rt route][$ci] Request Received [$rm] [$ru]\n" );
if ( is_method("INVITE") ) {
t_newtran();
http_async_query( CNAM_URL , "HTTP_REPLY" );
exit;
}
## Just to handle ACK for this simple example:
t_check_trans();
}
route[HTTP_REPLY] {
append_branch();
## Possible solution: Remove the append_branch() above, and comment out below:
# $ru = $ru;
send_reply( "380", "CNAM Response" );
drop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment