Module: sip-router Branch: master Commit: 2df6f560bcc54d2966732d397713a9cf3233d5fe URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2df6f560...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Sun Mar 31 21:49:10 2013 +0200
dialog: SDP can be passed to MI/RPC dlg_bridge
- rework from a patch of Patrick E.
---
modules/dialog/dialog.c | 31 ++++++++++++++++++++++++++++--- modules/dialog/dlg_transfer.c | 11 ++++++++--- modules/dialog/dlg_transfer.h | 2 +- 3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index 804bc46..e560b4e 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -1097,7 +1097,7 @@ static int w_dlg_bridge(struct sip_msg *msg, char *from, char *to, char *op) return -1; }
- if(dlg_bridge(&sf, &st, &so)!=0) + if(dlg_bridge(&sf, &st, &so, NULL)!=0) return -1; return 1; } @@ -1345,6 +1345,7 @@ struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param) str from = {0,0}; str to = {0,0}; str op = {0,0}; + str bd = {0,0}; struct mi_node* node;
node = cmd_tree->node.kids; @@ -1374,9 +1375,23 @@ struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param) { return init_mi_tree(500, "Bad OP value", 12); } + if(op.len==1 && *op.s=='.') + { + op.s = NULL; + op.len = 0; + } + node= node->next; + if(node != NULL) + { + bd = node->value; + if(bd.len<=0 || bd.s==NULL) + { + return init_mi_tree(500, "Bad SDP value", 13); + } + } }
- if(dlg_bridge(&from, &to, &op)!=0) + if(dlg_bridge(&from, &to, &op, &bd)!=0) return init_mi_tree(500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN);
return init_mi_tree(200, MI_OK_S, MI_OK_LEN); @@ -1676,6 +1691,7 @@ static void rpc_dlg_bridge(rpc_t *rpc, void *c) { str from = {NULL,0}; str to = {NULL,0}; str op = {NULL,0}; + str bd = {NULL,0}; int n;
n = rpc->scan(c, "SS", &from, &to); @@ -1687,9 +1703,18 @@ static void rpc_dlg_bridge(rpc_t *rpc, void *c) { if(rpc->scan(c, "*S", &op)<1) { op.s = NULL; op.len = 0; + } else { + if(op.len==1 && *op.s=='.') { + op.s = NULL; + op.len = 0; + } + if(rpc->scan(c, "*S", &bd)<1) { + bd.s = NULL; + bd.len = 0; + } }
- dlg_bridge(&from, &to, &op); + dlg_bridge(&from, &to, &op, &bd); }
static rpc_export_t rpc_methods[] = { diff --git a/modules/dialog/dlg_transfer.c b/modules/dialog/dlg_transfer.c index 25d9e8d..7245435 100644 --- a/modules/dialog/dlg_transfer.c +++ b/modules/dialog/dlg_transfer.c @@ -311,7 +311,7 @@ error: }
-int dlg_bridge(str *from, str *to, str *op) +int dlg_bridge(str *from, str *to, str *op, str *bd) { dlg_transfer_ctx_t *dtc; int ret; @@ -350,8 +350,13 @@ int dlg_bridge(str *from, str *to, str *op)
LM_DBG("bridge <%.*s> to <%.*s>\n", dtc->from.len, dtc->from.s, dtc->to.len, dtc->to.s); - s_body.s = DLG_HOLD_SDP; - s_body.len = DLG_HOLD_SDP_LEN; + if(bd!=NULL && bd->s!=NULL && bd->len>0) { + s_body.s = bd->s; + s_body.len = bd->len; + } else { + s_body.s = DLG_HOLD_SDP; + s_body.len = DLG_HOLD_SDP_LEN; + }
memset(&uac_r, '\0', sizeof(uac_req_t)); uac_r.method = &s_method; diff --git a/modules/dialog/dlg_transfer.h b/modules/dialog/dlg_transfer.h index ef05eeb..5337f38 100644 --- a/modules/dialog/dlg_transfer.h +++ b/modules/dialog/dlg_transfer.h @@ -32,7 +32,7 @@ typedef struct _dlg_transfer_ctx { struct dlg_cell *dlg; } dlg_transfer_ctx_t;
-int dlg_bridge(str *from, str *to, str *op); +int dlg_bridge(str *from, str *to, str *op, str *bd); int dlg_transfer(struct dlg_cell *dlg, str *to, int side); int dlg_bridge_init_hdrs(void); void dlg_bridge_destroy_hdrs(void);