[asterisk-commits] mmichelson: branch 1.6.1 r169792 - in /branches/1.6.1: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 21 15:57:33 CST 2009


Author: mmichelson
Date: Wed Jan 21 15:57:33 2009
New Revision: 169792

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=169792
Log:
Merged revisions 169791 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r169791 | mmichelson | 2009-01-21 15:53:55 -0600 (Wed, 21 Jan 2009) | 18 lines

Further fix some oddities in sip show users and sip show peers logic

ccesario on IRC pointed out that his sip peers were not displayed
properly when he would issue the command "sip show peers." The problem
was that the onlymatchonip field was used to determine if the endpoint
was a "peer" or "user." The tricky part is that a "friend" is supposed
to be treated as both a "user" and a "peer" but the logic would not allow
"friends" to show up as "peers" since onlymatchonip was set to FALSE
for friends.

I have modified the sip_peer structure to more explicitly keep track of
what type endpoint it is so that the various manager and CLI commands
will display the expected information

Reported by ccesario via IRC
Tested by ccesario


........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/channels/chan_sip.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.1/channels/chan_sip.c?view=diff&rev=169792&r1=169791&r2=169792
==============================================================================
--- branches/1.6.1/channels/chan_sip.c (original)
+++ branches/1.6.1/channels/chan_sip.c Wed Jan 21 15:57:33 2009
@@ -1495,8 +1495,14 @@
 	AST_LIST_ENTRY(sip_mailbox) entry;
 };
 
-/*! \brief Structure for SIP peer data, we place calls to peers if registered  or fixed IP address (host) */
-/* XXX field 'name' must be first otherwise sip_addrcmp() will fail */
+enum sip_peer_type {
+	SIP_TYPE_PEER = (1 << 0),
+	SIP_TYPE_USER = (1 << 1),
+};
+
+/*! \brief Structure for SIP peer data, we place calls to peers if registered  or fixed IP address (host) 
+*/
+/* XXX field 'name' must be first otherwise sip_addrcmp() will fail, as will astobj2 hashing of the structure */
 struct sip_peer {
 	char name[80];			/*!< peer->name is the unique name of this object */
 	struct sip_socket socket;	/*!< Socket used for this peer */
@@ -1574,6 +1580,7 @@
 	int timer_t1;			/*!<  The maximum T1 value for the peer */
 	int timer_b;			/*!<  The maximum timer B (transaction timeouts) */
 	int deprecated_username; /*!< If it's a realtime peer, are they using the deprecated "username" instead of "defaultuser" */
+	enum sip_peer_type type; /*!< Distinguish between "user" and "peer" types. This is used solely for CLI and manager commands */
 };
 
 
@@ -12590,7 +12597,7 @@
 	user_iter = ao2_iterator_init(peers, 0);
 	while ((user = ao2_iterator_next(&user_iter))) {
 		ao2_lock(user);
-		if (user->onlymatchonip == TRUE) {
+		if (!(user->type & SIP_TYPE_USER)) {
 			ao2_unlock(user);
 			unref_peer(user, "sip show users");
 			continue;
@@ -12782,7 +12789,7 @@
 	while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {	
 		ao2_lock(peer);
 
-		if (peer->onlymatchonip == FALSE) {
+		if (!(peer->type & SIP_TYPE_PEER)) {
 			ao2_unlock(peer);
 			unref_peer(peer, "unref peer because it's actually a user");
 			continue;
@@ -13651,7 +13658,7 @@
 	user_iter = ao2_iterator_init(peers, 0);
 	while ((user = ao2_iterator_next(&user_iter))) {
 		ao2_lock(user);
-		if (user->onlymatchonip == TRUE) {
+		if (!(user->type & SIP_TYPE_USER)) {
 			ao2_unlock(user);
 			unref_peer(user, "complete sip user");
 			continue;
@@ -21492,8 +21499,16 @@
 				ast_str_set(&fullcontact, 0, "%s", v->value);
 			}
 		} else if (!strcasecmp(v->name, "type")) {
-			if (!strcasecmp(v->value, "peer")) 
+			if (!strcasecmp(v->value, "peer")) {
 				peer->onlymatchonip = TRUE;		/* For realtime support, add type=peer in the table */
+				peer->type = SIP_TYPE_PEER;
+			} else if (!strcasecmp(v->value, "user")) {
+				peer->onlymatchonip = FALSE;
+				peer->type = SIP_TYPE_USER;
+			} else if (!strcasecmp(v->value, "friend")) {
+				peer->onlymatchonip = FALSE;
+				peer->type = SIP_TYPE_USER | SIP_TYPE_PEER;
+			}
 		} else if (!strcasecmp(v->name, "secret")) 
 			ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
 		else if (!strcasecmp(v->name, "md5secret")) 




More information about the asterisk-commits mailing list