OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

processor.h
Go to the documentation of this file.
1 /*
2 *
3 * Inter Asterisk Exchange 2
4 *
5 * The core routine which determines the processing of packets for one call.
6 *
7 * Open Phone Abstraction Library (OPAL)
8 *
9 * Copyright (c) 2005 Indranet Technologies Ltd.
10 *
11 * The contents of this file are subject to the Mozilla Public License
12 * Version 1.0 (the "License"); you may not use this file except in
13 * compliance with the License. You may obtain a copy of the License at
14 * http://www.mozilla.org/MPL/
15 *
16 * Software distributed under the License is distributed on an "AS IS"
17 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18 * the License for the specific language governing rights and limitations
19 * under the License.
20 *
21 * The Original Code is Open Phone Abstraction Library.
22 *
23 * The Initial Developer of the Original Code is Indranet Technologies Ltd.
24 *
25 * The author of this code is Derek J Smithies
26 *
27 * $Revision: 24178 $
28 * $Author: rjongbloed $
29 * $Date: 2010-04-05 19:10:56 -0500 (Mon, 05 Apr 2010) $
30 */
31
32 #ifndef OPAL_IAX2_PROCESSOR_H
33 #define OPAL_IAX2_PROCESSOR_H
34
35 #ifndef _PTLIB_H
36 #include <ptlib.h>
37 #endif
38
39 #include <opal/buildopts.h>
40
41 #if OPAL_IAX2
42
43 #include <opal/connection.h>
44
45 #include <iax2/frame.h>
46 #include <iax2/iedata.h>
47 #include <iax2/remote.h>
48 #include <iax2/safestrings.h>
49 #include <iax2/sound.h>
50
51 class IAX2EndPoint;
52 class IAX2Connection;
53 class IAX2ThreadHelper;
54
56
77 class IAX2WaitingForAck : public PObject
78 {
79 PCLASSINFO(IAX2WaitingForAck, PObject);
80
81 public:
83 enum ResponseToAck {
84 RingingAcked = 0,
85 AcceptAcked = 1,
86 AuthRepAcked = 2,
87 AnswerAcked = 3
88 };
89
91 IAX2WaitingForAck();
92
94 void Assign(IAX2FullFrame *f, ResponseToAck _response);
95
97 PBoolean MatchingAckPacket(IAX2FullFrame *f);
98
100 ResponseToAck GetResponse() { return response; }
101
103 PString GetResponseAsString() const;
104
106 virtual void PrintOn(ostream & strm) const;
107
109 void ZeroValues();
110
111 private:
113 DWORD timeStamp;
114
116 PINDEX seqNo;
117
119 ResponseToAck response;
120 };
121
123
136 class IAX2Processor : public PThread
137 {
138 PCLASSINFO(IAX2Processor, PObject);
139
140 public:
142 IAX2Processor(IAX2EndPoint & ep);
143
145 virtual ~IAX2Processor();
146
148 IAX2SequenceNumbers & GetSequenceInfo() { return sequence; }
149
151 IAX2Encryption & GetEncryptionInfo() { return encryption; }
152
154 void IncomingEthernetFrame (IAX2Frame *frame);
155
158 virtual void PrintOn(ostream & strm) const = 0;
159
161 IAX2EndPoint & GetEndPoint() { return endpoint; };
162
172 void SetCallToken(const PString & newToken);
173
175 PString GetCallToken();
176
178 IAX2Remote & GetRemoteInfo() { return remote; }
179
181 const PTimeInterval & GetCallStartTick() { return callStartTick; }
182
186 void Main();
187
190 PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame);
191
194 void SetSpecialPackets(PBoolean newValue) { specialPackets = newValue; }
195
197 void Terminate();
198
203 void Activate();
204
211 virtual PBoolean IncomingMessageOutOfOrder(IAX2FullFrame *ff)= 0;
212
214 void ReportLists(PString & answer);
215
216 protected:
217
219 IAX2EndPoint & endpoint;
220
224 PTimeInterval callStartTick;
225
227 IAX2Remote remote;
228
231 void StartNoResponseTimer(PINDEX msToWait = 60000);
232
234 void StopNoResponseTimer() { noResponseTimer.Stop(); }
235
237 PTimer noResponseTimer;
238
240 void CleanPendingLists() { activate.Signal(); }
241
244 IAX2WaitingForAck nextTask;
245
247 PSyncPoint activate;
248
250 PBoolean endThread;
251
253 IAX2Encryption encryption;
254
256 IAX2SequenceNumbers sequence;
257
259 IAX2ActiveFrameList frameList;
260
263 SafeString callToken;
264
266 virtual void OnNoResponseTimeout() = 0;
267
270 enum DefinedNoResponseTimePeriod {
271 NoResponseTimePeriod = 5000
272 };
273
277 PBoolean IsHandlingSpecialPackets() { return specialPackets; };
278
281 PBoolean specialPackets;
282
285 virtual void ProcessLists() = 0;
286
289 virtual void ProcessFullFrame(IAX2FullFrame & fullFrame) = 0;
290
293 virtual void ProcessIaxCmdLagRq(IAX2FullFrameProtocol *src);
294
297 virtual void ProcessIaxCmdLagRp(IAX2FullFrameProtocol *src);
298
301 virtual void ProcessIaxCmdVnak(IAX2FullFrameProtocol *src);
302
305 virtual void ProcessIaxCmdPing(IAX2FullFrameProtocol *src);
306
309 virtual void ProcessIaxCmdPong(IAX2FullFrameProtocol *src);
310
314 PBoolean ProcessOneIncomingEthernetFrame();
315
317 PAtomicInteger controlFramesSent;
318
320 PAtomicInteger controlFramesRcvd;
321
323 void IncControlFramesSent() { ++controlFramesSent; }
324
326 void IncControlFramesRcvd() { ++controlFramesRcvd; }
327
330 virtual void ProcessNetworkFrame(IAX2MiniFrame * src) = 0;
331
332 /* A frame of FullFrameProtocol type is labelled as AST_FRAME_IAX in the
333 asterisk souces, It will contain 0, 1, 2 or more Information Elements
334 (Ie) in the data section. This processor is used to do things that are
335 common to registration and call handling.
336
337 This method will eat/delete the supplied frame. Return true on success,
338 false on failure.*/
339 virtual PBoolean ProcessNetworkFrame(IAX2FullFrameProtocol * src);
340
344 void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
345
351 void TransmitFrameToRemoteEndpoint(IAX2FullFrame *src,
352 IAX2WaitingForAck::ResponseToAck response
353 );
354
358 void TransmitFrameNow(IAX2Frame *src);
359
361 void TransmitFrameToRemoteEndpoint(IAX2FullFrameProtocol *src);
362
365 PBoolean Authenticate(IAX2FullFrameProtocol *reply,
366 PString & password
367 );
368
370 IAX2IeData ieData;
371
374 void SendAckFrame(IAX2FullFrame *inReplyTo);
375
379 void SendVnakFrame(IAX2FullFrame *inReplyTo);
380
382 void SendUnsupportedFrame(IAX2FullFrame *inReplyTo);
383
384 private:
385 #ifdef DOC_PLUS_PLUS
386
393 void OnNoResponseTimeoutStart(PTimer &, INT);
394 #else
395 PDECLARE_NOTIFIER(PTimer, IAX2Processor, OnNoResponseTimeoutStart);
396 #endif
397
398 protected:
405 DWORD currentSoundTimeStamp;
406 };
407
408
409 #endif // OPAL_IAX2
410
411 #endif // OPAL_IAX2_PROCESSOR_H