📄 ist_fsm.c
字号:
int port; osip_generic_param_t *maddr; osip_generic_param_t *received; osip_generic_param_t *rport; osip_via_param_get_byname (via, "maddr", &maddr); osip_via_param_get_byname (via, "received", &received); osip_via_param_get_byname (via, "rport", &rport); /* 1: user should not use the provided information (host and port) if they are using a reliable transport. Instead, they should use the already open socket attached to this transaction. */ /* 2: check maddr and multicast usage */ if (maddr != NULL) host = maddr->gvalue; /* we should check if this is a multicast address and use set the "ttl" in this case. (this must be done in the UDP message (not at the SIP layer) */ else if (received != NULL) host = received->gvalue; else host = via->host; if (rport == NULL || rport->gvalue == NULL) { if (via->port != NULL) port = osip_atoi (via->port); else port = 5060; } else port = osip_atoi (rport->gvalue); i = osip->cb_send_message (ist, ist->last_response, host, port, ist->out_socket); } else i = -1; if (i != 0) { ist_handle_transport_error (ist, i); return; } __osip_message_callback (OSIP_IST_STATUS_3456XX_SENT_AGAIN, ist, ist->last_response);}voidosip_ist_timeout_h_event (osip_transaction_t * ist, osip_event_t * evt){ ist->ist_context->timer_h_length = -1; ist->ist_context->timer_h_start = -1; __osip_transaction_set_state (ist, IST_TERMINATED); __osip_kill_transaction_callback (OSIP_IST_KILL_TRANSACTION, ist);}voidosip_ist_timeout_i_event (osip_transaction_t * ist, osip_event_t * evt){ ist->ist_context->timer_i_length = -1; ist->ist_context->timer_i_start = -1; __osip_transaction_set_state (ist, IST_TERMINATED); __osip_kill_transaction_callback (OSIP_IST_KILL_TRANSACTION, ist);}voidist_snd_1xx (osip_transaction_t * ist, osip_event_t * evt){ int i; osip_via_t *via; osip_t *osip = (osip_t *) ist->config; if (ist->last_response != NULL) { osip_message_free (ist->last_response); } ist->last_response = evt->sip; via = (osip_via_t *) osip_list_get (ist->last_response->vias, 0); if (via) { char *host; int port; osip_generic_param_t *maddr; osip_generic_param_t *received; osip_generic_param_t *rport; osip_via_param_get_byname (via, "maddr", &maddr); osip_via_param_get_byname (via, "received", &received); osip_via_param_get_byname (via, "rport", &rport); /* 1: user should not use the provided information (host and port) if they are using a reliable transport. Instead, they should use the already open socket attached to this transaction. */ /* 2: check maddr and multicast usage */ if (maddr != NULL) host = maddr->gvalue; /* we should check if this is a multicast address and use set the "ttl" in this case. (this must be done in the UDP message (not at the SIP layer) */ else if (received != NULL) host = received->gvalue; else host = via->host; if (rport == NULL || rport->gvalue == NULL) { if (via->port != NULL) port = osip_atoi (via->port); else port = 5060; } else port = osip_atoi (rport->gvalue); i = osip->cb_send_message (ist, ist->last_response, host, port, ist->out_socket); } else i = -1; if (i != 0) { ist_handle_transport_error (ist, i); return; } else __osip_message_callback (OSIP_IST_STATUS_1XX_SENT, ist, ist->last_response); /* we are already in the proper state */ return;}voidist_snd_2xx (osip_transaction_t * ist, osip_event_t * evt){ int i; osip_via_t *via; osip_t *osip = (osip_t *) ist->config; if (ist->last_response != NULL) { osip_message_free (ist->last_response); } ist->last_response = evt->sip; via = (osip_via_t *) osip_list_get (ist->last_response->vias, 0); if (via) { char *host; int port; osip_generic_param_t *maddr; osip_generic_param_t *received; osip_generic_param_t *rport; osip_via_param_get_byname (via, "maddr", &maddr); osip_via_param_get_byname (via, "received", &received); osip_via_param_get_byname (via, "rport", &rport); /* 1: user should not use the provided information (host and port) if they are using a reliable transport. Instead, they should use the already open socket attached to this transaction. */ /* 2: check maddr and multicast usage */ if (maddr != NULL) host = maddr->gvalue; /* we should check if this is a multicast address and use set the "ttl" in this case. (this must be done in the UDP message (not at the SIP layer) */ else if (received != NULL) host = received->gvalue; else host = via->host; if (rport == NULL || rport->gvalue == NULL) { if (via->port != NULL) port = osip_atoi (via->port); else port = 5060; } else port = osip_atoi (rport->gvalue); i = osip->cb_send_message (ist, ist->last_response, host, port, ist->out_socket); } else i = -1; if (i != 0) { ist_handle_transport_error (ist, i); return; } else { __osip_message_callback (OSIP_IST_STATUS_2XX_SENT, ist, ist->last_response); __osip_transaction_set_state (ist, IST_TERMINATED); __osip_kill_transaction_callback (OSIP_IST_KILL_TRANSACTION, ist); } return;}voidist_snd_3456xx (osip_transaction_t * ist, osip_event_t * evt){ int i; osip_via_t *via; osip_t *osip = (osip_t *) ist->config; if (ist->last_response != NULL) { osip_message_free (ist->last_response); } ist->last_response = evt->sip; via = (osip_via_t *) osip_list_get (ist->last_response->vias, 0); if (via) { char *host; int port; osip_generic_param_t *maddr; osip_generic_param_t *received; osip_generic_param_t *rport; osip_via_param_get_byname (via, "maddr", &maddr); osip_via_param_get_byname (via, "received", &received); osip_via_param_get_byname (via, "rport", &rport); /* 1: user should not use the provided information (host and port) if they are using a reliable transport. Instead, they should use the already open socket attached to this transaction. */ /* 2: check maddr and multicast usage */ if (maddr != NULL) host = maddr->gvalue; /* we should check if this is a multicast address and use set the "ttl" in this case. (this must be done in the UDP message (not at the SIP layer) */ else if (received != NULL) host = received->gvalue; else host = via->host; if (rport == NULL || rport->gvalue == NULL) { if (via->port != NULL) port = osip_atoi (via->port); else port = 5060; } else port = osip_atoi (rport->gvalue); i = osip->cb_send_message (ist, ist->last_response, host, port, ist->out_socket); } else i = -1; if (i != 0) { ist_handle_transport_error (ist, i); return; } else { if (MSG_IS_STATUS_3XX (ist->last_response)) __osip_message_callback (OSIP_IST_STATUS_3XX_SENT, ist, ist->last_response); else if (MSG_IS_STATUS_4XX (ist->last_response)) __osip_message_callback (OSIP_IST_STATUS_4XX_SENT, ist, ist->last_response); else if (MSG_IS_STATUS_5XX (ist->last_response)) __osip_message_callback (OSIP_IST_STATUS_5XX_SENT, ist, ist->last_response); else __osip_message_callback (OSIP_IST_STATUS_6XX_SENT, ist, ist->last_response); } ist->ist_context->timer_g_start = time (NULL); ist->ist_context->timer_h_start = time (NULL); __osip_transaction_set_state (ist, IST_COMPLETED); return;}voidist_rcv_ack (osip_transaction_t * ist, osip_event_t * evt){ if (ist->ack != NULL) { osip_message_free (ist->ack); } ist->ack = evt->sip; if (ist->state == IST_COMPLETED) __osip_message_callback (OSIP_IST_ACK_RECEIVED, ist, ist->ack); else /* IST_CONFIRMED */ __osip_message_callback (OSIP_IST_ACK_RECEIVED_AGAIN, ist, ist->ack); /* set the timer to 0 for reliable, and T4 for unreliable (already set) */ ist->ist_context->timer_i_start = time (NULL); /* not started */ __osip_transaction_set_state (ist, IST_CONFIRMED);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -