[svn-commits] russell: branch russell/events r121443 - in /team/russell/events: ./ configs/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 10 07:52:52 CDT 2008


Author: russell
Date: Tue Jun 10 07:52:52 2008
New Revision: 121443

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121443
Log:
sync with trunk

Modified:
    team/russell/events/   (props changed)
    team/russell/events/configs/dundi.conf.sample
    team/russell/events/doc/tex/asterisk-conf.tex
    team/russell/events/doc/tex/channelvariables.tex
    team/russell/events/include/asterisk/utils.h
    team/russell/events/main/asterisk.c
    team/russell/events/main/netsock.c
    team/russell/events/main/pbx.c
    team/russell/events/pbx/dundi-parser.c
    team/russell/events/pbx/dundi-parser.h
    team/russell/events/pbx/pbx_dundi.c

Propchange: team/russell/events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun 10 07:52:52 2008
@@ -1,1 +1,1 @@
-/trunk:1-121429
+/trunk:1-121441

Modified: team/russell/events/configs/dundi.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/events/configs/dundi.conf.sample?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/configs/dundi.conf.sample (original)
+++ team/russell/events/configs/dundi.conf.sample Tue Jun 10 07:52:52 2008
@@ -33,7 +33,8 @@
 ; Our entity identifier (Should generally be the MAC address of the
 ; machine it's running on.  Defaults to the first eth address, but you
 ; can override it here, as long as you set it to the MAC of *something*
-; you own!)
+; you own!)  The EID can be overridden by a setting in asterisk.conf,
+; or by setting this option.
 ;
 ;entityid=00:07:E9:3B:76:60
 ;

Modified: team/russell/events/doc/tex/asterisk-conf.tex
URL: http://svn.digium.com/view/asterisk/team/russell/events/doc/tex/asterisk-conf.tex?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/doc/tex/asterisk-conf.tex (original)
+++ team/russell/events/doc/tex/asterisk-conf.tex Tue Jun 10 07:52:52 2008
@@ -124,6 +124,11 @@
 ;           eh. on SMB/CIFS mounts
 lockmode = lockfile | flock
   
+; Entity ID.  This is in the form of a MAC address.  It should be universally
+; unique.  It must be unique between servers communicating with a protocol
+; that uses this value.  The only thing that uses this currently is DUNDi,
+; but other things will use it in the future.
+; entityid=00:11:22:33:44:55
 
 [files]
 ; Changing the following lines may compromise your security

Modified: team/russell/events/doc/tex/channelvariables.tex
URL: http://svn.digium.com/view/asterisk/team/russell/events/doc/tex/channelvariables.tex?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/doc/tex/channelvariables.tex (original)
+++ team/russell/events/doc/tex/channelvariables.tex Tue Jun 10 07:52:52 2008
@@ -795,6 +795,7 @@
 ${FORWARD_CONTEXT}       Context for forwarded calls
 ${UNIQUEID}            * Current call unique identifier
 ${SYSTEMNAME}          * value of the systemname option of asterisk.conf
+${ENTITYID}            * Global Entity ID set automatically, or from asterisk.conf
 \end{verbatim}
 
 \subsection{Application return values}

Modified: team/russell/events/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/utils.h?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/include/asterisk/utils.h (original)
+++ team/russell/events/include/asterisk/utils.h Tue Jun 10 07:52:52 2008
@@ -678,17 +678,39 @@
 	unsigned char eid[6];
 } __attribute__ ((__packed__));
 
+/*!
+ * \brief Global EID
+ *
+ * This is set in asterisk.conf, or determined automatically by taking the mac
+ * address of an Ethernet interface on the system.
+ */
 extern struct ast_eid g_eid;
 
 /*!
  * \brief Fill in an ast_eid with the default eid of this machine
  */
-void ast_set_eid(struct ast_eid *eid);
-
+void ast_set_default_eid(struct ast_eid *eid);
+
+/*!
+ * /brief Convert an EID to a string
+ */
 char *ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid);
 
+/*!
+ * \brief Convert a string into an EID
+ *
+ * This function expects an EID in the format:
+ *    00:11:22:33:44:55
+ *
+ * \return 0 success, non-zero failure
+ */
 int ast_str_to_eid(struct ast_eid *eid, const char *s);
 
+/*!
+ * \brief Compare two EIDs
+ *
+ * \return 0 if the two are the same, non-zero otherwise
+ */
 int ast_eid_cmp(const struct ast_eid *eid1, const struct ast_eid *eid2);
 
 #endif /* _ASTERISK_UTILS_H */

Modified: team/russell/events/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/asterisk.c?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/main/asterisk.c (original)
+++ team/russell/events/main/asterisk.c Tue Jun 10 07:52:52 2008
@@ -2616,7 +2616,7 @@
 	ast_copy_string(cfg_paths.socket_path, DEFAULT_SOCKET, sizeof(cfg_paths.socket_path));
 	ast_copy_string(cfg_paths.run_dir, DEFAULT_RUN_DIR, sizeof(cfg_paths.run_dir));
 
-	ast_set_eid(&g_eid);
+	ast_set_default_eid(&g_eid);
 
 	/* no asterisk.conf? no problem, use buildtime config! */
 	if (!cfg) {

Modified: team/russell/events/main/netsock.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/netsock.c?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/main/netsock.c (original)
+++ team/russell/events/main/netsock.c Tue Jun 10 07:52:52 2008
@@ -225,9 +225,8 @@
 	return os;
 }
 
-void ast_set_eid(struct ast_eid *eid)
-{
-	int success = 0;
+void ast_set_default_eid(struct ast_eid *eid)
+{
 #if defined(SIOCGIFHWADDR)
 	int s, x = 0;
 	char eid_str[20];
@@ -243,8 +242,8 @@
 			continue;
 		memcpy(eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(*eid));
 		ast_debug(1, "Seeding global EID '%s' from '%s' using 'siocgifhwaddr'\n", ast_eid_to_str(eid_str, sizeof(eid_str), eid), ifr.ifr_name);
-		success = 1;
-		break;
+		close(s);
+		return;
 	}
 	close(s);
 #else
@@ -257,19 +256,17 @@
 		for (p = ifap; p; p = p->ifa_next) {
 			if ((p->ifa_addr->sa_family == AF_LINK) && !(p->ifa_flags & IFF_LOOPBACK) && (p->ifa_flags & IFF_RUNNING)) {
 				struct sockaddr_dl* sdp = (struct sockaddr_dl*) p->ifa_addr;
-				memcpy(&eid->eid), sdp->sdl_data + sdp->sdl_nlen, 6);
+				memcpy(&(eid->eid), sdp->sdl_data + sdp->sdl_nlen, 6);
 				ast_debug(1, "Seeding global EID '%s' from '%s' using 'getifaddrs'\n", ast_eid_to_str(eid_str, sizeof(eid_str), eid), p->ifa_name);
-				success = 1;
-				break;
+				freeifaddrs(ifap);
+				return;
 			}
 		}
 		freeifaddrs(ifap);
 	}
 #endif
 #endif
-
-	if (!success)
-		ast_log(LOG_ERROR, "No ethernet interface found for seeding default EID.  You will have to set it manually.\n");
+	ast_log(LOG_NOTICE, "No ethernet interface found for seeding global EID. You will have to set it manually.\n");
 }
 
 int ast_str_to_eid(struct ast_eid *eid, const char *s)

Modified: team/russell/events/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/pbx.c?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/main/pbx.c (original)
+++ team/russell/events/main/pbx.c Tue Jun 10 07:52:52 2008
@@ -2314,6 +2314,9 @@
 			s = workspace;
 		} else if (!strcmp(var, "SYSTEMNAME")) {
 			s = ast_config_AST_SYSTEM_NAME;
+		} else if (!strcmp(var, "ENTITYID")) {
+			ast_eid_to_str(workspace, workspacelen, &g_eid);
+			s = workspace;
 		}
 	}
 	/* if not found, look into chanvars or global vars */

Modified: team/russell/events/pbx/dundi-parser.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/pbx/dundi-parser.c?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/pbx/dundi-parser.c (original)
+++ team/russell/events/pbx/dundi-parser.c Tue Jun 10 07:52:52 2008
@@ -48,8 +48,21 @@
 static void (*outputf)(const char *str) = internaloutput;
 static void (*errorf)(const char *str) = internalerror;
 
-#define dundi_eid_to_str(a,b,c) ast_eid_to_str(a,b,c)
-#define dundi_str_to_eid(a,b) ast_str_to_eid(a,b)
+char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid)
+{
+	int x;
+	char *os = s;
+	if (maxlen < 13) {
+		if (s && (maxlen > 0))
+			*s = '\0';
+	} else {
+		for (x=0;x<6;x++) {
+			sprintf(s, "%02X", eid->eid[x]);
+			s += 2;
+		}
+	}
+	return os;
+}
 
 int dundi_str_short_to_eid(dundi_eid *eid, const char *s)
 {
@@ -87,7 +100,7 @@
 static void dump_eid(char *output, int maxlen, void *value, int len)
 {
 	if (len == 6)
-		dundi_eid_to_str(output, maxlen, (dundi_eid *)value);
+		ast_eid_to_str(output, maxlen, (dundi_eid *)value);
 	else
 		snprintf(output, maxlen, "Invalid EID len %d", len);
 }
@@ -288,7 +301,7 @@
 	memcpy(tmp, answer->data, datalen);
 	tmp[datalen] = '\0';
 
-	dundi_eid_to_str(eid_str, sizeof(eid_str), &answer->eid);
+	ast_eid_to_str(eid_str, sizeof(eid_str), &answer->eid);
 	snprintf(output, maxlen, "[%s] %d <%s/%s> from [%s]", 
 		dundi_flags2str(flags, sizeof(flags), ntohs(answer->flags)), 
 		ntohs(answer->weight),

Modified: team/russell/events/pbx/dundi-parser.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/pbx/dundi-parser.h?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/pbx/dundi-parser.h (original)
+++ team/russell/events/pbx/dundi-parser.h Tue Jun 10 07:52:52 2008
@@ -77,12 +77,9 @@
 extern int dundi_ie_append_byte(struct dundi_ie_data *ied, unsigned char ie, unsigned char dat);
 extern int dundi_ie_append(struct dundi_ie_data *ied, unsigned char ie);
 extern int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen);
-extern char *dundi_eid_to_str(char *s, int maxlen, dundi_eid *eid);
 extern char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid);
-extern int dundi_str_to_eid(dundi_eid *eid, const char *s);
 extern int dundi_str_short_to_eid(dundi_eid *eid, const char *s);
 extern int dundi_eid_zero(dundi_eid *eid);
-extern int dundi_eid_cmp(dundi_eid *eid1, dundi_eid *eid2);
 extern char *dundi_flags2str(char *s, int maxlen, int flags);
 extern char *dundi_hint2str(char *s, int maxlen, int flags);
 #endif

Modified: team/russell/events/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/pbx/pbx_dundi.c?view=diff&rev=121443&r1=121442&r2=121443
==============================================================================
--- team/russell/events/pbx/pbx_dundi.c (original)
+++ team/russell/events/pbx/pbx_dundi.c Tue Jun 10 07:52:52 2008
@@ -460,11 +460,6 @@
 	dundi_xmit(&tmp.pack);
 }
 
-static void reset_global_eid(void)
-{
-	ast_set_eid(&global_eid);
-}
-
 static int get_trans_id(void)
 {
 	struct dundi_transaction *t;
@@ -509,7 +504,7 @@
 
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, cur, list) {
-		if (!dundi_eid_cmp(&cur->eid,eid))
+		if (!ast_eid_cmp(&cur->eid,eid))
 			break;
 	}
 	AST_LIST_UNLOCK(&peers);
@@ -591,7 +586,7 @@
 			dr[anscnt].expiration = dundi_cache_time;
 			ast_copy_string(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech));
 			dr[anscnt].eid = *us_eid;
-			dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
+			ast_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
 			if (ast_test_flag(&flags, DUNDI_FLAG_EXISTS)) {
 				AST_LIST_HEAD_INIT_NOLOCK(&headp);
 				newvariable = ast_var_assign("NUMBER", called_number);
@@ -645,7 +640,7 @@
 	int expiration = dundi_cache_time;
 
 	ast_debug(1, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context, 
-			st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) :  "ourselves");
+			st->eids[0] ? ast_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) :  "ourselves");
 	memset(&ied, 0, sizeof(ied));
 	memset(&dr, 0, sizeof(dr));
 	memset(&hmd, 0, sizeof(hmd));
@@ -704,7 +699,7 @@
 	char eid_str[20];
 
 	ast_debug(1, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context, 
-		st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) :  "ourselves");
+		st->eids[0] ? ast_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) :  "ourselves");
 	memset(&ied, 0, sizeof(ied));
 
 	/* Now produce precache */
@@ -739,11 +734,11 @@
 	int res;
 
 	ast_debug(1, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context, 
-		st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) :  "ourselves");
+		st->eids[0] ? ast_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) :  "ourselves");
 	memset(&ied, 0, sizeof(ied));
 	memset(&dei, 0, sizeof(dei));
 	memset(&hmd, 0, sizeof(hmd));
-	if (!dundi_eid_cmp(&st->trans->us_eid, &st->reqeid)) {
+	if (!ast_eid_cmp(&st->trans->us_eid, &st->reqeid)) {
 		/* Ooh, it's us! */
 		ast_debug(1, "Neat, someone look for us!\n");
 		ast_copy_string(dei.orgunit, dept, sizeof(dei.orgunit));
@@ -799,7 +794,7 @@
 		   and the last EID is the root, it is permissible that the first and last EID
 		   could be the same.  In that case, we should go ahead copy only the "root" section
 		   since we will not need it for authentication. */
-		if (!dundi_eid_cmp(ies->eids[0], ies->eids[ies->eidcount - 1]))
+		if (!ast_eid_cmp(ies->eids[0], ies->eids[ies->eidcount - 1]))
 			skipfirst = 1;
 	}
 	totallen = sizeof(struct dundi_query_state);
@@ -818,7 +813,7 @@
 			*st->eids[x-skipfirst] = *ies->eids[x];
 			s += sizeof(dundi_eid);
 		}
-		ast_debug(1, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context);
+		ast_debug(1, "Answering EID query for '%s@%s'!\n", ast_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context);
 
 		trans->thread = 1;
 		if (ast_pthread_create_detached(&lookupthread, NULL, dundi_query_thread, st)) {
@@ -965,7 +960,7 @@
 					trans->parent->dr[trans->parent->respcount].expiration = ies->expiration;
 				else
 					trans->parent->dr[trans->parent->respcount].expiration = dundi_cache_time;
-				dundi_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, 
+				ast_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, 
 					sizeof(trans->parent->dr[trans->parent->respcount].eid_str),
 					&ies->answers[x]->eid);
 				ast_copy_string(trans->parent->dr[trans->parent->respcount].dest, (char *)ies->answers[x]->data,
@@ -1005,7 +1000,7 @@
 		   and the last EID is the root, it is permissible that the first and last EID
 		   could be the same.  In that case, we should go ahead copy only the "root" section
 		   since we will not need it for authentication. */
-		if (!dundi_eid_cmp(ies->eids[0], ies->eids[ies->eidcount - 1]))
+		if (!ast_eid_cmp(ies->eids[0], ies->eids[ies->eidcount - 1]))
 			skipfirst = 1;
 	}
 
@@ -1089,7 +1084,7 @@
 		   and the last EID is the root, it is permissible that the first and last EID
 		   could be the same.  In that case, we should go ahead copy only the "root" section
 		   since we will not need it for authentication. */
-		if (!dundi_eid_cmp(ies->eids[0], ies->eids[ies->eidcount - 1]))
+		if (!ast_eid_cmp(ies->eids[0], ies->eids[ies->eidcount - 1]))
 			skipfirst = 1;
 	}
 
@@ -1191,7 +1186,7 @@
 							req->dr[req->respcount].techint = tech;
 							req->dr[req->respcount].expiration = expiration;
 							dundi_str_short_to_eid(&req->dr[req->respcount].eid, src);
-							dundi_eid_to_str(req->dr[req->respcount].eid_str, 
+							ast_eid_to_str(req->dr[req->respcount].eid_str, 
 								sizeof(req->dr[req->respcount].eid_str), &req->dr[req->respcount].eid);
 							ast_copy_string(req->dr[req->respcount].dest, ptr,
 								sizeof(req->dr[req->respcount].dest));
@@ -1232,7 +1227,7 @@
 	time(&now);
 	dundi_eid_to_str_short(eid_str, sizeof(eid_str), peer_eid);
 	dundi_eid_to_str_short(eidroot_str, sizeof(eidroot_str), &req->root_eid);
-	dundi_eid_to_str(eid_str_full, sizeof(eid_str_full), peer_eid);
+	ast_eid_to_str(eid_str_full, sizeof(eid_str_full), peer_eid);
 	snprintf(key, sizeof(key), "%s/%s/%s/e%08lx", eid_str, req->number, req->dcontext, crc32);
 	res |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
 	snprintf(key, sizeof(key), "%s/%s/%s/e%08lx", eid_str, req->number, req->dcontext, 0L);
@@ -1298,7 +1293,7 @@
 {
 	struct dundi_peer *peer = (struct dundi_peer *)data;
 	char eid_str[20];
-	ast_debug(1, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+	ast_debug(1, "Register expired for '%s'\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 	peer->registerexpire = -1;
 	peer->lastms = 0;
 	memset(&peer->addr, 0, sizeof(peer->addr));
@@ -1318,13 +1313,13 @@
 		ekey = ast_key_get(peer->inkey, AST_KEY_PUBLIC);
 		if (!ekey) {
 			ast_log(LOG_NOTICE, "No such key '%s' for creating RSA encrypted shared key for '%s'!\n",
-				peer->inkey, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+				peer->inkey, ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 			return -1;
 		}
 		skey = ast_key_get(peer->outkey, AST_KEY_PRIVATE);
 		if (!skey) {
 			ast_log(LOG_NOTICE, "No such key '%s' for signing RSA encrypted shared key for '%s'!\n",
-				peer->outkey, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+				peer->outkey, ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 			return -1;
 		}
 		if ((res = ast_encrypt_bin(peer->txenckey, key, sizeof(key), ekey)) != 128) {
@@ -1489,14 +1484,14 @@
 	key = ast_key_get(peer->outkey, AST_KEY_PRIVATE);
 	if (!key) {
 		ast_log(LOG_NOTICE, "Unable to find key '%s' to decode shared key from '%s'\n",
-			peer->outkey, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			peer->outkey, ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 		return -1;
 	}
 
 	skey = ast_key_get(peer->inkey, AST_KEY_PUBLIC);
 	if (!skey) {
 		ast_log(LOG_NOTICE, "Unable to find key '%s' to verify shared key from '%s'\n",
-			peer->inkey, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			peer->inkey, ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 		return -1;
 	}
 
@@ -1685,7 +1680,7 @@
 				ast_db_put("dundi/dpeers", dundi_eid_to_str_short(eid_str, sizeof(eid_str), &peer->eid), data);
 				if (inaddrcmp(&peer->addr, &trans->addr)) {
 					ast_verb(3, "Registered DUNDi peer '%s' at '%s:%d'\n",
-							dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), 
+							ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), 
 							ast_inet_ntoa(trans->addr.sin_addr), ntohs(trans->addr.sin_port));
 					needqual = 1;
 				}
@@ -1729,7 +1724,7 @@
 									trans->parent->dr[trans->parent->respcount].expiration = ies.expiration;
 								else
 									trans->parent->dr[trans->parent->respcount].expiration = dundi_cache_time;
-								dundi_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, 
+								ast_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, 
 									sizeof(trans->parent->dr[trans->parent->respcount].eid_str),
 									&ies.answers[x]->eid);
 								ast_copy_string(trans->parent->dr[trans->parent->respcount].dest, (char *)ies.answers[x]->data,
@@ -1812,7 +1807,7 @@
 							ast_copy_string(trans->parent->dei->phone, ies.q_phone, sizeof(trans->parent->dei->phone));
 						if (ies.q_ipaddr)
 							ast_copy_string(trans->parent->dei->ipaddr, ies.q_ipaddr, sizeof(trans->parent->dei->ipaddr));
-						if (!dundi_eid_cmp(&trans->them_eid, &trans->parent->query_eid)) {
+						if (!ast_eid_cmp(&trans->them_eid, &trans->parent->query_eid)) {
 							/* If it's them, update our address */
 							ast_copy_string(trans->parent->dei->ipaddr, ast_inet_ntoa(trans->addr.sin_addr), sizeof(trans->parent->dei->ipaddr));
 						}
@@ -1852,8 +1847,8 @@
 					dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, &ied);
 				}
 			} else {
-				ast_debug(1, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid),
-						dundi_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid));
+				ast_debug(1, "Yay, we've registered as '%s' to '%s'\n", ast_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid),
+						ast_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid));
 				/* Close connection if not final */
 				if (!final) 
 					dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL);
@@ -2581,7 +2576,7 @@
 	AST_LIST_LOCK(&peers);
 	len = strlen(word);
 	AST_LIST_TRAVERSE(&peers, p, list) {
-		const char *s = dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid);
+		const char *s = ast_eid_to_str(eid_str, sizeof(eid_str), &p->eid);
 		if (!strncasecmp(word, s, len) && ++which > state) {
 			ret = ast_strdup(s);
 			break;
@@ -2720,7 +2715,7 @@
 	}
 	if ((a->argc < 3) || (a->argc > 3))
 		return CLI_SHOWUSAGE;
-	if (dundi_str_to_eid(&eid, a->argv[2])) {
+	if (ast_str_to_eid(&eid, a->argv[2])) {
 		ast_cli(a->fd, "'%s' is not a valid EID!\n", a->argv[2]);
 		return CLI_SHOWUSAGE;
 	}
@@ -2770,7 +2765,7 @@
 		return CLI_SHOWUSAGE;
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, peer, list) {
-		if (!strcasecmp(dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), a->argv[3]))
+		if (!strcasecmp(ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), a->argv[3]))
 			break;
 	}
 	if (peer) {
@@ -2790,7 +2785,7 @@
 		default:
 			order = "Unknown";
 		}
-		ast_cli(a->fd, "Peer:    %s\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+		ast_cli(a->fd, "Peer:    %s\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 		ast_cli(a->fd, "Model:   %s\n", model2str(peer->model));
 		ast_cli(a->fd, "Host:    %s\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "<Unspecified>");
 		ast_cli(a->fd, "Dynamic: %s\n", peer->dynamic ? "yes" : "no");
@@ -2888,7 +2883,7 @@
 			snprintf(avgms, sizeof(avgms), "%d ms", peer->avgms);
 		else
 			strcpy(avgms, "Unavail");
-		snprintf(srch, sizeof(srch), FORMAT, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), 
+		snprintf(srch, sizeof(srch), FORMAT, ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), 
 					peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
 					peer->dynamic ? "(D)" : "(S)", model2str(peer->model), avgms, status);
 
@@ -2905,7 +2900,7 @@
                 }
 		
         if (print_line) {
-			ast_cli(a->fd, FORMAT, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), 
+			ast_cli(a->fd, FORMAT, ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), 
 					peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
 					peer->dynamic ? "(D)" : "(S)", model2str(peer->model), avgms, status);
 		}
@@ -2962,7 +2957,7 @@
 	if (a->argc != 3)
 		return CLI_SHOWUSAGE;
 	AST_LIST_LOCK(&peers);
-	dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid);
+	ast_eid_to_str(eid_str, sizeof(eid_str), &global_eid);
 	AST_LIST_UNLOCK(&peers);
 	ast_cli(a->fd, "Global EID for this system is '%s'\n", eid_str);
 	return CLI_SUCCESS;
@@ -2990,7 +2985,7 @@
 	ast_cli(a->fd, FORMAT2, "Number", "Context", "Root", "Max", "Rsp");
 	AST_LIST_TRAVERSE(&requests, req, list) {
 		ast_cli(a->fd, FORMAT, req->number, req->dcontext,
-			dundi_eid_zero(&req->root_eid) ? "<unspecified>" : dundi_eid_to_str(eidstr, sizeof(eidstr), &req->root_eid), req->maxcount, req->respcount);
+			dundi_eid_zero(&req->root_eid) ? "<unspecified>" : ast_eid_to_str(eidstr, sizeof(eidstr), &req->root_eid), req->maxcount, req->respcount);
 	}
 	AST_LIST_UNLOCK(&peers);
 	return CLI_SUCCESS;
@@ -3218,7 +3213,7 @@
 			if (peer->qualtrans == trans) {
 				if (fromtimeout) {
 					if (peer->lastms > -1)
-						ast_log(LOG_NOTICE, "Peer '%s' has become UNREACHABLE!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+						ast_log(LOG_NOTICE, "Peer '%s' has become UNREACHABLE!\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 					peer->lastms = -1;
 				} else {
 					ms = ast_tvdiff_ms(ast_tvnow(), peer->qualtx);
@@ -3226,9 +3221,9 @@
 						ms = 1;
 					if (ms < peer->maxms) {
 						if ((peer->lastms >= peer->maxms) || (peer->lastms < 0))
-							ast_log(LOG_NOTICE, "Peer '%s' has become REACHABLE!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+							ast_log(LOG_NOTICE, "Peer '%s' has become REACHABLE!\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 					} else if (peer->lastms < peer->maxms) {
-						ast_log(LOG_NOTICE, "Peer '%s' has become TOO LAGGED (%d ms)\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), ms);
+						ast_log(LOG_NOTICE, "Peer '%s' has become TOO LAGGED (%d ms)\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), ms);
 					}
 					peer->lastms = ms;
 				}
@@ -3236,7 +3231,7 @@
 			}
 			if (trans->storehist) {
 				if (trans->parent && !ast_strlen_zero(trans->parent->number)) {
-					if (!dundi_eid_cmp(&trans->them_eid, &peer->eid)) {
+					if (!ast_eid_cmp(&trans->them_eid, &peer->eid)) {
 						peer->avgms = 0;
 						cnt = 0;
 						if (peer->lookups[DUNDI_TIMING_HISTORY-1])
@@ -3379,7 +3374,7 @@
 		if (!res) 
 			res = dundi_xmit(pack);
 		if (res)
-			ast_log(LOG_NOTICE, "Failed to send packet to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->them_eid));
+			ast_log(LOG_NOTICE, "Failed to send packet to '%s'\n", ast_eid_to_str(eid_str, sizeof(eid_str), &trans->them_eid));
 				
 		if (cmdresp == DUNDI_COMMAND_ACK)
 			ast_free(pack);
@@ -3393,7 +3388,7 @@
 	struct dundi_transaction *trans = (struct dundi_transaction *)data;
 	char eid_str[20];
 	ast_log(LOG_NOTICE, "Transaction to '%s' took too long to ACK, destroying\n", 
-		dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->them_eid));
+		ast_eid_to_str(eid_str, sizeof(eid_str), &trans->them_eid));
 	trans->autokillid = -1;
 	destroy_trans(trans, 0); /* We could actually set it to 1 instead of 0, but we won't ;-) */
 	return 0;
@@ -3402,13 +3397,13 @@
 static void dundi_ie_append_eid_appropriately(struct dundi_ie_data *ied, char *context, dundi_eid *eid, dundi_eid *us)
 {
 	struct dundi_peer *p;
-	if (!dundi_eid_cmp(eid, us)) {
+	if (!ast_eid_cmp(eid, us)) {
 		dundi_ie_append_eid(ied, DUNDI_IE_EID_DIRECT, eid);
 		return;
 	}
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, p, list) {
-		if (!dundi_eid_cmp(&p->eid, eid)) {
+		if (!ast_eid_cmp(&p->eid, eid)) {
 			if (has_permission(&p->include, context))
 				dundi_ie_append_eid(ied, DUNDI_IE_EID_DIRECT, eid);
 			else
@@ -3615,16 +3610,16 @@
 
 		AST_LIST_TRAVERSE(&peers, peer, list) {
 			if (has_permission(&peer->include, dr->dcontext) && 
-			    dundi_eid_cmp(&peer->eid, &trans->them_eid) &&
+			    ast_eid_cmp(&peer->eid, &trans->them_eid) &&
 				(peer->order <= order)) {
 				/* For each other transaction, make sure we don't
 				   ask this EID about the others if they're not
 				   already in the list */
-				if (!dundi_eid_cmp(&tmp, &peer->eid)) 
+				if (!ast_eid_cmp(&tmp, &peer->eid)) 
 					x = -1;
 				else {
 					for (x=0;x<trans->eidcount;x++) {
-						if (!dundi_eid_cmp(&trans->eids[x], &peer->eid))
+						if (!ast_eid_cmp(&trans->eids[x], &peer->eid))
 							break;
 					}
 				}
@@ -3662,9 +3657,9 @@
 		return 0;
 
 	if (ast_strlen_zero(dr->number))
-		ast_debug(1, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext);
+		ast_debug(1, "Will query peer '%s' for '%s' (context '%s')\n", ast_eid_to_str(eid_str, sizeof(eid_str), &p->eid), ast_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext);
 	else
-		ast_debug(1, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext);
+		ast_debug(1, "Will query peer '%s' for '%s@%s'\n", ast_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext);
 
 	trans = create_transaction(p);
 	if (!trans)
@@ -3725,7 +3720,7 @@
 			allowconnect = p->model & DUNDI_MODEL_OUTBOUND;
 		}
 		if (skip) {
-			if (!dundi_eid_cmp(skip, &p->eid))
+			if (!ast_eid_cmp(skip, &p->eid))
 				pass = 0;
 		}
 		if (pass) {
@@ -3738,7 +3733,7 @@
 					/* Make sure we haven't already seen it and that it won't
 					   affect our answer */
 					for (x=0;avoid[x];x++) {
-						if (!dundi_eid_cmp(avoid[x], &p->eid) || !dundi_eid_cmp(avoid[x], &p->us_eid)) {
+						if (!ast_eid_cmp(avoid[x], &p->eid) || !ast_eid_cmp(avoid[x], &p->us_eid)) {
 							/* If not a direct connection, it affects our answer */
 							if (directs && !directs[x]) 
 								ast_clear_flag_nonstd(dr->hmd, DUNDI_HINT_UNAFFECTED);
@@ -3751,7 +3746,7 @@
 							/* Check for a matching or 0 cache entry */
 							append_transaction(dr, p, ttl, avoid);
 						} else {
-							ast_debug(1, "Avoiding '%s' in transaction\n", dundi_eid_to_str(eid_str, sizeof(eid_str), avoid[x]));
+							ast_debug(1, "Avoiding '%s' in transaction\n", ast_eid_to_str(eid_str, sizeof(eid_str), avoid[x]));
 						}
 					}
 				}
@@ -3774,9 +3769,9 @@
 			dr->dcontext, dr->number);
 		if (!strcasecmp(cur->dcontext, dr->dcontext) &&
 		    !strcasecmp(cur->number, dr->number) &&
-		    (!dundi_eid_cmp(&cur->root_eid, &dr->root_eid) || (cur->crc32 == dr->crc32))) {
+		    (!ast_eid_cmp(&cur->root_eid, &dr->root_eid) || (cur->crc32 == dr->crc32))) {
 			ast_debug(1, "Found existing query for '%s@%s' for '%s' crc '%08lx'\n", 
-				cur->dcontext, cur->number, dundi_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
+				cur->dcontext, cur->number, ast_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
 			*pending = cur;
 			res = 1;
 			break;
@@ -3784,7 +3779,7 @@
 	}
 	if (!res) {
 		ast_debug(1, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n", 
-				dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
+				dr->number, dr->dcontext, ast_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
 		/* Go ahead and link us in since nobody else is searching for this */
 		AST_LIST_INSERT_HEAD(&requests, dr, list);
 		*pending = NULL;
@@ -3870,18 +3865,18 @@
 	res = register_request(&dr, &pending);
 	if (res) {
 		/* Already a request */
-		if (rooteid && !dundi_eid_cmp(&dr.root_eid, &pending->root_eid)) {
+		if (rooteid && !ast_eid_cmp(&dr.root_eid, &pending->root_eid)) {
 			/* This is on behalf of someone else.  Go ahead and close this out since
 			   they'll get their answer anyway. */
 			ast_debug(1, "Oooh, duplicate request for '%s@%s' for '%s'\n",
-				dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid));
+				dr.number,dr.dcontext,ast_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid));
 			close(dr.pfds[0]);
 			close(dr.pfds[1]);
 			return -2;
 		} else {
 			/* Wait for the cache to populate */
 			ast_debug(1, "Waiting for similar request for '%s@%s' for '%s'\n",
-				dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid));
+				dr.number,dr.dcontext,ast_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid));
 			start = ast_tvnow();
 			while(check_request(pending) && (ast_tvdiff_ms(ast_tvnow(), start) < ttlms) && (!chan || !ast_check_hangup(chan))) {
 				/* XXX Would be nice to have a way to poll/select here XXX */
@@ -4570,7 +4565,7 @@
 	struct dundi_peer *peer = (struct dundi_peer *)data;
 	char eid_str[20];
 	char eid_str2[20];
-	ast_debug(1, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid));
+	ast_debug(1, "Register us as '%s' to '%s'\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), ast_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid));
 	peer->registerid = ast_sched_add(sched, default_expiration * 1000, do_register, data);
 	/* Destroy old transaction if there is one */
 	if (peer->regtrans)
@@ -4585,7 +4580,7 @@
 		dundi_send(peer->regtrans, DUNDI_COMMAND_REGREQ, 0, 0, &ied);
 		
 	} else
-		ast_log(LOG_NOTICE, "Unable to create new transaction for registering to '%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+		ast_log(LOG_NOTICE, "Unable to create new transaction for registering to '%s'!\n", ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 
 	return 0;
 }
@@ -4628,7 +4623,7 @@
 	char *c;
 	int port, expire;
 	char eid_str[20];
-	dundi_eid_to_str(eid_str, sizeof(eid_str), eid);
+	ast_eid_to_str(eid_str, sizeof(eid_str), eid);
 	if (!ast_db_get("dundi/dpeers", eid_str, data, sizeof(data))) {
 		c = strchr(data, ':');
 		if (c) {
@@ -4656,7 +4651,7 @@
 
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, peer, list) {
-		if (!dundi_eid_cmp(&peer->eid, eid)) {	
+		if (!ast_eid_cmp(&peer->eid, eid)) {	
 			break;
 		}
 	}
@@ -4699,7 +4694,7 @@
 				}
 			}
 		} else if (!strcasecmp(v->name, "ustothem")) {
-			if (!dundi_str_to_eid(&testeid, v->value))
+			if (!ast_str_to_eid(&testeid, v->value))
 				peer->us_eid = testeid;
 			else
 				ast_log(LOG_WARNING, "'%s' is not a valid DUNDi Entity Identifier at line %d\n", v->value, v->lineno);
@@ -4732,7 +4727,7 @@
 				peer->maxms = DEFAULT_MAXMS;
 			} else if (sscanf(v->value, "%d", &peer->maxms) != 1) {
 				ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of dundi.conf\n", 
-					dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), v->lineno);
+					ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), v->lineno);
 				peer->maxms = 0;
 			}
 		} else if (!strcasecmp(v->name, "model")) {
@@ -4766,22 +4761,22 @@
 	(*globalpcmode) |= peer->pcmodel;
 	if (!peer->model && !peer->pcmodel) {
 		ast_log(LOG_WARNING, "Peer '%s' lacks a model or pcmodel, discarding!\n", 
-			dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 		peer->dead = 1;
 	} else if ((peer->model & DUNDI_MODEL_INBOUND) && (peer->pcmodel & DUNDI_MODEL_OUTBOUND)) {
 		ast_log(LOG_WARNING, "Peer '%s' may not be both inbound/symmetric model and outbound/symmetric precache model, discarding!\n", 
-			dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 		peer->dead = 1;
 	} else if ((peer->model & DUNDI_MODEL_OUTBOUND) && (peer->pcmodel & DUNDI_MODEL_INBOUND)) {
 		ast_log(LOG_WARNING, "Peer '%s' may not be both outbound/symmetric model and inbound/symmetric precache model, discarding!\n", 
-			dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 		peer->dead = 1;
 	} else if (!AST_LIST_EMPTY(&peer->include) && !(peer->model & DUNDI_MODEL_OUTBOUND) && !(peer->pcmodel & DUNDI_MODEL_INBOUND)) {
 		ast_log(LOG_WARNING, "Peer '%s' is supposed to be included in outbound searches but isn't an outbound peer or inbound precache!\n", 
-			dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 	} else if (!AST_LIST_EMPTY(&peer->permit) && !(peer->model & DUNDI_MODEL_INBOUND) && !(peer->pcmodel & DUNDI_MODEL_OUTBOUND)) {
 		ast_log(LOG_WARNING, "Peer '%s' is supposed to have permission for some inbound searches but isn't an inbound peer or outbound precache!\n", 
-			dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+			ast_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
 	} else { 
 		if (needregister) {
 			peer->registerid = ast_sched_add(sched, 2000, do_register, peer);
@@ -5153,7 +5148,9 @@
 	} else
 		ast_log(LOG_WARNING, "Unable to get host name!\n");
 	AST_LIST_LOCK(&peers);
-	reset_global_eid();
+
+	memcpy(&global_eid, &g_eid, sizeof(global_eid));
+
 	global_storehistory = 0;
 	ast_copy_string(secretpath, "dundi", sizeof(secretpath));
 	v = ast_variable_browse(cfg, "general");
@@ -5193,7 +5190,7 @@
 				global_autokilltimeout = 0;
 			}
 		} else if (!strcasecmp(v->name, "entityid")) {
-			if (!dundi_str_to_eid(&testeid, v->value))
+			if (!ast_str_to_eid(&testeid, v->value))
 				global_eid = testeid;
 			else
 				ast_log(LOG_WARNING, "Invalid global endpoint identifier '%s' at line %d\n", v->value, v->lineno);
@@ -5240,7 +5237,7 @@
 	while ((cat = ast_category_browse(cfg, cat))) {
 		if (strcasecmp(cat, "general") && strcasecmp(cat, "mappings") && strcasecmp(cat, "event_mappings")) {
 			/* Entries */
-			if (!dundi_str_to_eid(&testeid, cat))
+			if (!ast_str_to_eid(&testeid, cat))
 				build_peer(&testeid, ast_variable_browse(cfg, cat), &globalpcmodel);
 			else if (!strcasecmp(cat, "*")) {
 				build_peer(&empty_eid, ast_variable_browse(cfg, cat), &globalpcmodel);




More information about the svn-commits mailing list