OPAL  Version 3.12.9
gkclient.h
Go to the documentation of this file.
1 /*
2  * gkclient.h
3  *
4  * Gatekeeper client 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  * iFace, Inc. http://www.iface.com
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 30798 $
30  * $Author: rjongbloed $
31  * $Date: 2013-10-31 16:14:02 +1100 (Thu, 31 Oct 2013) $
32  */
33 
34 #ifndef OPAL_H323_GKCLIENT_H
35 #define OPAL_H323_GKCLIENT_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 <opal/mediafmt.h>
46 #include <h323/h225ras.h>
47 #include <h323/h235auth.h>
48 
49 #if OPAL_H460
50 class H460_FeatureSet;
51 #endif
52 
53 class H323Connection;
54 class H225_ArrayOf_AliasAddress;
55 class H225_H323_UU_PDU;
56 class H225_AlternateGK;
57 class H225_ArrayOf_AlternateGK;
58 class H225_ArrayOf_ServiceControlSession;
59 class H225_FeatureSet;
60 
61 
63 
66 class H323Gatekeeper : public H225_RAS
67 {
68  PCLASSINFO(H323Gatekeeper, H225_RAS);
69  public:
77  );
78 
83 
86  virtual PBoolean WriteTo(
87  H323TransactionPDU & pdu,
88  const H323TransportAddressArray & addresses,
89  PBoolean callback = true
90  );
92 
95  PBoolean OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
96  PBoolean OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
97  PBoolean OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
98  PBoolean OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
99  PBoolean OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
100  PBoolean OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
101  PBoolean OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
102  PBoolean OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
103  PBoolean OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
104  PBoolean OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
105  PBoolean OnReceiveDisengageReject(const H323RasPDU &, const H225_DisengageReject &);
106  PBoolean OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
107  PBoolean OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
108  PBoolean OnReceiveInfoRequest(const H225_InfoRequest & irq);
109  PBoolean OnReceiveInfoRequestResponse(const H225_InfoRequestResponse & irr);
110  PBoolean OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
111  void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
112  void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
113  PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
114  void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
116 
121  PBoolean DiscoverAny();
122 
127  PBoolean DiscoverByName(
128  const PString & identifier
129  );
130 
135  PBoolean DiscoverByAddress(
136  const H323TransportAddress & address
137  );
138 
142  PBoolean DiscoverByNameAndAddress(
143  const PString & identifier,
144  const H323TransportAddress & address
145  );
146 
149  PBoolean RegistrationRequest(
150  PBoolean autoReregister = true,
151  PBoolean didGkDiscovery = false
152  );
153 
156  PBoolean UnregistrationRequest(
157  int reason
158  );
159 
162  PBoolean LocationRequest(
163  const PString & alias,
164  H323TransportAddress & address
165  );
166 
169  PBoolean LocationRequest(
170  const PStringList & aliases,
171  H323TransportAddress & address
172  );
173 
176 
177  unsigned rejectReason;
178 
179  PBoolean gatekeeperRouted;
180  PINDEX endpointCount;
182  PBYTEArray * accessTokenData;
183 
184  H225_ArrayOf_AliasAddress * aliasAddresses;
185  H225_ArrayOf_AliasAddress * destExtraCallInfo;
186  };
187 
190  PBoolean AdmissionRequest(
191  H323Connection & connection,
192  AdmissionResponse & response,
193  PBoolean ignorePreGrantedARQ = false
194  );
195 
198  PBoolean DisengageRequest(
199  const H323Connection & connection,
200  unsigned reason
201  );
202 
205  PBoolean BandwidthRequest(
206  H323Connection & connection,
207  OpalBandwidth requestedBandwidth
208  );
209 
212  void InfoRequestResponse();
213 
216  void InfoRequestResponse(
217  const H323Connection & connection
218  );
219 
222  void InfoRequestResponse(
223  const H323Connection & connection,
224  const H225_H323_UU_PDU & pdu,
225  PBoolean sent
226  );
227 
230  virtual void OnServiceControlSessions(
231  const H225_ArrayOf_ServiceControlSession & serviceControl,
232  H323Connection * connection
233  );
234 
237  virtual void OnTerminalAliasChanged();
239 
244  PBoolean IsDiscoveryComplete() const { return discoveryComplete; }
245 
249 
264  };
266  friend ostream & operator<<(ostream & strm, RegistrationFailReasons reason) { return strm << GetRegistrationFailReasonString(reason); }
267 
271 
280  PString GetName() const;
281 
284  const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
285 
290  void SetPassword(
291  const PString & password,
292  const PString & username = PString()
293  );
294 
295  /*
296  * Return the call signalling address for the gatekeeper (if present)
297  */
299  { return gkRouteAddress; }
301 
302 #if OPAL_H460
304 #endif
305 
306  protected:
307  bool StartGatekeeper(const H323TransportAddress & address);
308  virtual bool DiscoverGatekeeper();
309  unsigned SetupGatekeeperRequest(H323RasPDU & request);
310 
311  void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
312  PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
313  PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
314  void RegistrationTimeToLive();
315 
316  void SetInfoRequestRate(
317  const PTimeInterval & rate
318  );
319  void ClearInfoRequestRate();
320  H225_InfoRequestResponse & BuildInfoRequestResponse(
321  H323RasPDU & response,
322  unsigned seqNum
323  );
324  PBoolean SendUnsolicitedIRR(
325  H225_InfoRequestResponse & irr,
326  H323RasPDU & response
327  );
328 
329  void SetAlternates(
330  const H225_ArrayOf_AlternateGK & alts,
331  bool permanent
332  );
333 
334  virtual PBoolean MakeRequest(
335  Request & request
336  );
337  PBoolean MakeRequestWithReregister(
338  Request & request,
339  unsigned unregisteredTag
340  );
341 
342  virtual H323Transport * CreateTransport(PIPSocket::Address bindng = PIPSocket::GetDefaultIpAny(), WORD port = 0, PBoolean reuseAddr = false);
343 
344  // Handling interface changes
345  void OnAddInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
346  void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
347  bool SetListenerAddresses(H225_ArrayOf_TransportAddress & pdu);
348 
349  // Gatekeeper registration state variables
353  void SetRegistrationFailReason(unsigned reason, unsigned commandMask);
355 
356  PDECLARE_InterfaceNotifier(H323Gatekeeper, OnHighPriorityInterfaceChange);
357  PDECLARE_InterfaceNotifier(H323Gatekeeper, OnLowPriorityInterfaceChange);
358 
359  class AlternateInfo : public PObject {
360  PCLASSINFO(AlternateInfo, PObject);
361  public:
362  AlternateInfo(H225_AlternateGK & alt);
363  ~AlternateInfo();
364  Comparison Compare(const PObject & obj) const;
365  void PrintOn(ostream & strm) const;
366 
369  unsigned priority;
370  enum {
376 
377  private:
378  // Disable copy constructor and assignment
379  AlternateInfo(const AlternateInfo &other): PObject(other) { }
380  AlternateInfo & operator=(const AlternateInfo &) { return *this; }
381  };
382  typedef PSortedList<AlternateInfo> AlternateList;
385 
386  PSemaphore requestMutex;
387  H235Authenticators authenticators;
388 
389  enum {
395 
396  // Gatekeeper operation variables
399  PTimer timeToLive;
403  PThread * monitor;
405  PSyncPoint monitorTickle;
406 
407  PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
408 
409 #if OPAL_H460
411 #endif
412 
413 };
414 
415 
416 PLIST(H323GatekeeperList, H323Gatekeeper);
417 
418 
419 #endif // OPAL_H323
420 
421 #endif // OPAL_H323_GKCLIENT_H
422 
423