[asterisk-commits] russell: branch group/sip-object-matching r178066 - /team/group/sip-object-ma...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 23 12:39:20 CST 2009


Author: russell
Date: Mon Feb 23 12:39:20 2009
New Revision: 178066

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=178066
Log:
Update name matching to be able to only match type=peer, as well.

Also, fix register_verify() to only match type=peer instead of all objects.

Modified:
    team/group/sip-object-matching/channels/chan_sip.c

Modified: team/group/sip-object-matching/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/sip-object-matching/channels/chan_sip.c?view=diff&rev=178066&r1=178065&r2=178066
==============================================================================
--- team/group/sip-object-matching/channels/chan_sip.c (original)
+++ team/group/sip-object-matching/channels/chan_sip.c Mon Feb 23 12:39:20 2009
@@ -487,8 +487,9 @@
 #endif
 
 /* Arguments for find_peer */
-#define	FINDALLDEVICES	FALSE
-#define FINDONLYUSERS	TRUE
+#define FINDUSERS (1 << 0)
+#define FINDPEERS (1 << 1)
+#define FINDALLDEVICES (FINDUSERS | FINDPEERS)
 
 #define	SIPBUFSIZE		512		/*!< Buffer size for many operations */
 
@@ -4511,7 +4512,7 @@
 static int find_by_name(void *obj, void *arg, void *data, int flags)
 {
 	struct sip_peer *search = obj, *match = arg;
-	int *forcenamematch = data;
+	int *which_objects = data;
 
 	/* Usernames in SIP uri's are case sensitive. Domains are not */
 	if (strcmp(search->name, match->name)) {
@@ -4520,7 +4521,7 @@
 
 	/* If we're only looking for name matches, we should avoid type=peer devices,
 	   since these should not match on any name-based search */
-	if (*forcenamematch && search->onlymatchonip) {
+	if (!(*which_objects & FINDUSERS) && search->onlymatchonip) {
 		return 0;
 	}
 
@@ -4535,14 +4536,14 @@
 	since it might cause a database lookup.
 
 */
-static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime, int forcenamematch, int devstate_only)
+static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime, int which_objects, int devstate_only)
 {
 	struct sip_peer *p = NULL;
 	struct sip_peer tmp_peer;
 
 	if (peer) {
 		ast_copy_string(tmp_peer.name, peer, sizeof(tmp_peer.name));
-		p = ao2_t_callback_data(peers, OBJ_POINTER, find_by_name, &tmp_peer, &forcenamematch, "ao2_find in peers table");
+		p = ao2_t_callback_data(peers, OBJ_POINTER, find_by_name, &tmp_peer, &which_objects, "ao2_find in peers table");
 	} else if (sin) { /* search by addr? */
 		tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr;
 		tmp_peer.addr.sin_port = sin->sin_port;
@@ -11970,7 +11971,7 @@
 
 	ast_string_field_set(p, exten, name);
 	build_contact(p);
-	peer = find_peer(name, NULL, TRUE, FINDALLDEVICES, FALSE);
+	peer = find_peer(name, NULL, TRUE, FINDPEERS, FALSE);
 	if (!(peer && ast_apply_ha(peer->ha, sin))) {
 		/* Peer fails ACL check */
 		if (peer) {
@@ -12882,7 +12883,7 @@
 		peer = find_peer(of, NULL, TRUE, FINDALLDEVICES, FALSE);
 	} else {
 		/* First find devices based on username (avoid all type=peer's) */
-		peer = find_peer(of, NULL, TRUE, FINDONLYUSERS, FALSE);
+		peer = find_peer(of, NULL, TRUE, FINDUSERS, FALSE);
 
 		/* Then find devices based on IP */
 		if (!peer) {




More information about the asterisk-commits mailing list