Send re-register packets by GRQ (gatekeeper request) interval
[asterisk/asterisk.git] / addons / ooh323c / src / ooGkClient.c
index e149aba..3aaaba7 100644 (file)
@@ -1285,6 +1285,8 @@ int ooGkClientHandleRegistrationReject
    unsigned int x=0;
    DListNode *pNode = NULL;
    OOTimer *pTimer = NULL;
+   ooGkClientTimerCb *cbData=NULL;
+
    /* First delete the corresponding RRQ timer */
    for(x=0; x<pGkClient->timerList.count; x++)
    {
@@ -1381,14 +1383,33 @@ int ooGkClientHandleRegistrationReject
    pGkClient->rrqRetries = 0;
    pGkClient->grqRetries = 0;
    pGkClient->discoveryComplete = FALSE;
-   ast_mutex_unlock(&pGkClient->Lock);
 
-   iRet = ooGkClientSendGRQ(pGkClient);
-   if(iRet != OO_OK){
-      OOTRACEERR1("\nError: Transmission of rediscovery of GK failed\n");
+   cbData = (ooGkClientTimerCb*) memAlloc
+                               (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+   if(!cbData)
+   {
+      OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n");
+      pGkClient->state = GkClientFailed;
+      ast_mutex_unlock(&pGkClient->Lock);
       return OO_FAILED;
    }
+   cbData->timerType = OO_GRQ_TIMER;
+   cbData->pGkClient = pGkClient;
+   if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+                     &ooGkClientGRQTimerExpired, pGkClient->grqTimeout,
+                     cbData, FALSE))
+   {
+      OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
+      memFreePtr(&pGkClient->ctxt, cbData);
+      pGkClient->state = GkClientFailed;
+      ast_mutex_unlock(&pGkClient->Lock);
+      return OO_FAILED;
+   }
+
+   ast_mutex_unlock(&pGkClient->Lock);
+
    return OO_OK;
+
 }