struct DialogId *CreateFixedDialogId(char *callid, char *localTag, char *remoteTag) { struct DialogId *dialogid = CreateEmptyDialogId(); SetCallId(dialogid, callid); SetLocalTag(dialogid, localTag); SetRemoteTag(dialogid, remoteTag); return dialogid; }
void ExtractDialogId(struct DialogId *dialogid, MESSAGE *message) { SetCallId(dialogid, MessageGetCallId(message)); if (MessageGetType(message) == MESSAGE_TYPE_RESPONSE) { SetLocalTag(dialogid, MessageGetFromTag(message)); SetRemoteTag(dialogid, MessageGetToTag(message)); } else { SetRemoteTag(dialogid, MessageGetFromTag(message)); } }
struct Transaction *DialogNewTransaction(struct Dialog *dialog, MESSAGE *message, int type) { struct DialogId *id = GetDialogId(dialog); struct Transaction *t = AddTransaction(message, (struct TransactionUser *)dialog, type); dialog->transaction = t; if (type == TRANSACTION_TYPE_CLIENT_INVITE) { SetLocalTag(id, MessageGetFromTag(message)); SetCallId(id, MessageGetCallId(message)); SetLocalSeqNumber(dialog, MessageGetCSeqNumber(message)); } else if (type == TRANSACTION_TYPE_SERVER_INVITE) { SetRemoteTag(id, MessageGetFromTag(message)); SetCallId(id, MessageGetCallId(message)); ExtractRemoteTarget(dialog, message); if (NotifyCm != NULL) { NotifyCm(CALL_INCOMING, DialogGetUserAgent(dialog)); } } return t; }
int CSipTransaction::Init( CSipMessage* request ) { last_response = NULL; your_instance = NULL; static int itransactionid = 1; CVia* topvia; int i; time_t now; if (request == NULL) return -1; if (request->m_callid == NULL) return -1; if (request->m_callid->number == NULL) return -1; now = time(NULL); birth_time = now; transactionid = itransactionid; itransactionid++; topvia = (CVia*)request->m_listVias.GetAt(0); if (topvia == NULL) goto ti_error_1; i = SetTopVia(topvia); if (i != 0) goto ti_error_1; /* In some situation, some of those informtions might be useless. Mostly, I prefer to keep them in all case for backward compatibility. */ i = SetFrom(request->m_from); if (i != 0) goto ti_error_2; i = SetTo(request->m_to); if (i != 0) goto ti_error_3; i = SetCallId(request->m_callid); if (i != 0) goto ti_error_4; i = SetCseq(request->m_seq); if (i != 0) goto ti_error_5; /* RACE conditions can happen for server transactions */ /* (*transaction)->orig_request = request; */ this->orig_request = NULL; (this)->transactionff = new CFifo; if ((this)->transactionff == NULL) goto ti_error_6; return 0; ti_error_6 : delete ((this)->cseq); ti_error_5 : delete ((this)->callid); ti_error_4 : delete ((this)->to); ti_error_3 : delete ((this)->from); ti_error_2 : delete ((this)->topvia); ti_error_1 : delete (this); return -1; }