[asterisk-commits] rmudgett: branch group/issue8824 r143470 - in /team/group/issue8824: apps/ ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 18 11:21:37 CDT 2008


Author: rmudgett
Date: Thu Sep 18 11:21:37 2008
New Revision: 143470

URL: http://svn.digium.com/view/asterisk?view=rev&rev=143470
Log:
*  Added enumeration values for connected line source and
redirecting reason.

channels/misdn/isdn_lib.c
channels/misdn/isdn_msg_parser.c
*  Fixed null pointer dereference when chan_misdn tries to send a
FACILITY message that is not supported by mISDN.

funcs/func_connectedline.c
funcs/func_redirecting.c
*  Made the dial plan functions accept enumeration names as well as
numbers for the connected line source and redirecting reason.

include/asterisk/callerid.h
main/callerid.c
*  Added enumeration values and conversion functions for the connected
line source and	redirecting reason.


Modified:
    team/group/issue8824/apps/app_dial.c
    team/group/issue8824/apps/app_queue.c
    team/group/issue8824/channels/chan_misdn.c
    team/group/issue8824/channels/chan_sip.c
    team/group/issue8824/channels/misdn/isdn_lib.c
    team/group/issue8824/channels/misdn/isdn_msg_parser.c
    team/group/issue8824/funcs/func_connectedline.c
    team/group/issue8824/funcs/func_redirecting.c
    team/group/issue8824/include/asterisk/callerid.h
    team/group/issue8824/include/asterisk/channel.h
    team/group/issue8824/main/callerid.c
    team/group/issue8824/main/channel.c
    team/group/issue8824/main/features.c

Modified: team/group/issue8824/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_dial.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/apps/app_dial.c (original)
+++ team/group/issue8824/apps/app_dial.c Thu Sep 18 11:21:37 2008
@@ -567,7 +567,7 @@
 
 		if (!ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(outgoing, DIAL_NOCONNECTEDLINE)) {
 			ast_party_connected_line_collect_caller(&connected_caller, &outgoing->chan->cid);
-			connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+			connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 			ast_connected_line_update(in, &connected_caller);
 		}
 	}
@@ -618,7 +618,7 @@
 					ast_verb(3, "%s answered %s\n", c->name, in->name);
 					if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
 						ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
-						connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+						connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 						ast_connected_line_update(in, &connected_caller);
 					}
 					peer = c;
@@ -661,7 +661,7 @@
 						ast_verb(3, "%s answered %s\n", c->name, in->name);
 						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
 							ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
-							connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+							connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 							ast_connected_line_update(in, &connected_caller);
 						}
 						peer = c;

Modified: team/group/issue8824/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_queue.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/apps/app_queue.c (original)
+++ team/group/issue8824/apps/app_queue.c Thu Sep 18 11:21:37 2008
@@ -93,6 +93,7 @@
 #include "asterisk/strings.h"
 #include "asterisk/global_datastores.h"
 #include "asterisk/taskprocessor.h"
+#include "asterisk/callerid.h"
 
 /*!
  * \par Please read before modifying this file.
@@ -2455,7 +2456,7 @@
 					ast_verb(3, "%s answered %s\n", o->chan->name, in->name);
 					if (update_connectedline && o->update_connectedline) {
 						ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
-						connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+						connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 						ast_connected_line_update(in, &connected_caller);
 					}
 					peer = o;
@@ -2526,7 +2527,7 @@
 								ast_verb(3, "%s answered %s\n", o->chan->name, in->name);
 								if (update_connectedline && o->update_connectedline) {
 									ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
-									connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+									connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 									ast_connected_line_update(in, &connected_caller);
 								}
 								peer = o;

Modified: team/group/issue8824/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_misdn.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/channels/chan_misdn.c (original)
+++ team/group/issue8824/channels/chan_misdn.c Thu Sep 18 11:21:37 2008
@@ -2159,7 +2159,7 @@
 	} else if (strstr(a->argv[3],"CFDeactivate")) {
 
 		if (a->argc < 6) {
-			ast_verbose("CFActivate requires 1 arg: FromNumber\n\n");
+			ast_verbose("CFDeactivate requires 1 arg: FromNumber\n\n");
 			return 0;
 		}
 		port = atoi(a->argv[4]);
@@ -2171,8 +2171,8 @@
 		bc->fac_out.Function = Fac_CFDeactivate;
 		bc->fac_out.u.CFDeactivate.BasicService = 0; //All Services
 		bc->fac_out.u.CFDeactivate.Procedure = 0; //Unconditional
-		
 		ast_copy_string((char *)bc->fac_out.u.CFActivate.ServedUserNumber, served_nr, sizeof(bc->fac_out.u.CFActivate.ServedUserNumber));
+
 		misdn_lib_send_event(bc, EVENT_FACILITY);
 	}
 
@@ -5288,7 +5288,7 @@
 				| misdn_plan_to_ast_plan(bc->connected.number_plan);
 			connected.id.number_presentation = misdn_pres_to_ast_pres(bc->connected.presentation)
 				| misdn_screen_to_ast_screen(bc->connected.screening);
-			connected.source = 0;	/*! \todo XXX Need an answer value to put here */
+			connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 			ast_queue_connected_line_update(ch->ast, &connected);
 		}
 	

Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Thu Sep 18 11:21:37 2008
@@ -15490,7 +15490,7 @@
 				connected.id.number = (char *) p->cid_num;
 				connected.id.name = (char *) p->cid_name;
 				connected.id.number_presentation = p->callingpres;
-				connected.source = 0;	/*! \todo XXX Need an answer value to put here */
+				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 				ast_queue_connected_line_update(p->owner, &connected);
 			}
 			ast_queue_control(p->owner, AST_CONTROL_RINGING);
@@ -15521,7 +15521,7 @@
 				connected.id.number = (char *) p->cid_num;
 				connected.id.name = (char *) p->cid_name;
 				connected.id.number_presentation = p->callingpres;
-				connected.source = 0;	/*! \todo XXX Need an answer value to put here */
+				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 				ast_queue_connected_line_update(p->owner, &connected);
 			}
 		}
@@ -17616,7 +17616,7 @@
 				connected.id.number = (char *) p->cid_num;
 				connected.id.name = (char *) p->cid_name;
 				connected.id.number_presentation = p->callingpres;
-				connected.source = 0;	/*! \todo XXX Need a transfer value to put here */
+				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 				ast_queue_connected_line_update(p->owner, &connected);
 			}
 			/* Handle SDP here if we already have an owner */
@@ -18167,18 +18167,18 @@
 		if (target.chan2) {
 			/* Tell each of the other channels to whom they are now connected */
 			ast_party_connected_line_collect_caller(&connected_caller, &current->chan2->cid);
-			connected_caller.source = 0;	/*! \todo XXX Need a transfer value to put here */
+			connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 			ast_connected_line_update(target.chan2, &connected_caller);
 			ast_party_connected_line_collect_caller(&connected_caller, &target.chan2->cid);
-			connected_caller.source = 0;	/*! \todo XXX Need a transfer value to put here */
+			connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 			ast_connected_line_update(current->chan2, &connected_caller);
 		} else {
 			/* Notify the first other party that they are connected to someone else assuming that target.chan1
 			   has progressed far enough through the dialplan to have it's called party information set. */ 
 			if (current->chan2) {
-				/*! \todo XXX Need a transfer value to put here (maybe) */
-				//target.chan1->connected.source = 0;
-				ast_connected_line_update(current->chan2, &target.chan1->connected);
+				connected_caller = target.chan1->connected;
+				connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
+				ast_connected_line_update(current->chan2, &connected_caller);
 			}
 
 			/* We can't indicate to the called channel directly so we force the masquerade to complete
@@ -18188,7 +18188,7 @@
 			ast_channel_unlock(target.chan1);
 
 			ast_party_connected_line_collect_caller(&connected_caller, &target.chan1->cid);
-			connected_caller.source = 0;	/*! \todo XXX Need a transfer value to put here */
+			connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 			ast_queue_connected_line_update(target.chan1, &connected_caller);
 		}
 	}

Modified: team/group/issue8824/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/misdn/isdn_lib.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/channels/misdn/isdn_lib.c (original)
+++ team/group/issue8824/channels/misdn/isdn_lib.c Thu Sep 18 11:21:37 2008
@@ -3605,8 +3605,19 @@
   
 	/* Later we should think about sending bchannel data directly to misdn. */
 	msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
-	msg_queue_tail(&stack->downqueue, msg);
-	sem_post(&glob_mgr->new_msg);
+	if (!msg) {
+		/*
+		 * The message was not built.
+		 *
+		 * NOTE:  The only time that the message will fail to build
+		 * is because the requested FACILITY message is not supported.
+		 * A failed malloc() results in exit() being called.
+		 */
+		RETURN(-1, OUT);
+	} else {
+		msg_queue_tail(&stack->downqueue, msg);
+		sem_post(&glob_mgr->new_msg);
+	}
   
 OUT:
 	misdn_send_unlock(bc);

Modified: team/group/issue8824/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/misdn/isdn_msg_parser.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/channels/misdn/isdn_msg_parser.c (original)
+++ team/group/issue8824/channels/misdn/isdn_msg_parser.c Thu Sep 18 11:21:37 2008
@@ -1010,12 +1010,12 @@
 
 static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) 
 {
-	int len,
-		HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN;
-	unsigned char *ie_fac,
-				  fac_tmp[256];
-	msg_t *msg =(msg_t*)create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY,  bc?bc->l3_id:-1, sizeof(FACILITY_t) ,nt);
-	FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); 
+	int len;
+	int HEADER_LEN;
+	unsigned char *ie_fac;
+	unsigned char fac_tmp[256];
+	msg_t *msg;
+	FACILITY_t *facility;
 	Q931_info_t *qi;
 
 #ifdef DEBUG 
@@ -1023,8 +1023,14 @@
 #endif
 	
 	len = encodeFac(fac_tmp, &(bc->fac_out));
-	if (len <= 0)
+	if (len <= 0) {
+		/* mISDN does not know how to build the requested facility structure */
 		return NULL;
+	}
+
+	msg = (msg_t *) create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, bc ? bc->l3_id : -1, sizeof(FACILITY_t), nt);
+	HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN;
+	facility = (FACILITY_t *) (msg->data + HEADER_LEN); 
 
 	ie_fac = msg_put(msg, len);
 	if (bc->nt) {

Modified: team/group/issue8824/funcs/func_connectedline.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/funcs/func_connectedline.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/funcs/func_connectedline.c (original)
+++ team/group/issue8824/funcs/func_connectedline.c Thu Sep 18 11:21:37 2008
@@ -69,7 +69,7 @@
 	} else if (!strncasecmp("pres", data, 4)) {
 		ast_copy_string(buf, ast_named_caller_presentation(chan->connected.id.number_presentation), len);
 	} else if (!strncasecmp("source", data, 6)) {
-		snprintf(buf, len, "%d", chan->connected.source);
+		ast_copy_string(buf, ast_connected_line_source_name(chan->connected.source), len);
 	} else {
 		ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
 	}
@@ -160,14 +160,22 @@
 			set_it(chan, &connected);
 		}
 	} else if (!strncasecmp("source", data, 6)) {
+		int source;
+
 		val = ast_strdupa(value);
 		ast_trim_blanks(val);
 
 		if (('0' <= val[0]) && (val[0] <= '9')) {
-			connected.source = atoi(val);
+			source = atoi(val);
+		} else {
+			source = ast_connected_line_source_parse(val);
+		}
+
+		if (source < 0) {
+			ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
+		} else {
+			connected.source = source;
 			set_it(chan, &connected);
-		} else {
-			ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
 		}
 	} else {
 		ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
@@ -186,7 +194,11 @@
 		"from sending out protocol messages because of the value\n"
 		"being set.\n"
 		"The allowable datatypes are:\n"
-		"\"all\", \"name\", \"num\", \"ton\", \"pres\", and \"source\"\n",
+		"\"all\", \"name\", \"num\", \"ton\", \"pres\", and \"source\"\n"
+		"The source datatype can be set to the following:\n"
+		"answer    - Normal Call Answering\n"
+		"diversion - Call Diversion\n"
+		"transfer  - Call Transfer\n",
 	.read = connectedline_read,
 	.write = connectedline_write,
 };

Modified: team/group/issue8824/funcs/func_redirecting.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/funcs/func_redirecting.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/funcs/func_redirecting.c (original)
+++ team/group/issue8824/funcs/func_redirecting.c Thu Sep 18 11:21:37 2008
@@ -153,7 +153,7 @@
 	} else if (!strncasecmp("pres", data, 4)) {
 		ast_copy_string(buf, ast_named_caller_presentation(chan->redirecting.from.number_presentation), len);
 	} else if (!strncasecmp("reason", data, 6)) {
-		snprintf(buf, len, "%d", chan->redirecting.reason);
+		ast_copy_string(buf, ast_redirecting_reason_name(chan->redirecting.reason), len);
 	} else if (!strncasecmp("count", data, 5)) {
 		snprintf(buf, len, "%d", chan->redirecting.count);
 	} else {
@@ -335,14 +335,22 @@
 			set_it(chan, &redirecting);
 		}
 	} else if (!strncasecmp("reason", data, 6)) {
+		int reason;
+
 		val = ast_strdupa(value);
 		ast_trim_blanks(val);
 
 		if (('0' <= val[0]) && (val[0] <= '9')) {
-			redirecting.reason = atoi(val);
+			reason = atoi(val);
+		} else {
+			reason = ast_redirecting_reason_parse(val);
+		}
+
+		if (reason < 0) {
+			ast_log(LOG_ERROR, "Unknown redirecting reason '%s', value unchanged\n", val);
+		} else {
+			redirecting.reason = reason;
 			set_it(chan, &redirecting);
-		} else {
-			ast_log(LOG_ERROR, "Unknown redirecting reason '%s', value unchanged\n", val);
 		}
 	} else if (!strncasecmp("count", data, 5)) {
 		val = ast_strdupa(value);
@@ -376,7 +384,15 @@
 		"The allowable datatypes are:\n"
 		"\"from-all\", \"from-name\", \"from-num\", \"from-ton\",\n"
 		"\"to-all\", \"to-name\", \"to-num\", \"to-ton\",\n"
-		"\"pres\", \"reason\", and \"count\"\n",
+		"\"pres\", \"reason\", and \"count\"\n"
+		"The reason datatype can be set to the following:\n"
+		"unknown      - Unknown\n"
+		"cfb          - Call Forwarding Busy\n"
+		"cfnr         - Call Forwarding No Reply\n"
+		"deflection   - Call Deflection\n"
+		"out_of_order - Called DTE Out-Of-Order\n"
+		"cf_dte       - Call Forwarding By The Called DTE\n"
+		"cfu          - Call Forwarding Unconditional\n",
 	.read = redirecting_read,
 	.write = redirecting_write,
 };

Modified: team/group/issue8824/include/asterisk/callerid.h
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/include/asterisk/callerid.h?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/include/asterisk/callerid.h (original)
+++ team/group/issue8824/include/asterisk/callerid.h Thu Sep 18 11:21:37 2008
@@ -66,9 +66,9 @@
 
 /* defines dealing with message waiting indication generation */
 /*! MWI SDMF format */
-#define CID_MWI_TYPE_SDMF		0x00 
+#define CID_MWI_TYPE_SDMF		0x00
 /*! MWI MDMF format -- generate only MWI field */
-#define CID_MWI_TYPE_MDMF		0x01 
+#define CID_MWI_TYPE_MDMF		0x01
 /*! MWI MDMF format -- generate name, callerid, date and MWI fields */
 #define CID_MWI_TYPE_MDMF_FULL	0x02
 
@@ -86,21 +86,24 @@
 void callerid_init(void);
 
 /*! \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 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 flags passed flags
  * \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_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, int codec);
 
 /*! \brief Create a callerID state machine
  * \param cid_signalling Type of signalling in use
  *
+ * \details
  * This function returns a malloc'd instance of the callerid_state data structure.
  * \return Returns a pointer to a malloc'd callerid_state structure, or NULL on error.
  */
@@ -112,9 +115,11 @@
  * \param samples number of samples contained within the buffer.
  * \param codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
  *
+ * \details
  * Send received audio to the Caller*ID demodulator.
- * \return Returns -1 on error, 0 for "needs more samples",
- * and 1 if the CallerID spill reception is complete.
+ * \retval -1 on error
+ * \retval 0 for "needs more samples"
+ * \retval 1 if the CallerID spill reception is complete.
  */
 int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, int codec);
 
@@ -124,9 +129,11 @@
  * \param samples number of samples contained within the buffer.
  * \param codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
  *
+ * \details
  * Send received audio to the Caller*ID demodulator (for japanese style lines).
- * \return Returns -1 on error, 0 for "needs more samples",
- * and 1 if the CallerID spill reception is complete.
+ * \retval -1 on error
+ * \retval 0 for "needs more samples"
+ * \retval 1 if the CallerID spill reception is complete.
  */
 int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, int codec);
 
@@ -136,6 +143,7 @@
  * \param name Pass the address of a pointer-to-char (will contain the name)
  * \param flags Pass the address of an int variable(will contain the various callerid flags)
  *
+ * \details
  * This function extracts a callerid string out of a callerid_state state machine.
  * If no number is found, *number will be set to NULL.  Likewise for the name.
  * Flags can contain any of the following:
@@ -144,18 +152,16 @@
  */
 void callerid_get(struct callerid_state *cid, char **number, char **name, int *flags);
 
-/*! Get and parse DTMF-based callerid  */
-/*!
+/*!
+ * \brief Get and parse DTMF-based callerid
  * \param cidstring The actual transmitted string.
  * \param number The cid number is returned here.
  * \param flags The cid flags are returned here.
- * This function parses DTMF callerid.
  */
 void callerid_get_dtmf(char *cidstring, char *number, int *flags);
 
-/*! \brief Free a callerID state
+/*! \brief This function frees callerid_state cid.
  * \param cid This is the callerid_state state machine to free
- * This function frees callerid_state cid.
  */
 void callerid_free(struct callerid_state *cid);
 
@@ -165,25 +171,27 @@
  * \param number Caller-ID Number
  * \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)
  *
+ * \details
  * Acts like callerid_generate except uses an asterisk format callerid string.
  */
 int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int codec);
 
-/*! \brief Generate message waiting indicator 
+/*! \brief Generate message waiting indicator
  * \param active The message indicator state
  *  -- either 0 no messages in mailbox or 1 messages in mailbox
  * \param type Format of message (any of CID_MWI_TYPE_*)
- * \see callerid_generate() for more info as it use the same encoding  
+ * \see callerid_generate() for more info as it uses the same encoding
 */
 int vmwi_generate(unsigned char *buf, int active, int type, int codec, const char *name,
 	const char *number, int flags);
 
 /*! \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
+ * \see ast_callerid_generate() for other details
  */
 int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, int codec);
 
 /*! \brief Destructively parse inbuf into name and location (or number)
+ * \details
  * Parses callerid stream from inbuf and changes into useable form, outputed in name and location.
  * \param instr buffer of callerid stream (in audio form) to be parsed. Warning, data in buffer is changed.
  * \param name address of a pointer-to-char for the name value of the stream.
@@ -192,8 +200,8 @@
  */
 int ast_callerid_parse(char *instr, char **name, char **location);
 
-/*! Generate a CAS (CPE Alert Signal) tone for 'n' samples */
-/*!
+/*!
+ * \brief Generate a CAS (CPE Alert Signal) tone for 'n' samples
  * \param outbuf Allocated buffer for data.  Must be at least 2400 bytes unless no SAS is desired
  * \param sas Non-zero if CAS should be preceeded by SAS
  * \param len How many samples to generate.
@@ -202,23 +210,26 @@
  */
 int ast_gen_cas(unsigned char *outbuf, int sas, int len, int codec);
 
-/*! \brief Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s... */
-/*!
+/*!
+ * \brief Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
  * \param n The number to be stripped/shrunk
  * \return Returns nothing important
  */
 void ast_shrink_phone_number(char *n);
 
-/*! \brief Check if a string consists only of digits and + \#
-    \param n number to be checked.
-    \return Returns 0 if n is a number, 1 if it's not.
+/*!
+ * \brief Check if a string consists only of digits and + \#
+ * \param n number to be checked.
+ * \return Returns 0 if n is a number, 1 if it's not.
  */
 int ast_isphonenumber(const char *n);
 
-/*! \brief Check if a string consists only of digits and and + \# ( ) - .
-	(meaning it can be cleaned with ast_shrink_phone_number)
-    \param exten The extension (or URI) to be checked.
-    \return Returns 0 if n is a number, 1 if it's not.
+/*!
+ * \brief Check if a string consists only of digits and and + \# ( ) - .
+ * (meaning it can be cleaned with ast_shrink_phone_number)
+ * \param exten The extension (or URI) to be checked.
+ * \retval 1 if string is valid AST shrinkable phone number
+ * \retval 0 if not
  */
 int ast_is_shrinkable_phonenumber(const char *exten);
 
@@ -288,71 +299,103 @@
 
 /* Various defines and bits for handling PRI- and SS7-type restriction */
 
-#define AST_PRES_NUMBER_TYPE				0x03
+#define AST_PRES_NUMBER_TYPE					0x03
 #define AST_PRES_USER_NUMBER_UNSCREENED			0x00
 #define AST_PRES_USER_NUMBER_PASSED_SCREEN		0x01
 #define AST_PRES_USER_NUMBER_FAILED_SCREEN		0x02
-#define AST_PRES_NETWORK_NUMBER				0x03
-
-#define AST_PRES_RESTRICTION				0x60
-#define AST_PRES_ALLOWED				0x00
-#define AST_PRES_RESTRICTED				0x20
-#define AST_PRES_UNAVAILABLE				0x40
-#define AST_PRES_RESERVED				0x60
+#define AST_PRES_NETWORK_NUMBER					0x03
+
+#define AST_PRES_RESTRICTION					0x60
+#define AST_PRES_ALLOWED						0x00
+#define AST_PRES_RESTRICTED						0x20
+#define AST_PRES_UNAVAILABLE					0x40
+#define AST_PRES_RESERVED						0x60
 
 #define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \
-	AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_ALLOWED
+	(AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED)
 
 #define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \
-	AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_ALLOWED
+	(AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
 
 #define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \
-	AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_ALLOWED
+	(AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
 
 #define AST_PRES_ALLOWED_NETWORK_NUMBER	\
-	AST_PRES_NETWORK_NUMBER + AST_PRES_ALLOWED
+	(AST_PRES_ALLOWED | AST_PRES_NETWORK_NUMBER)
 
 #define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED \
-	AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_RESTRICTED
+	(AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED)
 
 #define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \
-	AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_RESTRICTED
+	(AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
 
 #define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \
-	AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_RESTRICTED
+	(AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
 
 #define AST_PRES_PROHIB_NETWORK_NUMBER \
-	AST_PRES_NETWORK_NUMBER + AST_PRES_RESTRICTED
+	(AST_PRES_RESTRICTED | AST_PRES_NETWORK_NUMBER)
 
 #define AST_PRES_NUMBER_NOT_AVAILABLE \
-	AST_PRES_NETWORK_NUMBER + AST_PRES_UNAVAILABLE
+	(AST_PRES_UNAVAILABLE | AST_PRES_NETWORK_NUMBER)
 
 int ast_parse_caller_presentation(const char *data);
 const char *ast_describe_caller_presentation(int data);
 const char *ast_named_caller_presentation(int data);
 
-/*! \page Def_CallerPres Caller ID Presentation
-
-	Caller ID presentation values are used to set properties to a
-	caller ID in PSTN networks, and as RPID value in SIP transactions.
-
-	The following values are available to use:
-	\arg \b Defined value, text string in config file, explanation
-
-	\arg \b AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened", Presentation Allowed, Not Screened,
-	\arg \b AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen", Presentation Allowed, Passed Screen,
-	\arg \b AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen", Presentation Allowed, Failed Screen,
-	\arg \b AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed", Presentation Allowed, Network Number,
-	\arg \b AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, "prohib_not_screened", Presentation Prohibited, Not Screened,
-	\arg \b AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen", Presentation Prohibited, Passed Screen,
-	\arg \b AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen", Presentation Prohibited, Failed Screen,
-	\arg \b AST_PRES_PROHIB_NETWORK_NUMBER, "prohib", Presentation Prohibited, Network Number,
-
-	\par References
-	\arg \ref callerid.h Definitions
-	\arg \ref callerid.c Functions
-	\arg \ref CID Caller ID names and numbers
-*/
+/*!
+ * \page Def_CallerPres Caller ID Presentation
+ *
+ * Caller ID presentation values are used to set properties to a
+ * caller ID in PSTN networks, and as RPID value in SIP transactions.
+ *
+ * The following values are available to use:
+ * \arg \b Defined value, text string in config file, explanation
+ *
+ * \arg \b AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened", Presentation Allowed, Not Screened,
+ * \arg \b AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen", Presentation Allowed, Passed Screen,
+ * \arg \b AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen", Presentation Allowed, Failed Screen,
+ * \arg \b AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed", Presentation Allowed, Network Number,
+ * \arg \b AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, "prohib_not_screened", Presentation Prohibited, Not Screened,
+ * \arg \b AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen", Presentation Prohibited, Passed Screen,
+ * \arg \b AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen", Presentation Prohibited, Failed Screen,
+ * \arg \b AST_PRES_PROHIB_NETWORK_NUMBER, "prohib", Presentation Prohibited, Network Number,
+ *
+ * \par References
+ * \arg \ref callerid.h Definitions
+ * \arg \ref callerid.c Functions
+ * \arg \ref CID Caller ID names and numbers
+ */
+
+/*! 
+ * \brief Q.931 encoded redirecting reason
+ */
+enum Q931_REDIRECTING_REASON {
+	Q931_REDIRECTING_REASON_UNKNOWN = 0x0,
+	Q931_REDIRECTING_REASON_CALL_FWD_BUSY = 0x1,/* Call forwarding busy or called DTE busy */
+	Q931_REDIRECTING_REASON_NO_REPLY = 0x2,     /* Call forwarding no reply */
+	Q931_REDIRECTING_REASON_DEFLECTION = 0x4,   /* Call deflection */
+	Q931_REDIRECTING_REASON_OUT_OF_ORDER = 0x9, /* Called DTE out of order */
+	Q931_REDIRECTING_REASON_CALL_FWD_DTE = 0xA, /* Call forwarding by the called DTE */
+	Q931_REDIRECTING_REASON_CALL_FWD = 0xF      /* Call forwarding unconditional or systematic call redirection */
+};
+
+int ast_redirecting_reason_parse(const char *data);
+const char *ast_redirecting_reason_describe(int data);
+const char *ast_redirecting_reason_name(int data);
+
+/*! 
+ * \brief Connected line update source code
+ */
+enum AST_CONNECTED_LINE_UPDATE_SOURCE {
+	AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN,   /* Update for unknown reason (May be interpreted to mean from answer) */
+	AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER,    /* Update from normal call answering */
+	AST_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION, /* Update from call diversion */
+	AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER   /* Update from call transfer */
+};
+
+int ast_connected_line_source_parse(const char *data);
+const char *ast_connected_line_source_describe(int data);
+const char *ast_connected_line_source_name(int data);
 
 
 #endif /* _ASTERISK_CALLERID_H */

Modified: team/group/issue8824/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/include/asterisk/channel.h?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/include/asterisk/channel.h (original)
+++ team/group/issue8824/include/asterisk/channel.h Thu Sep 18 11:21:37 2008
@@ -306,8 +306,9 @@
 	 */
 	int ani2;
 
-	/*! \brief Information about the source (Q.SIG requirement).
-	 * enum values for Normal-Answer, Call-transfer, Call-diversion
+	/*! \brief Information about the source of an update (Q.SIG/ISDN requirement).
+	 * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
+	 * for Normal-Answer, Call-transfer, Call-diversion
 	 */
 	int source;
 };

Modified: team/group/issue8824/main/callerid.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/main/callerid.c?view=diff&rev=143470&r1=143469&r2=143470
==============================================================================
--- team/group/issue8824/main/callerid.c (original)
+++ team/group/issue8824/main/callerid.c Thu Sep 18 11:21:37 2008
@@ -922,8 +922,10 @@
 	return bytes;
 }
 
-/*! \brief Clean up phone string
- * remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets.
+/*!
+ * \brief Clean up phone string
+ * \details
+ * Remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets.
  * Basically, remove anything that could be invalid in a pattern.
  */
 void ast_shrink_phone_number(char *n)
@@ -958,11 +960,13 @@
 	n[y] = '\0';
 }
 
-/*! \brief Checks if phone number consists of valid characters 
-	\param exten	String that needs to be checked
-	\param valid	Valid characters in string
-	\return 1 if valid string, 0 if string contains invalid characters
-*/
+/*!
+ * \brief Checks if phone number consists of valid characters
+ * \param exten	String that needs to be checked
+ * \param valid	Valid characters in string
+ * \retval 1 if valid string
+ * \retval 0 if string contains invalid characters
+ */
 static int ast_is_valid_string(const char *exten, const char *valid)
 {
 	int x;
@@ -975,19 +979,22 @@
 	return 1;
 }
 
-/*! \brief checks if string consists only of digits and * \# and + 
-	\return 1 if string is valid AST phone number
-	\return 0 if not
+/*!
+ * \brief checks if string consists only of digits and * \# and +
+ * \retval 1 if string is valid AST phone number
+ * \retval 0 if not
 */
 int ast_isphonenumber(const char *n)
 {
 	return ast_is_valid_string(n, "0123456789*#+");
 }
 
-/*! \brief checks if string consists only of digits and ( ) - * \# and + 
-	Pre-qualifies the string for ast_shrink_phone_number()
-	\return 1 if string is valid AST shrinkable phone number
-	\return 0 if not
+/*!
+ * \brief checks if string consists only of digits and ( ) - * \# and +
+ * \details
+ * Pre-qualifies the string for ast_shrink_phone_number()
+ * \retval 1 if string is valid AST shrinkable phone number
+ * \retval 0 if not
 */
 int ast_is_shrinkable_phonenumber(const char *exten)
 {
@@ -1095,68 +1102,268 @@
 	return 0;
 }
 
-/*! \brief Translation table for Caller ID Presentation settings */
-static struct {
-	int val;
+struct ast_value_translation {
+	int value;
 	const char *name;
 	const char *description;
-} pres_types[] = {
-	{  AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened", "Presentation Allowed, Not Screened"},
-	{  AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen", "Presentation Allowed, Passed Screen"},
-	{  AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen", "Presentation Allowed, Failed Screen"},
-	{  AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed", "Presentation Allowed, Network Number"},
-	{  AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, "prohib_not_screened", "Presentation Prohibited, Not Screened"},
-	{  AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen", "Presentation Prohibited, Passed Screen"},
-	{  AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen", "Presentation Prohibited, Failed Screen"},
-	{  AST_PRES_PROHIB_NETWORK_NUMBER, "prohib", "Presentation Prohibited, Network Number"},
-	{  AST_PRES_NUMBER_NOT_AVAILABLE, "unavailable", "Number Unavailable"},
 };
 
-/*! \brief Convert caller ID text code to value 
-	used in config file parsing
-	\param data text string
-	\return value AST_PRES_ from callerid.h 
-*/
+/*! \brief Translation table for Caller ID Presentation settings */
+static struct ast_value_translation pres_types[] = {
+/* *INDENT-OFF* */
+	{ AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED,        "allowed_not_screened",  "Presentation Allowed, Not Screened" },
+	{ AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_PASSED_SCREEN,     "allowed_passed_screen", "Presentation Allowed, Passed Screen" },
+	{ AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_FAILED_SCREEN,     "allowed_failed_screen", "Presentation Allowed, Failed Screen" },
+	{ AST_PRES_ALLOWED | AST_PRES_NETWORK_NUMBER,                "allowed",               "Presentation Allowed, Network Number" },
+
+	{ AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED,     "prohib_not_screened",   "Presentation Prohibited, Not Screened" },
+	{ AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_PASSED_SCREEN,  "prohib_passed_screen",  "Presentation Prohibited, Passed Screen" },
+	{ AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_FAILED_SCREEN,  "prohib_failed_screen",  "Presentation Prohibited, Failed Screen" },
+	{ AST_PRES_RESTRICTED | AST_PRES_NETWORK_NUMBER,             "prohib",                "Presentation Prohibited, Network Number" },
+
+	{ AST_PRES_UNAVAILABLE | AST_PRES_NETWORK_NUMBER,            "unavailable",           "Number Unavailable" }, /* Default name to value conversion. */
+	{ AST_PRES_UNAVAILABLE | AST_PRES_USER_NUMBER_UNSCREENED,    "unavailable",           "Number Unavailable" },
+	{ AST_PRES_UNAVAILABLE | AST_PRES_USER_NUMBER_FAILED_SCREEN, "unavailable",           "Number Unavailable" },
+	{ AST_PRES_UNAVAILABLE | AST_PRES_USER_NUMBER_PASSED_SCREEN, "unavailable",           "Number Unavailable" },
+/* *INDENT-ON* */
+};
+
+/*!
+ * \brief Convert caller ID text code to value (used in config file parsing)
+ * \param data text string from config file
+ * \retval value AST_PRES_ from callerid.h
+ * \retval -1 if not in table
+ */
 int ast_parse_caller_presentation(const char *data)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_LEN(pres_types); i++) {
-		if (!strcasecmp(pres_types[i].name, data))
-			return pres_types[i].val;
-	}
+	int index;
+
+	for (index = 0; index < ARRAY_LEN(pres_types); ++index) {
+		if (!strcasecmp(pres_types[index].name, data)) {
+			return pres_types[index].value;
+		}
+	}	/* end for */
 
 	return -1;
-}
-
-/*! \brief Convert caller ID pres value to explanatory string 
-	\param data value (see callerid.h AST_PRES_ ) 
-	\return string for human presentation
-*/
+}	/* end ast_parse_caller_presentation() */
+
+/*!
+ * \brief Convert caller ID pres value to explanatory string
+ * \param data AST_PRES_ value from callerid.h
+ * \return string for human presentation
+ */
 const char *ast_describe_caller_presentation(int data)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_LEN(pres_types); i++) {
-		if (pres_types[i].val == data)
-			return pres_types[i].description;
-	}
+	int index;
+
+	for (index = 0; index < ARRAY_LEN(pres_types); ++index) {
+		if (pres_types[index].value == data) {
+			return pres_types[index].description;
+		}
+	}	/* end for */
 
 	return "unknown";
-}
-
-/*! \brief Convert caller ID pres value to text code
-	\param data text string
-	\return string for config file
-*/
+}	/* end ast_describe_caller_presentation() */
+
+/*!
+ * \brief Convert caller ID pres value to text code
+ * \param data AST_PRES_ value from callerid.h
+ * \return string for config file
+ */
 const char *ast_named_caller_presentation(int data)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_LEN(pres_types); i++) {
-		if (pres_types[i].val == data)
-			return pres_types[i].name;
-	}
+	int index;
+
+	for (index = 0; index < ARRAY_LEN(pres_types); ++index) {
+		if (pres_types[index].value == data) {
+			return pres_types[index].name;
+		}
+	}	/* end for */
 
 	return "unknown";
-}
+}	/* end ast_named_caller_presentation() */
+
+
+
+
+/* ******************************************************************* */
+
+
+
+
+/*! \brief Translation table for redirecting reason settings */
+static struct ast_value_translation redirecting_reason_types[] = {
+/* *INDENT-OFF* */
+	{ Q931_REDIRECTING_REASON_UNKNOWN,       "unknown",      "Unknown" },
+	{ Q931_REDIRECTING_REASON_CALL_FWD_BUSY, "cfb",          "Call Forwarding Busy" },
+	{ Q931_REDIRECTING_REASON_NO_REPLY,      "cfnr",         "Call Forwarding No Reply" },
+	{ Q931_REDIRECTING_REASON_DEFLECTION,    "deflection",   "Call Deflection" },
+	{ Q931_REDIRECTING_REASON_OUT_OF_ORDER,  "out_of_order", "Called DTE Out-Of-Order" },

[... 219 lines stripped ...]



More information about the asterisk-commits mailing list