OPAL  Version 3.10.10
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: 26776 $
30  * $Author: rjongbloed $
31  * $Date: 2011-12-07 16:55:11 -0600 (Wed, 07 Dec 2011) $
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 {
98  e_Idle, e_Outgoing, e_Incoming,
99  e_NumStates
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 
110  e_Indeterminate, e_DeterminedMaster, e_DeterminedSlave,
111  e_NumStatuses
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; }
140  bool HasReceivedCapabilities() const { return receivedCapabilites; }
141 
142  protected:
143  enum States {
144  e_Idle, e_InProgress, e_Confirmed,
145  e_NumStates
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:
168  const H323ChannelNumber & channelNumber);
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();
193 
194  bool IsAwaitingEstablishment() const { return state == e_AwaitingEstablishment; }
195  bool IsEstablished() const { return state == e_Established; }
196 
197  protected:
198  virtual void Release();
199 
200 
202 
204 
205  enum States {
212  e_NumStates
213  } state;
214 #if PTRACING
215  static const char * GetStateName(States s);
216  friend ostream & operator<<(ostream & o, States s) { return o << GetStateName(s); }
217 #endif
218 
219 
221 };
222 
223 
224 PDICTIONARY(H245LogicalChannelDict, H323ChannelNumber, H245NegLogicalChannel);
225 
229 {
231 
232  public:
234 
235  virtual void Add(H323Channel & channel);
236 
237  virtual PBoolean Open(
238  const H323Capability & capability,
239  unsigned sessionID,
240  unsigned replacementFor = 0
241  );
242  virtual PBoolean Close(unsigned channelNumber, PBoolean fromRemote);
243  virtual PBoolean HandleOpen(const H245_OpenLogicalChannel & pdu);
244  virtual PBoolean HandleOpenAck(const H245_OpenLogicalChannelAck & pdu);
245  virtual PBoolean HandleOpenConfirm(const H245_OpenLogicalChannelConfirm & pdu);
246  virtual PBoolean HandleReject(const H245_OpenLogicalChannelReject & pdu);
247  virtual PBoolean HandleClose(const H245_CloseLogicalChannel & pdu);
248  virtual PBoolean HandleCloseAck(const H245_CloseLogicalChannelAck & pdu);
249  virtual PBoolean HandleRequestClose(const H245_RequestChannelClose & pdu);
250  virtual PBoolean HandleRequestCloseAck(const H245_RequestChannelCloseAck & pdu);
251  virtual PBoolean HandleRequestCloseReject(const H245_RequestChannelCloseReject & pdu);
252  virtual PBoolean HandleRequestCloseRelease(const H245_RequestChannelCloseRelease & pdu);
253 
254  H323ChannelNumber GetNextChannelNumber();
255  PINDEX GetSize() const { return channels.GetSize(); }
256  H323Channel * GetChannelAt(PINDEX i);
257  H323Channel * FindChannel(unsigned channelNumber, PBoolean fromRemote);
258  H245NegLogicalChannel & GetNegLogicalChannelAt(PINDEX i);
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 
Definition: h323neg.h:161
H323ChannelNumber lastChannelNumber
Definition: h323neg.h:264
bool IsSendingCapabilities() const
Definition: h323neg.h:138
States
Definition: h323neg.h:143
H323Connection & connection
Definition: h323neg.h:69
unsigned retryCount
Definition: h323neg.h:107
PDICTIONARY(H245LogicalChannelDict, H323ChannelNumber, H245NegLogicalChannel)
Definition: h323neg.h:228
H323ChannelNumber channelNumber
Definition: h323neg.h:203
H245LogicalChannelDict channels
Definition: h323neg.h:265
Definition: h323caps.h:89
Definition: h323neg.h:57
Definition: h323neg.h:295
PBoolean awaitingResponse
Definition: h323neg.h:287
bool HasReceivedCapabilities() const
Definition: h323neg.h:140
DWORD determinationNumber
Definition: h323neg.h:106
unsigned retryCount
Definition: h323neg.h:315
bool IsAwaitingEstablishment() const
Definition: h323neg.h:194
bool ConfrimedCapabilitiesSent() const
Definition: h323neg.h:139
PTimeInterval tripStartTime
Definition: h323neg.h:313
States
Definition: h323neg.h:205
Definition: channels.h:99
unsigned inSequenceNumber
Definition: h323neg.h:288
MasterSlaveStatus
Definition: h323neg.h:109
bool HasSentCapabilities() const
Definition: h323neg.h:137
unsigned outSequenceNumber
Definition: h323neg.h:153
PBoolean awaitingResponse
Definition: h323neg.h:311
PINDEX GetSize() const
Definition: h323neg.h:255
bool IsEstablished() const
Definition: h323neg.h:195
PTimeInterval GetRoundTripDelay() const
Definition: h323neg.h:307
PBoolean receivedCapabilites
Definition: h323neg.h:155
Definition: h323con.h:130
unsigned inSequenceNumber
Definition: h323neg.h:152
Definition: h323neg.h:208
ostream & operator<<(ostream &strm, OpalSilenceDetector::Mode mode)
H323Channel * channel
Definition: h323neg.h:201
PBoolean IsMaster() const
Definition: h323neg.h:91
H323EndPoint & endpoint
Definition: h323neg.h:68
PTimeInterval roundTripTime
Definition: h323neg.h:314
PBoolean IsDetermined() const
Definition: h323neg.h:92
Definition: h323neg.h:122
Definition: channels.h:70
States
Definition: h323neg.h:97
PBoolean IsRemoteOffline() const
Definition: h323neg.h:308
virtual void HandleTimeout()
PDECLARE_NOTIFIER(PTimer, H245Negotiator, HandleTimeoutUnlocked)
Definition: h323neg.h:206
Definition: h323ep.h:85
H245Negotiator(H323EndPoint &endpoint, H323Connection &connection)
unsigned sequenceNumber
Definition: h323neg.h:312
unsigned outSequenceNumber
Definition: h323neg.h:289
Definition: h323neg.h:76
PTimer replyTimer
Definition: h323neg.h:70
Definition: h323neg.h:271