OPAL Version 3.10.4

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

- File List
- Globals

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:
62 H245Negotiator(H323EndPoint & endpoint, H323Connection & connection);
63
64 protected:
65 PDECLARE_NOTIFIER(PTimer, H245Negotiator, HandleTimeoutUnlocked);
66 virtual void HandleTimeout();
67
68 H323EndPoint & endpoint;
69 H323Connection & connection;
70 PTimer replyTimer;
71 };
72
73
76 class H245NegMasterSlaveDetermination : public H245Negotiator
77 {
78 PCLASSINFO(H245NegMasterSlaveDetermination, H245Negotiator);
79
80 public:
81 H245NegMasterSlaveDetermination(H323EndPoint & endpoint, H323Connection & connection);
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
106 DWORD determinationNumber;
107 unsigned retryCount;
108
109 enum MasterSlaveStatus {
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
122 class H245NegTerminalCapabilitySet : public H245Negotiator
123 {
124 PCLASSINFO(H245NegTerminalCapabilitySet, H245Negotiator);
125
126 public:
127 H245NegTerminalCapabilitySet(H323EndPoint & endpoint, H323Connection & connection);
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
152 unsigned inSequenceNumber;
153 unsigned outSequenceNumber;
154
155 PBoolean receivedCapabilites;
156 };
157
158
161 class H245NegLogicalChannel : public H245Negotiator
162 {
163 PCLASSINFO(H245NegLogicalChannel, H245Negotiator);
164
165 public:
166 H245NegLogicalChannel(H323EndPoint & endpoint,
167 H323Connection & connection,
168 const H323ChannelNumber & channelNumber);
169 H245NegLogicalChannel(H323EndPoint & endpoint,
170 H323Connection & connection,
171 H323Channel & channel);
172 ~H245NegLogicalChannel();
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
201 H323Channel * channel;
202
203 H323ChannelNumber channelNumber;
204
205 enum States {
206 e_Released,
207 e_AwaitingEstablishment,
208 e_Established,
209 e_AwaitingRelease,
210 e_AwaitingConfirmation,
211 e_AwaitingResponse,
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
220 friend class H245NegLogicalChannels;
221 };
222
223
224 PDICTIONARY(H245LogicalChannelDict, H323ChannelNumber, H245NegLogicalChannel);
225
228 class H245NegLogicalChannels : public H245Negotiator
229 {
230 PCLASSINFO(H245NegLogicalChannels, H245Negotiator);
231
232 public:
233 H245NegLogicalChannels(H323EndPoint & endpoint, H323Connection & connection);
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:
264 H323ChannelNumber lastChannelNumber;
265 H245LogicalChannelDict channels;
266 };
267
268
271 class H245NegRequestMode : public H245Negotiator
272 {
273 PCLASSINFO(H245NegRequestMode, H245Negotiator);
274
275 public:
276 H245NegRequestMode(H323EndPoint & endpoint, H323Connection & connection);
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:
287 PBoolean awaitingResponse;
288 unsigned inSequenceNumber;
289 unsigned outSequenceNumber;
290 };
291
292
295 class H245NegRoundTripDelay : public H245Negotiator
296 {
297 PCLASSINFO(H245NegRoundTripDelay, H245Negotiator);
298
299 public:
300 H245NegRoundTripDelay(H323EndPoint & endpoint, H323Connection & connection);
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:
311 PBoolean awaitingResponse;
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