[asterisk-commits] lmadsen: trunk r313528 - in /trunk: ./ channels/ channels/sip/include/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 13 10:49:40 CDT 2011


Author: lmadsen
Date: Wed Apr 13 10:49:33 2011
New Revision: 313528

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=313528
Log:
Add 'description' field for CLI and Manager output

(closes issue #19076)
Reported by: lmadsen
Patches: 
      __20110408-channel-description.txt uploaded by lmadsen (license 10)
Tested by: lmadsen

Review: https://reviewboard.asterisk.org/r/1163/

Modified:
    trunk/CHANGES
    trunk/channels/chan_dahdi.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/channels/sip/include/sip.h
    trunk/configs/chan_dahdi.conf.sample
    trunk/configs/iax.conf.sample
    trunk/configs/sip.conf.sample
    trunk/configs/users.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Apr 13 10:49:33 2011
@@ -23,6 +23,9 @@
    for chan_dahdi ISDN channels.
  * Added new action MeetmeListRooms to list active conferences (shows same
    data as "meetme list" at the CLI).
+ * DAHDIShowChannels, SIPshowpeer, SIPpeers, and IAXpeers now contains a
+   Description field that is set by 'description' in the channel configuration
+   file.
 
 Asterisk HTTP Server
 --------------------------
@@ -41,6 +44,9 @@
    alternate configuration file to use.
  * 'dialplan add extension' command will now automatically create a context if
    the specified context does not exist with a message indicated it did so.
+ * 'sip show peers', 'iax show peers', and 'dahdi show peers' now contains a
+   Description field which can be populated with 'description' in the channel
+   configuration files (sip.conf, iax2.conf, and chan_dahdi.conf).
 
 CDR
 --------------------------

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Wed Apr 13 10:49:33 2011
@@ -979,6 +979,11 @@
 	 * \note The "context" string read in from chan_dahdi.conf
 	 */
 	char context[AST_MAX_CONTEXT];
+	/*! 
+	 * \brief A description for the channel configuration
+	 * \note The "description" string read in from chan_dahdi.conf
+	 */
+	char description[32];
 	/*!
 	 * \brief Saved context string.
 	 */
@@ -1276,6 +1281,7 @@
 	MEMBER(dahdi_pvt, use_smdi, AST_DATA_BOOLEAN)				\
 	MEMBER(dahdi_pvt, context, AST_DATA_STRING)				\
 	MEMBER(dahdi_pvt, defcontext, AST_DATA_STRING)				\
+	MEMBER(dahdi_pvt, description, AST_DATA_STRING)				\
 	MEMBER(dahdi_pvt, exten, AST_DATA_STRING)				\
 	MEMBER(dahdi_pvt, language, AST_DATA_STRING)				\
 	MEMBER(dahdi_pvt, mohinterpret, AST_DATA_STRING)			\
@@ -12682,6 +12688,7 @@
 		ast_copy_string(tmp->mohinterpret, conf->chan.mohinterpret, sizeof(tmp->mohinterpret));
 		ast_copy_string(tmp->mohsuggest, conf->chan.mohsuggest, sizeof(tmp->mohsuggest));
 		ast_copy_string(tmp->context, conf->chan.context, sizeof(tmp->context));
+		ast_copy_string(tmp->description, conf->chan.description, sizeof(tmp->description));
 		ast_copy_string(tmp->parkinglot, conf->chan.parkinglot, sizeof(tmp->parkinglot));
 		tmp->cid_ton = 0;
 		if (analog_lib_handles(tmp->sig, tmp->radio, tmp->oprmode)) {
@@ -14995,8 +15002,8 @@
 
 static char *dahdi_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-#define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s\n"
-#define FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s\n"
+#define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
+#define FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
 	unsigned int targetnum = 0;
 	int filtertype = 0;
 	struct dahdi_pvt *tmp = NULL;
@@ -15033,7 +15040,7 @@
 		}
 	}
 
-	ast_cli(a->fd, FORMAT2, "Chan", "Extension", "Context", "Language", "MOH Interpret", "Blocked", "State");
+	ast_cli(a->fd, FORMAT2, "Chan", "Extension", "Context", "Language", "MOH Interpret", "Blocked", "State", "Description");
 	ast_mutex_lock(&iflock);
 	for (tmp = iflist; tmp; tmp = tmp->next) {
 		if (filtertype) {
@@ -15071,7 +15078,7 @@
 
 		snprintf(statestr, sizeof(statestr), "%s", "In Service");
 
-		ast_cli(a->fd, FORMAT, tmps, tmp->exten, tmp->context, tmp->language, tmp->mohinterpret, blockstr, statestr);
+		ast_cli(a->fd, FORMAT, tmps, tmp->exten, tmp->context, tmp->language, tmp->mohinterpret, blockstr, statestr, tmp->description);
 	}
 	ast_mutex_unlock(&iflock);
 	return CLI_SUCCESS;
@@ -15107,6 +15114,7 @@
 	for (tmp = iflist; tmp; tmp = tmp->next) {
 		if (tmp->channel == channel) {
 			ast_cli(a->fd, "Channel: %d\n", tmp->channel);
+			ast_cli(a->fd, "Description: %s\n", tmp->description);
 			ast_cli(a->fd, "File Descriptor: %d\n", tmp->subs[SUB_REAL].dfd);
 			ast_cli(a->fd, "Span: %d\n", tmp->span);
 			ast_cli(a->fd, "Extension: %s\n", tmp->exten);
@@ -15812,6 +15820,7 @@
 					"Context: %s\r\n"
 					"DND: %s\r\n"
 					"Alarm: %s\r\n"
+					"Description: %s\r\n"
 					"%s"
 					"\r\n",
 					tmp->channel,
@@ -15822,7 +15831,8 @@
 					tmp->sig,
 					tmp->context,
 					dahdi_dnd(tmp, -1) ? "Enabled" : "Disabled",
-					alarm2str(alm), idText);
+					alarm2str(alm),
+					tmp->description, idText);
 			} else {
 				astman_append(s,
 					"Event: DAHDIShowChannels\r\n"
@@ -15832,12 +15842,14 @@
 					"Context: %s\r\n"
 					"DND: %s\r\n"
 					"Alarm: %s\r\n"
+					"Description: %s\r\n"
 					"%s"
 					"\r\n",
 					tmp->channel, sig2str(tmp->sig), tmp->sig,
 					tmp->context,
 					dahdi_dnd(tmp, -1) ? "Enabled" : "Disabled",
-					alarm2str(alm), idText);
+					alarm2str(alm),
+					tmp->description, idText);
 			}
 		}
 	}
@@ -16836,6 +16848,8 @@
 				confp->chan.dtmfrelax = 0;
 		} else if (!strcasecmp(v->name, "mailbox")) {
 			ast_copy_string(confp->chan.mailbox, v->value, sizeof(confp->chan.mailbox));
+		} else if (!strcasecmp(v->name, "description")) {
+			ast_copy_string(confp->chan.description, v->value, sizeof(confp->chan.description));
 		} else if (!strcasecmp(v->name, "hasvoicemail")) {
 			if (ast_true(v->value) && ast_strlen_zero(confp->chan.mailbox)) {
 				ast_copy_string(confp->chan.mailbox, cat, sizeof(confp->chan.mailbox));

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Wed Apr 13 10:49:33 2011
@@ -484,6 +484,7 @@
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(name);
 		AST_STRING_FIELD(username);
+		AST_STRING_FIELD(description);		/*!< Description of the peer */
 		AST_STRING_FIELD(secret);
 		AST_STRING_FIELD(dbsecret);
 		AST_STRING_FIELD(outkey);	    /*!< What key we use to talk to this peer */
@@ -3837,6 +3838,7 @@
 		encmethods_to_str(peer->encmethods, encmethods);
 		ast_cli(a->fd, "\n\n");
 		ast_cli(a->fd, "  * Name       : %s\n", peer->name);
+		ast_cli(a->fd, "  Description  : %s\n", peer->description);
 		ast_cli(a->fd, "  Secret       : %s\n", ast_strlen_zero(peer->secret) ? "<Not set>" : "<Set>");
 		ast_cli(a->fd, "  Context      : %s\n", peer->context);
  		ast_cli(a->fd, "  Parking lot  : %s\n", peer->parkinglot);
@@ -6712,8 +6714,8 @@
 	int unmonitored_peers = 0;
 	struct ao2_iterator i;
 
-#define FORMAT2 "%-15.15s  %-15.15s %s  %-15.15s  %-8s  %s %-10s\n"
-#define FORMAT "%-15.15s  %-15.15s %s  %-15.15s  %-5d%s  %s %-10s\n"
+#define FORMAT2 "%-15.15s  %-15.15s %s  %-15.15s  %-8s  %s %-11s %-32.32s\n"
+#define FORMAT "%-15.15s  %-15.15s %s  %-15.15s  %-5d%s  %s %-11s %-32.32s\n"
 
 	struct iax2_peer *peer = NULL;
 	char name[256];
@@ -6755,7 +6757,7 @@
 
 
 	if (!s)
-		ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "   ", "Status");
+		ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "   ", "Status", "Description");
 
 	i = ao2_iterator_init(peers, 0);
 	for (peer = ao2_iterator_next(&i); peer;
@@ -6801,7 +6803,8 @@
 				"Dynamic: %s\r\n"
 				"Trunk: %s\r\n"
 				"Encryption: %s\r\n"
-				"Status: %s\r\n\r\n",
+				"Status: %s\r\n"
+				"Description: %s\r\n\r\n",
 				idtext,
 				name,
 				ast_sockaddr_stringify_addr(&peer->addr),
@@ -6809,7 +6812,8 @@
 				ast_test_flag64(peer, IAX_DYNAMIC) ? "yes" : "no",
 				ast_test_flag64(peer, IAX_TRUNK) ? "yes" : "no",
 				peer->encmethods ? ast_str_buffer(encmethods) : "no",
-				status);
+				status,
+				peer->description);
 		} else {
 			ast_cli(fd, FORMAT, name,
 				ast_sockaddr_stringify_addr(&peer->addr),
@@ -6818,7 +6822,8 @@
 				ast_sockaddr_port(&peer->addr),
 				ast_test_flag64(peer, IAX_TRUNK) ? "(T)" : "   ",
 				peer->encmethods ? "(E)" : "   ",
-				status);
+				status,
+				peer->description);
 		}
 		total_peers++;
 	}
@@ -12459,6 +12464,8 @@
 				ast_string_field_set(peer, mohsuggest, v->value);
 			} else if (!strcasecmp(v->name, "dbsecret")) {
 				ast_string_field_set(peer, dbsecret, v->value);
+			} else if (!strcasecmp(v->name, "description")) {
+				ast_string_field_set(peer, description, v->value);
 			} else if (!strcasecmp(v->name, "trunk")) {
 				ast_set2_flag64(peer, ast_true(v->value), IAX_TRUNK);	
 				if (ast_test_flag64(peer, IAX_TRUNK) && !timer) {

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Apr 13 10:49:33 2011
@@ -15997,8 +15997,8 @@
 	struct ao2_iterator i;
 	
 /* the last argument is left-aligned, so we don't need a size anyways */
-#define FORMAT2 "%-25.25s  %-39.39s %-3.3s %-10.10s %-3.3s %-8s %-10s %s\n"
-#define FORMAT  "%-25.25s  %-39.39s %-3.3s %-3.3s %-3.3s %-8d %-10s %s\n"
+#define FORMAT2 "%-25.25s %-39.39s %-3.3s %-10.10s %-3.3s %-8s %-11s %-32.32s %s\n"
+#define FORMAT  "%-25.25s %-39.39s %-3.3s %-10.10s %-3.3s %-8d %-11s %-32.32s %s\n"
 
 	char name[256];
 	int total_peers = 0;
@@ -16038,7 +16038,7 @@
 	}
 
 	if (!s) /* Normal list */
-		ast_cli(fd, FORMAT2, "Name/username", "Host", "Dyn", "Forcerport", "ACL", "Port", "Status", (realtimepeers ? "Realtime" : ""));
+		ast_cli(fd, FORMAT2, "Name/username", "Host", "Dyn", "Forcerport", "ACL", "Port", "Status", "Description", (realtimepeers ? "Realtime" : ""));
 	
 
 	i = ao2_iterator_init(peers, 0);
@@ -16103,6 +16103,7 @@
 			ast_test_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT) ? " N " : "   ",	/* NAT=yes? */
 			peer->ha ? " A " : "   ", 	/* permit/deny */
 			ast_sockaddr_isnull(&peer->addr) ? 0 : ast_sockaddr_port(&peer->addr), status,
+			peer->description ? peer->description : "",
 			realtimepeers ? (peer->is_realtime ? "Cached RT":"") : "");
 
 		if (!s)  {/* Normal CLI list */
@@ -16112,6 +16113,7 @@
 			ast_test_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT) ? " N " : "   ",	/* NAT=yes? */
 			peer->ha ? " A " : "   ",       /* permit/deny */
 			ast_sockaddr_isnull(&peer->addr) ? 0 : ast_sockaddr_port(&peer->addr), status,
+			peer->description ? peer->description : "",
 			realtimepeers ? (peer->is_realtime ? "Cached RT":"") : "");
 		} else {	/* Manager format */
 			/* The names here need to be the same as other channels */
@@ -16128,7 +16130,8 @@
 			"TextSupport: %s\r\n"
 			"ACL: %s\r\n"
 			"Status: %s\r\n"
-			"RealtimeDevice: %s\r\n\r\n",
+			"RealtimeDevice: %s\r\n"
+			"Description: %s\r\n\r\n",
 			idtext,
 			peer->name,
 			ast_sockaddr_isnull(&peer->addr) ? "-none-" : ast_sockaddr_stringify_fmt(&peer->addr, AST_SOCKADDR_STR_HOST),
@@ -16139,7 +16142,8 @@
 			ast_test_flag(&peer->flags[1], SIP_PAGE2_TEXTSUPPORT) ? "yes" : "no",	/* TEXTSUPPORT=yes? */
 			peer->ha ? "yes" : "no",       /* permit/deny */
 			status,
-			realtimepeers ? (peer->is_realtime ? "yes":"no") : "no");
+			realtimepeers ? (peer->is_realtime ? "yes":"no") : "no",
+			peer->description);
 		}
 		ao2_unlock(peer);
 		unref_peer(peer, "toss iterator peer ptr");
@@ -16717,6 +16721,7 @@
 		struct ast_str *mailbox_str = ast_str_alloca(512);
 		ast_cli(fd, "\n\n");
 		ast_cli(fd, "  * Name       : %s\n", peer->name);
+		ast_cli(fd, "  Description  : %s\n", peer->description);
 		if (realtimepeers) {	/* Realtime is enabled */
 			ast_cli(fd, "  Realtime peer: %s\n", peer->is_realtime ? "Yes, cached" : "No");
 		}
@@ -16924,7 +16929,8 @@
  				astman_append(s, "ChanVariable: %s=%s\r\n", v->name, v->value);
 			}
 		}
-		astman_append(s, "SIP-Use-Reason-Header : %s\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_Q850_REASON)) ? "Y" : "N");
+		astman_append(s, "SIP-Use-Reason-Header : %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_Q850_REASON)) ? "Y" : "N");
+		astman_append(s, "Description : %s\r\n", peer->description);
 
 		peer = unref_peer(peer, "sip_show_peer: unref_peer: done with peer");
 
@@ -26105,6 +26111,7 @@
 		peer->call_limit=INT_MAX;
 	ast_string_field_set(peer, vmexten, default_vmexten);
 	ast_string_field_set(peer, secret, "");
+	ast_string_field_set(peer, description, "");
 	ast_string_field_set(peer, remotesecret, "");
 	ast_string_field_set(peer, md5secret, "");
 	ast_string_field_set(peer, cid_num, "");
@@ -26347,6 +26354,8 @@
 				ast_string_field_set(peer, remotesecret, v->value);
 			} else if (!strcasecmp(v->name, "secret")) {
 				ast_string_field_set(peer, secret, v->value);
+			} else if (!strcasecmp(v->name, "description")) {
+				ast_string_field_set(peer, description, v->value);
 			} else if (!strcasecmp(v->name, "md5secret")) {
 				ast_string_field_set(peer, md5secret, v->value);
 			} else if (!strcasecmp(v->name, "auth")) {
@@ -29090,7 +29099,8 @@
 	MEMBER(sip_peer, maxms, AST_DATA_MILLISECONDS)		\
 	MEMBER(sip_peer, qualifyfreq, AST_DATA_MILLISECONDS)	\
 	MEMBER(sip_peer, timer_t1, AST_DATA_MILLISECONDS)	\
-	MEMBER(sip_peer, timer_b, AST_DATA_MILLISECONDS)
+	MEMBER(sip_peer, timer_b, AST_DATA_MILLISECONDS)	\
+	MEMBER(sip_peer, description, AST_DATA_STRING)
 
 AST_DATA_STRUCTURE(sip_peer, DATA_EXPORT_SIP_PEER);
 

Modified: trunk/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/sip.h?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/channels/sip/include/sip.h (original)
+++ trunk/channels/sip/include/sip.h Wed Apr 13 10:49:33 2011
@@ -1157,6 +1157,7 @@
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(secret);       /*!< Password for inbound auth */
 		AST_STRING_FIELD(md5secret);    /*!< Password in MD5 */
+		AST_STRING_FIELD(description);	/*!< Description of this peer */
 		AST_STRING_FIELD(remotesecret); /*!< Remote secret (trunks, remote devices) */
 		AST_STRING_FIELD(context);      /*!< Default context for incoming calls */
 		AST_STRING_FIELD(subscribecontext); /*!< Default context for subscriptions */

Modified: trunk/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/chan_dahdi.conf.sample?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/configs/chan_dahdi.conf.sample (original)
+++ trunk/configs/chan_dahdi.conf.sample Wed Apr 13 10:49:33 2011
@@ -820,6 +820,11 @@
 ;
 ;useincomingcalleridondahditransfer = yes
 ;
+; Add a description for the channel which can be shown through the Asterisk
+; console  when executing the 'dahdi show channels' command is run.
+;
+;description=Phone located in lobby
+;
 ; AMA flags affects the recording of Call Detail Records.  If specified
 ; it may be 'default', 'omit', 'billing', or 'documentation'.
 ;
@@ -1068,10 +1073,13 @@
 ;
 ;
 ;callerid="Green Phone"<(256) 428-6121>
+;description=Reception Phone			; add a description for 'dahdi show channels'
 ;channel => 1
 ;callerid="Black Phone"<(256) 428-6122>
+;description=Courtesy Phone
 ;channel => 2
 ;callerid="CallerID Phone" <(630) 372-1564>
+;description=					; reset the description for following channels
 ;channel => 3
 ;callerid="Pac Tel Phone" <(256) 428-6124>
 ;channel => 4

Modified: trunk/configs/iax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/iax.conf.sample?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/configs/iax.conf.sample (original)
+++ trunk/configs/iax.conf.sample Wed Apr 13 10:49:33 2011
@@ -504,6 +504,7 @@
 username=asterisk
 secret=supersecret
 host=216.207.245.47
+description=Demo System At Digium	; Description of this peer, as listed by 'iax2 show peers'
 ;sendani=no
 ;host=asterisk.linux-support.net
 ;port=5036
@@ -544,6 +545,7 @@
 ;[biggateway]
 ;type=peer
 ;host=192.168.0.1
+;description=Gateway to PSTN
 ;context=*
 ;secret=myscret
 ;trunk=yes			; Use IAX2 trunking with this host

Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Wed Apr 13 10:49:33 2011
@@ -1100,6 +1100,7 @@
 ; use_q850_reason
 ; maxforwards
 ; encryption
+; description		; Used to provide a description of the peer in console output
 
 ;[sip_proxy]
 ; For incoming calls only. Example: FWD (Free World Dialup)
@@ -1195,6 +1196,7 @@
 ;context=from-sip                ; Where to start in the dialplan when this phone calls
 ;callerid=John Doe <1234>        ; Full caller ID, to override the phones config
                                  ; on incoming calls to Asterisk
+;description=Courtesy Phone      ; Description of the peer. Shown when doing 'sip show peers'.
 ;host=192.168.0.23               ; we have a static but private IP address
                                  ; No registration allowed
 ;nat=no                          ; there is not NAT between phone and Asterisk

Modified: trunk/configs/users.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/users.conf.sample?view=diff&rev=313528&r1=313527&r2=313528
==============================================================================
--- trunk/configs/users.conf.sample (original)
+++ trunk/configs/users.conf.sample Wed Apr 13 10:49:33 2011
@@ -87,6 +87,8 @@
 
 ;[6000]
 ;fullname = Joe User
+;description = Courtesy Phone In Lobby    ; Used to provide a description of the
+                                          ; peer in console output
 ;email = joe at foo.bar
 ;secret = 1234
 ;dahdichan = 1




More information about the asterisk-commits mailing list