OPAL  Version 3.14.3
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: 31774 $
30  * $Author: rjongbloed $
31  * $Date: 2014-04-16 11:58:42 +1000 (Wed, 16 Apr 2014) $
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_config.h>
42 
43 #if OPAL_H323
44 
45 #include <opal/mediafmt.h>
46 #include <h323/h225ras.h>
47 #include <h323/h235auth.h>
48 #include <h460/h460.h>
49 
50 class H323Connection;
51 class H225_ArrayOf_AliasAddress;
52 class H225_H323_UU_PDU;
53 class H225_AlternateGK;
54 class H225_ArrayOf_AlternateGK;
55 class H225_ArrayOf_ServiceControlSession;
56 class H225_FeatureSet;
57 class H460_FeatureSet;
58 
59 
61 
64 class H323Gatekeeper : public H225_RAS
65 {
66  PCLASSINFO(H323Gatekeeper, H225_RAS);
67  public:
75  );
76 
81 
84  virtual PBoolean WriteTo(
85  H323TransactionPDU & pdu,
86  const H323TransportAddressArray & addresses,
87  PBoolean callback = true
88  );
90 
93  PBoolean OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
94  PBoolean OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
95  PBoolean OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
96  PBoolean OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
97  PBoolean OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
98  PBoolean OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
99  PBoolean OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
100  PBoolean OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
101  PBoolean OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
102  PBoolean OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
103  PBoolean OnReceiveDisengageReject(const H323RasPDU &, const H225_DisengageReject &);
104  PBoolean OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
105  PBoolean OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
106  PBoolean OnReceiveInfoRequest(const H225_InfoRequest & irq);
107  PBoolean OnReceiveInfoRequestResponse(const H225_InfoRequestResponse & irr);
108  PBoolean OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
109  void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
110  void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
111 #if OPAL_H460
112  PBoolean OnSendFeatureSet(H460_MessageType pduType, H225_FeatureSet & features) const;
113  void OnReceiveFeatureSet(H460_MessageType pduType, const H225_FeatureSet & features) const;
114 #endif
115 
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  bool RegistrationRequest(
150  bool autoReregister = true,
151  bool didGkDiscovery = false,
152  bool lightweight = true
153  );
154 
157  PBoolean UnregistrationRequest(
158  int reason
159  );
160 
163  PBoolean LocationRequest(
164  const PString & alias,
165  H323TransportAddress & address
166  );
167 
170  PBoolean LocationRequest(
171  const PStringList & aliases,
172  H323TransportAddress & address
173  );
174 
177 
178  unsigned rejectReason;
179 
180  PBoolean gatekeeperRouted;
181  PINDEX endpointCount;
183  PBYTEArray * accessTokenData;
184 
185  H225_ArrayOf_AliasAddress * aliasAddresses;
186  H225_ArrayOf_AliasAddress * destExtraCallInfo;
187  };
188 
191  PBoolean AdmissionRequest(
192  H323Connection & connection,
193  AdmissionResponse & response,
194  PBoolean ignorePreGrantedARQ = false
195  );
196 
199  PBoolean DisengageRequest(
200  const H323Connection & connection,
201  unsigned reason
202  );
203 
206  PBoolean BandwidthRequest(
207  H323Connection & connection,
208  OpalBandwidth requestedBandwidth
209  );
210 
213  void InfoRequestResponse();
214 
217  void InfoRequestResponse(
218  const H323Connection & connection
219  );
220 
223  void InfoRequestResponse(
224  const H323Connection & connection,
225  const H225_H323_UU_PDU & pdu,
226  PBoolean sent
227  );
228 
231  virtual void OnServiceControlSessions(
232  const H225_ArrayOf_ServiceControlSession & serviceControl,
233  H323Connection * connection
234  );
235 
238  virtual void OnTerminalAliasChanged();
240 
245  PBoolean IsDiscoveryComplete() const { return discoveryComplete; }
246 
250 
265  };
267  friend ostream & operator<<(ostream & strm, RegistrationFailReasons reason) { return strm << GetRegistrationFailReasonString(reason); }
268 
272 
281  PString GetName() const;
282 
285  PString GetEndpointIdentifier() const { return m_endpointIdentifier; }
286 
291  void SetPassword(
292  const PString & password,
293  const PString & username = PString()
294  );
295 
299  void SetAliases(const PStringList & aliases) { m_aliases = aliases; }
300 
303  const PStringList & GetAliases() const { return m_aliases; }
304 
305  /*
306  * Return the call signalling address for the gatekeeper (if present)
307  */
309  { return gkRouteAddress; }
311 
312 #if OPAL_H460
314 #endif
315 
316  void Monitor();
317  void ReRegisterNow();
318 
319  protected:
320  bool StartGatekeeper(const H323TransportAddress & address);
321  virtual bool DiscoverGatekeeper();
322  unsigned SetupGatekeeperRequest(H323RasPDU & request);
323 
324  void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
325  PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
326  void RegistrationTimeToLive();
327 
328  void SetInfoRequestRate(
329  const PTimeInterval & rate
330  );
331  void ClearInfoRequestRate();
332  H225_InfoRequestResponse & BuildInfoRequestResponse(
333  H323RasPDU & response,
334  unsigned seqNum
335  );
336  PBoolean SendUnsolicitedIRR(
337  H225_InfoRequestResponse & irr,
338  H323RasPDU & response
339  );
340 
341  void SetAlternates(
342  const H225_ArrayOf_AlternateGK & alts,
343  bool permanent
344  );
345 
346  virtual PBoolean MakeRequest(
347  Request & request
348  );
349  PBoolean MakeRequestWithReregister(
350  Request & request,
351  unsigned unregisteredTag
352  );
353 
354  virtual H323Transport * CreateTransport(PIPSocket::Address bindng = PIPSocket::GetDefaultIpAny(), WORD port = 0, PBoolean reuseAddr = false);
355 
356  // Handling interface changes
357  void OnAddInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
358  void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
359  bool SetListenerAddresses(H225_ArrayOf_TransportAddress & pdu);
360 
361  // Gatekeeper registration state variables
363  PStringList m_aliases;
364  PWCharArray m_endpointIdentifier;
366  void SetRegistrationFailReason(unsigned reason, unsigned commandMask);
368 
369  PDECLARE_InterfaceNotifier(H323Gatekeeper, OnHighPriorityInterfaceChange);
370  PDECLARE_InterfaceNotifier(H323Gatekeeper, OnLowPriorityInterfaceChange);
371 
372  class AlternateInfo : public PObject {
373  PCLASSINFO(AlternateInfo, PObject);
374  public:
375  AlternateInfo(H225_AlternateGK & alt);
376  ~AlternateInfo();
377  Comparison Compare(const PObject & obj) const;
378  void PrintOn(ostream & strm) const;
379 
382  unsigned priority;
383  enum {
389 
390  private:
391  // Disable copy constructor and assignment
392  AlternateInfo(const AlternateInfo &other): PObject(other) { }
393  AlternateInfo & operator=(const AlternateInfo &) { return *this; }
394  };
395  typedef PSortedList<AlternateInfo> AlternateList;
398 
399  PSemaphore requestMutex;
400  H235Authenticators authenticators;
401 
402  enum {
408 
409  // Gatekeeper operation variables
412  PTimer timeToLive;
416 
417  PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
418 
419 #if OPAL_H460
421 #endif
422 
423 };
424 
425 
426 PLIST(H323GatekeeperList, H323Gatekeeper);
427 
428 
429 #endif // OPAL_H323
430 
431 #endif // OPAL_H323_GKCLIENT_H
432 
433