Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/options.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/causes.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/manager.h"
#include "asterisk/dsp.h"
#include "asterisk/stringfields.h"
#include "asterisk/format.h"
#include "asterisk/format_cap.h"
#include "asterisk/udptl.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
#include "asterisk/paths.h"
#include "ootypes.h"
#include "ooUtils.h"
#include "ooCapability.h"
#include "oochannels.h"
#include "ooh323ep.h"
#include "ooh323cDriver.h"
#include "ooCalls.h"
#include "ooq931.h"
#include "ooStackCmds.h"
#include "ooGkClient.h"
Go to the source code of this file.
Functions | |
void | close_rtp_connection (ooCallData *call) |
void | close_udptl_connection (ooCallData *call) |
int | configure_local_rtp (struct ooh323_pvt *p, ooCallData *call) |
int | delete_peers (void) |
int | delete_users (void) |
struct ooh323_peer * | find_peer (const char *name, int port) |
struct ooh323_user * | find_user (const char *name, const char *ip) |
EXTERN char * | handle_cli_ooh323_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
int | ooh323_convert_hangupcause_asteriskToH323 (int cause) |
int | ooh323_convert_hangupcause_h323ToAsterisk (int cause) |
int | ooh323_convertAsteriskCapToH323Cap (struct ast_format *format) |
void | ooh323_delete_peer (struct ooh323_peer *peer) |
int | ooh323_destroy (struct ooh323_pvt *p) |
int | ooh323_onReceivedDigit (OOH323CallData *call, const char *digit) |
int | ooh323_onReceivedSetup (ooCallData *call, Q931Message *pmsg) |
struct ast_frame * | ooh323_rtp_read (struct ast_channel *ast, struct ooh323_pvt *p) |
void | ooh323_set_read_format (ooCallData *call, struct ast_format *fmt) |
void | ooh323_set_write_format (ooCallData *call, struct ast_format *fmt, int txframes) |
int | reload_config (int reload) |
int | restart_monitor (void) |
void | setup_rtp_connection (ooCallData *call, const char *remoteIp, int remotePort) |
void | setup_udptl_connection (ooCallData *call, const char *remoteIp, int remotePort) |
int | update_our_aliases (ooCallData *call, struct ooh323_pvt *p) |
void close_rtp_connection | ( | ooCallData * | call | ) |
Definition at line 4810 of file chan_ooh323.c.
References ast_log, ast_mutex_lock, ast_mutex_unlock, ast_rtp_instance_stop(), ast_verb, call(), find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, and ooh323_pvt::rtp.
Referenced by ooh323c_stop_transmit_channel().
void close_udptl_connection | ( | ooCallData * | call | ) |
Definition at line 4901 of file chan_ooh323.c.
References ast_channel_trylock, ast_channel_unlock, AST_CONTROL_T38_PARAMETERS, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_queue_control_data(), AST_T38_TERMINATED, ast_verb, call(), DEADLOCK_AVOIDANCE, find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, ooh323_pvt::owner, ast_control_t38_parameters::request_response, T38_ENABLED, ooh323_pvt::t38_tx_enable, and ooh323_pvt::t38support.
Referenced by ooh323c_stop_transmit_datachannel().
int configure_local_rtp | ( | struct ooh323_pvt * | p, |
ooCallData * | call | ||
) |
Definition at line 4599 of file chan_ooh323.c.
References ao2_ref, ast_channel_set_fd(), ast_channel_trylock, ast_channel_unlock, ast_copy_string(), ast_debug, ast_format_cap_count(), ast_format_cap_get_format(), ast_format_cap_get_framing(), ast_log, ast_mutex_unlock, ast_parse_arg(), ast_rtp_codecs_payloads_set_rtpmap_type(), ast_rtp_codecs_set_framing(), ast_rtp_instance_fd(), ast_rtp_instance_get_codecs(), ast_rtp_instance_get_local_address(), ast_rtp_instance_new(), ast_rtp_instance_set_prop(), ast_rtp_instance_set_qos(), ast_rtp_instance_set_timeout(), AST_RTP_PROPERTY_DTMF, AST_RTP_PROPERTY_NAT, AST_RTP_PROPERTY_RTCP, ast_sockaddr_copy(), ast_sockaddr_port, ast_sockaddr_stringify_addr(), ast_udptl_fd(), ast_udptl_get_us(), ast_udptl_new_with_bindaddr(), ast_udptl_set_far_max_datagram(), ast_verb, bindaddr, call(), ooh323_pvt::cap, DEADLOCK_AVOIDANCE, ooh323_pvt::dtmfcodec, ooh323_pvt::dtmfmode, errno, gH323Debug, gTOS, H323_DTMF_CISCO, H323_DTMF_RFC2833, io, ooh323_pvt::lock, LOG_ERROR, LOG_WARNING, ooh323_pvt::nat, NULL, ooh323_convertAsteriskCapToH323Cap(), ooh323_pvt::owner, PARSE_ADDR, ooh323_pvt::rtdrcount, ooh323_pvt::rtdrinterval, ooh323_pvt::rtp, ooh323_pvt::rtptimeout, tmp(), and ooh323_pvt::udptl.
Referenced by onNewCallCreated(), onOutgoingCall(), and ooh323_onReceivedSetup().
int delete_peers | ( | void | ) |
Definition at line 4230 of file chan_ooh323.c.
References ast_free, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_peer_list::lock, ooh323_peer::next, NULL, peerl, and ast_peer_list::peers.
Referenced by reload_config(), and unload_module().
int delete_users | ( | void | ) |
Definition at line 4265 of file chan_ooh323.c.
References ao2_cleanup, ast_free, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_user_list::lock, ooh323_user::next, NULL, userl, and ast_user_list::users.
Referenced by reload_config(), and unload_module().
struct ooh323_peer * find_peer | ( | const char * | name, |
int | port | ||
) |
Definition at line 890 of file chan_ooh323.c.
References ast_mutex_lock, ast_mutex_unlock, ast_verb, ooh323_peer::e164, gH323Debug, ooh323_peer::h323id, ooh323_peer::ip, ast_peer_list::lock, ooh323_peer::name, name, ooh323_peer::next, peerl, and ast_peer_list::peers.
Referenced by ooh323_request().
struct ooh323_user * find_user | ( | const char * | name, |
const char * | ip | ||
) |
Definition at line 832 of file chan_ooh323.c.
References ast_mutex_lock, ast_mutex_unlock, ast_verb, gH323Debug, ast_user_list::lock, name, user, userl, and ast_user_list::users.
Referenced by ooh323_destroy(), and ooh323_onReceivedSetup().
EXTERN char * handle_cli_ooh323_reload | ( | struct ast_cli_entry * | e, |
int | cmd, | ||
struct ast_cli_args * | a | ||
) |
Definition at line 2778 of file chan_ooh323.c.
References a, ast_mutex_lock, ast_mutex_unlock, ast_verb, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, gH323Debug, h323_reload_lock, h323_reloading, NULL, restart_monitor(), and ast_cli_entry::usage.
int ooh323_convert_hangupcause_asteriskToH323 | ( | int | cause | ) |
Definition at line 5179 of file chan_ooh323.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_BUSY, AST_CAUSE_CALL_REJECTED, AST_CAUSE_CONGESTION, AST_CAUSE_FAILURE, AST_CAUSE_NO_ANSWER, AST_CAUSE_NORMAL, and AST_CAUSE_UNALLOCATED.
Referenced by ooh323_hangup(), and ooh323_onReceivedSetup().
int ooh323_convert_hangupcause_h323ToAsterisk | ( | int | cause | ) |
Definition at line 5206 of file chan_ooh323.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_BUSY, AST_CAUSE_CALL_REJECTED, AST_CAUSE_CONGESTION, AST_CAUSE_FAILURE, AST_CAUSE_NO_ANSWER, AST_CAUSE_NORMAL, and AST_CAUSE_UNALLOCATED.
int ooh323_convertAsteriskCapToH323Cap | ( | struct ast_format * | format | ) |
Definition at line 4506 of file chan_ooh323.c.
References ast_format_alaw, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g723, ast_format_g726, ast_format_g726_aal2, ast_format_g729, ast_format_get_name(), ast_format_gsm, ast_format_h263, ast_format_speex, ast_format_ulaw, ast_log, and LOG_NOTICE.
Referenced by configure_local_rtp(), and ooh323_set_rtp_peer().
void ooh323_delete_peer | ( | struct ooh323_peer * | peer | ) |
Definition at line 2328 of file chan_ooh323.c.
References ao2_cleanup, ast_free, ast_mutex_lock, ast_mutex_unlock, ast_verb, ooh323_peer::cap, ooh323_peer::e164, ooh323_peer::email, gH323Debug, ooh323_peer::h323id, ast_peer_list::lock, ooh323_peer::next, NULL, peerl, ast_peer_list::peers, and ooh323_peer::url.
Referenced by build_peer().
int ooh323_destroy | ( | struct ooh323_pvt * | p | ) |
Definition at line 4117 of file chan_ooh323.c.
References ao2_cleanup, ast_channel_name(), ast_channel_tech_pvt_set(), ast_channel_trylock, ast_channel_unlock, ast_debug, ast_dsp_free(), ast_free, ast_module_unref, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_rtp_instance_destroy(), ast_rtp_instance_stop(), ast_test_flag, ast_udptl_destroy(), ast_verb, ooh323_pvt::callerid_name, DEADLOCK_AVOIDANCE, find_user(), gH323Debug, H323_OUTGOING, iflist, myself, ooh323_pvt::next, NULL, and ooh323_pvt::username.
Referenced by do_monitor(), ooh323_request(), and unload_module().
int ooh323_onReceivedDigit | ( | OOH323CallData * | call, |
const char * | digit | ||
) |
Callback for sending digits from H.323 up to asterisk
Definition at line 1798 of file chan_ooh323.c.
References ast_channel_trylock, ast_channel_unlock, ast_debug, AST_FRAME_DTMF, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_queue_frame(), call(), ast_frame::data, ast_frame::datalen, DEADLOCK_AVOIDANCE, digit, find_call(), ast_frame::frametype, ast_frame_subclass::integer, ooh323_pvt::lock, LOG_ERROR, ast_frame::mallocd, NULL, ast_frame::offset, ooh323_pvt::owner, ast_frame::ptr, ast_frame::samples, ast_frame::src, and ast_frame::subclass.
Referenced by load_module().
int ooh323_onReceivedSetup | ( | ooCallData * | call, |
Q931Message * | pmsg | ||
) |
Definition at line 1840 of file chan_ooh323.c.
References ooh323_pvt::accountcode, ooh323_pvt::amaflags, ooh323_pvt::aniasdni, AST_CAUSE_CALL_REJECTED, AST_CAUSE_NORMAL_CIRCUIT_CONGESTION, ast_clear_flag, ast_copy_string(), ast_format_cap_append_from_cap(), ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_mutex_lock, ast_mutex_unlock, ast_set_flag, AST_STATE_RING, ast_strdup, ast_strlen_zero(), ast_verb, c, call(), ooh323_pvt::callee_dialedDigits, ooh323_pvt::callee_email, ooh323_pvt::callee_h323id, ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_email, ooh323_pvt::caller_h323id, ooh323_pvt::caller_url, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, ooh323_pvt::cap, configure_local_rtp(), ooh323_pvt::context, ooh323_pvt::directrtp, ooh323_pvt::dtmfcodec, ooh323_pvt::dtmfmode, ooh323_pvt::earlydirect, ooh323_pvt::exten, ooh323_pvt::faststart, ooh323_pvt::faxdetect, find_user(), ooh323_pvt::flags, ooh323_pvt::g729onlyA, gDirectRTP, gEarlyDirect, gH323Debug, ooh323_pvt::h245tunneling, H323_DISABLEGK, H323_NEEDDESTROY, H323_OUTGOING, ooh323_pvt::lock, LOG_ERROR, ooh323_pvt::nat, ooh323_pvt::neighbor, NULL, ooh323_alloc(), ooh323_convert_hangupcause_asteriskToH323(), ooh323_new(), ooh323c_set_capability_for_call(), ooh323_pvt::rtdrcount, ooh323_pvt::rtdrinterval, ooh323_pvt::rtpmask, ooh323_pvt::rtpmaskstr, ooh323_pvt::rtptimeout, ooh323_pvt::t38support, update_our_aliases(), ooh323_pvt::user, and ooh323_pvt::username.
Referenced by load_module().
struct ast_frame * ooh323_rtp_read | ( | struct ast_channel * | ast, |
struct ooh323_pvt * | p | ||
) |
Definition at line 4978 of file chan_ooh323.c.
References ao2_ref, ast_async_goto(), ast_channel_caller(), ast_channel_context(), ast_channel_exten(), ast_channel_fdno(), ast_channel_name(), ast_channel_nativeformats(), ast_channel_nativeformats_set(), ast_channel_readformat(), ast_channel_writeformat(), ast_debug, ast_dsp_process(), ast_exists_extension(), ast_format_alaw, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_iscompatible_format(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_name(), ast_format_slin, ast_format_ulaw, AST_FRAME_DTMF, AST_FRAME_NULL, AST_FRAME_VOICE, ast_frdup, ast_frfree, ast_log, ast_null_frame, ast_rtp_instance_read(), ast_set_read_format(), ast_set_write_format(), ast_udptl_read(), ast_verb, ooh323_pvt::callToken, ooh323_pvt::chmodepend, ast_frame::datalen, ooh323_pvt::dtmfmode, ooh323_pvt::faxdetect, FAXDETECT_CNG, ooh323_pvt::faxdetected, ooh323_pvt::faxmode, ast_frame_subclass::format, ast_frame::frametype, gH323Debug, H323_DTMF_INBAND, ast_party_caller::id, ast_frame_subclass::integer, ooh323_pvt::lastrtprx, LOG_NOTICE, NULL, ast_party_id::number, ooh323_pvt::owner, pbx_builtin_setvar_helper(), ooh323_pvt::rtp, S_COR, ast_party_number::str, ast_frame::subclass, T38_DISABLED, ooh323_pvt::t38support, ooh323_pvt::udptl, ooh323_pvt::vad, ast_party_number::valid, and ooh323_pvt::vrtp.
Referenced by ooh323_read().
void ooh323_set_read_format | ( | ooCallData * | call, |
struct ast_format * | fmt | ||
) |
Definition at line 1625 of file chan_ooh323.c.
References ao2_ref, ao2_replace, ast_channel_nativeformats_set(), ast_channel_readformat(), ast_channel_trylock, ast_channel_unlock, ast_debug, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_get_name(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_set_read_format(), ast_verb, call(), DEADLOCK_AVOIDANCE, find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, ooh323_pvt::owner, and ooh323_pvt::readformat.
void ooh323_set_write_format | ( | ooCallData * | call, |
struct ast_format * | fmt, | ||
int | txframes | ||
) |
Definition at line 1553 of file chan_ooh323.c.
References ao2_ref, ao2_replace, ast_channel_nativeformats(), ast_channel_nativeformats_set(), ast_channel_readformat(), ast_channel_trylock, ast_channel_unlock, ast_channel_writeformat(), ast_debug, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cap_set_framing(), ast_format_get_name(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_rtp_codecs_payloads_set_rtpmap_type(), ast_rtp_instance_get_codecs(), ast_set_read_format(), ast_set_write_format(), ast_str_alloca, ast_verb, call(), DEADLOCK_AVOIDANCE, ooh323_pvt::dtmfcodec, ooh323_pvt::dtmfmode, find_call(), gH323Debug, H323_DTMF_CISCO, H323_DTMF_RFC2833, ooh323_pvt::lock, LOG_ERROR, NULL, ooh323_pvt::owner, ooh323_pvt::rtp, and ooh323_pvt::writeformat.
Referenced by ooh323c_start_transmit_channel().
int reload_config | ( | int | reload | ) |
Definition at line 2813 of file chan_ooh323.c.
References ast_calloc, ast_category_browse(), ast_channel_string2amaflag(), ast_config_AST_LOG_DIR, ast_config_destroy(), ast_config_load, ast_copy_string(), ast_false(), ast_format_cap_append, ast_format_cap_remove_by_type(), ast_format_cap_update_by_allow_disallow(), ast_format_ulaw, ast_free, ast_jb_read_conf(), ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_mutex_lock, ast_mutex_unlock, ast_parse_arg(), ast_sockaddr_is_ipv6(), ast_strdup, ast_strdupa, ast_strlen_zero(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verb, bindaddr, buf, build_peer(), build_user(), config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEUNCHANGED, DEFAULT_CONTEXT, DEFAULT_H323ACCNT, DEFAULT_H323ID, default_jbconf, DEFAULT_LOGFILE, delete_peers(), delete_users(), FALSE, FAXDETECT_CNG, FAXDETECT_T38, g729onlyA, gAccountcode, gAliasList, gAMAFLAGS, gANIasDNI, gBeMaster, gCallerID, gCap, gContext, gDirectRTP, gDTMFCodec, gDTMFMode, gEarlyDirect, gFastStart, gFAXdetect, gGatekeeper, gH323Debug, gIncomingLimit, gIP, gIsGateway, global_jbconf, gLogFile, gMediaWaitForConnect, gNat, gOutgoingLimit, gPort, gRasGkMode, gRASIP, gRTDRCount, gRTDRInterval, gRTPTimeout, gT38Support, gTOS, gTRCLVL, gTunneling, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_INBANDRELAX, H323_DTMF_Q931, H323_DTMF_RFC2833, IPTOS_MINCOST, ast_variable::lineno, ast_user_list::lock, ast_peer_list::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, manufacturer, ooh323_config::mTCPPortEnd, ooh323_config::mTCPPortStart, ast_variable::name, ooh323_peer::next, ast_variable::next, NULL, ooconfig, PARSE_ADDR, peerl, ast_peer_list::peers, reload(), RESULT_SUCCESS, strsep(), t35countrycode, t35extensions, T38_DISABLED, T38_ENABLED, T38_FAXGW, tmp(), user, userl, ast_user_list::users, v6mode, ast_variable::value, vendor, and version.
Referenced by load_module(), and ooh323_do_reload().
int restart_monitor | ( | void | ) |
Definition at line 4082 of file chan_ooh323.c.
References ast_log, ast_mutex_lock, ast_mutex_unlock, ast_pthread_create, AST_PTHREADT_NULL, AST_PTHREADT_STOP, do_monitor(), LOG_ERROR, LOG_WARNING, monitor_thread, monlock, and NULL.
Referenced by handle_cli_ooh323_reload(), load_module(), ooh323_request(), and reload_module().
void setup_rtp_connection | ( | ooCallData * | call, |
const char * | remoteIp, | ||
int | remotePort | ||
) |
Definition at line 4775 of file chan_ooh323.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g726_aal2, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_parse_arg(), ast_rtp_codecs_payloads_set_rtpmap_type(), ast_rtp_instance_get_codecs(), ast_rtp_instance_set_remote_address, AST_RTP_OPT_G726_NONSTANDARD, ast_sockaddr_set_port, ast_verb, call(), find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, PARSE_ADDR, ooh323_pvt::rtp, tmp(), and ooh323_pvt::writeformat.
Referenced by ooh323c_start_transmit_channel().
void setup_udptl_connection | ( | ooCallData * | call, |
const char * | remoteIp, | ||
int | remotePort | ||
) |
Definition at line 4839 of file chan_ooh323.c.
References ast_channel_name(), ast_channel_trylock, ast_channel_unlock, AST_CONTROL_T38_PARAMETERS, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_parse_arg(), ast_queue_control_data(), ast_sockaddr_port, ast_sockaddr_set_port, ast_sockaddr_stringify_host(), AST_T38_NEGOTIATED, AST_T38_RATE_14400, ast_udptl_get_far_max_ifp(), ast_udptl_set_peer(), ast_udptl_set_tag(), ast_verb, call(), DEADLOCK_AVOIDANCE, find_call(), gH323Debug, ooh323_pvt::lastTxT38, ooh323_pvt::lock, LOG_ERROR, ast_control_t38_parameters::max_ifp, NULL, ooh323_pvt::owner, PARSE_ADDR, ast_control_t38_parameters::rate, ast_control_t38_parameters::request_response, T38_ENABLED, ooh323_pvt::t38_tx_enable, ooh323_pvt::t38support, and ooh323_pvt::udptl.
Referenced by ooh323c_start_transmit_datachannel().
int update_our_aliases | ( | ooCallData * | call, |
struct ooh323_pvt * | p | ||
) |
Definition at line 4949 of file chan_ooh323.c.
References ast_copy_string(), call(), ooh323_pvt::callee_dialedDigits, ooh323_pvt::callee_email, ooh323_pvt::callee_h323id, ooh323_pvt::callee_url, and NULL.
Referenced by ooh323_onReceivedSetup().