[asterisk-commits] russell: branch 1.4 r82250 - /branches/1.4/pbx/pbx_dundi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 11 11:03:42 CDT 2007
Author: russell
Date: Tue Sep 11 11:03:42 2007
New Revision: 82250
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82250
Log:
The sample dundi.conf claims support for a wildcard peer entry - [*], but the
code did not support it. This patch makes it work.
(closes issue #10546, patch by dds, with some changes by me)
Modified:
branches/1.4/pbx/pbx_dundi.c
Modified: branches/1.4/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_dundi.c?view=diff&rev=82250&r1=82249&r2=82250
==============================================================================
--- branches/1.4/pbx/pbx_dundi.c (original)
+++ branches/1.4/pbx/pbx_dundi.c Tue Sep 11 11:03:42 2007
@@ -268,6 +268,13 @@
static AST_LIST_HEAD_NOLOCK_STATIC(requests, dundi_request);
static AST_LIST_HEAD_NOLOCK_STATIC(alltrans, dundi_transaction);
+/*!
+ * \brief Wildcard peer
+ *
+ * This peer is created if the [*] entry is specified in dundi.conf
+ */
+static struct dundi_peer *any_peer;
+
static int dundi_xmit(struct dundi_packet *pack);
static void dundi_debug_output(const char *data)
@@ -488,6 +495,9 @@
if (!dundi_eid_cmp(&cur->eid,eid))
break;
}
+
+ if (!cur && any_peer)
+ cur = any_peer;
return cur;
}
@@ -1507,7 +1517,7 @@
unsigned char *bufcpy;
struct dundi_ie_data ied;
struct dundi_ies ies;
- struct dundi_peer *peer;
+ struct dundi_peer *peer = NULL;
char eid_str[20];
char eid_str2[20];
memset(&ied, 0, sizeof(ied));
@@ -1591,6 +1601,23 @@
case DUNDI_COMMAND_REGREQ:
/* A register request -- should only have one entity */
peer = find_peer(ies.eids[0]);
+
+ /* if the peer is not found and we have a valid 'any_peer' setting */
+ if (any_peer && peer == any_peer) {
+ /* copy any_peer into a new peer object */
+ peer = ast_calloc(1, sizeof(*peer));
+ if (peer) {
+ memcpy(peer, any_peer, sizeof(*peer));
+
+ /* set EID to remote EID */
+ peer->eid = *ies.eids[0];
+
+ AST_LIST_LOCK(&peers);
+ AST_LIST_INSERT_HEAD(&peers, peer, list);
+ AST_LIST_UNLOCK(&peers);
+ }
+ }
+
if (!peer || !peer->dynamic) {
dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_NOAUTH, NULL);
dundi_send(trans, DUNDI_COMMAND_REGRESPONSE, 0, 1, &ied);
@@ -4331,8 +4358,9 @@
dundi_ttl = DUNDI_DEFAULT_TTL;
dundi_cache_time = DUNDI_DEFAULT_CACHE_TIME;
+ any_peer = NULL;
+
cfg = ast_config_load(config_file);
-
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config_file);
@@ -4455,7 +4483,10 @@
/* Entries */
if (!dundi_str_to_eid(&testeid, cat))
build_peer(&testeid, ast_variable_browse(cfg, cat), &globalpcmodel);
- else
+ else if (!strcasecmp(cat, "*")) {
+ build_peer(&empty_eid, ast_variable_browse(cfg, cat), &globalpcmodel);
+ any_peer = find_peer(NULL);
+ } else
ast_log(LOG_NOTICE, "Ignoring invalid EID entry '%s'\n", cat);
}
cat = ast_category_browse(cfg, cat);
More information about the asterisk-commits
mailing list