[asterisk-commits] bbryant: branch bbryant/keyrotation r135074 - in /team/bbryant/keyrotation: c...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Aug 1 10:04:56 CDT 2008
Author: bbryant
Date: Fri Aug 1 10:04:56 2008
New Revision: 135074
URL: http://svn.digium.com/view/asterisk?view=rev&rev=135074
Log:
Add option to disable key rotation from the iax configuration.
Modified:
team/bbryant/keyrotation/channels/chan_iax2.c
team/bbryant/keyrotation/channels/iax2-parser.c
team/bbryant/keyrotation/configs/iax.conf.sample
Modified: team/bbryant/keyrotation/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/keyrotation/channels/chan_iax2.c?view=diff&rev=135074&r1=135073&r2=135074
==============================================================================
--- team/bbryant/keyrotation/channels/chan_iax2.c (original)
+++ team/bbryant/keyrotation/channels/chan_iax2.c Fri Aug 1 10:04:56 2008
@@ -294,6 +294,7 @@
response, so that we've achieved a three-way handshake with
them before sending voice or anything else*/
IAX_ALLOWFWDOWNLOAD = (1 << 26), /*!< Allow the FWDOWNL command? */
+ IAX_NOKEYROTATE = (1 << 27), /*!< Disable key rotation with encryption */
};
static int global_rtautoclear = 120;
@@ -1790,7 +1791,7 @@
iaxs[x]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
iaxs[x]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
iaxs[x]->amaflags = amaflags;
- ast_copy_flags(iaxs[x], (&globalflags), IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+ iaxs[x]->flags |= globalflags.flags & (IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE);
ast_string_field_set(iaxs[x], accountcode, accountcode);
ast_string_field_set(iaxs[x], mohinterpret, mohinterpret);
@@ -3406,7 +3407,7 @@
if (peer->maxms && ((peer->lastms > peer->maxms) || (peer->lastms < 0)))
goto return_unref;
- ast_copy_flags(cai, peer, IAX_SENDANI | IAX_TRUNK | IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+ ast_copy_flags(cai, peer, IAX_SENDANI | IAX_TRUNK | IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE);
cai->maxtime = peer->maxms;
cai->capability = peer->capability;
cai->encmethods = peer->encmethods;
@@ -3843,7 +3844,6 @@
pvt->keyrotateid =
ast_sched_add(sched, 120000 + (ast_random() % 180001), iax2_key_rotate, vpvt);
-
snprintf(key, sizeof(key), "%lX", ast_random());
@@ -4794,8 +4794,13 @@
);
#endif
- if (f->frametype == AST_FRAME_VOICE && IAX_CALLENCRYPTED(pvt) && pvt->keyrotateid == -1)
- iax2_key_rotate(pvt);
+ if (pvt->keyrotateid == -1 && f->frametype == AST_FRAME_VOICE && IAX_CALLENCRYPTED(pvt)) {
+ if (ast_test_flag(pvt, IAX_NOKEYROTATE)) {
+ pvt->keyrotateid = -2;
+ } else {
+ iax2_key_rotate(pvt);
+ }
+ }
if ((ast_test_flag(pvt, IAX_TRUNK) ||
(((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L)) ||
@@ -5970,6 +5975,7 @@
ast_copy_flags(iaxs[callno], user, IAX_CODEC_USER_FIRST);
ast_copy_flags(iaxs[callno], user, IAX_CODEC_NOPREFS);
ast_copy_flags(iaxs[callno], user, IAX_CODEC_NOCAP);
+ ast_copy_flags(iaxs[callno], user, IAX_NOKEYROTATE);
iaxs[callno]->encmethods = user->encmethods;
/* Store the requested username if not specified */
if (ast_strlen_zero(iaxs[callno]->username))
@@ -10080,7 +10086,7 @@
memset(&cai, 0, sizeof(cai));
cai.capability = iax2_capability;
- ast_copy_flags(&cai, &globalflags, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+ ast_copy_flags(&cai, &globalflags, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE);
/* Populate our address from the given */
if (create_addr(pds.peer, NULL, &sin, &cai)) {
@@ -10099,7 +10105,7 @@
}
/* If this is a trunk, update it now */
- ast_copy_flags(iaxs[callno], &cai, IAX_TRUNK | IAX_SENDANI | IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+ ast_copy_flags(iaxs[callno], &cai, IAX_TRUNK | IAX_SENDANI | IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE);
if (ast_test_flag(&cai, IAX_TRUNK)) {
int new_callno;
if ((new_callno = make_trunk(callno, 1)) != -1)
@@ -10440,6 +10446,9 @@
if (peer) {
if (firstpass) {
+ if (ast_test_flag(&globalflags, IAX_NOKEYROTATE)) {
+ ast_copy_flags(peer, &globalflags, IAX_NOKEYROTATE);
+ }
ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
peer->encmethods = iax2_encryption;
peer->adsi = adsi;
@@ -10490,6 +10499,11 @@
peer->authmethods = get_auth_methods(v->value);
} else if (!strcasecmp(v->name, "encryption")) {
peer->encmethods = get_encrypt_methods(v->value);
+ } else if (!strcasecmp(v->name, "keyrotate")) {
+ if (ast_false(v->value))
+ ast_set_flag(peer, IAX_NOKEYROTATE);
+ else
+ ast_clear_flag(peer, IAX_NOKEYROTATE);
} else if (!strcasecmp(v->name, "transfer")) {
if (!strcasecmp(v->value, "mediaonly")) {
ast_set_flags_to(peer, IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);
@@ -10712,7 +10726,7 @@
user->adsi = adsi;
ast_string_field_set(user, name, name);
ast_string_field_set(user, language, language);
- ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP);
+ ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP | IAX_NOKEYROTATE);
ast_clear_flag(user, IAX_HASCALLERID);
ast_string_field_set(user, cid_name, "");
ast_string_field_set(user, cid_num, "");
@@ -10758,6 +10772,11 @@
user->authmethods = get_auth_methods(v->value);
} else if (!strcasecmp(v->name, "encryption")) {
user->encmethods = get_encrypt_methods(v->value);
+ } else if (!strcasecmp(v->name, "keyrotate")) {
+ if (ast_false(v->value))
+ ast_set_flag(user, IAX_NOKEYROTATE);
+ else
+ ast_clear_flag(user, IAX_NOKEYROTATE);
} else if (!strcasecmp(v->name, "transfer")) {
if (!strcasecmp(v->value, "mediaonly")) {
ast_set_flags_to(user, IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);
@@ -11119,7 +11138,12 @@
authdebug = ast_true(v->value);
else if (!strcasecmp(v->name, "encryption"))
iax2_encryption = get_encrypt_methods(v->value);
- else if (!strcasecmp(v->name, "transfer")) {
+ else if (!strcasecmp(v->name, "keyrotate")) {
+ if (ast_false(v->value))
+ ast_set_flag((&globalflags), IAX_NOKEYROTATE);
+ else
+ ast_clear_flag((&globalflags), IAX_NOKEYROTATE);
+ } else if (!strcasecmp(v->name, "transfer")) {
if (!strcasecmp(v->value, "mediaonly")) {
ast_set_flags_to((&globalflags), IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);
} else if (ast_true(v->value)) {
Modified: team/bbryant/keyrotation/channels/iax2-parser.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/keyrotation/channels/iax2-parser.c?view=diff&rev=135074&r1=135073&r2=135074
==============================================================================
--- team/bbryant/keyrotation/channels/iax2-parser.c (original)
+++ team/bbryant/keyrotation/channels/iax2-parser.c Fri Aug 1 10:04:56 2008
@@ -85,6 +85,16 @@
snprintf(output, maxlen, "IPV4 %s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
ast_copy_string(output, "Invalid Address", maxlen);
+ }
+}
+
+static void dump_string_hex(char *output, int maxlen, void *value, int len)
+{
+ int i = 0;
+
+ while (len-- && (i + 1) * 4 < maxlen) {
+ sprintf(output + (4 * i), "\\x%2.2x", *((unsigned char *)value + i));
+ i++;
}
}
@@ -229,7 +239,7 @@
{ IAX_IE_ADSICPE, "ADSICPE", dump_short },
{ IAX_IE_DNID, "DNID", dump_string },
{ IAX_IE_AUTHMETHODS, "AUTHMETHODS", dump_short },
- { IAX_IE_CHALLENGE, "CHALLENGE", dump_string },
+ { IAX_IE_CHALLENGE, "CHALLENGE", dump_string_hex },
{ IAX_IE_MD5_RESULT, "MD5 RESULT", dump_string },
{ IAX_IE_RSA_RESULT, "RSA RESULT", dump_string },
{ IAX_IE_APPARENT_ADDR, "APPARENT ADDRESS", dump_addr },
Modified: team/bbryant/keyrotation/configs/iax.conf.sample
URL: http://svn.digium.com/view/asterisk/team/bbryant/keyrotation/configs/iax.conf.sample?view=diff&rev=135074&r1=135073&r2=135074
==============================================================================
--- team/bbryant/keyrotation/configs/iax.conf.sample (original)
+++ team/bbryant/keyrotation/configs/iax.conf.sample Fri Aug 1 10:04:56 2008
@@ -172,6 +172,11 @@
;
; trunkmtu = 0
;
+; This is a compatibility option for older versions of IAX2 that don't have
+; keyrotation, this option will disable the IAX_COMMAND_RTENC message.
+; default is on
+;
+; keyrotate=off
; This option defines the maximum size an IAX2 trunk can grow to. The default value is 128000 bytes which
; represents 40ms uncompressed linear with 200 channels. Depending on different things though
@@ -372,6 +377,9 @@
; cause the given audio file to
; be played upon completion of
; an attended transfer.
+; keyrotate=off ; This is a compatibility option for older versions of
+; ; IAX2 that don't have keyrotation. This option will
+; ; disable the IAX_COMMAND_RTENC message. default is on.
;dbsecret=mysecrets/place ; Secrets can be stored in astdb, too
;transfer=no ; Disable IAX native transfer
;transfer=mediaonly ; When doing IAX native transfers, transfer
@@ -385,6 +393,9 @@
;accountcode=markster0101
;permit=209.16.236.73/255.255.255.0
;language=en ; Use english as default language
+;keyrotate=off ; This is a compatibility option for older versions of
+; ; IAX2 that don't have keyrotation. This option will
+; ; disable the IAX_COMMAND_RTENC message. default is on.
;
; Peers may also be specified, with a secret and
; a remote hostname.
@@ -407,7 +418,13 @@
;qualifyfreqnotok = 10000 ; how frequently to ping the peer when it's
; either LAGGED or UNAVAILABLE, in milliseconds
;jitterbuffer=no ; Turn off jitter buffer for this peer
-
+; This is a compatibility option for older versions of IAX2 that don't have
+; keyrotation, this option will disable the IAX_COMMAND_RTENC message.
+; default is on
+;
+;keyrotate=off ; This is a compatibility option for older versions of
+; ; IAX2 that don't have keyrotation. This option will
+; ; disable the IAX_COMMAND_RTENC message. default is on.
;
; Peers can remotely register as well, so that they can be mobile. Default
; IP's can also optionally be given but are not required. Caller*ID can be
More information about the asterisk-commits
mailing list