mirror of https://github.com/sipwise/kamailio.git
A recent Kamailio version update has added an extra field to the end of
the gw list returned by load_gws() (the rule ID), which throws off
lcr_rate() as it looks at the last field in each gw string. Reverse the
approach to instead count the number of fields from the start of the
string to allow possible future extension of the field list.
Change-Id: I143e738553cec57047b19d94b6effa59788c1dc9
(cherry picked from commit c896cdd82b)
changes/09/35609/1
parent
8ee8b6fc90
commit
d4e9adf126
@ -0,0 +1,57 @@
|
||||
--- a/src/modules/lcr_rate/lcr_rate_mod.c
|
||||
+++ b/src/modules/lcr_rate/lcr_rate_mod.c
|
||||
@@ -153,7 +153,7 @@
|
||||
struct usr_avp *avp;
|
||||
int_str val;
|
||||
struct peer *ret, *j;
|
||||
- int len, i;
|
||||
+ int len, i, k;
|
||||
char *c;
|
||||
str s;
|
||||
swr_rate_t rate;
|
||||
@@ -198,15 +198,39 @@
|
||||
return NULL;
|
||||
}
|
||||
memcpy(j->s.s, val.s.s, val.s.len);
|
||||
- c = memrchr(j->s.s, '|', val.s.len);
|
||||
- if (!c) {
|
||||
- LM_ERR("separator not found in string <%.*s>\n", val.s.len, j->s.s);
|
||||
- goto next;
|
||||
+
|
||||
+ /* lcr gw fields:
|
||||
+ * 0: gw index
|
||||
+ * 1: scheme
|
||||
+ * 2: strip
|
||||
+ * 3: prefix
|
||||
+ * 4: tag
|
||||
+ * 5: ip adr
|
||||
+ * 6: hostname
|
||||
+ * 7: port
|
||||
+ * 8: params
|
||||
+ * 9: transport
|
||||
+ * 10: flags
|
||||
+ * 11: rule id
|
||||
+ */
|
||||
+ c = j->s.s;
|
||||
+ for (k = 0; k < 10; k++) {
|
||||
+ c = memchr(c, '|', val.s.len - (c - j->s.s));
|
||||
+ if (!c) {
|
||||
+ LM_ERR("separator not found in string <%.*s> (field #%i)\n",
|
||||
+ val.s.len, j->s.s, k);
|
||||
+ goto next;
|
||||
+ }
|
||||
+ c++;
|
||||
}
|
||||
|
||||
- c++;
|
||||
s.s = c;
|
||||
- s.len = val.s.len - (c - j->s.s);
|
||||
+
|
||||
+ /* find terminator */
|
||||
+ c = memchr(c, '|', val.s.len - (c - j->s.s));
|
||||
+ if (!c)
|
||||
+ c = j->s.s + val.s.len;
|
||||
+ s.len = c - s.s;
|
||||
if (str2int(&s, &j->id)) {
|
||||
LM_ERR("could not convert string <%.*s> to int\n", s.len, s.s);
|
||||
goto next;
|
||||
Loading…
Reference in new issue