chan_dahdi: Fix buggy and missing Caller ID parameters

There are several things wrong with analog Caller ID
handling that are fixed by this commit:

callerid.c's Caller ID generation function contains the
logic to use the presentation to properly send the proper
Caller ID. However, currently, DAHDI does not pass any
presentation information to the Caller ID module, which
means that presentation is completely ignored on all calls.
This means that lines could be getting Caller ID information
they aren't supposed to.

Part of the reason this has been obscured is because the
simple switch logic for handling the built in *67 and *82
is completely wrong. Rather than modifying the presentation
for the call accordingly (which is what it's supposed to do),
it simply blanks out the Caller ID or fills it in. This is
wrong, so wrong that it makes a mockery of the specification.
Additionally, it would leave to the "UNAVAILABLE" disposition
being used for Caller ID generation as opposed to the "PRIVATE"
disposition that it should have been using. This is now fixed
to only update the presentation and not modify the number and
name, so that the simple switch *67/*82 work correctly.

Next, sig_analog currently only copies over the name and number,
nothing else, when it is filling in a duplicated caller id
structure. Thus, we also now copy over the presentation
information so that is available for the Caller ID spill.
Additionally, this meant that "valid" was implicitly 0,
and as such presentation would always fail to "Unavailable".
The validity is therefore also copied over so it can be used
by ast_party_id_presentation.

As part of this fix, new API is added so that all the relevant
Caller ID information can be passed in to the Caller ID generation
functions. Parameters that are also completely missing from the
Caller ID spill have also been added, to enhance the compatibility,
correctness, and completeness of the Asterisk Caller ID implementation.

ASTERISK-29991 #close

Change-Id: Icc44a5e09979916f4c18a440f96e10dc1c76ae15
This commit is contained in:
Naveen Albert
2022-03-29 01:35:43 +00:00
committed by George Joseph
parent be6a03f68c
commit f2f397c1a8
4 changed files with 160 additions and 16 deletions

View File

@@ -55,6 +55,7 @@
#define CID_UNKNOWN_NUMBER (1 << 3)
#define CID_MSGWAITING (1 << 4)
#define CID_NOMSGWAITING (1 << 5)
#define CID_QUALIFIER (1 << 6)
#define CID_SIG_BELL 1
#define CID_SIG_V23 2
@@ -67,6 +68,12 @@
#define CID_START_POLARITY_IN 3
#define CID_START_DTMF_NOALERT 4
/* Caller ID message formats */
/*! SDMF - number only */
#define CID_TYPE_SDMF 0x00
/*! MDMF - name, number, etc. */
#define CID_TYPE_MDMF 0x01
/* defines dealing with message waiting indication generation */
/*! MWI SDMF format */
#define CID_MWI_TYPE_SDMF 0x00
@@ -101,7 +108,26 @@ void callerid_init(void);
* \return It returns the size
* (in bytes) of the data (if it returns a size of 0, there is probably an error)
*/
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec);
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec);
/*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission.
* \param buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own.
* "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun.
* \param number Use NULL for no number or "P" for "private"
* \param name name to be used
* \param ddn Dialable Directory Number (or NULL)
* \param redirecting Redirecting reason
* \param flags passed flags
* \param format Message format
* \param callwaiting callwaiting flag
* \param codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW
* \details
* This function creates a stream of callerid (a callerid spill) data in ulaw format.
* \return It returns the size
* (in bytes) of the data (if it returns a size of 0, there is probably an error)
*/
int callerid_full_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting,
int flags, int format, int callwaiting, struct ast_format *codec);
/*! \brief Create a callerID state machine
* \param cid_signalling Type of signalling in use
@@ -177,6 +203,23 @@ void callerid_free(struct callerid_state *cid);
*/
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);
/*! \brief Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
* \param buf buffer for output samples. See callerid_generate() for details regarding buffer.
* \param name Caller-ID Name
* \param number Caller-ID Number
* \param ddn Dialable Directory Number (or NULL)
* \param redirecting Redirecting Reason (-1 if N/A)
* \param pres Presentation (0 for default)
* \param qualifier Call Qualifier (0 for no, 1 for yes)
* \param format Message Format
* \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)
*
* \details
* Like ast_callerid_generate but with additional parameters.
*/
int ast_callerid_full_generate(unsigned char *buf, const char *name, const char *number,
const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec);
/*!
* \brief Generate message waiting indicator
* \param buf
@@ -198,6 +241,12 @@ int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct
*/
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);
/*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
* \see ast_callerid_generate() for other details
*/
int ast_callerid_callwaiting_full_generate(unsigned char *buf, const char *name, const char *number,
const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec);
/*! \brief Destructively parse inbuf into name and location (or number)
* \details
* Parses callerid stream from inbuf and changes into useable form, outputted in name and location.