Dialogic 05-2239-009 User Manual

Page of 604
For an “Accept” response the message sent is a 200 OK, while “Reject” sends a 501 response. In 
either case, the response message must include the Call-ID header that was received in the 
NOTIFY request. 
The following two code snippets illustrate how an application would send “Accept” and “Reject” 
responses to NOTIFY requests.
“Accept” Response to NOTIFY Request
void CSubNotMgr::SendSIPNotifyAccept ()
{
   char        str[MAX_STRING_SIZE];
   sprintf(str, "<--- Sending SIP NOTIFY Accept\n");
   printandlog(ALL_DEVICES, MISC, NULL, str, 0);
   GC_PARM_BLKP   parmblkp = NULL;  // input parameter block pointer 
   GC_PARM_BLKP   retblkp = NULL;   // return parameter block
   GC_INFO        gc_error_info;    // GlobalCall error information data 
   int            retval = GC_SUCCESS;
   gc_util_insert_parm_val(&parmblkp,
                           IPSET_MSG_SIP,
                           IPPARM_MSGTYPE,
                           sizeof(int),
                           IP_MSGTYPE_SIP_NOTIFY_ACCEPT);
   // Insert SIP Call ID field 
   gc_util_insert_parm_ref_ex(&parmblkp,
                              IPSET_SIP_MSGINFO,
                              IPPARM_CALLID_HDR,
                              (unsigned long)(strlen(m_CurrentCallID)),
                              m_CurrentCallID);
   if (parmblkp == NULL)
   {
      // memory allocation error 
      return;
   }
   // transmit NOTIFY message to network 
   retval = gc_Extension(GCTGT_GCLIB_CHAN, boardh, 
                         IPEXTID_SENDMSG, parmblkp, 
                         &retblkp, EV_ASYNC);
   if (retval != GC_SUCCESS)
   {
      gc_ErrorInfo( &gc_error_info );
      printf ("Error : gc_Extension() on HANDLE: 0x%lx, 
              GC ErrorValue: 0x%hx - %s, CCLibID: %i - %s, 
              CC ErrorValue: 0x%lx - %s\n", boardh, 
              gc_error_info.gcValue, gc_error_info.gcMsg, 
              gc_error_info.ccLibId, gc_error_info.ccLibName, 
              gc_error_info.ccValue, gc_error_info.ccMsg);
      return;
   }
   // clean up
   gc_util_delete_parm_blk(parmblkp);
   m_bNotifyAcceptSent = true;
}