[asterisk-commits] russell: trunk r121439 - in /trunk: doc/tex/ include/asterisk/ main/ pbx/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 10 07:48:50 CDT 2008


Author: russell
Date: Tue Jun 10 07:48:50 2008
New Revision: 121439

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121439
Log:
Merge another change from team/russell/events ...

DUNDi uses a concept called the Entity ID for unique server identifiers.  I have
pulled out the handling of EIDs and made it something available to all of Asterisk.
There is now a global Entity ID that can be used for other purposes as well, such
as code providing distributed device state, which is why I did this.  The global
Entity ID is set automatically, just like it was done in DUNDi, but it can also be
set in asterisk.conf.  DUNDi will now use this global EID unless one is specified
in dundi.conf.

The current EID for the system can be seen in the "core show settings" CLI command.
It is also available in the dialplan via the ENTITYID variable.

Modified:
    trunk/doc/tex/asterisk-conf.tex
    trunk/doc/tex/channelvariables.tex
    trunk/include/asterisk/dundi.h
    trunk/include/asterisk/utils.h
    trunk/main/asterisk.c
    trunk/main/netsock.c
    trunk/main/pbx.c
    trunk/pbx/dundi-parser.c
    trunk/pbx/dundi-parser.h
    trunk/pbx/pbx_dundi.c

Modified: trunk/doc/tex/asterisk-conf.tex
URL: http://svn.digium.com/view/asterisk/trunk/doc/tex/asterisk-conf.tex?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/doc/tex/asterisk-conf.tex (original)
+++ trunk/doc/tex/asterisk-conf.tex Tue Jun 10 07:48:50 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: trunk/doc/tex/channelvariables.tex
URL: http://svn.digium.com/view/asterisk/trunk/doc/tex/channelvariables.tex?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/doc/tex/channelvariables.tex (original)
+++ trunk/doc/tex/channelvariables.tex Tue Jun 10 07:48:50 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: trunk/include/asterisk/dundi.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/dundi.h?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/include/asterisk/dundi.h (original)
+++ trunk/include/asterisk/dundi.h Tue Jun 10 07:48:50 2008
@@ -25,15 +25,11 @@
 #define _ASTERISK_DUNDI_H
 
 #include "asterisk/channel.h"
+#include "asterisk/utils.h"
 
 #define DUNDI_PORT 4520
 
-/*!\brief A DUNDi Entity ID is essentially a MAC address, brief and unique */
-struct _dundi_eid {
-	unsigned char eid[6];
-} __attribute__ ((__packed__));
-
-typedef struct _dundi_eid dundi_eid;
+typedef struct ast_eid dundi_eid;
 
 struct dundi_hdr {
 	unsigned short strans;			/*!< Source transaction */
@@ -54,26 +50,49 @@
 #define DUNDI_FLAG_RETRANS		(1 << 16)	/*!< Applies to dtrans */
 #define DUNDI_FLAG_RESERVED		(1 << 16)	/*!< Applies to strans */
 
-#define DUNDI_PROTO_NONE		0		/*!< No answer yet */
-#define DUNDI_PROTO_IAX			1		/*!< IAX version 2 */
-#define DUNDI_PROTO_SIP			2		/*!< Session Initiation Protocol */
-#define DUNDI_PROTO_H323		3		/*!< ITU H.323 */
-
-#define DUNDI_FLAG_NONEXISTENT		(0)		/*!< Isn't and can't be a valid number */
-#define DUNDI_FLAG_EXISTS		(1 << 0)	/*!< Is a valid number */
-#define DUNDI_FLAG_MATCHMORE		(1 << 1)	/*!< Might be valid if you add more digits */
-#define DUNDI_FLAG_CANMATCH		(1 << 2)	/*!< Might be a match */
-#define DUNDI_FLAG_IGNOREPAT		(1 << 3)	/*!< Keep dialtone */
-#define DUNDI_FLAG_RESIDENTIAL		(1 << 4)	/*!< Destination known to be residential */
-#define DUNDI_FLAG_COMMERCIAL		(1 << 5)	/*!< Destination known to be commercial */
-#define DUNDI_FLAG_MOBILE		(1 << 6)	/*!< Destination known to be cellular/mobile */
-#define DUNDI_FLAG_NOUNSOLICITED	(1 << 7)	/*!< No unsolicited calls of any kind through this route */
-#define DUNDI_FLAG_NOCOMUNSOLICIT	(1 << 8)	/*!< No commercial unsolicited calls through this route */
-
-#define DUNDI_HINT_NONE			(0)
-#define DUNDI_HINT_TTL_EXPIRED		(1 << 0)	/*!< TTL Expired */
-#define DUNDI_HINT_DONT_ASK		(1 << 1)	/*!< Don't ask for anything beginning with data */
-#define DUNDI_HINT_UNAFFECTED		(1 << 2)	/*!< Answer not affected by entity list */
+enum {
+	/*! No answer yet */
+	DUNDI_PROTO_NONE = 0,
+	/*! IAX, version 2 */
+	DUNDI_PROTO_IAX  = 1,
+	/*! SIP - Session Initiation Protocol, RFC 3261 */
+	DUNDI_PROTO_SIP  = 2,
+	/*! ITU H.323 */
+	DUNDI_PROTO_H323 = 3,
+};
+
+enum {
+	/*! Isn't and can't be a valid number */
+	DUNDI_FLAG_NONEXISTENT =    (0),
+	/*! Is a valid number */
+	DUNDI_FLAG_EXISTS =         (1 << 0),
+	/*! Might be valid if you add more digits */
+	DUNDI_FLAG_MATCHMORE =      (1 << 1),
+	/*! Might be a match */
+	DUNDI_FLAG_CANMATCH =       (1 << 2),
+	/*! Keep dialtone */
+	DUNDI_FLAG_IGNOREPAT =      (1 << 3),
+	/*! Destination known to be residential */
+	DUNDI_FLAG_RESIDENTIAL =    (1 << 4),
+	/*! Destination known to be commercial */
+	DUNDI_FLAG_COMMERCIAL =     (1 << 5),
+	/*! Destination known to be cellular/mobile */
+	DUNDI_FLAG_MOBILE =         (1 << 6),
+	/*! No unsolicited calls of any kind through this route */
+	DUNDI_FLAG_NOUNSOLICITED =  (1 << 7),
+	/*! No commercial unsolicited calls through this route */
+	DUNDI_FLAG_NOCOMUNSOLICIT = (1 << 8),
+};
+
+enum {
+	DUNDI_HINT_NONE =        (0),
+	/*! TTL Expired */
+	DUNDI_HINT_TTL_EXPIRED = (1 << 0),
+	/*! Don't ask for anything beginning with data */
+	DUNDI_HINT_DONT_ASK =    (1 << 1),
+	/*! Answer not affected by entity list */
+	DUNDI_HINT_UNAFFECTED =  (1 << 2),
+};
 
 struct dundi_encblock {				/*!< AES-128 encrypted block */
 	unsigned char iv[16];			/*!< Initialization vector of random data */
@@ -93,14 +112,24 @@
 	unsigned char data[0];			/*!< For data for hint */
 } __attribute__ ((__packed__));
 
-#define DUNDI_CAUSE_SUCCESS		0	/*!< Success */
-#define DUNDI_CAUSE_GENERAL		1	/*!< General unspecified failure */
-#define DUNDI_CAUSE_DYNAMIC		2	/*!< Requested entity is dynamic */
-#define DUNDI_CAUSE_NOAUTH		3	/*!< No or improper authorization */
-#define DUNDI_CAUSE_DUPLICATE		4	/*!< Duplicate request */
-#define DUNDI_CAUSE_TTL_EXPIRED		5	/*!< Expired TTL */
-#define DUNDI_CAUSE_NEEDKEY		6	/*!< Need new session key to decode */
-#define DUNDI_CAUSE_BADENCRYPT		7	/*!< Badly encrypted data */
+enum {
+	/*! Success */
+	DUNDI_CAUSE_SUCCESS =     0,
+	/*! General unspecified failure */
+	DUNDI_CAUSE_GENERAL =     1,
+	/*! Requested entity is dynamic */
+	DUNDI_CAUSE_DYNAMIC =     2,
+	/*! No or improper authorization */
+	DUNDI_CAUSE_NOAUTH =      3,
+	/*! Duplicate request */
+	DUNDI_CAUSE_DUPLICATE =   4,
+	/*! Expired TTL */
+	DUNDI_CAUSE_TTL_EXPIRED = 5,
+	/*! Need new session key to decode */
+	DUNDI_CAUSE_NEEDKEY =     6,
+	/*! Badly encrypted data */
+	DUNDI_CAUSE_BADENCRYPT =  7,
+};
 
 struct dundi_cause {			
 	unsigned char causecode;		/*!< Numerical cause (DUNDI_CAUSE_*) */
@@ -114,14 +143,16 @@
 	dundi_eid peereid;
 } __attribute__ ((__packed__));
 
-#define DUNDI_PEER_PRIMARY		(1 << 0)
-#define DUNDI_PEER_SECONDARY		(1 << 1)
-#define DUNDI_PEER_UNAVAILABLE		(1 << 2)
-#define DUNDI_PEER_REGISTERED		(1 << 3)
-#define DUNDI_PEER_MOD_OUTBOUND		(1 << 4)
-#define DUNDI_PEER_MOD_INBOUND		(1 << 5)
-#define DUNDI_PEER_PCMOD_OUTBOUND	(1 << 6)
-#define DUNDI_PEER_PCMOD_INBOUND	(1 << 7)
+enum {
+	DUNDI_PEER_PRIMARY =        (1 << 0),
+	DUNDI_PEER_SECONDARY =      (1 << 1),
+	DUNDI_PEER_UNAVAILABLE =    (1 << 2),
+	DUNDI_PEER_REGISTERED =     (1 << 3),
+	DUNDI_PEER_MOD_OUTBOUND =   (1 << 4),
+	DUNDI_PEER_MOD_INBOUND =    (1 << 5),
+	DUNDI_PEER_PCMOD_OUTBOUND = (1 << 6),
+	DUNDI_PEER_PCMOD_INBOUND =  (1 << 7),
+};
 
 #define DUNDI_COMMAND_FINAL		(0x80)		/*!< Or'd with other flags */
 
@@ -163,7 +194,7 @@
 #define DUNDI_IE_SHAREDKEY		17	/*!< RSA encrypted AES-128 key */
 #define DUNDI_IE_SIGNATURE		18	/*!< RSA Signature of encrypted shared key */
 #define DUNDI_IE_KEYCRC32		19	/*!< CRC32 of encrypted key (int) */
-#define DUNDI_IE_HINT			20	/*!< Answer hints (struct ast_hint) */
+#define DUNDI_IE_HINT			20	/*!< Answer hints */
 
 #define DUNDI_IE_DEPARTMENT		21	/*!< Department, for EIDQUERY (string) */
 #define DUNDI_IE_ORGANIZATION		22	/*!< Organization, for EIDQUERY (string) */

Modified: trunk/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/utils.h?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Tue Jun 10 07:48:50 2008
@@ -671,4 +671,46 @@
 
 #include "asterisk/strings.h"
 
+/*!
+ * \brief An Entity ID is essentially a MAC address, brief and unique 
+ */
+struct ast_eid {
+	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_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: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Tue Jun 10 07:48:50 2008
@@ -169,6 +169,8 @@
 
 /*! @} */
 
+struct ast_eid g_eid;
+
 /* XXX tmpdir is a subdir of the spool directory, and no way to remap it */
 char record_cache_dir[AST_CACHE_DIR_LEN] = DEFAULT_TMP_DIR;
 
@@ -386,6 +388,7 @@
 {
 	char buf[BUFSIZ];
 	struct ast_tm tm;
+	char eid_str[128];
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -396,6 +399,8 @@
 	case CLI_GENERATE:
 		return NULL;
 	}
+
+	ast_eid_to_str(eid_str, sizeof(eid_str), &g_eid);
 
 	ast_cli(a->fd, "\nPBX Core settings\n");
 	ast_cli(a->fd, "-----------------\n");
@@ -425,6 +430,7 @@
 	}
 	ast_cli(a->fd, "  System:                      %s/%s built by %s on %s %s\n", ast_build_os, ast_build_kernel, ast_build_user, ast_build_machine, ast_build_date);
 	ast_cli(a->fd, "  System name:                 %s\n", ast_config_AST_SYSTEM_NAME);
+	ast_cli(a->fd, "  Entity ID:                   %s\n", eid_str);
 	ast_cli(a->fd, "  Default language:            %s\n", defaultlanguage);
 	ast_cli(a->fd, "  Language prefix:             %s\n", ast_language_is_prefix ? "Enabled" : "Disabled");
 	ast_cli(a->fd, "  User name and group:         %s/%s\n", ast_config_AST_RUN_USER, ast_config_AST_RUN_GROUP);
@@ -2608,6 +2614,8 @@
 	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_default_eid(&g_eid);
+
 	/* no asterisk.conf? no problem, use buildtime config! */
 	if (!cfg) {
 		return;
@@ -2773,6 +2781,13 @@
 				option_minmemfree = 0;
 			}
 #endif
+		} else if (!strcasecmp(v->name, "entityid")) {
+			struct ast_eid tmp_eid;
+			if (!ast_str_to_eid(&tmp_eid, v->value)) {
+				ast_verbose("Successfully set global EID to '%s'\n", v->value);
+				g_eid = tmp_eid;
+			} else
+				ast_verbose("Invalid Entity ID '%s' provided\n", v->value);
 		}
 	}
 	for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {

Modified: trunk/main/netsock.c
URL: http://svn.digium.com/view/asterisk/trunk/main/netsock.c?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/main/netsock.c (original)
+++ trunk/main/netsock.c Tue Jun 10 07:48:50 2008
@@ -207,3 +207,84 @@
 {
 	ASTOBJ_UNREF(ns, ast_netsock_destroy);
 }
+
+char *ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
+{
+	int x;
+	char *os = s;
+	if (maxlen < 18) {
+		if (s && (maxlen > 0))
+			*s = '\0';
+	} else {
+		for (x = 0; x < 5; x++) {
+			sprintf(s, "%02x:", eid->eid[x]);
+			s += 3;
+		}
+		sprintf(s, "%02x", eid->eid[5]);
+	}
+	return os;
+}
+
+void ast_set_default_eid(struct ast_eid *eid)
+{
+#if defined(SIOCGIFHWADDR)
+	int s, x = 0;
+	char eid_str[20];
+	struct ifreq ifr;
+
+	s = socket(AF_INET, SOCK_STREAM, 0);
+	if (s < 0)
+		return;
+	for (x = 0; x < 10; x++) {
+		memset(&ifr, 0, sizeof(ifr));
+		snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x);
+		if (ioctl(s, SIOCGIFHWADDR, &ifr))
+			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);
+		close(s);
+		return;
+	}
+	close(s);
+#else
+#if defined(ifa_broadaddr) && !defined(SOLARIS)
+	char eid_str[20];
+	struct ifaddrs *ifap;
+	
+	if (getifaddrs(&ifap) == 0) {
+		struct ifaddrs *p;
+		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);
+				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);
+				freeifaddrs(ifap);
+				return;
+			}
+		}
+		freeifaddrs(ifap);
+	}
+#endif
+#endif
+	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)
+{
+	unsigned int eid_int[6];
+	int x;
+
+	if (sscanf(s, "%x:%x:%x:%x:%x:%x", &eid_int[0], &eid_int[1], &eid_int[2],
+		 &eid_int[3], &eid_int[4], &eid_int[5]) != 6)
+		 	return -1;
+	
+	for (x = 0; x < 6; x++)
+		eid->eid[x] = eid_int[x];
+
+	return 0;
+}
+
+int ast_eid_cmp(const struct ast_eid *eid1, const struct ast_eid *eid2)
+{
+	return memcmp(eid1, eid2, sizeof(*eid1));
+}

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Tue Jun 10 07:48:50 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: trunk/pbx/dundi-parser.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/dundi-parser.c?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/pbx/dundi-parser.c (original)
+++ trunk/pbx/dundi-parser.c Tue Jun 10 07:48:50 2008
@@ -48,23 +48,6 @@
 static void (*outputf)(const char *str) = internaloutput;
 static void (*errorf)(const char *str) = internalerror;
 
-char *dundi_eid_to_str(char *s, int maxlen, dundi_eid *eid)
-{
-	int x;
-	char *os = s;
-	if (maxlen < 18) {
-		if (s && (maxlen > 0))
-			*s = '\0';
-	} else {
-		for (x=0;x<5;x++) {
-			sprintf(s, "%02x:", eid->eid[x]);
-			s += 3;
-		}
-		sprintf(s, "%02x", eid->eid[5]);
-	}
-	return os;
-}
-
 char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid)
 {
 	int x;
@@ -81,18 +64,6 @@
 	return os;
 }
 
-int dundi_str_to_eid(dundi_eid *eid, const char *s)
-{
-	unsigned int eid_int[6];
-	int x;
-	if (sscanf(s, "%x:%x:%x:%x:%x:%x", &eid_int[0], &eid_int[1], &eid_int[2],
-		 &eid_int[3], &eid_int[4], &eid_int[5]) != 6)
-		 	return -1;
-	for (x=0;x<6;x++)
-		eid->eid[x] = eid_int[x];
-	return 0;
-}
-
 int dundi_str_short_to_eid(dundi_eid *eid, const char *s)
 {
 	unsigned int eid_int[6];
@@ -113,11 +84,6 @@
 	return 1;
 }
 
-int dundi_eid_cmp(dundi_eid *eid1, dundi_eid *eid2)
-{
-	return memcmp(eid1, eid2, sizeof(dundi_eid));
-}
-
 static void dump_string(char *output, int maxlen, void *value, int len)
 {
 	if (maxlen > len + 1)
@@ -134,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);
 }
@@ -335,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: trunk/pbx/dundi-parser.h
URL: http://svn.digium.com/view/asterisk/trunk/pbx/dundi-parser.h?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/pbx/dundi-parser.h (original)
+++ trunk/pbx/dundi-parser.h Tue Jun 10 07:48:50 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: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=121439&r1=121438&r2=121439
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Tue Jun 10 07:48:50 2008
@@ -388,50 +388,6 @@
 	dundi_xmit(&tmp.pack);
 }
 
-static void reset_global_eid(void)
-{
-#if defined(SIOCGIFHWADDR)
-	int s, x = 0;
-	char eid_str[20];
-	struct ifreq ifr;
-
-	s = socket(AF_INET, SOCK_STREAM, 0);
-	if (s < 0)
-		return;
-	for (x = 0; x < 10; x++) {
-		memset(&ifr, 0, sizeof(ifr));
-		snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x);
-		if (ioctl(s, SIOCGIFHWADDR, &ifr))
-			continue;
-		memcpy(&global_eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(global_eid));
-		ast_debug(1, "Seeding global EID '%s' from '%s' using 'siocgifhwaddr'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name);
-		close(s);
-		return;
-	}
-	close(s);
-#else
-#if defined(ifa_broadaddr) && !defined(SOLARIS)
-	char eid_str[20];
-	struct ifaddrs *ifap;
-	
-	if (getifaddrs(&ifap) == 0) {
-		struct ifaddrs *p;
-		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(&(global_eid.eid), sdp->sdl_data + sdp->sdl_nlen, 6);
-				ast_debug(1, "Seeding global EID '%s' from '%s' using 'getifaddrs'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), p->ifa_name);
-				freeifaddrs(ifap);
-				return;
-			}
-		}
-		freeifaddrs(ifap);
-	}
-#endif
-#endif
-	ast_log(LOG_NOTICE, "No ethernet interface found for seeding global EID. You will have to set it manually.\n");
-}
-
 static int get_trans_id(void)
 {
 	struct dundi_transaction *t;
@@ -475,7 +431,7 @@
 		eid = &empty_eid;
 	
 	AST_LIST_TRAVERSE(&peers, cur, list) {
-		if (!dundi_eid_cmp(&cur->eid,eid))
+		if (!ast_eid_cmp(&cur->eid,eid))
 			break;
 	}
 
@@ -557,7 +513,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);
@@ -611,7 +567,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));
@@ -670,7 +626,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 */
@@ -705,11 +661,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));
@@ -765,7 +721,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);
@@ -784,7 +740,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)) {
@@ -931,7 +887,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,
@@ -971,7 +927,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;
 	}
 
@@ -1055,7 +1011,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;
 	}
 
@@ -1157,7 +1113,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));
@@ -1198,7 +1154,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);
@@ -1264,7 +1220,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));
@@ -1284,13 +1240,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) {
@@ -1455,14 +1411,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;
 	}
 
@@ -1651,7 +1607,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;
 				}
@@ -1695,7 +1651,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,
@@ -1778,7 +1734,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));
 						}
@@ -1818,8 +1774,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);
@@ -2353,7 +2309,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;
@@ -2492,7 +2448,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;
 	}
@@ -2542,7 +2498,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) {
@@ -2562,7 +2518,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");
@@ -2660,7 +2616,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);
 
@@ -2677,7 +2633,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);
 		}
@@ -2734,7 +2690,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;
@@ -2762,7 +2718,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;
@@ -2930,7 +2886,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);
@@ -2938,9 +2894,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;
 				}
@@ -2948,7 +2904,7 @@
 			}
 			if (ast_test_flag(trans, FLAG_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])
@@ -3082,7 +3038,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);
@@ -3096,7 +3052,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;
@@ -3105,13 +3061,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
@@ -3318,16 +3274,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;
 					}
 				}
@@ -3365,9 +3321,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)
@@ -3428,7 +3384,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) {
@@ -3441,7 +3397,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);
@@ -3454,7 +3410,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]));
 						}
 					}
 				}
@@ -3477,9 +3433,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;
@@ -3487,7 +3443,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;
@@ -3573,18 +3529,18 @@

[... 133 lines stripped ...]



More information about the asterisk-commits mailing list