<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18802">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_dahdi: Fix buggy and missing Caller ID parameters<br><br>There are several things wrong with analog Caller ID<br>handling that are fixed by this commit:<br><br>callerid.c's Caller ID generation function contains the<br>logic to use the presentation to properly send the proper<br>Caller ID. However, currently, DAHDI does not pass any<br>presentation information to the Caller ID module, which<br>means that presentation is completely ignored on all calls.<br>This means that lines could be getting Caller ID information<br>they aren't supposed to.<br><br>Part of the reason this has been obscured is because the<br>simple switch logic for handling the built in *67 and *82<br>is completely wrong. Rather than modifying the presentation<br>for the call accordingly (which is what it's supposed to do),<br>it simply blanks out the Caller ID or fills it in. This is<br>wrong, so wrong that it makes a mockery of the specification.<br>Additionally, it would leave to the "UNAVAILABLE" disposition<br>being used for Caller ID generation as opposed to the "PRIVATE"<br>disposition that it should have been using. This is now fixed<br>to only update the presentation and not modify the number and<br>name, so that the simple switch *67/*82 work correctly.<br><br>Next, sig_analog currently only copies over the name and number,<br>nothing else, when it is filling in a duplicated caller id<br>structure. Thus, we also now copy over the presentation<br>information so that is available for the Caller ID spill.<br>Additionally, this meant that "valid" was implicitly 0,<br>and as such presentation would always fail to "Unavailable".<br>The validity is therefore also copied over so it can be used<br>by ast_party_id_presentation.<br><br>As part of this fix, new API is added so that all the relevant<br>Caller ID information can be passed in to the Caller ID generation<br>functions. Parameters that are also completely missing from the<br>Caller ID spill have also been added, to enhance the compatibility,<br>correctness, and completeness of the Asterisk Caller ID implementation.<br><br>ASTERISK-29991 #close<br><br>Change-Id: Icc44a5e09979916f4c18a440f96e10dc1c76ae15<br>---<br>M channels/chan_dahdi.c<br>M channels/sig_analog.c<br>M include/asterisk/callerid.h<br>M main/callerid.c<br>4 files changed, 160 insertions(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/02/18802/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c</span><br><span>index 506c7a9..5a1f11e 100644</span><br><span>--- a/channels/chan_dahdi.c</span><br><span>+++ b/channels/chan_dahdi.c</span><br><span>@@ -1613,19 +1613,29 @@</span><br><span> }</span><br><span> </span><br><span> if ((p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ int pres = ast_party_id_presentation(&caller->id);</span><br><span> if (cwcid == 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- p->cidlen = ast_callerid_generate(p->cidspill,</span><br><span style="color: hsl(120, 100%, 40%);">+ p->cidlen = ast_callerid_full_generate(p->cidspill,</span><br><span> caller->id.name.str,</span><br><span> caller->id.number.str,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ -1,</span><br><span style="color: hsl(120, 100%, 40%);">+ pres,</span><br><span style="color: hsl(120, 100%, 40%);">+ 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ CID_TYPE_MDMF,</span><br><span> AST_LAW(p));</span><br><span> } else {</span><br><span> ast_verb(3, "CPE supports Call Waiting Caller*ID. Sending '%s/%s'\n",</span><br><span> caller->id.name.str, caller->id.number.str);</span><br><span> p->callwaitcas = 0;</span><br><span> p->cidcwexpire = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- p->cidlen = ast_callerid_callwaiting_generate(p->cidspill,</span><br><span style="color: hsl(120, 100%, 40%);">+ p->cidlen = ast_callerid_callwaiting_full_generate(p->cidspill,</span><br><span> caller->id.name.str,</span><br><span> caller->id.number.str,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ -1,</span><br><span style="color: hsl(120, 100%, 40%);">+ pres,</span><br><span style="color: hsl(120, 100%, 40%);">+ 0,</span><br><span> AST_LAW(p));</span><br><span> p->cidlen += READ_SIZE * 4;</span><br><span> }</span><br><span>diff --git a/channels/sig_analog.c b/channels/sig_analog.c</span><br><span>index fb93d5f..469fa06 100644</span><br><span>--- a/channels/sig_analog.c</span><br><span>+++ b/channels/sig_analog.c</span><br><span>@@ -1089,6 +1089,10 @@</span><br><span> if (p->use_callerid) {</span><br><span> p->caller.id.name.str = p->lastcid_name;</span><br><span> p->caller.id.number.str = p->lastcid_num;</span><br><span style="color: hsl(120, 100%, 40%);">+ p->caller.id.name.valid = ast_channel_connected(ast)->id.name.valid;</span><br><span style="color: hsl(120, 100%, 40%);">+ p->caller.id.number.valid = ast_channel_connected(ast)->id.number.valid;</span><br><span style="color: hsl(120, 100%, 40%);">+ p->caller.id.name.presentation = ast_channel_connected(ast)->id.name.presentation;</span><br><span style="color: hsl(120, 100%, 40%);">+ p->caller.id.number.presentation = ast_channel_connected(ast)->id.number.presentation;</span><br><span> }</span><br><span> </span><br><span> ast_setstate(ast, AST_STATE_RINGING);</span><br><span>@@ -2264,10 +2268,8 @@</span><br><span> ast_verb(3, "Disabling Caller*ID on %s\n", ast_channel_name(chan));</span><br><span> /* Disable Caller*ID if enabled */</span><br><span> p->hidecallerid = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- ast_party_number_free(&ast_channel_caller(chan)->id.number);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_party_number_init(&ast_channel_caller(chan)->id.number);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_party_name_free(&ast_channel_caller(chan)->id.name);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_party_name_init(&ast_channel_caller(chan)->id.name);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_caller(chan)->id.number.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_caller(chan)->id.name.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;</span><br><span> res = analog_play_tone(p, idx, ANALOG_TONE_DIALRECALL);</span><br><span> if (res) {</span><br><span> ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",</span><br><span>@@ -2353,7 +2355,8 @@</span><br><span> ast_verb(3, "Enabling Caller*ID on %s\n", ast_channel_name(chan));</span><br><span> /* Enable Caller*ID if enabled */</span><br><span> p->hidecallerid = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- ast_set_callerid(chan, p->cid_num, p->cid_name, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_caller(chan)->id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_caller(chan)->id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;</span><br><span> res = analog_play_tone(p, idx, ANALOG_TONE_DIALRECALL);</span><br><span> if (res) {</span><br><span> ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",</span><br><span>diff --git a/include/asterisk/callerid.h b/include/asterisk/callerid.h</span><br><span>index 460f105..16a3df1 100644</span><br><span>--- a/include/asterisk/callerid.h</span><br><span>+++ b/include/asterisk/callerid.h</span><br><span>@@ -55,6 +55,7 @@</span><br><span> #define CID_UNKNOWN_NUMBER (1 << 3)</span><br><span> #define CID_MSGWAITING (1 << 4)</span><br><span> #define CID_NOMSGWAITING (1 << 5)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CID_QUALIFIER (1 << 6)</span><br><span> </span><br><span> #define CID_SIG_BELL 1</span><br><span> #define CID_SIG_V23 2</span><br><span>@@ -67,6 +68,12 @@</span><br><span> #define CID_START_POLARITY_IN 3</span><br><span> #define CID_START_DTMF_NOALERT 4</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Caller ID message formats */</span><br><span style="color: hsl(120, 100%, 40%);">+/*! SDMF - number only */</span><br><span style="color: hsl(120, 100%, 40%);">+#define CID_TYPE_SDMF 0x00</span><br><span style="color: hsl(120, 100%, 40%);">+/*! MDMF - name, number, etc. */</span><br><span style="color: hsl(120, 100%, 40%);">+#define CID_TYPE_MDMF 0x01</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* defines dealing with message waiting indication generation */</span><br><span> /*! MWI SDMF format */</span><br><span> #define CID_MWI_TYPE_SDMF 0x00</span><br><span>@@ -101,7 +108,26 @@</span><br><span> * \return It returns the size</span><br><span> * (in bytes) of the data (if it returns a size of 0, there is probably an error)</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec);</span><br><span style="color: hsl(120, 100%, 40%);">+int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own.</span><br><span style="color: hsl(120, 100%, 40%);">+ * "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param number Use NULL for no number or "P" for "private"</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param name name to be used</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param ddn Dialable Directory Number (or NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param redirecting Redirecting reason</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param flags passed flags</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param format Message format</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param callwaiting callwaiting flag</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW</span><br><span style="color: hsl(120, 100%, 40%);">+ * \details</span><br><span style="color: hsl(120, 100%, 40%);">+ * This function creates a stream of callerid (a callerid spill) data in ulaw format.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return It returns the size</span><br><span style="color: hsl(120, 100%, 40%);">+ * (in bytes) of the data (if it returns a size of 0, there is probably an error)</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int callerid_full_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting,</span><br><span style="color: hsl(120, 100%, 40%);">+ int flags, int format, int callwaiting, struct ast_format *codec);</span><br><span> </span><br><span> /*! \brief Create a callerID state machine</span><br><span> * \param cid_signalling Type of signalling in use</span><br><span>@@ -177,6 +203,23 @@</span><br><span> */</span><br><span> int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param buf buffer for output samples. See callerid_generate() for details regarding buffer.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param name Caller-ID Name</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param number Caller-ID Number</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param ddn Dialable Directory Number (or NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param redirecting Redirecting Reason (-1 if N/A)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param pres Presentation (0 for default)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param qualifier Call Qualifier (0 for no, 1 for yes)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param format Message Format</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \details</span><br><span style="color: hsl(120, 100%, 40%);">+ * Like ast_callerid_generate but with additional parameters.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_callerid_full_generate(unsigned char *buf, const char *name, const char *number,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*!</span><br><span> * \brief Generate message waiting indicator</span><br><span> * \param buf</span><br><span>@@ -198,6 +241,12 @@</span><br><span> */</span><br><span> int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)</span><br><span style="color: hsl(120, 100%, 40%);">+ * \see ast_callerid_generate() for other details</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_callerid_callwaiting_full_generate(unsigned char *buf, const char *name, const char *number,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Destructively parse inbuf into name and location (or number)</span><br><span> * \details</span><br><span> * Parses callerid stream from inbuf and changes into useable form, outputted in name and location.</span><br><span>diff --git a/main/callerid.c b/main/callerid.c</span><br><span>index 4d6186b..c6c29a0 100644</span><br><span>--- a/main/callerid.c</span><br><span>+++ b/main/callerid.c</span><br><span>@@ -736,7 +736,8 @@</span><br><span> ast_free(cid);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static int callerid_genmsg(char *msg, int size, const char *number, const char *name, int flags)</span><br><span style="color: hsl(120, 100%, 40%);">+static int callerid_genmsg(char *msg, int size, const char *number, const char *name, int flags, int format,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *ddn, int redirecting)</span><br><span> {</span><br><span> struct timeval now = ast_tvnow();</span><br><span> struct ast_tm tm;</span><br><span>@@ -754,6 +755,7 @@</span><br><span> tm.tm_mday, tm.tm_hour, tm.tm_min);</span><br><span> size -= res;</span><br><span> ptr += res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_strlen_zero(number) || (flags & CID_UNKNOWN_NUMBER)) {</span><br><span> /* Indicate number not known */</span><br><span> res = snprintf(ptr, size, "\004\001O");</span><br><span>@@ -779,6 +781,11 @@</span><br><span> size -= i;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (format == CID_TYPE_SDMF) { /* If Simple Data Message Format, we're done. */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* (some older Caller ID units only support SDMF. If they get an MDMF spill, it's useless.) */</span><br><span style="color: hsl(120, 100%, 40%);">+ return (ptr - msg);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_strlen_zero(name) || (flags & CID_UNKNOWN_NAME)) {</span><br><span> /* Indicate name not known */</span><br><span> res = snprintf(ptr, size, "\010\001O");</span><br><span>@@ -803,8 +810,44 @@</span><br><span> ptr += i;</span><br><span> size -= i;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- return (ptr - msg);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Call Qualifier */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (flags & CID_QUALIFIER) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res = snprintf(ptr, size, "\006\001L"); /* LDC (Long Distance Call) is the only valid option */</span><br><span style="color: hsl(120, 100%, 40%);">+ size -= res;</span><br><span style="color: hsl(120, 100%, 40%);">+ ptr += res;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* DDN (Dialable Directory Number) - 11 digits MAX, parameter 003 */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* some CPE seem to display the DDN instead of the CLID, if sent */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Redirecting Reason */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (redirecting >= 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (redirecting) {</span><br><span style="color: hsl(120, 100%, 40%);">+ case AST_REDIRECTING_REASON_USER_BUSY:</span><br><span style="color: hsl(120, 100%, 40%);">+ res = snprintf(ptr, size, "\005\001\001");</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ case AST_REDIRECTING_REASON_NO_ANSWER:</span><br><span style="color: hsl(120, 100%, 40%);">+ res = snprintf(ptr, size, "\005\001\002");</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ case AST_REDIRECTING_REASON_UNCONDITIONAL:</span><br><span style="color: hsl(120, 100%, 40%);">+ res = snprintf(ptr, size, "\005\001\003");</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ case AST_REDIRECTING_REASON_CALL_FWD_DTE:</span><br><span style="color: hsl(120, 100%, 40%);">+ res = snprintf(ptr, size, "\005\001\004");</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ case AST_REDIRECTING_REASON_DEFLECTION:</span><br><span style="color: hsl(120, 100%, 40%);">+ res = snprintf(ptr, size, "\005\001\005");</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ default:</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ptr += res;</span><br><span style="color: hsl(120, 100%, 40%);">+ size -= res;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return (ptr - msg);</span><br><span> }</span><br><span> </span><br><span> int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec,</span><br><span>@@ -824,7 +867,7 @@</span><br><span> msg[0] = 0x82;</span><br><span> </span><br><span> /* put date, number info at the right place */</span><br><span style="color: hsl(0, 100%, 40%);">- len = callerid_genmsg(msg+2, sizeof(msg)-2, number, name, flags);</span><br><span style="color: hsl(120, 100%, 40%);">+ len = callerid_genmsg(msg+2, sizeof(msg)-2, number, name, flags, CID_TYPE_MDMF, "", -1);</span><br><span> </span><br><span> /* length of MDMF CLI plus Message Waiting Structure */</span><br><span> msg[1] = len+3;</span><br><span>@@ -897,6 +940,12 @@</span><br><span> </span><br><span> int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ return callerid_full_generate(buf, number, name, NULL, -1, flags, CID_TYPE_MDMF, callwaiting, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int callerid_full_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting,</span><br><span style="color: hsl(120, 100%, 40%);">+ int flags, int format, int callwaiting, struct ast_format *codec)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span> int bytes = 0;</span><br><span> int x, sum;</span><br><span> int len;</span><br><span>@@ -906,7 +955,7 @@</span><br><span> float ci = 0.0;</span><br><span> float scont = 0.0;</span><br><span> char msg[256];</span><br><span style="color: hsl(0, 100%, 40%);">- len = callerid_genmsg(msg, sizeof(msg), number, name, flags);</span><br><span style="color: hsl(120, 100%, 40%);">+ len = callerid_genmsg(msg, sizeof(msg), number, name, flags, format, ddn, redirecting);</span><br><span> if (!callwaiting) {</span><br><span> /* Wait a half a second */</span><br><span> for (x = 0; x < 4000; x++)</span><br><span>@@ -1051,23 +1100,56 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static int __ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int callwaiting, struct ast_format *codec)</span><br><span style="color: hsl(120, 100%, 40%);">+static int __ast_callerid_generate(unsigned char *buf, const char *name, const char *number,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *ddn, int redirecting, int pres, int qualifier, int format, int callwaiting, struct ast_format *codec)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ int flags = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "Caller ID Type %s: Number: %s, Name: %s, Redirecting No: %s, Redirecting Reason: %s, Pres: %s, Qualifier: %s, Format: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ callwaiting ? "II" : "I", number, name, ddn, ast_redirecting_reason_describe(redirecting),</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_named_caller_presentation(pres), qualifier ? "LDC" : "None", format == CID_TYPE_MDMF ? "MDMF" : "SDMF");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_strlen_zero(name))</span><br><span> name = NULL;</span><br><span> if (ast_strlen_zero(number))</span><br><span> number = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- return callerid_generate(buf, number, name, 0, callwaiting, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pres & AST_PRES_RESTRICTED) {</span><br><span style="color: hsl(120, 100%, 40%);">+ flags |= CID_PRIVATE_NUMBER;</span><br><span style="color: hsl(120, 100%, 40%);">+ flags |= CID_PRIVATE_NAME;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (pres & AST_PRES_UNAVAILABLE) {</span><br><span style="color: hsl(120, 100%, 40%);">+ flags |= CID_UNKNOWN_NUMBER;</span><br><span style="color: hsl(120, 100%, 40%);">+ flags |= CID_UNKNOWN_NAME;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (qualifier) {</span><br><span style="color: hsl(120, 100%, 40%);">+ flags |= CID_QUALIFIER;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return callerid_full_generate(buf, number, name, ddn, redirecting, flags, format, callwaiting, codec);</span><br><span> }</span><br><span> </span><br><span> int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return __ast_callerid_generate(buf, name, number, 0, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+ return __ast_callerid_generate(buf, name, number, "", -1, 0, 0, CID_TYPE_MDMF, 0, codec);</span><br><span> }</span><br><span> </span><br><span> int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return __ast_callerid_generate(buf, name, number, 1, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+ return __ast_callerid_generate(buf, name, number, "", -1, 0, 0, CID_TYPE_MDMF, 1, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_callerid_full_generate(unsigned char *buf, const char *name, const char *number,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ return __ast_callerid_generate(buf, name, number, ddn, redirecting, pres, qualifier, format, 0, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_callerid_callwaiting_full_generate(unsigned char *buf, const char *name, const char *number,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Type II Caller ID (CWCID) only uses MDMF, so format isn't an argument */</span><br><span style="color: hsl(120, 100%, 40%);">+ return __ast_callerid_generate(buf, name, number, ddn, redirecting, pres, qualifier, CID_TYPE_MDMF, 1, codec);</span><br><span> }</span><br><span> </span><br><span> char *ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18802">change 18802</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18802"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Icc44a5e09979916f4c18a440f96e10dc1c76ae15 </div>
<div style="display:none"> Gerrit-Change-Number: 18802 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>