/* ======================== conds ======================== */ static tsk_bool_t _fsm_cond_not_served_here(tsip_dialog_register_t* dialog, tsip_message_t* message) { if(message && TSIP_REQUEST_IS_REGISTER(message)){ if(tsk_object_cmp(TSIP_DIALOG_GET_STACK(dialog)->network.realm, message->line.request.uri) != 0){ tsip_dialog_register_send_RESPONSE(dialog, TSIP_MESSAGE_AS_REQUEST(message), 404, "Domain not served here"); return tsk_true; } } return tsk_false; }
/** * @fn int tsip_dialog_register_event_callback(const tsip_dialog_register_t *self, tsip_dialog_event_type_t type, * const tsip_message_t *msg) * * @brief Callback function called to alert the dialog for new events from the transaction/transport layers. * * @param [in,out] self A reference to the dialog. * @param type The event type. * @param [in,out] msg The incoming SIP/IMS message. * * @return Zero if succeed and non-zero error code otherwise. **/ int tsip_dialog_register_event_callback(const tsip_dialog_register_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) { int ret = -1; switch(type){ case tsip_dialog_i_msg: { if(msg){ if(TSIP_MESSAGE_IS_RESPONSE(msg)){ // // RESPONSE // const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; if(TSIP_RESPONSE_IS_1XX(msg)){ ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, action); } else if(TSIP_RESPONSE_IS_2XX(msg)){ ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, action); } else if(TSIP_RESPONSE_IS(msg,401) || TSIP_RESPONSE_IS(msg,407) || TSIP_RESPONSE_IS(msg,421) || TSIP_RESPONSE_IS(msg,494)){ ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, action); } else if(TSIP_RESPONSE_IS(msg,423)){ ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_423, msg, action); } else{ // Alert User ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, action); /* TSK_DEBUG_WARN("Not supported status code: %d", TSIP_RESPONSE_CODE(msg)); */ } } else{ // // REQUEST // if(TSIP_REQUEST_IS_REGISTER(msg)){ ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iREGISTER, msg, tsk_null); } } } break; } case tsip_dialog_canceled: { ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); break; } case tsip_dialog_terminated: case tsip_dialog_timedout: case tsip_dialog_error: case tsip_dialog_transport_error: { ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); break; } default: break; } return ret; }