processor.h
Go to the documentation of this file.
/*
*
* Inter Asterisk Exchange 2
*
* The core routine which determines the processing of packets for one call.
*
* 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: 24178 $
* $Author: rjongbloed $
* $Date: 2010-04-05 19:10:56 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef OPAL_IAX2_PROCESSOR_H
#define OPAL_IAX2_PROCESSOR_H
#ifndef _PTLIB_H
#include <ptlib.h>
#endif
#include <opal/buildopts.h>
#if OPAL_IAX2
#include <opal/connection.h>
#include <iax2/frame.h>
#include <iax2/iedata.h>
#include <iax2/remote.h>
#include <iax2/safestrings.h>
#include <iax2/sound.h>
class IAX2EndPoint;
class IAX2Connection;
class IAX2ThreadHelper;
class IAX2WaitingForAck : public PObject
{
PCLASSINFO(IAX2WaitingForAck, PObject);
public:
enum ResponseToAck {
RingingAcked = 0,
AcceptAcked = 1,
AuthRepAcked = 2,
AnswerAcked = 3
};
IAX2WaitingForAck();
void Assign(IAX2FullFrame *f, ResponseToAck _response);
PBoolean MatchingAckPacket(IAX2FullFrame *f);
ResponseToAck GetResponse() { return response; }
PString GetResponseAsString() const;
virtual void PrintOn(ostream & strm) const;
void ZeroValues();
private:
DWORD timeStamp;
PINDEX seqNo;
ResponseToAck response;
};
class IAX2Processor : public PThread
{
PCLASSINFO(IAX2Processor, PObject);
public:
IAX2Processor(IAX2EndPoint & ep);
virtual ~IAX2Processor();
IAX2SequenceNumbers & GetSequenceInfo() { return sequence; }
IAX2Encryption & GetEncryptionInfo() { return encryption; }
void IncomingEthernetFrame (IAX2Frame *frame);
virtual void PrintOn(ostream & strm) const = 0;
IAX2EndPoint & GetEndPoint() { return endpoint; };
void SetCallToken(const PString & newToken);
PString GetCallToken();
IAX2Remote & GetRemoteInfo() { return remote; }
const PTimeInterval & GetCallStartTick() { return callStartTick; }
void Main();
PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame);
void SetSpecialPackets(PBoolean newValue) { specialPackets = newValue; }
void Terminate();
void Activate();
virtual PBoolean IncomingMessageOutOfOrder(IAX2FullFrame *ff)= 0;
void ReportLists(PString & answer);
protected:
IAX2EndPoint & endpoint;
PTimeInterval callStartTick;
IAX2Remote remote;
void StartNoResponseTimer(PINDEX msToWait = 60000);
void StopNoResponseTimer() { noResponseTimer.Stop(); }
PTimer noResponseTimer;
void CleanPendingLists() { activate.Signal(); }
IAX2WaitingForAck nextTask;
PSyncPoint activate;
PBoolean endThread;
IAX2Encryption encryption;
IAX2SequenceNumbers sequence;
IAX2ActiveFrameList frameList;
SafeString callToken;
virtual void OnNoResponseTimeout() = 0;
enum DefinedNoResponseTimePeriod {
NoResponseTimePeriod = 5000
};
PBoolean IsHandlingSpecialPackets() { return specialPackets; };
PBoolean specialPackets;
virtual void ProcessLists() = 0;
virtual void ProcessFullFrame(IAX2FullFrame & fullFrame) = 0;
virtual void ProcessIaxCmdLagRq(IAX2FullFrameProtocol *src);
virtual void ProcessIaxCmdLagRp(IAX2FullFrameProtocol *src);
virtual void ProcessIaxCmdVnak(IAX2FullFrameProtocol *src);
virtual void ProcessIaxCmdPing(IAX2FullFrameProtocol *src);
virtual void ProcessIaxCmdPong(IAX2FullFrameProtocol *src);
PBoolean ProcessOneIncomingEthernetFrame();
PAtomicInteger controlFramesSent;
PAtomicInteger controlFramesRcvd;
void IncControlFramesSent() { ++controlFramesSent; }
void IncControlFramesRcvd() { ++controlFramesRcvd; }
virtual void ProcessNetworkFrame(IAX2MiniFrame * src) = 0;
/* A frame of FullFrameProtocol type is labelled as AST_FRAME_IAX in the
asterisk souces, It will contain 0, 1, 2 or more Information Elements
(Ie) in the data section. This processor is used to do things that are
common to registration and call handling.
This method will eat/delete the supplied frame. Return true on success,
false on failure.*/
virtual PBoolean ProcessNetworkFrame(IAX2FullFrameProtocol * src);
void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
void TransmitFrameToRemoteEndpoint(IAX2FullFrame *src,
IAX2WaitingForAck::ResponseToAck response
);
void TransmitFrameNow(IAX2Frame *src);
void TransmitFrameToRemoteEndpoint(IAX2FullFrameProtocol *src);
PBoolean Authenticate(IAX2FullFrameProtocol *reply,
PString & password
);
IAX2IeData ieData;
void SendAckFrame(IAX2FullFrame *inReplyTo);
void SendVnakFrame(IAX2FullFrame *inReplyTo);
void SendUnsupportedFrame(IAX2FullFrame *inReplyTo);
private:
#ifdef DOC_PLUS_PLUS
void OnNoResponseTimeoutStart(PTimer &, INT);
#else
PDECLARE_NOTIFIER(PTimer, IAX2Processor, OnNoResponseTimeoutStart);
#endif
protected:
DWORD currentSoundTimeStamp;
};
#endif // OPAL_IAX2
#endif // OPAL_IAX2_PROCESSOR_H
IAX2Processor::IncomingMessageOutOfOrder
virtual PBoolean IncomingMessageOutOfOrder(IAX2FullFrame *ff)=0
IAX2Processor::ProcessIaxCmdPong
virtual void ProcessIaxCmdPong(IAX2FullFrameProtocol *src)
IAX2SequenceNumbers
Definition: remote.h:230
IAX2Processor::IncomingEthernetFrame
void IncomingEthernetFrame(IAX2Frame *frame)
IAX2Processor::CleanPendingLists
void CleanPendingLists()
Definition: processor.h:240
IAX2WaitingForAck::GetResponse
ResponseToAck GetResponse()
Definition: processor.h:100
IAX2WaitingForAck::Assign
void Assign(IAX2FullFrame *f, ResponseToAck _response)
sound.h
IAX2Processor::GetCallToken
PString GetCallToken()
IAX2Processor::ProcessIaxCmdLagRp
virtual void ProcessIaxCmdLagRp(IAX2FullFrameProtocol *src)
IAX2Processor::callToken
SafeString callToken
Definition: processor.h:263
IAX2Processor::TransmitFrameToRemoteEndpoint
void TransmitFrameToRemoteEndpoint(IAX2Frame *src)
IAX2EndPoint
Definition: iax2ep.h:104
IAX2WaitingForAck::ResponseToAck
ResponseToAck
Definition: processor.h:83
IAX2Remote
Definition: remote.h:59
connection.h
buildopts.h
IAX2Processor::PrintOn
virtual void PrintOn(ostream &strm) const =0
IAX2Processor::~IAX2Processor
virtual ~IAX2Processor()
IAX2Processor::controlFramesSent
PAtomicInteger controlFramesSent
Definition: processor.h:317
IAX2Connection
Definition: iax2con.h:63
IAX2Processor::SendAckFrame
void SendAckFrame(IAX2FullFrame *inReplyTo)
IAX2Processor::StartNoResponseTimer
void StartNoResponseTimer(PINDEX msToWait=60000)
IAX2WaitingForAck::AnswerAcked
Definition: processor.h:87
IAX2FullFrame
Definition: frame.h:369
IAX2Processor::GetEncryptionInfo
IAX2Encryption & GetEncryptionInfo()
Definition: processor.h:151
IAX2Processor::ProcessNetworkFrame
virtual void ProcessNetworkFrame(IAX2MiniFrame *src)=0
IAX2Processor::Authenticate
PBoolean Authenticate(IAX2FullFrameProtocol *reply, PString &password)
SafeString
Definition: safestrings.h:107
IAX2MiniFrame
Definition: frame.h:307
IAX2Processor::sequence
IAX2SequenceNumbers sequence
Definition: processor.h:256
IAX2Processor::OnNoResponseTimeout
virtual void OnNoResponseTimeout()=0
IAX2Processor::DefinedNoResponseTimePeriod
DefinedNoResponseTimePeriod
Definition: processor.h:270
IAX2Processor::ProcessIaxCmdPing
virtual void ProcessIaxCmdPing(IAX2FullFrameProtocol *src)
IAX2Processor::remote
IAX2Remote remote
Definition: processor.h:227
IAX2Processor::controlFramesRcvd
PAtomicInteger controlFramesRcvd
Definition: processor.h:320
IAX2Processor::StopNoResponseTimer
void StopNoResponseTimer()
Definition: processor.h:234
IAX2Processor::SendUnsupportedFrame
void SendUnsupportedFrame(IAX2FullFrame *inReplyTo)
IAX2Processor::currentSoundTimeStamp
DWORD currentSoundTimeStamp
Definition: processor.h:405
IAX2Processor::GetEndPoint
IAX2EndPoint & GetEndPoint()
Definition: processor.h:161
IAX2Processor::Terminate
void Terminate()
IAX2Processor::GetCallStartTick
const PTimeInterval & GetCallStartTick()
Definition: processor.h:181
IAX2IeData
Definition: iedata.h:55
IAX2Processor::ProcessLists
virtual void ProcessLists()=0
IAX2FullFrameProtocol
Definition: frame.h:885
frame.h
IAX2WaitingForAck::RingingAcked
Definition: processor.h:84
IAX2Processor::ProcessIaxCmdVnak
virtual void ProcessIaxCmdVnak(IAX2FullFrameProtocol *src)
IAX2Processor::endpoint
IAX2EndPoint & endpoint
Definition: processor.h:219
IAX2Processor::Activate
void Activate()
IAX2Processor::GetRemoteInfo
IAX2Remote & GetRemoteInfo()
Definition: processor.h:178
iedata.h
IAX2Processor::SetSpecialPackets
void SetSpecialPackets(PBoolean newValue)
Definition: processor.h:194
IAX2Encryption
Definition: remote.h:345
IAX2Processor::specialPackets
PBoolean specialPackets
Definition: processor.h:277
IAX2Processor::callStartTick
PTimeInterval callStartTick
Definition: processor.h:224
IAX2Processor::IncControlFramesRcvd
void IncControlFramesRcvd()
Definition: processor.h:326
IAX2Processor::noResponseTimer
PTimer noResponseTimer
Definition: processor.h:237
IAX2ActiveFrameList
Definition: frame.h:1223
IAX2Processor::IsHandlingSpecialPackets
PBoolean IsHandlingSpecialPackets()
Definition: processor.h:277
IAX2Processor
Definition: processor.h:136
IAX2Processor::ReportLists
void ReportLists(PString &answer)
IAX2Processor::TransmitFrameNow
void TransmitFrameNow(IAX2Frame *src)
IAX2WaitingForAck::IAX2WaitingForAck
IAX2WaitingForAck()
IAX2WaitingForAck::GetResponseAsString
PString GetResponseAsString() const
IAX2Processor::NoResponseTimePeriod
Definition: processor.h:271
IAX2WaitingForAck::AuthRepAcked
Definition: processor.h:86
IAX2Processor::encryption
IAX2Encryption encryption
Definition: processor.h:253
IAX2WaitingForAck::MatchingAckPacket
PBoolean MatchingAckPacket(IAX2FullFrame *f)
IAX2Processor::SetCallToken
void SetCallToken(const PString &newToken)
remote.h
IAX2Processor::Main
void Main()
IAX2Processor::IncControlFramesSent
void IncControlFramesSent()
Definition: processor.h:323
IAX2Processor::GetSequenceInfo
IAX2SequenceNumbers & GetSequenceInfo()
Definition: processor.h:148
IAX2Processor::ProcessFullFrame
virtual void ProcessFullFrame(IAX2FullFrame &fullFrame)=0
IAX2Processor::ProcessOneIncomingEthernetFrame
PBoolean ProcessOneIncomingEthernetFrame()
IAX2Processor::SendVnakFrame
void SendVnakFrame(IAX2FullFrame *inReplyTo)
IAX2Frame
Definition: frame.h:75
IAX2WaitingForAck::PrintOn
virtual void PrintOn(ostream &strm) const
IAX2Processor::ieData
IAX2IeData ieData
Definition: processor.h:370
IAX2Processor::endThread
PBoolean endThread
Definition: processor.h:250
safestrings.h
IAX2Processor::IAX2Processor
IAX2Processor(IAX2EndPoint &ep)
IAX2Processor::nextTask
IAX2WaitingForAck nextTask
Definition: processor.h:244
IAX2WaitingForAck::ZeroValues
void ZeroValues()
IAX2WaitingForAck::AcceptAcked
Definition: processor.h:85
IAX2Processor::frameList
IAX2ActiveFrameList frameList
Definition: processor.h:259
IAX2Processor::activate
PSyncPoint activate
Definition: processor.h:247
IAX2Processor::IsStatusQueryEthernetFrame
PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame)
IAX2WaitingForAck
Definition: processor.h:77
IAX2Processor::ProcessIaxCmdLagRq
virtual void ProcessIaxCmdLagRq(IAX2FullFrameProtocol *src)