Summary: | ASTERISK-10158: [patch] Dundi support for true dynamic peering (the '*' mapping) | ||
Reporter: | David Smith (dds) | Labels: | |
Date Opened: | 2007-08-24 03:37:48 | Date Closed: | 2007-09-18 11:15:18 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | PBX/pbx_dundi |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) dundi.conf ( 1) dyndundi.patch ( 2) output.txt | |
Description: | The sample configuration file for DUNDi claims that you can specify a '*' peer as a special unspecified entity to match any peer. This is useful in situations where you have a dynamic server pool, such as when doing speech recognition processing on a grid, and you want to make use of DUNDi's ability to find a server to forward the call to based on the current load. The implementation of this was non-existent; apparently the person who wrote the sample configuration file was under a different impression than the author(s) of pbx_dundi.c. I've implemented this support and included a patch in this bug. I would very much like this support to be included in the next release, as I believe others would do. Thanks, ****** ADDITIONAL INFORMATION ****** --- asterisk-1.4.10~dfsg.orig/pbx/pbx_dundi.c +++ asterisk-1.4.10~dfsg/pbx/pbx_dundi.c @@ -267,6 +267,7 @@ static AST_LIST_HEAD_NOLOCK_STATIC(alltrans, dundi_transaction); static int dundi_xmit(struct dundi_packet *pack); +static struct dundi_peer *any_peer; static void dundi_debug_output(const char *data) { @@ -486,7 +487,8 @@ if (!dundi_eid_cmp(&cur->eid,eid)) break; } - + if (!cur && any_peer) + cur = any_peer; return cur; } @@ -1505,7 +1507,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)); @@ -1589,6 +1591,21 @@ case DUNDI_COMMAND_REGREQ: /* A register request -- should only have one entity */ peer = find_peer(ies.eids[0]); + /** Dynamic Peering **/ + /* if the peer is not found and we have a valid 'any_peer' setting */ + if (peer == any_peer && any_peer != NULL) + { + /* copy any_peer into a new peer object */ + peer = ast_calloc(1, sizeof(*peer)); + memcpy(peer, any_peer, sizeof(*peer)); + /* set EID to remote EID */ + peer->eid = *ies.eids[0]; + /* add the peer the peer list */ + AST_LIST_LOCK(&peers); + AST_LIST_INSERT_HEAD(&peers, peer, list); + AST_LIST_UNLOCK(&peers); + } + /** End Dynamic Peering **/ 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); @@ -1801,7 +1818,7 @@ dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL); break; case DUNDI_COMMAND_ENCREJ: - if ((ast_test_flag(trans, FLAG_SENDFULLKEY)) || AST_LIST_EMPTY(&trans->lasttrans) || !(peer = find_peer(&trans->them_eid))) { + if ((ast_test_flag(trans, FLAG_SENDFULLKEY)) || AST_LIST_EMPTY(&trans->lasttrans) || !(peer = find_peer(&trans->them_eid))) { /* No really, it's over at this point */ if (!final) dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL); @@ -4330,6 +4347,7 @@ dundi_ttl = DUNDI_DEFAULT_TTL; dundi_cache_time = DUNDI_DEFAULT_CACHE_TIME; cfg = ast_config_load(config_file); + any_peer = NULL; if (!cfg) { @@ -4453,8 +4471,14 @@ /* Entries */ if (!dundi_str_to_eid(&testeid, cat)) build_peer(&testeid, ast_variable_browse(cfg, cat), &globalpcmodel); - else - ast_log(LOG_NOTICE, "Ignoring invalid EID entry '%s'\n", cat); + else if (!strcasecmp(cat, "*")) + /* any peer */ + { + 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); } | ||
Comments: | By: Ronald Chan (loloski) 2007-09-07 21:58:01 Any news here please? By: Russell Bryant (russell) 2007-09-11 10:43:45 In the future, please use tabs instead of spaces for indentation. Also, take a look at doc/CODING-GUIDELINES for other coding standards. By: Digium Subversion (svnbot) 2007-09-11 10:45:06 Repository: asterisk Revision: 82250 ------------------------------------------------------------------------ r82250 | russell | 2007-09-11 10:45:06 -0500 (Tue, 11 Sep 2007) | 4 lines 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 ASTERISK-10158, patch by dds, with some changes by me) ------------------------------------------------------------------------ By: Digium Subversion (svnbot) 2007-09-11 10:46:28 Repository: asterisk Revision: 82251 ------------------------------------------------------------------------ r82251 | russell | 2007-09-11 10:46:28 -0500 (Tue, 11 Sep 2007) | 12 lines Merged revisions 82250 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r82250 | russell | 2007-09-11 11:03:42 -0500 (Tue, 11 Sep 2007) | 4 lines 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 ASTERISK-10158, patch by dds, with some changes by me) ........ ------------------------------------------------------------------------ By: Michiel van Baak (mvanbaak) 2007-09-12 04:25:58 as tbsky noted in 0010703: dundi.conf can not do "[*]" config, dds make a patch for it. i try it and it works well. but when using this setup under freePBX, asterisk often crash and core dump when press freePBX "reload" bar. so i think there maybe something wrong with it. sorry i can not comment on that patch, since that bug is closed now. By: Michiel van Baak (mvanbaak) 2007-09-12 04:26:52 Can you provide your dundi.conf and a backtrace ? By: tbsky (tbsky) 2007-09-18 03:07:55 hi: sorry. i just learn how to backtrace. i upload my dundi.conf and backtrace output.txt. thanks for help! By: David Smith (dds) 2007-09-18 03:26:31 Would a decent enough solution to make it so that in destroy_peer, the peer->permit and peer->include are only free()d if they are different then the any_peer->permit and any_peer->include, respectively? Thanks, David By: Digium Subversion (svnbot) 2007-09-18 11:12:14 Repository: asterisk Revision: 82802 ------------------------------------------------------------------------ r82802 | russell | 2007-09-18 11:12:14 -0500 (Tue, 18 Sep 2007) | 4 lines When copying the contents from the wildcard peer, do a deep copy instead of shallow copy so that it doesn't crash when beging destroyed. (closes issue ASTERISK-10158, patch by me) ------------------------------------------------------------------------ By: Digium Subversion (svnbot) 2007-09-18 11:15:18 Repository: asterisk Revision: 82803 ------------------------------------------------------------------------ r82803 | russell | 2007-09-18 11:15:18 -0500 (Tue, 18 Sep 2007) | 12 lines Merged revisions 82802 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r82802 | russell | 2007-09-18 11:31:01 -0500 (Tue, 18 Sep 2007) | 4 lines When copying the contents from the wildcard peer, do a deep copy instead of shallow copy so that it doesn't crash when beging destroyed. (closes issue ASTERISK-10158, patch by me) ........ ------------------------------------------------------------------------ |