Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions
chan_ooh323.h File Reference
#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"
This graph shows which files directly or indirectly include this file:

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_peerfind_peer (const char *name, int port)
 
struct ooh323_userfind_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_frameooh323_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)
 

Function Documentation

◆ close_rtp_connection()

void close_rtp_connection ( ooCallData *  call)

Definition at line 4810 of file chan_ooh323.c.

4811{
4812 struct ooh323_pvt *p = NULL;
4813
4814 if(gH323Debug)
4815 ast_verb(0, "--- close_rtp_connection\n");
4816
4817 p = find_call(call);
4818 if (!p) {
4819 ast_log(LOG_ERROR, "Couldn't find matching call to close rtp "
4820 "connection\n");
4821 return;
4822 }
4823 ast_mutex_lock(&p->lock);
4824 if (p->rtp) {
4826 }
4828
4829 if(gH323Debug)
4830 ast_verb(0, "+++ close_rtp_connection\n");
4831
4832 return;
4833}
#define ast_log
Definition: astobj2.c:42
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
static int call(void *data)
Definition: chan_pjsip.c:2394
#define LOG_ERROR
#define ast_verb(level,...)
#define ast_mutex_unlock(a)
Definition: lock.h:190
#define ast_mutex_lock(a)
Definition: lock.h:189
#define NULL
Definition: resample.c:96
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
Definition: rtp_engine.c:2359
struct ast_rtp_instance * rtp
Definition: chan_ooh323.c:187
ast_mutex_t lock
Definition: chan_ooh323.c:185

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().

◆ close_udptl_connection()

void close_udptl_connection ( ooCallData *  call)

Definition at line 4901 of file chan_ooh323.c.

4902{
4903 struct ooh323_pvt *p = NULL;
4904
4905 if(gH323Debug)
4906 ast_verb(0, "--- close_udptl_connection\n");
4907
4908 p = find_call(call);
4909 if (!p) {
4910 ast_log(LOG_ERROR, "Couldn't find matching call to close udptl "
4911 "connection\n");
4912 return;
4913 }
4914 ast_mutex_lock(&p->lock);
4915 if (p->owner) {
4916 while (p->owner && ast_channel_trylock(p->owner)) {
4917 ast_debug(1, "Failed to grab lock, trying again\n");
4919 }
4920 if (!p->owner) {
4922 ast_log(LOG_ERROR, "Channel has no owner\n");
4923 return;
4924 }
4925 } else {
4927 ast_log(LOG_ERROR, "Channel has no owner\n");
4928 return;
4929 }
4930
4931 p->t38_tx_enable = 0;
4932 if (p->t38support == T38_ENABLED) {
4933 struct ast_control_t38_parameters parameters = { .request_response = 0 };
4935 ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
4936 }
4937
4940
4941 if(gH323Debug)
4942 ast_verb(0, "+++ close_udptl_connection\n");
4943
4944 return;
4945}
#define T38_ENABLED
Definition: chan_ooh323.c:102
#define ast_channel_trylock(chan)
Definition: channel.h:2970
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Definition: channel.c:1257
#define ast_channel_unlock(chan)
Definition: channel.h:2969
@ AST_T38_TERMINATED
@ AST_CONTROL_T38_PARAMETERS
#define ast_debug(level,...)
Log a DEBUG message.
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:479
enum ast_control_t38 request_response
int t38support
Definition: chan_ooh323.c:191
struct ast_channel * owner
Definition: chan_ooh323.c:203
int t38_tx_enable
Definition: chan_ooh323.c:197

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().

◆ configure_local_rtp()

int configure_local_rtp ( struct ooh323_pvt p,
ooCallData *  call 
)

Definition at line 4599 of file chan_ooh323.c.

4600{
4601 char lhost[INET6_ADDRSTRLEN];
4602 unsigned lport = 0;
4603 struct ast_sockaddr tmp;
4604 ooMediaInfo mediaInfo;
4605 int x;
4606
4607 if (gH323Debug)
4608 ast_verb(0, "--- configure_local_rtp\n");
4609
4610 memset(&mediaInfo, 0, sizeof(mediaInfo));
4611 if (ast_parse_arg(call->localIP, PARSE_ADDR, &tmp)) {
4613 }
4614 if (!(p->rtp = ast_rtp_instance_new("asterisk", sched, &tmp, NULL))) {
4615 ast_log(LOG_WARNING, "Unable to create RTP session: %s\n",
4616 strerror(errno));
4617 return 0;
4618 }
4619
4620 ast_rtp_instance_set_qos(p->rtp, gTOS, 0, "ooh323-rtp");
4621
4622 if (!(p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &tmp))) {
4623 ast_log(LOG_WARNING, "Unable to create UDPTL session: %s\n",
4624 strerror(errno));
4625 return 0;
4626 }
4628
4629 if (p->owner) {
4630 while (p->owner && ast_channel_trylock(p->owner)) {
4631 ast_debug(1,"Failed to grab lock, trying again\n");
4633 }
4634 if (!p->owner) {
4636 ast_log(LOG_ERROR, "Channel has no owner\n");
4637 return 0;
4638 }
4639 } else {
4640 ast_log(LOG_ERROR, "Channel has no owner\n");
4641 return 0;
4642 }
4643
4647
4649
4650 if (p->rtp) {
4651 if (p->cap) {
4654 }
4655 if (p->nat) {
4657 }
4658 if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
4661 p->rtp, p->dtmfcodec, "audio", "telephone-event", 0);
4662 }
4663 if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) {
4666 p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
4667 }
4668 /* figure out our local RTP port and tell the H.323 stack about it*/
4670 ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
4671 lport = ast_sockaddr_port(&tmp);
4672
4673 if (p->rtptimeout) {
4675 }
4677
4678 }
4679
4680 if (p->rtdrcount) {
4681 if (gH323Debug)
4682 ast_verb(0, "Setup RTDR info: %d, %d\n", p->rtdrinterval, p->rtdrcount);
4683 call->rtdrInterval = p->rtdrinterval;
4684 call->rtdrCount = p->rtdrcount;
4685 }
4686
4687
4688 ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP));
4689 mediaInfo.lMediaPort = lport;
4690 mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort + 1;
4691 for (x = 0; x < ast_format_cap_count(p->cap); x++) {
4692 struct ast_format *format = ast_format_cap_get_format(p->cap, x);
4693
4694 strcpy(mediaInfo.dir, "transmit");
4695 mediaInfo.cap = ooh323_convertAsteriskCapToH323Cap(format);
4696 ooAddMediaInfo(call, mediaInfo);
4697 strcpy(mediaInfo.dir, "receive");
4698 ooAddMediaInfo(call, mediaInfo);
4699 if (mediaInfo.cap == OO_G729A) {
4700 strcpy(mediaInfo.dir, "transmit");
4701 mediaInfo.cap = OO_G729;
4702 ooAddMediaInfo(call, mediaInfo);
4703 strcpy(mediaInfo.dir, "receive");
4704 ooAddMediaInfo(call, mediaInfo);
4705
4706 strcpy(mediaInfo.dir, "transmit");
4707 mediaInfo.cap = OO_G729B;
4708 ooAddMediaInfo(call, mediaInfo);
4709 strcpy(mediaInfo.dir, "receive");
4710 ooAddMediaInfo(call, mediaInfo);
4711 }
4712
4713 ao2_ref(format, -1);
4714 }
4715
4716 if (p->udptl) {
4718 ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
4719 lport = ast_sockaddr_port(&tmp);
4720 ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP));
4721 mediaInfo.lMediaPort = lport;
4722 mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort +1;
4723 mediaInfo.cap = OO_T38;
4724 strcpy(mediaInfo.dir, "transmit");
4725 ooAddMediaInfo(call, mediaInfo);
4726 strcpy(mediaInfo.dir, "receive");
4727 ooAddMediaInfo(call, mediaInfo);
4728 }
4729
4730 if (gH323Debug)
4731 ast_verb(0, "+++ configure_local_rtp\n");
4732
4733 return 1;
4734}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static int tmp()
Definition: bt_open.c:389
static int gTOS
Definition: chan_ooh323.c:373
struct ast_sockaddr bindaddr
Definition: chan_ooh323.c:353
static struct io_context * io
Definition: chan_ooh323.c:401
int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format)
Definition: chan_ooh323.c:4506
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2445
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
unsigned int ast_format_cap_get_framing(const struct ast_format_cap *cap)
Get the global framing.
Definition: format_cap.c:438
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
Definition: main/config.c:3842
#define LOG_WARNING
int errno
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
Definition: netsock2.h:517
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
Definition: netsock2.h:167
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition: netsock2.h:286
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
Definition: rtp_engine.c:487
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
Definition: rtp_engine.c:1671
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
Definition: rtp_engine.c:727
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Definition: rtp_engine.c:665
@ AST_RTP_PROPERTY_NAT
Definition: rtp_engine.h:118
@ AST_RTP_PROPERTY_RTCP
Definition: rtp_engine.h:126
@ AST_RTP_PROPERTY_DTMF
Definition: rtp_engine.h:120
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record tx payload type information that was seen in an a=rtpmap: SDP line.
Definition: rtp_engine.c:1484
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
Definition: rtp_engine.c:2345
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
Definition: rtp_engine.c:749
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Definition: rtp_engine.c:2368
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
Definition: rtp_engine.c:2870
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
Definition of a media format.
Definition: format.c:43
Socket address structure.
Definition: netsock2.h:97
int rtdrinterval
Definition: chan_ooh323.c:245
int rtptimeout
Definition: chan_ooh323.c:194
struct ast_format_cap * cap
Definition: chan_ooh323.c:229
struct ast_udptl * udptl
Definition: chan_ooh323.c:195
Definition: sched.c:76
int ast_udptl_fd(const struct ast_udptl *udptl)
Definition: udptl.c:728
void ast_udptl_get_us(const struct ast_udptl *udptl, struct ast_sockaddr *us)
Definition: udptl.c:1138
struct ast_udptl * ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *in)
Definition: udptl.c:1026
void ast_udptl_set_far_max_datagram(struct ast_udptl *udptl, unsigned int max_datagram)
sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default val...
Definition: udptl.c:995

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().

◆ delete_peers()

int delete_peers ( void  )

Definition at line 4230 of file chan_ooh323.c.

4231{
4232 struct ooh323_peer *cur = NULL, *prev = NULL;
4234 cur = peerl.peers;
4235 while (cur) {
4236 prev = cur;
4237 cur = cur->next;
4238
4239 ast_mutex_destroy(&prev->lock);
4240 ast_free(prev->h323id);
4241 ast_free(prev->email);
4242 ast_free(prev->url);
4243 ast_free(prev->e164);
4244 if(prev->rtpmask) {
4245 ast_mutex_lock(&prev->rtpmask->lock);
4246 prev->rtpmask->inuse--;
4247 ast_mutex_unlock(&prev->rtpmask->lock);
4248 if (prev->rtpmask->inuse == 0) {
4249 regfree(&prev->rtpmask->regex);
4250 ast_mutex_destroy(&prev->rtpmask->lock);
4251 ast_free(prev->rtpmask);
4252 }
4253 }
4254 ast_free(prev);
4255
4256 if (cur == peerl.peers) {
4257 break;
4258 }
4259 }
4260 peerl.peers = NULL;
4262 return 0;
4263}
#define ast_free(a)
Definition: astmm.h:180
static struct ast_peer_list peerl
#define ast_mutex_destroy(a)
Definition: lock.h:188
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
ast_mutex_t lock
Definition: chan_ooh323.c:324
struct ooh323_peer * next
Definition: chan_ooh323.c:312

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().

◆ delete_users()

int delete_users ( void  )

Definition at line 4265 of file chan_ooh323.c.

4266{
4267 struct ooh323_user *cur = NULL, *prev = NULL;
4269 cur = userl.users;
4270 while (cur) {
4271 prev = cur;
4272 cur = cur->next;
4273 ast_mutex_destroy(&prev->lock);
4274
4275 if(prev->rtpmask) {
4276 ast_mutex_lock(&prev->rtpmask->lock);
4277 prev->rtpmask->inuse--;
4278 ast_mutex_unlock(&prev->rtpmask->lock);
4279 if (prev->rtpmask->inuse == 0) {
4280 regfree(&prev->rtpmask->regex);
4281 ast_mutex_destroy(&prev->rtpmask->lock);
4282 ast_free(prev->rtpmask);
4283 }
4284 }
4285 ao2_cleanup(prev->cap);
4286 ast_free(prev);
4287 if (cur == userl.users) {
4288 break;
4289 }
4290 }
4291 userl.users = NULL;
4293 return 0;
4294}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
static struct ast_user_list userl
struct ooh323_user * users
Definition: chan_ooh323.c:318
ast_mutex_t lock
Definition: chan_ooh323.c:319
struct ooh323_user * next
Definition: chan_ooh323.c:280

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().

◆ find_peer()

struct ooh323_peer * find_peer ( const char *  name,
int  port 
)

Definition at line 890 of file chan_ooh323.c.

891{
892 struct ooh323_peer *peer;
893
894 if (gH323Debug)
895 ast_verb(0, "--- find_peer \"%s\"\n", name);
896
897
899 for (peer = peerl.peers; peer; peer = peer->next) {
900 if (gH323Debug) {
901 ast_verb(0, " comparing with \"%s\"\n", peer->ip);
902 }
903 if (!strcasecmp(peer->name, name))
904 break;
905 if (peer->h323id && !strcasecmp(peer->h323id, name))
906 break;
907 if (peer->e164 && !strcasecmp(peer->e164, name))
908 break;
909 /*
910 if (!strcmp(peer->ip, name)) {
911 if (port > 0 && peer->port == port) { break; }
912 else if (port <= 0) { break; }
913 }
914 */
915 }
917
918 if (gH323Debug) {
919 if (peer) {
920 ast_verb(0, " found matching peer\n");
921 }
922 ast_verb(0, "+++ find_peer \"%s\"\n", name);
923 }
924
925 return peer;
926}
static const char name[]
Definition: format_mp3.c:68
char ip[4 *8+7+2]
Definition: chan_ooh323.c:297
char name[256]
Definition: chan_ooh323.c:286
char * e164
Definition: chan_ooh323.c:302
char * h323id
Definition: chan_ooh323.c:299

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().

◆ find_user()

struct ooh323_user * find_user ( const char *  name,
const char *  ip 
)

Definition at line 832 of file chan_ooh323.c.

833{
834 struct ooh323_user *user;
835
836 if (gH323Debug)
837 ast_verb(0, "--- find_user: %s, %s\n",name,ip);
838
840
841 for (user = userl.users; user; user = user->next) {
842 if (ip && user->mUseIP && !strcmp(user->mIP, ip)) {
843 break;
844 }
845 if (name && !strcmp(user->name, name)) {
846 break;
847 }
848 }
849
851
852 if (gH323Debug)
853 ast_verb(0, "+++ find_user\n");
854
855 return user;
856}
static char user[512]
structure to hold users read from users.conf

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().

◆ handle_cli_ooh323_reload()

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.

2779{
2780
2781 switch (cmd) {
2782 case CLI_INIT:
2783 e->command = "ooh323 reload";
2784 e->usage =
2785 "Usage: ooh323 reload\n"
2786 " Reload OOH323 config.\n";
2787 return NULL;
2788 case CLI_GENERATE:
2789 return NULL;
2790 }
2791
2792 if (a->argc != 2)
2793 return CLI_SHOWUSAGE;
2794
2795 if (gH323Debug)
2796 ast_verb(0, "--- ooh323_reload\n");
2797
2799 if (h323_reloading) {
2800 ast_verb(0, "Previous OOH323 reload not yet done\n");
2801 } else {
2802 h323_reloading = 1;
2803 }
2806
2807 if (gH323Debug)
2808 ast_verb(0, "+++ ooh323_reload\n");
2809
2810 return 0;
2811}
int restart_monitor(void)
Definition: chan_ooh323.c:4082
static ast_mutex_t h323_reload_lock
Definition: chan_ooh323.c:329
static int h323_reloading
Definition: chan_ooh323.c:328
#define CLI_SHOWUSAGE
Definition: cli.h:45
@ CLI_INIT
Definition: cli.h:152
@ CLI_GENERATE
Definition: cli.h:153
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static struct test_val a

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.

◆ ooh323_convert_hangupcause_asteriskToH323()

int ooh323_convert_hangupcause_asteriskToH323 ( int  cause)

Definition at line 5179 of file chan_ooh323.c.

5180{
5181 switch (cause) {
5183 return OO_REASON_REMOTE_REJECTED;
5185 return OO_REASON_NOUSER;
5186 case AST_CAUSE_BUSY:
5187 return OO_REASON_REMOTE_BUSY;
5189 return OO_REASON_NOCOMMON_CAPABILITIES;
5191 return OO_REASON_REMOTE_BUSY;
5193 return OO_REASON_REMOTE_NOANSWER;
5194 case AST_CAUSE_NORMAL:
5195 return OO_REASON_REMOTE_CLEARED;
5196 case AST_CAUSE_FAILURE:
5197 default:
5198 return OO_REASON_UNKNOWN;
5199 }
5200
5201 return 0;
5202
5203
5204}
#define AST_CAUSE_CONGESTION
Definition: causes.h:153
#define AST_CAUSE_UNALLOCATED
Definition: causes.h:98
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
Definition: causes.h:130
#define AST_CAUSE_FAILURE
Definition: causes.h:150
#define AST_CAUSE_NORMAL
Definition: causes.h:151
#define AST_CAUSE_CALL_REJECTED
Definition: causes.h:111
#define AST_CAUSE_BUSY
Definition: causes.h:149
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:109

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().

◆ ooh323_convert_hangupcause_h323ToAsterisk()

int ooh323_convert_hangupcause_h323ToAsterisk ( int  cause)

Definition at line 5206 of file chan_ooh323.c.

5207{
5208 switch (cause) {
5209 case OO_REASON_REMOTE_REJECTED:
5211 case OO_REASON_NOUSER:
5212 return AST_CAUSE_UNALLOCATED;
5213 case OO_REASON_REMOTE_BUSY:
5214 case OO_REASON_LOCAL_BUSY:
5215 return AST_CAUSE_BUSY;
5216 case OO_REASON_NOCOMMON_CAPABILITIES: /* No codecs approved */
5218 case OO_REASON_REMOTE_CONGESTED:
5219 case OO_REASON_LOCAL_CONGESTED:
5220 return AST_CAUSE_CONGESTION;
5221 case OO_REASON_REMOTE_NOANSWER:
5222 return AST_CAUSE_NO_ANSWER;
5223 case OO_REASON_UNKNOWN:
5224 case OO_REASON_INVALIDMESSAGE:
5225 case OO_REASON_TRANSPORTFAILURE:
5226 return AST_CAUSE_FAILURE;
5227 case OO_REASON_REMOTE_CLEARED:
5228 return AST_CAUSE_NORMAL;
5229 default:
5230 return AST_CAUSE_NORMAL;
5231 }
5232 /* Never reached */
5233 return 0;
5234}

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.

◆ ooh323_convertAsteriskCapToH323Cap()

int ooh323_convertAsteriskCapToH323Cap ( struct ast_format format)

Definition at line 4506 of file chan_ooh323.c.

4507{
4509 return OO_G711ULAW64K;
4510 } else if (ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
4511 return OO_G711ALAW64K;
4512 } else if (ast_format_cmp(format, ast_format_gsm) == AST_FORMAT_CMP_EQUAL) {
4513 return OO_GSMFULLRATE;
4514 } else if (ast_format_cmp(format, ast_format_speex) == AST_FORMAT_CMP_EQUAL) {
4515 return OO_SPEEX;
4516 } else if (ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
4517 return OO_G729A;
4518 } else if (ast_format_cmp(format, ast_format_g726) == AST_FORMAT_CMP_EQUAL) {
4519 return OO_G726;
4521 return OO_G726AAL2;
4522 } else if (ast_format_cmp(format, ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
4523 return OO_G7231;
4524 } else if (ast_format_cmp(format, ast_format_h263) == AST_FORMAT_CMP_EQUAL) {
4525 return OO_H263VIDEO;
4526 } else {
4527 ast_log(LOG_NOTICE, "Don't know how to deal with mode %s\n", ast_format_get_name(format));
4528 return -1;
4529 }
4530}
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
@ AST_FORMAT_CMP_EQUAL
Definition: format.h:36
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:96
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:131
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:166
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:111
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:146
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:116
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:151
#define LOG_NOTICE

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().

◆ ooh323_delete_peer()

void ooh323_delete_peer ( struct ooh323_peer peer)

Definition at line 2328 of file chan_ooh323.c.

2329{
2330 struct ooh323_peer *prev = NULL, *cur = NULL;
2331
2332 if (gH323Debug)
2333 ast_verb(0, "--- ooh323_delete_peer\n");
2334
2335 if (peer) {
2336 cur = peerl.peers;
2338 while(cur) {
2339 if(cur==peer) break;
2340 prev = cur;
2341 cur = cur->next;
2342 }
2343
2344 if (cur) {
2345 if(prev)
2346 prev->next = cur->next;
2347 else
2348 peerl.peers = cur->next;
2349 }
2351
2352 ast_free(peer->h323id);
2353 ast_free(peer->email);
2354 ast_free(peer->url);
2355 ast_free(peer->e164);
2356
2357 ao2_cleanup(peer->cap);
2358 ast_free(peer);
2359 }
2360
2361 if (gH323Debug)
2362 ast_verb(0, "+++ ooh323_delete_peer\n");
2363
2364}
char * email
Definition: chan_ooh323.c:300
struct ast_format_cap * cap
Definition: chan_ooh323.c:289
char * url
Definition: chan_ooh323.c:301

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().

◆ ooh323_destroy()

int ooh323_destroy ( struct ooh323_pvt p)

Definition at line 4117 of file chan_ooh323.c.

4118{
4119 /* NOTE: Assumes iflock already acquired */
4120 struct ooh323_pvt *prev = NULL, *cur = NULL;
4121 struct ooh323_user *user = NULL;
4122
4123 if (gH323Debug) {
4124 ast_verb(0, "--- ooh323_destroy \n");
4125
4126 if (p)
4127 ast_verb(0, " Destroying %s\n", p->username);
4128 }
4129
4130 cur = iflist;
4131 while (cur) {
4132 if (cur == p) { break; }
4133 prev = cur;
4134 cur = cur->next;
4135 }
4136
4137 if (cur) {
4138 ast_mutex_lock(&cur->lock);
4139 if (prev)
4140 prev->next = cur->next;
4141 else
4142 iflist = cur->next;
4143
4144 if (cur->callToken) {
4145 if (gH323Debug)
4146 ast_verb(0, " Destroying %s\n", cur->callToken);
4147 ast_free(cur->callToken);
4148 cur->callToken = 0;
4149 }
4150
4151 if (cur->username) {
4152 ast_free(cur->username);
4153 cur->username = 0;
4154 }
4155
4156 if (cur->host) {
4157 ast_free(cur->host);
4158 cur->host = 0;
4159 }
4160
4161 if (cur->callerid_name) {
4162 ast_free(cur->callerid_name);
4163 cur->callerid_name = 0;
4164 }
4165
4166 if (cur->callerid_num) {
4167 ast_free(cur->callerid_num);
4168 cur->callerid_num = 0;
4169 }
4170
4171 if (cur->rtp) {
4172 ast_rtp_instance_stop(cur->rtp);
4173 ast_rtp_instance_destroy(cur->rtp);
4174 cur->rtp = NULL;
4175 }
4176
4177 if (cur->udptl) {
4178 ast_udptl_destroy(cur->udptl);
4179 cur->udptl = NULL;
4180 }
4181
4182 /* Unlink us from the owner if we have one */
4183 if (cur->owner) {
4184 while(ast_channel_trylock(cur->owner)) {
4185 ast_debug(1, "Failed to grab lock, trying again\n");
4186 DEADLOCK_AVOIDANCE(&cur->lock);
4187 }
4188 ast_debug(1, "Detaching from %s\n", ast_channel_name(cur->owner));
4189 ast_channel_tech_pvt_set(cur->owner, NULL);
4190 ast_channel_unlock(cur->owner);
4191 cur->owner = NULL;
4193 }
4194
4195 if (cur->vad) {
4196 ast_dsp_free(cur->vad);
4197 cur->vad = NULL;
4198 }
4199
4200/* decrement user/peer count */
4201
4202 if(!ast_test_flag(cur, H323_OUTGOING)) {
4203 if (cur->neighbor.user) {
4204 user = find_user(p->callerid_name, cur->neighbor.user);
4205 if(user && user->inUse > 0) {
4206 ast_mutex_lock(&user->lock);
4207 user->inUse--;
4208 ast_mutex_unlock(&user->lock);
4209 }
4210 ast_free(cur->neighbor.user);
4211 }
4212 } else {
4213/* outgoing limit decrement here !!! */
4214 }
4215
4216 ast_mutex_unlock(&cur->lock);
4217 ast_mutex_destroy(&cur->lock);
4218 ao2_cleanup(cur->writeformat);
4219 ao2_cleanup(cur->readformat);
4220 ao2_cleanup(cur->cap);
4221 ast_free(cur);
4222 }
4223
4224 if (gH323Debug)
4225 ast_verb(0, "+++ ooh323_destroy\n");
4226
4227 return 0;
4228}
#define H323_OUTGOING
Definition: chan_ooh323.c:93
struct ast_module * myself
Definition: chan_ooh323.c:113
struct ooh323_user * find_user(const char *name, const char *ip)
Definition: chan_ooh323.c:832
static struct ooh323_pvt * iflist
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
void ast_dsp_free(struct ast_dsp *dsp)
Definition: dsp.c:1783
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:483
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition: rtp_engine.c:458
struct ooh323_pvt * next
Definition: chan_ooh323.c:248
char * callerid_name
Definition: chan_ooh323.c:215
char * username
Definition: chan_ooh323.c:213
void ast_udptl_destroy(struct ast_udptl *udptl)
Definition: udptl.c:1148
#define ast_test_flag(p, flag)
Definition: utils.h:63

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().

◆ ooh323_onReceivedDigit()

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.

1799{
1800 struct ooh323_pvt *p = NULL;
1801 struct ast_frame f;
1802 int res;
1803
1804 ast_debug(1, "Received Digit: %c\n", digit[0]);
1805 p = find_call(call);
1806 if (!p) {
1807 ast_log(LOG_ERROR, "Failed to find a matching call.\n");
1808 return -1;
1809 }
1810 if (!p->owner) {
1811 ast_log(LOG_ERROR, "Channel has no owner\n");
1812 return -1;
1813 }
1814 ast_mutex_lock(&p->lock);
1815 memset(&f, 0, sizeof(f));
1816 f.frametype = AST_FRAME_DTMF;
1817 f.subclass.integer = digit[0];
1818 f.datalen = 0;
1819 f.samples = 800;
1820 f.offset = 0;
1821 f.data.ptr = NULL;
1822 f.mallocd = 0;
1823 f.src = "SEND_DIGIT";
1824
1825 while (p->owner && ast_channel_trylock(p->owner)) {
1826 ast_debug(1, "Failed to grab lock, trying again\n");
1828 }
1829 if (!p->owner) {
1831 ast_log(LOG_ERROR, "Channel has no owner\n");
1832 return 0;
1833 }
1834 res = ast_queue_frame(p->owner, &f);
1837 return res;
1838}
char digit
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1158
#define AST_FRAME_DTMF
Data structure associated with a single frame of data.

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().

◆ ooh323_onReceivedSetup()

int ooh323_onReceivedSetup ( ooCallData *  call,
Q931Message *  pmsg 
)

Definition at line 1840 of file chan_ooh323.c.

1841{
1842 struct ooh323_pvt *p = NULL;
1843 struct ooh323_user *user = NULL;
1844 struct ast_channel *c = NULL;
1845 ooAliases *alias = NULL;
1846 char *at = NULL;
1847 char number [OO_MAX_NUMBER_LENGTH];
1848
1849 if (gH323Debug)
1850 ast_verb(0, "--- ooh323_onReceivedSetup %s\n", call->callToken);
1851
1852
1853 if (!(p = ooh323_alloc(call->callReference, call->callToken))) {
1854 ast_log(LOG_ERROR, "Failed to create a new call.\n");
1855 return -1;
1856 }
1857 ast_mutex_lock(&p->lock);
1859
1860
1861 if (call->remoteDisplayName) {
1862 p->callerid_name = ast_strdup(call->remoteDisplayName);
1863 }
1864
1865 if (ooCallGetCallingPartyNumber(call, number, OO_MAX_NUMBER_LENGTH) == OO_OK) {
1867 }
1868
1869 if (call->remoteAliases) {
1870 for (alias = call->remoteAliases; alias; alias = alias->next) {
1871 if (alias->type == T_H225AliasAddress_h323_ID) {
1872 if (!p->callerid_name) {
1873 p->callerid_name = ast_strdup(alias->value);
1874 }
1875 ast_copy_string(p->caller_h323id, alias->value, sizeof(p->caller_h323id));
1876 }
1877 else if(alias->type == T_H225AliasAddress_dialedDigits)
1878 {
1879 if(!p->callerid_num)
1880 p->callerid_num = ast_strdup(alias->value);
1881 ast_copy_string(p->caller_dialedDigits, alias->value,
1882 sizeof(p->caller_dialedDigits));
1883 }
1884 else if(alias->type == T_H225AliasAddress_email_ID)
1885 {
1886 ast_copy_string(p->caller_email, alias->value, sizeof(p->caller_email));
1887 }
1888 else if(alias->type == T_H225AliasAddress_url_ID)
1889 {
1890 ast_copy_string(p->caller_url, alias->value, sizeof(p->caller_url));
1891 }
1892 }
1893 }
1894
1895 number[0] = '\0';
1896 if(ooCallGetCalledPartyNumber(call, number, OO_MAX_NUMBER_LENGTH)== OO_OK) {
1897 ast_copy_string(p->exten, number, sizeof(p->exten));
1898 } else {
1901 ast_copy_string(p->exten, p->callee_dialedDigits, sizeof(p->exten));
1902 } else if(!ast_strlen_zero(p->callee_h323id)) {
1903 ast_copy_string(p->exten, p->callee_h323id, sizeof(p->exten));
1904 } else if(!ast_strlen_zero(p->callee_email)) {
1905 ast_copy_string(p->exten, p->callee_email, sizeof(p->exten));
1906 if ((at = strchr(p->exten, '@'))) {
1907 *at = '\0';
1908 }
1909 }
1910 }
1911
1912 /* if no extension found, set to default 's' */
1913 if (ast_strlen_zero(p->exten)) {
1914 p->exten[0]='s';
1915 p->exten[1]='\0';
1916 }
1917
1918 user = find_user(p->callerid_name, call->remoteIP);
1919 if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) {
1920 ast_mutex_lock(&user->lock);
1921 p->username = ast_strdup(user->name);
1922 p->neighbor.user = user->mUseIP ? ast_strdup(user->mIP) :
1924 ast_copy_string(p->context, user->context, sizeof(p->context));
1925 ast_copy_string(p->accountcode, user->accountcode, sizeof(p->accountcode));
1926 p->amaflags = user->amaflags;
1928 p->g729onlyA = user->g729onlyA;
1929 p->dtmfmode |= user->dtmfmode;
1930 p->dtmfcodec = user->dtmfcodec;
1931 p->faxdetect = user->faxdetect;
1932 p->t38support = user->t38support;
1933 p->rtptimeout = user->rtptimeout;
1934 p->nat = user->nat;
1935 p->h245tunneling = user->h245tunneling;
1936 p->faststart = user->faststart;
1937 p->directrtp = user->directrtp;
1938 p->earlydirect = user->earlydirect;
1939
1940 if (p->faststart)
1941 OO_SETFLAG(call->flags, OO_M_FASTSTART);
1942 else
1943 OO_CLRFLAG(call->flags, OO_M_FASTSTART);
1944 /* if we disable h245tun for this user then we clear flag */
1945 /* in any other case we don't must touch this */
1946 /* ie if we receive setup without h245tun but enabled
1947 we can't enable it per call */
1948 if (!p->h245tunneling)
1949 OO_CLRFLAG(call->flags, OO_M_TUNNELING);
1950
1951 if (user->rtpmask && user->rtpmaskstr[0]) {
1952 p->rtpmask = user->rtpmask;
1953 ast_copy_string(p->rtpmaskstr, user->rtpmaskstr,
1954 sizeof(p->rtpmaskstr));
1955 }
1956 if (user->rtdrcount > 0 && user->rtdrinterval > 0) {
1957 p->rtdrcount = user->rtdrcount;
1958 p->rtdrinterval = user->rtdrinterval;
1959 }
1960
1961 p->aniasdni = user->aniasdni;
1962
1963 if (user->incominglimit) user->inUse++;
1964 ast_mutex_unlock(&user->lock);
1965 } else {
1966 if (!OO_TESTFLAG(p->flags,H323_DISABLEGK)) {
1967 p->username = ast_strdup(call->remoteIP);
1968 p->directrtp = gDirectRTP;
1970 } else {
1972 ast_log(LOG_ERROR, "Unacceptable ip %s\n", call->remoteIP);
1973 if (!user) {
1975 call->callEndReason = OO_REASON_REMOTE_REJECTED;
1976 }
1977 else {
1979 call->callEndReason = OO_REASON_REMOTE_REJECTED;
1980 }
1982 return -1;
1983 }
1984 }
1985
1987 p->t38support, p->g729onlyA);
1988/* Incoming call */
1990 if(!c) {
1992 ast_log(LOG_ERROR, "Could not create ast_channel\n");
1993 return -1;
1994 }
1995
1996 if (p->aniasdni) {
1997 ooCallSetCallerId(call, p->exten);
1998 }
1999 if (!configure_local_rtp(p, call)) {
2001 ast_log(LOG_ERROR, "Couldn't create rtp structure\n");
2002 return -1;
2003 }
2004
2006
2007 if (gH323Debug)
2008 ast_verb(0, "+++ ooh323_onReceivedSetup - Determined context %s, "
2009 "extension %s\n", p->context, p->exten);
2010
2011 return OO_OK;
2012}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
Definition: causes.h:120
static int gEarlyDirect
Definition: chan_ooh323.c:372
#define H323_DISABLEGK
Definition: chan_ooh323.c:96
int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call)
Definition: chan_ooh323.c:4599
int update_our_aliases(ooCallData *call, struct ooh323_pvt *p)
Definition: chan_ooh323.c:4949
static int gDirectRTP
Definition: chan_ooh323.c:371
static struct ast_channel * ooh323_new(struct ooh323_pvt *i, int state, const char *host, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
Definition: chan_ooh323.c:413
static struct ooh323_pvt * ooh323_alloc(int callref, char *callToken)
Definition: chan_ooh323.c:556
#define H323_NEEDDESTROY
Definition: chan_ooh323.c:95
int ooh323_convert_hangupcause_asteriskToH323(int cause)
Definition: chan_ooh323.c:5179
@ AST_STATE_RING
Definition: channelstate.h:40
@ AST_MEDIA_TYPE_UNKNOWN
Definition: codec.h:31
int ast_format_cap_append_from_cap(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
Append the formats of provided type in src to dst.
Definition: format_cap.c:269
int ooh323c_set_capability_for_call(ooCallData *call, struct ast_format_cap *cap, int dtmf, int dtmfcodec, int t38support, int g729onlyA)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Main Channel structure associated with a channel.
Number structure.
Definition: app_followme.c:154
char * user
Definition: chan_ooh323.c:205
char callee_h323id[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:221
int earlydirect
Definition: chan_ooh323.c:240
struct OOH323Regex * rtpmask
Definition: chan_ooh323.c:243
char caller_h323id[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:217
int h245tunneling
Definition: chan_ooh323.c:246
char context[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:233
char rtpmaskstr[120]
Definition: chan_ooh323.c:244
char exten[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:232
char caller_email[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:219
unsigned int flags
Definition: chan_ooh323.c:210
char * callerid_num
Definition: chan_ooh323.c:216
char accountcode[256]
Definition: chan_ooh323.c:234
char callee_dialedDigits[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:222
char caller_url[256]
Definition: chan_ooh323.c:220
char caller_dialedDigits[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:218
char callee_email[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:223
union ooh323_pvt::@3 neighbor
static struct test_val c
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_set_flag(p, flag)
Definition: utils.h:70

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().

◆ ooh323_rtp_read()

struct ast_frame * ooh323_rtp_read ( struct ast_channel ast,
struct ooh323_pvt p 
)

Definition at line 4978 of file chan_ooh323.c.

4979{
4980 /* Retrieve audio/etc from channel. Assumes p->lock is already held. */
4981 struct ast_frame *f;
4982 struct ast_frame *dfr = NULL;
4983 static struct ast_frame null_frame = { AST_FRAME_NULL, };
4984 switch (ast_channel_fdno(ast)) {
4985 case 0:
4986 f = ast_rtp_instance_read(p->rtp, 0); /* RTP Audio */
4987 p->lastrtprx = time(NULL);
4988 break;
4989 case 1:
4990 f = ast_rtp_instance_read(p->rtp, 1); /* RTCP Control Channel */
4991 break;
4992 case 2:
4993 f = ast_rtp_instance_read(p->vrtp, 0); /* RTP Video */
4994 p->lastrtprx = time(NULL);
4995 break;
4996 case 3:
4997 f = ast_rtp_instance_read(p->vrtp, 1); /* RTCP Control Channel for video */
4998 break;
4999 case 5:
5000 f = ast_udptl_read(p->udptl); /* UDPTL t.38 data */
5001 if (gH323Debug) {
5002 ast_debug(1, "Got UDPTL %u/%d len %d for %s\n",
5004 }
5005 p->lastrtprx = time(NULL);
5006 break;
5007
5008 default:
5009 f = &null_frame;
5010 }
5011
5012 if (f && p->owner && !p->faxmode && (f->frametype == AST_FRAME_VOICE)) {
5013 /* We already hold the channel lock */
5015 struct ast_format_cap *caps;
5016
5017 ast_debug(1, "Oooh, voice format changed to %s\n", ast_format_get_name(f->subclass.format));
5018
5020 if (caps) {
5023 ao2_ref(caps, -1);
5024 }
5027 }
5028 if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad &&
5032 dfr = ast_frdup(f);
5033 dfr = ast_dsp_process(p->owner, p->vad, dfr);
5034 }
5035 } else {
5036 return f;
5037 }
5038
5039 /* process INBAND DTMF*/
5040 if (dfr && (dfr->frametype == AST_FRAME_DTMF) && ((dfr->subclass.integer == 'f') || (dfr->subclass.integer == 'e'))) {
5041 ast_debug(1, "* Detected FAX Tone %s\n", (dfr->subclass.integer == 'e') ? "CED" : "CNG");
5042 /* Switch to T.38 ON CED*/
5043 if (!p->faxmode && !p->chmodepend && (dfr->subclass.integer == 'e') && (p->t38support != T38_DISABLED)) {
5044 if (gH323Debug)
5045 ast_verb(0, "request to change %s to t.38 because fax ced\n", p->callToken);
5046 p->chmodepend = 1;
5047 p->faxdetected = 1;
5048 ooRequestChangeMode(p->callToken, 1);
5049 } else if ((dfr->subclass.integer == 'f') && !p->faxdetected) {
5050 const char *target_context = ast_channel_context(p->owner);
5051 if ((strcmp(ast_channel_exten(p->owner), "fax")) &&
5052 (ast_exists_extension(p->owner, target_context, "fax", 1,
5054 ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner));
5056 if (ast_async_goto(p->owner, target_context, "fax", 1)) {
5057 ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);
5058 }
5059 p->faxdetected = 1;
5060 ast_frfree(dfr);
5061 return &ast_null_frame;
5062 }
5063 }
5064 } else if (dfr && dfr->frametype == AST_FRAME_DTMF) {
5065 ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass.integer);
5066 ast_frfree(f);
5067 return dfr;
5068 }
5069
5070 if (dfr) {
5071 ast_frfree(dfr);
5072 }
5073 return f;
5074}
#define T38_DISABLED
Definition: chan_ooh323.c:101
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
int ast_channel_fdno(const struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition: channel.c:5781
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5822
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress,...
Definition: dsp.c:1499
@ AST_FORMAT_CMP_NOT_EQUAL
Definition: format.h:38
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
enum ast_format_cmp_res ast_format_cap_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format)
Find if ast_format is within the capabilities of the ast_format_cap object.
Definition: format_cap.c:581
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
#define ast_frdup(fr)
Copies a frame.
#define ast_frfree(fr)
@ AST_FRAME_NULL
@ AST_FRAME_VOICE
struct ast_frame ast_null_frame
Definition: main/frame.c:79
#define H323_DTMF_INBAND
Definition: ooh323cDriver.h:30
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4175
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Definition: pbx.c:6969
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition: rtp_engine.c:600
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
struct ast_format * format
struct ast_frame_subclass subclass
enum ast_frame_type frametype
struct ast_party_id id
Caller party ID.
Definition: channel.h:422
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
char * callToken
Definition: chan_ooh323.c:212
struct ast_rtp_instance * vrtp
Definition: chan_ooh323.c:189
int faxdetected
Definition: chan_ooh323.c:193
time_t lastrtprx
Definition: chan_ooh323.c:209
int chmodepend
Definition: chan_ooh323.c:201
struct ast_dsp * vad
Definition: chan_ooh323.c:242
struct ast_frame * ast_udptl_read(struct ast_udptl *udptl)
Definition: udptl.c:760

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().

◆ ooh323_set_read_format()

void ooh323_set_read_format ( ooCallData *  call,
struct ast_format fmt 
)

Definition at line 1625 of file chan_ooh323.c.

1626{
1627 struct ooh323_pvt *p = NULL;
1628
1629 if (gH323Debug)
1630 ast_verb(0, "--- ooh323_update_readformat %s\n",
1631 ast_format_get_name(fmt));
1632
1633 p = find_call(call);
1634 if (!p) {
1635 ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken);
1636 return;
1637 }
1638
1639 ast_mutex_lock(&p->lock);
1640
1641 ao2_replace(p->readformat, fmt);
1642
1643 if (p->owner) {
1644 struct ast_format_cap *caps;
1645
1647 if (!caps) {
1648 ast_log(LOG_ERROR, "Could not allocate capabilities structure\n");
1649 return;
1650 }
1651
1652 while (p->owner && ast_channel_trylock(p->owner)) {
1653 ast_debug(1,"Failed to grab lock, trying again\n");
1655 }
1656 if (!p->owner) {
1658 ast_log(LOG_ERROR, "Channel has no owner\n");
1659 ao2_ref(caps, -1);
1660 return;
1661 }
1662
1663 if (gH323Debug) {
1664 ast_verb(0, "Readformat before update %s\n",
1666 }
1667 ast_format_cap_append(caps, fmt, 0);
1669 ao2_ref(caps, -1);
1672 } else
1673 ast_log(LOG_ERROR, "No owner found\n");
1674
1676
1677 if (gH323Debug)
1678 ast_verb(0, "+++ ooh323_update_readformat\n");
1679}
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition: astobj2.h:501
struct ast_format * readformat
Definition: chan_ooh323.c:227

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.

◆ ooh323_set_write_format()

void ooh323_set_write_format ( ooCallData *  call,
struct ast_format fmt,
int  txframes 
)

Definition at line 1553 of file chan_ooh323.c.

1554{
1555 struct ooh323_pvt *p = NULL;
1556
1557 if (gH323Debug)
1558 ast_verb(0, "--- ooh323_update_writeformat %s/%d\n",
1559 ast_format_get_name(fmt), txframes);
1560
1561 p = find_call(call);
1562 if (!p) {
1563 ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken);
1564 return;
1565 }
1566
1567 ast_mutex_lock(&p->lock);
1568
1569 ao2_replace(p->writeformat, fmt);
1570
1571 if (p->owner) {
1572 struct ast_format_cap *caps;
1573
1575 if (!caps) {
1576 ast_log(LOG_ERROR, "Could not allocate capabilities structure\n");
1577 return;
1578 }
1579
1580 while (p->owner && ast_channel_trylock(p->owner)) {
1581 ast_debug(1,"Failed to grab lock, trying again\n");
1583 }
1584 if (!p->owner) {
1586 ast_log(LOG_ERROR, "Channel has no owner\n");
1587 ao2_ref(caps, -1);
1588 return;
1589 }
1590 if (gH323Debug) {
1591 struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
1592 ast_verb(0, "Writeformat before update %s/%s\n",
1595 }
1596
1597 if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
1599 p->rtp, p->dtmfcodec, "audio", "telephone-event", 0);
1600 }
1601 if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) {
1603 p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
1604 }
1605
1606 if (txframes) {
1607 ast_format_cap_set_framing(caps, txframes);
1608 }
1609 ast_format_cap_append(caps, fmt, 0);
1611 ao2_ref(caps, -1);
1615 } else
1616 ast_log(LOG_ERROR, "No owner found\n");
1617
1618
1620
1621 if (gH323Debug)
1622 ast_verb(0, "+++ ooh323_update_writeformat\n");
1623}
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:324
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:734
void ast_format_cap_set_framing(struct ast_format_cap *cap, unsigned int framing)
Set the global framing.
Definition: format_cap.c:136
#define ast_str_alloca(init_len)
Definition: strings.h:848
Support for dynamic strings.
Definition: strings.h:623
struct ast_format * writeformat
Definition: chan_ooh323.c:228

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().

◆ reload_config()

int reload_config ( int  reload)

Definition at line 2813 of file chan_ooh323.c.

2814{
2815 int format;
2816 struct ooAliases *pNewAlias = NULL, *cur, *prev;
2817 struct ast_config *cfg;
2818 struct ast_variable *v;
2819 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
2820 struct ooh323_user *user = NULL;
2821 struct ooh323_peer *peer = NULL;
2822 char *cat;
2823 const char *utype;
2824
2825 if (gH323Debug)
2826 ast_verb(0, "--- reload_config\n");
2827
2828 cfg = ast_config_load((char*)config, config_flags);
2829
2830 /* We *must* have a config file otherwise stop immediately */
2831 if (!cfg) {
2832 ast_log(LOG_NOTICE, "Unable to load config %s, OOH323 disabled\n", config);
2833 return 1;
2834 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
2835 return RESULT_SUCCESS;
2836
2837 if (reload) {
2838 delete_users();
2839 delete_peers();
2840 if (gH323Debug) {
2841 ast_verb(0, " reload_config - Freeing up alias list\n");
2842 }
2843 cur = gAliasList;
2844 while (cur) {
2845 prev = cur;
2846 cur = cur->next;
2847 ast_free(prev->value);
2848 ast_free(prev);
2849 }
2850 gAliasList = NULL;
2851 ooH323EpClearAllAliases();
2852 }
2853
2854 /* Inintialize everything to default */
2855 snprintf(gLogFile, sizeof(gLogFile), "%s/%s", ast_config_AST_LOG_DIR, DEFAULT_LOGFILE);
2856 gPort = 1720;
2857 gIP[0] = '\0';
2858 strcpy(gCallerID, DEFAULT_H323ID);
2862 gDTMFCodec = 101;
2865 gTRCLVL = OOTRCLVLERR;
2866 gRasGkMode = RasNoGatekeeper;
2867 gGatekeeper[0] = '\0';
2868 gRASIP[0] = '\0';
2869 gRTPTimeout = 60;
2870 gNat = FALSE;
2871 gRTDRInterval = 0;
2872 gRTDRCount = 0;
2874 gFastStart = 1;
2875 gTunneling = 1;
2876 gTOS = 0;
2877 strcpy(gContext, DEFAULT_CONTEXT);
2878 gAliasList = NULL;
2880 ooconfig.mTCPPortStart = 12030;
2881 ooconfig.mTCPPortEnd = 12230;
2882 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
2883
2884 v = ast_variable_browse(cfg, "general");
2885 while (v) {
2886
2887 if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
2888 v = v->next;
2889 continue;
2890 }
2891
2892 if (!strcasecmp(v->name, "port")) {
2893 gPort = (int)strtol(v->value, NULL, 10);
2894 } else if (!strcasecmp(v->name, "bindaddr")) {
2895 ast_copy_string(gIP, v->value, sizeof(gIP));
2897 ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
2898 ast_config_destroy(cfg);
2899 return 1;
2900 }
2902 v6mode = 1;
2903 }
2904 } else if (!strcasecmp(v->name, "h225portrange")) {
2905 char* endlimit = 0;
2906 char temp[512];
2907 ast_copy_string(temp, v->value, sizeof(temp));
2908 endlimit = strchr(temp, ',');
2909 if (endlimit) {
2910 *endlimit = '\0';
2911 endlimit++;
2912 ooconfig.mTCPPortStart = atoi(temp);
2913 ooconfig.mTCPPortEnd = atoi(endlimit);
2914
2915 } else {
2916 ast_log(LOG_ERROR, "h225portrange: Invalid format, separate port range with \",\"\n");
2917 }
2918 } else if (!strcasecmp(v->name, "gateway")) {
2920 } else if (!strcasecmp(v->name, "faststart")) {
2922 if (gFastStart)
2923 ooH323EpEnableFastStart();
2924 else
2925 ooH323EpDisableFastStart();
2926 } else if (!strcasecmp(v->name, "mediawaitforconnect")) {
2929 ooH323EpEnableMediaWaitForConnect();
2930 else
2931 ooH323EpDisableMediaWaitForConnect();
2932 } else if (!strcasecmp(v->name, "h245tunneling")) {
2934 if (gTunneling)
2935 ooH323EpEnableH245Tunneling();
2936 else
2937 ooH323EpDisableH245Tunneling();
2938 } else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) {
2941 } else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) {
2943 } else if (!strcasecmp(v->name, "g729onlyA")) {
2944 g729onlyA = ast_true(v->value);
2945 } else if (!strcasecmp(v->name, "roundtrip")) {
2946 sscanf(v->value, "%d,%d", &gRTDRCount, &gRTDRInterval);
2947 } else if (!strcasecmp(v->name, "trybemaster")) {
2948 gBeMaster = ast_true(v->value);
2949 if (gBeMaster)
2950 ooH323EpTryBeMaster(1);
2951 else
2952 ooH323EpTryBeMaster(0);
2953 } else if (!strcasecmp(v->name, "h323id")) {
2954 pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
2955 if (!pNewAlias) {
2956 ast_log(LOG_ERROR, "Failed to allocate memory for h323id alias\n");
2957 ast_config_destroy(cfg);
2958 return 1;
2959 }
2960 if (gAliasList == NULL) { /* first h323id - set as callerid if callerid is not set */
2962 }
2963 pNewAlias->type = T_H225AliasAddress_h323_ID;
2964 pNewAlias->value = ast_strdup(v->value);
2965 pNewAlias->next = gAliasList;
2966 gAliasList = pNewAlias;
2967 pNewAlias = NULL;
2968 } else if (!strcasecmp(v->name, "e164")) {
2969 int valid = 1;
2970 const char *tmp;
2971 for(tmp = v->value; *tmp; tmp++) {
2972 if (!isdigit(*tmp)) {
2973 valid = 0;
2974 break;
2975 }
2976 }
2977 if (valid) {
2978 pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
2979 if (!pNewAlias) {
2980 ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n");
2981 ast_config_destroy(cfg);
2982 return 1;
2983 }
2984 pNewAlias->type = T_H225AliasAddress_dialedDigits;
2985 pNewAlias->value = ast_strdup(v->value);
2986 pNewAlias->next = gAliasList;
2987 gAliasList = pNewAlias;
2988 pNewAlias = NULL;
2989 } else {
2990 ast_log(LOG_ERROR, "Invalid e164: %s\n", v->value);
2991 }
2992 } else if (!strcasecmp(v->name, "email")) {
2993 pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
2994 if (!pNewAlias) {
2995 ast_log(LOG_ERROR, "Failed to allocate memory for email alias\n");
2996 ast_config_destroy(cfg);
2997 return 1;
2998 }
2999 pNewAlias->type = T_H225AliasAddress_email_ID;
3000 pNewAlias->value = ast_strdup(v->value);
3001 pNewAlias->next = gAliasList;
3002 gAliasList = pNewAlias;
3003 pNewAlias = NULL;
3004 } else if (!strcasecmp(v->name, "t35country")) {
3005 t35countrycode = atoi(v->value);
3006 } else if (!strcasecmp(v->name, "t35extensions")) {
3007 t35extensions = atoi(v->value);
3008 } else if (!strcasecmp(v->name, "manufacturer")) {
3009 manufacturer = atoi(v->value);
3010 } else if (!strcasecmp(v->name, "vendorid")) {
3011 ast_copy_string(vendor, v->value, sizeof(vendor));
3012 } else if (!strcasecmp(v->name, "versionid")) {
3013 ast_copy_string(version, v->value, sizeof(version));
3014 } else if (!strcasecmp(v->name, "callerid")) {
3016 } else if (!strcasecmp(v->name, "incominglimit")) {
3017 gIncomingLimit = atoi(v->value);
3018 } else if (!strcasecmp(v->name, "outgoinglimit")) {
3019 gOutgoingLimit = atoi(v->value);
3020 } else if (!strcasecmp(v->name, "gatekeeper")) {
3021 if (!strcasecmp(v->value, "DISABLE")) {
3022 gRasGkMode = RasNoGatekeeper;
3023 } else if (!strcasecmp(v->value, "DISCOVER")) {
3024 gRasGkMode = RasDiscoverGatekeeper;
3025 } else {
3026 gRasGkMode = RasUseSpecificGatekeeper;
3028 }
3029 } else if (!strcasecmp(v->name, "localras")) {
3030 ast_copy_string(gRASIP, v->value, sizeof(gRASIP));
3031 ast_verb(3, " == Setting RAS IP to %s\n", gRASIP);
3032 } else if (!strcasecmp(v->name, "logfile")) {
3033 if (v->value[0] == '/') {
3034 ast_copy_string(gLogFile, v->value, sizeof(gLogFile));
3035 } else {
3036 snprintf(gLogFile, sizeof(gLogFile), "%s/%s", ast_config_AST_LOG_DIR, v->value);
3037 }
3038 } else if (!strcasecmp(v->name, "context")) {
3039 ast_copy_string(gContext, v->value, sizeof(gContext));
3040 ast_verb(3, " == Setting default context to %s\n", gContext);
3041 } else if (!strcasecmp(v->name, "nat")) {
3042 gNat = ast_true(v->value);
3043 } else if (!strcasecmp(v->name, "rtptimeout")) {
3044 gRTPTimeout = atoi(v->value);
3045 if (gRTPTimeout < 0)
3046 gRTPTimeout = 60;
3047 } else if (!strcasecmp(v->name, "tos")) {
3048 if (sscanf(v->value, "%30i", &format) == 1)
3049 gTOS = format & 0xff;
3050 else if (!strcasecmp(v->value, "lowdelay"))
3051 gTOS = IPTOS_LOWDELAY;
3052 else if (!strcasecmp(v->value, "throughput"))
3053 gTOS = IPTOS_THROUGHPUT;
3054 else if (!strcasecmp(v->value, "reliability"))
3055 gTOS = IPTOS_RELIABILITY;
3056 else if (!strcasecmp(v->value, "mincost"))
3058 else if (!strcasecmp(v->value, "none"))
3059 gTOS = 0;
3060 else
3061 ast_log(LOG_WARNING, "Invalid tos value at line %d, should be "
3062 "'lowdelay', 'throughput', 'reliability', "
3063 "'mincost', or 'none'\n", v->lineno);
3064 } else if (!strcasecmp(v->name, "amaflags")) {
3066 } else if (!strcasecmp(v->name, "accountcode")) {
3068 } else if (!strcasecmp(v->name, "disallow")) {
3070 } else if (!strcasecmp(v->name, "allow")) {
3071 const char* tcodecs = v->value;
3072 if (!strcasecmp(v->value, "all")) {
3073 tcodecs = "ulaw,alaw,g729,g723,gsm";
3074 }
3076 } else if (!strcasecmp(v->name, "dtmfmode")) {
3077 if (!strcasecmp(v->value, "inband"))
3079 else if (!strcasecmp(v->value, "rfc2833"))
3081 else if (!strcasecmp(v->value, "cisco"))
3083 else if (!strcasecmp(v->value, "q931keypad"))
3085 else if (!strcasecmp(v->value, "h245alphanumeric"))
3087 else if (!strcasecmp(v->value, "h245signal"))
3089 else {
3090 ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n",
3091 v->value);
3093 }
3094 } else if (!strcasecmp(v->name, "relaxdtmf")) {
3096 } else if (!strcasecmp(v->name, "dtmfcodec") && atoi(v->value)) {
3097 gDTMFCodec = atoi(v->value);
3098 } else if (!strcasecmp(v->name, "faxdetect")) {
3099 if (ast_true(v->value)) {
3101 } else if (ast_false(v->value)) {
3102 gFAXdetect = 0;
3103 } else {
3104 char *buf = ast_strdupa(v->value);
3105 char *word, *next = buf;
3106 gFAXdetect = 0;
3107 while ((word = strsep(&next, ","))) {
3108 if (!strcasecmp(word, "cng")) {
3110 } else if (!strcasecmp(word, "t38")) {
3112 } else {
3113 ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
3114 }
3115 }
3116
3117 }
3118 } else if (!strcasecmp(v->name, "t38support")) {
3119 if (!strcasecmp(v->value, "disabled"))
3121 if (!strcasecmp(v->value, "no"))
3123 else if (!strcasecmp(v->value, "faxgw"))
3125 else if (!strcasecmp(v->value, "yes"))
3127 } else if (!strcasecmp(v->name, "tracelevel")) {
3128 gTRCLVL = atoi(v->value);
3129 ooH323EpSetTraceLevel(gTRCLVL);
3130 } else if (!strcasecmp(v->name, "aniasdni")) {
3131 gANIasDNI = ast_true(v->value);
3132 }
3133 v = v->next;
3134 }
3135
3136 for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) {
3137 if (strcasecmp(cat, "general")) {
3138 int friend_type = 0;
3139 utype = ast_variable_retrieve(cfg, cat, "type");
3140 if (utype) {
3141 friend_type = strcasecmp(utype, "friend");
3142 if (!strcmp(utype, "user") || 0 == friend_type) {
3143 user = build_user(cat, ast_variable_browse(cfg, cat));
3144 if (user) {
3146 user->next = userl.users;
3147 userl.users = user;
3149 } else {
3150 ast_log(LOG_WARNING, "Failed to build user %s\n", cat);
3151 }
3152 }
3153 if (!strcasecmp(utype, "peer") || 0 == friend_type) {
3154 peer = build_peer(cat, ast_variable_browse(cfg, cat), friend_type);
3155 if (peer) {
3157 peer->next = peerl.peers;
3158 peerl.peers = peer;
3160 } else {
3161 ast_log(LOG_WARNING, "Failed to build peer %s\n", cat);
3162 }
3163 }
3164 }
3165 }
3166 }
3167 ast_config_destroy(cfg);
3168
3169
3170 /* Determine ip address if neccessary */
3171 if (ast_strlen_zero(gIP)) {
3172 ooGetLocalIPAddress(gIP);
3173 if (!strcmp(gIP, "127.0.0.1") || !strcmp(gIP, "::1")) {
3174 ast_log(LOG_NOTICE, "Failed to determine local ip address. Please "
3175 "specify it in ooh323.conf. OOH323 Disabled\n");
3176 return 1;
3177 }
3178 }
3179
3180 if (gH323Debug)
3181 ast_verb(0, "+++ reload_config\n");
3182
3183 return 0;
3184
3185}
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Definition: abstract_jb.c:545
#define FALSE
Definition: app_minivm.c:527
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
static int gIncomingLimit
Definition: chan_ooh323.c:379
static int gFastStart
Definition: chan_ooh323.c:367
#define DEFAULT_H323ACCNT
Definition: chan_ooh323.c:86
static char vendor[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:390
static int gANIasDNI
Definition: chan_ooh323.c:385
static int gRTDRCount
Definition: chan_ooh323.c:383
static struct ast_jb_conf default_jbconf
Definition: chan_ooh323.c:115
#define T38_FAXGW
Definition: chan_ooh323.c:103
static char gCallerID[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:355
static int g729onlyA
Definition: chan_ooh323.c:375
static char gIP[2+8 *4+7]
Definition: chan_ooh323.c:352
static int t35countrycode
Definition: chan_ooh323.c:387
static struct ast_format_cap * gCap
Definition: chan_ooh323.c:357
#define DEFAULT_H323ID
Definition: chan_ooh323.c:84
#define DEFAULT_LOGFILE
Definition: chan_ooh323.c:85
static int gIsGateway
Definition: chan_ooh323.c:366
static int gOutgoingLimit
Definition: chan_ooh323.c:380
#define DEFAULT_CONTEXT
Definition: chan_ooh323.c:83
static int gT38Support
Definition: chan_ooh323.c:361
static char gGatekeeper[100]
Definition: chan_ooh323.c:362
int delete_peers()
Definition: chan_ooh323.c:4230
#define IPTOS_MINCOST
Definition: chan_ooh323.c:77
static char gLogFile[PATH_MAX]
Definition: chan_ooh323.c:349
static struct ooh323_user * build_user(const char *name, struct ast_variable *v)
Definition: chan_ooh323.c:2368
int v6mode
Definition: chan_ooh323.c:354
static int gTRCLVL
Definition: chan_ooh323.c:382
static struct ooh323_config ooconfig
static char version[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:391
static char gAccountcode[80]
Definition: chan_ooh323.c:376
static int gFAXdetect
Definition: chan_ooh323.c:360
static int gDTMFMode
Definition: chan_ooh323.c:358
static int gTunneling
Definition: chan_ooh323.c:368
static struct ooAliases * gAliasList
Definition: chan_ooh323.c:356
static int gNat
Definition: chan_ooh323.c:384
static const char config[]
Definition: chan_ooh323.c:111
static int gMediaWaitForConnect
Definition: chan_ooh323.c:370
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
static int gPort
Definition: chan_ooh323.c:351
static int gRTPTimeout
Definition: chan_ooh323.c:374
static int gRTDRInterval
Definition: chan_ooh323.c:383
static int gBeMaster
Definition: chan_ooh323.c:369
static struct ast_jb_conf global_jbconf
Definition: chan_ooh323.c:122
static int manufacturer
Definition: chan_ooh323.c:389
static char gContext[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:378
static int gAMAFLAGS
Definition: chan_ooh323.c:377
static struct ooh323_peer * build_peer(const char *name, struct ast_variable *v, int friend_type)
Definition: chan_ooh323.c:2515
static int gDTMFCodec
Definition: chan_ooh323.c:359
static int t35extensions
Definition: chan_ooh323.c:388
int delete_users()
Definition: chan_ooh323.c:4265
static char gRASIP[2+8 *4+7]
Definition: chan_ooh323.c:363
static enum RasGatekeeperMode gRasGkMode
Definition: chan_ooh323.c:364
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition: channel.c:4379
#define RESULT_SUCCESS
Definition: cli.h:40
short word
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_format_cap_update_by_allow_disallow(struct ast_format_cap *cap, const char *list, int allowing)
Parse an "allow" or "deny" list and modify a format capabilities structure accordingly.
Definition: format_cap.c:320
void ast_format_cap_remove_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Remove all formats matching a specific format type.
Definition: format_cap.c:523
char * strsep(char **str, const char *delims)
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3326
#define CONFIG_STATUS_FILEUNCHANGED
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:784
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1215
@ CONFIG_FLAG_FILEUNCHANGED
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
Definition: netsock2.c:524
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
#define H323_DTMF_INBANDRELAX
Definition: ooh323cDriver.h:32
#define H323_DTMF_Q931
Definition: ooh323cDriver.h:27
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
const char * ast_config_AST_LOG_DIR
Definition: options.c:159
static int reload(void)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2199
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
Definition: utils.c:2216
Structure used to handle boolean flags.
Definition: utils.h:199
General jitterbuffer configuration.
Definition: abstract_jb.h:70
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next

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().

◆ restart_monitor()

int restart_monitor ( void  )

Definition at line 4082 of file chan_ooh323.c.

4083{
4084 pthread_attr_t attr;
4085
4086 /* If we're supposed to be stopped -- stay stopped */
4088 return 0;
4089 if (ast_mutex_lock(&monlock)) {
4090 ast_log(LOG_WARNING, "Unable to lock monitor\n");
4091 return -1;
4092 }
4093 if (monitor_thread == pthread_self()) {
4095 ast_log(LOG_WARNING, "Cannot kill myself\n");
4096 return -1;
4097 }
4099 /* Wake up the thread */
4100 pthread_kill(monitor_thread, SIGURG);
4101 } else {
4102 pthread_attr_init(&attr);
4103 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
4104 /* Start a new monitor */
4105 if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
4107 ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
4108 return -1;
4109 }
4110 }
4112 return 0;
4113}
static void * do_monitor(void *data)
Definition: chan_ooh323.c:3998
static ast_mutex_t monlock
Definition: chan_ooh323.c:405
static pthread_t monitor_thread
Definition: chan_ooh323.c:410
#define AST_PTHREADT_NULL
Definition: lock.h:66
#define AST_PTHREADT_STOP
Definition: lock.h:67
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:584

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().

◆ setup_rtp_connection()

void setup_rtp_connection ( ooCallData *  call,
const char *  remoteIp,
int  remotePort 
)

Definition at line 4775 of file chan_ooh323.c.

4776{
4777 struct ooh323_pvt *p = NULL;
4778 struct ast_sockaddr tmp;
4779
4780 if (gH323Debug)
4781 ast_verb(0, "--- setup_rtp_connection %s:%d\n", remoteIp, remotePort);
4782
4783 /* Find the call or allocate a private structure if call not found */
4784 p = find_call(call);
4785
4786 if (!p || !p->rtp) {
4787 ast_log(LOG_ERROR, "Something is wrong: rtp\n");
4788 return;
4789 }
4790
4791 ast_mutex_lock(&p->lock);
4792
4793 ast_parse_arg(remoteIp, PARSE_ADDR, &tmp);
4794 ast_sockaddr_set_port(&tmp, remotePort);
4796
4799 "audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD);
4800 }
4801
4803
4804 if(gH323Debug)
4805 ast_verb(0, "+++ setup_rtp_connection\n");
4806
4807 return;
4808}
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
Definition: netsock2.h:532
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.h:1138
@ AST_RTP_OPT_G726_NONSTANDARD
Definition: rtp_engine.h:147

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().

◆ setup_udptl_connection()

void setup_udptl_connection ( ooCallData *  call,
const char *  remoteIp,
int  remotePort 
)

Definition at line 4839 of file chan_ooh323.c.

4841{
4842 struct ooh323_pvt *p = NULL;
4843 struct ast_sockaddr them;
4844
4845 if (gH323Debug)
4846 ast_verb(0, "--- setup_udptl_connection\n");
4847
4848 /* Find the call or allocate a private structure if call not found */
4849 p = find_call(call);
4850
4851 if (!p) {
4852 ast_log(LOG_ERROR, "Something is wrong: rtp\n");
4853 return;
4854 }
4855
4856 ast_mutex_lock(&p->lock);
4857 if (p->owner) {
4858 while (p->owner && ast_channel_trylock(p->owner)) {
4859 ast_debug(1, "Failed to grab lock, trying again\n");
4861 }
4862 if (!p->owner) {
4864 ast_log(LOG_ERROR, "Channel has no owner\n");
4865 return;
4866 }
4867 } else {
4869 ast_log(LOG_ERROR, "Channel has no owner\n");
4870 return;
4871 }
4872
4873 ast_parse_arg(remoteIp, PARSE_ADDR, &them);
4874 ast_sockaddr_set_port(&them, remotePort);
4875
4876 ast_udptl_set_peer(p->udptl, &them);
4878 p->t38_tx_enable = 1;
4879 p->lastTxT38 = time(NULL);
4880 if (p->t38support == T38_ENABLED) {
4881 struct ast_control_t38_parameters parameters = { .request_response = 0 };
4883 parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl);
4884 parameters.rate = AST_T38_RATE_14400;
4885 ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
4886 }
4887 if (gH323Debug) {
4888 ast_debug(1, "Receiving UDPTL %s:%d\n", ast_sockaddr_stringify_host(&them),
4889 ast_sockaddr_port(&them));
4890 }
4891
4894
4895 if(gH323Debug)
4896 ast_verb(0, "+++ setup_udptl_connection\n");
4897
4898 return;
4899}
@ AST_T38_NEGOTIATED
@ AST_T38_RATE_14400
static char * ast_sockaddr_stringify_host(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brack...
Definition: netsock2.h:327
enum ast_control_t38_rate rate
time_t lastTxT38
Definition: chan_ooh323.c:200
void ast_udptl_set_peer(struct ast_udptl *udptl, const struct ast_sockaddr *them)
Definition: udptl.c:1128
void ast_udptl_set_tag(struct ast_udptl *udptl, const char *format,...)
Associates a character string 'tag' with a UDPTL session.
Definition: udptl.c:1110
unsigned int ast_udptl_get_far_max_ifp(struct ast_udptl *udptl)
retrieves far max ifp
Definition: udptl.c:1014

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().

◆ update_our_aliases()

int update_our_aliases ( ooCallData *  call,
struct ooh323_pvt p 
)

Definition at line 4949 of file chan_ooh323.c.

4950{
4951 int updated = -1;
4952 ooAliases *psAlias = NULL;
4953
4954 if (!call->ourAliases)
4955 return updated;
4956 for (psAlias = call->ourAliases; psAlias; psAlias = psAlias->next) {
4957 if (psAlias->type == T_H225AliasAddress_h323_ID) {
4958 ast_copy_string(p->callee_h323id, psAlias->value, sizeof(p->callee_h323id));
4959 updated = 1;
4960 }
4961 if (psAlias->type == T_H225AliasAddress_dialedDigits) {
4962 ast_copy_string(p->callee_dialedDigits, psAlias->value,
4963 sizeof(p->callee_dialedDigits));
4964 updated = 1;
4965 }
4966 if (psAlias->type == T_H225AliasAddress_url_ID) {
4967 ast_copy_string(p->callee_url, psAlias->value, sizeof(p->callee_url));
4968 updated = 1;
4969 }
4970 if (psAlias->type == T_H225AliasAddress_email_ID) {
4971 ast_copy_string(p->callee_email, psAlias->value, sizeof(p->callee_email));
4972 updated = 1;
4973 }
4974 }
4975 return updated;
4976}
char callee_url[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:224

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().