aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-17 22:34:08 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-17 22:34:08 +0000
commitc3b984a3201863f7c6596022dce128b803187cf8 (patch)
tree1d324e144695d0c93637324ba6f5639f46decaaf /channels
parent243a5c2a23cc73345a4f18bebf80760a4f8b4163 (diff)
Fix codec priority stuff during authentication (issue #6194 reported by jkoopmann)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@27973 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index a1ce6907b..a124fb00b 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -464,7 +464,10 @@ struct chan_iax2_pvt {
int maxtime;
/*! Peer Address */
struct sockaddr_in addr;
+ /*! Actual used codec preferences */
struct ast_codec_pref prefs;
+ /*! Requested codec preferences */
+ struct ast_codec_pref rprefs;
/*! Our call number */
unsigned short callno;
/*! Peer callno */
@@ -4755,9 +4758,12 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
if (ies->version)
version = ies->version;
- if(ies->codec_prefs)
+ /* Use provided preferences until told otherwise for actual preferences */
+ if(ies->codec_prefs) {
+ ast_codec_pref_convert(&iaxs[callno]->rprefs, ies->codec_prefs, 32, 0);
ast_codec_pref_convert(&iaxs[callno]->prefs, ies->codec_prefs, 32, 0);
-
+ }
+
if (!gotcapability)
iaxs[callno]->peercapability = iaxs[callno]->peerformat;
if (version > IAX_PROTO_VERSION) {
@@ -6299,7 +6305,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
struct iax_frame *duped_fr;
char host_pref_buf[128];
char caller_pref_buf[128];
- struct ast_codec_pref pref,rpref;
+ struct ast_codec_pref pref;
char *using_prefs = "mine";
dblbuf[0] = 0; /* Keep GCC from whining */
@@ -6826,20 +6832,22 @@ retryowner:
strcpy(host_pref_buf, "disabled");
} else {
using_prefs = "mine";
- if(ies.codec_prefs) {
- ast_codec_pref_convert(&rpref, ies.codec_prefs, 32, 0);
+ /* If the information elements are in here... use them */
+ if (ies.codec_prefs)
+ ast_codec_pref_convert(&iaxs[fr.callno]->rprefs, ies.codec_prefs, 32, 0);
+ if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
/* If we are codec_first_choice we let the caller have the 1st shot at picking the codec.*/
if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
- pref = rpref;
+ pref = iaxs[fr.callno]->rprefs;
using_prefs = "caller";
} else {
pref = iaxs[fr.callno]->prefs;
}
} else
pref = iaxs[fr.callno]->prefs;
-
+
format = ast_codec_choose(&pref, iaxs[fr.callno]->capability & iaxs[fr.callno]->peercapability, 0);
- ast_codec_pref_string(&rpref, caller_pref_buf, sizeof(caller_pref_buf) - 1);
+ ast_codec_pref_string(&iaxs[fr.callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
ast_codec_pref_string(&iaxs[fr.callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
if (!format) {
@@ -6870,12 +6878,12 @@ retryowner:
strcpy(host_pref_buf,"disabled");
} else {
using_prefs = "mine";
- if(ies.codec_prefs) {
+ if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
/* Do the opposite of what we tried above. */
if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
pref = iaxs[fr.callno]->prefs;
} else {
- pref = rpref;
+ pref = iaxs[fr.callno]->rprefs;
using_prefs = "caller";
}
format = ast_codec_choose(&pref, iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability, 1);
@@ -7231,11 +7239,11 @@ retryowner2:
strcpy(host_pref_buf, "disabled");
} else {
using_prefs = "mine";
- if(ies.codec_prefs) {
- /* If we are codec_first_choice we let the caller have the 1st shot at picking the codec.*/
- ast_codec_pref_convert(&rpref, ies.codec_prefs, 32, 0);
+ if (ies.codec_prefs)
+ ast_codec_pref_convert(&iaxs[fr.callno]->rprefs, ies.codec_prefs, 32, 0);
+ if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
- ast_codec_pref_convert(&pref, ies.codec_prefs, 32, 0);
+ pref = iaxs[fr.callno]->rprefs;
using_prefs = "caller";
} else {
pref = iaxs[fr.callno]->prefs;
@@ -7244,7 +7252,7 @@ retryowner2:
pref = iaxs[fr.callno]->prefs;
format = ast_codec_choose(&pref, iaxs[fr.callno]->capability & iaxs[fr.callno]->peercapability, 0);
- ast_codec_pref_string(&rpref, caller_pref_buf, sizeof(caller_pref_buf) - 1);
+ ast_codec_pref_string(&iaxs[fr.callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
ast_codec_pref_string(&iaxs[fr.callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
if (!format) {
@@ -7278,12 +7286,12 @@ retryowner2:
strcpy(host_pref_buf,"disabled");
} else {
using_prefs = "mine";
- if(ies.codec_prefs) {
+ if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
/* Do the opposite of what we tried above. */
if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
pref = iaxs[fr.callno]->prefs;
} else {
- pref = rpref;
+ pref = iaxs[fr.callno]->rprefs;
using_prefs = "caller";
}
format = ast_codec_choose(&pref, iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability, 1);