Debian Codegraph @

addons/ooh323c/src/ooGkClient.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2005 by Page Iberica, S.A.
3 * Copyright (C) 2005 by Objective Systems, Inc.
4 *
5 * This software is furnished under an open source license and may be
6 * used and copied only in accordance with the terms of this license.
7 * The text of the license may generally be found in the root
8 * directory of this installation in the COPYING file. It
9 * can also be viewed online at the following URL:
10 *
11 * http://www.obj-sys.com/open/license.html
12 *
13 * Any redistributions of this file including modified versions must
14 * maintain this copyright notice.
15 *
16 *****************************************************************************/
17
18 /**
19 * @file ooGkClient.h
20 * This file contains functions to support RAS protocol.
21 *
22 *
23 */
24 #ifndef _OOGKCLIENT_H_
25 #define _OOGKCLIENT_H_
26
27 #include "ooasn1.h"
28 #include "ootypes.h"
29 #include "H323-MESSAGES.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifndef EXTERN
36 #ifdef MAKE_DLL
37 #define EXTERN __declspec(dllexport)
38 #else
39 #define EXTERN
40 #endif /* _WIN32 */
41 #endif /* EXTERN */
42
43
44 /*-------------------------------------------------------------------*/
45 /* Public definitions */
46 /*-------------------------------------------------------------------*/
47
48
49
50 #define MAX_IP_LEN 2+8*4+7
51 #define DEFAULT_GKPORT 1719
52 #define MULTICAST_GKADDRESS "224.0.1.41"
53 #define MULTICAST_GKPORT 1718
54 #define DEFAULT_BW_REQUEST 100000
55
56 /* Various timeouts in seconds */
57 #define DEFAULT_REG_TTL 300
58 #define DEFAULT_TTL_OFFSET 20
59 #define DEFAULT_ARQ_TIMEOUT 5
60 #define DEFAULT_DRQ_TIMEOUT 5
61 #define DEFAULT_GRQ_TIMEOUT 15
62 #define DEFAULT_RRQ_TIMEOUT 10
63
64 /* Number of retries before giving up */
65 #define OO_MAX_GRQ_RETRIES 3
66 #define OO_MAX_RRQ_RETRIES 3
67 #define OO_MAX_ARQ_RETRIES 3
68
69 /* Gk Client timers */
70 #define OO_GRQ_TIMER (1<<0)
71 #define OO_RRQ_TIMER (1<<1)
72 #define OO_REG_TIMER (1<<2)
73 #define OO_ARQ_TIMER (1<<3)
74 #define OO_DRQ_TIMER (1<<4)
75
76 /**
77 * @defgroup gkclient Gatekeeper client
78 * @{
79 */
80
81 struct OOH323CallData;
82 struct ooGkClient;
83 struct RasCallAdmissionInfo;
84
85 typedef struct ooGkClientTimerCb{
86 int timerType;
87 struct ooGkClient *pGkClient;
88 struct RasCallAdmissionInfo *pAdmInfo;
89 }ooGkClientTimerCb;
90
91 enum RasGatekeeperMode {
92 RasNoGatekeeper = 0,
93 RasDiscoverGatekeeper = 1,
94 RasUseSpecificGatekeeper = 2,
95 };
96
97 enum RasCallType{
98 RasPointToPoint =0,
99 RasOneToN,
100 RasnToOne,
101 RasnToN,
102 };
103
104
105 enum OOGkClientState {
106 GkClientIdle = 0,
107 GkClientDiscovered, /* Gk Discovery is complete */
108 GkClientRegistered, /* registered with gk */
109 GkClientUnregistered,
110 GkClientGkErr,/*Gk is not responding, in discover mode can look for new GK*/
111 GkClientFailed,
112 GkClientStopped
113 };
114
115
116 typedef struct RasGatekeeperInfo
117 {
118 ASN1BOOL willRespondToIRR;
119 H225UUIEsRequested uuiesRequested;
120 H225BandWidth bw;
121 H225RegistrationConfirm_preGrantedARQ preGrantedARQ;
122 }RasGatekeeperInfo;
123
124 /**
125 * Call Admission Information
126 */
127 typedef struct RasCallAdmissionInfo
128 {
129 struct OOH323CallData *call;
130 unsigned int retries;
131 unsigned short requestSeqNum;
132 ASN1USINT irrFrequency;
133 } RasCallAdmissionInfo;
134
135 struct OOAliases;
136
137 /**
138 * NOTE- This functionality is not yet fully completed.
139 * This is a callback function which is triggered when registration confirm
140 * message is received from the gatekeeper. The first parameter is the message
141 * received. The second parameter provides updated list of aliases after the
142 * message was processed by the stack.
143 * @param rcf Handle to the received registration confirm message
144 */
145 typedef int (*cb_OnReceivedRegistrationConfirm)
146 (H225RegistrationConfirm *rcf, struct OOAliases *aliases);
147
148
149 /**
150 * NOTE- This functionality is not yet fully completed.
151 * This is a callback function which is triggered when unregistration confirm
152 * message is received. The first parameter is the message received. The second
153 * parameter provides updated list of aliases after the message was processed
154 * by the stack.
155 */
156 typedef int (*cb_OnReceivedUnregistrationConfirm)
157 (H225UnregistrationConfirm *ucf, struct OOAliases *aliases);
158
159 /**
160 * NOTE- This functionality is not yet fully completed.
161 * This is a callback function which is triggered when unregistration request
162 * message is received. The first parameter is the message received. The second
163 * parameter provides the list of aliases requested to be unregistered.
164 */
165 typedef int (*cb_OnReceivedUnregistrationRequest)
166 (H225UnregistrationRequest *urq, struct OOAliases *aliases);
167
168 typedef struct OOGKCLIENTCALLBACKS{
169 cb_OnReceivedRegistrationConfirm onReceivedRegistrationConfirm;
170 cb_OnReceivedUnregistrationConfirm onReceivedUnregistrationConfirm;
171 cb_OnReceivedUnregistrationRequest onReceivedUnregistrationRequest;
172 }OOGKCLIENTCALLBACKS;
173
174 /**
175 * Structure to store all the configuration information for the gatekeeper
176 * client. Gatekeeper client is responsible for all the communication with
177 * a gatekeeper.
178 */
179 typedef struct ooGkClient{
180 ASN1BOOL discoveryComplete;
181 OOCTXT ctxt;
182 OOCTXT msgCtxt;
183 OOSOCKET rasSocket;
184 int localRASPort;
185 char localRASIP[2+8*4+7];
186 char gkRasIP[2+8*4+7];
187 char gkCallSignallingIP[2+8*4+7];
188 RasGatekeeperInfo gkInfo;
189 int gkRasPort;
190 int gkCallSignallingPort;
191 unsigned short requestSeqNum;
192 enum RasGatekeeperMode gkMode; /* Current Gk mode */
193 struct timeval registrationTime;
194 H225GatekeeperIdentifier gkId;
195 H225EndpointIdentifier endpointId;
196 DList callsPendingList;
197 DList callsAdmittedList;
198 DList timerList;
199 OOGKCLIENTCALLBACKS callbacks;
200 ASN1UINT grqRetries;
201 ASN1UINT rrqRetries;
202 ASN1UINT grqTimeout;
203 ASN1UINT rrqTimeout;
204 ASN1UINT regTimeout;
205 ASN1UINT arqTimeout;
206 ASN1UINT drqTimeout;
207 enum OOGkClientState state;
208 ast_mutex_t Lock;
209 } ooGkClient;
210
211 struct OOAliases;
212 struct OOH323CallData;
213
214 /**
215 * This function is used to initialize the Gatekeeper client.If an application
216 * wants to use gatekeeper services, it should call this function immediately
217 * after initializing the H323 EndPoint.
218 * @param eGkMode Gatekeeper mode.
219 * @param szGkAddr Dotted gk ip address, if gk has to be specified.
220 * @param iGkPort Gk port.
221 *
222 * @return OO_OK, on success. OO_FAILED, on failure.
223 *
224 */
225 EXTERN int ooGkClientInit
226 (enum RasGatekeeperMode eGkMode, char *szGkAddr, char *szRasAddr, int iGkPort );
227
228 /**
229 * This function is used to print the gatekeeper client configuration
230 * information to log.
231 * @param pGkClient Handle to gatekeeper client.
232 */
233 EXTERN void ooGkClientPrintConfig(ooGkClient *pGkClient);
234
235 /**
236 * This function is used to destroy Gatekeeper client. It releases all the
237 * associated memory.
238 *
239 * @return OO_OK, on success. OO_FAILED, on failure.
240 */
241 EXTERN int ooGkClientDestroy(void);
242
243 /**
244 * This function is used to start the Gatekeeper client functionality.
245 * @param pGkClient Pointer to the Gatekeeper Client.
246 *
247 * @return OO_OK, on success. OO_FAILED, on failure.
248 */
249 EXTERN int ooGkClientStart(ooGkClient *pGkClient);
250
251 /**
252 * This function is invoked to set a gatekeeper mode.
253 * @param pGkClient Handle to gatekeeper client.
254 * @param eGkMode Gatekeeper mode selected. One of the following:
255 * - RasNoGatekeeper (DEFAULT), No Gatekeeper.
256 * - RasDiscoverGatekeeper, to discover a gatekeeper
257 * automatically.
258 * - RasUseSpecificGatekeeper, to use a specific gatekeeper.
259 * @param szGkAddr Gatekeeper address (only when using specific gatekeeper).
260 * @param iGkPort Gatekeeper RAS port
261 *
262 * @return Completion status - OO_OK on success, OO_FAILED on failure
263 */
264 EXTERN int ooGkClientSetGkMode(ooGkClient *pGkClient,
265 enum RasGatekeeperMode eGkMode, char *szGkAddr,
266 int iGkPort );
267
268 /**
269 * This function is used to create a RAS channel for the gatekeeper.
270 * @param pGkClient Pointer to the Gatekeeper client for which RAS channel
271 * has to be created.
272 *
273 * @return OO_OK, on success. OO_FAILED, on failure.
274 */
275 EXTERN int ooGkClientCreateChannel(ooGkClient *pGkClient);
276
277 /**
278 * This function is used to close a RAS channel of the gatekeeper client.
279 * @param pGkClient Pointer to the gatekeeper client.
280 *
281 * @return OO_OK, on success. OO_FAILED, on failure.
282 */
283 EXTERN int ooGkClientCloseChannel(ooGkClient *pGkClient);
284
285
286 /**
287 * This function is used to fill endpoint's vendor information into vendor
288 * identifier.
289 * @param pGkClient Pointer to gatekeeper client.
290 * @param psVendor Pointer to vendor identifier to be filled.
291 *
292 */
293 EXTERN void ooGkClientRasFillVendor
294 (ooGkClient *pGkClient, H225VendorIdentifier *psVendor);
295
296
297 /**
298 * This function is invoked to receive data on Gatekeeper client's RAS channel.
299 * @param pGkClient Handle to Gatekeeper client for which message has to be
300 * received.
301 *
302 * @return Completion status - OO_OK on success, OO_FAILED on
303 * failure
304 */
305 EXTERN int ooGkClientReceive(ooGkClient *pGkClient);
306
307
308 /**
309 * This function is used to handle a received RAS message by a gatekeeper
310 * client.
311 * @param pGkClient Handle to gatekeeper client.
312 * @param pRasMsg Handle to received Ras message.
313 *
314 * @return OO_OK, on success. OO_FAILED, on failure.
315 */
316 EXTERN int ooGkClientHandleRASMessage
317 (ooGkClient *pGkClient, H225RasMessage *pRasMsg);
318
319
320 /**
321 * This function is used to send a message on Gatekeeper client RAS channel.
322 * @param pGkClient Handle to the gatekeeper client.
323 * @param pRasMsg Handle to Ras message to be sent.
324 *
325 * @return OO_OK, on success. OO_FAILED, otherwise.
326 */
327 EXTERN int ooGkClientSendMsg(ooGkClient *pGkClient, H225RasMessage *pRasMsg);
328
329
330 /**
331 * This function is used to send Gatekeeper request message.
332 * @param pGkClient Handle to gatekeeper client for which GRQ message has to
333 * be sent.
334 *
335 * @return OO_OK, on success. OO_FAILED, otherwise.
336 */
337 EXTERN int ooGkClientSendGRQ(ooGkClient *pGkClient);
338
339
340 /**
341 * This function is used to handle a received gatekeeper reject message.
342 * @param pGkClient Handle to gatekeeper client.
343 * @param pGatekeeperReject Handle to received reject message.
344 *
345 * @return OO_OK, on success. OO_FAILED, otherwise.
346 */
347 EXTERN int ooGkClientHandleGatekeeperReject
348 (ooGkClient *pGkClient, H225GatekeeperReject *pGatekeeperReject);
349
350 /**
351 * This function is used to handle a received gatekeeper confirm message.
352 * @param pGkClient Handle to gatekeeper client.
353 * @param pGatekeeperConfirm Handle to received confirmed message.
354 *
355 * @return OO_OK, on success. OO_FAILED, otherwise.
356 */
357 EXTERN int ooGkClientHandleGatekeeperConfirm
358 (ooGkClient *pGkClient, H225GatekeeperConfirm *pGatekeeperConfirm);
359
360
361 /**
362 * This function is used to send Registration request message.
363 * @param pGkClient Handle to gatekeeper client for which RRQ message has to
364 * be sent.
365 * @param keepAlive Indicates whether keepalive lightweight registration has
366 * to be sent.
367 *
368 * @return OO_OK, on success. OO_FAILED, otherwise.
369 */
370 EXTERN int ooGkClientSendRRQ(ooGkClient *pGkClient, ASN1BOOL keepAlive);
371
372 /**
373 * This function is used to handle a received registration confirm message.
374 * @param pGkClient Handle to gatekeeper client.
375 * @param pRegistrationConfirm Handle to received confirmed message.
376 *
377 * @return OO_OK, on success. OO_FAILED, otherwise.
378 */
379 EXTERN int ooGkClientHandleRegistrationConfirm
380 (ooGkClient *pGkClient, H225RegistrationConfirm *pRegistrationConfirm);
381
382 /**
383 * This function is used to handle a received registration reject message.
384 * @param pGkClient Handle to gatekeeper client.
385 * @param pRegistrationReject Handle to received reject message.
386 *
387 * @return OO_OK, on success. OO_FAILED, otherwise.
388 */
389 EXTERN int ooGkClientHandleRegistrationReject
390 (ooGkClient *pGkClient, H225RegistrationReject *pRegistrationReject);
391
392
393 /**
394 * This function is used to send UnRegistration request message.
395 * @param pGkClient Handle to gatekeeper client for which URQ message has to
396 * be sent.
397 * @param aliases List of aliases to be unregistered. NULL, if all the
398 * aliases have to be unregistered.
399 *
400 * @return OO_OK, on success. OO_FAILED, otherwise.
401 */
402 EXTERN int ooGkClientSendURQ(ooGkClient *pGkClient, struct OOAliases *aliases);
403
404 /**
405 * This function is used to handle a received Unregistration request message.
406 * @param pGkClient Handle to gatekeeper client.
407 * @param punregistrationRequest Handle to received unregistration request.
408 *
409 * @return OO_OK, on success. OO_FAILED, otherwise.
410 */
411 EXTERN int ooGkClientHandleUnregistrationRequest
412 (ooGkClient *pGkClient, H225UnregistrationRequest *punregistrationRequest);
413
414
415 /**
416 * This function is used to send an unregistration confirm message to
417 * gatekeeper.
418 * @param pGkClient Handle to gatekeeper client.
419 * @param reqNo Request Sequence number for the confirm message.
420 *
421 * @return OO_OK, on success. OO_FAILED, on failure.
422 */
423 EXTERN int ooGkClientSendUnregistrationConfirm(ooGkClient *pGkClient,
424 unsigned reqNo);
425
426 /**
427 * This function is invoked to request bandwith admission for a call.
428 * @param pGkClient Gatekeeper client to be used
429 * @param call Handle to the call.
430 * @param retransmit Indicates whether new call or retransmitting for
431 * existing call.
432 *
433 * @return OO_OK, on success. OO_FAILED, on failure.
434 */
435 EXTERN int ooGkClientSendAdmissionRequest
436 (ooGkClient *pGkClient, struct OOH323CallData *call, ASN1BOOL retransmit);
437
438 /**
439 * This function is used to handle a received Admission confirm message.
440 * @param pGkClient Handle to gatekeeper client.
441 * @param pAdmissionConfirm Handle to received confirmed message.
442 *
443 * @return OO_OK, on success. OO_FAILED, otherwise.
444 */
445 EXTERN int ooGkClientHandleAdmissionConfirm
446 (ooGkClient *pGkClient, H225AdmissionConfirm *pAdmissionConfirm);
447
448
449 /**
450 * This function is used to handle a received Admission Reject message. It
451 * finds the associated call and marks it for cleaning with appropriate
452 * call end reason code.
453 * @param pGkClient Handle to Gatekeeper client.
454 * @param pAdmissionReject Handle to received admission reject message.
455 *
456 * @return OO_OK, on success. OO_FAILED, on failure.
457 */
458 EXTERN int ooGkClientHandleAdmissionReject
459 (ooGkClient *pGkClient, H225AdmissionReject *pAdmissionReject);
460
461 /**
462 * This function is invoked to request call disengage to gatekeeper.
463 * @param pGkClient Gatekeeper client to be used.
464 * @param call Call Handle
465 *
466 * @return Completion status - OO_OK on success, OO_FAILED on failure
467 */
468 EXTERN int ooGkClientSendDisengageRequest
469 (ooGkClient *pGkClient, struct OOH323CallData *call);
470
471 /**
472 * This function is used to handle a received disengage confirm message.
473 * @param pGkClient Handle to gatekeeper client.
474 * @param pDCF Handle to received confirmed message.
475 *
476 * @return OO_OK, on success. OO_FAILED, otherwise.
477 */
478 EXTERN int ooGkClientHandleDisengageConfirm
479 (ooGkClient *pGkClient, H225DisengageConfirm *pDCF);
480
481 /**
482 * This function is used to handle an expired registration request timer.
483 * @param pdata Handle to callback data
484 *
485 * @return OO_OK, on success. OO_FAILED, on failure.
486 */
487 EXTERN int ooGkClientRRQTimerExpired(void*pdata);
488
489 /**
490 * This function is used to handle an expired gatekeeper request timer.
491 * @param pdata Handle to callback data
492 *
493 * @return OO_OK, on success. OO_FAILED, on failure.
494 */
495 EXTERN int ooGkClientGRQTimerExpired(void* pdata);
496
497 /**
498 * This function is used to handle an expired registration time-to-live timer.
499 * @param pdata Handle to callback data
500 *
501 * @return OO_OK, on success. OO_FAILED, on failure.
502 */
503 EXTERN int ooGkClientREGTimerExpired(void *pdata);
504
505 /**
506 * This function is used to handle an expired admission request timer.
507 * @param pdata Handle to callback data
508 *
509 * @return OO_OK, on success. OO_FAILED, on failure.
510 */
511 EXTERN int ooGkClientARQTimerExpired(void* pdata);
512
513 /**
514 * This function is used to clean call related data from gatekeeper client.
515 * @param pGkClient Handle to the gatekeeper client.
516 * @param call Handle to the call to be cleaned.
517 *
518 * @return OO_OK, on success. OO_FAILED, on failure.
519 */
520 EXTERN int ooGkClientCleanCall(ooGkClient *pGkClient, struct OOH323CallData *call);
521
522 /**
523 * This function is used to handle gatekeeper client failure or gatekeeper
524 * failure which can be detected by unresponsiveness of gk.
525 * @param pGkClient Handle to gatekeeper client.
526 *
527 * @return OO_OK, on success. OO_FAILED, on failure.
528 */
529 EXTERN int ooGkClientHandleClientOrGkFailure(ooGkClient *pGkClient);
530
531 /**
532 * This function is used to update the registration status of aliases.
533 * @param pGkClient Handle to the GK client.
534 * @param pAddresses List of newly registered addresses. NULL means all
535 * aliases have been successfully registered.
536 * @param registered Indicates whether aliases are registered or unregistered.
537 *
538 * @return OO_OK, on success. OO_FAILED, on failure.
539 */
540 EXTERN int ooGkClientUpdateRegisteredAliases
541 (ooGkClient *pGkClient, H225_SeqOfH225AliasAddress *pAddresses,
542 OOBOOL registered);
543
544 /**
545 * This function is used internally to set Gatekeeper Clients callbacks.
546 * Note: This functionality is not yet fully supported
547 * @param pGkClient Handle to the GK client.
548 * @param callbacks Callback structure contatining various gatekeeper client
549 * callbacks.
550 * @return OO_OK, on success. OO_FAILED, on failure.
551 */
552 int ooGkClientSetCallbacks
553 (ooGkClient *pGkClient, OOGKCLIENTCALLBACKS callbacks);
554 /**
555 * @}
556 */
557
558 int ooGkClientReInit(ooGkClient *pGkClient);
559 void ooGkClientFillVendor
560 (ooGkClient *pGkClient, H225VendorIdentifier *pVendor );
561 void ooGkClientPrintMessage
562 (ooGkClient *pGkClient, ASN1OCTET *msg, ASN1UINT len);
563 int ooGkClientSendIRR
564 (ooGkClient *pGkClient, struct OOH323CallData *call);
565
566
567 #ifdef __cplusplus
568 }
569 #endif
570
571 #endif /* __GKCLIENT_H */