static int ac_packetfilter_simple(ac_sip_t *asip, void *data) { osip_message_t* sip = asip->req->evt->sip; int code = osip_message_get_status_code(sip); LOG_DEBUG("Performing simple ac on %s->%s, remote: %d\n", asip->from, asip->to, asip->req->remote_msg); /* filter only inbound */ if (asip->req->remote_msg && !asip->req->internally_generated) { /* todo: we should check that the sip from == the aor associated with the connection (on remote calls) */ /* except that that would mess up the gateway things. */ //ASSERT_ZERO(sipp_get_sip_aors_simple(sip, &local_aor, &remote_aor, 1), end); /* if ((!MSG_IS_RESPONSE(asip->evt->sip) && (strcmp(asip->from, asip->remote) || strcmp(asip->to, asip->local))) || (MSG_IS_RESPONSE(asip->evt->sip) && (strcmp(asip->to, asip->remote) || strcmp(asip->from, asip->local)))) asip->verdict = AC_VERDICT_REJECT; else */ if (MSG_IS_RESPONSE(sip)) { /* reject 482 merges, as server loops aren't of any interest to us */ if (code == 482) { LOG_WARN("Skipping %d response\n", code); asip->verdict = AC_VERDICT_REJECT; } } else if (MSG_IS_ACK(sip) || MSG_IS_BYE(sip) || MSG_IS_CANCEL(sip) || MSG_IS_UPDATE(sip)) { /* this we should let through pretty much undisturbed */ } else if (MSG_IS_SUBSCRIBE(sip) || MSG_IS_PUBLISH(sip)) { /* if this is remotely got, just reject */ asip->verdict = AC_VERDICT_REJECT; } else if (MSG_IS_INVITE(sip) || MSG_IS_MESSAGE(sip)) { /* hm, nothing.. */ // } else if (MSG_IS_NOTIFY(sip)) { } else { /* todo: what about OPTIONS? */ LOG_WARN("Got unsupported request\n"); asip->verdict = AC_VERDICT_UNSUPP; } } else { /* allow *all* outgoing! */ asip->verdict = AC_VERDICT_ALLOW; } return 1; }
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; }