diff options
-rw-r--r-- | apps/app_directory.c | 48 | ||||
-rw-r--r-- | channels/chan_pjsip.c | 6 | ||||
-rw-r--r-- | channels/chan_sip.c | 9 |
3 files changed, 40 insertions, 23 deletions
diff --git a/apps/app_directory.c b/apps/app_directory.c index 267e2e8c3..ef3c363f9 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -518,7 +518,9 @@ static struct ast_config *realtime_directory(char *context) /* Skip hidden */ continue; } - ast_str_set(&tmp, 0, "no-password,%s", S_OR(fullname, "")); + + /* password,Full Name,email,pager,options */ + ast_str_set(&tmp, 0, "no-password,%s,,,", S_OR(fullname, "")); if (ast_variable_retrieve(rtdata, mailbox, "alias")) { for (alias = ast_variable_browse(rtdata, mailbox); alias; alias = alias->next) { if (!strcasecmp(alias->name, "alias")) { @@ -602,7 +604,10 @@ static int search_directory_sub(const char *context, struct ast_config *vmcfg, s { struct ast_variable *v; struct ast_str *buf = ast_str_thread_get(&commonbuf, 100); - char *pos, *bufptr, *cat, *alias; + char *name; + char *options; + char *alias; + char *cat; struct directory_item *item; int res; @@ -613,33 +618,36 @@ static int search_directory_sub(const char *context, struct ast_config *vmcfg, s ast_debug(2, "Pattern: %s\n", ext); for (v = ast_variable_browse(vmcfg, context); v; v = v->next) { - - /* Ignore hidden */ - if (strcasestr(v->value, "hidefromdir=yes")) { - continue; - } - ast_str_set(&buf, 0, "%s", v->value); - bufptr = ast_str_buffer(buf); + options = ast_str_buffer(buf); /* password,Full Name,email,pager,options */ - strsep(&bufptr, ","); - pos = strsep(&bufptr, ","); - - /* No name to compare against */ - if (ast_strlen_zero(pos)) { + strsep(&options, ","); /* Skip password */ + name = strsep(&options, ","); /* Save full name */ + strsep(&options, ","); /* Skip email */ + strsep(&options, ","); /* Skip pager */ + /* options is now the options field if it exists. */ + + if (options && strcasestr(options, "hidefromdir=yes")) { + /* Ignore hidden */ + continue; + } + if (ast_strlen_zero(name)) { + /* No name to compare against */ continue; } res = 0; if (ast_test_flag(&flags, OPT_LISTBYLASTNAME)) { - res = check_match(&item, context, pos, v->name, ext, 0 /* use_first_name */); + res = check_match(&item, context, name, v->name, ext, 0 /* use_first_name */); } if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) { - res = check_match(&item, context, pos, v->name, ext, 1 /* use_first_name */); + res = check_match(&item, context, name, v->name, ext, 1 /* use_first_name */); } - if (!res && ast_test_flag(&flags, OPT_ALIAS) && (alias = strcasestr(bufptr, "alias="))) { + if (!res && ast_test_flag(&flags, OPT_ALIAS) + && options && (alias = strcasestr(options, "alias="))) { char *a; + ast_debug(1, "Found alias: %s\n", alias); while ((a = strsep(&alias, "|"))) { if (!strncasecmp(a, "alias=", 6)) { @@ -683,9 +691,9 @@ static int search_directory_sub(const char *context, struct ast_config *vmcfg, s res = check_match(&item, context, position, cat, ext, 1 /* use_first_name */); } if (!res && ast_test_flag(&flags, OPT_ALIAS)) { - struct ast_variable *alias; - for (alias = ast_variable_browse(ucfg, cat); alias; alias = alias->next) { - if (!strcasecmp(v->name, "alias") && (res = check_match(&item, context, v->value, cat, ext, 1))) { + for (v = ast_variable_browse(ucfg, cat); v; v = v->next) { + if (!strcasecmp(v->name, "alias") + && (res = check_match(&item, context, v->value, cat, ext, 1))) { break; } } diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c index b7d7065f2..c6a02d9c7 100644 --- a/channels/chan_pjsip.c +++ b/channels/chan_pjsip.c @@ -388,7 +388,9 @@ static struct ast_channel *chan_pjsip_new(struct ast_sip_session *session, int s chan = ast_channel_alloc_with_endpoint(1, state, S_COR(session->id.number.valid, session->id.number.str, ""), S_COR(session->id.name.valid, session->id.name.str, ""), - session->endpoint->accountcode, "", "", assignedids, requestor, 0, + session->endpoint->accountcode, + exten, session->endpoint->context, + assignedids, requestor, 0, session->endpoint->persistent, "PJSIP/%s-%08x", ast_sorcery_object_get_id(session->endpoint), (unsigned) ast_atomic_fetchadd_int((int *) &chan_idx, +1)); @@ -445,8 +447,6 @@ static struct ast_channel *chan_pjsip_new(struct ast_sip_session *session, int s ast_party_id_copy(&ast_channel_caller(chan)->id, &session->id); ast_party_id_copy(&ast_channel_caller(chan)->ani, &session->id); - ast_channel_context_set(chan, session->endpoint->context); - ast_channel_exten_set(chan, S_OR(exten, "s")); ast_channel_priority_set(chan, 1); ast_channel_callgroup_set(chan, session->endpoint->pickup.callgroup); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5be0200ed..ff0067dcd 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9240,6 +9240,15 @@ static struct sip_pvt *__find_call(struct sip_request *req, struct ast_sockaddr switch (found) { case SIP_REQ_MATCH: + sip_pvt_lock(sip_pvt_ptr); + if (args.method != SIP_RESPONSE && args.authentication_present + && strcmp(args.fromtag, sip_pvt_ptr->theirtag)) { + /* If we have a request that uses athentication and the fromtag is + * different from that in the original call dialog, update the + * fromtag in the saved call dialog */ + ast_string_field_set(sip_pvt_ptr, theirtag, args.fromtag); + } + sip_pvt_unlock(sip_pvt_ptr); ao2_iterator_destroy(iterator); dialog_unref(fork_pvt, "unref fork_pvt"); free_via(via); |