[asterisk-commits] mmichelson: branch group/issue8824 r143564 - in /team/group/issue8824: channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 18 19:13:12 CDT 2008


Author: mmichelson
Date: Thu Sep 18 19:13:11 2008
New Revision: 143564

URL: http://svn.digium.com/view/asterisk?view=rev&rev=143564
Log:
Change the redirecting reasons defined in callerid.h

They were defined as Q.931 redirecting reason codes, but
since other channel drivers are able to redirect for many
more specific reasons, I have changed the core to use a larger
list of redirecting reasons. chan_misdn has been updated
to translate to/from these core reasons, and appropriate
strings have been added to callerid.c for these reasons.

My next step will be to add reason parsing for Diversion
headers in chan_sip.c


Modified:
    team/group/issue8824/channels/chan_misdn.c
    team/group/issue8824/channels/chan_sip.c
    team/group/issue8824/include/asterisk/callerid.h
    team/group/issue8824/main/callerid.c

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=143564&r1=143563&r2=143564
==============================================================================
--- team/group/issue8824/channels/chan_misdn.c (original)
+++ team/group/issue8824/channels/chan_misdn.c Thu Sep 18 19:13:11 2008
@@ -108,6 +108,9 @@
 static char *complete_ch(struct ast_cli_args *a);
 static char *complete_debug_port(struct ast_cli_args *a);
 static char *complete_show_config(struct ast_cli_args *a);
+
+static enum Q931_REDIRECTING_REASON ast_to_q931_reason(const enum AST_REDIRECTING_REASON ast);
+static enum AST_REDIRECTING_REASON q931_to_ast_reason(const enum Q931_REDIRECTING_REASON q931);
 
 /* BEGIN: chan_misdn.h */
 
@@ -137,6 +140,37 @@
 	MISDN_HOLD_DISCONNECT, /*!< if this chan is holded */
 };
 
+/*! 
+ * \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 */
+};
+
+static struct misdn_reasons {
+	enum AST_REDIRECTING_REASON ast;
+	enum Q931_REDIRECTING_REASON q931;
+} misdn_reason_table[] = {
+	{ AST_REDIRECTING_REASON_UNKNOWN, Q931_REDIRECTING_REASON_UNKNOWN },
+	{ AST_REDIRECTING_REASON_USER_BUSY, Q931_REDIRECTING_REASON_CALL_FWD_BUSY },
+	{ AST_REDIRECTING_REASON_NO_ANSWER, Q931_REDIRECTING_REASON_NO_REPLY },
+	{ AST_REDIRECTING_REASON_UNAVAILABLE, Q931_REDIRECTING_REASON_NO_REPLY },
+	{ AST_REDIRECTING_REASON_UNCONDITIONAL, Q931_REDIRECTING_REASON_CALL_FWD },
+	{ AST_REDIRECTING_REASON_TIME_OF_DAY, Q931_REDIRECTING_REASON_UNKNOWN },
+	{ AST_REDIRECTING_REASON_DO_NOT_DISTURB, Q931_REDIRECTING_REASON_UNKNOWN },
+	{ AST_REDIRECTING_REASON_DEFLECTION, Q931_REDIRECTING_REASON_DEFLECTION },
+	{ AST_REDIRECTING_REASON_FOLLOW_ME, Q931_REDIRECTING_REASON_UNKNOWN },
+	{ AST_REDIRECTING_REASON_OUT_OF_ORDER, Q931_REDIRECTING_REASON_OUT_OF_ORDER },
+	{ AST_REDIRECTING_REASON_AWAY, Q931_REDIRECTING_REASON_UNKNOWN },
+	{ AST_REDIRECTING_REASON_CALL_FWD_DTE, Q931_REDIRECTING_REASON_CALL_FWD_DTE }
+};
+
 #define ORG_AST 1
 #define ORG_MISDN 2
 
@@ -421,7 +455,6 @@
 static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame *frame);
 
 
-
 static inline void free_robin_list_r (struct robin_list *r)
 {
 	if (r) {
@@ -1060,6 +1093,53 @@
 	return screening;
 }	/* end ast_screen_to_misdn_screen() */
 
+/*! \brief convert core redirecting reason to a Q.931 redirecting reason code
+ */
+static enum Q931_REDIRECTING_REASON ast_to_q931_reason(const enum AST_REDIRECTING_REASON ast)
+{
+	enum Q931_REDIRECTING_REASON q931;
+
+	if (ast >= 0 && ast < ARRAY_LEN(misdn_reason_table))
+		return misdn_reason_table[ast].q931;
+
+	return Q931_REDIRECTING_REASON_UNKOWN;
+}
+
+/*! \brief convert a Q.931 redirecting reason code into a core redirecting reason
+ */
+static enum AST_REDIRECTING_REASON q931_to_ast_reason(const enum Q931_REDIRECTING_REASON q931)
+{
+	enum AST_REDIRECTING_REASON ast;
+
+	switch (q931) {
+		case Q931_REDIRECTING_REASON_UNKNOWN:
+			ast = AST_REDIRECTING_REASON_UNKNOWN;
+			break;
+		case Q931_REDIRECTING_REASON_CALL_FWD_BUSY:
+			ast = AST_REDIRECTING_REASON_USER_BUSY;
+			break;
+		case Q931_REDIRECTING_REASON_NO_REPLY:
+			ast = AST_REDIRECTING_REASON_NO_ANSWER;
+			break;
+		case Q931_REDIRECTING_REASON_DEFLECTION:
+			ast = AST_REDIRECTING_REASON_DEFLECTION;
+			break;
+		case Q931_REDIRECTING_REASON_OUT_OF_ORDER:
+			ast = AST_REDIRECTING_REASON_OUT_OF_ORDER;
+			break;
+		case Q931_REDIRECTING_REASON_CALL_FWD_DTE:
+			ast = AST_REDIRECTING_REASON_CALL_FWD_DTE;
+			break;
+		case Q931_REDIRECTING_REASON_CALL_FWD:
+			ast = AST_REDIRECTING_REASON_UNCONDITIONAL;
+			break;
+		default:
+			ast = AST_REDIRECTING_REASON_UNKNOWN;
+			break;
+	}
+
+	return ast;
+}
 
 
 
@@ -2779,7 +2859,7 @@
 			ast->redirecting.from.number_presentation =
 				misdn_pres_to_ast_pres(bc->redirecting.from.presentation)
 				| misdn_screen_to_ast_screen(bc->redirecting.from.screening);
-			ast->redirecting.reason = bc->redirecting.reason;
+			ast->redirecting.reason = q931_to_ast_reason(bc->redirecting.reason);
 		}
 	
 		misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial));
@@ -2850,7 +2930,7 @@
 	bc->redirecting.from.screening = ast_screen_to_misdn_screen(ast->redirecting.from.number_presentation);
 	bc->redirecting.from.number_type = ast_ton_to_misdn_ton(ast->redirecting.from.number_type);
 	bc->redirecting.from.number_plan = ast_plan_to_misdn_plan(ast->redirecting.from.number_type);
-	bc->redirecting.reason = ast->redirecting.reason;
+	bc->redirecting.reason = ast_to_q931_reason(ast->redirecting.reason);
 }	/* end misdn_copy_redirecting_from_ast() */
 
 

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=143564&r1=143563&r2=143564
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Thu Sep 18 19:13:11 2008
@@ -15304,21 +15304,21 @@
 		if (p->owner->redirecting.from.name) {
 			ast_free(p->owner->redirecting.from.name);
 		}
-		ast_debug(3, LOG_NOTICE, "Got redirecting from name %s\n", redirecting_from_name);
+		ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
 		p->owner->redirecting.from.name = redirecting_from_name;
 	}
 	if (!ast_strlen_zero(redirecting_to_number)) {
 		if (p->owner->redirecting.to.number) {
 			ast_free(p->owner->redirecting.to.number);
 		}
-		ast_debug(3, LOG_NOTICE, "Got redirecting to number %s\n", redirecting_to_number);
+		ast_debug(3, "Got redirecting to number %s\n", redirecting_to_number);
 		p->owner->redirecting.to.number = redirecting_to_number;
 	}
 	if (!ast_strlen_zero(redirecting_to_name)) {
 		if (p->owner->redirecting.to.name) {
 			ast_free(p->owner->redirecting.to.name);
 		}
-		ast_debug(3, LOG_NOTICE, "Got redirecting to name %s\n", redirecting_from_number);
+		ast_debug(3, "Got redirecting to name %s\n", redirecting_from_number);
 		p->owner->redirecting.to.name = redirecting_to_name;
 	}
 }

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=143564&r1=143563&r2=143564
==============================================================================
--- team/group/issue8824/include/asterisk/callerid.h (original)
+++ team/group/issue8824/include/asterisk/callerid.h Thu Sep 18 19:13:11 2008
@@ -366,17 +366,24 @@
  * \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 */
+/*! \brief redirecting reason codes.
+ *
+ * This list attempts to encompass redirecting reasons
+ * as defined by several channel technologies.
+ */
+enum AST_REDIRECTING_REASON {
+	AST_REDIRECTING_REASON_UNKNOWN,
+	AST_REDIRECTING_REASON_USER_BUSY,
+	AST_REDIRECTING_REASON_NO_ANSWER,
+	AST_REDIRECTING_REASON_UNAVAILABLE,
+	AST_REDIRECTING_REASON_UNCONDITIONAL,
+	AST_REDIRECTING_REASON_TIME_OF_DAY,
+	AST_REDIRECTING_REASON_DO_NOT_DISTURB,
+	AST_REDIRECTING_REASON_DEFLECTION,
+	AST_REDIRECTING_REASON_FOLLOW_ME,
+	AST_REDIRECTING_REASON_OUT_OF_ORDER,
+	AST_REDIRECTING_REASON_AWAY,
+	AST_REDIRECTING_REASON_CALL_FWD_DTE,           /* This is something defined in Q.931, and no I don't know what it means */
 };
 
 int ast_redirecting_reason_parse(const char *data);

Modified: team/group/issue8824/main/callerid.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/main/callerid.c?view=diff&rev=143564&r1=143563&r2=143564
==============================================================================
--- team/group/issue8824/main/callerid.c (original)
+++ team/group/issue8824/main/callerid.c Thu Sep 18 19:13:11 2008
@@ -1194,13 +1194,18 @@
 /*! \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" },
-	{ Q931_REDIRECTING_REASON_CALL_FWD_DTE,  "cf_dte",       "Call Forwarding By The Called DTE" },
-	{ Q931_REDIRECTING_REASON_CALL_FWD,      "cfu",          "Call Forwarding Unconditional" }
+	{ AST_REDIRECTING_REASON_UNKNOWN,        "unknown",      "Unknown" },
+	{ AST_REDIRECTING_REASON_USER_BUSY,      "cfb",          "Call Forwarding Busy" },
+	{ AST_REDIRECTING_REASON_NO_ANSWER,      "cfnr",         "Call Forwarding No Reply" },
+	{ AST_REDIRECTING_REASON_UNAVAILABLE,    "unavailable",  "Callee is Unavailable" },
+	{ AST_REDIRECTING_REASON_UNCONDITIONAL,  "cfu",          "Call Forwarding Unconditional" },
+	{ AST_REDIRECTING_REASON_TIME_OF_DAY,    "time_of_day",  "Time of Day" },
+	{ AST_REDIRECTING_REASON_DO_NOT_DISTURB, "dnd",          "Do Not Disturb" },
+	{ AST_REDIRECTING_REASON_DEFLECTION,     "deflection",   "Call Deflection" },
+	{ AST_REDIRECTING_REASON_FOLLOW_ME,      "follow_me",    "Follow Me" },
+	{ AST_REDIRECTING_REASON_OUT_OF_ORDER,   "out_of_order", "Called DTE Out-Of-Order" },
+	{ AST_REDIRECTING_REASON_AWAY,           "away",         "Callee is Away" },
+	{ AST_REDIRECTING_REASON_CALL_FWD_DTE,   "cf_dte",       "Call Forwarding By The Called DTE" },
 /* *INDENT-ON* */
 };
 




More information about the asterisk-commits mailing list