From 0a6d87edfe40cc00985c179f63c7d666bc6bc948 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 30 Apr 2019 23:26:41 +0000 Subject: [PATCH] FS-11824 [sofia-sip,mod_sofia,core] Added cause codes that map to SIP 600,603,604,606,607 --- libs/sofia-sip/libsofia-sip-ua/sip/sip_status.c | 2 ++ libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c | 9 +++++++++ .../libsofia-sip-ua/sip/sofia-sip/sip_status.h | 3 +++ libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c | 1 + src/include/switch_types.h | 7 ++++++- src/mod/endpoints/mod_sofia/mod_sofia.c | 11 +++++++++++ src/switch_channel.c | 4 ++++ 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sip_status.c b/libs/sofia-sip/libsofia-sip-ua/sip/sip_status.c index f75da713eb..2ea82963e6 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sip_status.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sip_status.c @@ -104,6 +104,7 @@ char const sip_603_Decline[] = "Decline", sip_604_Does_not_exist_anywhere[] = "Does Not Exist Anywhere", sip_606_Not_acceptable[] = "Not Acceptable", + sip_607_Unwanted[] = "Unwanted", sip_687_Dialog_terminated[] = "Dialog Terminated" ; @@ -191,6 +192,7 @@ char const *sip_status_phrase(int status) case 603: return sip_603_Decline; case 604: return sip_604_Does_not_exist_anywhere; case 606: return sip_606_Not_acceptable; + case 607: return sip_607_Unwanted; case 687: return sip_687_Dialog_terminated; } diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c b/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c index 051ba5ae39..e5ef095eb0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c @@ -1422,6 +1422,15 @@ int sip_response_terminates_dialog(int response_code, */ *return_graceful_terminate_usage = 0; return 0; + + case 607: /** @par 607 Unwanted + + This response is similar to 603, except it informs the caller + that the call is unwanted and may be blacklisted. Added by + RFC-8197 + */ + *return_graceful_terminate_usage = 0; + return 0; } /* Do not change graceful_terminate */ diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_status.h b/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_status.h index c5a738927f..b10d165e3a 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_status.h +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_status.h @@ -169,6 +169,8 @@ SOFIAPUBFUN char const *sip_status_phrase(int status); #define SIP_604_DOES_NOT_EXIST_ANYWHERE 604, sip_604_Does_not_exist_anywhere /** 606 Not Acceptable @HIDE */ #define SIP_606_NOT_ACCEPTABLE 606, sip_606_Not_acceptable +/** 607 Unwanted @HIDE */ +#define SIP_607_UNWANTED 607, sip_607_Unwanted /** 687 Dialog terminated @HIDE */ #define SIP_687_DIALOG_TERMINATED 687, sip_687_Dialog_terminated @@ -238,6 +240,7 @@ SOFIAPUBVAR char const sip_600_Busy_everywhere[]; SOFIAPUBVAR char const sip_603_Decline[]; SOFIAPUBVAR char const sip_604_Does_not_exist_anywhere[]; SOFIAPUBVAR char const sip_606_Not_acceptable[]; +SOFIAPUBVAR char const sip_607_Unwanted[]; SOFIAPUBVAR char const sip_687_Dialog_terminated[]; SOFIA_END_DECLS diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c b/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c index 2927380728..00514fbd2c 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c @@ -1511,6 +1511,7 @@ static int response_phrase_test(void) { SIP_603_DECLINE }, { SIP_604_DOES_NOT_EXIST_ANYWHERE }, { SIP_606_NOT_ACCEPTABLE }, + { SIP_607_UNWANTED }, { 0, NULL } }; int i; diff --git a/src/include/switch_types.h b/src/include/switch_types.h index eb45ec630a..52c2fef3b7 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -2175,7 +2175,12 @@ typedef enum { SWITCH_CAUSE_INVALID_PROFILE = 611, SWITCH_CAUSE_NO_PICKUP = 612, SWITCH_CAUSE_SRTP_READ_ERROR = 613, - SWITCH_CAUSE_BOWOUT = 614 + SWITCH_CAUSE_BOWOUT = 614, + SWITCH_CAUSE_BUSY_EVERYWHERE = 615, + SWITCH_CAUSE_DECLINE = 616, + SWITCH_CAUSE_DOES_NOT_EXIST_ANYWHERE = 617, + SWITCH_CAUSE_NOT_ACCEPTABLE = 618, + SWITCH_CAUSE_UNWANTED = 619 } switch_call_cause_t; typedef enum { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index a1aecbe0a3..c2900cf515 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -340,6 +340,17 @@ static int hangup_cause_to_sip(switch_call_cause_t cause) return 487; case SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR: return 483; + /* Custom mappings not part of RFC */ + case SWITCH_CAUSE_BUSY_EVERYWHERE: + return 600; + case SWITCH_CAUSE_DECLINE: + return 603; + case SWITCH_CAUSE_DOES_NOT_EXIST_ANYWHERE: + return 604; + case SWITCH_CAUSE_NOT_ACCEPTABLE: + return 606; + case SWITCH_CAUSE_UNWANTED: + return 607; default: return 480; } diff --git a/src/switch_channel.c b/src/switch_channel.c index f87b5a9e71..ad77b5fbc9 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -125,6 +125,10 @@ static struct switch_cause_table CAUSE_CHART[] = { {"NO_PICKUP", SWITCH_CAUSE_NO_PICKUP}, {"SRTP_READ_ERROR", SWITCH_CAUSE_SRTP_READ_ERROR}, {"BOWOUT", SWITCH_CAUSE_BOWOUT}, + {"BUSY_EVERYWHERE", SWITCH_CAUSE_BUSY_EVERYWHERE}, + {"DECLINE", SWITCH_CAUSE_DECLINE}, + {"DOES_NOT_EXIST_ANYWHERE", SWITCH_CAUSE_DOES_NOT_EXIST_ANYWHERE}, + {"UNWANTED", SWITCH_CAUSE_UNWANTED}, {NULL, 0} };