|
|
|
@ -3,21 +3,24 @@ Date: Thu, 26 Mar 2020 10:06:46 +0100
|
|
|
|
Subject: sca-line-seize
|
|
|
|
Subject: sca-line-seize
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
src/modules/sca/sca.c | 103 ++++++++++++++++++++++++++-
|
|
|
|
src/modules/sca/sca.c | 107 ++++++++++++++++++++++++++-
|
|
|
|
src/modules/sca/sca.h | 6 ++
|
|
|
|
src/modules/sca/sca.h | 6 ++
|
|
|
|
src/modules/sca/sca_call_info.c | 77 +++++++++-----------
|
|
|
|
src/modules/sca/sca_appearance.h | 2 +-
|
|
|
|
src/modules/sca/sca_subscribe.c | 56 +++++++++------
|
|
|
|
src/modules/sca/sca_call_info.c | 78 +++++++++-----------
|
|
|
|
src/modules/sca/sca_subscribe.h | 4 +-
|
|
|
|
src/modules/sca/sca_call_info.h | 6 +-
|
|
|
|
src/modules/sca/sca_util.c | 153 +++++++++++++++++++++++-----------------
|
|
|
|
src/modules/sca/sca_dialog.h | 2 +-
|
|
|
|
6 files changed, 263 insertions(+), 136 deletions(-)
|
|
|
|
src/modules/sca/sca_subscribe.c | 61 ++++++++-------
|
|
|
|
|
|
|
|
src/modules/sca/sca_subscribe.h | 6 +-
|
|
|
|
|
|
|
|
src/modules/sca/sca_util.c | 155 +++++++++++++++++++++++----------------
|
|
|
|
|
|
|
|
9 files changed, 279 insertions(+), 144 deletions(-)
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/modules/sca/sca.c b/src/modules/sca/sca.c
|
|
|
|
diff --git a/src/modules/sca/sca.c b/src/modules/sca/sca.c
|
|
|
|
index dba9ff0..698da84 100644
|
|
|
|
index 07dac39..c2347bb 100644
|
|
|
|
--- a/src/modules/sca/sca.c
|
|
|
|
--- a/src/modules/sca/sca.c
|
|
|
|
+++ b/src/modules/sca/sca.c
|
|
|
|
+++ b/src/modules/sca/sca.c
|
|
|
|
@@ -64,6 +64,12 @@ db_func_t dbf; // db api
|
|
|
|
@@ -64,6 +64,12 @@ db_func_t dbf; // db api
|
|
|
|
struct tm_binds tmb; // tm functions for sending messages
|
|
|
|
struct tm_binds tmb; // tm functions for sending messages
|
|
|
|
sl_api_t slb; // sl callback, function for getting to-tag
|
|
|
|
sl_api_t slb; // sl callback, function for getting to-tag
|
|
|
|
|
|
|
|
|
|
|
|
+/* avps */
|
|
|
|
+/* avps */
|
|
|
|
+unsigned short from_uri_avp_type;
|
|
|
|
+unsigned short from_uri_avp_type;
|
|
|
|
@ -32,30 +35,30 @@ index dba9ff0..698da84 100644
|
|
|
|
static int sca_child_init(int);
|
|
|
|
static int sca_child_init(int);
|
|
|
|
static void sca_mod_destroy(void);
|
|
|
|
static void sca_mod_destroy(void);
|
|
|
|
static int sca_set_config(sca_mod *);
|
|
|
|
static int sca_set_config(sca_mod *);
|
|
|
|
+static int sca_handle_subscribe_0_f(sip_msg_t* msg);
|
|
|
|
+static int sca_handle_subscribe_0_f(sip_msg_t *msg);
|
|
|
|
+static int sca_handle_subscribe_1_f(sip_msg_t* msg, char*);
|
|
|
|
+static int sca_handle_subscribe_1_f(sip_msg_t *msg, char *);
|
|
|
|
+static int sca_handle_subscribe_2_f(sip_msg_t* msg, char*, char *);
|
|
|
|
+static int sca_handle_subscribe_2_f(sip_msg_t *msg, char *, char *);
|
|
|
|
+int fixup_hs(void **, int);
|
|
|
|
+int fixup_hs(void **, int);
|
|
|
|
+int fixup_free_hs(void **param, int param_no);
|
|
|
|
+int fixup_free_hs(void **param, int param_no);
|
|
|
|
static int sca_call_info_update_0_f(sip_msg_t* msg, char*, char*);
|
|
|
|
static int sca_call_info_update_0_f(sip_msg_t *msg, char *, char *);
|
|
|
|
static int sca_call_info_update_1_f(sip_msg_t* msg, char*, char*);
|
|
|
|
static int sca_call_info_update_1_f(sip_msg_t *msg, char *, char *);
|
|
|
|
static int sca_call_info_update_2_f(sip_msg_t* msg, char*, char*);
|
|
|
|
static int sca_call_info_update_2_f(sip_msg_t *msg, char *, char *);
|
|
|
|
@@ -82,8 +93,12 @@ int fixup_free_ciu(void **param, int param_no);
|
|
|
|
@@ -82,8 +93,12 @@ int fixup_free_ciu(void **param, int param_no);
|
|
|
|
* EXPORTED COMMANDS
|
|
|
|
* EXPORTED COMMANDS
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static cmd_export_t cmds[] = {
|
|
|
|
static cmd_export_t cmds[] = {
|
|
|
|
- {"sca_handle_subscribe", (cmd_function)sca_handle_subscribe, 0, NULL, 0,
|
|
|
|
- {"sca_handle_subscribe", (cmd_function)sca_handle_subscribe, 0, NULL, 0,
|
|
|
|
- REQUEST_ROUTE},
|
|
|
|
- REQUEST_ROUTE},
|
|
|
|
+ { "sca_handle_subscribe", (cmd_function)sca_handle_subscribe_0_f, 0,
|
|
|
|
+ {"sca_handle_subscribe", (cmd_function)sca_handle_subscribe_0_f, 0,
|
|
|
|
+ NULL, NULL, REQUEST_ROUTE },
|
|
|
|
+ NULL, NULL, REQUEST_ROUTE},
|
|
|
|
+ { "sca_handle_subscribe", (cmd_function)sca_handle_subscribe_1_f, 1,
|
|
|
|
+ {"sca_handle_subscribe", (cmd_function)sca_handle_subscribe_1_f, 1,
|
|
|
|
+ fixup_hs, fixup_free_hs, REQUEST_ROUTE },
|
|
|
|
+ fixup_hs, fixup_free_hs, REQUEST_ROUTE},
|
|
|
|
+ { "sca_handle_subscribe", (cmd_function)sca_handle_subscribe_2_f, 2,
|
|
|
|
+ {"sca_handle_subscribe", (cmd_function)sca_handle_subscribe_2_f, 2,
|
|
|
|
+ fixup_hs, fixup_free_hs, REQUEST_ROUTE },
|
|
|
|
+ fixup_hs, fixup_free_hs, REQUEST_ROUTE},
|
|
|
|
{"sca_call_info_update", (cmd_function)sca_call_info_update_0_f, 0, NULL, 0,
|
|
|
|
{"sca_call_info_update", (cmd_function)sca_call_info_update_0_f, 0,
|
|
|
|
REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE},
|
|
|
|
NULL, 0, REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE},
|
|
|
|
{"sca_call_info_update", (cmd_function)sca_call_info_update_1_f, 1,
|
|
|
|
{"sca_call_info_update", (cmd_function)sca_call_info_update_1_f, 1,
|
|
|
|
@@ -139,6 +154,8 @@ int line_seize_max_expires = 15;
|
|
|
|
@@ -141,6 +156,8 @@ int line_seize_max_expires = 15;
|
|
|
|
int purge_expired_interval = 120;
|
|
|
|
int purge_expired_interval = 120;
|
|
|
|
int onhold_bflag = -1;
|
|
|
|
int onhold_bflag = -1;
|
|
|
|
str server_address = STR_NULL;
|
|
|
|
str server_address = STR_NULL;
|
|
|
|
@ -64,7 +67,7 @@ index dba9ff0..698da84 100644
|
|
|
|
|
|
|
|
|
|
|
|
static param_export_t params[] = {
|
|
|
|
static param_export_t params[] = {
|
|
|
|
{"outbound_proxy", PARAM_STR, &outbound_proxy},
|
|
|
|
{"outbound_proxy", PARAM_STR, &outbound_proxy},
|
|
|
|
@@ -152,6 +169,8 @@ static param_export_t params[] = {
|
|
|
|
@@ -154,6 +171,8 @@ static param_export_t params[] = {
|
|
|
|
{"purge_expired_interval", INT_PARAM, &purge_expired_interval},
|
|
|
|
{"purge_expired_interval", INT_PARAM, &purge_expired_interval},
|
|
|
|
{"onhold_bflag", INT_PARAM, &onhold_bflag},
|
|
|
|
{"onhold_bflag", INT_PARAM, &onhold_bflag},
|
|
|
|
{"server_address", PARAM_STR, &server_address},
|
|
|
|
{"server_address", PARAM_STR, &server_address},
|
|
|
|
@ -73,24 +76,25 @@ index dba9ff0..698da84 100644
|
|
|
|
{NULL, 0, NULL},
|
|
|
|
{NULL, 0, NULL},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@@ -319,6 +338,31 @@ static int sca_child_init(int rank)
|
|
|
|
@@ -329,6 +348,32 @@ static int sca_child_init(int rank)
|
|
|
|
return (0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+static int
|
|
|
|
+static int sca_process_avps(
|
|
|
|
+sca_process_avps(str *avp_param, int_str *avp, unsigned short *avp_type)
|
|
|
|
+ str *avp_param, int_str *avp, unsigned short *avp_type)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ pv_spec_t *avp_spec;
|
|
|
|
+ pv_spec_t *avp_spec;
|
|
|
|
+ unsigned short avp_flags;
|
|
|
|
+ unsigned short avp_flags;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (avp_param && avp_param->len > 0) {
|
|
|
|
+ if(avp_param && avp_param->len > 0) {
|
|
|
|
+ avp_spec = pv_cache_get(avp_param);
|
|
|
|
+ avp_spec = pv_cache_get(avp_param);
|
|
|
|
+ if (avp_spec==NULL|| avp_spec->type!=PVT_AVP) {
|
|
|
|
+ if(avp_spec == NULL || avp_spec->type != PVT_AVP) {
|
|
|
|
+ LM_ERR("malformed or non AVP definition <%.*s>\n", STR_FMT(avp_param));
|
|
|
|
+ LM_ERR("malformed or non AVP definition <%.*s>\n",
|
|
|
|
|
|
|
|
+ STR_FMT(avp_param));
|
|
|
|
+ return -1;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (pv_get_avp_name(0, &(avp_spec->pvp), avp, &avp_flags) != 0) {
|
|
|
|
+ if(pv_get_avp_name(0, &(avp_spec->pvp), avp, &avp_flags) != 0) {
|
|
|
|
+ LM_ERR("invalid AVP definition <%.*s>\n", STR_FMT(avp_param));
|
|
|
|
+ LM_ERR("invalid AVP definition <%.*s>\n", STR_FMT(avp_param));
|
|
|
|
+ return -1;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
@ -104,45 +108,48 @@ index dba9ff0..698da84 100644
|
|
|
|
+
|
|
|
|
+
|
|
|
|
static int sca_mod_init(void)
|
|
|
|
static int sca_mod_init(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sca = (sca_mod *) shm_malloc(sizeof(sca_mod));
|
|
|
|
sca = (sca_mod *)shm_malloc(sizeof(sca_mod));
|
|
|
|
@@ -377,6 +421,11 @@ static int sca_mod_init(void)
|
|
|
|
@@ -389,6 +434,14 @@ static int sca_mod_init(void)
|
|
|
|
// timer process forks in sca_child_init, above.
|
|
|
|
// timer process forks in sca_child_init, above.
|
|
|
|
register_dummy_timers(1);
|
|
|
|
register_dummy_timers(1);
|
|
|
|
|
|
|
|
|
|
|
|
+ if(sca_process_avps(&from_uri_avp_param, &from_uri_avp, &from_uri_avp_type)<0 ||
|
|
|
|
+ if(sca_process_avps(&from_uri_avp_param, &from_uri_avp, &from_uri_avp_type)
|
|
|
|
+ sca_process_avps(&to_uri_avp_param, &to_uri_avp, &to_uri_avp_type)<0) {
|
|
|
|
+ < 0
|
|
|
|
|
|
|
|
+ || sca_process_avps(
|
|
|
|
|
|
|
|
+ &to_uri_avp_param, &to_uri_avp, &to_uri_avp_type)
|
|
|
|
|
|
|
|
+ < 0) {
|
|
|
|
+ goto error;
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
LM_INFO("SCA initialized \n");
|
|
|
|
LM_INFO("SCA initialized \n");
|
|
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
return (0);
|
|
|
|
@@ -414,6 +463,56 @@ void sca_mod_destroy(void)
|
|
|
|
@@ -428,6 +481,56 @@ void sca_mod_destroy(void)
|
|
|
|
sca_db_disconnect();
|
|
|
|
sca_db_disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+static int sca_handle_subscribe_0_f(sip_msg_t* msg) {
|
|
|
|
+static int sca_handle_subscribe_0_f(sip_msg_t *msg)
|
|
|
|
|
|
|
|
+{
|
|
|
|
+ return sca_handle_subscribe(msg, NULL, NULL);
|
|
|
|
+ return sca_handle_subscribe(msg, NULL, NULL);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+static int sca_handle_subscribe_1_f(sip_msg_t* msg, char* p1) {
|
|
|
|
+static int sca_handle_subscribe_1_f(sip_msg_t *msg, char *p1)
|
|
|
|
|
|
|
|
+{
|
|
|
|
+ str uri_to = STR_NULL;
|
|
|
|
+ str uri_to = STR_NULL;
|
|
|
|
+ if(get_str_fparam(&uri_to, msg, (gparam_p)p1)!=0)
|
|
|
|
+ if(get_str_fparam(&uri_to, msg, (gparam_p)p1) != 0) {
|
|
|
|
+ {
|
|
|
|
|
|
|
|
+ LM_ERR("unable to get value from param pvar_to\n");
|
|
|
|
+ LM_ERR("unable to get value from param pvar_to\n");
|
|
|
|
+ return -1;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return sca_handle_subscribe(msg, &uri_to, NULL);
|
|
|
|
+ return sca_handle_subscribe(msg, &uri_to, NULL);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+static int sca_handle_subscribe_2_f(sip_msg_t* msg, char* p1, char* p2) {
|
|
|
|
+static int sca_handle_subscribe_2_f(sip_msg_t *msg, char *p1, char *p2)
|
|
|
|
|
|
|
|
+{
|
|
|
|
+ str uri_to = STR_NULL;
|
|
|
|
+ str uri_to = STR_NULL;
|
|
|
|
+ str uri_from = STR_NULL;
|
|
|
|
+ str uri_from = STR_NULL;
|
|
|
|
+ if(get_str_fparam(&uri_to, msg, (gparam_p)p1)!=0)
|
|
|
|
+ if(get_str_fparam(&uri_to, msg, (gparam_p)p1) != 0) {
|
|
|
|
+ {
|
|
|
|
|
|
|
|
+ LM_ERR("unable to get value from param pvar_to\n");
|
|
|
|
+ LM_ERR("unable to get value from param pvar_to\n");
|
|
|
|
+ return -1;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(get_str_fparam(&uri_from, msg, (gparam_p)p2)!=0)
|
|
|
|
+ if(get_str_fparam(&uri_from, msg, (gparam_p)p2) != 0) {
|
|
|
|
+ {
|
|
|
|
|
|
|
|
+ LM_ERR("unable to get value from param pvar_from\n");
|
|
|
|
+ LM_ERR("unable to get value from param pvar_from\n");
|
|
|
|
+ return -1;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
@ -151,7 +158,7 @@ index dba9ff0..698da84 100644
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int fixup_hs(void **param, int param_no)
|
|
|
|
+int fixup_hs(void **param, int param_no)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ switch (param_no) {
|
|
|
|
+ switch(param_no) {
|
|
|
|
+ case 1:
|
|
|
|
+ case 1:
|
|
|
|
+ case 2:
|
|
|
|
+ case 2:
|
|
|
|
+ return fixup_spve_null(param, 1);
|
|
|
|
+ return fixup_spve_null(param, 1);
|
|
|
|
@ -162,23 +169,23 @@ index dba9ff0..698da84 100644
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int fixup_free_hs(void **param, int param_no)
|
|
|
|
+int fixup_free_hs(void **param, int param_no)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ switch (param_no) {
|
|
|
|
+ switch(param_no) {
|
|
|
|
+ case 1:
|
|
|
|
+ case 1:
|
|
|
|
+ case 2:
|
|
|
|
+ case 2:
|
|
|
|
+ return fixup_free_spve_null(param, 1);
|
|
|
|
+ return fixup_free_spve_null(param, 1);
|
|
|
|
+ default:
|
|
|
|
+ default:
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
static int sca_call_info_update_0_f(sip_msg_t* msg, char* p1, char* p2)
|
|
|
|
static int sca_call_info_update_0_f(sip_msg_t *msg, char *p1, char *p2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return sca_call_info_update(msg, SCA_CALL_INFO_SHARED_BOTH, NULL, NULL);
|
|
|
|
return sca_call_info_update(msg, SCA_CALL_INFO_SHARED_BOTH, NULL, NULL);
|
|
|
|
diff --git a/src/modules/sca/sca.h b/src/modules/sca/sca.h
|
|
|
|
diff --git a/src/modules/sca/sca.h b/src/modules/sca/sca.h
|
|
|
|
index 04d3c1e..2425bc3 100644
|
|
|
|
index cceae17..7a80847 100644
|
|
|
|
--- a/src/modules/sca/sca.h
|
|
|
|
--- a/src/modules/sca/sca.h
|
|
|
|
+++ b/src/modules/sca/sca.h
|
|
|
|
+++ b/src/modules/sca/sca.h
|
|
|
|
@@ -55,4 +55,10 @@ typedef struct _sca_mod sca_mod;
|
|
|
|
@@ -57,4 +57,10 @@ typedef struct _sca_mod sca_mod;
|
|
|
|
|
|
|
|
|
|
|
|
extern sca_mod *sca;
|
|
|
|
extern sca_mod *sca;
|
|
|
|
|
|
|
|
|
|
|
|
@ -189,11 +196,24 @@ index 04d3c1e..2425bc3 100644
|
|
|
|
+extern int_str to_uri_avp;
|
|
|
|
+extern int_str to_uri_avp;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
#endif // SCA_H
|
|
|
|
#endif // SCA_H
|
|
|
|
|
|
|
|
diff --git a/src/modules/sca/sca_appearance.h b/src/modules/sca/sca_appearance.h
|
|
|
|
|
|
|
|
index bd94e14..6ce3112 100644
|
|
|
|
|
|
|
|
--- a/src/modules/sca/sca_appearance.h
|
|
|
|
|
|
|
|
+++ b/src/modules/sca/sca_appearance.h
|
|
|
|
|
|
|
|
@@ -40,7 +40,7 @@ enum
|
|
|
|
|
|
|
|
#define sca_appearance_is_held(app1) \
|
|
|
|
|
|
|
|
((app1) \
|
|
|
|
|
|
|
|
&& ((app1)->state == SCA_APPEARANCE_STATE_HELD \
|
|
|
|
|
|
|
|
- || (app1)->state == SCA_APPEARANCE_STATE_HELD_PRIVATE))
|
|
|
|
|
|
|
|
+ || (app1)->state == SCA_APPEARANCE_STATE_HELD_PRIVATE))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
|
|
|
{
|
|
|
|
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
|
|
|
|
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
|
|
|
|
index 5592efd..4ae93f9 100644
|
|
|
|
index c443f23..867421b 100644
|
|
|
|
--- a/src/modules/sca/sca_call_info.c
|
|
|
|
--- a/src/modules/sca/sca_call_info.c
|
|
|
|
+++ b/src/modules/sca/sca_call_info.c
|
|
|
|
+++ b/src/modules/sca/sca_call_info.c
|
|
|
|
@@ -1798,11 +1798,11 @@ int sca_call_info_update(sip_msg_t *msg, int update_mask, str *uri_to,
|
|
|
|
@@ -1851,11 +1851,11 @@ int sca_call_info_update(
|
|
|
|
str to_aor = STR_NULL;
|
|
|
|
str to_aor = STR_NULL;
|
|
|
|
str contact_uri = STR_NULL;
|
|
|
|
str contact_uri = STR_NULL;
|
|
|
|
int aor_flags = SCA_CALL_INFO_UPDATE_FLAG_DEFAULT;
|
|
|
|
int aor_flags = SCA_CALL_INFO_UPDATE_FLAG_DEFAULT;
|
|
|
|
@ -206,176 +226,233 @@ index 5592efd..4ae93f9 100644
|
|
|
|
|
|
|
|
|
|
|
|
method = sca_get_msg_method(msg);
|
|
|
|
method = sca_get_msg_method(msg);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1846,6 +1846,9 @@ int sca_call_info_update(sip_msg_t *msg, int update_mask, str *uri_to,
|
|
|
|
@@ -1868,7 +1868,7 @@ int sca_call_info_update(
|
|
|
|
|
|
|
|
if(i >= n_dispatch) {
|
|
|
|
|
|
|
|
if(msg->cseq == NULL
|
|
|
|
|
|
|
|
&& ((parse_headers(msg, HDR_CSEQ_F, 0) == -1)
|
|
|
|
|
|
|
|
- || (msg->cseq == NULL))) {
|
|
|
|
|
|
|
|
+ || (msg->cseq == NULL))) {
|
|
|
|
|
|
|
|
LM_ERR("no CSEQ header\n");
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1900,6 +1900,9 @@ int sca_call_info_update(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ delete_avp(from_uri_avp_type|AVP_VAL_STR, from_uri_avp);
|
|
|
|
+ delete_avp(from_uri_avp_type | AVP_VAL_STR, from_uri_avp);
|
|
|
|
+ delete_avp(to_uri_avp_type|AVP_VAL_STR, to_uri_avp);
|
|
|
|
+ delete_avp(to_uri_avp_type | AVP_VAL_STR, to_uri_avp);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
memset(&call_info, 0, sizeof(sca_call_info));
|
|
|
|
memset(&call_info, 0, sizeof(sca_call_info));
|
|
|
|
call_info_hdr = get_hdr(msg, HDR_CALLINFO_T);
|
|
|
|
call_info_hdr = get_hdr(msg, HDR_CALLINFO_T);
|
|
|
|
if (!SCA_HEADER_EMPTY(call_info_hdr)) {
|
|
|
|
if(!SCA_HEADER_EMPTY(call_info_hdr)) {
|
|
|
|
@@ -1858,36 +1861,22 @@ int sca_call_info_update(sip_msg_t *msg, int update_mask, str *uri_to,
|
|
|
|
@@ -1912,34 +1915,22 @@ int sca_call_info_update(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (uri_from != NULL) {
|
|
|
|
if(uri_from != NULL) {
|
|
|
|
- if(sca_build_to_body_from_uri(msg, &from, uri_from)<0){
|
|
|
|
- if(sca_build_to_body_from_uri(msg, &from, uri_from) < 0) {
|
|
|
|
- LM_ERR("Bad From uri from param\n");
|
|
|
|
- LM_ERR("Bad From uri from param\n");
|
|
|
|
- return (-1);
|
|
|
|
- return (-1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ val.s.s = uri_from->s;
|
|
|
|
+ val.s.s = uri_from->s;
|
|
|
|
+ val.s.len = uri_from->len;
|
|
|
|
+ val.s.len = uri_from->len;
|
|
|
|
+ add_avp(from_uri_avp_type|AVP_VAL_STR, from_uri_avp, val);
|
|
|
|
+ add_avp(from_uri_avp_type | AVP_VAL_STR, from_uri_avp, val);
|
|
|
|
LM_DBG("from[%.*s] param\n", STR_FMT(uri_from));
|
|
|
|
LM_DBG("from[%.*s] param\n", STR_FMT(uri_from));
|
|
|
|
- to_body_flags |= SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC;
|
|
|
|
- to_body_flags |= SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC;
|
|
|
|
- if (sca_uri_extract_aor(&from->uri, &from_aor) < 0) {
|
|
|
|
- if(sca_uri_extract_aor(&from->uri, &from_aor) < 0) {
|
|
|
|
- LM_ERR("Failed to extract AoR from From URI %.*s\n",
|
|
|
|
- LM_ERR("Failed to extract AoR from From URI %.*s\n",
|
|
|
|
- STR_FMT(&from->uri));
|
|
|
|
- STR_FMT(&from->uri));
|
|
|
|
- goto done;
|
|
|
|
- goto done;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
|
|
- } else if(sca_get_msg_from_header(msg, &from) < 0) {
|
|
|
|
- else if (sca_get_msg_from_header(msg, &from) < 0) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad From header\n");
|
|
|
|
- LM_ERR("Bad From header\n");
|
|
|
|
+ if (sca_get_msg_from_header(msg, &from) < 0) {
|
|
|
|
+ }
|
|
|
|
+ LM_ERR( "Bad From header" );
|
|
|
|
+ if(sca_get_msg_from_header(msg, &from) < 0) {
|
|
|
|
|
|
|
|
+ LM_ERR("Bad From header");
|
|
|
|
return (-1);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (uri_to != NULL) {
|
|
|
|
if(uri_to != NULL) {
|
|
|
|
- if(sca_build_to_body_from_uri(msg, &to, uri_to)<0){
|
|
|
|
- if(sca_build_to_body_from_uri(msg, &to, uri_to) < 0) {
|
|
|
|
- LM_ERR("Bad From uri to param\n");
|
|
|
|
- LM_ERR("Bad From uri to param\n");
|
|
|
|
- goto done;
|
|
|
|
- goto done;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ val.s.s = uri_to->s;
|
|
|
|
+ val.s.s = uri_to->s;
|
|
|
|
+ val.s.len = uri_to->len;
|
|
|
|
+ val.s.len = uri_to->len;
|
|
|
|
+ add_avp(to_uri_avp_type|AVP_VAL_STR, to_uri_avp, val);
|
|
|
|
+ add_avp(to_uri_avp_type | AVP_VAL_STR, to_uri_avp, val);
|
|
|
|
LM_DBG("to[%.*s] param\n", STR_FMT(uri_to));
|
|
|
|
LM_DBG("to[%.*s] param\n", STR_FMT(uri_to));
|
|
|
|
- to_body_flags |= SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC;
|
|
|
|
- to_body_flags |= SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC;
|
|
|
|
- if (sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
- if(sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
- LM_ERR("Failed to extract AoR from To URI %.*s\n",
|
|
|
|
- LM_ERR("Failed to extract AoR from To URI %.*s\n",
|
|
|
|
- STR_FMT(&to->uri));
|
|
|
|
- STR_FMT(&to->uri));
|
|
|
|
- goto done;
|
|
|
|
- goto done;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
|
|
- } else if(sca_get_msg_to_header(msg, &to) < 0) {
|
|
|
|
- else if (sca_get_msg_to_header(msg, &to) < 0) {
|
|
|
|
+ }
|
|
|
|
+ if (sca_get_msg_to_header(msg, &to) < 0) {
|
|
|
|
+ if(sca_get_msg_to_header(msg, &to) < 0) {
|
|
|
|
LM_ERR("Bad To header\n");
|
|
|
|
LM_ERR("Bad To header\n");
|
|
|
|
goto done;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1916,27 +1905,35 @@ int sca_call_info_update(sip_msg_t *msg, int update_mask, str *uri_to,
|
|
|
|
@@ -1967,27 +1958,34 @@ int sca_call_info_update(
|
|
|
|
goto done;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aor_flags |= SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC;
|
|
|
|
aor_flags |= SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (uri_to==NULL) {
|
|
|
|
- if(uri_to == NULL) {
|
|
|
|
- if (sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
- if(sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
- LM_ERR("Failed to extract AoR from To URI %.*s\n",
|
|
|
|
- LM_ERR("Failed to extract AoR from To URI %.*s\n",
|
|
|
|
- STR_FMT(&to->uri));
|
|
|
|
- STR_FMT(&to->uri));
|
|
|
|
- goto done;
|
|
|
|
- goto done;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- } else {
|
|
|
|
- if (uri_from==NULL) {
|
|
|
|
- if(uri_from == NULL) {
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
if (sca_uri_extract_aor(&from->uri, &from_aor) < 0) {
|
|
|
|
if(sca_uri_extract_aor(&from->uri, &from_aor) < 0) {
|
|
|
|
LM_ERR("Failed to extract AoR from From URI %.*s\n",
|
|
|
|
LM_ERR("Failed to extract AoR from From URI %.*s\n",
|
|
|
|
- STR_FMT(&from->uri));
|
|
|
|
STR_FMT(&from->uri));
|
|
|
|
+ STR_FMT(&from->uri));
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ if (sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
+ if(sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
+ LM_ERR( "Failed to extract AoR from To URI %.*s",
|
|
|
|
+ LM_ERR("Failed to extract AoR from To URI %.*s", STR_FMT(&to->uri));
|
|
|
|
+ STR_FMT(&to->uri));
|
|
|
|
|
|
|
|
+ goto done;
|
|
|
|
+ goto done;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ if (sca_uri_extract_aor(&from->uri, &from_aor) < 0) {
|
|
|
|
+ if(sca_uri_extract_aor(&from->uri, &from_aor) < 0) {
|
|
|
|
+ LM_ERR( "Failed to extract AoR from From URI %.*s",
|
|
|
|
+ LM_ERR("Failed to extract AoR from From URI %.*s",
|
|
|
|
+ STR_FMT(&from->uri));
|
|
|
|
+ STR_FMT(&from->uri));
|
|
|
|
+ goto done;
|
|
|
|
+ goto done;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
if (uri_to==NULL) {
|
|
|
|
if(uri_to == NULL) {
|
|
|
|
if (sca_create_canonical_aor(msg, &to_aor) < 0) {
|
|
|
|
if(sca_create_canonical_aor(msg, &to_aor) < 0) {
|
|
|
|
goto done;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aor_flags |= SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC;
|
|
|
|
aor_flags |= SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC;
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ if ( sca_uri_extract_aor( &to->uri, &to_aor ) < 0 ) {
|
|
|
|
+ if(sca_uri_extract_aor(&to->uri, &to_aor) < 0) {
|
|
|
|
+ LM_ERR( "Failed to extract AoR from To URI %.*s",
|
|
|
|
+ LM_ERR("Failed to extract AoR from To URI %.*s",
|
|
|
|
+ STR_FMT( &to->uri ));
|
|
|
|
+ STR_FMT(&to->uri));
|
|
|
|
+ goto done;
|
|
|
|
+ goto done;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2006,16 +2003,6 @@ int sca_call_info_update(sip_msg_t *msg, int update_mask, str *uri_to,
|
|
|
|
@@ -2058,16 +2056,6 @@ done:
|
|
|
|
pkg_free(to_aor.s);
|
|
|
|
pkg_free(to_aor.s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- if ((to_body_flags & SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC)) {
|
|
|
|
- if((to_body_flags & SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC)) {
|
|
|
|
- if (from != NULL) {
|
|
|
|
- if(from != NULL) {
|
|
|
|
- free_to(from);
|
|
|
|
- free_to(from);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if ((to_body_flags & SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC)) {
|
|
|
|
- if((to_body_flags & SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC)) {
|
|
|
|
- if (to != NULL) {
|
|
|
|
- if(to != NULL) {
|
|
|
|
- free_to(to);
|
|
|
|
- free_to(to);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/modules/sca/sca_call_info.h b/src/modules/sca/sca_call_info.h
|
|
|
|
|
|
|
|
index 914f36f..0f2d53c 100644
|
|
|
|
|
|
|
|
--- a/src/modules/sca/sca_call_info.h
|
|
|
|
|
|
|
|
+++ b/src/modules/sca/sca_call_info.h
|
|
|
|
|
|
|
|
@@ -49,17 +49,17 @@ typedef struct _sca_call_info sca_call_info;
|
|
|
|
|
|
|
|
#define SCA_CALL_INFO_EMPTY(ci1) \
|
|
|
|
|
|
|
|
((void *)(ci1) == NULL \
|
|
|
|
|
|
|
|
|| ((ci1)->index == SCA_CALL_INFO_APPEARANCE_INDEX_ANY \
|
|
|
|
|
|
|
|
- && (ci1)->state == SCA_APPEARANCE_STATE_UNKNOWN))
|
|
|
|
|
|
|
|
+ && (ci1)->state == SCA_APPEARANCE_STATE_UNKNOWN))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SCA_CALL_INFO_IS_SHARED_CALLER(ci1) \
|
|
|
|
|
|
|
|
(!SCA_CALL_INFO_EMPTY((ci1)) \
|
|
|
|
|
|
|
|
&& (((sca_call_info *)(ci1))->ua_shared \
|
|
|
|
|
|
|
|
- & SCA_CALL_INFO_SHARED_CALLER))
|
|
|
|
|
|
|
|
+ & SCA_CALL_INFO_SHARED_CALLER))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SCA_CALL_INFO_IS_SHARED_CALLEE(ci1) \
|
|
|
|
|
|
|
|
(!SCA_CALL_INFO_EMPTY((ci1)) \
|
|
|
|
|
|
|
|
&& (((sca_call_info *)(ci1))->ua_shared \
|
|
|
|
|
|
|
|
- & SCA_CALL_INFO_SHARED_CALLEE))
|
|
|
|
|
|
|
|
+ & SCA_CALL_INFO_SHARED_CALLEE))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern const str SCA_CALL_INFO_HEADER_STR;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/modules/sca/sca_dialog.h b/src/modules/sca/sca_dialog.h
|
|
|
|
|
|
|
|
index d308954..dee234c 100644
|
|
|
|
|
|
|
|
--- a/src/modules/sca/sca_dialog.h
|
|
|
|
|
|
|
|
+++ b/src/modules/sca/sca_dialog.h
|
|
|
|
|
|
|
|
@@ -35,7 +35,7 @@ typedef struct _sca_dialog sca_dialog;
|
|
|
|
|
|
|
|
#define SCA_DIALOG_EMPTY(d) \
|
|
|
|
|
|
|
|
((d) == NULL \
|
|
|
|
|
|
|
|
|| (SCA_STR_EMPTY(&(d)->call_id) && SCA_STR_EMPTY(&(d)->from_tag) \
|
|
|
|
|
|
|
|
- && SCA_STR_EMPTY(&(d)->to_tag)))
|
|
|
|
|
|
|
|
+ && SCA_STR_EMPTY(&(d)->to_tag)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sca_dialog_build_from_tags(sca_dialog *, int, str *, str *, str *);
|
|
|
|
|
|
|
|
int sca_dialog_create_replaces_header(sca_dialog *, str *);
|
|
|
|
diff --git a/src/modules/sca/sca_subscribe.c b/src/modules/sca/sca_subscribe.c
|
|
|
|
diff --git a/src/modules/sca/sca_subscribe.c b/src/modules/sca/sca_subscribe.c
|
|
|
|
index 8040d49..d568729 100644
|
|
|
|
index dc33f00..6d7eb03 100644
|
|
|
|
--- a/src/modules/sca/sca_subscribe.c
|
|
|
|
--- a/src/modules/sca/sca_subscribe.c
|
|
|
|
+++ b/src/modules/sca/sca_subscribe.c
|
|
|
|
+++ b/src/modules/sca/sca_subscribe.c
|
|
|
|
@@ -1005,10 +1005,6 @@ int sca_subscription_from_request(sca_mod *scam, sip_msg_t *msg, int event_type,
|
|
|
|
@@ -844,8 +844,8 @@ static int sca_subscription_update_unsafe(sca_mod *scam,
|
|
|
|
|
|
|
|
// this is allocated separately from the rest of the subscription
|
|
|
|
|
|
|
|
len = sizeof(char *)
|
|
|
|
|
|
|
|
* (update_sub->dialog.call_id.len
|
|
|
|
|
|
|
|
- + update_sub->dialog.from_tag.len
|
|
|
|
|
|
|
|
- + update_sub->dialog.to_tag.len);
|
|
|
|
|
|
|
|
+ + update_sub->dialog.from_tag.len
|
|
|
|
|
|
|
|
+ + update_sub->dialog.to_tag.len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dlg_id_tmp = (char *)shm_malloc(len);
|
|
|
|
|
|
|
|
if(dlg_id_tmp == NULL) {
|
|
|
|
|
|
|
|
@@ -1023,10 +1023,6 @@ int sca_subscription_from_request(sca_mod *scam, sip_msg_t *msg, int event_type,
|
|
|
|
expires = max_expires;
|
|
|
|
expires = max_expires;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- if (SCA_HEADER_EMPTY(msg->to)) {
|
|
|
|
- if(SCA_HEADER_EMPTY(msg->to)) {
|
|
|
|
- LM_ERR("Empty To header\n");
|
|
|
|
- LM_ERR("Empty To header\n");
|
|
|
|
- goto error;
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
if (SCA_HEADER_EMPTY(msg->callid)) {
|
|
|
|
if(SCA_HEADER_EMPTY(msg->callid)) {
|
|
|
|
LM_ERR("Empty Call-ID header\n");
|
|
|
|
LM_ERR("Empty Call-ID header\n");
|
|
|
|
goto error;
|
|
|
|
goto error;
|
|
|
|
@@ -1030,29 +1026,18 @@ int sca_subscription_from_request(sca_mod *scam, sip_msg_t *msg, int event_type,
|
|
|
|
@@ -1048,30 +1044,18 @@ int sca_subscription_from_request(sca_mod *scam, sip_msg_t *msg, int event_type,
|
|
|
|
goto error;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- if (SCA_HEADER_EMPTY(msg->from)) {
|
|
|
|
- if(SCA_HEADER_EMPTY(msg->from)) {
|
|
|
|
- LM_ERR("Empty From header\n");
|
|
|
|
- LM_ERR("Empty From header\n");
|
|
|
|
- goto error;
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (parse_from_header(msg) < 0) {
|
|
|
|
- if(parse_from_header(msg) < 0) {
|
|
|
|
+ if (sca_get_msg_from_header(msg, &from) < 0) {
|
|
|
|
+ if(sca_get_msg_from_header(msg, &from) < 0) {
|
|
|
|
LM_ERR("Bad From header\n");
|
|
|
|
LM_ERR("Bad From header\n");
|
|
|
|
goto error;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- from = (struct to_body *) msg->from->parsed;
|
|
|
|
- from = (struct to_body *)msg->from->parsed;
|
|
|
|
if (SCA_STR_EMPTY(&from->tag_value)) {
|
|
|
|
if(SCA_STR_EMPTY(&from->tag_value)) {
|
|
|
|
LM_ERR("No from-tag in From header\n");
|
|
|
|
LM_ERR("No from-tag in From header\n");
|
|
|
|
goto error;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- if ((to = (struct to_body *) msg->to->parsed) == NULL) {
|
|
|
|
- if((to = (struct to_body *)msg->to->parsed) == NULL) {
|
|
|
|
- parse_to(msg->to->body.s, msg->to->body.s + msg->to->body.len + 1, // end of buffer
|
|
|
|
- parse_to(msg->to->body.s,
|
|
|
|
- &tmp_to);
|
|
|
|
- msg->to->body.s + msg->to->body.len + 1, // end of buffer
|
|
|
|
|
|
|
|
- &tmp_to);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (tmp_to.error != PARSE_OK) {
|
|
|
|
- if(tmp_to.error != PARSE_OK) {
|
|
|
|
- LM_ERR("Bad To header\n");
|
|
|
|
- LM_ERR("Bad To header\n");
|
|
|
|
- goto error;
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- to = &tmp_to;
|
|
|
|
- to = &tmp_to;
|
|
|
|
+ if ( sca_get_msg_to_header( msg, &to ) < 0 ) {
|
|
|
|
+ if(sca_get_msg_to_header(msg, &to) < 0) {
|
|
|
|
+ LM_ERR( "Bad To header" );
|
|
|
|
+ LM_ERR("Bad To header");
|
|
|
|
+ goto error;
|
|
|
|
+ goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (parse_sip_msg_uri(msg) < 0) {
|
|
|
|
if(parse_sip_msg_uri(msg) < 0) {
|
|
|
|
@@ -1135,7 +1120,7 @@ int sca_subscription_from_request(sca_mod *scam, sip_msg_t *msg, int event_type,
|
|
|
|
@@ -1153,7 +1137,7 @@ error:
|
|
|
|
return (-1);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -384,46 +461,46 @@ index 8040d49..d568729 100644
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sca_subscription req_sub;
|
|
|
|
sca_subscription req_sub;
|
|
|
|
sca_subscription *sub = NULL;
|
|
|
|
sca_subscription *sub = NULL;
|
|
|
|
@@ -1150,6 +1135,8 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
@@ -1168,6 +1152,8 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
int idx = -1;
|
|
|
|
int idx = -1;
|
|
|
|
int rc = -1;
|
|
|
|
int rc = -1;
|
|
|
|
int released = 0;
|
|
|
|
int released = 0;
|
|
|
|
+ int_str val;
|
|
|
|
+ int_str val;
|
|
|
|
+ struct to_body *tmp_to;
|
|
|
|
+ struct to_body *tmp_to;
|
|
|
|
|
|
|
|
|
|
|
|
if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
|
|
|
|
if(parse_headers(msg, HDR_EOH_F, 0) < 0) {
|
|
|
|
LM_ERR("header parsing failed: bad request\n");
|
|
|
|
LM_ERR("header parsing failed: bad request\n");
|
|
|
|
@@ -1174,6 +1161,21 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
@@ -1192,6 +1178,21 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
return (-1);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ delete_avp(from_uri_avp_type|AVP_VAL_STR, from_uri_avp);
|
|
|
|
+ delete_avp(from_uri_avp_type | AVP_VAL_STR, from_uri_avp);
|
|
|
|
+ delete_avp(to_uri_avp_type|AVP_VAL_STR, to_uri_avp);
|
|
|
|
+ delete_avp(to_uri_avp_type | AVP_VAL_STR, to_uri_avp);
|
|
|
|
+ if (uri_from != NULL) {
|
|
|
|
+ if(uri_from != NULL) {
|
|
|
|
+ val.s.s = uri_from->s;
|
|
|
|
+ val.s.s = uri_from->s;
|
|
|
|
+ val.s.len = uri_from->len;
|
|
|
|
+ val.s.len = uri_from->len;
|
|
|
|
+ add_avp(from_uri_avp_type|AVP_VAL_STR, from_uri_avp, val);
|
|
|
|
+ add_avp(from_uri_avp_type | AVP_VAL_STR, from_uri_avp, val);
|
|
|
|
+ LM_DBG("from[%.*s] param\n", STR_FMT(uri_from));
|
|
|
|
+ LM_DBG("from[%.*s] param\n", STR_FMT(uri_from));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (uri_to != NULL) {
|
|
|
|
+ if(uri_to != NULL) {
|
|
|
|
+ val.s.s = uri_to->s;
|
|
|
|
+ val.s.s = uri_to->s;
|
|
|
|
+ val.s.len = uri_to->len;
|
|
|
|
+ val.s.len = uri_to->len;
|
|
|
|
+ add_avp(to_uri_avp_type|AVP_VAL_STR, to_uri_avp, val);
|
|
|
|
+ add_avp(to_uri_avp_type | AVP_VAL_STR, to_uri_avp, val);
|
|
|
|
+ LM_DBG("to[%.*s] param\n", STR_FMT(uri_to));
|
|
|
|
+ LM_DBG("to[%.*s] param\n", STR_FMT(uri_to));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
if (sca_subscription_from_request(sca, msg, event_type, &req_sub) < 0) {
|
|
|
|
if(sca_subscription_from_request(sca, msg, event_type, &req_sub) < 0) {
|
|
|
|
SCA_SUB_REPLY_ERROR(sca, 400, "Bad Shared Call Appearance Request",
|
|
|
|
SCA_SUB_REPLY_ERROR(
|
|
|
|
msg);
|
|
|
|
sca, 400, "Bad Shared Call Appearance Request", msg);
|
|
|
|
@@ -1187,7 +1189,15 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
@@ -1207,7 +1208,15 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
sca_subscription_print(&req_sub);
|
|
|
|
sca_subscription_print(&req_sub);
|
|
|
|
|
|
|
|
|
|
|
|
// check to see if the message has a to-tag
|
|
|
|
// check to see if the message has a to-tag
|
|
|
|
- to_tag = &(get_to(msg)->tag_value);
|
|
|
|
- to_tag = &(get_to(msg)->tag_value);
|
|
|
|
+ if(uri_to!=NULL) {
|
|
|
|
+ if(uri_to != NULL) {
|
|
|
|
+ if (sca_get_msg_to_header(msg, &tmp_to) < 0) {
|
|
|
|
+ if(sca_get_msg_to_header(msg, &tmp_to) < 0) {
|
|
|
|
+ LM_ERR( "Bad To header" );
|
|
|
|
+ LM_ERR("Bad To header");
|
|
|
|
+ return(-1);
|
|
|
|
+ return (-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ to_tag = &(tmp_to->tag_value);
|
|
|
|
+ to_tag = &(tmp_to->tag_value);
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
@ -432,7 +509,7 @@ index 8040d49..d568729 100644
|
|
|
|
|
|
|
|
|
|
|
|
// XXX should lock starting here and use unsafe methods below?
|
|
|
|
// XXX should lock starting here and use unsafe methods below?
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1354,9 +1364,9 @@ int ki_sca_handle_subscribe(sip_msg_t *msg)
|
|
|
|
@@ -1391,9 +1400,9 @@ done:
|
|
|
|
return (rc);
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -445,49 +522,74 @@ index 8040d49..d568729 100644
|
|
|
|
|
|
|
|
|
|
|
|
int sca_subscription_reply(sca_mod *scam, int status_code, char *status_msg,
|
|
|
|
int sca_subscription_reply(sca_mod *scam, int status_code, char *status_msg,
|
|
|
|
diff --git a/src/modules/sca/sca_subscribe.h b/src/modules/sca/sca_subscribe.h
|
|
|
|
diff --git a/src/modules/sca/sca_subscribe.h b/src/modules/sca/sca_subscribe.h
|
|
|
|
index e919717..5ee2cbc 100644
|
|
|
|
index e27883e..44f93b7 100644
|
|
|
|
--- a/src/modules/sca/sca_subscribe.h
|
|
|
|
--- a/src/modules/sca/sca_subscribe.h
|
|
|
|
+++ b/src/modules/sca/sca_subscribe.h
|
|
|
|
+++ b/src/modules/sca/sca_subscribe.h
|
|
|
|
@@ -75,7 +75,7 @@ extern const str SCA_METHOD_SUBSCRIBE;
|
|
|
|
@@ -50,7 +50,7 @@ struct _sca_subscription
|
|
|
|
sca_subscription_reply((mod), (scode), (smsg), \
|
|
|
|
str rr; // Record-Route header values
|
|
|
|
SCA_EVENT_TYPE_CALL_INFO, -1, (sreply))
|
|
|
|
|
|
|
|
|
|
|
|
int db_cmd_flag; // track whether to INSERT or UPDATE
|
|
|
|
|
|
|
|
- int server_id; // server
|
|
|
|
|
|
|
|
+ int server_id; // server
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _sca_subscription sca_subscription;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -79,7 +79,7 @@ extern const str SCA_METHOD_SUBSCRIBE;
|
|
|
|
|
|
|
|
sca_subscription_reply( \
|
|
|
|
|
|
|
|
(mod), (scode), (smsg), SCA_EVENT_TYPE_CALL_INFO, -1, (sreply))
|
|
|
|
|
|
|
|
|
|
|
|
-int sca_handle_subscribe(sip_msg_t *, char *, char *);
|
|
|
|
-int sca_handle_subscribe(sip_msg_t *, char *, char *);
|
|
|
|
+int sca_handle_subscribe(sip_msg_t *, str *, str *);
|
|
|
|
+int sca_handle_subscribe(sip_msg_t *, str *, str *);
|
|
|
|
int sca_subscription_reply(sca_mod *, int, char *, int, int, sip_msg_t *);
|
|
|
|
int sca_subscription_reply(sca_mod *, int, char *, int, int, sip_msg_t *);
|
|
|
|
|
|
|
|
|
|
|
|
int sca_subscription_from_db_result(db1_res_t *, sca_subscription *);
|
|
|
|
int sca_subscription_from_db_result(db1_res_t *, sca_subscription *);
|
|
|
|
@@ -88,6 +88,6 @@ void sca_subscription_state_to_str(int, str *);
|
|
|
|
@@ -93,6 +93,6 @@ int sca_subscription_aor_has_subscribers(int, str *);
|
|
|
|
int sca_subscription_aor_has_subscribers(int, str *);
|
|
|
|
int sca_subscription_delete_subscriber_for_event(
|
|
|
|
int sca_subscription_delete_subscriber_for_event(sca_mod *, str *, str *, str *);
|
|
|
|
sca_mod *, str *, str *, str *);
|
|
|
|
int sca_subscription_terminate(sca_mod *, str *, int, str *, int, int);
|
|
|
|
int sca_subscription_terminate(sca_mod *, str *, int, str *, int, int);
|
|
|
|
-int ki_sca_handle_subscribe(sip_msg_t *msg);
|
|
|
|
-int ki_sca_handle_subscribe(sip_msg_t *msg);
|
|
|
|
+int ki_sca_handle_subscribe(sip_msg_t *msg, str *, str *);
|
|
|
|
+int ki_sca_handle_subscribe(sip_msg_t *msg, str *, str *);
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SCA_SUBSCRIBE_H
|
|
|
|
#endif // SCA_SUBSCRIBE_H
|
|
|
|
diff --git a/src/modules/sca/sca_util.c b/src/modules/sca/sca_util.c
|
|
|
|
diff --git a/src/modules/sca/sca_util.c b/src/modules/sca/sca_util.c
|
|
|
|
index b586c8f..46d04c5 100644
|
|
|
|
index 4ab4c6f..e1ef561 100644
|
|
|
|
--- a/src/modules/sca/sca_util.c
|
|
|
|
--- a/src/modules/sca/sca_util.c
|
|
|
|
+++ b/src/modules/sca/sca_util.c
|
|
|
|
+++ b/src/modules/sca/sca_util.c
|
|
|
|
@@ -112,93 +112,118 @@ int sca_get_msg_cseq_method(sip_msg_t *msg)
|
|
|
|
@@ -112,94 +112,123 @@ int sca_get_msg_cseq_method(sip_msg_t *msg)
|
|
|
|
return (get_cseq(msg)->method_id);
|
|
|
|
return (get_cseq(msg)->method_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-int sca_get_msg_from_header(sip_msg_t *msg, struct to_body **from)
|
|
|
|
-int sca_get_msg_from_header(sip_msg_t *msg, struct to_body **from)
|
|
|
|
+int sca_get_avp_value(unsigned short avp_type, int_str avp, str *result) {
|
|
|
|
+int sca_get_avp_value(unsigned short avp_type, int_str avp, str *result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
- struct to_body *f;
|
|
|
|
+ int_str val;
|
|
|
|
+ int_str val;
|
|
|
|
+ struct usr_avp *_avp;
|
|
|
|
+ struct usr_avp *_avp;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
- assert(msg != NULL);
|
|
|
|
|
|
|
|
- assert(from != NULL);
|
|
|
|
+ assert(result != NULL);
|
|
|
|
+ assert(result != NULL);
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if (avp.s.len > 0) {
|
|
|
|
- if(SCA_HEADER_EMPTY(msg->from)) {
|
|
|
|
|
|
|
|
- LM_ERR("Empty From header\n");
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if(parse_from_header(msg) < 0) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad From header\n");
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- f = get_from(msg);
|
|
|
|
|
|
|
|
- if(SCA_STR_EMPTY(&f->tag_value)) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad From header: no tag parameter\n");
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
+ if(avp.s.len > 0) {
|
|
|
|
+ _avp = search_first_avp(avp_type, avp, &val, 0);
|
|
|
|
+ _avp = search_first_avp(avp_type, avp, &val, 0);
|
|
|
|
+ if(_avp) {
|
|
|
|
+ if(_avp) {
|
|
|
|
+ result->s = val.s.s;
|
|
|
|
+ result->s = val.s.s;
|
|
|
|
+ result->len = val.s.len;
|
|
|
|
+ result->len = val.s.len;
|
|
|
|
+ return 0;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ return -1;
|
|
|
|
+ return -1;
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
@ -495,160 +597,148 @@ index b586c8f..46d04c5 100644
|
|
|
|
+ * caller needs to call free_to for *body
|
|
|
|
+ * caller needs to call free_to for *body
|
|
|
|
+ */
|
|
|
|
+ */
|
|
|
|
+int sca_parse_uri(struct to_body *body, str *uri)
|
|
|
|
+int sca_parse_uri(struct to_body *body, str *uri)
|
|
|
|
{
|
|
|
|
+{
|
|
|
|
+ assert(body != NULL);
|
|
|
|
+ assert(body != NULL);
|
|
|
|
+ assert(uri != NULL);
|
|
|
|
+ assert(uri != NULL);
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
- // ensure the URI is parsed for future use
|
|
|
|
|
|
|
|
- if(parse_uri(f->uri.s, f->uri.len, GET_FROM_PURI(msg)) < 0) {
|
|
|
|
|
|
|
|
- LM_ERR("Failed to parse From URI %.*s\n", STR_FMT(&f->uri));
|
|
|
|
+ parse_to(uri->s, uri->s + uri->len + 1, body);
|
|
|
|
+ parse_to(uri->s, uri->s + uri->len + 1, body);
|
|
|
|
+ if (body->error != PARSE_OK) {
|
|
|
|
+ if(body->error != PARSE_OK) {
|
|
|
|
+ LM_ERR("Bad uri value[%.*s]\n", STR_FMT(uri));
|
|
|
|
+ LM_ERR("Bad uri value[%.*s]\n", STR_FMT(uri));
|
|
|
|
+ return(-1);
|
|
|
|
return (-1);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ return (0);
|
|
|
|
-
|
|
|
|
+}
|
|
|
|
- *from = f;
|
|
|
|
+
|
|
|
|
-
|
|
|
|
+int sca_get_msg_from_header( sip_msg_t *msg, struct to_body **from ) {
|
|
|
|
return (0);
|
|
|
|
struct to_body *f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-int sca_get_msg_to_header(sip_msg_t *msg, struct to_body **to)
|
|
|
|
|
|
|
|
+int sca_get_msg_from_header(sip_msg_t *msg, struct to_body **from)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
- struct to_body parsed_to;
|
|
|
|
|
|
|
|
- struct to_body *t = NULL;
|
|
|
|
|
|
|
|
+ struct to_body *f;
|
|
|
|
+ static struct to_body sf;
|
|
|
|
+ static struct to_body sf;
|
|
|
|
+ str uri = STR_NULL;
|
|
|
|
+ str uri = STR_NULL;
|
|
|
|
|
|
|
|
|
|
|
|
- assert(msg != NULL);
|
|
|
|
- assert(msg != NULL);
|
|
|
|
assert(from != NULL);
|
|
|
|
- assert(to != NULL);
|
|
|
|
|
|
|
|
+ assert(from != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
- if (SCA_HEADER_EMPTY(msg->from)) {
|
|
|
|
- if(SCA_HEADER_EMPTY(msg->to)) {
|
|
|
|
- LM_ERR("Empty From header\n");
|
|
|
|
- LM_ERR("Empty To header\n");
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (parse_from_header(msg) < 0) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad From header\n");
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- f = get_from(msg);
|
|
|
|
|
|
|
|
- if (SCA_STR_EMPTY(&f->tag_value)) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad From header: no tag parameter\n");
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
- return (-1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ if(sca_get_avp_value(from_uri_avp_type, from_uri_avp, &uri)<0) {
|
|
|
|
- t = get_to(msg);
|
|
|
|
+ assert( msg != NULL );
|
|
|
|
- if(t == NULL) {
|
|
|
|
+ if (SCA_HEADER_EMPTY(msg->from)) {
|
|
|
|
- parse_to(msg->to->body.s,
|
|
|
|
|
|
|
|
- msg->to->body.s + msg->to->body.len + 1, // end of buffer
|
|
|
|
|
|
|
|
- &parsed_to);
|
|
|
|
|
|
|
|
- if(parsed_to.error != PARSE_OK) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad To header\n");
|
|
|
|
|
|
|
|
+ if(sca_get_avp_value(from_uri_avp_type, from_uri_avp, &uri) < 0) {
|
|
|
|
|
|
|
|
+ assert(msg != NULL);
|
|
|
|
|
|
|
|
+ if(SCA_HEADER_EMPTY(msg->from)) {
|
|
|
|
+ LM_ERR("Empty From header\n");
|
|
|
|
+ LM_ERR("Empty From header\n");
|
|
|
|
+ return (-1);
|
|
|
|
+ return (-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (parse_from_header(msg) < 0) {
|
|
|
|
+ if(parse_from_header(msg) < 0) {
|
|
|
|
+ LM_ERR("Bad From header\n");
|
|
|
|
+ LM_ERR("Bad From header\n");
|
|
|
|
+ return (-1);
|
|
|
|
+ return (-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ f = get_from(msg);
|
|
|
|
+ f = get_from(msg);
|
|
|
|
+ if (SCA_STR_EMPTY(&f->tag_value)) {
|
|
|
|
+ if(SCA_STR_EMPTY(&f->tag_value)) {
|
|
|
|
+ LM_ERR("Bad From header: no tag parameter\n");
|
|
|
|
+ LM_ERR("Bad From header: no tag parameter\n");
|
|
|
|
+ return (-1);
|
|
|
|
return (-1);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
- t = &parsed_to;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
- // ensure the URI is parsed for future use
|
|
|
|
- // ensure the URI is parsed for future use
|
|
|
|
- if (parse_uri(f->uri.s, f->uri.len, GET_FROM_PURI(msg)) < 0) {
|
|
|
|
- if(parse_uri(t->uri.s, t->uri.len, GET_TO_PURI(msg)) < 0) {
|
|
|
|
- LM_ERR("Failed to parse From URI %.*s\n", STR_FMT(&f->uri));
|
|
|
|
- LM_ERR("Failed to parse To URI %.*s\n", STR_FMT(&t->uri));
|
|
|
|
- return (-1);
|
|
|
|
- return (-1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ // ensure the URI is parsed for future use
|
|
|
|
+ // ensure the URI is parsed for future use
|
|
|
|
+ if (parse_uri(f->uri.s, f->uri.len, GET_FROM_PURI(msg)) < 0) {
|
|
|
|
+ if(parse_uri(f->uri.s, f->uri.len, GET_FROM_PURI(msg)) < 0) {
|
|
|
|
+ LM_ERR("Failed to parse From URI %.*s\n", STR_FMT(&f->uri));
|
|
|
|
+ LM_ERR("Failed to parse From URI %.*s\n", STR_FMT(&f->uri));
|
|
|
|
+ return (-1);
|
|
|
|
+ return (-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
- *from = f;
|
|
|
|
- *to = t;
|
|
|
|
+ *from = f;
|
|
|
|
+ *from = f;
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ LM_DBG("using $avp(%.*s)[%.*s] as from uri\n",
|
|
|
|
+ LM_DBG("using $avp(%.*s)[%.*s] as from uri\n", STR_FMT(&from_uri_avp.s),
|
|
|
|
+ STR_FMT(&from_uri_avp.s), STR_FMT(&uri));
|
|
|
|
+ STR_FMT(&uri));
|
|
|
|
+ if(sca_parse_uri(&sf, &uri)<0) return -1;
|
|
|
|
+ if(sca_parse_uri(&sf, &uri) < 0)
|
|
|
|
|
|
|
|
+ return -1;
|
|
|
|
+ *from = &sf;
|
|
|
|
+ *from = &sf;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int sca_get_msg_to_header(sip_msg_t *msg, struct to_body **to)
|
|
|
|
-/*
|
|
|
|
|
|
|
|
- * caller needs to call free_to for *body
|
|
|
|
|
|
|
|
- */
|
|
|
|
|
|
|
|
-int sca_build_to_body_from_uri(sip_msg_t *msg, struct to_body **body, str *uri)
|
|
|
|
|
|
|
|
+int sca_get_msg_to_header(sip_msg_t *msg, struct to_body **to)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
- struct to_body parsed_to;
|
|
|
|
- assert(msg != NULL);
|
|
|
|
|
|
|
|
- assert(body != NULL);
|
|
|
|
|
|
|
|
- assert(uri != NULL);
|
|
|
|
+ static struct to_body parsed_to;
|
|
|
|
+ static struct to_body parsed_to;
|
|
|
|
struct to_body *t = NULL;
|
|
|
|
+ struct to_body *t = NULL;
|
|
|
|
+ str uri = STR_NULL;
|
|
|
|
+ str uri = STR_NULL;
|
|
|
|
|
|
|
|
|
|
|
|
- assert(msg != NULL);
|
|
|
|
- *body = pkg_malloc(sizeof(struct to_body));
|
|
|
|
assert(to != NULL);
|
|
|
|
- if(*body == NULL) {
|
|
|
|
+ if(sca_get_avp_value(to_uri_avp_type, to_uri_avp, &uri)<0) {
|
|
|
|
- LM_ERR("cannot allocate pkg memory\n");
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
+ assert(to != NULL);
|
|
|
|
|
|
|
|
+ if(sca_get_avp_value(to_uri_avp_type, to_uri_avp, &uri) < 0) {
|
|
|
|
+ assert(msg != NULL);
|
|
|
|
+ assert(msg != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
- if (SCA_HEADER_EMPTY(msg->to)) {
|
|
|
|
- parse_to(uri->s, uri->s + uri->len + 1, *body);
|
|
|
|
- LM_ERR("Empty To header\n");
|
|
|
|
- if((*body)->error != PARSE_OK) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad uri value[%.*s]\n", STR_FMT(uri));
|
|
|
|
|
|
|
|
- free_to(*body);
|
|
|
|
- return (-1);
|
|
|
|
- return (-1);
|
|
|
|
- }
|
|
|
|
+ if(SCA_HEADER_EMPTY(msg->to)) {
|
|
|
|
- t = get_to(msg);
|
|
|
|
|
|
|
|
- if (t == NULL) {
|
|
|
|
|
|
|
|
- parse_to(msg->to->body.s, msg->to->body.s + msg->to->body.len + 1, // end of buffer
|
|
|
|
|
|
|
|
- &parsed_to);
|
|
|
|
|
|
|
|
- if (parsed_to.error != PARSE_OK) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad To header\n");
|
|
|
|
|
|
|
|
+ if (SCA_HEADER_EMPTY(msg->to)) {
|
|
|
|
|
|
|
|
+ LM_ERR("Empty To header\n");
|
|
|
|
+ LM_ERR("Empty To header\n");
|
|
|
|
return (-1);
|
|
|
|
+ return (-1);
|
|
|
|
}
|
|
|
|
+ }
|
|
|
|
- t = &parsed_to;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- // ensure the URI is parsed for future use
|
|
|
|
|
|
|
|
- if (parse_uri(t->uri.s, t->uri.len, GET_TO_PURI(msg)) < 0) {
|
|
|
|
|
|
|
|
- LM_ERR("Failed to parse To URI %.*s\n", STR_FMT(&t->uri));
|
|
|
|
|
|
|
|
- return (-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- *to = t;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- return (0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
+ t = get_to(msg);
|
|
|
|
+ t = get_to(msg);
|
|
|
|
+ if (t == NULL) {
|
|
|
|
+ if(t == NULL) {
|
|
|
|
+ parse_to(msg->to->body.s, msg->to->body.s + msg->to->body.len + 1, // end of buffer
|
|
|
|
+ parse_to(msg->to->body.s,
|
|
|
|
+ &parsed_to);
|
|
|
|
+ msg->to->body.s + msg->to->body.len + 1, // end of buffer
|
|
|
|
+ if (parsed_to.error != PARSE_OK) {
|
|
|
|
+ &parsed_to);
|
|
|
|
|
|
|
|
+ if(parsed_to.error != PARSE_OK) {
|
|
|
|
+ LM_ERR("Bad To header\n");
|
|
|
|
+ LM_ERR("Bad To header\n");
|
|
|
|
+ return (-1);
|
|
|
|
+ return (-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ t = &parsed_to;
|
|
|
|
+ t = &parsed_to;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
-/*
|
|
|
|
|
|
|
|
- * caller needs to call free_to for *body
|
|
|
|
|
|
|
|
- */
|
|
|
|
|
|
|
|
-int sca_build_to_body_from_uri(sip_msg_t *msg, struct to_body **body, str *uri)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- assert(msg != NULL);
|
|
|
|
|
|
|
|
- assert(body != NULL);
|
|
|
|
|
|
|
|
- assert(uri != NULL);
|
|
|
|
|
|
|
|
+ // ensure the URI is parsed for future use
|
|
|
|
+ // ensure the URI is parsed for future use
|
|
|
|
+ if (parse_uri(t->uri.s, t->uri.len, GET_TO_PURI(msg)) < 0) {
|
|
|
|
+ if(parse_uri(t->uri.s, t->uri.len, GET_TO_PURI(msg)) < 0) {
|
|
|
|
+ LM_ERR("Failed to parse To URI %.*s\n", STR_FMT(&t->uri));
|
|
|
|
+ LM_ERR("Failed to parse To URI %.*s\n", STR_FMT(&t->uri));
|
|
|
|
+ return (-1);
|
|
|
|
+ return (-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
- *body = pkg_malloc(sizeof(struct to_body));
|
|
|
|
|
|
|
|
- if(*body == NULL) {
|
|
|
|
|
|
|
|
- LM_ERR("cannot allocate pkg memory\n");
|
|
|
|
|
|
|
|
- return(-1);
|
|
|
|
|
|
|
|
+ *to = t;
|
|
|
|
+ *to = t;
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ LM_DBG("using $avp(%.*s)[%.*s] as to uri\n",
|
|
|
|
+ LM_DBG("using $avp(%.*s)[%.*s] as to uri\n", STR_FMT(&to_uri_avp.s),
|
|
|
|
+ STR_FMT(&to_uri_avp.s), STR_FMT(&uri));
|
|
|
|
+ STR_FMT(&uri));
|
|
|
|
+ if(sca_parse_uri(&parsed_to, &uri)<0) return -1;
|
|
|
|
+ if(sca_parse_uri(&parsed_to, &uri) < 0)
|
|
|
|
|
|
|
|
+ return -1;
|
|
|
|
+ *to = &parsed_to;
|
|
|
|
+ *to = &parsed_to;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
- parse_to(uri->s, uri->s + uri->len + 1, *body);
|
|
|
|
|
|
|
|
- if ((*body)->error != PARSE_OK) {
|
|
|
|
|
|
|
|
- LM_ERR("Bad uri value[%.*s]\n", STR_FMT(uri));
|
|
|
|
|
|
|
|
- free_to(*body);
|
|
|
|
|
|
|
|
- return(-1);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|