Change order of sending TCS and MSD packets
authorAlexandr Anikin <may@telecom-service.ru>
Sat, 25 Dec 2010 16:35:09 +0000 (16:35 +0000)
committerAlexandr Anikin <may@telecom-service.ru>
Sat, 25 Dec 2010 16:35:09 +0000 (16:35 +0000)
Change order of sending Terminal Capability Set and MasterSlave
Determination packets, MSD send when TCS exchange procedure is done
(we send tcs ack to remote and we have remote tcs ack already
or we receive tcs ack from remote and we have send our tcs ack to
remote  already). Some endpoints can work in this sequence only,
i suggest they can't work with both (tcs and msd) exchange procedures
simultaneously.

Also changed StartH245 facility message sending. It send on
incoming calls only due to some endpoints can't proccess properly
this facility messages on their incoming calls.

(closes issue #18433)
Reported by: MrHanMan
Patches:
      tcs-msd-h245-3.patch uploaded by may213 (license 454)
Tested by: MrHanMan, may213

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@299715 65c4cc65-6c06-0410-ace0-fbb531ad65f3

addons/ooh323c/src/oochannels.c
addons/ooh323c/src/ooh245.c
addons/ooh323c/src/ooh323.c
addons/ooh323c/src/ooq931.c

index e74b75c..7fa8509 100644 (file)
@@ -146,13 +146,6 @@ int ooCreateH245Connection(OOH323CallData *call)
                          call->callType, call->callToken);
             return ret;
          }
-         ret = ooSendMasterSlaveDetermination(call);
-         if(ret != OO_OK)
-         {
-            OOTRACEERR3("ERROR:Sending Master-slave determination message "
-                        "(%s, %s)\n", call->callType, call->callToken);
-            return ret;
-         }
       }
       else
       {
@@ -489,13 +482,6 @@ int ooAcceptH245Connection(OOH323CallData *call)
                    call->callType, call->callToken);
       return ret;
    }
-   ret = ooSendMasterSlaveDetermination(call);
-   if(ret != OO_OK)
-   {
-      OOTRACEERR3("ERROR:Sending Master-slave determination message "
-                  "(%s, %s)\n", call->callType, call->callToken);
-      return ret;
-   }   
    return OO_OK;
 }
 
index adbe184..d993c9e 100644 (file)
@@ -2102,10 +2102,20 @@ int ooHandleH245Command(OOH323CallData *call,
 
 int ooOnReceivedTerminalCapabilitySetAck(OOH323CallData* call)
 {
+   int ret = OO_OK;
    call->localTermCapState = OO_LocalTermCapSetAckRecvd;
    if(call->remoteTermCapState != OO_RemoteTermCapSetAckSent)
       return OO_OK;
    
+   if(call->masterSlaveState == OO_MasterSlave_Idle) {
+      ret = ooSendMasterSlaveDetermination(call);
+      if(ret != OO_OK) {
+                OOTRACEERR3("ERROR:Sending Master-slave determination message "
+                            "(%s, %s)\n", call->callType, call->callToken);
+                return ret;
+      }
+   } 
+
    if((call->masterSlaveState == OO_MasterSlave_Master ||
        call->masterSlaveState == OO_MasterSlave_Slave) &&
        (call->msAckStatus == OO_msAck_remoteReceived))
@@ -3127,6 +3137,16 @@ int ooOnReceivedTerminalCapabilitySet(OOH323CallData *call, H245Message *pmsg)
       call->localTermCapState  != OO_LocalTermCapSetAckRecvd)
       return OO_OK;
 
+   if(call->masterSlaveState == OO_MasterSlave_Idle) {
+      ret = ooSendMasterSlaveDetermination(call);
+      if(ret != OO_OK) {
+                OOTRACEERR3("ERROR:Sending Master-slave determination message "
+                            "(%s, %s)\n", call->callType, call->callToken);
+                return ret;
+      }
+   } 
+
+
    /* Check MasterSlave procedure has finished */
    if(call->masterSlaveState != OO_MasterSlave_Master &&
       call->masterSlaveState != OO_MasterSlave_Slave)
index ed097d9..09df3c9 100644 (file)
@@ -1040,10 +1040,6 @@ int ooOnReceivedAlerting(OOH323CallData *call, Q931Message *q931Msg)
          return OO_FAILED;
        }
       }
-   } else if (!call->pH245Channel && !call->h245listener) {
-       ret = ooSendStartH245Facility(call);
-       if (ret != OO_OK)
-               return ret;
    }
 
    return OO_OK;
@@ -1274,10 +1270,6 @@ int ooOnReceivedProgress(OOH323CallData *call, Q931Message *q931Msg)
          return OO_FAILED;
        }
       }
-   } else if (!call->pH245Channel && !call->h245listener) {
-       ret = ooSendStartH245Facility(call);
-       if (ret != OO_OK)
-               return ret;
    }
 
    return OO_OK;
@@ -1572,16 +1564,6 @@ int ooOnReceivedSignalConnect(OOH323CallData* call, Q931Message *q931Msg)
             return ret;
          }
       }
-      if(call->masterSlaveState == OO_MasterSlave_Idle)
-      {
-         ret = ooSendMasterSlaveDetermination(call);
-         if(ret != OO_OK)
-         {
-            OOTRACEERR3("ERROR:Sending Master-slave determination message "
-                     "(%s, %s)\n", call->callType, call->callToken);
-            return ret;
-         }   
-      }
 
    }
    call->callState = OO_CALL_CONNECTED;
@@ -1986,12 +1968,17 @@ int ooHandleStartH245FacilityMessage
    OO_CLRFLAG (call->flags, OO_M_TUNNELING);
 
    /*Establish an H.245 connection */
-   ret = ooCreateH245Connection(call);
-   if(ret != OO_OK)
-   {
+   if (!call->pH245Channel) {
+    ret = ooCreateH245Connection(call);
+    if(ret != OO_OK)
+    {
       OOTRACEERR3("ERROR: Failed to establish an H.245 connection with remote"
                   " endpoint (%s, %s)\n", call->callType, call->callToken);
       return ret;
+    }
+   } else {
+     OOTRACEINFO3("INFO: H.245 connection already established with remote"
+                  " endpoint (%s, %s)\n", call->callType, call->callToken);
    }
    return OO_OK;
 }
index 7e42a22..d0233f3 100644 (file)
@@ -1213,14 +1213,6 @@ int ooSendTCSandMSD(OOH323CallData *call)
                        return ret;
                }
        }
-       if(call->masterSlaveState == OO_MasterSlave_Idle) {
-               ret = ooSendMasterSlaveDetermination(call);
-               if(ret != OO_OK) {
-                       OOTRACEERR3("ERROR:Sending Master-slave determination message "
-                               "(%s, %s)\n", call->callType, call->callToken);
-                       return ret;
-               }
-       }
 
        return OO_OK;
 }
@@ -1593,6 +1585,9 @@ int ooSendProgress(OOH323CallData *call)
       OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken);
    }
 
+   if (!OO_TESTFLAG(call->flags, OO_M_TUNNELING) && call->h245listener)
+      ooSendStartH245Facility(call);
+
    ooSendTCSandMSD(call);
    memReset (call->msgctxt);