[sr-dev] git:master:3e7ff1f3: app_python: support for more combinations of functions with 4 params

2018-06-22 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 3e7ff1f3613db1c5de559bbf259a621647a5424b
URL: 
https://github.com/kamailio/kamailio/commit/3e7ff1f3613db1c5de559bbf259a621647a5424b

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2018-06-22T13:30:09+02:00

app_python: support for more combinations of functions with 4 params

---

Modified: src/modules/app_python/apy_kemi.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3e7ff1f3613db1c5de559bbf259a621647a5424b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3e7ff1f3613db1c5de559bbf259a621647a5424b.patch

---

diff --git a/src/modules/app_python/apy_kemi.c 
b/src/modules/app_python/apy_kemi.c
index 6a1d62d932..7110912b92 100644
--- a/src/modules/app_python/apy_kemi.c
+++ b/src/modules/app_python/apy_kemi.c
@@ -583,14 +583,46 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject 
*args, int idx)
ret = ((sr_kemi_fmssnn_f)(ket->func))(lmsg,
&vps[0].s, &vps[1].s, vps[2].n, 
vps[3].n);
return sr_kemi_apy_return_int(ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_STR
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_INT
+   && ket->ptypes[3]==SR_KEMIP_INT) {
+   /* snnn */
+   ret = ((sr_kemi_fmsnnn_f)(ket->func))(lmsg,
+   &vps[0].s, vps[1].n, vps[2].n, 
vps[3].n);
+   return sr_kemi_apy_return_int(ket, ret);
} else if(ket->ptypes[0]==SR_KEMIP_INT
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_STR) {
-   /* ssnn */
+   /* nsss */
ret = ((sr_kemi_fmnsss_f)(ket->func))(lmsg,
vps[0].n, &vps[1].s, &vps[2].s, 
&vps[3].s);
return sr_kemi_apy_return_int(ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_INT
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_STR
+   && ket->ptypes[3]==SR_KEMIP_STR) {
+   /* nnss */
+   ret = ((sr_kemi_fmnnss_f)(ket->func))(lmsg,
+   vps[0].n, vps[1].n, &vps[2].s, 
&vps[3].s);
+   return sr_kemi_apy_return_int(ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_INT
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_INT
+   && ket->ptypes[3]==SR_KEMIP_STR) {
+   /* nnns */
+   ret = ((sr_kemi_fmnnns_f)(ket->func))(lmsg,
+   vps[0].n, vps[1].n, vps[2].n, 
&vps[3].s);
+   return sr_kemi_apy_return_int(ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_INT
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_INT
+   && ket->ptypes[3]==SR_KEMIP_INT) {
+   /*  */
+   ret = ((sr_kemi_fm_f)(ket->func))(lmsg,
+   vps[0].n, vps[1].n, vps[2].n, 
vps[3].n);
+   return sr_kemi_apy_return_int(ket, ret);
} else {
LM_ERR("invalid parameters for: %.*s\n",
fname.len, fname.s);


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:8ff9f0dc: app_lua: support for more combinations of functions with 4 params

2018-06-22 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 8ff9f0dc0c00e80ad3a9add41823ca3dc101b94e
URL: 
https://github.com/kamailio/kamailio/commit/8ff9f0dc0c00e80ad3a9add41823ca3dc101b94e

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2018-06-22T13:30:08+02:00

app_lua: support for more combinations of functions with 4 params

---

Modified: src/modules/app_lua/app_lua_sr.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/8ff9f0dc0c00e80ad3a9add41823ca3dc101b94e.diff
Patch: 
https://github.com/kamailio/kamailio/commit/8ff9f0dc0c00e80ad3a9add41823ca3dc101b94e.patch

---

diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index c98830da5c..a72e657279 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -1702,6 +1702,13 @@ int sr_kemi_lua_exec_func_ex(lua_State* L, sr_kemi_t 
*ket, int pdelta)
ret = 
((sr_kemi_fmssnn_f)(ket->func))(env_L->msg,
&vps[0].s, &vps[1].s, vps[2].n, 
vps[3].n);
return sr_kemi_lua_return_int(L, ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_STR
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_INT
+   && ket->ptypes[3]==SR_KEMIP_INT) {
+   ret = 
((sr_kemi_fmsnnn_f)(ket->func))(env_L->msg,
+   &vps[0].s, vps[1].n, vps[2].n, 
vps[3].n);
+   return sr_kemi_lua_return_int(L, ket, ret);
} else if(ket->ptypes[0]==SR_KEMIP_INT
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
@@ -1709,6 +1716,27 @@ int sr_kemi_lua_exec_func_ex(lua_State* L, sr_kemi_t 
*ket, int pdelta)
ret = 
((sr_kemi_fmnsss_f)(ket->func))(env_L->msg,
vps[0].n, &vps[1].s, &vps[2].s, 
&vps[3].s);
return sr_kemi_lua_return_int(L, ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_INT
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_STR
+   && ket->ptypes[3]==SR_KEMIP_STR) {
+   ret = 
((sr_kemi_fmnnss_f)(ket->func))(env_L->msg,
+   vps[0].n, vps[1].n, &vps[2].s, 
&vps[3].s);
+   return sr_kemi_lua_return_int(L, ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_INT
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_INT
+   && ket->ptypes[3]==SR_KEMIP_STR) {
+   ret = 
((sr_kemi_fmnnns_f)(ket->func))(env_L->msg,
+   vps[0].n, vps[1].n, vps[2].n, 
&vps[3].s);
+   return sr_kemi_lua_return_int(L, ket, ret);
+   } else if(ket->ptypes[0]==SR_KEMIP_INT
+   && ket->ptypes[1]==SR_KEMIP_INT
+   && ket->ptypes[2]==SR_KEMIP_INT
+   && ket->ptypes[3]==SR_KEMIP_INT) {
+   ret = 
((sr_kemi_fm_f)(ket->func))(env_L->msg,
+   vps[0].n, vps[1].n, vps[2].n, 
vps[3].n);
+   return sr_kemi_lua_return_int(L, ket, ret);
} else {
LM_ERR("invalid parameters for: %.*s\n",
fname->len, fname->s);


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] Append_to_reply does not work for XHTTP responses without body (#1548)

2018-06-22 Thread Daniel-Constantin Mierla
I just tried with master and 5.1 branches and all is ok.

```
event_route[xhttp:request] {
append_to_reply("X-Orig: $si:$sp\r\n");

xhttp_reply("200", "OK", "", "");
}
```

Then:

```
# curl -v http://192.168.188.25:5060
* Rebuilt URL to: http://192.168.188.25:5060/
*   Trying 192.168.188.25...
* TCP_NODELAY set
* Connected to 192.168.188.25 (192.168.188.25) port 5060 (#0)
> GET / HTTP/1.1
> Host: 192.168.188.25:5060
> User-Agent: curl/7.60.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Sia: SIP/2.0/TCP 192.168.188.25:5
< X-Orig: 192.168.188.25:5
< Server: kamailio (5.1.4 (x86_64/darwin))
< Content-Length: 0
<
* Connection #0 to host 192.168.188.25 left intact
```

So either is an older kamailio version or something specific for your settings.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1548#issuecomment-399389233___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] t_relay() sending packets from the wrong TCP socket (#1532)

2018-06-22 Thread Daniel-Constantin Mierla
Vadim Lebedev - you are chasing the wrong direction here. If you look at the 
docs, there is a global parameter tcp_reuse_port for this purpose, setting 
SO_REUSEPORT if available in the OS. However, the discussion here is in the 
context of a collision of ports as mentioned again by @Forty-Tw0  in the 
comment:

  * https://github.com/kamailio/kamailio/issues/1532#issuecomment-399254671

So to conclude:

  * kamailio is reusing the connection from REGISTER to send back traffic to 
the device, it is no other way if the device is behind a non-port forwarding 
NAT (e.g., symmetric NAT)
  * if it doesn't, then the pcap should help to see if the INVITE created some 
other connection or uses a different Contact address so the REGISTER connection 
is not matching anymore

The reason I closed here is because this seems like a specific use case issue 
that can be discussed on sr-users once we see pcaps, rather than an issue in 
the code. Based on conclusion there, we can chase futher the code or config 
options. We do not use issue tracker as a discussion forum to decide if it is a 
bug or not, the issue here have to be opened when it is clear a bug in the code 
(or a feature request).

@Forty-Tw0 - as suggested, let's discuss this use case scenario on sr-users 
mailing list. Again, there are many aspects that might not use a clear 
terminology, like `Device A receives a SIP message with a contact telling them 
to respond to Kamailio on 5062, which causes it to create a new TCP connection` 
-- what to respond on 5062? The SIP response or follow up requests? These are 
either Via or Record-Route or Contact headers ... so a lot to clarify and can 
be just config things that needs to be tuned, sr-users is the right place to 
discuss and get to a conclusion of how it can be fixed.



-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1532#issuecomment-399382420___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:13457759: modules: readme files regenerated - tm ... [skip ci]

2018-06-22 Thread Kamailio Dev
Module: kamailio
Branch: master
Commit: 134577590f1d3b18508119449198fb03d5c19b4f
URL: 
https://github.com/kamailio/kamailio/commit/134577590f1d3b18508119449198fb03d5c19b4f

Author: Kamailio Dev 
Committer: Kamailio Dev 
Date: 2018-06-22T10:46:55+02:00

modules: readme files regenerated - tm ... [skip ci]

---

Modified: src/modules/tm/README

---

Diff:  
https://github.com/kamailio/kamailio/commit/134577590f1d3b18508119449198fb03d5c19b4f.diff
Patch: 
https://github.com/kamailio/kamailio/commit/134577590f1d3b18508119449198fb03d5c19b4f.patch


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] tm: add relay_100 config parameter to support stateless operation (#1534)

2018-06-22 Thread Daniel-Constantin Mierla
Merged #1534.

-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1534#event-1695433712___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:8a12e15b: Merge pull request #1534 from armenb/armenb/relay_100

2018-06-22 Thread GitHub
Module: kamailio
Branch: master
Commit: 8a12e15b7a7c597f39a69f5bfdb265e42d5a778d
URL: 
https://github.com/kamailio/kamailio/commit/8a12e15b7a7c597f39a69f5bfdb265e42d5a778d

Author: Daniel-Constantin Mierla 
Committer: GitHub 
Date: 2018-06-22T10:34:45+02:00

Merge pull request #1534 from armenb/armenb/relay_100

tm: add relay_100 config parameter to support stateless operation

---

Modified: src/modules/tm/config.c
Modified: src/modules/tm/config.h
Modified: src/modules/tm/doc/params.xml
Modified: src/modules/tm/t_reply.c
Modified: src/modules/tm/tm.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/8a12e15b7a7c597f39a69f5bfdb265e42d5a778d.diff
Patch: 
https://github.com/kamailio/kamailio/commit/8a12e15b7a7c597f39a69f5bfdb265e42d5a778d.patch

---

diff --git a/src/modules/tm/config.c b/src/modules/tm/config.c
index 00f86b12b1..b5494fea50 100644
--- a/src/modules/tm/config.c
+++ b/src/modules/tm/config.c
@@ -93,8 +93,9 @@ struct cfg_group_tm   default_tm_cfg = {
0,  /* local_ack_mode, default 0 (rfc3261 conformant) */
1, /* local_cancel_reason -- add Reason header to locally generated
  CANCELs; on by default */
-   1  /* e2e_cancel_reason -- copy the Reason headers from incoming CANCELs
+   1,  /* e2e_cancel_reason -- copy the Reason headers from incoming 
CANCELs
  into the corresp. hop-by-hop CANCELs, on by default */
+   0   /* relay_100 -- by default, assume stateful proxy and do not relay 
SIP 100 */
 };
 
 void   *tm_cfg = &default_tm_cfg;
@@ -204,5 +205,7 @@ cfg_def_t   tm_cfg_def[] = {
{"e2e_cancel_reason",   CFG_VAR_INT | CFG_ATOMIC,   0, 1, 0, 0,
"if set to 1, Reason headers from received CANCELs are copied 
into"
" the corresponding generated hop-by-hop CANCELs"},
+   {"relay_100",   CFG_VAR_INT | CFG_ATOMIC,   0, 1, 0, 0,
+   "if set to 1, relay SIP 100 messages as a stateless proxy"},
{0, 0, 0, 0, 0, 0}
 };
diff --git a/src/modules/tm/config.h b/src/modules/tm/config.h
index 963fea6ea0..d46f71f9f6 100644
--- a/src/modules/tm/config.h
+++ b/src/modules/tm/config.h
@@ -135,6 +135,7 @@ struct cfg_group_tm {
int local_ack_mode;
int local_cancel_reason;
int e2e_cancel_reason;
+   unsigned int relay_100;
 };
 
 extern struct cfg_group_tm default_tm_cfg;
diff --git a/src/modules/tm/doc/params.xml b/src/modules/tm/doc/params.xml
index d787447c40..3692dab0d4 100644
--- a/src/modules/tm/doc/params.xml
+++ b/src/modules/tm/doc/params.xml
@@ -1454,6 +1454,33 @@ function ksr_tm_event(evname)
return 1;
 end
 ...
+
+   
+   
+
+   
+   relay_100 (str)
+   
+   This parameter controls whether or not a SIP 100 
response is proxied.
+   Note that this is not valid behavior when operating in 
stateful mode
+   per RFC 3261 Section 21.1.1, and therefore is useful 
only when
+   operating as a stateless proxy.
+   When using this feature, it is possible to control 
which 100 responses
+   are proxied and which are not by detecting whether they 
are part of
+   an existing transaction and setting up the appropriate 
logic in
+   onreply_route.
+   
+   
+   
+   Default value is 0 (disabled).
+   
+   
+   
+   Set relay_100 parameter
+   
+...
+modparam("tm", "relay_100", 1)
+...
 


diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 8b94cec624..474851aa7c 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -1494,9 +1494,10 @@ static enum rps t_should_relay_response( struct cell 
*Trans , int new_code,
 #else
*should_store=0;
 #endif
-   /* 1xx and 2xx except 100 will be relayed */
+   /* By default, 1xx and 2xx (except 100) will be relayed. 100 
relaying can be
+* controlled via relay_100 parameter */
Trans->uac[branch].last_received=new_code;
-   *should_relay= new_code==100? -1 : branch;
+   *should_relay= (new_code==100 && !cfg_get(tm, tm_cfg, 
relay_100)) ? -1 : branch;
if (new_code>=200 ) {
prepare_to_cancel( Trans, &cancel_data->cancel_bitmap, 
0);
 #ifdef CANCEL_REASON_SUPPORT
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 426898f314..68df52b5c1 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -474,6 +474,7 @@ static param_export_t params[]={
 #endif /* CANCEL_REASON_SUPPORT */
{"xavp_contact",PARAM_STR, &ulattrs_xavp_name   
 },
{"event_callback",  PARAM_STR, &tm_event_callback   
 },
+   {"relay_100",   PARAM_I

[sr-dev] git:master:926fbc97: tm: add relay_100 config parameter to support stateless operation

2018-06-22 Thread Armen Babikyan
Module: kamailio
Branch: master
Commit: 926fbc97643364f79d09bde290c39faa357d3a6f
URL: 
https://github.com/kamailio/kamailio/commit/926fbc97643364f79d09bde290c39faa357d3a6f

Author: Armen Babikyan 
Committer: Armen Babikyan 
Date: 2018-06-21T23:50:09-07:00

tm: add relay_100 config parameter to support stateless operation

---

Modified: src/modules/tm/config.c
Modified: src/modules/tm/config.h
Modified: src/modules/tm/doc/params.xml
Modified: src/modules/tm/t_reply.c
Modified: src/modules/tm/tm.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/926fbc97643364f79d09bde290c39faa357d3a6f.diff
Patch: 
https://github.com/kamailio/kamailio/commit/926fbc97643364f79d09bde290c39faa357d3a6f.patch

---

diff --git a/src/modules/tm/config.c b/src/modules/tm/config.c
index 00f86b12b1..b5494fea50 100644
--- a/src/modules/tm/config.c
+++ b/src/modules/tm/config.c
@@ -93,8 +93,9 @@ struct cfg_group_tm   default_tm_cfg = {
0,  /* local_ack_mode, default 0 (rfc3261 conformant) */
1, /* local_cancel_reason -- add Reason header to locally generated
  CANCELs; on by default */
-   1  /* e2e_cancel_reason -- copy the Reason headers from incoming CANCELs
+   1,  /* e2e_cancel_reason -- copy the Reason headers from incoming 
CANCELs
  into the corresp. hop-by-hop CANCELs, on by default */
+   0   /* relay_100 -- by default, assume stateful proxy and do not relay 
SIP 100 */
 };
 
 void   *tm_cfg = &default_tm_cfg;
@@ -204,5 +205,7 @@ cfg_def_t   tm_cfg_def[] = {
{"e2e_cancel_reason",   CFG_VAR_INT | CFG_ATOMIC,   0, 1, 0, 0,
"if set to 1, Reason headers from received CANCELs are copied 
into"
" the corresponding generated hop-by-hop CANCELs"},
+   {"relay_100",   CFG_VAR_INT | CFG_ATOMIC,   0, 1, 0, 0,
+   "if set to 1, relay SIP 100 messages as a stateless proxy"},
{0, 0, 0, 0, 0, 0}
 };
diff --git a/src/modules/tm/config.h b/src/modules/tm/config.h
index 963fea6ea0..d46f71f9f6 100644
--- a/src/modules/tm/config.h
+++ b/src/modules/tm/config.h
@@ -135,6 +135,7 @@ struct cfg_group_tm {
int local_ack_mode;
int local_cancel_reason;
int e2e_cancel_reason;
+   unsigned int relay_100;
 };
 
 extern struct cfg_group_tm default_tm_cfg;
diff --git a/src/modules/tm/doc/params.xml b/src/modules/tm/doc/params.xml
index d787447c40..3692dab0d4 100644
--- a/src/modules/tm/doc/params.xml
+++ b/src/modules/tm/doc/params.xml
@@ -1454,6 +1454,33 @@ function ksr_tm_event(evname)
return 1;
 end
 ...
+
+   
+   
+
+   
+   relay_100 (str)
+   
+   This parameter controls whether or not a SIP 100 
response is proxied.
+   Note that this is not valid behavior when operating in 
stateful mode
+   per RFC 3261 Section 21.1.1, and therefore is useful 
only when
+   operating as a stateless proxy.
+   When using this feature, it is possible to control 
which 100 responses
+   are proxied and which are not by detecting whether they 
are part of
+   an existing transaction and setting up the appropriate 
logic in
+   onreply_route.
+   
+   
+   
+   Default value is 0 (disabled).
+   
+   
+   
+   Set relay_100 parameter
+   
+...
+modparam("tm", "relay_100", 1)
+...
 


diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 9958e70333..00691c0ff8 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -1492,9 +1492,10 @@ static enum rps t_should_relay_response( struct cell 
*Trans , int new_code,
 #else
*should_store=0;
 #endif
-   /* 1xx and 2xx except 100 will be relayed */
+   /* By default, 1xx and 2xx (except 100) will be relayed. 100 
relaying can be
+* controlled via relay_100 parameter */
Trans->uac[branch].last_received=new_code;
-   *should_relay= new_code==100? -1 : branch;
+   *should_relay= (new_code==100 && !cfg_get(tm, tm_cfg, 
relay_100)) ? -1 : branch;
if (new_code>=200 ) {
prepare_to_cancel( Trans, &cancel_data->cancel_bitmap, 
0);
 #ifdef CANCEL_REASON_SUPPORT
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 426898f314..68df52b5c1 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -474,6 +474,7 @@ static param_export_t params[]={
 #endif /* CANCEL_REASON_SUPPORT */
{"xavp_contact",PARAM_STR, &ulattrs_xavp_name   
 },
{"event_callback",  PARAM_STR, &tm_event_callback   
 },
+   {"relay_100",   PARAM_INT, &default_tm_cfg.relay_100
 },
{0,

Re: [sr-dev] [kamailio/kamailio] t_relay() sending packets from the wrong TCP socket (#1532)

2018-06-22 Thread Vadim Lebedev
Well i don't want to be nit picking however, i believe you're mistaken
here.  You can reuse port on which you are listening for outgoing
connections too.
You need to use* setsockopt(... SO_REUSEPORT ).*..
here goes the demo:

#!/usr/bin/python3
import socket
import threading


READER1_ADDR = ("127.0.0.1", 23008)
READER2_ADDR = ("127.0.0.1", 23009)



class wait_conn(threading.Thread):
def __init__(self, addr, name):

super(wait_conn,self).__init__()

self.name = name
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.sock.bind(addr)
self.sock.listen(3)

def run(self):
s, a = self.sock.accept()
print(self.name, ": Incomming connection from: ",  s.getpeername())
s.close()
self.sock.close()


t1 = wait_conn(READER1_ADDR, "r1")
t1.start()
t2 = wait_conn(READER2_ADDR, "r2")
t2.start()

w1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
w1.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
w1.bind(READER1_ADDR)
w1.connect(READER2_ADDR)
w1.close()




t1.join(1.0)
t2.join(1.0)




2018-06-21 21:27 GMT+02:00 Daniel-Constantin Mierla <
notificati...@github.com>:

> Obviously the difference is that kamailio does bind() and listen() on the
> socket (ip:port) first -- maybe that should have said to be clear about
> what case we talk here. So try with socket(), bind(), listen() and then
> connect().
>
> Once there is listen() on a socket, read events for it mean accept()
> should be done. The kernel won't create an outgoing connection from a
> listen socket, but use ephemeral ports.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> ,
> or mute the thread
> 
> .
>
> ___
> Kamailio (SER) - Development Mailing List
> sr-dev@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
>
>
___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] Modules: Evapi async_relay export to kemi (#1563)

2018-06-22 Thread Daniel-Constantin Mierla
Merged #1563.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1563#event-1695430365___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] Modules: Evapi async_relay export to kemi (#1563)

2018-06-22 Thread Daniel-Constantin Mierla
Merging it, given that fixup needs to be evaluated after suspending the 
transaction, it is not much that we can reuse now. In the near future, I will 
think of making a wrapper with two arguments for the parameters that can come 
either as fixup param or str*.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1563#issuecomment-399365984___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:752e875f: Merge pull request #1563 from surendratiwari3/evapi_async_relay_kemi

2018-06-22 Thread GitHub
Module: kamailio
Branch: master
Commit: 752e875faece8233d39f8c91d7d553517ee94cd6
URL: 
https://github.com/kamailio/kamailio/commit/752e875faece8233d39f8c91d7d553517ee94cd6

Author: Daniel-Constantin Mierla 
Committer: GitHub 
Date: 2018-06-22T10:32:49+02:00

Merge pull request #1563 from surendratiwari3/evapi_async_relay_kemi

Modules: Evapi async_relay export to kemi

---

Modified: src/modules/evapi/evapi_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/752e875faece8233d39f8c91d7d553517ee94cd6.diff
Patch: 
https://github.com/kamailio/kamailio/commit/752e875faece8233d39f8c91d7d553517ee94cd6.patch

---

diff --git a/src/modules/evapi/evapi_mod.c b/src/modules/evapi/evapi_mod.c
index 7673cb262e..9ed8bd6d9a 100644
--- a/src/modules/evapi/evapi_mod.c
+++ b/src/modules/evapi/evapi_mod.c
@@ -591,6 +591,56 @@ static int ki_evapi_relay(sip_msg_t *msg, str *sdata)
return evapi_relay(sdata);
 }
 
+/**
+ *
+ */
+static int ki_evapi_async_relay(sip_msg_t *msg, str *sdata)
+{
+   unsigned int tindex;
+   unsigned int tlabel;
+   tm_cell_t *t = 0;
+
+
+   if(tmb.t_suspend==NULL) {
+   LM_ERR("evapi async relay is disabled - tm module not 
loaded\n");
+   return -1;
+   }
+
+   t = tmb.t_gett();
+   if (t==NULL || t==T_UNDEFINED)
+   {
+   if(tmb.t_newtran(msg)<0)
+   {
+   LM_ERR("cannot create the transaction\n");
+   return -1;
+   }
+   t = tmb.t_gett();
+   if (t==NULL || t==T_UNDEFINED)
+   {
+   LM_ERR("cannot lookup the transaction\n");
+   return -1;
+   }
+   }
+   if(tmb.t_suspend(msg, &tindex, &tlabel)<0)
+   {
+   LM_ERR("failed to suspend request processing\n");
+   return -1;
+   }
+
+   LM_DBG("transaction suspended [%u:%u]\n", tindex, tlabel);
+
+   if(sdata->s==NULL || sdata->len == 0) {
+   LM_ERR("invalid data parameter\n");
+   return -1;
+   }
+
+   if(evapi_relay(sdata)<0) {
+   LM_ERR("failed to relay event: %.*s\n", sdata->len, sdata->s);
+   return -2;
+   }
+   return 1;
+}
+
 /**
  *
  */
@@ -637,7 +687,11 @@ static sr_kemi_t sr_kemi_evapi_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
-
+   { str_init("evapi"), str_init("async_relay"),
+   SR_KEMIP_INT, ki_evapi_async_relay,
+   { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+   },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };
 /* clang-format on */


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:99472814: Modules: Evapi async_relay export to kemi

2018-06-22 Thread surendratiwari3
Module: kamailio
Branch: master
Commit: 99472814b19f50e30beda1840c5e969938027cac
URL: 
https://github.com/kamailio/kamailio/commit/99472814b19f50e30beda1840c5e969938027cac

Author: surendratiwari3 
Committer: surendratiwari3 
Date: 2018-06-13T03:08:52Z

Modules: Evapi async_relay export to kemi

---

Modified: src/modules/evapi/evapi_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/99472814b19f50e30beda1840c5e969938027cac.diff
Patch: 
https://github.com/kamailio/kamailio/commit/99472814b19f50e30beda1840c5e969938027cac.patch

---

diff --git a/src/modules/evapi/evapi_mod.c b/src/modules/evapi/evapi_mod.c
index 7673cb262e..9ed8bd6d9a 100644
--- a/src/modules/evapi/evapi_mod.c
+++ b/src/modules/evapi/evapi_mod.c
@@ -591,6 +591,56 @@ static int ki_evapi_relay(sip_msg_t *msg, str *sdata)
return evapi_relay(sdata);
 }
 
+/**
+ *
+ */
+static int ki_evapi_async_relay(sip_msg_t *msg, str *sdata)
+{
+   unsigned int tindex;
+   unsigned int tlabel;
+   tm_cell_t *t = 0;
+
+
+   if(tmb.t_suspend==NULL) {
+   LM_ERR("evapi async relay is disabled - tm module not 
loaded\n");
+   return -1;
+   }
+
+   t = tmb.t_gett();
+   if (t==NULL || t==T_UNDEFINED)
+   {
+   if(tmb.t_newtran(msg)<0)
+   {
+   LM_ERR("cannot create the transaction\n");
+   return -1;
+   }
+   t = tmb.t_gett();
+   if (t==NULL || t==T_UNDEFINED)
+   {
+   LM_ERR("cannot lookup the transaction\n");
+   return -1;
+   }
+   }
+   if(tmb.t_suspend(msg, &tindex, &tlabel)<0)
+   {
+   LM_ERR("failed to suspend request processing\n");
+   return -1;
+   }
+
+   LM_DBG("transaction suspended [%u:%u]\n", tindex, tlabel);
+
+   if(sdata->s==NULL || sdata->len == 0) {
+   LM_ERR("invalid data parameter\n");
+   return -1;
+   }
+
+   if(evapi_relay(sdata)<0) {
+   LM_ERR("failed to relay event: %.*s\n", sdata->len, sdata->s);
+   return -2;
+   }
+   return 1;
+}
+
 /**
  *
  */
@@ -637,7 +687,11 @@ static sr_kemi_t sr_kemi_evapi_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
-
+   { str_init("evapi"), str_init("async_relay"),
+   SR_KEMIP_INT, ki_evapi_async_relay,
+   { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+   },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };
 /* clang-format on */


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] ims_usrloc_scscf:bugfix erraneous unlinking of deleted contact (#1572)

2018-06-22 Thread Daniel-Constantin Mierla
Merged #1572.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1572#event-1695422795___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:5.1:e8b2bf9d: Merge pull request #1572 from christoph-v/bugfix_prm18_0001045_contact_remove_5.1

2018-06-22 Thread GitHub
Module: kamailio
Branch: 5.1
Commit: e8b2bf9deedfd83d38996d8c5c37761e0e5dcde2
URL: 
https://github.com/kamailio/kamailio/commit/e8b2bf9deedfd83d38996d8c5c37761e0e5dcde2

Author: Daniel-Constantin Mierla 
Committer: GitHub 
Date: 2018-06-22T10:28:36+02:00

Merge pull request #1572 from 
christoph-v/bugfix_prm18_0001045_contact_remove_5.1

ims_usrloc_scscf:bugfix erraneous unlinking of deleted contact

---

Modified: src/modules/ims_usrloc_scscf/impurecord.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/e8b2bf9deedfd83d38996d8c5c37761e0e5dcde2.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e8b2bf9deedfd83d38996d8c5c37761e0e5dcde2.patch

---

diff --git a/src/modules/ims_usrloc_scscf/impurecord.c 
b/src/modules/ims_usrloc_scscf/impurecord.c
index 6510d85aa1..20c8a64154 100644
--- a/src/modules/ims_usrloc_scscf/impurecord.c
+++ b/src/modules/ims_usrloc_scscf/impurecord.c
@@ -1102,10 +1102,11 @@ int remove_impucontact_from_list(impurecord_t* impu, 
impu_contact_t *impucontact
} else if (contact == impu->linked_contacts.tail->contact) {
LM_DBG("deleting tail\n");
impu->linked_contacts.tail = impu->linked_contacts.tail->prev;
+impu->linked_contacts.tail->next = 0;
} else {
LM_DBG("deleting mid list\n");
impucontact->prev->next = impucontact->next;
-   impucontact->prev = impucontact->next->prev;
+   impucontact->next->prev = impucontact->prev;
}

impu->linked_contacts.numcontacts--;


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] app_python3: fix kemi function call argument type checks (#1568)

2018-06-22 Thread Daniel-Constantin Mierla
Merged #1568.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1568#event-1695422027___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:3c4bc85f: Merge pull request #1568 from kmduk/py3_kemi_function_calls

2018-06-22 Thread GitHub
Module: kamailio
Branch: master
Commit: 3c4bc85f6ded3e5d123bf057c716c86ff0da8d9f
URL: 
https://github.com/kamailio/kamailio/commit/3c4bc85f6ded3e5d123bf057c716c86ff0da8d9f

Author: Daniel-Constantin Mierla 
Committer: GitHub 
Date: 2018-06-22T10:28:07+02:00

Merge pull request #1568 from kmduk/py3_kemi_function_calls

app_python3: fix kemi function call argument type checks

---

Modified: src/modules/app_python3/apy_kemi.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3c4bc85f6ded3e5d123bf057c716c86ff0da8d9f.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3c4bc85f6ded3e5d123bf057c716c86ff0da8d9f.patch


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] TOPOS with event_route filter fails with BYE message (#1569)

2018-06-22 Thread Daniel-Constantin Mierla
Closed #1569.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1569#event-1695418823___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] TOPOS with event_route filter fails with BYE message (#1569)

2018-06-22 Thread Daniel-Constantin Mierla
I looked at the code and the only significant difference between 5.1 and master 
branches for topos module is related to matching KDMQ method, so the behaviour 
should be the same.

I am closing this one, you said you are going to open another issue as feature 
request for a new event route.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1569#issuecomment-399364375___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:5.1:fc5c5f56: topos: fix warning about uninitialized variable

2018-06-22 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: 5.1
Commit: fc5c5f56c08766415e8a13b9e86e405bc504d695
URL: 
https://github.com/kamailio/kamailio/commit/fc5c5f56c08766415e8a13b9e86e405bc504d695

Author: Henning Westerholt 
Committer: Daniel-Constantin Mierla 
Date: 2018-06-22T10:21:55+02:00

topos: fix warning about uninitialized variable

(cherry picked from commit e7ee14f0d168c36c62cd6bef58334db1f0871470)

---

Modified: src/modules/topos/tps_storage.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/fc5c5f56c08766415e8a13b9e86e405bc504d695.diff
Patch: 
https://github.com/kamailio/kamailio/commit/fc5c5f56c08766415e8a13b9e86e405bc504d695.patch

---

diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index da141888c3..66169f7b02 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -371,7 +371,7 @@ int tps_storage_link_msg(sip_msg_t *msg, tps_data_t *td, 
int dir)
  */
 int tps_storage_record(sip_msg_t *msg, tps_data_t *td, int dialog)
 {
-   int ret;
+   int ret = -1; /* error if dialog == 0 */
str suid;
 
if(dialog==0) {


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] Problem with re-invite and bye from uas when re-invite fail using topos module (#1571)

2018-06-22 Thread Daniel-Constantin Mierla
The only reason could be that the Contact address is updated in the wrong field 
after the re-INVITE.

Can you watch the records in database table topos_d and look at a_contact and 
b_contact fields before and after re-INVITE?

I also pushed a commit to mater branch to log how contact addresses are mapped, 
so you can fetch the latest git and try with it, then besides the database 
records for topos_d you can attach fresh log messages to match the values from 
database.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1571#issuecomment-399362267___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:5bafb32f: topos: debug log messages with linked contact addresses

2018-06-22 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 5bafb32fa3dd0aefdb5e0c1a8bbd94638fe1022d
URL: 
https://github.com/kamailio/kamailio/commit/5bafb32fa3dd0aefdb5e0c1a8bbd94638fe1022d

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2018-06-22T10:11:56+02:00

topos: debug log messages with linked contact addresses

---

Modified: src/modules/topos/tps_storage.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/5bafb32fa3dd0aefdb5e0c1a8bbd94638fe1022d.diff
Patch: 
https://github.com/kamailio/kamailio/commit/5bafb32fa3dd0aefdb5e0c1a8bbd94638fe1022d.patch

---

diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index fb159d4dac..5e0e87b249 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -360,6 +360,11 @@ int tps_storage_link_msg(sip_msg_t *msg, tps_data_t *td, 
int dir)
}
}
 
+   LM_DBG("downstream: %s acontact: [%.*s] bcontact: [%.*s]\n",
+   (dir==TPS_DIR_DOWNSTREAM)?"yes":"no",
+   td->a_contact.len, 
(td->a_contact.len>0)?td->a_contact.s:"",
+   td->b_contact.len, 
(td->b_contact.len>0)?td->b_contact.s:"");
+
return 0;
 
 error:


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:ecfb1b6c: topos: print warn message of missing record-route only for initial requests

2018-06-22 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: ecfb1b6c9abcaa662155f67b56516fd2d0750fe7
URL: 
https://github.com/kamailio/kamailio/commit/ecfb1b6c9abcaa662155f67b56516fd2d0750fe7

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2018-06-22T09:23:01+02:00

topos: print warn message of missing record-route only for initial requests

---

Modified: src/modules/topos/tps_storage.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/ecfb1b6c9abcaa662155f67b56516fd2d0750fe7.diff
Patch: 
https://github.com/kamailio/kamailio/commit/ecfb1b6c9abcaa662155f67b56516fd2d0750fe7.patch

---

diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index 66169f7b02..fb159d4dac 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -396,10 +396,10 @@ int tps_storage_record(sip_msg_t *msg, tps_data_t *td, 
int dialog)
 
ret = tps_storage_link_msg(msg, td, TPS_DIR_DOWNSTREAM);
if(ret<0) goto error;
-   if(td->as_contact.len <= 0 && td->bs_contact.len <= 0) {
-   LM_WARN("no local address - do record routing for all initial 
requests\n");
-   }
if(dialog==0) {
+   if(td->as_contact.len <= 0 && td->bs_contact.len <= 0) {
+   LM_WARN("no local address - do record routing for all 
initial requests\n");
+   }
ret = _tps_storage_api.insert_dialog(td);
if(ret<0) goto error;
}


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev