Module: kamailio
Branch: master
Commit: 06d583e356351ae9d8a559c9f5de3e57fb128a38
URL: https://github.com/kamailio/kamailio/commit/06d583e356351ae9d8a559c9f5de3e5…
Author: Xenofon Karamanos <22965395+xkaraman(a)users.noreply.github.com>
Committer: Xenofon Karamanos <22965395+xkaraman(a)users.noreply.github.com>
Date: 2024-06-04T12:41:58+03:00
core/resolve: Check dns_cache_init and choose appropriate functions
---
Modified: src/core/resolve.c
Modified: src/core/resolve.h
---
Diff: https://github.com/kamailio/kamailio/commit/06d583e356351ae9d8a559c9f5de3e5…
Patch: https://github.com/kamailio/kamailio/commit/06d583e356351ae9d8a559c9f5de3e5…
---
diff --git a/src/core/resolve.c b/src/core/resolve.c
index 6d581f4915f..da247952fd9 100644
--- a/src/core/resolve.c
+++ b/src/core/resolve.c
@@ -1623,7 +1623,11 @@ struct hostent *no_naptr_srv_sip_resolvehost(
srv_name.s = tmp_srv;
srv_name.len = strlen(tmp_srv);
#ifdef USE_DNS_CACHE
- he = dns_srv_get_he(&srv_name, port, dns_flags);
+ if(dns_cache_init) {
+ he = dns_srv_get_he(&srv_name, port, dns_flags);
+ } else {
+ he = srv_sip_resolvehost(&srv_name, 0, port, proto, 1, 0);
+ }
#else
he = srv_sip_resolvehost(&srv_name, 0, port, proto, 1, 0);
#endif
@@ -1660,6 +1664,7 @@ struct hostent *naptr_sip_resolvehost(
struct rdata *naptr_head;
char n_proto;
str srv_name;
+ str *name_copy = 0;
naptr_bmp_t tried_bmp; /* tried bitmap */
char origproto = PROTO_NONE;
@@ -1704,7 +1709,15 @@ struct hostent *naptr_sip_resolvehost(
he = no_naptr_srv_sip_resolvehost(name, port, proto);
/* fallback all the way down to A/AAAA */
if(he == 0) {
- he = dns_get_he(name, dns_flags);
+ if(dns_cache_init) {
+ he = dns_get_he(name, dns_flags);
+ } else {
+ /* We need a zero terminated char* */
+ name_copy = shm_malloc(name->len + 1);
+ shm_str_dup(name_copy, name);
+ he = resolvehost(name_copy->s);
+ shm_free(name_copy);
+ }
}
end:
if(naptr_head)
@@ -1833,6 +1846,45 @@ ip_addr_t *str2ip(str *st)
return ipb;
}
+/*
+* Resolve a host name to a hostent.
+* @param[in] name: the host name to resolve
+* @return the hostent structure or NULL on error
+*
+* @note
+* This function is a wrapper to choose between the DNS cache and the
+* system resolver. If the DNS cache is enabled, it will use the DNS cache
+* to resolve the host name. Otherwise, it will use the system resolver.
+*/
+struct hostent *__resolvehost(char *name)
+{
+ if(dns_cache_init) {
+ return dns_resolvehost(name);
+ } else {
+ return _resolvehost(name);
+ }
+}
+
+/*
+* Resolve a host name to a hostent.
+* @param[in] name: the host name to resolve
+* @param[in] port: the port number
+* @param[in] proto: the protocol
+* @return the hostent structure or NULL on error
+*
+* @note
+* This function is a wrapper to choose between the DNS cache and the
+* system resolver. If the DNS cache is enabled, it will use the DNS cache
+* to resolve the host name. Otherwise, it will use the system resolver.
+*/
+struct hostent *__sip_resolvehost(str *name, unsigned short *port, char *proto)
+{
+ if(dns_cache_init) {
+ return dns_sip_resolvehost(name, port, proto);
+ } else {
+ return _sip_resolvehost(name, port, proto);
+ }
+}
/* converts a str to an ipv6 address struct stored in ipb
* - ipb must be already allocated
* - return 0 on success; <0 on failure */
diff --git a/src/core/resolve.h b/src/core/resolve.h
index c39d90c2104..0e66a7b4ae0 100644
--- a/src/core/resolve.h
+++ b/src/core/resolve.h
@@ -329,14 +329,14 @@ int sip_hostport2su(
union sockaddr_union *su, str *host, unsigned short port, char *proto);
+/* Wrapper functions that check for dns_cache_init */
+struct hostent *__resolvehost(char *name);
+struct hostent *__sip_resolvehost(str *name, unsigned short *port, char *proto);
+
+
/* wrappers */
-#ifdef USE_DNS_CACHE
-#define resolvehost dns_resolvehost
-#define sip_resolvehost dns_sip_resolvehost
-#else
-#define resolvehost _resolvehost
-#define sip_resolvehost _sip_resolvehost
-#endif
+#define resolvehost __resolvehost
+#define sip_resolvehost __sip_resolvehost
#ifdef USE_NAPTR
@Sergey-safarov
Both EL distros 8.10 and 9.4 have been released with Python 3.12.
Can you consider updating bumping the Python version to 3.12 for the
upcoming 5.8.2 release.
Thank you.
Richard Chan
### Description
When configured `read_sdp_pv` param for rtpengine module, then multipart content dropped in the body.
And the message cannot be parsed because
```
Content-Type: multipart/mixed;boundary=level3-boundary
```
But the message body does not have a separator.
### Troubleshooting
#### Reproduction
To reproduce need to start Kamailio with config file
```
loadmodule "pv.so"
loadmodule "ctl.so"
loadmodule "corex.so"
loadmodule "sdpops.so"
loadmodule "rtpengine.so"
modparam("rtpengine", "rtpengine_sock", "udp:localhost:2223")
modparam("rtpengine", "read_sdp_pv", "$var(sdp_for_rtpengine)")
listen=udp:x.x.x.x:5060
request_route {
$var(sdp_for_rtpengine) = $sdp(body);
rtpengine_manage("ICE=force");
forward();
}
```
And then send call using `sipp` script
```xml
<scenario name="Basic Sipstone UAC">
<!-- In client mode (sipp placing calls), the Call-ID MUST be -->
<!-- generated by sipp. To do so, use [call_id] keyword. -->
<send retrans="500">
<![CDATA[
INVITE sip:[service]@example.com:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
To: sut <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:sipp@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Type: multipart/mixed;boundary=level3-boundary
Content-Length: [len]
--level3-boundary
Content-Type: application/sdp
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
--level3-boundary
Content-Type: application/isup;version=ansi
Content-Disposition: session;handling=optional
\x01\x18\x08\x10\x0a\x03\x06\x0d\x03\x80\x90\xa2\x07\x03\x10\x87\x36\x08\x14\x89
\x0a\x07\x03\x13\x27\x97\x45\x28\x49\xc0\x08\xc0\x03\x10\x65\x41\x17\x88\x67\x3d
\x01\x11\xc4\x03\x01\x01\x00\xea\x01\x01\xc7\x01\x20\x01\x0d\x0a
--level3-boundary--
]]>
</send>
```
If the `read_sdp_pv` param will be commented in the Kamailio config file, then the resulting message will be properly formatted and have the other multipart media.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3854
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3854(a)github.com>
#### Pre-Submission Checklist
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] 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
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
Add support for setting a different RPC reload interval than the reg_gc_interval parameter.
This allows the cleanup timer to match the user's re-transmission timeout without constraining RPC reload times to a large interval.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3829
-- Commit Summary --
* uac: add reload_delta parameter
-- File Changes --
M src/modules/uac/doc/uac.xml (9)
M src/modules/uac/doc/uac_admin.xml (37)
M src/modules/uac/uac.c (5)
M src/modules/uac/uac_reg.c (5)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3829.patchhttps://github.com/kamailio/kamailio/pull/3829.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3829
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3829(a)github.com>
### Description
We send HEP3 data to the UDP listener in kamailio. In this HEP3 data, there are SIP requests and replies. We want to route these SIP messages through `request_route` and `onreply_route`. For this, we use the SipCapture module with the following settings:
```
modparam("sipcapture", "db_url", DBURL)
modparam("sipcapture", "capture_on", 1)
modparam("sipcapture", "hep_capture_on", 1)
modparam("sipcapture", "insert_retries", 0)
modparam("sipcapture", "insert_retry_timeout", 0)
request_route {
xlog("L_INFO", "Got new request ($ci) $rm: $si => $Ri\n");
}
onreply_route {
xlog("L_INFO", "Got new reply ($ci) $rm: $si => $Ri - Reply Code $rs\n");
}
```
In the past (version kamailio 5.1.x - 5.4.x), this worked as expected. From the logs:
```
2(8) INFO: <script>: Got new request (7xkVDrAWegvcZl-ACaUb1HWHwiCYhAJR) INVITE: 217.116.121.230 => 172.20.21.4
3(9) INFO: <script>: Got new reply (7xkVDrAWegvcZl-ACaUb1HWHwiCYhAJR) INVITE: 172.20.21.4 => 217.116.121.230 - Reply Code 407
```
Starting with kamailio 5.5.x, some pseudo variables are broken. From the logs:
```
1(7) INFO: <script>: Got new request (7xkVDrAWegvcZl-ACaUb1HWHwiCYhAJR) INVITE: 217.116.121.230 => 217.116.121
2(8) INFO: <script>: Got new reply (7xkVDrAWegvcZl-ACaUb1HWHwiCYhAJR) INVITE: 172.20.21.4 => 172.20.21.4 3(9) INFO: <script>: ...
```
As you can see, the `$Ri` in the request is wrong. It looks like the first three octets of the `$si` and the fourth octet is missing entirely.
And for the reply:
- The `$Ri` is the `$si`.
- The line is missing the static text `Reply Code`, the actual reply code.
- The next log is on the same line (the new line is gone). (In this case, we simply sent a third HEP3 message.)
To my untrained eye this looks like possible memory corruption.
### Troubleshooting
#### Reproduction
1. Set up a kamailio 5.8.1 using the attached [kamailio.cfg](https://github.com/kamailio/kamailio/files/15161868/kamailio.…
`/usr/sbin/kamailio -E -DD -dd -f "/etc/kamailio/kamailio.cfg"`
2. Send the HEP3 data using [heplify](https://github.com/sipcapture/heplify)
`./heplify -t pcap -rf "sipcapture-bug.pcap" -hs localhost:9060 -e -eof-exit`
#### Debugging Data
#### Log Messages
see above
#### SIP Traffic
see attached [sipcapture-bug.pcap](https://github.com/kamailio/kamailio/files/15161698/si…
### Possible Solutions
Use kamailio 5.4.x or earlier versions.
### Additional Information
When setting `nonsip_hook` = `1`, then the `$hep(...)` pseudo variables look fine. Unfortunately, we don't know how process the SIP messages after that point.
```
modparam("sipcapture", "nonsip_hook", 1)
...
event_route[sipcapture:request] {
xlog("L_INFO", "version: $hep(version)\n");
xlog("L_INFO", "src_ipv4: $hep(0x003)\n");
xlog("L_INFO", "dst_ipv4: $hep(0x004)\n");
xlog("L_INFO", "src_proto: $hep(0x007)\n");
xlog("L_INFO", "dst_proto: $hep(0x008)\n");
xlog("L_INFO", "proto: $hep(0x00b)\n");
}
```
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.8.1 (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, 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:
compiled with gcc 12.2.0
```
Also tested with same error: 5.5.x, 5.6.x, 5.7.x
* **Operating System**:
```
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3835
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3835(a)github.com>