OPAL  Version 3.12.9
h323neg.h
Go to the documentation of this file.
1 /*
2  * h323neg.h
3  *
4  * H.323 protocol handler
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions of this code were written with the assisance of funding from
25  * Vovida Networks, Inc. http://www.vovida.com.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 29738 $
30  * $Author: rjongbloed $
31  * $Date: 2013-05-20 09:28:42 +1000 (Mon, 20 May 2013) $
32  */
33 
34 #ifndef OPAL_H323_H323NEG_H
35 #define OPAL_H323_H323NEG_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <opal/buildopts.h>
42 
43 #if OPAL_H323
44 
45 #include <h323/h323pdu.h>
46 #include <h323/channels.h>
47 
48 
49 class H323EndPoint;
50 class H323Connection;
51 
52 
54 
57 class H245Negotiator : public PObject
58 {
59  PCLASSINFO(H245Negotiator, PObject);
60 
61  public:
63 
64  protected:
65  PDECLARE_NOTIFIER(PTimer, H245Negotiator, HandleTimeoutUnlocked);
66  virtual void HandleTimeout();
67 
70  PTimer replyTimer;
71 };
72 
73 
77 {
79 
80  public:
82 
83  PBoolean Start(PBoolean renegotiate);
84  void Stop();
85  PBoolean HandleIncoming(const H245_MasterSlaveDetermination & pdu);
86  PBoolean HandleAck(const H245_MasterSlaveDeterminationAck & pdu);
87  PBoolean HandleReject(const H245_MasterSlaveDeterminationReject & pdu);
88  PBoolean HandleRelease(const H245_MasterSlaveDeterminationRelease & pdu);
89  void HandleTimeout();
90 
91  PBoolean IsMaster() const { return status == e_DeterminedMaster; }
92  PBoolean IsDetermined() const { return state == e_Idle && status != e_Indeterminate; }
93 
94  protected:
95  PBoolean Restart();
96 
97  enum States {
100  } state;
101 #if PTRACING
102  static const char * GetStateName(States s);
103  friend ostream & operator<<(ostream & o, States s) { return o << GetStateName(s); }
104 #endif
105 
107  unsigned retryCount;
108 
112  } status;
113 #if PTRACING
114  static const char * GetStatusName(MasterSlaveStatus s);
115  friend ostream & operator<<(ostream & o , MasterSlaveStatus s) { return o << GetStatusName(s); }
116 #endif
117 };
118 
119 
123 {
125 
126  public:
128 
129  PBoolean Start(PBoolean renegotiate, PBoolean empty = false);
130  void Stop(PBoolean dec = false);
131  PBoolean HandleIncoming(const H245_TerminalCapabilitySet & pdu);
132  PBoolean HandleAck(const H245_TerminalCapabilitySetAck & pdu);
133  PBoolean HandleReject(const H245_TerminalCapabilitySetReject & pdu);
134  PBoolean HandleRelease(const H245_TerminalCapabilitySetRelease & pdu);
135  void HandleTimeout();
136 
137  bool HasSentCapabilities() const { return state >= e_InProgress; }
138  bool IsSendingCapabilities() const { return state == e_InProgress; }
139  bool ConfrimedCapabilitiesSent() const { return state == e_Confirmed; }
141 
142  protected:
143  enum States {
146  } state;
147 #if PTRACING
148  static const char * GetStateName(States s);
149  friend ostream & operator<<(ostream & o, States s) { return o << GetStateName(s); }
150 #endif
151 
154 
156 };
157 
158 
162 {
164 
165  public:
170  H323Connection & connection,
171  H323Channel & channel);
173 
174  virtual PBoolean Open(
175  const H323Capability & capability,
176  unsigned sessionID,
177  unsigned replacementFor = 0
178  );
179  virtual PBoolean Close();
180  virtual PBoolean HandleOpen(const H245_OpenLogicalChannel & pdu);
181  virtual PBoolean HandleOpenAck(const H245_OpenLogicalChannelAck & pdu);
182  virtual PBoolean HandleOpenConfirm(const H245_OpenLogicalChannelConfirm & pdu);
183  virtual PBoolean HandleReject(const H245_OpenLogicalChannelReject & pdu);
184  virtual PBoolean HandleClose(const H245_CloseLogicalChannel & pdu);
185  virtual PBoolean HandleCloseAck(const H245_CloseLogicalChannelAck & pdu);
186  virtual PBoolean HandleRequestClose(const H245_RequestChannelClose & pdu);
187  virtual PBoolean HandleRequestCloseAck(const H245_RequestChannelCloseAck & pdu);
188  virtual PBoolean HandleRequestCloseReject(const H245_RequestChannelCloseReject & pdu);
189  virtual PBoolean HandleRequestCloseRelease(const H245_RequestChannelCloseRelease & pdu);
190  virtual void HandleTimeout();
191 
192  H323Channel * GetChannel() const;
193 
195  bool IsEstablished() const { return state == e_Established; }
196 
197  protected:
198  virtual void Release();
199 
200 
202 
204 
205  enum States {
214  } state;
215 #if PTRACING
216  static const char * GetStateName(States s);
217  friend ostream & operator<<(ostream & o, States s) { return o << GetStateName(s); }
218 #endif
219 
220 
222 };
223 
224 
225 PDICTIONARY(H245LogicalChannelDict, H323ChannelNumber, H245NegLogicalChannel);
226 
230 {
232 
233  public:
235 
236  virtual void Add(H323Channel & channel);
237 
238  virtual PBoolean Open(
239  const H323Capability & capability,
240  unsigned sessionID,
241  unsigned replacementFor = 0
242  );
243  virtual PBoolean Close(unsigned channelNumber, PBoolean fromRemote);
244  virtual PBoolean HandleOpen(const H245_OpenLogicalChannel & pdu);
245  virtual PBoolean HandleOpenAck(const H245_OpenLogicalChannelAck & pdu);
246  virtual PBoolean HandleOpenConfirm(const H245_OpenLogicalChannelConfirm & pdu);
247  virtual PBoolean HandleReject(const H245_OpenLogicalChannelReject & pdu);
248  virtual PBoolean HandleClose(const H245_CloseLogicalChannel & pdu);
249  virtual PBoolean HandleCloseAck(const H245_CloseLogicalChannelAck & pdu);
250  virtual PBoolean HandleRequestClose(const H245_RequestChannelClose & pdu);
251  virtual PBoolean HandleRequestCloseAck(const H245_RequestChannelCloseAck & pdu);
252  virtual PBoolean HandleRequestCloseReject(const H245_RequestChannelCloseReject & pdu);
253  virtual PBoolean HandleRequestCloseRelease(const H245_RequestChannelCloseRelease & pdu);
254 
256  H245LogicalChannelDict & GetChannels() { return channels; }
257  const H245LogicalChannelDict & GetChannels() const { return channels; }
258  H323Channel * FindChannel(unsigned channelNumber, PBoolean fromRemote);
259  H245NegLogicalChannel * FindNegLogicalChannel(unsigned channelNumber, PBoolean fromRemote);
260  H323Channel * FindChannelBySession(unsigned rtpSessionId, PBoolean fromRemote);
261  void RemoveAll();
262 
263  protected:
265  H245LogicalChannelDict channels;
266 };
267 
268 
272 {
273  PCLASSINFO(H245NegRequestMode, H245Negotiator);
274 
275  public:
277 
278  virtual PBoolean StartRequest(const PString & newModes);
279  virtual PBoolean StartRequest(const H245_ArrayOf_ModeDescription & newModes);
280  virtual PBoolean HandleRequest(const H245_RequestMode & pdu);
281  virtual PBoolean HandleAck(const H245_RequestModeAck & pdu);
282  virtual PBoolean HandleReject(const H245_RequestModeReject & pdu);
283  virtual PBoolean HandleRelease(const H245_RequestModeRelease & pdu);
284  virtual void HandleTimeout();
285 
286  protected:
290 };
291 
292 
296 {
298 
299  public:
301 
302  PBoolean StartRequest();
303  PBoolean HandleRequest(const H245_RoundTripDelayRequest & pdu);
304  PBoolean HandleResponse(const H245_RoundTripDelayResponse & pdu);
305  void HandleTimeout();
306 
307  PTimeInterval GetRoundTripDelay() const { return roundTripTime; }
308  PBoolean IsRemoteOffline() const { return retryCount == 0; }
309 
310  protected:
312  unsigned sequenceNumber;
313  PTimeInterval tripStartTime;
314  PTimeInterval roundTripTime;
315  unsigned retryCount;
316 };
317 
318 
319 #endif // OPAL_H323
320 
321 #endif // OPAL_H323_H323NEG_H
322 
323