ServanVcare created an issue (kamailio/kamailio#4415)
### Description
In Kamailio 6.0.3, we enabled the topos and topos_htable modules. We initiate a
call from an Asterisk and then send a SIP notify with the talk event header. If
topos is enabled, all messages are properly forwarded to the phone, except for
the SIP notify with the talk event header. If we pick up the call via the phone
and then send a SIP notify with the hold event header, it is properly forwarded
to the phone and the phone set the call on hold.
If we only use the topos module via SQL, the SIP notify with the Talk event
header is properly forwarded to the device.
### Troubleshooting
#### Reproduction
Use the topos_htable and send a SIP notify with event header Talk to the phone.
We used the following module parameters for topos and topos_htable:
```
modparam("topos", "storage", "htable")
modparam("topos", "branch_expire", 180)
modparam("topos", "dialog_expire", 10800)
modparam("topos", "clean_interval", 3600)
modparam("topos", "sanity_checks", 0)
modparam("topos", "contact_host", "<ip-adres>")
modparam("topos", "rr_update", 1)
modparam("topos", "contact_mode", 1)
#### SIP Traffic
PCAP of this happening:
[sip_notify_examples.zip](https://github.com/user-attachments/files/22680836/sip_notify_examples.zip)
### Possible Solutions
Yes, we have modified topos_htable_storage.c with the following function
modified in the code:
```
// we change the arguments in the functions
// static int tps_htable_load_initial_method_branch(tps_data_t *md, tps_data_t
*sd)
static int tps_htable_load_initial_method_branch(sip_msg_t* msg, tps_data_t
*md, tps_data_t *sd)
{
str hkey;
ht_cell_t *hval;
char *ptr;
int ret = 0;
int i = 0;
str xuuid = str_init("");
str xtag = str_init("");
str smethod = str_init("INVITE");
// checks
if(md == NULL || sd == NULL) {
LM_DBG("NULL pointers");
return -1;
}
if(md->a_callid.len <= 0 || md->b_tag.len <= 0) {
LM_DBG("no call-id or to-tag for this message\n");
return -1;
}
LM_DBG("HERE\n");
// build key
if(md->direction == TPS_DIR_DOWNSTREAM) {
if(md->b_tag.s != NULL) {
xtag.s = md->b_tag.s;
xtag.len = md->b_tag.len;
}
} else {
if(md->a_tag.s != NULL) {
xtag.s = md->a_tag.s;
xtag.len = md->a_tag.len;
}
}
if(md->a_uuid.len > 1) {
xuuid.s = md->a_uuid.s + 1;
xuuid.len = md->a_uuid.len - 1;
} else if(md->b_uuid.len > 1) {
xuuid.s = md->b_uuid.s + 1;
xuuid.len = md->b_uuid.len - 1;
} else if(sd->a_uuid.len > 1) {
xuuid.s = sd->a_uuid.s + 1;
xuuid.len = sd->a_uuid.len - 1;
} else if(sd->b_uuid.len > 1) {
xuuid.s = sd->b_uuid.s + 1;
xuuid.len = sd->b_uuid.len - 1;
}
// The next 4 lines we set in comments
// if(md->s_method_id & (METHOD_SUBSCRIBE | METHOD_NOTIFY)) {
// smethod.s = "SUBSCRIBE";
// smethod.len = 9;
// }
// The next if-statement is the workaround
if(md->s_method_id == METHOD_SUBSCRIBE) {
smethod.s = "SUBSCRIBE";
smethod.len = 9;
} else if(md->s_method_id == METHOD_NOTIFY) {
hdr_field_t *event_hdr = msg->event;
int is_talk_event = 0;
// Check if the direct pointer to the Event header exists
if (event_hdr) {
str body = event_hdr->body;
// Trim leading whitespace from the header body
while(body.len > 0 && (*body.s == ' ' || *body.s == '\t')) {
body.s++;
body.len--;
}
// Check if the event type is "talk"
if (body.len >= 4 && strncasecmp(body.s, "talk", 4) == 0) {
is_talk_event = 1;
}
}
if (!is_talk_event) {
smethod.s = "SUBSCRIBE";
smethod.len = 9;
}
// If it IS a talk event, smethod remains the default "INVITE".
}
ptr = _tps_htable_key_buf;
// base64 encode key values
if(_tps_base64) {
base64url_enc(md->s_method.s, md->s_method.len,
_tps_base64_buf[0],
TPS_BASE64_SIZE - 1);
base64url_enc(md->a_callid.s, md->a_callid.len,
_tps_base64_buf[1],
TPS_BASE64_SIZE - 1);
base64url_enc(
xtag.s, xtag.len, _tps_base64_buf[2],
TPS_BASE64_SIZE - 1);
base64url_enc(
xuuid.s, xuuid.len, _tps_base64_buf[3],
TPS_BASE64_SIZE - 1);
ret = snprintf(ptr, TPS_HTABLE_SIZE_KEY, "%s|%s|%s|x%s",
_tps_base64_buf[0], _tps_base64_buf[1],
_tps_base64_buf[2],
_tps_base64_buf[3]);
} else {
ret = snprintf(ptr, TPS_HTABLE_SIZE_KEY, "%.*s|%.*s|%.*s|x%.*s",
smethod.len, smethod.s, md->a_callid.len,
md->a_callid.s,
xtag.len, xtag.s, xuuid.len, xuuid.s);
}
if(ret < 0 || ret >= TPS_HTABLE_SIZE_KEY) {
LM_ERR("failed to build htable key\n");
return -1;
}
hkey.s = _tps_htable_key_buf;
hkey.len = strlen(_tps_htable_key_buf);
memset(sd, 0, sizeof(tps_data_t));
sd->cp = sd->cbuf;
// load hval from transaction htable module
hval = _tps_htable_api.get_clone(&_tps_htable_transaction, &hkey);
if(hval != NULL) {
LM_DBG("hval = %.*s\n", hval->value.s.len, hval->value.s.s);
i = 0;
while((ptr = strsep(&hval->value.s.s, "|")) != NULL) {
// base64 decode val values
if(_tps_base64 && strlen(ptr) > 0 && i != 0 && i < 2) {
base64url_dec(ptr, strlen(ptr),
_tps_base64_buf[0],
TPS_BASE64_SIZE - 1);
ptr = _tps_base64_buf[0];
}
if(i == 0) {
// skip rectime, not needed
;
} else if(i == 1) {
TPS_HTABLE_DATA_APPEND(sd, &hkey, ptr,
&sd->x_vbranch1);
} else {
// skip, not needed
;
}
i++;
}
LM_DBG("AFTER LOAD initial method branch %.*s",
sd->x_vbranch1.len,
sd->x_vbranch1.s);
pkg_free(hval);
} else {
LM_DBG("no initial branch found with key %.*s\n", hkey.len,
hkey.s);
return 1;
}
return 0;
}
```
### Additional Information
```
version: kamailio 6.0.3 (x86_64/linux) 97fda2
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE,
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, 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_SEND_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: 97fda2
compiled on 11:57:14 Sep 30 2025 with gcc 11.4.0
```
* **Operating System**:
```
Linux VC-POC-VCARE.vtel.local 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9
00:02:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4415
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/[email protected]>_______________________________________________
Kamailio - Development Mailing List -- [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!