diff --git a/libs/iax/src/iax-client.h b/libs/iax/src/iax-client.h index 2f0faf71cd..5a14fe6237 100644 --- a/libs/iax/src/iax-client.h +++ b/libs/iax/src/iax-client.h @@ -162,6 +162,9 @@ extern int iax_send_text(struct iax_session *session, char *text); extern int iax_send_ping(struct iax_session *session); extern int iax_load_complete(struct iax_session *session); extern int iax_reject(struct iax_session *session, char *reason); +int iax_reject_registration(struct iax_session *session, char *reason); +int iax_ack_registration(struct iax_session *session); +int iax_auth_registration(struct iax_session *session); extern int iax_busy(struct iax_session *session); extern int iax_congestion(struct iax_session *session); extern int iax_hangup(struct iax_session *session, char *byemsg); diff --git a/libs/iax/src/iax.c b/libs/iax/src/iax.c index 0639f2effb..19004b05a4 100644 --- a/libs/iax/src/iax.c +++ b/libs/iax/src/iax.c @@ -1255,7 +1255,11 @@ static int send_command_final(struct iax_session *i, char type, int command, uns #endif int r; r = __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 1, 0); - if (r >= 0) destroy_session(i); + if (r >= 0) { + iax_mutex_lock(session_mutex); + destroy_session(i); + iax_mutex_unlock(session_mutex); + } return r; } @@ -1669,6 +1673,24 @@ int iax_register(struct iax_session *session, char *server, char *peer, char *se return res; } +int iax_reject_registration(struct iax_session *session, char *reason) +{ + struct iax_ie_data ied; + memset(&ied, 0, sizeof(ied)); + iax_ie_append_str(&ied, IAX_IE_CAUSE, reason ? (unsigned char *) reason : (unsigned char *) "Unspecified"); + return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REGREJ, 0, ied.buf, ied.pos, -1); +} + +int iax_ack_registration(struct iax_session *session) +{ + return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REGACK, 0, NULL, 0, -1); +} + +int iax_auth_registration(struct iax_session *session) +{ + return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REGAUTH, 0, NULL, 0, -1); +} + int iax_reject(struct iax_session *session, char *reason) { struct iax_ie_data ied; diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index ca84c6de75..3f93afe4ce 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -1038,9 +1038,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void) break; case IAX_EVENT_REGREQ: /* what is the right way to handle this? */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Registration request ignored, not implemented.\n"); - iax_destroy(iaxevent->session); - iaxevent->session = NULL; + iax_reject_registration(iaxevent->session, NULL); break; case IAX_EVENT_TIMEOUT: break;