mirror of https://github.com/sipwise/kamailio.git
parent
18ac7389ac
commit
69fe3498fc
@ -1,112 +0,0 @@
|
|||||||
From: Dmitry Wagin <dmitry.wagin@ya.ru>
|
|
||||||
Date: Tue, 15 Jun 2021 15:58:12 +0300
|
|
||||||
Subject: nathelper: fix_nated_sdp added ignoring RFC3605-param if omitted
|
|
||||||
|
|
||||||
- doesn't throw an error while "a=rtcp" param is omitted (RFC1889 behavior) or address is omitted
|
|
||||||
- replace_sdp_ip() returns 0 on omitted IP-address
|
|
||||||
- added param can_omit to replace_sdp_ip()
|
|
||||||
---
|
|
||||||
src/modules/nathelper/nathelper.c | 37 ++++++++++++++++++-------------------
|
|
||||||
1 file changed, 18 insertions(+), 19 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/nathelper/nathelper.c b/src/modules/nathelper/nathelper.c
|
|
||||||
index 1392a0a..9e45a61 100644
|
|
||||||
--- a/src/modules/nathelper/nathelper.c
|
|
||||||
+++ b/src/modules/nathelper/nathelper.c
|
|
||||||
@@ -1609,13 +1609,12 @@ static int is_rfc1918_f(struct sip_msg *msg, char *str1, char *str2)
|
|
||||||
#define AOLDMEDPRT_LEN (sizeof(AOLDMEDPRT) - 1)
|
|
||||||
|
|
||||||
|
|
||||||
-/* replace ip addresses in SDP and return umber of replacements */
|
|
||||||
+/* replace ip addresses in SDP and return number of replacements */
|
|
||||||
static inline int replace_sdp_ip(
|
|
||||||
- struct sip_msg *msg, str *org_body, char *line, str *ip, int linelen)
|
|
||||||
+ struct sip_msg *msg, str *org_body, char *line, str *ip, int linelen, int can_omit)
|
|
||||||
{
|
|
||||||
str body1, oldip, newip;
|
|
||||||
str body = *org_body;
|
|
||||||
- unsigned hasreplaced = 0;
|
|
||||||
int pf, pf1 = 0;
|
|
||||||
str body2;
|
|
||||||
char *bodylimit = body.s + body.len;
|
|
||||||
@@ -1631,10 +1630,17 @@ static inline int replace_sdp_ip(
|
|
||||||
}
|
|
||||||
body1 = body;
|
|
||||||
for(;;) {
|
|
||||||
- if(nh_extract_mediaip(&body1, &oldip, &pf, line, linelen) == -1)
|
|
||||||
+ ret = nh_extract_mediaip(&body1, &oldip, &pf, line, linelen);
|
|
||||||
+ if(ret == 0)
|
|
||||||
break;
|
|
||||||
- if(pf != AF_INET) {
|
|
||||||
- LM_ERR("not an IPv4 address in '%s' SDP\n", line);
|
|
||||||
+ if(ret == -1) {
|
|
||||||
+ if(can_omit) {
|
|
||||||
+ body2.s = body1.s + linelen;
|
|
||||||
+ body2.len = bodylimit - body2.s;
|
|
||||||
+ body1 = body2;
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ LM_ERR("no `IP[4|6]' in `%s' field\n", line);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(!pf1)
|
|
||||||
@@ -1652,13 +1658,8 @@ static inline int replace_sdp_ip(
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
count += ret;
|
|
||||||
- hasreplaced = 1;
|
|
||||||
body1 = body2;
|
|
||||||
}
|
|
||||||
- if(!hasreplaced && linelen>=6 && memcmp("a=rtcp", line, 6)!=0) {
|
|
||||||
- LM_ERR("can't extract '%s' IP from the SDP\n", line);
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
@@ -1737,15 +1738,14 @@ static int ki_fix_nated_sdp_ip(sip_msg_t *msg, int level, str *ip)
|
|
||||||
if(level & (FIX_MEDIP | FIX_ORGIP)) {
|
|
||||||
|
|
||||||
/* Iterate all a=rtcp and replace ips in them. rfc3605 */
|
|
||||||
- ret = replace_sdp_ip(msg, &body, "a=rtcp", (ip && ip->len>0) ? ip : 0, 6);
|
|
||||||
+ ret = replace_sdp_ip(msg, &body, "a=rtcp", (ip && ip->len>0) ? ip : 0, 6, 1);
|
|
||||||
if(ret == -1)
|
|
||||||
- LM_DBG("a=rtcp parameter does not exist. nothing to do.\n");
|
|
||||||
- else
|
|
||||||
- count += ret;
|
|
||||||
+ return -1;
|
|
||||||
+ count += ret;
|
|
||||||
|
|
||||||
if(level & FIX_MEDIP) {
|
|
||||||
/* Iterate all c= and replace ips in them. */
|
|
||||||
- ret = replace_sdp_ip(msg, &body, "c=", (ip && ip->len>0) ? ip : 0, 2);
|
|
||||||
+ ret = replace_sdp_ip(msg, &body, "c=", (ip && ip->len>0) ? ip : 0, 2, 0);
|
|
||||||
if(ret == -1)
|
|
||||||
return -1;
|
|
||||||
count += ret;
|
|
||||||
@@ -1753,7 +1753,7 @@ static int ki_fix_nated_sdp_ip(sip_msg_t *msg, int level, str *ip)
|
|
||||||
|
|
||||||
if(level & FIX_ORGIP) {
|
|
||||||
/* Iterate all o= and replace ips in them. */
|
|
||||||
- ret = replace_sdp_ip(msg, &body, "o=", (ip && ip->len>0) ? ip : 0, 2);
|
|
||||||
+ ret = replace_sdp_ip(msg, &body, "o=", (ip && ip->len>0) ? ip : 0, 2, 0);
|
|
||||||
if(ret == -1)
|
|
||||||
return -1;
|
|
||||||
count += ret;
|
|
||||||
@@ -1800,7 +1800,7 @@ static int nh_extract_mediaip(str *body, str *mediaip, int *pf, char *line,
|
|
||||||
cp = cp1 + linelen;
|
|
||||||
}
|
|
||||||
if(cp1 == NULL)
|
|
||||||
- return -1;
|
|
||||||
+ return 0;
|
|
||||||
|
|
||||||
mediaip->s = cp1 + linelen;
|
|
||||||
mediaip->len =
|
|
||||||
@@ -1835,7 +1835,6 @@ static int nh_extract_mediaip(str *body, str *mediaip, int *pf, char *line,
|
|
||||||
cp = eat_space_end(cp + len, mediaip->s + mediaip->len);
|
|
||||||
}
|
|
||||||
if(nextisip != 2 || mediaip->len == 0) {
|
|
||||||
- LM_ERR("no `IP[4|6]' in `%s' field\n", line);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
@ -1,110 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Thu, 28 Oct 2021 15:54:39 +0200
|
|
||||||
Subject: pv_headers: don't try to replace header
|
|
||||||
|
|
||||||
Multiple headers where not removed if new value was just one header
|
|
||||||
---
|
|
||||||
src/modules/pv_headers/pvh_func.c | 6 ----
|
|
||||||
src/modules/pv_headers/pvh_hdr.c | 59 ---------------------------------------
|
|
||||||
src/modules/pv_headers/pvh_hdr.h | 1 -
|
|
||||||
3 files changed, 66 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_func.c b/src/modules/pv_headers/pvh_func.c
|
|
||||||
index 7afc39d..01a7d3d 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_func.c
|
|
||||||
+++ b/src/modules/pv_headers/pvh_func.c
|
|
||||||
@@ -276,12 +276,6 @@ int pvh_apply_headers(struct sip_msg *msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!str_hash_case_get(&rm_hdrs, sub->name.s, sub->name.len)) {
|
|
||||||
- if(!pvh_avp_is_null(sub) && xavi_count(&sub->name, &sub) == 1) {
|
|
||||||
- LM_DBG("replace header[%s]: %s\n", sub->name.s, sub->val.v.s.s);
|
|
||||||
- pvh_real_hdr_replace(msg, &sub->name, &sub->val.v.s);
|
|
||||||
- pvh_str_hash_add_key(&rm_hdrs, &sub->name);
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
LM_DBG("remove header[%s]: %s\n", sub->name.s, sub->val.v.s.s);
|
|
||||||
pvh_real_hdr_del_by_name(msg, &sub->name);
|
|
||||||
pvh_str_hash_add_key(&rm_hdrs, &sub->name);
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_hdr.c b/src/modules/pv_headers/pvh_hdr.c
|
|
||||||
index d83a646..fbb471c 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_hdr.c
|
|
||||||
+++ b/src/modules/pv_headers/pvh_hdr.c
|
|
||||||
@@ -131,65 +131,6 @@ int pvh_real_hdr_append(struct sip_msg *msg, str *hname, str *hvalue)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
-int pvh_real_hdr_replace(struct sip_msg *msg, str *hname, str *hvalue)
|
|
||||||
-{
|
|
||||||
- struct lump *anchor = NULL;
|
|
||||||
- hdr_field_t *hf = NULL;
|
|
||||||
- str new_h = STR_NULL;
|
|
||||||
- int new = 1;
|
|
||||||
-
|
|
||||||
- if(hname->s == NULL || hvalue->s == NULL) {
|
|
||||||
- LM_ERR("header name/value cannot be empty");
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- for(hf = msg->headers; hf; hf = hf->next) {
|
|
||||||
- if(hf->name.len == hname->len
|
|
||||||
- && strncasecmp(hf->name.s, hname->s, hname->len) == 0) {
|
|
||||||
- if(hf->body.len == hvalue->len
|
|
||||||
- && strncasecmp(hf->body.s, hvalue->s, hvalue->len) == 0) {
|
|
||||||
- return 1;
|
|
||||||
- }
|
|
||||||
- new = 0;
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- if(!hf->next)
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if(hf == NULL) {
|
|
||||||
- LM_ERR("unable to find header lump\n");
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if(new == 0) {
|
|
||||||
- if((anchor = del_lump(msg, hf->name.s - msg->buf, hf->len, 0)) == 0) {
|
|
||||||
- LM_ERR("unable to delete header lump\n");
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
- } else {
|
|
||||||
- anchor = anchor_lump(msg, hf->name.s + hf->len - msg->buf, 0, 0);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if(anchor == 0) {
|
|
||||||
- LM_ERR("unable to find header lump\n");
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if(pvh_create_hdr_str(hname, hvalue, &new_h) <= 0)
|
|
||||||
- return -1;
|
|
||||||
-
|
|
||||||
- if(insert_new_lump_after(anchor, new_h.s, new_h.len, 0) == 0) {
|
|
||||||
- LM_ERR("cannot insert header lump\n");
|
|
||||||
- pkg_free(new_h.s);
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- LM_DBG("%s header: %.*s\n", new ? "append" : "replace", new_h.len, new_h.s);
|
|
||||||
-
|
|
||||||
- return 1;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
int pvh_real_hdr_del_by_name(struct sip_msg *msg, str *hname)
|
|
||||||
{
|
|
||||||
hdr_field_t *hf = NULL;
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_hdr.h b/src/modules/pv_headers/pvh_hdr.h
|
|
||||||
index 4f86953..a5ad415 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_hdr.h
|
|
||||||
+++ b/src/modules/pv_headers/pvh_hdr.h
|
|
||||||
@@ -38,7 +38,6 @@ void pvh_hdrs_set_applied(struct sip_msg *msg);
|
|
||||||
void pvh_hdrs_reset_flags(struct sip_msg *msg);
|
|
||||||
|
|
||||||
int pvh_real_hdr_append(struct sip_msg *msg, str *hname, str *hvalue);
|
|
||||||
-int pvh_real_hdr_replace(struct sip_msg *msg, str *hname, str *hvalue);
|
|
||||||
int pvh_real_hdr_del_by_name(struct sip_msg *msg, str *hname);
|
|
||||||
int pvh_real_hdr_remove_display(struct sip_msg *msg, str *hname);
|
|
||||||
int pvh_real_replace_reply_reason(struct sip_msg *msg, str *value);
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Fri, 23 Jul 2021 15:56:11 +0200
|
|
||||||
Subject: pv_headers: fix removal of all values on when using PV_IDX_ALL
|
|
||||||
|
|
||||||
$(x_hdr(whatever)[*]) = "hello" was just removing the first value
|
|
||||||
|
|
||||||
Change-Id: Icc170673aef64e335ef82d940b6b85c940dbde55
|
|
||||||
|
|
||||||
Change-Id: I3614396eccbbf616b1c53f8511c2a7b42e8ef2df
|
|
||||||
---
|
|
||||||
src/modules/pv_headers/pvh_xavp.c | 4 ++--
|
|
||||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c
|
|
||||||
index 7cba757..96fdc29 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_xavp.c
|
|
||||||
+++ b/src/modules/pv_headers/pvh_xavp.c
|
|
||||||
@@ -618,7 +618,7 @@ int pvh_set_header(
|
|
||||||
|
|
||||||
if(val == NULL || (val->flags & PV_VAL_NULL)) {
|
|
||||||
if(idxf == PV_IDX_ALL) {
|
|
||||||
- cnt = xavi_rm_by_name(hname, 1, &xavi);
|
|
||||||
+ cnt = xavi_rm_by_name(hname, 1, &avi);
|
|
||||||
LM_DBG("removed %d values of %.*s=>%.*s, set $null\n", cnt,
|
|
||||||
xavi->name.len, xavi->name.s, hname->len, hname->s);
|
|
||||||
if(pvh_set_xavi(msg, &xavi_name, hname, NULL, SR_XTYPE_NULL, 0, 0)
|
|
||||||
@@ -649,7 +649,7 @@ int pvh_set_header(
|
|
||||||
goto err;
|
|
||||||
} else if(idxf == PV_IDX_ALL) {
|
|
||||||
if(hname_cnt > 1) {
|
|
||||||
- cnt = xavi_rm_by_name(hname, 1, &xavi);
|
|
||||||
+ cnt = xavi_rm_by_name(hname, 1, &avi);
|
|
||||||
LM_DBG("removed %d values of %.*s=>%.*s\n", cnt, xavi->name.len,
|
|
||||||
xavi->name.s, hname->len, hname->s);
|
|
||||||
}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
From af926514ac3e70dff51408baf326b29bce4eecfc Mon Sep 17 00:00:00 2001
|
|
||||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
|
||||||
Date: Tue, 27 Jul 2021 10:52:21 +0200
|
|
||||||
Subject: [PATCH] pv_headers: pvh_set_header, remove values to set null when
|
|
||||||
necessary
|
|
||||||
|
|
||||||
* fix pvh_set_xavi for SR_XTYPE_NULL
|
|
||||||
---
|
|
||||||
src/modules/pv_headers/pvh_xavp.c | 10 ++++++----
|
|
||||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c
|
|
||||||
index 96fdc292b0..b8e4f92e61 100644
|
|
||||||
--- a/src/modules/pv_headers/pvh_xavp.c
|
|
||||||
+++ b/src/modules/pv_headers/pvh_xavp.c
|
|
||||||
@@ -375,7 +375,7 @@ int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
|
||||||
LM_DBG("br_xname: %.*s name: %.*s append:%d\n", br_xname.len, br_xname.s,
|
|
||||||
name->len, name->s, append);
|
|
||||||
memset(&xval, 0, sizeof(sr_xval_t));
|
|
||||||
- if(data == NULL || SR_XTYPE_NULL) {
|
|
||||||
+ if(data == NULL || type == SR_XTYPE_NULL) {
|
|
||||||
xval.type = SR_XTYPE_NULL;
|
|
||||||
} else if(type == SR_XTYPE_STR) {
|
|
||||||
xval.type = SR_XTYPE_STR;
|
|
||||||
@@ -618,9 +618,11 @@ int pvh_set_header(
|
|
||||||
|
|
||||||
if(val == NULL || (val->flags & PV_VAL_NULL)) {
|
|
||||||
if(idxf == PV_IDX_ALL) {
|
|
||||||
- cnt = xavi_rm_by_name(hname, 1, &avi);
|
|
||||||
- LM_DBG("removed %d values of %.*s=>%.*s, set $null\n", cnt,
|
|
||||||
- xavi->name.len, xavi->name.s, hname->len, hname->s);
|
|
||||||
+ if(hname_cnt > 1) {
|
|
||||||
+ cnt = xavi_rm_by_name(hname, 1, &avi);
|
|
||||||
+ LM_DBG("removed %d values of %.*s=>%.*s, set $null\n", cnt,
|
|
||||||
+ xavi->name.len, xavi->name.s, hname->len, hname->s);
|
|
||||||
+ }
|
|
||||||
if(pvh_set_xavi(msg, &xavi_name, hname, NULL, SR_XTYPE_NULL, 0, 0)
|
|
||||||
< 0)
|
|
||||||
goto err;
|
|
||||||
--
|
|
||||||
2.20.1
|
|
||||||
|
|
||||||
Loading…
Reference in new issue