[Asterisk-code-review] SIP diversion: Fix REDIRECTING(reason) value inconsistencies. (asterisk[master])
Kevin Harwell
asteriskteam at digium.com
Wed Mar 2 12:00:02 CST 2016
Kevin Harwell has posted comments on this change.
Change subject: SIP diversion: Fix REDIRECTING(reason) value inconsistencies.
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
https://gerrit.asterisk.org/#/c/2331/1/res/res_pjsip_diversion.c
File res/res_pjsip_diversion.c:
Line 40: /*!
: * \internal
: * \brief Determine if the given string is a SIP token.
: * \since 13.8.0
: *
: * \param str String to determine if is a SIP token.
: *
: * \note A token is defined by RFC3261 Section 25.1
: *
: * \return Non-zero if the string is a SIP token.
: */
: static int sip_is_token(const char *str)
: {
: int is_token;
:
: if (ast_strlen_zero(str)) {
: /* An empty string is not a token. */
: return 0;
: }
:
: is_token = 1;
: do {
: if (!isalnum(*str)
: && !strchr("-.!%*_+`'~", *str)) {
: /* The character is not allowed in a token. */
: is_token = 0;
: break;
: }
: } while (*++str);
:
: return is_token;
: }
:
: /*! \brief Diversion header reasons
: *
: * The core defines a bunch of constants used to define
: * redirecting reasons. This provides a translation table
: * between those and the strings which may be present in
: * a SIP Diversion header
: */
: static const struct reasons {
: enum AST_REDIRECTING_REASON code;
: const char *text;
: } reason_table[] = {
: { AST_REDIRECTING_REASON_UNKNOWN, "unknown" },
: { AST_REDIRECTING_REASON_USER_BUSY, "user-busy" },
: { AST_REDIRECTING_REASON_NO_ANSWER, "no-answer" },
: { AST_REDIRECTING_REASON_UNAVAILABLE, "unavailable" },
: { AST_REDIRECTING_REASON_UNCONDITIONAL, "unconditional" },
: { AST_REDIRECTING_REASON_TIME_OF_DAY, "time-of-day" },
: { AST_REDIRECTING_REASON_DO_NOT_DISTURB, "do-not-disturb" },
: { AST_REDIRECTING_REASON_DEFLECTION, "deflection" },
: { AST_REDIRECTING_REASON_FOLLOW_ME, "follow-me" },
: { AST_REDIRECTING_REASON_OUT_OF_ORDER, "out-of-service" },
: { AST_REDIRECTING_REASON_AWAY, "away" },
: { AST_REDIRECTING_REASON_CALL_FWD_DTE, "cf_dte" }, /* Non-standard */
: { AST_REDIRECTING_REASON_SEND_TO_VM, "send_to_vm" }, /* Non-standard */
: };
:
: static const char *reason_code_to_str(const struct ast_party_redirecting_reason *reason)
: {
: int idx;
: int code;
:
: /* use specific string if given */
: if (!ast_strlen_zero(reason->str)) {
: return reason->str;
: }
:
: code = reason->code;
: for (idx = 0; idx < ARRAY_LEN(reason_table); ++idx) {
: if (code == reason_table[idx].code) {
: return reason_table[idx].text;
: }
: }
:
: return "unknown";
: }
All this code looks to be duplicated between chan_sip and here. Since these are utility functions and data can they be moved to a central location and shared (maybe callerid.c as some stuff is already there)?
For that matter can the reason_code_to_str function just be replaced by the ast_readirecting_reason_name function?
--
To view, visit https://gerrit.asterisk.org/2331
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ifba83d23a195a9f64d55b9c681d2e62476b68a87
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-HasComments: Yes
More information about the asterisk-code-review
mailing list