2003-03-16 22:37:31 +00:00
|
|
|
/*
|
|
|
|
|
* Asterisk -- A telephony toolkit for Linux.
|
|
|
|
|
*
|
|
|
|
|
* Implementation of Inter-Asterisk eXchange
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003, Digium
|
|
|
|
|
*
|
2004-10-02 01:56:08 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
2003-03-16 22:37:31 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
|
* the GNU General Public License
|
|
|
|
|
*/
|
2005-10-26 13:03:17 +00:00
|
|
|
|
|
|
|
|
/*!\file
|
|
|
|
|
* \brief Implementation of the IAX2 protocol
|
|
|
|
|
*/
|
2003-03-16 22:37:31 +00:00
|
|
|
|
|
|
|
|
#ifndef _IAX2_PARSER_H
|
|
|
|
|
#define _IAX2_PARSER_H
|
|
|
|
|
|
2006-08-29 20:50:36 +00:00
|
|
|
#include "asterisk/linkedlists.h"
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
#include "asterisk/aes.h"
|
2006-08-29 20:50:36 +00:00
|
|
|
|
2003-03-16 22:37:31 +00:00
|
|
|
struct iax_ies {
|
|
|
|
|
char *called_number;
|
|
|
|
|
char *calling_number;
|
|
|
|
|
char *calling_ani;
|
|
|
|
|
char *calling_name;
|
2004-10-02 01:56:08 +00:00
|
|
|
int calling_ton;
|
|
|
|
|
int calling_tns;
|
|
|
|
|
int calling_pres;
|
2003-03-16 22:37:31 +00:00
|
|
|
char *called_context;
|
|
|
|
|
char *username;
|
|
|
|
|
char *password;
|
|
|
|
|
unsigned int capability;
|
|
|
|
|
unsigned int format;
|
2005-01-09 10:32:53 +00:00
|
|
|
char *codec_prefs;
|
2003-03-16 22:37:31 +00:00
|
|
|
char *language;
|
|
|
|
|
int version;
|
|
|
|
|
unsigned short adsicpe;
|
|
|
|
|
char *dnid;
|
2003-05-14 05:33:06 +00:00
|
|
|
char *rdnis;
|
2003-03-16 22:37:31 +00:00
|
|
|
unsigned int authmethods;
|
2004-12-29 23:02:21 +00:00
|
|
|
unsigned int encmethods;
|
2003-03-16 22:37:31 +00:00
|
|
|
char *challenge;
|
|
|
|
|
char *md5_result;
|
|
|
|
|
char *rsa_result;
|
|
|
|
|
struct sockaddr_in *apparent_addr;
|
|
|
|
|
unsigned short refresh;
|
|
|
|
|
unsigned short dpstatus;
|
|
|
|
|
unsigned short callno;
|
|
|
|
|
char *cause;
|
2004-12-26 22:33:25 +00:00
|
|
|
unsigned char causecode;
|
2003-03-16 22:37:31 +00:00
|
|
|
unsigned char iax_unknown;
|
|
|
|
|
int msgcount;
|
|
|
|
|
int autoanswer;
|
|
|
|
|
int musiconhold;
|
2003-03-20 05:56:00 +00:00
|
|
|
unsigned int transferid;
|
2003-10-01 22:59:06 +00:00
|
|
|
unsigned int datetime;
|
2004-02-24 21:27:16 +00:00
|
|
|
char *devicetype;
|
|
|
|
|
char *serviceident;
|
|
|
|
|
int firmwarever;
|
|
|
|
|
unsigned int fwdesc;
|
|
|
|
|
unsigned char *fwdata;
|
|
|
|
|
unsigned char fwdatalen;
|
2004-12-29 23:02:21 +00:00
|
|
|
unsigned char *enckey;
|
|
|
|
|
unsigned char enckeylen;
|
2004-05-25 04:34:43 +00:00
|
|
|
unsigned int provver;
|
2004-11-19 21:52:25 +00:00
|
|
|
unsigned short samprate;
|
2004-07-07 09:34:01 +00:00
|
|
|
int provverpres;
|
2005-02-12 18:52:14 +00:00
|
|
|
unsigned int rr_jitter;
|
|
|
|
|
unsigned int rr_loss;
|
|
|
|
|
unsigned int rr_pkts;
|
|
|
|
|
unsigned short rr_delay;
|
|
|
|
|
unsigned int rr_dropped;
|
|
|
|
|
unsigned int rr_ooo;
|
2007-01-16 08:38:59 +00:00
|
|
|
struct ast_variable *vars;
|
2007-04-20 21:12:53 +00:00
|
|
|
char *osptokenblock[IAX_MAX_OSPBLOCK_NUM];
|
|
|
|
|
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM];
|
2003-03-16 22:37:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define DIRECTION_INGRESS 1
|
|
|
|
|
#define DIRECTION_OUTGRESS 2
|
|
|
|
|
|
2003-04-19 18:12:41 +00:00
|
|
|
struct iax_frame {
|
|
|
|
|
#ifdef LIBIAX
|
|
|
|
|
struct iax_session *session;
|
|
|
|
|
struct iax_event *event;
|
2005-01-11 17:08:52 +00:00
|
|
|
#else
|
|
|
|
|
int sockfd;
|
2003-04-19 18:12:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! /Our/ call number */
|
2003-03-16 22:37:31 +00:00
|
|
|
unsigned short callno;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! /Their/ call number */
|
2003-03-16 22:37:31 +00:00
|
|
|
unsigned short dcallno;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Start of raw frame (outgoing only) */
|
2003-03-16 22:37:31 +00:00
|
|
|
void *data;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Length of frame (outgoing only) */
|
2003-03-16 22:37:31 +00:00
|
|
|
int datalen;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! How many retries so far? */
|
2003-03-16 22:37:31 +00:00
|
|
|
int retries;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Outgoing relative timestamp (ms) */
|
2003-03-16 22:37:31 +00:00
|
|
|
unsigned int ts;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! How long to wait before retrying */
|
2003-03-16 22:37:31 +00:00
|
|
|
int retrytime;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Are we received out of order? */
|
2007-01-04 18:32:23 +00:00
|
|
|
unsigned int outoforder:1;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Have we been sent at all yet? */
|
2007-01-04 18:32:23 +00:00
|
|
|
unsigned int sentyet:1;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Non-zero if should be sent to transfer peer */
|
2007-01-04 18:32:23 +00:00
|
|
|
unsigned int transfer:1;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Non-zero if this is the final message */
|
2007-01-04 18:32:23 +00:00
|
|
|
unsigned int final:1;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Ingress or outgres */
|
2007-01-04 18:32:23 +00:00
|
|
|
unsigned int direction:2;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Can this frame be cached? */
|
2007-01-04 18:32:23 +00:00
|
|
|
unsigned int cacheable:1;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Outgoing Packet sequence number */
|
2003-03-16 22:37:31 +00:00
|
|
|
int oseqno;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Next expected incoming packet sequence number */
|
2003-03-16 22:37:31 +00:00
|
|
|
int iseqno;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Retransmission ID */
|
2003-03-16 22:37:31 +00:00
|
|
|
int retrans;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! is this packet encrypted or not. if set this varible holds encryption methods*/
|
|
|
|
|
int encmethods;
|
|
|
|
|
/*! store encrypt key */
|
|
|
|
|
ast_aes_encrypt_key ecx;
|
|
|
|
|
/*! store decrypt key which corresponds to ecx */
|
|
|
|
|
ast_aes_decrypt_key mydcx;
|
|
|
|
|
/*! random data for encryption pad */
|
|
|
|
|
unsigned char semirand[32];
|
|
|
|
|
/*! Easy linking */
|
2006-08-29 20:50:36 +00:00
|
|
|
AST_LIST_ENTRY(iax_frame) list;
|
Merged revisions 181371 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r181371 | dvossel | 2009-03-11 12:34:57 -0500 (Wed, 11 Mar 2009) | 17 lines
Merged revisions 181340 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r181340 | dvossel | 2009-03-11 12:25:31 -0500 (Wed, 11 Mar 2009) | 11 lines
encrypted IAX2 during packet loss causes decryption to fail on retransmitted frames
If an iax channel is encrypted, and a retransmit frame is sent, that packet's iseqno is updated while it is encrypted. This causes the entire frame to be corrupted. When the corrupted frame is sent, the other side decrypts it and sends a VNAK back because the decrypted frame doesn't make any sense. When we get the VNAK, we look through the sent queue and send the same corrupted frame causing a loop. To fix this, encrypted frames requiring retransmission are decrypted, updated, then re-encrypted. Since key-rotation may change the key held by the pvt struct, the keys used for encryption/decryption are held within the iax_frame to guarantee they remain correct.
(closes issue #14607)
Reported by: stevenla
Tested by: dvossel
Review: http://reviewboard.digium.com/r/192/
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@181372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11 17:37:25 +00:00
|
|
|
/*! Actual, isolated frame header */
|
2003-03-16 22:37:31 +00:00
|
|
|
struct ast_frame af;
|
2006-08-29 20:50:36 +00:00
|
|
|
/*! Amount of space _allocated_ for data */
|
2007-07-17 20:49:09 +00:00
|
|
|
size_t afdatalen;
|
2003-03-16 22:37:31 +00:00
|
|
|
unsigned char unused[AST_FRIENDLY_OFFSET];
|
|
|
|
|
unsigned char afdata[0]; /* Data for frame */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct iax_ie_data {
|
|
|
|
|
unsigned char buf[1024];
|
|
|
|
|
int pos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Choose a different function for output */
|
2006-02-01 23:05:28 +00:00
|
|
|
void iax_set_output(void (*output)(const char *data));
|
2003-03-16 22:37:31 +00:00
|
|
|
/* Choose a different function for errors */
|
2006-02-01 23:05:28 +00:00
|
|
|
void iax_set_error(void (*output)(const char *data));
|
|
|
|
|
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
|
2009-05-15 21:08:26 +00:00
|
|
|
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len);
|
2003-03-16 22:37:31 +00:00
|
|
|
|
2006-02-01 23:05:28 +00:00
|
|
|
const char *iax_ie2str(int ie);
|
2003-03-16 22:37:31 +00:00
|
|
|
|
2006-02-01 23:05:28 +00:00
|
|
|
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
|
|
|
|
|
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
|
|
|
|
|
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
|
|
|
|
|
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
|
|
|
|
|
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
|
|
|
|
|
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
|
|
|
|
|
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
|
|
|
|
|
int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
|
2003-03-16 22:37:31 +00:00
|
|
|
|
2006-02-01 23:05:28 +00:00
|
|
|
int iax_get_frames(void);
|
|
|
|
|
int iax_get_iframes(void);
|
|
|
|
|
int iax_get_oframes(void);
|
2003-04-19 18:12:41 +00:00
|
|
|
|
2006-02-01 23:05:28 +00:00
|
|
|
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
|
2007-01-04 18:32:23 +00:00
|
|
|
struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheable);
|
2006-02-01 23:05:28 +00:00
|
|
|
void iax_frame_free(struct iax_frame *fr);
|
2003-03-16 22:37:31 +00:00
|
|
|
#endif
|