?? osip.c
字號:
} else { if (0 == strcmp (evt->sip->cseq->method, "INVITE") || 0 == strcmp (evt->sip->cseq->method, "ACK")) { transactions = osip->ict_transactions;#ifdef OSIP_MT mut = ict_fastmutex;#endif } else { transactions = osip->nict_transactions;#ifdef OSIP_MT mut = nict_fastmutex;#endif } } } else if (EVT_IS_OUTGOINGMSG (evt)) { if (MSG_IS_RESPONSE (evt->sip)) { if (0 == strcmp (evt->sip->cseq->method, "INVITE") || 0 == strcmp (evt->sip->cseq->method, "ACK")) { transactions = osip->ist_transactions;#ifdef OSIP_MT mut = ist_fastmutex;#endif } else { transactions = osip->nist_transactions;#ifdef OSIP_MT mut = nist_fastmutex;#endif } } else { if (0 == strcmp (evt->sip->cseq->method, "INVITE") || 0 == strcmp (evt->sip->cseq->method, "ACK")) { transactions = osip->ict_transactions;#ifdef OSIP_MT mut = ict_fastmutex;#endif } else { transactions = osip->nict_transactions;#ifdef OSIP_MT mut = nict_fastmutex;#endif } } } if (transactions == NULL) return NULL; /* not a message??? */#ifdef OSIP_MT smutex_lock (mut);#endif transaction = osip_transaction_find (transactions, evt); if (consume == 1) { /* we add the event before releasing the mutex!! */ if (transaction != NULL) { transaction_add_event (transaction, evt);#ifdef OSIP_MT smutex_unlock (mut);#endif return transaction; } }#ifdef OSIP_MT smutex_unlock (mut);#endif return transaction;}transaction_t *osip_create_transaction (osip_t * osip, sipevent_t * evt){ transaction_t *transaction; int i; context_type_t ctx_type; if (evt==NULL) return NULL; if (evt->sip==NULL) return NULL; /* make sure the request's method reflect the cseq value. */ if (MSG_IS_REQUEST (evt->sip)) { /* delete request where cseq method does not match the method in request-line */ if (evt->sip->cseq==NULL || evt->sip->strtline==NULL || evt->sip->cseq->method==NULL || evt->sip->strtline->sipmethod==NULL) { return NULL; } if (0 != strcmp (evt->sip->cseq->method, evt->sip->strtline->sipmethod)) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "core module: Discard invalid message with method!=cseq!\n")); return NULL; } } if (MSG_IS_ACK (evt->sip)) /* ACK never create transactions */ return NULL; if (EVT_IS_INCOMINGREQ (evt)) { /* we create a new context for this incoming request */ if (0 == strcmp (evt->sip->cseq->method, "INVITE")) ctx_type = IST; else ctx_type = NIST; } else if (EVT_IS_OUTGOINGREQ (evt)) { if (0 == strcmp (evt->sip->cseq->method, "INVITE")) ctx_type = ICT; else ctx_type = NICT; } else { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Cannot build a transction for this message!\n")); return NULL; } i = transaction_init (&transaction, ctx_type, osip, evt->sip); if (i == -1) { return NULL; } evt->transactionid = transaction->transactionid; return transaction;}transaction_t *osip_transaction_find (list_t * transactions, sipevent_t * evt){ int pos = 0; transaction_t *transaction; if (EVT_IS_INCOMINGREQ (evt)) { while (!list_eol (transactions, pos)) { transaction = (transaction_t *) list_get (transactions, pos); if (0 == transaction_matching_request_to_xist_17_2_3 (transaction, evt->sip)) return transaction; pos++; } } else if (EVT_IS_INCOMINGRESP (evt)) { while (!list_eol (transactions, pos)) { transaction = (transaction_t *) list_get (transactions, pos); if (0 == transaction_matching_response_to_xict_17_1_3 (transaction, evt->sip)) return transaction; pos++; } } else /* handle OUTGOING message */ { /* THE TRANSACTION ID MUST BE SET */ while (!list_eol (transactions, pos)) { transaction = (transaction_t *) list_get (transactions, pos); if (transaction->transactionid == evt->transactionid) return transaction; pos++; } } return NULL;}intosip_init (osip_t ** osip){ *osip = (osip_t *) smalloc (sizeof (osip_t)); if (*osip == NULL) return -1; /* allocation failed */#ifndef DISABLE_MEMSET memset (*osip, 0, sizeof (osip_t));#else (*osip)->cb_ict_kill_transaction = NULL; (*osip)->cb_ict_invite_sent = NULL; (*osip)->cb_ict_invite_sent2 = NULL; (*osip)->cb_ict_ack_sent = NULL; (*osip)->cb_ict_ack_sent2 = NULL; (*osip)->cb_ict_1xx_received = NULL; (*osip)->cb_ict_2xx_received = NULL; (*osip)->cb_ict_2xx_received2 = NULL; (*osip)->cb_ict_3456xx_received = NULL; (*osip)->cb_ict_3456xx_received2 = NULL; (*osip)->cb_ict_transport_error = NULL; /* callbacks for ist */ (*osip)->cb_ist_kill_transaction = NULL; (*osip)->cb_ist_invite_received = NULL; (*osip)->cb_ist_invite_received2 = NULL; (*osip)->cb_ist_ack_received = NULL; (*osip)->cb_ist_ack_received2 = NULL; (*osip)->cb_ist_1xx_sent = NULL; (*osip)->cb_ist_1xx_sent2 = NULL; (*osip)->cb_ist_2xx_sent = NULL; (*osip)->cb_ist_2xx_sent2 = NULL; (*osip)->cb_ist_3456xx_sent = NULL; (*osip)->cb_ist_3456xx_sent2 = NULL; (*osip)->cb_ist_transport_error = NULL; /* callbacks for nict */ (*osip)->cb_nict_kill_transaction = NULL; (*osip)->cb_nict_register_sent = NULL; (*osip)->cb_nict_bye_sent = NULL; (*osip)->cb_nict_options_sent = NULL; (*osip)->cb_nict_info_sent = NULL; (*osip)->cb_nict_cancel_sent = NULL; (*osip)->cb_nict_notify_sent = NULL; (*osip)->cb_nict_subscribe_sent = NULL; (*osip)->cb_nict_unknown_sent = NULL; (*osip)->cb_nict_request_sent2 = NULL; (*osip)->cb_nict_1xx_received = NULL; (*osip)->cb_nict_2xx_received = NULL; (*osip)->cb_nict_2xx_received2 = NULL; (*osip)->cb_nict_3456xx_received = NULL; (*osip)->cb_nict_3456xx_received2 = NULL; (*osip)->cb_nict_transport_error = NULL; /* callbacks for nist */ (*osip)->cb_nist_kill_transaction = NULL; (*osip)->cb_nist_register_received = NULL; (*osip)->cb_nist_bye_received = NULL; (*osip)->cb_nist_options_received = NULL; (*osip)->cb_nist_info_received = NULL; (*osip)->cb_nist_cancel_received = NULL; (*osip)->cb_nist_notify_received = NULL; (*osip)->cb_nist_subscribe_received = NULL; /* ... TO BE ADDED: All known and used method extansions */ (*osip)->cb_nist_unknown_received = NULL; (*osip)->cb_nist_request_received2 = NULL; (*osip)->cb_nist_1xx_sent = NULL; (*osip)->cb_nist_2xx_sent = NULL; (*osip)->cb_nist_2xx_sent2 = NULL; (*osip)->cb_nist_3456xx_sent = NULL; (*osip)->cb_nist_3456xx_sent2 = NULL; (*osip)->cb_nist_transport_error = NULL;#endif (*osip)->ict_transactions = (list_t *) smalloc (sizeof (list_t)); list_init ((*osip)->ict_transactions); (*osip)->ist_transactions = (list_t *) smalloc (sizeof (list_t)); list_init ((*osip)->ist_transactions); (*osip)->nict_transactions = (list_t *) smalloc (sizeof (list_t)); list_init ((*osip)->nict_transactions); (*osip)->nist_transactions = (list_t *) smalloc (sizeof (list_t)); list_init ((*osip)->nist_transactions); return 0;}voidosip_free (osip_t * osip){ sfree (osip->ict_transactions); sfree (osip->ist_transactions); sfree (osip->nict_transactions); sfree (osip->nist_transactions);}voidosip_set_application_context (osip_t * osip, void *pointer){ osip->application_context = pointer;}void *osip_get_application_context (osip_t * osip){ if (osip == NULL) return NULL; return osip->application_context;}intosip_ict_execute (osip_t * osip){ transaction_t *transaction; sipevent_t *se; int more_event; int tr; tr = 0; while (!list_eol (osip->ict_transactions, tr)) { transaction = list_get (osip->ict_transactions, tr); tr++; more_event = 1; do { se = (sipevent_t *) fifo_tryget (transaction->transactionff); if (se == NULL) /* no more event for this transaction */ more_event = 0; else transaction_execute (transaction, se); } while (more_event == 1); } return 0;}intosip_ist_execute (osip_t * osip){ transaction_t *transaction; sipevent_t *se; int more_event; int tr; tr = 0; while (!list_eol (osip->ist_transactions, tr)) { transaction = list_get (osip->ist_transactions, tr); tr++; more_event = 1; do { se = (sipevent_t *) fifo_tryget (transaction->transactionff); if (se == NULL) /* no more event for this transaction */ more_event = 0; else transaction_execute (transaction, se); } while (more_event == 1); } return 0;}intosip_nict_execute (osip_t * osip){ transaction_t *transaction; sipevent_t *se; int more_event; int tr; tr = 0; while (!list_eol (osip->nict_transactions, tr)) { transaction = list_get (osip->nict_transactions, tr); tr++; more_event = 1; do { se = (sipevent_t *) fifo_tryget (transaction->transactionff); if (se == NULL) /* no more event for this transaction */ more_event = 0; else transaction_execute (transaction, se); } while (more_event == 1); } return 0;}intosip_nist_execute (osip_t * osip){ transaction_t *transaction; sipevent_t *se; int more_event; int tr; tr = 0; while (!list_eol (osip->nist_transactions, tr)) { transaction = list_get (osip->nist_transactions, tr); tr++; more_event = 1; do { se = (sipevent_t *) fifo_tryget (transaction->transactionff); if (se == NULL) /* no more event for this transaction */ more_event = 0; else transaction_execute (transaction, se); } while (more_event == 1); } return 0;}voidosip_timers_ict_execute (osip_t * osip){ transaction_t *tr; int pos = 0;#ifdef OSIP_MT smutex_lock (ict_fastmutex);#endif /* handle ict timers */ while (!list_eol (osip->ict_transactions, pos)) { sipevent_t *evt; tr = (transaction_t *) list_get (osip->ict_transactions, pos); if (1 <= fifo_size (tr->transactionff)) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO4, NULL, "1 Pending event already in transaction !\n")); } else { evt = ict_need_timer_b_event (tr->ict_context, tr->state, tr->transactionid); if (evt != NULL) fifo_add (tr->transactionff, evt); else { evt = ict_need_timer_a_event (tr->ict_context, tr->state, tr->transactionid); if (evt != NULL) fifo_add (tr->transactionff, evt); else { evt = ict_need_timer_d_event (tr->ict_context, tr->state, tr->transactionid); if (evt != NULL) fifo_add (tr->transactionff, evt); } } } pos++; }#ifdef OSIP_MT smutex_unlock (ict_fastmutex);#endif}voidosip_timers_ist_execute (osip_t * osip){ transaction_t *tr; int pos = 0;#ifdef OSIP_MT smutex_lock (ist_fastmutex);#endif /* handle ist timers */ while (!list_eol (osip->ist_transactions, pos)) { sipevent_t *evt; tr = (transaction_t *) list_get (osip->ist_transactions, pos); evt = ist_need_timer_i_event (tr->ist_context, tr->state, tr->transactionid); if (evt != NULL) fifo_add (tr->transactionff, evt); else { evt = ist_need_timer_h_event (tr->ist_context, tr->state, tr->transactionid); if (evt != NULL) fifo_add (tr->transactionff, evt); else { evt = ist_need_timer_g_event (tr->ist_context, tr->state, tr->transactionid); if (evt != NULL) fifo_add (tr->transactionff, evt); } } pos++; }#ifdef OSIP_MT smutex_unlock (ist_fastmutex);#endif}voidosip_timers_nict_execute (osip_t * osip){ transaction_t *tr; int pos = 0;#ifdef OSIP_MT smutex_lock (nict_fastmutex);#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -