]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adding subtract rsp code (got deleted by mistake)
authorDavid Yat Sin <dyatsin@sangoma.com>
Mon, 2 Jul 2012 08:43:21 +0000 (04:43 -0400)
committerDavid Yat Sin <dyatsin@sangoma.com>
Mon, 2 Jul 2012 08:43:21 +0000 (04:43 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c

index 25ec2a9d523820cb6fd24f4b4f7ee39fca4e5ecc..bbc538a58f07476e244431be626b29aca105214e 100644 (file)
@@ -647,3 +647,62 @@ switch_status_t mg_send_modify_rsp(SuId suId, MgMgcoCommand *req)
 }
 
 /*****************************************************************************************************************************/
+/*****************************************************************************************************************************/
+switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req)
+{
+       MgMgcoCommand  cmd;
+       int ret = 0x00;
+       MgMgcoTermId  *termId;
+       MgMgcoCtxt     ctxt;
+
+       memset(&cmd,0, sizeof(cmd));
+
+       /*copy transaction-id*/
+       memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
+
+       /*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
+       memcpy(&cmd.contextId, &req->contextId,sizeof(MgMgcoContextId));
+
+       /*copy peer identifier */
+       memcpy(&cmd.peerId, &req->peerId,sizeof(TknU32));
+
+       /*fill response structue */
+       if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&cmd.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
+               return ret;
+       }
+
+       cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
+       cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
+       cmd.u.mgCmdRsp[0]->type.val = MGT_SUB;
+       cmd.u.mgCmdRsp[0]->u.sub.pres.pres = PRSNT_NODEF;
+       cmd.u.mgCmdRsp[0]->u.sub.termIdLst.num.pres = PRSNT_NODEF;
+       cmd.u.mgCmdRsp[0]->u.sub.termIdLst.num.val  = 1;
+
+       mgUtlAllocMgMgcoTermIdLst(&cmd.u.mgCmdRsp[0]->u.sub.termIdLst, &req->u.mgCmdReq[0]->cmd.u.sub.termIdLst);
+
+#ifdef GCP_VER_2_1
+       termId = cmd.u.mgCmdRsp[0]->u.sub.termIdLst.terms[0];
+#else
+       termId = &(cmd.u.mgCmdRsp[0]->u.sub.termId);
+#endif
+       mg_fill_mgco_termid(termId, (CONSTANT U8*)"term1",&req->u.mgCmdRsp[0]->memCp);
+
+       /* We will always send one command at a time..*/
+       cmd.cmdStatus.pres = PRSNT_NODEF;
+       cmd.cmdStatus.val  = CH_CMD_STATUS_END_OF_CMD;
+
+       cmd.cmdType.pres = PRSNT_NODEF;
+       cmd.cmdType.val  = CH_CMD_TYPE_RSP;
+
+
+       ret = sng_mgco_send_cmd(suId, &cmd);
+
+       memcpy(&ctxt.transId,&req->transId,sizeof(MgMgcoTransId)); 
+       memcpy(&ctxt.cntxtId, &req->contextId,sizeof(MgMgcoContextId));
+       memcpy(&ctxt.peerId, &req->peerId,sizeof(TknU32));
+       ctxt.cmdStatus.pres = PRSNT_NODEF;
+       ctxt.cmdStatus.val  = CH_CMD_STATUS_END_OF_AXN;
+       ret = sng_mgco_send_axn_req(suId, &ctxt);
+
+       return ret;
+}
index 752fabd6eab370132b339835574ccef2d0d94950..c1b6db23dec9fcdf6e014f0295c36cb6f7ac487c 100644 (file)
@@ -132,6 +132,7 @@ switch_status_t mg_send_audit_rsp(SuId suId, MgMgcoCommand *req);
 switch_status_t handle_mg_audit_cmd(SuId suId, MgMgcoCommand *auditReq);
 
 switch_status_t mg_send_modify_rsp(SuId suId, MgMgcoCommand *req);
+switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req);
 void mg_util_set_term_string ( MgStr  *errTxt, MgMgcoTermId   *termId); 
 MgMgcoTermIdLst *mg_get_term_id_list(MgMgcoCommand *cmd);
 switch_status_t handle_pkg_audit( SuId suId, MgMgcoCommand *auditReq);
index 96f5bcbaafdfecb7e8cfffb595a8ec9058b47452..b3078fd046957f22c299b0fec96dc8fd490ea491 100644 (file)
@@ -182,7 +182,7 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
                 case MGT_TXNREQ:
                 {
                     MgMgcoTxnReq* txnReq; 
-                    MgMgcoTransId transId; /* XXX */
+                    /*MgMgcoTransId transId; *//* XXX */
                     int axnIter;
                     txnReq = &(msg->body.u.tl.txns[txnIter]->u.req);
 
@@ -207,14 +207,13 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
                             MgMgcoCommand mgCmd;
                            memset(&mgCmd, 0, sizeof(mgCmd));
                             mgCmd.peerId = msg->lcl.id;
-                            mgCmd.transId = transId;
                             mgCmd.u.mgCmdInd[0] = cmdReq;
                             
                             
                             /* XXX Handle choose context before this */
                             
                             mgCmd.contextId = ctxId;
-                            mgCmd.transId = transId;
+                            /*mgCmd.transId = transId;*/
 
                             mgCmd.cmdStatus.pres = PRSNT_NODEF;
                             
@@ -353,7 +352,7 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
 /*****************************************************************************************************************************/
 void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
 {
-       uint32_t txn_id = 0x00;
+       U32 txn_id = 0x00;
        MgMgcoInd  *mgErr;
        MgStr      errTxt;
        MgMgcoContextId   ctxtId;
@@ -373,7 +372,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
                ctxtId.type.pres = NOTPRSNT;
                ctxtId.val.pres  = NOTPRSNT;
 
-               mg_util_set_txn_string(&errTxt, (U32*)&txn_id);
+               mg_util_set_txn_string(&errTxt, &txn_id);
 
                if (SWITCH_STATUS_SUCCESS == mg_build_mgco_err_request(&mgErr, txn_id, &ctxtId,
                                                MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER, &errTxt)) {
@@ -427,6 +426,8 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
                                        case MGT_SUB:
                                                {
                                                        /*MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub;*/
+                                                       mg_send_subtract_rsp(suId, cmd);
+                                                       break;
                                                }
                                        case MGT_SVCCHG:
                                                {