OPAL  Version 3.12.5
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: 28549 $
30  * $Author: rjongbloed $
31  * $Date: 2012-11-16 05:31:10 -0600 (Fri, 16 Nov 2012) $
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 OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
106  PBoolean OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
107  PBoolean OnReceiveInfoRequest(const H225_InfoRequest & irq);
108  PBoolean OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
109  void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
110  void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
111  PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
112  void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
114 
119  PBoolean DiscoverAny();
120 
125  PBoolean DiscoverByName(
126  const PString & identifier
127  );
128 
133  PBoolean DiscoverByAddress(
134  const H323TransportAddress & address
135  );
136 
140  PBoolean DiscoverByNameAndAddress(
141  const PString & identifier,
142  const H323TransportAddress & address
143  );
144 
147  PBoolean RegistrationRequest(
148  PBoolean autoReregister = true,
149  PBoolean didGkDiscovery = false
150  );
151 
154  PBoolean UnregistrationRequest(
155  int reason
156  );
157 
160  PBoolean LocationRequest(
161  const PString & alias,
162  H323TransportAddress & address
163  );
164 
167  PBoolean LocationRequest(
168  const PStringList & aliases,
169  H323TransportAddress & address
170  );
171 
174 
175  unsigned rejectReason;
176 
177  PBoolean gatekeeperRouted;
178  PINDEX endpointCount;
180  PBYTEArray * accessTokenData;
181 
182  H225_ArrayOf_AliasAddress * aliasAddresses;
183  H225_ArrayOf_AliasAddress * destExtraCallInfo;
184  };
185 
188  PBoolean AdmissionRequest(
189  H323Connection & connection,
190  AdmissionResponse & response,
191  PBoolean ignorePreGrantedARQ = false
192  );
193 
196  PBoolean DisengageRequest(
197  const H323Connection & connection,
198  unsigned reason
199  );
200 
203  PBoolean BandwidthRequest(
204  H323Connection & connection,
205  OpalBandwidth requestedBandwidth
206  );
207 
210  void InfoRequestResponse();
211 
214  void InfoRequestResponse(
215  const H323Connection & connection
216  );
217 
220  void InfoRequestResponse(
221  const H323Connection & connection,
222  const H225_H323_UU_PDU & pdu,
223  PBoolean sent
224  );
225 
228  virtual void OnServiceControlSessions(
229  const H225_ArrayOf_ServiceControlSession & serviceControl,
230  H323Connection * connection
231  );
232 
235  virtual void OnTerminalAliasChanged();
237 
242  PBoolean IsDiscoveryComplete() const { return discoveryComplete; }
243 
247 
261  };
263  friend ostream & operator<<(ostream & strm, RegistrationFailReasons reason) { return strm << GetRegistrationFailReasonString(reason); }
264 
268 
277  PString GetName() const;
278 
281  const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
282 
287  void SetPassword(
288  const PString & password,
289  const PString & username = PString()
290  );
291 
292  /*
293  * Return the call signalling address for the gatekeeper (if present)
294  */
296  { return gkRouteAddress; }
298 
299 #if OPAL_H460
301 #endif
302 
303  protected:
304  bool StartGatekeeper(const H323TransportAddress & address);
305  virtual bool DiscoverGatekeeper();
306  unsigned SetupGatekeeperRequest(H323RasPDU & request);
307 
308  void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
309  PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
310  PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
311  void RegistrationTimeToLive();
312 
313  void SetInfoRequestRate(
314  const PTimeInterval & rate
315  );
316  void ClearInfoRequestRate();
317  H225_InfoRequestResponse & BuildInfoRequestResponse(
318  H323RasPDU & response,
319  unsigned seqNum
320  );
321  PBoolean SendUnsolicitedIRR(
322  H225_InfoRequestResponse & irr,
323  H323RasPDU & response
324  );
325 
326  void SetAlternates(
327  const H225_ArrayOf_AlternateGK & alts,
328  PBoolean permanent
329  );
330 
331  virtual PBoolean MakeRequest(
332  Request & request
333  );
334  PBoolean MakeRequestWithReregister(
335  Request & request,
336  unsigned unregisteredTag
337  );
338 
339  virtual H323Transport * CreateTransport(PIPSocket::Address bindng = PIPSocket::GetDefaultIpAny(), WORD port = 0, PBoolean reuseAddr = false);
340 
341  // Handling interface changes
342  void OnAddInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
343  void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
344  bool SetListenerAddresses(H225_ArrayOf_TransportAddress & pdu);
345 
346  // Gatekeeper registration state variables
350  void SetRegistrationFailReason(unsigned reason, unsigned commandMask);
352 
353  PDECLARE_InterfaceNotifier(H323Gatekeeper, OnHighPriorityInterfaceChange);
354  PDECLARE_InterfaceNotifier(H323Gatekeeper, OnLowPriorityInterfaceChange);
355 
356  class AlternateInfo : public PObject {
357  PCLASSINFO(AlternateInfo, PObject);
358  public:
359  AlternateInfo(H225_AlternateGK & alt);
360  ~AlternateInfo();
361  Comparison Compare(const PObject & obj);
362  void PrintOn(ostream & strm) const;
363 
366  unsigned priority;
367  enum {
374 
375  private:
376  // Disable copy constructor and assignment
377  AlternateInfo(const AlternateInfo &other): PObject(other) { }
378  AlternateInfo & operator=(const AlternateInfo &) { return *this; }
379  };
380  PSortedList<AlternateInfo> alternates;
382  PSemaphore requestMutex;
383  H235Authenticators authenticators;
384 
385  enum {
391 
392  // Gatekeeper operation variables
395  PTimer timeToLive;
399  PThread * monitor;
401  PSyncPoint monitorTickle;
402 
403  PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
404 
405 #if OPAL_H460
407 #endif
408 
409 };
410 
411 
412 PLIST(H323GatekeeperList, H323Gatekeeper);
413 
414 
415 #endif // OPAL_H323
416 
417 #endif // OPAL_H323_GKCLIENT_H
418 
419