remote.h
Go to the documentation of this file.
/*
*
*
* Inter Asterisk Exchange 2
*
* A class to describe the node we are talking to.
*
* Open Phone Abstraction Library (OPAL)
*
* Copyright (c) 2005 Indranet Technologies Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Indranet Technologies Ltd.
*
* The author of this code is Derek J Smithies
*
* $Revision: 24606 $
* $Author: dereksmithies $
* $Date: 2010-07-28 22:51:05 -0500 (Wed, 28 Jul 2010) $
*/
#ifndef OPAL_IAX2_REMOTE_H
#define OPAL_IAX2_REMOTE_H
#ifndef _PTLIB_H
#include <ptlib.h>
#endif
#include <opal/buildopts.h>
#if OPAL_IAX2
#include <ptlib/sockets.h>
#if OPAL_PTLIB_SSL_AES
#include <openssl/aes.h>
#endif
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class IAX2FullFrame;
class IAX2Remote : public PObject
{
PCLASSINFO(IAX2Remote, PObject);
public:
IAX2Remote();
virtual ~IAX2Remote() { };
PINDEX DestCallNumber() { return destCallNumber; }
PINDEX SourceCallNumber() { return sourceCallNumber; }
virtual void PrintOn(ostream & strm) const;
enum {
callNumberUndefined = 0xffff
};
PIPSocket::Address RemoteAddress() { return remoteAddress; }
PString BuildConnectionToken();
PString BuildOurConnectionToken();
PINDEX RemotePort() { return remotePort; }
void Assign(IAX2Remote &);
void SetRemoteAddress(PIPSocket::Address &newVal) { remoteAddress = newVal; }
void SetRemoteAddress(int newVal) { remoteAddress = newVal; }
void SetRemotePort (PINDEX newVal) { remotePort = newVal; }
void SetSourceCallNumber(PINDEX newVal) { sourceCallNumber = newVal; }
void SetDestCallNumber(PINDEX newVal);
PBoolean operator == (IAX2Remote & other);
PBoolean operator *= (IAX2Remote & other);
PBoolean operator != (IAX2Remote & other);
protected:
PINDEX sourceCallNumber;
PINDEX destCallNumber;
PIPSocket::Address remoteAddress;
PINDEX remotePort;
};
class IAX2FrameIdValue : public PObject
{
PCLASSINFO(IAX2FrameIdValue, PObject);
public:
IAX2FrameIdValue (PINDEX timeStamp, PINDEX seqVal);
IAX2FrameIdValue (PINDEX val);
PINDEX GetTimeStamp() const;
PINDEX GetSequenceVal() const;
PINDEX GetPlainSequence() const;
virtual void PrintOn(ostream & strm) const;
virtual Comparison Compare(const PObject & obj) const;
protected:
PUInt64 value;
};
PDECLARE_SORTED_LIST(IAX2PacketIdList, IAX2FrameIdValue)
#ifdef DOC_PLUS_PLUS
class IAX2PacketIdList : public PSortedList
{
#endif
PBoolean Contains(IAX2FrameIdValue &src);
PINDEX GetFirstValue();
void AppendNewFrame(IAX2FullFrame &src);
virtual void PrintOn(ostream & strm) const;
protected:
void RemoveOldContiguousValues();
};
class IAX2SequenceNumbers
{
public:
enum IncomingOrder {
InSequence,
SkippedFrame,
RepeatedFrame
};
IAX2SequenceNumbers()
{ ZeroAllValues(); };
virtual ~IAX2SequenceNumbers() { }
void ZeroAllValues();
PINDEX InSeqNo();
PINDEX OutSeqNo();
PBoolean IsFirstReplyFrame();
PBoolean IsSequenceNosZero();
void SetInSeqNo(PINDEX newVal);
void SetOutSeqNo(PINDEX newVal);
void SetInOutSeqNo(PINDEX inVal, PINDEX outVal);
void SetAckSequenceInfo(IAX2SequenceNumbers & other);
PBoolean operator !=(IAX2SequenceNumbers &other);
PBoolean operator ==(IAX2SequenceNumbers &other);
void MassageSequenceForSending(IAX2FullFrame &src /*<!src will be transmitted to the remote node */
);
void WrapAroundFrameSequence(IAX2SequenceNumbers & src);
IncomingOrder IncomingMessageInOrder
(IAX2FullFrame &src /*<!frame to be compared with current data base.*/ );
void CopyContents(IAX2SequenceNumbers &src);
PString AsString() const;
virtual void PrintOn(ostream & strm) const;
PBoolean IsFirstReply() { return (inSeqNo == 1) && (outSeqNo == 0); }
void AddWrapAroundValue(PINDEX newOffset);
protected:
enum sequenceDefines {
minSpacing = 3
};
PINDEX inSeqNo;
PINDEX outSeqNo;
PMutex mutex;
PINDEX lastSentTimeStamp;
IAX2PacketIdList receivedLog;
};
class IAX2Encryption : public PObject
{
PCLASSINFO(IAX2Encryption, PObject);
public:
IAX2Encryption();
void SetEncryptionOn (PBoolean newState = true);
void SetEncryptionKey(PString & newKey);
void SetChallengeKey(PString & newKey);
const PString & EncryptionKey() const;
const PString & ChallengeKey() const;
PBoolean IsEncrypted() const;
#if OPAL_PTLIB_SSL_AES
AES_KEY *AesEncryptKey();
AES_KEY *AesDecryptKey();
#endif
protected:
void CalculateAesKeys();
PString encryptionKey;
PString challengeKey;
PBoolean encryptionEnabled;
#if OPAL_PTLIB_SSL_AES
AES_KEY aesEncryptKey;
AES_KEY aesDecryptKey;
#endif
};
#endif // OPAL_IAX2
#endif // OPAL_IAX2_REMOTE_H
/* The comment below is magic for those who use emacs to edit this file.
* With the comment below, the tab key does auto indent to 2 spaces.
*
* Local Variables:
* mode:c
* c-basic-offset:2
* End:
*/
IAX2Remote::SetDestCallNumber
void SetDestCallNumber(PINDEX newVal)
IAX2SequenceNumbers::CopyContents
void CopyContents(IAX2SequenceNumbers &src)
IAX2FrameIdValue::IAX2FrameIdValue
IAX2FrameIdValue(PINDEX timeStamp, PINDEX seqVal)
IAX2FrameIdValue::GetSequenceVal
PINDEX GetSequenceVal() const
IAX2SequenceNumbers
Definition: remote.h:230
IAX2SequenceNumbers::IsSequenceNosZero
PBoolean IsSequenceNosZero()
IAX2Encryption::encryptionEnabled
PBoolean encryptionEnabled
Definition: remote.h:390
IAX2Encryption::IsEncrypted
PBoolean IsEncrypted() const
IAX2Remote::SetRemotePort
void SetRemotePort(PINDEX newVal)
Definition: remote.h:111
IAX2Remote::operator!=
PBoolean operator!=(IAX2Remote &other)
IAX2Encryption::IAX2Encryption
IAX2Encryption()
IAX2Remote::BuildOurConnectionToken
PString BuildOurConnectionToken()
IAX2SequenceNumbers::RepeatedFrame
we have already seen this frame...
Definition: remote.h:239
IAX2SequenceNumbers::PrintOn
virtual void PrintOn(ostream &strm) const
IAX2SequenceNumbers::ZeroAllValues
void ZeroAllValues()
IAX2SequenceNumbers::minSpacing
Definition: remote.h:324
IAX2SequenceNumbers::SetInOutSeqNo
void SetInOutSeqNo(PINDEX inVal, PINDEX outVal)
IAX2Remote
Definition: remote.h:59
buildopts.h
IAX2Encryption::EncryptionKey
const PString & EncryptionKey() const
IAX2Remote::BuildConnectionToken
PString BuildConnectionToken()
IAX2SequenceNumbers::IncomingOrder
IncomingOrder
Definition: remote.h:236
IAX2Remote::remoteAddress
PIPSocket::Address remoteAddress
Definition: remote.h:141
IAX2SequenceNumbers::mutex
PMutex mutex
Definition: remote.h:334
IAX2Remote::SetSourceCallNumber
void SetSourceCallNumber(PINDEX newVal)
Definition: remote.h:114
IAX2Remote::operator==
PBoolean operator==(IAX2Remote &other)
IAX2Encryption::challengeKey
PString challengeKey
Definition: remote.h:387
IAX2Remote::RemotePort
PINDEX RemotePort()
Definition: remote.h:99
IAX2SequenceNumbers::SetAckSequenceInfo
void SetAckSequenceInfo(IAX2SequenceNumbers &other)
IAX2Remote::DestCallNumber
PINDEX DestCallNumber()
Definition: remote.h:72
IAX2PacketIdList::RemoveOldContiguousValues
void RemoveOldContiguousValues()
IAX2FullFrame
Definition: frame.h:369
IAX2Remote::SetRemoteAddress
void SetRemoteAddress(PIPSocket::Address &newVal)
Definition: remote.h:105
IAX2Remote::Assign
void Assign(IAX2Remote &)
IAX2SequenceNumbers::OutSeqNo
PINDEX OutSeqNo()
IAX2Encryption::CalculateAesKeys
void CalculateAesKeys()
IAX2SequenceNumbers::lastSentTimeStamp
PINDEX lastSentTimeStamp
Definition: remote.h:337
IAX2Remote::destCallNumber
PINDEX destCallNumber
Definition: remote.h:138
IAX2SequenceNumbers::AsString
PString AsString() const
IAX2SequenceNumbers::IAX2SequenceNumbers
IAX2SequenceNumbers()
Definition: remote.h:245
IAX2SequenceNumbers::SetOutSeqNo
void SetOutSeqNo(PINDEX newVal)
IAX2FrameIdValue
Definition: remote.h:158
IAX2SequenceNumbers::InSeqNo
PINDEX InSeqNo()
IAX2SequenceNumbers::SkippedFrame
there is a missing frame, a VNAK condition
Definition: remote.h:238
IAX2SequenceNumbers::receivedLog
IAX2PacketIdList receivedLog
Definition: remote.h:340
IAX2Remote::PrintOn
virtual void PrintOn(ostream &strm) const
IAX2SequenceNumbers::IsFirstReply
PBoolean IsFirstReply()
Definition: remote.h:314
IAX2Encryption::ChallengeKey
const PString & ChallengeKey() const
IAX2Remote::sourceCallNumber
PINDEX sourceCallNumber
Definition: remote.h:135
IAX2SequenceNumbers::outSeqNo
PINDEX outSeqNo
Definition: remote.h:331
IAX2Remote::remotePort
PINDEX remotePort
Definition: remote.h:144
IAX2Encryption
Definition: remote.h:345
IAX2Remote::RemoteAddress
PIPSocket::Address RemoteAddress()
Definition: remote.h:88
IAX2Remote::SourceCallNumber
PINDEX SourceCallNumber()
Definition: remote.h:77
IAX2FrameIdValue::Compare
virtual Comparison Compare(const PObject &obj) const
IAX2Remote::operator*=
PBoolean operator*=(IAX2Remote &other)
IAX2SequenceNumbers::sequenceDefines
sequenceDefines
Definition: remote.h:323
IAX2Remote::callNumberUndefined
Definition: remote.h:84
IAX2FrameIdValue::value
PUInt64 value
Definition: remote.h:190
IAX2Remote::SetRemoteAddress
void SetRemoteAddress(int newVal)
Definition: remote.h:108
IAX2SequenceNumbers::AddWrapAroundValue
void AddWrapAroundValue(PINDEX newOffset)
IAX2Remote::IAX2Remote
IAX2Remote()
IAX2SequenceNumbers::operator!=
PBoolean operator!=(IAX2SequenceNumbers &other)
IAX2Encryption::SetEncryptionOn
void SetEncryptionOn(PBoolean newState=true)
IAX2SequenceNumbers::operator==
PBoolean operator==(IAX2SequenceNumbers &other)
IAX2Encryption::SetChallengeKey
void SetChallengeKey(PString &newKey)
IAX2SequenceNumbers::IsFirstReplyFrame
PBoolean IsFirstReplyFrame()
IAX2SequenceNumbers::~IAX2SequenceNumbers
virtual ~IAX2SequenceNumbers()
Definition: remote.h:249
IAX2SequenceNumbers::SetInSeqNo
void SetInSeqNo(PINDEX newVal)
IAX2Remote::~IAX2Remote
virtual ~IAX2Remote()
Definition: remote.h:68
IAX2SequenceNumbers::InSequence
perfect sequence number
Definition: remote.h:237
IAX2SequenceNumbers::WrapAroundFrameSequence
void WrapAroundFrameSequence(IAX2SequenceNumbers &src)
IAX2SequenceNumbers::MassageSequenceForSending
void MassageSequenceForSending(IAX2FullFrame &src)
IAX2Encryption::SetEncryptionKey
void SetEncryptionKey(PString &newKey)
IAX2FrameIdValue::GetPlainSequence
PINDEX GetPlainSequence() const
IAX2SequenceNumbers::inSeqNo
PINDEX inSeqNo
Definition: remote.h:328
IAX2Encryption::encryptionKey
PString encryptionKey
Definition: remote.h:384
IAX2PacketIdList
Definition: remote.h:201
IAX2FrameIdValue::GetTimeStamp
PINDEX GetTimeStamp() const
IAX2SequenceNumbers::IncomingMessageInOrder
IncomingOrder IncomingMessageInOrder(IAX2FullFrame &src)
IAX2FrameIdValue::PrintOn
virtual void PrintOn(ostream &strm) const