void nict_snd_request (osip_transaction_t * nict, osip_event_t * evt) { int i; osip_t *osip = (osip_t *) nict->config; /* Here we have ict->orig_request == NULL */ nict->orig_request = evt->sip; i = osip->cb_send_message (nict, evt->sip, nict->nict_context->destination, nict->nict_context->port, nict->out_socket); if (i == 0) { /* invoke the right callback! */ if (MSG_IS_REGISTER (evt->sip)) __osip_message_callback (OSIP_NICT_REGISTER_SENT, nict, nict->orig_request); else if (MSG_IS_BYE (evt->sip)) __osip_message_callback (OSIP_NICT_BYE_SENT, nict, nict->orig_request); else if (MSG_IS_OPTIONS (evt->sip)) __osip_message_callback (OSIP_NICT_OPTIONS_SENT, nict, nict->orig_request); else if (MSG_IS_INFO (evt->sip)) __osip_message_callback (OSIP_NICT_INFO_SENT, nict, nict->orig_request); else if (MSG_IS_CANCEL (evt->sip)) __osip_message_callback (OSIP_NICT_CANCEL_SENT, nict, nict->orig_request); else if (MSG_IS_NOTIFY (evt->sip)) __osip_message_callback (OSIP_NICT_NOTIFY_SENT, nict, nict->orig_request); else if (MSG_IS_SUBSCRIBE (evt->sip)) __osip_message_callback (OSIP_NICT_SUBSCRIBE_SENT, nict, nict->orig_request); else __osip_message_callback (OSIP_NICT_UNKNOWN_REQUEST_SENT, nict, nict->orig_request); __osip_transaction_set_state (nict, NICT_TRYING); } else { nict_handle_transport_error (nict, i); } }
void nist_rcv_request (osip_transaction_t * nist, osip_event_t * evt) { int i; if (nist->state == NIST_PRE_TRYING) /* announce new REQUEST */ { /* Here we have ist->orig_request == NULL */ nist->orig_request = evt->sip; if (MSG_IS_REGISTER (evt->sip)) __osip_message_callback (OSIP_NIST_REGISTER_RECEIVED, nist, nist->orig_request); else if (MSG_IS_BYE (evt->sip)) __osip_message_callback (OSIP_NIST_BYE_RECEIVED, nist, nist->orig_request); else if (MSG_IS_OPTIONS (evt->sip)) __osip_message_callback (OSIP_NIST_OPTIONS_RECEIVED, nist, nist->orig_request); else if (MSG_IS_INFO (evt->sip)) __osip_message_callback (OSIP_NIST_INFO_RECEIVED, nist, nist->orig_request); else if (MSG_IS_CANCEL (evt->sip)) __osip_message_callback (OSIP_NIST_CANCEL_RECEIVED, nist, nist->orig_request); else if (MSG_IS_NOTIFY (evt->sip)) __osip_message_callback (OSIP_NIST_NOTIFY_RECEIVED, nist, nist->orig_request); else if (MSG_IS_SUBSCRIBE (evt->sip)) __osip_message_callback (OSIP_NIST_SUBSCRIBE_RECEIVED, nist, nist->orig_request); else __osip_message_callback (OSIP_NIST_UNKNOWN_REQUEST_RECEIVED, nist, nist->orig_request); } else /* NIST_PROCEEDING or NIST_COMPLETED */ { /* delete retransmission */ osip_message_free (evt->sip); __osip_message_callback (OSIP_NIST_REQUEST_RECEIVED_AGAIN, nist, nist->orig_request); if (nist->last_response != NULL) /* retransmit last response */ { i = __osip_transaction_snd_xxx(nist, nist->last_response); if (i != 0) { nist_handle_transport_error (nist, i); return; } else { if (MSG_IS_STATUS_1XX (nist->last_response)) __osip_message_callback (OSIP_NIST_STATUS_1XX_SENT, nist, nist->last_response); else if (MSG_IS_STATUS_2XX (nist->last_response)) __osip_message_callback (OSIP_NIST_STATUS_2XX_SENT_AGAIN, nist, nist->last_response); else __osip_message_callback (OSIP_NIST_STATUS_3456XX_SENT_AGAIN, nist, nist->last_response); return; } } /* we are already in the proper state */ return; } /* we come here only if it was the first REQUEST received */ __osip_transaction_set_state (nist, NIST_TRYING); }
void nist_rcv_request (osip_transaction_t * nist, osip_event_t * evt) { int i; osip_t *osip = (osip_t *) nist->config; if (nist->state == NIST_PRE_TRYING) /* announce new REQUEST */ { /* Here we have ist->orig_request == NULL */ nist->orig_request = evt->sip; if (MSG_IS_REGISTER (evt->sip)) __osip_message_callback (OSIP_NIST_REGISTER_RECEIVED, nist, nist->orig_request); else if (MSG_IS_BYE (evt->sip)) __osip_message_callback (OSIP_NIST_BYE_RECEIVED, nist, nist->orig_request); else if (MSG_IS_OPTIONS (evt->sip)) __osip_message_callback (OSIP_NIST_OPTIONS_RECEIVED, nist, nist->orig_request); else if (MSG_IS_INFO (evt->sip)) __osip_message_callback (OSIP_NIST_INFO_RECEIVED, nist, nist->orig_request); else if (MSG_IS_CANCEL (evt->sip)) __osip_message_callback (OSIP_NIST_CANCEL_RECEIVED, nist, nist->orig_request); else if (MSG_IS_NOTIFY (evt->sip)) __osip_message_callback (OSIP_NIST_NOTIFY_RECEIVED, nist, nist->orig_request); else if (MSG_IS_SUBSCRIBE (evt->sip)) __osip_message_callback (OSIP_NIST_SUBSCRIBE_RECEIVED, nist, nist->orig_request); else __osip_message_callback (OSIP_NIST_UNKNOWN_REQUEST_RECEIVED, nist, nist->orig_request); } else /* NIST_PROCEEDING or NIST_COMPLETED */ { /* delete retransmission */ osip_message_free (evt->sip); __osip_message_callback (OSIP_NIST_REQUEST_RECEIVED_AGAIN, nist, nist->orig_request); if (nist->last_response != NULL) /* retransmit last response */ { osip_via_t *via; via = (osip_via_t *) osip_list_get (nist->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 (nist, nist->last_response, host, port, nist->out_socket); } else i = -1; if (i != 0) { nist_handle_transport_error (nist, i); return; } else { if (MSG_IS_STATUS_1XX (nist->last_response)) __osip_message_callback (OSIP_NIST_STATUS_1XX_SENT, nist, nist->last_response); else if (MSG_IS_STATUS_2XX (nist->last_response)) __osip_message_callback (OSIP_NIST_STATUS_2XX_SENT_AGAIN, nist, nist->last_response); else __osip_message_callback (OSIP_NIST_STATUS_3456XX_SENT_AGAIN, nist, nist->last_response); return; } } /* we are already in the proper state */ return; } /* we come here only if it was the first REQUEST received */ __osip_transaction_set_state (nist, NIST_TRYING); }
void nict_snd_request (osip_transaction_t * nict, osip_event_t * evt) { int i; osip_t *osip = (osip_t *) nict->config; /* Here we have ict->orig_request == NULL */ nict->orig_request = evt->sip; i = osip->cb_send_message (nict, evt->sip, nict->nict_context->destination, nict->nict_context->port, nict->out_socket); if (i >= 0) { /* invoke the right callback! */ if (MSG_IS_REGISTER (evt->sip)) __osip_message_callback (OSIP_NICT_REGISTER_SENT, nict, nict->orig_request); else if (MSG_IS_BYE (evt->sip)) __osip_message_callback (OSIP_NICT_BYE_SENT, nict, nict->orig_request); else if (MSG_IS_OPTIONS (evt->sip)) __osip_message_callback (OSIP_NICT_OPTIONS_SENT, nict, nict->orig_request); else if (MSG_IS_INFO (evt->sip)) __osip_message_callback (OSIP_NICT_INFO_SENT, nict, nict->orig_request); else if (MSG_IS_CANCEL (evt->sip)) __osip_message_callback (OSIP_NICT_CANCEL_SENT, nict, nict->orig_request); else if (MSG_IS_NOTIFY (evt->sip)) __osip_message_callback (OSIP_NICT_NOTIFY_SENT, nict, nict->orig_request); else if (MSG_IS_SUBSCRIBE (evt->sip)) __osip_message_callback (OSIP_NICT_SUBSCRIBE_SENT, nict, nict->orig_request); else __osip_message_callback (OSIP_NICT_UNKNOWN_REQUEST_SENT, nict, nict->orig_request); #ifndef USE_BLOCKINGSOCKET /* stop timer E in reliable transport - non blocking socket: the message was just sent */ { osip_via_t *via; char *proto; int k; k = osip_message_get_via (nict->orig_request, 0, &via); /* get top via */ if (k < 0) { nict_handle_transport_error (nict, -1); return; } proto = via_get_protocol (via); if (proto == NULL) { nict_handle_transport_error (nict, -1); return; } if (i == 0) { /* but message was really sent */ if (osip_strcasecmp (proto, "TCP") != 0 && osip_strcasecmp (proto, "TLS") != 0 && osip_strcasecmp (proto, "SCTP") != 0) { } else { /* reliable protocol is used: */ nict->nict_context->timer_e_length = -1; /* E is not ACTIVE */ nict->nict_context->timer_e_start.tv_sec = -1; } } else { if (osip_strcasecmp (proto, "TCP") != 0 && osip_strcasecmp (proto, "TLS") != 0 && osip_strcasecmp (proto, "SCTP") != 0) { } else { /* reliable protocol is used: */ nict->nict_context->timer_e_length = DEFAULT_T1_TCP_PROGRESS; } } } #endif if (nict->nict_context->timer_e_length > 0) { osip_gettimeofday (&nict->nict_context->timer_e_start, NULL); add_gettimeofday (&nict->nict_context->timer_e_start, nict->nict_context->timer_e_length); } __osip_transaction_set_state (nict, NICT_TRYING); } else { nict_handle_transport_error (nict, i); } }
gint get_exosip_events(gpointer main_window) { eXosip_event_t *je; char display[500] = ""; eXosip_lock(); eXosip_unlock(); /* Check for eXosip event - timeout after 50ms */ if((je = eXosip_event_wait(0,50)) != NULL) { /* Uncomment the next line for debugging */ //fprintf(stderr, "Event type: %d %s\n", je->type, je->textinfo); imsua_display_event_info(je); if (je->type == EXOSIP_CALL_INVITE) { ims_process_incoming_invite(je); } else if (je->type == EXOSIP_CALL_REINVITE) { ims_process_incoming_reinvite(je); } else if (je->type == EXOSIP_CALL_RINGING) { ims_process_18x(je); } else if (je->type == EXOSIP_CALL_GLOBALFAILURE) { ims_process_released_call(je); } else if (je->type == EXOSIP_CALL_CLOSED) { ims_process_released_call(je); } else if (je->type == EXOSIP_CALL_ANSWERED) { ims_process_200ok(je); } else if (je->type == EXOSIP_CALL_RELEASED) { ims_process_released_call(je); } else if (je->type == EXOSIP_CALL_CANCELLED) { ims_process_released_call(je); } else if (je->type == EXOSIP_CALL_ACK) { ims_process_ack(je); } else if (je->type == EXOSIP_CALL_MESSAGE_REQUESTFAILURE) { ims_process_released_call(je); } else if (je->type == EXOSIP_CALL_REQUESTFAILURE) { set_display("Call released"); } else if (je->type == EXOSIP_CALL_SERVERFAILURE) { set_display("Call released by server"); } else if (je->type == EXOSIP_CALL_MESSAGE_NEW) { if (MSG_IS_PRACK(je->request)) ims_process_prack(je); else if (MSG_IS_UPDATE(je->request)) ims_process_update(je); else if (MSG_IS_INFO(je->request)) common_process_info(je); else if (MSG_IS_BYE(je->request)) imsua_set_message_display("OK (BYE)", 1); } else if (je->type == EXOSIP_CALL_MESSAGE_ANSWERED) { if (MSG_IS_BYE(je->request)) ims_process_released_call(je); else if (MSG_IS_UPDATE(je->request) || MSG_IS_PRACK(je->request)) ims_process_2xx(je); } else if (je->type == EXOSIP_MESSAGE_NEW) { if (MSG_IS_MESSAGE(je->request)) { /* Checks that message is actually destined for user by comparing sending TO field to IMPU */ char sending_ui[50]; strcpy(sending_ui,(((je->request)->to)->url)->username); strcat(sending_ui,"@"); strcat(sending_ui,(((je->request)->to)->url)->host); char *temp; temp = strstr(pref->impu,":") + 1; if(strcmp(sending_ui,temp)==0) { char *null_string = NULL; ims_start_im_session(je, null_string); } } else if (MSG_IS_BYE(je->request)) { set_display("Call ended"); } } else if(je->type == EXOSIP_MESSAGE_REQUESTFAILURE) { } else if(je->type == EXOSIP_MESSAGE_ANSWERED) { } else if(je->type == EXOSIP_REGISTRATION_SUCCESS) { if(is_message_deregister == 1) { registered = NOT_REGISTERED; is_message_deregister = 0; sprintf(display, "Deregistered with %s",pref->realm); set_display(display); sprintf(display,"Not registered"); set_status_bar(display); watchers_remove_all_watchers(); num_associated_uris = 0; } else { registered = REGISTERED; ims_process_registration_200ok(je); } } else if(je->type == EXOSIP_REGISTRATION_FAILURE) { if((je->response)== NULL) { set_display("Registration failed for unknown reason\nMost probably incorrect credentials\n\nCheck Preferences"); } else if(((je->response)->status_code == 403)) { set_display("Invalid user name\n\nCheck Preferences"); } else if(((je->response)->status_code == 401)) { ims_process_401(je); } else if(((je->response)->status_code == 404) || ((je->response)->status_code == 407)) { set_display("Error with credentials\n\nCheck Preferences"); } else { set_display("Registration failed for unknown reason\n\nMost probably incorrect credentials\nCheck Preferences"); } } else if(je->type == EXOSIP_REGISTRATION_REFRESHED) { set_display("Registration Refreshed"); registered = REGISTERED; } else if(je->type == EXOSIP_REGISTRATION_TERMINATED) { } else if(je->type == EXOSIP_SUBSCRIPTION_ANSWERED) { ims_process_subscription_answered(je); } else if (je->type == EXOSIP_SUBSCRIPTION_NOTIFY) { ims_process_notify(je); } else if (je->type == EXOSIP_SUBSCRIPTION_REQUESTFAILURE) { } else if (je->type == EXOSIP_IN_SUBSCRIPTION_NEW) { } else if((je->response)&&((je->response)->status_code == 302)) { ims_process_302(je); } else { } } return TRUE; }