Module: sip-router
Branch: master
Commit: 934adcfb97f2e92e8bde695538e0e0b289ba3614
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=934adcf…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Wed Aug 17 13:35:53 2011 +0200
Adapt multiple modules relying on the dialog module to latest
dialog changes.
- modules_k/nat_traversal: Register for DLGCB_CONFIRMED_NA
(formerly called DLGCB_CONFIRMED; see commit e1068cb0ab4 for
details).
- modules_k/pua_dialoginfo:
* In __dialog_cbtest(), make sure that valid SIP message is
used.
* In __dialog_cbtest(), print details for callback on
DLGCB_CONFIRMED_NA too.
* In __dialog_created(), register to DLGCB_CONFIRMED_NA in
normal case and additionally to DLGCB_CONFIRMED_NA in debug
case (PUA_DIALOGINFO_DEBUG enabled).
- modules_k/sst:
* Use reply message from dialog callback parameters in
sst_dialog_confirmed_CB().
* Register to DLGCB_CONFIRMED_NA instead of DLGCB_CONFIRMED.
---
modules_k/nat_traversal/nat_traversal.c | 2 +-
modules_k/pua_dialoginfo/pua_dialoginfo.c | 44 +++++++++++++++++-----------
modules_k/sst/sst_handlers.c | 4 +-
3 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/modules_k/nat_traversal/nat_traversal.c
b/modules_k/nat_traversal/nat_traversal.c
index cc65354..62227e4 100644
--- a/modules_k/nat_traversal/nat_traversal.c
+++ b/modules_k/nat_traversal/nat_traversal.c
@@ -1248,7 +1248,7 @@ __dialog_created(struct dlg_cell *dlg, int type, struct
dlg_cb_params *_params)
if (dlg_api.register_dlgcb(dlg, DLGCB_EARLY, __dialog_early, param, NULL) != 0)
LM_ERR("cannot register callback for dialog early replies\n");
- if (dlg_api.register_dlgcb(dlg, DLGCB_CONFIRMED, __dialog_confirmed, param, NULL) !=
0)
+ if (dlg_api.register_dlgcb(dlg, DLGCB_CONFIRMED_NA, __dialog_confirmed, param, NULL)
!= 0)
LM_ERR("cannot register callback for dialog confirmation\n");
if ((request->msg_flags & FL_DO_KEEPALIVE) == 0)
diff --git a/modules_k/pua_dialoginfo/pua_dialoginfo.c
b/modules_k/pua_dialoginfo/pua_dialoginfo.c
index f2731c0..792e3b0 100644
--- a/modules_k/pua_dialoginfo/pua_dialoginfo.c
+++ b/modules_k/pua_dialoginfo/pua_dialoginfo.c
@@ -120,6 +120,7 @@ static void
__dialog_cbtest(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
{
str tag;
+ struct sip_msg *msg;
LM_ERR("dialog callback received, from=%.*s, to=%.*s\n", dlg->from_uri.len,
dlg->from_uri.s, dlg->to_uri.len, dlg->to_uri.s);
if (dlg->tag[0].len && dlg->tag[0].s ) {
LM_ERR("dialog callback: tag[0] = %.*s", dlg->tag[0].len,
dlg->tag[0].s);
@@ -129,24 +130,30 @@ __dialog_cbtest(struct dlg_cell *dlg, int type, struct dlg_cb_params
*_params)
}
if (type != DLGCB_DESTROY) {
+ msg = get_valid_msg(_params);
+ if (!msg) {
+ LM_ERR("no SIP message available in callback parameters\n");
+ return;
+ }
+
/* get to tag*/
- if ( !_params->msg->to) {
+ if ( !msg->to) {
// to header not defined, parse to header
LM_ERR("to header not defined, parse to header\n");
- if (parse_headers(_params->msg, HDR_TO_F,0)<0) {
+ if (parse_headers(msg, HDR_TO_F,0)<0) {
//parser error
LM_ERR("parsing of to-header failed\n");
tag.s = 0;
tag.len = 0;
- } else if (!_params->msg->to) {
+ } else if (!msg->to) {
// to header still not defined
LM_ERR("no to although to-header is parsed: bad reply or missing TO hdr
:-/\n");
tag.s = 0;
tag.len = 0;
} else
- tag = get_to(_params->msg)->tag_value;
+ tag = get_to(msg)->tag_value;
} else {
- tag = get_to(_params->msg)->tag_value;
+ tag = get_to(msg)->tag_value;
if (tag.s==0 || tag.len==0) {
LM_ERR("missing TAG param in TO hdr :-/\n");
tag.s = 0;
@@ -154,7 +161,7 @@ if (type != DLGCB_DESTROY) {
}
}
if (tag.s) {
- LM_ERR("dialog callback: _params->msg->to->parsed->tag_value =
%.*s", tag.len, tag.s);
+ LM_ERR("dialog callback: msg->to->parsed->tag_value = %.*s",
tag.len, tag.s);
}
}
@@ -162,6 +169,9 @@ if (type != DLGCB_DESTROY) {
case DLGCB_FAILED:
LM_ERR("dialog callback type 'DLGCB_FAILED' received, from=%.*s\n",
dlg->from_uri.len, dlg->from_uri.s);
break;
+ case DLGCB_CONFIRMED_NA:
+ LM_ERR("dialog callback type 'DLGCB_CONFIRMED_NA' received,
from=%.*s\n", dlg->from_uri.len, dlg->from_uri.s);
+ break;
case DLGCB_CONFIRMED:
LM_ERR("dialog callback type 'DLGCB_CONFIRMED' received,
from=%.*s\n", dlg->from_uri.len, dlg->from_uri.s);
break;
@@ -228,24 +238,24 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct
dlg_cb_params *_para
LM_DBG("dialog is early, from=%.*s\n", dlginfo->from_uri.len,
dlginfo->from_uri.s);
if (include_tags) {
/* get remotetarget */
- if ( !_params->msg->contact && ((parse_headers(_params->msg,
HDR_CONTACT_F,0)<0) || !_params->msg->contact) ) {
+ if ( !_params->rpl->contact && ((parse_headers(_params->rpl,
HDR_CONTACT_F,0)<0) || !_params->rpl->contact) ) {
LM_ERR("bad reply or missing CONTACT hdr\n");
} else {
- if ( parse_contact(_params->msg->contact)<0 ||
- ((contact_body_t *)_params->msg->contact->parsed)->contacts==NULL ||
- ((contact_body_t
*)_params->msg->contact->parsed)->contacts->next!=NULL ) {
+ if ( parse_contact(_params->rpl->contact)<0 ||
+ ((contact_body_t *)_params->rpl->contact->parsed)->contacts==NULL ||
+ ((contact_body_t
*)_params->rpl->contact->parsed)->contacts->next!=NULL ) {
LM_ERR("Malformed CONTACT hdr\n");
} else {
- target = ((contact_body_t
*)_params->msg->contact->parsed)->contacts->uri;
+ target = ((contact_body_t
*)_params->rpl->contact->parsed)->contacts->uri;
}
}
/* get to tag*/
- if ( !_params->msg->to && ((parse_headers(_params->msg,
HDR_TO_F,0)<0) || !_params->msg->to) ) {
+ if ( !_params->rpl->to && ((parse_headers(_params->rpl,
HDR_TO_F,0)<0) || !_params->rpl->to) ) {
LM_ERR("bad reply or missing TO hdr :-/\n");
tag.s = 0;
tag.len = 0;
} else {
- tag = get_to(_params->msg)->tag_value;
+ tag = get_to(_params->rpl)->tag_value;
if (tag.s==0 || tag.len==0) {
LM_ERR("missing TAG param in TO hdr :-/\n");
tag.s = 0;
@@ -281,7 +291,7 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct
dlg_cb_params *_para
static void
__dialog_created(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
{
- struct sip_msg *request = _params->msg;
+ struct sip_msg *request = _params->req;
struct dlginfo_cell *dlginfo;
int len;
@@ -329,7 +339,7 @@ __dialog_created(struct dlg_cell *dlg, int type, struct dlg_cb_params
*_params)
/* register dialog callbacks which triggers sending PUBLISH */
if (dlg_api.register_dlgcb(dlg,
- DLGCB_FAILED| DLGCB_CONFIRMED | DLGCB_TERMINATED | DLGCB_EXPIRED |
+ DLGCB_FAILED| DLGCB_CONFIRMED_NA | DLGCB_TERMINATED | DLGCB_EXPIRED |
DLGCB_REQ_WITHIN | DLGCB_EARLY,
__dialog_sendpublish, dlginfo, free_dlginfo_cell) != 0) {
LM_ERR("cannot register callback for interesting dialog types\n");
@@ -339,8 +349,8 @@ __dialog_created(struct dlg_cell *dlg, int type, struct dlg_cb_params
*_params)
#ifdef PUA_DIALOGINFO_DEBUG
/* dialog callback testing (registered last to be executed frist) */
if (dlg_api.register_dlgcb(dlg,
- DLGCB_FAILED| DLGCB_CONFIRMED | DLGCB_REQ_WITHIN | DLGCB_TERMINATED | DLGCB_EXPIRED |
- DLGCB_EARLY | DLGCB_RESPONSE_FWDED | DLGCB_RESPONSE_WITHIN |
+ DLGCB_FAILED| DLGCB_CONFIRMED_NA | DLGCB_CONFIRMED | DLGCB_REQ_WITHIN |
DLGCB_TERMINATED |
+ DLGCB_EXPIRED | DLGCB_EARLY | DLGCB_RESPONSE_FWDED | DLGCB_RESPONSE_WITHIN |
DLGCB_MI_CONTEXT | DLGCB_DESTROY,
__dialog_cbtest, NULL, NULL) != 0) {
LM_ERR("cannot register callback for all dialog types\n");
diff --git a/modules_k/sst/sst_handlers.c b/modules_k/sst/sst_handlers.c
index fb3351f..c7778a1 100644
--- a/modules_k/sst/sst_handlers.c
+++ b/modules_k/sst/sst_handlers.c
@@ -365,7 +365,7 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type,
static void sst_dialog_confirmed_CB(struct dlg_cell *did, int type,
struct dlg_cb_params * params)
{
- struct sip_msg* msg = params->msg;
+ struct sip_msg* msg = params->rpl;
LM_DBG("confirmed dialog CB %p\n", did);
DLOGMSG(msg);
@@ -944,7 +944,7 @@ static void setup_dialog_callbacks(struct dlg_cell *did, sst_info_t
*info)
#ifdef USE_CONFIRM_CALLBACK
LM_DBG("Adding callback DLGCB_CONFIRMED\n");
dlg_binds->register_dlgcb(did,
- DLGCB_CONFIRMED, sst_dialog_confirmed_CB, info, NULL);
+ DLGCB_CONFIRMED_NA, sst_dialog_confirmed_CB, info, NULL);
#endif /* USE_CONFIRM_CALLBACK */
LM_DBG("Adding callback "