2003-03-31 07:13:36 +00:00
|
|
|
/*
|
2003-06-20 06:03:34 +00:00
|
|
|
* chan_h323.h
|
2003-03-31 07:13:36 +00:00
|
|
|
*
|
|
|
|
* OpenH323 Channel Driver for ASTERISK PBX.
|
|
|
|
* By Jeremy McNamara
|
|
|
|
* For The NuFone Network
|
2006-09-19 17:07:22 +00:00
|
|
|
*
|
|
|
|
* This code has been derived from code created by
|
2003-03-31 07:13:36 +00:00
|
|
|
* Michael Manousos and Mark Spencer
|
|
|
|
*
|
2004-03-04 01:57:32 +00:00
|
|
|
* This file is part of the chan_h323 driver for Asterisk
|
2003-03-31 07:13:36 +00:00
|
|
|
*
|
2003-05-12 00:55:52 +00:00
|
|
|
* chan_h323 is free software; you can redistribute it and/or modify
|
2003-03-31 07:13:36 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2006-09-19 17:07:22 +00:00
|
|
|
* (at your option) any later version.
|
2003-03-31 07:13:36 +00:00
|
|
|
*
|
2006-09-19 17:07:22 +00:00
|
|
|
* chan_h323 is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2003-03-31 07:13:36 +00:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-09-19 17:07:22 +00:00
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2003-03-31 07:13:36 +00:00
|
|
|
*
|
2003-08-25 18:34:10 +00:00
|
|
|
* Version Info: $Id$
|
2003-03-31 07:13:36 +00:00
|
|
|
*/
|
|
|
|
|
2009-02-18 20:11:57 +00:00
|
|
|
#ifndef CHAN_H323_H
|
|
|
|
#define CHAN_H323_H
|
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
#include <arpa/inet.h>
|
2011-02-03 16:22:10 +00:00
|
|
|
#include "asterisk/format.h"
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2006-09-19 17:07:22 +00:00
|
|
|
/*
|
|
|
|
* Enable support for sending/reception of tunnelled Q.SIG messages and
|
|
|
|
* some sort of IEs (especially RedirectingNumber) which Cisco CallManager
|
|
|
|
* isn't like to pass in standard Q.931 message.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define TUNNELLING
|
|
|
|
|
|
|
|
#define H323_TUNNEL_CISCO (1 << 0)
|
|
|
|
#define H323_TUNNEL_QSIG (1 << 1)
|
|
|
|
|
2006-09-28 10:41:38 +00:00
|
|
|
#define H323_HOLD_NOTIFY (1 << 0)
|
|
|
|
#define H323_HOLD_Q931ONLY (1 << 1)
|
|
|
|
#define H323_HOLD_H450 (1 << 2)
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
typedef int64_t h323_format;
|
|
|
|
|
2004-12-15 23:24:13 +00:00
|
|
|
/** call_option struct holds various bits
|
|
|
|
* of information for each call */
|
|
|
|
typedef struct call_options {
|
2005-05-02 18:46:36 +00:00
|
|
|
char cid_num[80];
|
|
|
|
char cid_name[80];
|
2006-09-19 17:07:22 +00:00
|
|
|
char cid_rdnis[80];
|
|
|
|
int redirect_reason;
|
2006-09-29 18:35:44 +00:00
|
|
|
int presentation;
|
|
|
|
int type_of_number;
|
2006-10-07 14:48:32 +00:00
|
|
|
int transfer_capability;
|
2006-09-19 17:07:22 +00:00
|
|
|
int fastStart;
|
|
|
|
int h245Tunneling;
|
|
|
|
int silenceSuppression;
|
2005-05-02 18:46:36 +00:00
|
|
|
int progress_setup;
|
|
|
|
int progress_alert;
|
|
|
|
int progress_audio;
|
2006-09-25 09:03:14 +00:00
|
|
|
int dtmfcodec[2];
|
2005-05-21 17:09:30 +00:00
|
|
|
int dtmfmode;
|
2011-02-03 16:22:10 +00:00
|
|
|
h323_format capability;
|
2005-05-21 17:09:30 +00:00
|
|
|
int bridge;
|
|
|
|
int nat;
|
2006-09-19 17:07:22 +00:00
|
|
|
int tunnelOptions;
|
2006-09-28 10:41:38 +00:00
|
|
|
int holdHandling;
|
2009-04-22 19:23:49 +00:00
|
|
|
int autoframing; /*!< turn on to override local settings with remote framing length */
|
2006-09-19 17:07:22 +00:00
|
|
|
struct ast_codec_pref prefs;
|
2004-12-15 23:24:13 +00:00
|
|
|
} call_options_t;
|
2004-03-04 01:57:32 +00:00
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
/* structure to hold the valid asterisk users */
|
|
|
|
struct oh323_user {
|
2006-09-19 17:07:22 +00:00
|
|
|
ASTOBJ_COMPONENTS(struct oh323_user);
|
|
|
|
// char name[80];
|
2003-03-31 07:13:36 +00:00
|
|
|
char context[80];
|
|
|
|
char secret[80];
|
2005-05-25 17:18:05 +00:00
|
|
|
char accountcode[AST_MAX_ACCOUNT_CODE];
|
2003-03-31 07:13:36 +00:00
|
|
|
int amaflags;
|
2003-03-31 20:26:08 +00:00
|
|
|
int host;
|
2003-03-31 07:13:36 +00:00
|
|
|
struct sockaddr_in addr;
|
2005-05-21 17:09:30 +00:00
|
|
|
struct ast_ha *ha;
|
|
|
|
call_options_t options;
|
2003-03-31 07:13:36 +00:00
|
|
|
};
|
|
|
|
|
2006-09-19 17:07:22 +00:00
|
|
|
/* structure to hold the valid asterisk peers
|
2003-03-31 07:13:36 +00:00
|
|
|
All peers are registered to a GK if there is one */
|
|
|
|
struct oh323_peer {
|
2006-09-19 17:07:22 +00:00
|
|
|
ASTOBJ_COMPONENTS(struct oh323_peer);
|
2004-10-04 10:18:06 +00:00
|
|
|
char mailbox[80];
|
2003-03-31 07:13:36 +00:00
|
|
|
int delme;
|
2004-07-17 19:38:30 +00:00
|
|
|
struct sockaddr_in addr;
|
2004-09-30 19:30:49 +00:00
|
|
|
struct ast_ha *ha;
|
2004-12-15 23:24:13 +00:00
|
|
|
call_options_t options;
|
2003-03-31 07:13:36 +00:00
|
|
|
};
|
|
|
|
|
2006-09-19 17:07:22 +00:00
|
|
|
/* structure to hold the H.323 aliases which get registered to
|
2003-03-31 07:13:36 +00:00
|
|
|
the H.323 endpoint and gatekeeper */
|
|
|
|
struct oh323_alias {
|
2006-09-19 17:07:22 +00:00
|
|
|
ASTOBJ_COMPONENTS(struct oh323_alias);
|
2003-03-31 07:13:36 +00:00
|
|
|
char e164[20]; /* tells a GK to route this E.164 to this alias */
|
|
|
|
char prefix[500]; /* tells a GK this alias supports these prefixes */
|
|
|
|
char secret[20]; /* the H.235 password to send to the GK for authentication */
|
|
|
|
char context[80];
|
|
|
|
};
|
|
|
|
|
2006-09-19 17:07:22 +00:00
|
|
|
/** call_details struct call detail records
|
|
|
|
to asterisk for processing and used for matching up
|
2003-03-31 07:13:36 +00:00
|
|
|
asterisk channels to acutal h.323 connections */
|
2006-09-19 17:07:22 +00:00
|
|
|
typedef struct call_details {
|
2003-03-31 07:13:36 +00:00
|
|
|
unsigned int call_reference;
|
2006-09-19 17:07:22 +00:00
|
|
|
char *call_token;
|
2004-07-21 00:49:06 +00:00
|
|
|
char *call_source_aliases;
|
|
|
|
char *call_dest_alias;
|
|
|
|
char *call_source_name;
|
|
|
|
char *call_source_e164;
|
|
|
|
char *call_dest_e164;
|
2006-09-19 17:07:22 +00:00
|
|
|
char *redirect_number;
|
|
|
|
int redirect_reason;
|
2004-12-21 00:07:56 +00:00
|
|
|
int presentation;
|
2006-09-29 18:35:44 +00:00
|
|
|
int type_of_number;
|
2006-10-07 14:48:32 +00:00
|
|
|
int transfer_capability;
|
2004-07-21 00:49:06 +00:00
|
|
|
char *sourceIp;
|
2003-03-31 07:13:36 +00:00
|
|
|
} call_details_t;
|
|
|
|
|
2003-08-25 18:34:10 +00:00
|
|
|
typedef struct rtp_info {
|
2005-05-03 15:47:35 +00:00
|
|
|
char addr[32];
|
2003-08-25 18:34:10 +00:00
|
|
|
unsigned int port;
|
|
|
|
} rtp_info_t;
|
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
/* This is a callback prototype function, called pass
|
|
|
|
DTMF down the RTP. */
|
2006-09-19 17:07:22 +00:00
|
|
|
typedef int (*receive_digit_cb)(unsigned, char, const char *, int);
|
|
|
|
extern receive_digit_cb on_receive_digit;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
|
|
|
/* This is a callback prototype function, called to collect
|
|
|
|
the external RTP port from Asterisk. */
|
2004-10-10 12:20:18 +00:00
|
|
|
typedef rtp_info_t *(*on_rtp_cb)(unsigned, const char *);
|
2006-09-19 17:07:22 +00:00
|
|
|
extern on_rtp_cb on_external_rtp_create;
|
2004-10-10 12:20:18 +00:00
|
|
|
|
|
|
|
/* This is a callback prototype function, called to send
|
2006-09-19 17:07:22 +00:00
|
|
|
the remote IP and RTP port from H.323 to Asterisk */
|
2004-12-21 00:07:56 +00:00
|
|
|
typedef void (*start_rtp_cb)(unsigned int, const char *, int, const char *, int);
|
2006-09-19 17:07:22 +00:00
|
|
|
extern start_rtp_cb on_start_rtp_channel;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2004-12-15 23:24:13 +00:00
|
|
|
/* This is a callback that happens when call progress is
|
|
|
|
* made, and handles inband progress */
|
|
|
|
typedef int (*progress_cb)(unsigned, const char *, int);
|
|
|
|
extern progress_cb on_progress;
|
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
/* This is a callback prototype function, called upon
|
|
|
|
an incoming call happens. */
|
2005-05-19 16:17:08 +00:00
|
|
|
typedef call_options_t *(*setup_incoming_cb)(call_details_t *);
|
2004-10-10 12:20:18 +00:00
|
|
|
extern setup_incoming_cb on_incoming_call;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
|
|
|
/* This is a callback prototype function, called upon
|
|
|
|
an outbound call. */
|
2005-05-19 16:17:08 +00:00
|
|
|
typedef int (*setup_outbound_cb)(call_details_t *);
|
2006-09-19 17:07:22 +00:00
|
|
|
extern setup_outbound_cb on_outgoing_call;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2004-10-23 02:43:41 +00:00
|
|
|
/* This is a callback prototype function, called when
|
2004-05-20 07:07:18 +00:00
|
|
|
OnAlerting is invoked */
|
2004-09-19 16:53:01 +00:00
|
|
|
typedef void (*chan_ringing_cb)(unsigned, const char *);
|
2004-10-10 12:20:18 +00:00
|
|
|
extern chan_ringing_cb on_chan_ringing;
|
2004-05-20 07:07:18 +00:00
|
|
|
|
2004-10-23 02:43:41 +00:00
|
|
|
/* This is a callback protoype function, called when
|
2003-03-31 07:13:36 +00:00
|
|
|
OnConnectionEstablished is inovked */
|
2004-09-19 16:53:01 +00:00
|
|
|
typedef void (*con_established_cb)(unsigned, const char *);
|
2004-10-10 12:20:18 +00:00
|
|
|
extern con_established_cb on_connection_established;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2004-10-23 02:43:41 +00:00
|
|
|
/* This is a callback prototype function, called when
|
2003-03-31 07:13:36 +00:00
|
|
|
OnConnectionCleared callback is invoked */
|
2005-05-19 16:17:08 +00:00
|
|
|
typedef void (*clear_con_cb)(unsigned, const char *);
|
2004-10-10 12:20:18 +00:00
|
|
|
extern clear_con_cb on_connection_cleared;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2004-10-23 02:43:41 +00:00
|
|
|
/* This is a callback prototype function, called when
|
2006-09-19 17:07:22 +00:00
|
|
|
an H.323 call is answered */
|
2004-09-19 16:53:01 +00:00
|
|
|
typedef int (*answer_call_cb)(unsigned, const char *);
|
2004-10-10 12:20:18 +00:00
|
|
|
extern answer_call_cb on_answer_call;
|
2004-06-15 20:56:06 +00:00
|
|
|
|
2004-12-15 23:24:13 +00:00
|
|
|
/* This is a callback prototype function, called when
|
|
|
|
we know which RTP payload type RFC2833 will be
|
|
|
|
transmitted */
|
2006-09-25 09:03:14 +00:00
|
|
|
typedef void (*rfc2833_cb)(unsigned, const char *, int, int);
|
2004-12-15 23:24:13 +00:00
|
|
|
extern rfc2833_cb on_set_rfc2833_payload;
|
|
|
|
|
2005-04-04 07:06:26 +00:00
|
|
|
typedef void (*hangup_cb)(unsigned, const char *, int);
|
|
|
|
extern hangup_cb on_hangup;
|
|
|
|
|
2005-05-19 19:13:19 +00:00
|
|
|
typedef void (*setcapabilities_cb)(unsigned, const char *);
|
|
|
|
extern setcapabilities_cb on_setcapabilities;
|
|
|
|
|
2006-09-20 16:24:00 +00:00
|
|
|
typedef void (*setpeercapabilities_cb)(unsigned, const char *, int, struct ast_codec_pref *);
|
2006-09-19 17:07:22 +00:00
|
|
|
extern setpeercapabilities_cb on_setpeercapabilities;
|
|
|
|
|
2006-09-28 10:41:38 +00:00
|
|
|
typedef void (*onhold_cb)(unsigned, const char *, int);
|
|
|
|
extern onhold_cb on_hold;
|
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
/* debug flag */
|
2004-06-26 03:50:14 +00:00
|
|
|
extern int h323debug;
|
2003-03-31 07:13:36 +00:00
|
|
|
|
|
|
|
#define H323_DTMF_RFC2833 (1 << 0)
|
2006-09-25 09:03:14 +00:00
|
|
|
#define H323_DTMF_CISCO (1 << 1)
|
|
|
|
#define H323_DTMF_SIGNAL (1 << 2)
|
|
|
|
#define H323_DTMF_INBAND (1 << 3)
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2006-09-24 18:12:35 +00:00
|
|
|
#define H323_DTMF_RFC2833_PT 101
|
|
|
|
#define H323_DTMF_CISCO_PT 121
|
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2006-09-19 17:07:22 +00:00
|
|
|
#endif
|
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
void h323_gk_urq(void);
|
2004-10-04 10:18:06 +00:00
|
|
|
void h323_end_point_create(void);
|
2003-03-31 07:13:36 +00:00
|
|
|
void h323_end_process(void);
|
2003-12-18 19:54:18 +00:00
|
|
|
int h323_end_point_exist(void);
|
2006-09-19 17:07:22 +00:00
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
void h323_debug(int, unsigned);
|
|
|
|
|
|
|
|
/* callback function handler*/
|
2006-09-19 17:07:22 +00:00
|
|
|
void h323_callback_register(setup_incoming_cb,
|
|
|
|
setup_outbound_cb,
|
|
|
|
on_rtp_cb,
|
|
|
|
start_rtp_cb,
|
|
|
|
clear_con_cb,
|
|
|
|
chan_ringing_cb,
|
|
|
|
con_established_cb,
|
|
|
|
receive_digit_cb,
|
|
|
|
answer_call_cb,
|
|
|
|
progress_cb,
|
|
|
|
rfc2833_cb,
|
|
|
|
hangup_cb,
|
|
|
|
setcapabilities_cb,
|
2006-09-28 10:41:38 +00:00
|
|
|
setpeercapabilities_cb,
|
|
|
|
onhold_cb);
|
2006-09-19 17:07:22 +00:00
|
|
|
int h323_set_capabilities(const char *, int, int, struct ast_codec_pref *, int);
|
2003-03-31 07:13:36 +00:00
|
|
|
int h323_set_alias(struct oh323_alias *);
|
|
|
|
int h323_set_gk(int, char *, char *);
|
2003-06-03 07:11:52 +00:00
|
|
|
void h323_set_id(char *);
|
2004-01-06 16:43:24 +00:00
|
|
|
void h323_show_tokens(void);
|
2009-03-17 20:47:31 +00:00
|
|
|
void h323_show_version(void);
|
2003-06-03 07:11:52 +00:00
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
/* H323 listener related funcions */
|
2003-05-31 18:42:09 +00:00
|
|
|
int h323_start_listener(int, struct sockaddr_in);
|
2003-03-31 07:13:36 +00:00
|
|
|
|
2004-07-22 04:24:50 +00:00
|
|
|
void h323_native_bridge(const char *, const char *, char *);
|
2003-03-31 07:13:36 +00:00
|
|
|
|
|
|
|
/* Send a DTMF tone to remote endpoint */
|
|
|
|
void h323_send_tone(const char *call_token, char tone);
|
|
|
|
|
|
|
|
/* H323 create and destroy sessions */
|
2004-12-15 23:24:13 +00:00
|
|
|
int h323_make_call(char *dest, call_details_t *cd, call_options_t *);
|
|
|
|
int h323_clear_call(const char *, int cause);
|
2006-09-19 17:07:22 +00:00
|
|
|
|
2004-05-20 07:07:18 +00:00
|
|
|
/* H.323 alerting and progress */
|
|
|
|
int h323_send_alerting(const char *token);
|
|
|
|
int h323_send_progress(const char *token);
|
2003-03-31 07:13:36 +00:00
|
|
|
int h323_answering_call(const char *token, int);
|
2006-09-19 17:07:22 +00:00
|
|
|
int h323_soft_hangup(const char *data);
|
2003-03-31 07:13:36 +00:00
|
|
|
int h323_show_codec(int fd, int argc, char *argv[]);
|
2006-09-28 10:41:38 +00:00
|
|
|
int h323_hold_call(const char *token, int);
|
2004-09-21 18:42:37 +00:00
|
|
|
|
2003-03-31 07:13:36 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2009-02-18 20:11:57 +00:00
|
|
|
|
|
|
|
#endif
|