[asterisk-commits] dvossel: trunk r178300 - in /trunk: ./ channels/ doc/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 24 11:42:37 CST 2009


Author: dvossel
Date: Tue Feb 24 11:42:37 2009
New Revision: 178300

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=178300
Log:
Allows manager command to see if IAX link is trunked and encrypted. Displays what kind of encryption is enabled as well. 

Manager command "iaxpeers" now shows if a link is trunked and encrypted.  Instead of encryption saying simply "yes" or "no", it now displays what type of encryption is enabled and if keyrotation is on or not.  

(closes issue #14427)
Reported by: snuffy
Patches:
	iax_show_trunks.diff uploaded by snuffy (license 35)
	2009022200_iax2_show_trunkencryption.diff.txt uploaded by mvanbaak (license 7)
Tested by: mvanbaak, dvossel, snuffy




Modified:
    trunk/CHANGES
    trunk/channels/chan_iax2.c
    trunk/doc/manager_1_1.txt

Modified: trunk/CHANGES
URL: http://svn.digium.com/svn-view/asterisk/trunk/CHANGES?view=diff&rev=178300&r1=178299&r2=178300
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Feb 24 11:42:37 2009
@@ -51,6 +51,12 @@
  * Channel variables set with setvar= in a device configuration is now 
    set both for inbound and outbound calls.
  * Added support for ITU G.722.1 and G.722.1C (Siren7 and Siren14) media streams.
+
+IAX2 changes
+------------
+  * Added immediate option to iax.conf
+  * Added forceencryption option to iax.conf
+  * Added Encryption and Trunk status to manager command "iaxpeers"
 
 Skinny Changes
 --------------
@@ -566,8 +572,6 @@
   * Added the srvlookup option to iax.conf
   * Added support for OSP.  The token is set and retrieved through the CHANNEL()
      dialplan function.
-  * Added immediate option to iax.conf
-  * Added forceencryption option to iax.conf
 
 XMPP Google Talk/Jingle changes
 -------------------------------

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=178300&r1=178299&r2=178300
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Feb 24 11:42:37 2009
@@ -1306,6 +1306,22 @@
 	return 0;
 }
 
+static void encmethods_to_str(int e, struct ast_str *buf)
+{
+	ast_str_set(&buf, 0, "(");
+	if (e & IAX_ENCRYPT_AES128) {
+		ast_str_append(&buf, 0, "aes128");
+	}
+	if (e & IAX_ENCRYPT_KEYROTATE) {
+		ast_str_append(&buf, 0, ",keyrotate");
+	}
+	if (ast_str_strlen(buf) > 1) {
+		ast_str_append(&buf, 0, ")");
+	} else {
+		ast_str_set(&buf, 0, "No");
+	}
+}
+
 static int get_encrypt_methods(const char *s)
 {
 	int e;
@@ -2762,6 +2778,7 @@
 	char cbuf[256];
 	struct iax2_peer *peer;
 	char codec_buf[512];
+	struct ast_str *encmethods = ast_str_alloca(256);
 	int x = 0, codec = 0, load_realtime = 0;
 
 	switch (cmd) {
@@ -2784,6 +2801,7 @@
 
 	peer = find_peer(a->argv[3], load_realtime);
 	if (peer) {
+		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, "  Secret       : %s\n", ast_strlen_zero(peer->secret) ? "<Not set>" : "<Set>");
@@ -2791,6 +2809,8 @@
  		ast_cli(a->fd, "  Parking lot  : %s\n", peer->parkinglot);
 		ast_cli(a->fd, "  Mailbox      : %s\n", peer->mailbox);
 		ast_cli(a->fd, "  Dynamic      : %s\n", ast_test_flag(peer, IAX_DYNAMIC) ? "Yes" : "No");
+		ast_cli(a->fd, "  Trunk        : %s\n", ast_test_flag(peer, IAX_TRUNK) ? "Yes" : "No");
+		ast_cli(a->fd, "  Encryption   : %s\n", peer->encmethods ? ast_str_buffer(encmethods) : "No");
 		ast_cli(a->fd, "  Callerid     : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
 		ast_cli(a->fd, "  Expire       : %d\n", peer->expire);
 		ast_cli(a->fd, "  ACL          : %s\n", (peer->ha ? "Yes" : "No"));
@@ -5243,6 +5263,7 @@
 
 	struct iax2_peer *peer = NULL;
 	char name[256];
+	struct ast_str *encmethods = ast_str_alloca(256);
 	int registeredonly=0;
 	char *term = manager ? "\r\n" : "\n";
 	char idtext[256] = "";
@@ -5288,7 +5309,6 @@
 		peer_unref(peer), peer = ao2_iterator_next(&i)) {
 		char nm[20];
 		char status[20];
-		char srch[2000];
 		int retstatus;
 
 		if (registeredonly && !peer->addr.sin_addr.s_addr)
@@ -5300,7 +5320,8 @@
 			snprintf(name, sizeof(name), "%s/%s", peer->name, peer->username);
 		else
 			ast_copy_string(name, peer->name, sizeof(name));
-		
+
+		encmethods_to_str(peer->encmethods, encmethods);
 		retstatus = peer_status(peer, status, sizeof(status));
 		if (retstatus > 0)
 			online_peers++;
@@ -5308,18 +5329,11 @@
 			offline_peers++;
 		else
 			unmonitored_peers++;
-		
+
 		ast_copy_string(nm, ast_inet_ntoa(peer->mask), sizeof(nm));
 
-		snprintf(srch, sizeof(srch), FORMAT, name, 
-			 peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
-			 ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
-			 nm,
-			 ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : "   ",
-			 peer->encmethods ? "(E)" : "   ", status, term);
-		
-		if (s)
-			astman_append(s, 
+		if (s) {
+			astman_append(s,
 				"Event: PeerEntry\r\n%s"
 				"Channeltype: IAX2\r\n"
 				"ChanObjectType: peer\r\n"
@@ -5327,21 +5341,28 @@
 				"IPaddress: %s\r\n"
 				"IPport: %d\r\n"
 				"Dynamic: %s\r\n"
+				"Trunk: %s\r\n"
+				"Encryption: %s\r\n"
 				"Status: %s\r\n\r\n",
 				idtext,
 				name,
 				peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "-none-",
 				ntohs(peer->addr.sin_port),
 				ast_test_flag(peer, IAX_DYNAMIC) ? "yes" : "no",
+				ast_test_flag(peer, IAX_TRUNK) ? "yes" : "no",
+				peer->encmethods ? ast_str_buffer(encmethods) : "no",
 				status);
-		
-		else
-			ast_cli(fd, FORMAT, name, 
+		} else {
+			ast_cli(fd, FORMAT, name,
 				peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
 				ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
 				nm,
-				ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : "   ",
-				peer->encmethods ? "(E)" : "   ", status, term);
+				ntohs(peer->addr.sin_port),
+				ast_test_flag(peer, IAX_TRUNK) ? "(T)" : "   ",
+				peer->encmethods ? "(E)" : "   ",
+				status,
+				term);
+		}
 		total_peers++;
 	}
 
@@ -5577,6 +5598,7 @@
 	char status[20];
 	const char *id = astman_get_header(m,"ActionID");
 	char idtext[256] = "";
+	struct ast_str *encmethods = ast_str_alloca(256);
 	struct ao2_iterator i;
 
 	if (!ast_strlen_zero(id))
@@ -5587,7 +5609,7 @@
 
 	i = ao2_iterator_init(peers, 0);
 	for (peer = ao2_iterator_next(&i); peer; peer_unref(peer), peer = ao2_iterator_next(&i)) {
-
+		encmethods_to_str(peer->encmethods, encmethods);
 		astman_append(s, "Event: PeerEntry\r\n%sChanneltype: IAX\r\n", idtext);
 		if (!ast_strlen_zero(peer->username)) {
 			astman_append(s, "ObjectName: %s\r\nObjectUsername: %s\r\n", peer->name, peer->username);
@@ -5600,6 +5622,8 @@
 		astman_append(s, "Mask: %s\r\n", nm);
 		astman_append(s, "Port: %d\r\n", ntohs(peer->addr.sin_port));
 		astman_append(s, "Dynamic: %s\r\n", ast_test_flag(peer, IAX_DYNAMIC) ? "Yes" : "No");
+		astman_append(s, "Trunk: %s\r\n", ast_test_flag(peer, IAX_TRUNK) ? "Yes" : "No");
+		astman_append(s, "Encryption: %s\r\n", peer->encmethods ? ast_str_buffer(encmethods) : "No");
 		peer_status(peer, status, sizeof(status));
 		astman_append(s, "Status: %s\r\n\r\n", status);
 		peer_count++;

Modified: trunk/doc/manager_1_1.txt
URL: http://svn.digium.com/svn-view/asterisk/trunk/doc/manager_1_1.txt?view=diff&rev=178300&r1=178299&r2=178300
==============================================================================
--- trunk/doc/manager_1_1.txt (original)
+++ trunk/doc/manager_1_1.txt Tue Feb 24 11:42:37 2009
@@ -127,6 +127,12 @@
 
 - Event QueueEntry now also returns the Uniqueid field like other events from app_queue.
 
+- Action IAXpeerlist
+	Now includes if the IAX link is a trunk or not
+
+- Action IAXpeers
+	Now includes if the IAX link is a trunk or not
+
 * NEW ACTIONS
 -------------
 - Action: ModuleLoad




More information about the asterisk-commits mailing list