Debian Codegraph @

addons/ooh323c/src/ooh245.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2004-2005 by Objective Systems, Inc.
3 *
4 * This software is furnished under an open source license and may be
5 * used and copied only in accordance with the terms of this license.
6 * The text of the license may generally be found in the root
7 * directory of this installation in the COPYING file. It
8 * can also be viewed online at the following URL:
9 *
10 * http://www.obj-sys.com/open/license.html
11 *
12 * Any redistributions of this file including modified versions must
13 * maintain this copyright notice.
14 *
15 *****************************************************************************/
16
17 /**
18 * @file ooh245.h
19 * This file contains functions to support H245 negotiations.
20 */
21 #ifndef _OOH245HDR_H_
22 #define _OOH245HDR_H_
23
24 #include "ooasn1.h"
25 #include "ooCapability.h"
26 #include "oochannels.h"
27 #include "ootrace.h"
28
29 #include "ooq931.h"
30 #include "MULTIMEDIA-SYSTEM-CONTROL.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #ifndef EXTERN
37 #ifdef MAKE_DLL
38 #define EXTERN __declspec(dllexport)
39 #else
40 #define EXTERN
41 #endif /* MAKE_DLL */
42 #endif /* EXTERN */
43
44 struct OOH323CallData;
45
46 /**
47 * @defgroup h245 H.245 Message Handling
48 * @{
49 */
50 /**
51 * Defines the H.245 message structure. All request/response
52 * and command messages are represented using this structure.
53 */
54 typedef struct H245Message {
55 H245MultimediaSystemControlMessage h245Msg;
56 ASN1UINT msgType;
57 ASN1INT logicalChannelNo;
58 } H245Message;
59
60 /**
61 * Creates an outgoing H245 message of the type specified by the type
62 * argument for the Application context.
63 *
64 * @param msg A pointer to pointer to message which will be assigned to
65 * allocated memory.
66 * @param type Type of the message to be created.
67 * (Request/Response/Command/Indication)
68 *
69 * @return Completion status of operation: 0 (OO_OK) = success,
70 * negative return value is error.
71 */
72 EXTERN int ooCreateH245Message(OOH323CallData* call, H245Message **msg, int type);
73
74 /**
75 * Frees up the memory used by the H245 message.
76 *
77 * @param call Handle to the call
78 * @param pmsg Pointer to an H245 message structure.
79 *
80 * @return OO_OK, on success. OO_FAILED, on failure
81 */
82 EXTERN int ooFreeH245Message(struct OOH323CallData *call, H245Message *pmsg);
83
84 /**
85 * This function is used to enqueue an H.245 message into an outgoing queue for
86 * the call.
87 * @param call Pointer to call for which message has to be enqueued.
88 * @param msg Pointer to the H.245 message to be sent.
89 *
90 * @return OO_OK, on success. OO_FAILED, on failure.
91 */
92 EXTERN int ooSendH245Msg(struct OOH323CallData *call, H245Message *msg);
93
94 /**
95 * This function is used to retrieve an H.245 message enqueued in the outgoing
96 * queue.
97 * @param call Pointer to the call for which message has to be retrieved.
98 * @param msgbuf Pointer to a buffer in which the message will be returned.
99 * @param len Pointer to an int variable which will contain length of
100 * the message data after returning.
101 * @param msgType Pointer to an int variable, which will contain message type
102 * on return from the function.
103 *
104 * @return OO_OK, on success. OO_FAILED, on failure.
105 */
106 EXTERN int ooGetOutgoingH245Msgbuf(struct OOH323CallData *call,
107 ASN1OCTET *msgbuf,
108 int *len, int *msgType);
109
110 /**
111 * This function is used to send out a terminal capability set message.
112 *
113 * @param call Pointer to a call for which TerminalCapabilitySet message
114 * will be sent.
115 *
116 * @return OO_OK, on success. OO_FAILED, on failure.
117 */
118 EXTERN int ooSendTermCapMsg(struct OOH323CallData *call);
119 EXTERN int ooSendEmptyTermCapMsg(struct OOH323CallData *call);
120
121 /**
122 * This function is used to generate a random status determination number
123 * for MSD procedure.
124 *
125 * @return Generated status determination number.
126 */
127 EXTERN ASN1UINT ooGenerateStatusDeterminationNumber(void);
128
129 /**
130 * This fuction is used to handle received MasterSlaveDetermination procedure
131 * messages.
132 * @param call Pointer to the call for which a message is received.
133 * @param pmsg Pointer to MSD message
134 * @param msgType Message type indicating whether received message is MSD,
135 * MSDAck, MSDReject etc...
136 *
137 * @return OO_OK, on success. OO_FAILED, on failure.
138 */
139 EXTERN int ooHandleMasterSlave
140 (struct OOH323CallData *call, void * pmsg, int msgType);
141
142 /**
143 * This function is used to send MSD message.
144 * @param call Pointer to call for which MasterSlaveDetermination has to
145 * be sent.
146 *
147 * @return OO_OK, on success. OO_FAILED, on failure.
148 */
149 EXTERN int ooSendMasterSlaveDetermination(struct OOH323CallData *call);
150
151 /**
152 * This function is used to send a MasterSlaveDeterminationAck message.
153 * @param call Pointer to call for which MasterSlaveDeterminationAck has
154 * to be sent.
155 * @param status Result of the determination process(Master/Slave as it
156 * applies to remote endpoint)
157 *
158 * @return OO_OK, on success. OO_FAILED, on failure.
159 */
160 EXTERN int ooSendMasterSlaveDeterminationAck
161 (struct OOH323CallData* call, char * status);
162
163 /**
164 * This function is used to send a MasterSlaveDeterminationReject message.
165 * @param call Pointer to call for which message is to be sent.
166 * @return OO_OK, on success. OO_FAILED, on failure.
167 */
168 EXTERN int ooSendMasterSlaveDeterminationReject (struct OOH323CallData* call);
169
170
171 /**
172 * This function is used to handle MasterSlaveReject message. If number of
173 * retries is less than max allowed, then it restarts the
174 * MasterSlaveDetermination procedure.
175 * @param call Handle to the call for which MasterSlaveReject is
176 * received.
177 * @param reject Pointer to the received reject message.
178 *
179 * @return OO_OK, on success. OO_FAILED, on failure.
180 */
181 EXTERN int ooHandleMasterSlaveReject
182 (struct OOH323CallData *call, H245MasterSlaveDeterminationReject* reject);
183
184 /**
185 * This function is used to handle received OpenLogicalChannel message.
186 * @param call Pointer to call for which OpenLogicalChannel message is
187 * received.
188 * @param olc Pointer to the received OpenLogicalChannel message.
189 *
190 * @return OO_OK, on success. OO_FAILED, on failure.
191 */
192 EXTERN int ooHandleOpenLogicalChannel
193 (struct OOH323CallData* call, H245OpenLogicalChannel *olc);
194
195 /**
196 * This is a helper function used to handle a received OpenLogicalChannel
197 * message. It builds an OpenLogicalChannelAck message and sends it.
198 *
199 * @param call Pointer to cll for which OLC was received.
200 * @param olc The received OpenLogicalChannel message.
201 *
202 * @return OO_OK, on success. OO_FAILED, on failure.
203 */
204 EXTERN int ooHandleOpenLogicalChannel_helper
205 (struct OOH323CallData *call, H245OpenLogicalChannel*olc);
206
207 /**
208 * This function is used to build and send OpenLogicalChannelReject message.
209 * @param call Pointer to call for which OLCReject has to be sent.
210 * @param channelNum LogicalChannelNumber to be rejected.
211 * @param cause Cause of rejection.
212 *
213 * @return OO_OK, on success. OO_FAILED, on failure.
214 */
215 int ooSendOpenLogicalChannelReject
216 (struct OOH323CallData *call, ASN1UINT channelNum, ASN1UINT cause);
217
218 /**
219 * This function is used to handle a received OpenLogicalChannelAck message.
220 * @param call Pointer to call for which OLCAck is received
221 * @param olcAck Pointer to received olcAck message.
222 *
223 * @return OO_OK, on success. OO_FAILED, on failure.
224 */
225 EXTERN int ooOnReceivedOpenLogicalChannelAck(struct OOH323CallData *call,
226 H245OpenLogicalChannelAck *olcAck);
227
228
229 /**
230 * This function is used to handle the received OpenLogicalChannelReject
231 * message.
232 * @param call Handle to the call for which the message is received.
233 * @param olcRejected Pointer to received OpenLogicalChannelReject message.
234 *
235 * @return OO_OK, on success. OO_FAILED, on failure.
236 */
237 int ooOnReceivedOpenLogicalChannelRejected(struct OOH323CallData *call,
238 H245OpenLogicalChannelReject *olcRejected);
239 /**
240 * This message is used to send an EndSession command. It builds a EndSession
241 * command message and queues it into the calls outgoing queue.
242 * @param call Pointer to call for which EndSession command has to be
243 * sent.
244 * @return OO_OK, on success. OO_FAILED, on failure.
245 */
246 EXTERN int ooSendEndSessionCommand(struct OOH323CallData *call);
247
248 /**
249 * This function is used to handle a received H245Command message.
250 * @param call Pointer to call for which an H245Command is received.
251 * @param command Pointer to a command message.
252 *
253 * @return OO_OK, on success. OO_FAILED, on failure
254 */
255 EXTERN int ooHandleH245Command
256 (struct OOH323CallData *call, H245CommandMessage *command);
257
258
259 /**
260 * This function is used to handle a received UserInput Indication message.
261 * It extracts the dtmf received through user-input message and calls endpoints
262 * onReceivedDTMF callback function, if such a function is registered by the
263 * endpoint.
264 * @param call Handle to the call for which user-input indication
265 * message is received.
266 * @param indication Handle to the received user-input indication message.
267 *
268 * @return OO_OK, on success; OO_FAILED, on failure.
269 */
270 EXTERN int ooOnReceivedUserInputIndication
271 (OOH323CallData *call, H245UserInputIndication *indication);
272
273 /**
274 * This function is called on receiving a TerminalCapabilitySetAck message.
275 * If the MasterSlaveDetermination process is also over, this function
276 * initiates the process of opening logical channels.
277 * @param call Pointer to call for which TCSAck is received.
278 *
279 * @return OO_OK, on success. OO_FAILED, on failure.
280 */
281 EXTERN int ooOnReceivedTerminalCapabilitySetAck(struct OOH323CallData* call);
282
283 /**
284 * This function is called to close all the open logical channels. It sends
285 * CloseLogicalChannel message for all the forward channels and sends
286 * RequestCloseLogicalChannel message for all the reverse channels.
287 * @param call Pointer to call for which logical channels have to be
288 * closed.
289 *
290 * @return OO_OK, on success. OO_FAILED, on failure.
291 */
292 EXTERN int ooCloseAllLogicalChannels(struct OOH323CallData *call, char* dir);
293
294 EXTERN int ooUpdateAllLogicalChannels(struct OOH323CallData *call, char* localIP, int port);
295
296
297 /**
298 * This function is used to send out a CloseLogicalChannel message for a particular
299 * logical channel.
300 * @param call Pointer to a call, to which logical channel to be closed belongs.
301 * @param logicalChan Pointer to the logical channel to be closed.
302 *
303 * @return OO_OK, on success. OO_FAILED, on failure.
304 */
305 EXTERN int ooSendCloseLogicalChannel
306 (struct OOH323CallData *call, ooLogicalChannel *logicalChan);
307
308 /**
309 * This function is used to process a received closeLogicalChannel request. It closes the
310 * logical channel and removes the logical channel entry from the list. It also, sends
311 * closeLogicalChannelAck message to the remote endpoint.
312 * @param call Pointer to call for which CloseLogicalChannel message is received.
313 * @param clc Pointer to received CloseLogicalChannel message.
314 *
315 * @return OO_OK, on success. OO_FAILED, on failure.
316 */
317 EXTERN int ooOnReceivedCloseLogicalChannel(struct OOH323CallData *call,
318 H245CloseLogicalChannel* clc);
319
320 /**
321 * This function is used to process a received CloseLogicalChannelAck message. It closes the
322 * channel and removes it from the list of active logical channels.
323 * @param call Pointer to call for which CLCAck message is received.
324 * @param clcAck Pointer to the received CloseLogicalChannelAck message.
325 *
326 * @return OO_OK, on success. OO_FAILED, on failure
327 */
328 EXTERN int ooOnReceivedCloseChannelAck(struct OOH323CallData* call,
329 H245CloseLogicalChannelAck* clcAck);
330
331 /**
332 * This function is used to handle received H245 message. Based on the type of message received,
333 * it calls helper functions to process those messages.
334 * @param call Pointer to call for which a message is received.
335 * @param pmsg Pointer to the received H245 message.
336 *
337 * @return OO_OK, on success. OO_FAILED, on failure.
338 */
339 EXTERN int ooHandleH245Message
340 (struct OOH323CallData *call, H245Message * pmsg);
341
342 /**
343 * This function is used to process received TCS message. It builds TCSAck message and queues it
344 * into the calls outgoing queue. Also, starts Logical channel opening procedure if TCS and MSD
345 * procedures have finished.
346 * @param call Pointer to call for which TCS is received.
347 * @param pmsg Pointer to the received message.
348 *
349 * @return OO_OK, on success. OO_FAILED, on failure.
350 */
351 EXTERN int ooOnReceivedTerminalCapabilitySet
352 (struct OOH323CallData *call, H245Message *pmsg);
353
354 /**
355 * This function is used to send a TCSAck message to remote endpoint.
356 * @param call Pointer to call on which TCSAck has to be sent.
357 *
358 * @return OO_OK, on success. OO_FAILED, on failure.
359 */
360 EXTERN int ooH245AcknowledgeTerminalCapabilitySet(struct OOH323CallData *call);
361
362 /**
363 * This function is used to start OpenLogicalChannel procedure for all the
364 * channels to be opened for the call.
365 * @param call Pointer to call for which logical channels have to be opened.
366 *
367 * @return OO_OK, on success. OO_FAILED, on failure.
368 */
369 EXTERN int ooOpenLogicalChannels(struct OOH323CallData *call);
370
371 /**
372 * This function is used to send OpenLogicalChannel message for audio/video
373 * channel.
374 * @param call Pointer to call for which channel has to be opened.
375 * @param capType Type of media channel.
376 *
377 * @return OO_OK, on success. OO_FAILED, on failure.
378 */
379 EXTERN int ooOpenLogicalChannel(struct OOH323CallData *call,
380 enum OOCapType capType);
381
382 /**
383 * This function is used to build and send OpenLogicalChannel message using
384 * capability passed as parameter.
385 * @param call Pointer to call for which OpenLogicalChannel message
386 * has to be built.
387 * @param epCap Pointer to capability
388 *
389 * @return OO_OK, on success. OO_FAILED, on failure.
390 */
391 EXTERN int ooOpenChannel
392 (struct OOH323CallData* call, ooH323EpCapability *epCap);
393
394 /**
395 * This function is used to send dtmf digits as user input indication message
396 * contating alphanumeric string.
397 * @param call Handle to the call for which dtmf has to be sent.
398 * @param data DTMF data
399 *
400 * @return OO_OK, on success; OO_FAILED, on failure.
401 */
402 EXTERN int ooSendH245UserInputIndication_alphanumeric
403 (OOH323CallData *call, const char *data);
404
405 /**
406 * This function is used to send dtmf digits as user input indication message
407 * contating dtmf signal type.
408 * @param call Handle to the call for which dtmf has to be sent.
409 * @param data DTMF data
410 *
411 * @return OO_OK, on success; OO_FAILED, on failure.
412 */
413 EXTERN int ooSendH245UserInputIndication_signal
414 (OOH323CallData *call, const char *data);
415
416 /**
417 * This function is used to request a remote end point to close a logical
418 * channel.
419 * @param call Pointer to call for which the logical channel has to
420 * be closed.
421 * @param logicalChan Pointer to the logical channel structure which needs
422 * to be closed.
423 *
424 * @return OO_OK, on success. OO_FAILED, on failure.
425 */
426 EXTERN int ooSendRequestCloseLogicalChannel(struct OOH323CallData *call,
427 ooLogicalChannel *logicalChan);
428
429 /**
430 * This function is used to send a RequestChannelCloseRelease message when the
431 * corresponding timer has expired.
432 * @param call Handle to the call
433 * @param channelNum Channel number.
434 *
435 * @return OO_OK, on success. OO_FAILED, otherwise.
436 */
437 int ooSendRequestChannelCloseRelease
438 (struct OOH323CallData *call, int channelNum);
439
440 /**
441 * This function handles the received RequestChannelClose message, verifies
442 * that the requested channel is forward channel. It sends an acknowledgement
443 * for the message followed by CloseLogicalChannel message.
444 * @param call Pointer to the call for which RequestChannelClose is
445 * received.
446 * @param rclc Pointer to the received message.
447 *
448 * @return OO_OK, on success. OO_FAILED, on failure.
449 */
450 EXTERN int ooOnReceivedRequestChannelClose(struct OOH323CallData *call,
451 H245RequestChannelClose *rclc);
452
453 /**
454 * This function is used to handle a received RequestChannelCloseReject
455 * response message.
456 * @param call Handle to the call.
457 * @param rccReject Pointer to the received reject response message.
458 *
459 * @return OO_OK, on success. OO_FAILED, on failure.
460 */
461 int ooOnReceivedRequestChannelCloseReject
462 (struct OOH323CallData *call, H245RequestChannelCloseReject *rccReject);
463
464 /**
465 * This function is used to handle a received RequestChannelCloseAck
466 * response message.
467 * @param call Handle to the call.
468 * @param rccAck Pointer to the received ack response message.
469 *
470 * @return OO_OK, on success. OO_FAILED, on failure.
471 */
472 int ooOnReceivedRequestChannelCloseAck
473 (struct OOH323CallData *call, H245RequestChannelCloseAck *rccAck);
474
475 /**
476 * Builds an OLC for faststart with an audio/video capability passed as
477 * parameter.
478 * @param call Handle to call for which OLC has to be built.
479 * @param olc Pointer to an OLC structure which will be populated.
480 * @param epCap Pointer to the capability which will be used to
481 * build OLC.
482 * @param pctxt Pointer to an OOCTXT structure which will be used
483 * to allocate additional memory for OLC.
484 * @param dir Direction of OLC
485 *
486 * @return OO_OK, on success. OO_FAILED, on failure.
487 */
488 EXTERN int ooBuildFastStartOLC(struct OOH323CallData *call,
489 H245OpenLogicalChannel *olc,
490 ooH323EpCapability *epCap,
491 OOCTXT*pctxt, int dir);
492
493 /**
494 * Prepares a faststart response olc from the olc received in SETUP message.
495 * This function just changes the mediaChannel and mediaControl channel part
496 * of the olc received in SETUP.
497 * @param call Handle to call for which OLC has to be built.
498 * @param olc Pointer to an received OLC structure.
499 * @param epCap Pointer to the capability which will be used for
500 * this channel.
501 * @param pctxt Pointer to an OOCTXT structure which will be used
502 * to allocate additional memory for OLC.
503 * @param dir Direction of channel OORX, OOTX etc.
504 *
505 * @return OO_OK, on success. OO_FAILED, on failure.
506 */
507 EXTERN int ooPrepareFastStartResponseOLC
508 (OOH323CallData *call, H245OpenLogicalChannel *olc,
509 ooH323EpCapability *epCap, OOCTXT*pctxt, int dir);
510
511 /**
512 * This function is used to encode an H245 message and return encoded data
513 * into the buffer passed as a parameter to the function.
514 * @param call Handle to the call
515 * @param ph245Msg Handle to the message to be encoded.
516 * @param msgbuf buffer in which encoded message will be returned.
517 * @param size Size of the buffer.
518 *
519 * @return OO_OK, on success. OO_FAILED, on failure
520 */
521 EXTERN int ooEncodeH245Message
522 (struct OOH323CallData *call, H245Message *ph245Msg, char *msgbuf, int size);
523
524 /**
525 * This function is used to send a master-slave determination release message.
526 * @param call Handle to call, for which MSDRelease message has
527 * to be sent.
528 *
529 * @return OO_OK, on success. OO_FAILED, on failure.
530 */
531 int ooSendMasterSlaveDeterminationRelease(struct OOH323CallData * call);
532
533 /**
534 * This function is used to send a terminal capability set reject message
535 * to the remote endpoint.
536 * @param call Handle to the call for which reject message has to
537 * be sent.
538 * @param seqNo Sequence number of the TCS message to be rejected.
539 * @param cause Cause for rejecting a TCS message.
540 *
541 * @return OO_OK, on success; OO_FAILED, otherwise.
542 */
543 int ooSendTerminalCapabilitySetReject
544 (struct OOH323CallData *call, int seqNo, ASN1UINT cause);
545
546 /**
547 * This function is used to send a TerminalCapabilitySetRelease message after
548 * capability exchange timer has expired.
549 * @param call Handle to call for which release message has to be
550 * sent.
551 *
552 * @return OO_OK, on success; OO_FAILED, on failure.
553 */
554 int ooSendTerminalCapabilitySetRelease(struct OOH323CallData * call);
555
556 int ooSendRequestMode(OOH323CallData* call, int isT38Mode);
557
558
559 /**
560 * This is an helper function used to extract ip address and port info from
561 * H245TransportAddress structure.
562 * @param call Handle to associated call.
563 * @param h245Address Handle to H245TransportAddress structure from which
564 * information has to be extracted.
565 * @param ip Pointer to buffer in which ip address will be
566 * returned. Make sure that buffer has sufficient length.
567 * @param port Pointer to integer in which port number will be
568 * returned.
569 *
570 * @return OO_OK, on success. OO_FAILED, on failure.
571 */
572 int ooGetIpPortFromH245TransportAddress
573 (OOH323CallData *call, H245TransportAddress *h245Address, char *ip,
574 int *port);
575
576 /**
577 * This is a callback function for handling an expired master-slave
578 * determination timer.
579 * @param data Callback data registered at the time of creation of
580 * the timer.
581 *
582 * @return OO_OK, on success. OO_FAILED, otherwise.
583 */
584 int ooMSDTimerExpired(void *data);
585
586 /**
587 * This is a callback function for handling an expired capability exchange
588 * timer.
589 * @param data Callback data registered at the time of creation of
590 * the timer.
591 *
592 * @return OO_OK, on success. OO_FAILED, otherwise.
593 */
594 int ooTCSTimerExpired(void *data);
595
596 /**
597 * This is a callback function for handling an expired OpenLogicalChannel
598 * timer.
599 * @param pdata Callback data registered at the time of creation of
600 * the timer.
601 *
602 * @return OO_OK, on success. OO_FAILED, otherwise.
603 */
604 int ooOpenLogicalChannelTimerExpired(void *pdata);
605
606 /**
607 * This is a callback function for handling an expired CloseLogicalChannel
608 * timer.
609 * @param pdata Callback data registered at the time of creation of
610 * the timer.
611 *
612 * @return OO_OK, on success. OO_FAILED, otherwise.
613 */
614 int ooCloseLogicalChannelTimerExpired(void *pdata);
615
616 /**
617 * This is a callback function for handling an expired RequestChannelClose
618 * timer.
619 * @param pdata Callback data registered at the time of creation of
620 * the timer.
621 *
622 * @return OO_OK, on success. OO_FAILED, otherwise.
623 */
624 int ooRequestChannelCloseTimerExpired(void *pdata);
625
626 /**
627 * This is a callback function for handling an expired EndSession timer.
628 * @param pdata Callback data registered at the time of creation of
629 * the timer.
630 *
631 * @return OO_OK, on success. OO_FAILED, otherwise.
632 */
633 int ooSessionTimerExpired(void *pdata);
634 /**
635 * @}
636 */
637 int ooRTDTimerExpired(void *pdata);
638
639 int ooHandleRequestMode(OOH323CallData* call,
640 H245RequestMode *requestMode);
641
642 int ooSendRequestModeAck(OOH323CallData* call,
643 H245SequenceNumber sequenceNumber);
644
645 int ooSendRequestModeReject(OOH323CallData* call,
646 H245SequenceNumber sequenceNumber);
647
648 void ooOnReceivedRequestModeAck(OOH323CallData* call, H245RequestModeAck * requestModeAck);
649
650 int ooOnReceivedRoundTripDelayRequest(OOH323CallData *call,
651 H245SequenceNumber sequenceNumber);
652
653 int ooSendRoundTripDelayRequest(OOH323CallData *call);
654
655
656 #ifdef __cplusplus
657 }
658 #endif
659
660 #endif