Merge latest fixes to stable branch.
This commit is contained in:
parent
ff273f0f0e
commit
e25f33a595
7
CHANGES
7
CHANGES
|
@ -1,6 +1,13 @@
|
|||
CHANGES
|
||||
=======
|
||||
|
||||
chan_capi-1.1.5
|
||||
------------------
|
||||
- corrected check for Info value on CONNECT_B3_CONF
|
||||
- fixed NULL-pointer in cid_name (asterisk 1.6 pickup revealed this)
|
||||
- changed action on prodding in .write function to ignore it
|
||||
- API adaptions to new asterisk trunk
|
||||
|
||||
chan_capi-1.1.4
|
||||
------------------
|
||||
- use extended fax if available only and have fine resolution on receive activated by default
|
||||
|
|
14
Makefile
14
Makefile
|
@ -56,7 +56,17 @@ ifeq (${OSNAME},NetBSD)
|
|||
CONFIG_DIR=$(INSTALL_PREFIX)/usr/pkg/etc/asterisk
|
||||
endif
|
||||
|
||||
OSARCH=$(shell uname -s)
|
||||
|
||||
ifeq ($(strip $(PROC)),)
|
||||
ifeq (${OSARCH},Linux)
|
||||
PROC=$(shell uname -m)
|
||||
else
|
||||
ifeq (${OSARCH},FreeBSD)
|
||||
PROC=$(shell uname -m)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
AVERSION=$(shell if grep -q "VERSION_NUM 0104" $(ASTERISK_HEADER_DIR)/asterisk/version.h; then echo V1_4; fi)
|
||||
|
||||
|
@ -87,9 +97,9 @@ endif
|
|||
|
||||
CFLAGS=-pipe -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE
|
||||
CFLAGS+=$(OPTIMIZE)
|
||||
CFLAGS+=-O6
|
||||
CFLAGS+=-O2
|
||||
CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
|
||||
CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
|
||||
CFLAGS+=$(shell if uname -m | grep -q "ppc\|arm\|s390"; then echo "-fsigned-char"; fi)
|
||||
|
||||
LIBS=-ldl -lpthread -lm
|
||||
CC=gcc
|
||||
|
|
2
README
2
README
|
@ -1,6 +1,6 @@
|
|||
chan_capi a Common ISDN API 2.0 implementation for Asterisk
|
||||
|
||||
Copyright (C) 2005-2009 Cytronics & Melware
|
||||
Copyright (C) 2005-2010 Cytronics & Melware
|
||||
Armin Schindler <armin@melware.de>
|
||||
|
||||
Reworked, but based on the work of
|
||||
|
|
74
chan_capi.c
74
chan_capi.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* An implementation of Common ISDN API 2.0 for Asterisk
|
||||
*
|
||||
* Copyright (C) 2005-2009 Cytronics & Melware
|
||||
* Copyright (C) 2005-2010 Cytronics & Melware
|
||||
*
|
||||
* Armin Schindler <armin@melware.de>
|
||||
*
|
||||
|
@ -177,7 +177,11 @@ static char capi_subscriber_prefix[AST_MAX_EXTENSION];
|
|||
|
||||
static char default_language[MAX_LANGUAGE] = "";
|
||||
|
||||
#ifdef CC_AST_HAS_FORMAT_T
|
||||
format_t capi_capability = AST_FORMAT_ALAW;
|
||||
#else
|
||||
int capi_capability = AST_FORMAT_ALAW;
|
||||
#endif
|
||||
|
||||
static int null_plci_dtmf_support = 1;
|
||||
|
||||
|
@ -791,7 +795,7 @@ static int local_queue_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
if ((i->state == CAPI_STATE_DISCONNECTING) ||
|
||||
(i->isdnstate & CAPI_ISDN_STATE_HANGUP)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_4 "%s: no queue_frame in state disconnecting for %d/%d\n",
|
||||
i->vname, f->frametype, f->subclass);
|
||||
i->vname, f->frametype, FRAME_SUBCLASS_INTEGER(f->subclass));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -800,7 +804,7 @@ static int local_queue_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
}
|
||||
|
||||
if ((f->frametype == AST_FRAME_CONTROL) &&
|
||||
(f->subclass == AST_CONTROL_HANGUP)) {
|
||||
(FRAME_SUBCLASS_INTEGER(f->subclass) == AST_CONTROL_HANGUP)) {
|
||||
i->isdnstate |= CAPI_ISDN_STATE_HANGUP;
|
||||
}
|
||||
|
||||
|
@ -1068,7 +1072,11 @@ static void interface_cleanup(struct capi_pvt *i)
|
|||
|
||||
i->rtpcodec = 0;
|
||||
if (i->rtp) {
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
ast_rtp_instance_destroy(i->rtp);
|
||||
#else
|
||||
ast_rtp_destroy(i->rtp);
|
||||
#endif
|
||||
i->rtp = NULL;
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1170,7 @@ static void send_progress(struct capi_pvt *i)
|
|||
|
||||
if (!(i->isdnstate & CAPI_ISDN_STATE_PROGRESS)) {
|
||||
i->isdnstate |= CAPI_ISDN_STATE_PROGRESS;
|
||||
fr.subclass = AST_CONTROL_PROGRESS;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_PROGRESS;
|
||||
local_queue_frame(i, &fr);
|
||||
}
|
||||
return;
|
||||
|
@ -2123,7 +2131,7 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state, const char *l
|
|||
int fmt;
|
||||
|
||||
#ifdef CC_AST_HAS_EXT_CHAN_ALLOC
|
||||
tmp = ast_channel_alloc(0, state, i->cid, NULL,
|
||||
tmp = ast_channel_alloc(0, state, i->cid, emptyid,
|
||||
#ifdef CC_AST_HAS_EXT2_CHAN_ALLOC
|
||||
i->accountcode, i->dnid, i->context,
|
||||
#ifdef CC_AST_HAS_LINKEDID_CHAN_ALLOC
|
||||
|
@ -2296,9 +2304,14 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state, const char *l
|
|||
* PBX wants us to dial ...
|
||||
*/
|
||||
#ifdef CC_AST_HAS_REQUEST_REQUESTOR
|
||||
#ifdef CC_AST_HAS_REQUEST_FORMAT_T
|
||||
static struct ast_channel *
|
||||
pbx_capi_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
|
||||
/* TODO: new field requestor to link to called channel */
|
||||
#else
|
||||
static struct ast_channel *
|
||||
pbx_capi_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
|
||||
/* TODO: new field requestor to link to called channel */
|
||||
#endif
|
||||
#else
|
||||
static struct ast_channel *
|
||||
pbx_capi_request(const char *type, int format, void *data, int *cause)
|
||||
|
@ -2881,7 +2894,8 @@ static void clear_channel_fax_loop(struct ast_channel *c, struct capi_pvt *i)
|
|||
i->vname);
|
||||
break;
|
||||
}
|
||||
if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) {
|
||||
if ((f->frametype == AST_FRAME_CONTROL) &&
|
||||
(FRAME_SUBCLASS_INTEGER(f->subclass) == AST_CONTROL_HANGUP)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: clear channel fax: hangup frame.\n",
|
||||
i->vname);
|
||||
ast_frfree(f);
|
||||
|
@ -2896,7 +2910,7 @@ static void clear_channel_fax_loop(struct ast_channel *c, struct capi_pvt *i)
|
|||
i->vname);
|
||||
} else {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: cler channel fax: unhandled frame %d/%d.\n",
|
||||
i->vname, f->frametype, f->subclass);
|
||||
i->vname, f->frametype, FRAME_SUBCLASS_INTEGER(f->subclass));
|
||||
}
|
||||
ast_frfree(f);
|
||||
} else if (ready_fd == i->readerfd) {
|
||||
|
@ -3545,7 +3559,7 @@ static void capidev_handle_did_digits(_cmsg *CMSG, unsigned int PLCI, unsigned i
|
|||
/* we are already in pbx, so we send the digits as dtmf */
|
||||
for (a = 0; a < strlen(did); a++) {
|
||||
fr.frametype = AST_FRAME_DTMF;
|
||||
fr.subclass = did[a];
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = did[a];
|
||||
local_queue_frame(i, &fr);
|
||||
}
|
||||
}
|
||||
|
@ -3561,16 +3575,18 @@ static void capidev_handle_did_digits(_cmsg *CMSG, unsigned int PLCI, unsigned i
|
|||
*/
|
||||
void capi_queue_cause_control(struct capi_pvt *i, int control)
|
||||
{
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, };
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, };
|
||||
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_HANGUP;
|
||||
|
||||
if ((i->owner) && (control)) {
|
||||
int cause = i->owner->hangupcause;
|
||||
if (cause == AST_CAUSE_NORMAL_CIRCUIT_CONGESTION) {
|
||||
fr.subclass = AST_CONTROL_CONGESTION;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_CONGESTION;
|
||||
} else if ((cause != AST_CAUSE_NO_USER_RESPONSE) &&
|
||||
(cause != AST_CAUSE_NO_ANSWER)) {
|
||||
/* not NOANSWER */
|
||||
fr.subclass = AST_CONTROL_BUSY;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_BUSY;
|
||||
}
|
||||
}
|
||||
local_queue_frame(i, &fr);
|
||||
|
@ -3873,7 +3889,7 @@ static void capidev_handle_info_indication(_cmsg *CMSG, unsigned int PLCI, unsig
|
|||
i->vname);
|
||||
send_progress(i);
|
||||
fr.frametype = AST_FRAME_CONTROL;
|
||||
fr.subclass = AST_CONTROL_RINGING;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_RINGING;
|
||||
local_queue_frame(i, &fr);
|
||||
if (i->owner)
|
||||
ast_setstate(i->owner, AST_STATE_RINGING);
|
||||
|
@ -3883,7 +3899,7 @@ static void capidev_handle_info_indication(_cmsg *CMSG, unsigned int PLCI, unsig
|
|||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: info element CALL PROCEEDING\n",
|
||||
i->vname);
|
||||
fr.frametype = AST_FRAME_CONTROL;
|
||||
fr.subclass = AST_CONTROL_PROCEEDING;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_PROCEEDING;
|
||||
local_queue_frame(i, &fr);
|
||||
break;
|
||||
case 0x8003: /* PROGRESS */
|
||||
|
@ -4135,7 +4151,7 @@ static int handle_facility_indication_dtmf(
|
|||
|
||||
while (i->special_tone_extension[n] != 0) {
|
||||
fr.frametype = AST_FRAME_DTMF;
|
||||
fr.subclass = i->special_tone_extension[n++];
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = i->special_tone_extension[n++];
|
||||
local_queue_frame(i, &fr);
|
||||
}
|
||||
}
|
||||
|
@ -4146,7 +4162,7 @@ static int handle_facility_indication_dtmf(
|
|||
if (ignore_digit == 0) {
|
||||
if (pbx_capi_voicecommand_process_digit(i, 0, dtmf) == 0) {
|
||||
fr.frametype = AST_FRAME_DTMF;
|
||||
fr.subclass = dtmf;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = dtmf;
|
||||
local_queue_frame(i, &fr);
|
||||
}
|
||||
}
|
||||
|
@ -4229,7 +4245,7 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
}
|
||||
#ifndef CC_AST_HAS_VERSION_1_4
|
||||
fr.frametype = AST_FRAME_CONTROL;
|
||||
fr.subclass = AST_CONTROL_PROGRESS;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_PROGRESS;
|
||||
local_queue_frame(i, &fr);
|
||||
#endif
|
||||
return;
|
||||
|
@ -4289,9 +4305,9 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
}
|
||||
}
|
||||
}
|
||||
fr.subclass = capi_capability;
|
||||
FRAME_SUBCLASS_CODEC(fr.subclass) = capi_capability;
|
||||
} else {
|
||||
fr.subclass = i->codec;
|
||||
FRAME_SUBCLASS_CODEC(fr.subclass) = i->codec;
|
||||
}
|
||||
|
||||
fr.frametype = AST_FRAME_VOICE;
|
||||
|
@ -4302,8 +4318,8 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
fr.mallocd = 0;
|
||||
fr.delivery = ast_tv(0,0);
|
||||
fr.src = NULL;
|
||||
cc_verbose(8, 1, VERBOSE_PREFIX_3 "%s: DATA_B3_IND (len=%d) fr.datalen=%d fr.subclass=%d\n",
|
||||
i->vname, b3len, fr.datalen, fr.subclass);
|
||||
cc_verbose(8, 1, VERBOSE_PREFIX_3 "%s: DATA_B3_IND (len=%d) fr.datalen=%d fr.subclass=%ld\n",
|
||||
i->vname, b3len, fr.datalen, FRAME_SUBCLASS_CODEC(fr.subclass));
|
||||
local_queue_frame(i, &fr);
|
||||
return;
|
||||
}
|
||||
|
@ -4313,7 +4329,9 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
*/
|
||||
static void capi_signal_answer(struct capi_pvt *i)
|
||||
{
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER, };
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, };
|
||||
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_ANSWER;
|
||||
|
||||
if (i->outgoing == 1) {
|
||||
local_queue_frame(i, &fr);
|
||||
|
@ -4602,9 +4620,11 @@ static void capidev_handle_connect_b3_indication(_cmsg *CMSG, unsigned int PLCI,
|
|||
*/
|
||||
static void capidev_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, unsigned int NCCI, struct capi_pvt *i)
|
||||
{
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, };
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, };
|
||||
int state;
|
||||
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_HANGUP;
|
||||
|
||||
capi_sendf(NULL, 0, CAPI_DISCONNECT_RESP, PLCI, HEADER_MSGNUM(CMSG), "");
|
||||
|
||||
show_capi_info(i, DISCONNECT_IND_REASON(CMSG));
|
||||
|
@ -4651,7 +4671,7 @@ static void capidev_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI,
|
|||
}
|
||||
|
||||
if (DISCONNECT_IND_REASON(CMSG) == 0x34a2) {
|
||||
fr.subclass = AST_CONTROL_CONGESTION;
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_CONGESTION;
|
||||
}
|
||||
|
||||
if (state == CAPI_STATE_DISCONNECTING) {
|
||||
|
@ -5022,7 +5042,9 @@ void capidev_handle_connection_conf(struct capi_pvt **i, unsigned int PLCI,
|
|||
unsigned short wInfo, unsigned short wMsgNum)
|
||||
{
|
||||
struct capi_pvt *ii;
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_BUSY, };
|
||||
struct ast_frame fr = { AST_FRAME_CONTROL, };
|
||||
|
||||
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_BUSY;
|
||||
|
||||
if (*i) {
|
||||
cc_log(LOG_ERROR, CC_MESSAGE_BIGNAME ": CONNECT_CONF for already "
|
||||
|
@ -5127,7 +5149,7 @@ static void capidev_handle_msg(_cmsg *CMSG)
|
|||
case CAPI_P_CONF(CONNECT_B3):
|
||||
wInfo = CONNECT_B3_CONF_INFO(CMSG);
|
||||
if(i == NULL) break;
|
||||
if (wInfo == 0) {
|
||||
if ((wInfo & 0xff00) == 0) {
|
||||
i->NCCI = NCCI;
|
||||
if (i->channeltype != CAPI_CHANNELTYPE_NULL) {
|
||||
capi_controllers[i->controller]->nfreebchannels--;
|
||||
|
|
28
chan_capi.h
28
chan_capi.h
|
@ -31,7 +31,11 @@
|
|||
#include <asterisk/features.h>
|
||||
#include <asterisk/utils.h>
|
||||
#include <asterisk/cli.h>
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
#include <asterisk/rtp_engine.h>
|
||||
#else
|
||||
#include <asterisk/rtp.h>
|
||||
#endif
|
||||
#include <asterisk/causes.h>
|
||||
#include <asterisk/strings.h>
|
||||
#include <asterisk/dsp.h>
|
||||
|
@ -126,6 +130,14 @@ static inline unsigned int read_capi_dword(void *m)
|
|||
#define FRAME_DATA_PTR data
|
||||
#endif
|
||||
|
||||
#ifdef CC_AST_HAS_UNION_SUBCLASS_IN_FRAME
|
||||
#define FRAME_SUBCLASS_INTEGER(x) x.integer
|
||||
#define FRAME_SUBCLASS_CODEC(x) x.codec
|
||||
#else
|
||||
#define FRAME_SUBCLASS_INTEGER(x) x
|
||||
#define FRAME_SUBCLASS_CODEC(x) x
|
||||
#endif
|
||||
|
||||
#ifndef CC_AST_HAS_CHANNEL_RELEASE
|
||||
#define ast_channel_release(x) ast_channel_free(x)
|
||||
#endif
|
||||
|
@ -496,8 +508,16 @@ struct capi_pvt {
|
|||
time_t whentoretrieve;
|
||||
|
||||
/* RTP */
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
struct ast_rtp_instance *rtp;
|
||||
#else
|
||||
struct ast_rtp *rtp;
|
||||
#endif
|
||||
#ifdef CC_AST_HAS_FORMAT_T
|
||||
format_t capability;
|
||||
#else
|
||||
int capability;
|
||||
#endif
|
||||
int rtpcodec;
|
||||
int codec;
|
||||
unsigned int timestamp;
|
||||
|
@ -570,7 +590,11 @@ struct cc_capi_conf {
|
|||
float rxgain;
|
||||
float txgain;
|
||||
struct ast_codec_pref prefs;
|
||||
#ifdef CC_AST_HAS_FORMAT_T
|
||||
format_t capability;
|
||||
#else
|
||||
int capability;
|
||||
#endif
|
||||
#ifdef CC_AST_HAS_VERSION_1_4
|
||||
struct ast_jb_conf jbconf;
|
||||
char mohinterpret[MAX_MUSICCLASS];
|
||||
|
@ -666,7 +690,11 @@ struct cc_capi_controller {
|
|||
* prototypes
|
||||
*/
|
||||
extern const struct ast_channel_tech capi_tech;
|
||||
#ifdef CC_AST_HAS_FORMAT_T
|
||||
extern format_t capi_capability;
|
||||
#else
|
||||
extern int capi_capability;
|
||||
#endif
|
||||
extern unsigned capi_ApplID;
|
||||
extern struct capi_pvt *capi_iflist;
|
||||
extern void cc_start_b3(struct capi_pvt *i);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <errno.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
|
@ -484,7 +485,8 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i,
|
|||
i->vname);
|
||||
break;
|
||||
}
|
||||
if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) {
|
||||
if ((f->frametype == AST_FRAME_CONTROL) &&
|
||||
(FRAME_SUBCLASS_INTEGER(f->subclass) == AST_CONTROL_HANGUP)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: chat: hangup frame.\n",
|
||||
i->vname);
|
||||
ast_frfree(f);
|
||||
|
@ -501,11 +503,15 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i,
|
|||
/* ignore NULL frame */
|
||||
cc_verbose(5, 1, VERBOSE_PREFIX_3 "%s: chat: NULL frame, ignoring.\n",
|
||||
i->vname);
|
||||
#ifdef CC_AST_HAS_VERSION_1_4
|
||||
} else if ((f->frametype == AST_FRAME_DTMF_END) && (voice_message == NULL)) {
|
||||
pbx_capi_voicecommand_process_digit (i, c, f->subclass);
|
||||
#else
|
||||
} else if ((f->frametype == AST_FRAME_DTMF) && (voice_message == NULL)) {
|
||||
#endif
|
||||
pbx_capi_voicecommand_process_digit(i, c, FRAME_SUBCLASS_INTEGER(f->subclass));
|
||||
} else {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: chat: unhandled frame %d/%d.\n",
|
||||
i->vname, f->frametype, f->subclass);
|
||||
i->vname, f->frametype, FRAME_SUBCLASS_INTEGER(f->subclass));
|
||||
}
|
||||
ast_frfree(f);
|
||||
} else if (ready_fd == i->readerfd) {
|
||||
|
|
|
@ -51,7 +51,7 @@ void cc_qsig_verbose(int c_d, char *text, ...)
|
|||
if (option_verbose > 4) {
|
||||
if ((!c_d) || ((c_d) && (capiqsigdebug))) {
|
||||
cc_mutex_lock(&qsig_verbose_lock);
|
||||
cc_pbx_verbose(line);
|
||||
cc_pbx_verbose("%s", line);
|
||||
cc_mutex_unlock(&qsig_verbose_lock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,12 +166,23 @@ int capi_alloc_rtp(struct capi_pvt *i)
|
|||
hp = ast_gethostbyname("localhost", &ahp);
|
||||
memcpy(&addr, hp->h_addr, sizeof(addr));
|
||||
|
||||
if (!(i->rtp = ast_rtp_new_with_bindaddr(NULL, NULL, 0, 0, addr))) {
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
i->rtp = ast_rtp_instance_new(NULL, NULL, (struct sockaddr_in *)&addr, NULL);
|
||||
#else
|
||||
i->rtp = ast_rtp_new_with_bindaddr(NULL, NULL, 0, 0, addr);
|
||||
#endif
|
||||
|
||||
if (!(i->rtp)) {
|
||||
cc_log(LOG_ERROR, "%s: unable to alloc rtp.\n", i->vname);
|
||||
return 1;
|
||||
}
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
ast_rtp_instance_get_local_address(i->rtp, &us);
|
||||
ast_rtp_instance_set_remote_address(i->rtp, &us);
|
||||
#else
|
||||
ast_rtp_get_us(i->rtp, &us);
|
||||
ast_rtp_set_peer(i->rtp, &us);
|
||||
#endif
|
||||
cc_verbose(2, 1, VERBOSE_PREFIX_4 "%s: alloc rtp socket on %s:%d\n",
|
||||
i->vname,
|
||||
#ifdef CC_AST_HAS_VERSION_1_4
|
||||
|
@ -202,17 +213,28 @@ int capi_write_rtp(struct capi_pvt *i, struct ast_frame *f)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
ast_rtp_instance_get_local_address(i->rtp, &us);
|
||||
ast_rtp_instance_set_remote_address(i->rtp, &us);
|
||||
if (ast_rtp_instance_write(i->rtp, f) != 0) {
|
||||
#else
|
||||
ast_rtp_get_us(i->rtp, &us);
|
||||
ast_rtp_set_peer(i->rtp, &us);
|
||||
if (ast_rtp_write(i->rtp, f) != 0) {
|
||||
#endif
|
||||
cc_verbose(3, 0, VERBOSE_PREFIX_2 "%s: rtp_write error, dropping packet.\n",
|
||||
i->vname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
len = recvfrom(ast_rtp_fd(i->rtp), buf, sizeof(buf),
|
||||
0, (struct sockaddr *)&us, &uslen);
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
len = recvfrom(ast_rtp_instance_fd(i->rtp, 0),
|
||||
buf, sizeof(buf), 0, (struct sockaddr *)&us, &uslen);
|
||||
#else
|
||||
len = recvfrom(ast_rtp_fd(i->rtp),
|
||||
buf, sizeof(buf), 0, (struct sockaddr *)&us, &uslen);
|
||||
#endif
|
||||
if (len <= 0)
|
||||
break;
|
||||
|
||||
|
@ -238,7 +260,7 @@ int capi_write_rtp(struct capi_pvt *i, struct ast_frame *f)
|
|||
i->send_buffer_handle++;
|
||||
|
||||
cc_verbose(6, 1, VERBOSE_PREFIX_4 "%s: RTP write for NCCI=%#x len=%d(%d) %s ts=%x\n",
|
||||
i->vname, i->NCCI, len, f->datalen, ast_getformatname(f->subclass),
|
||||
i->vname, i->NCCI, len, f->datalen, ast_getformatname(FRAME_SUBCLASS_CODEC(f->subclass)),
|
||||
i->timestamp);
|
||||
|
||||
capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
|
||||
|
@ -269,28 +291,42 @@ struct ast_frame *capi_read_rtp(struct capi_pvt *i, unsigned char *buf, int len)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
ast_rtp_instance_get_local_address(i->rtp, &us);
|
||||
ast_rtp_instance_set_remote_address(i->rtp, &us);
|
||||
#else
|
||||
ast_rtp_get_us(i->rtp, &us);
|
||||
ast_rtp_set_peer(i->rtp, &us);
|
||||
#endif
|
||||
|
||||
if (len != sendto(ast_rtp_fd(i->rtp), buf, len, 0, (struct sockaddr *)&us, sizeof(us))) {
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
if (len != sendto(ast_rtp_instance_fd(i->rtp, 0), buf, len, 0, (struct sockaddr *)&us, sizeof(us)))
|
||||
#else
|
||||
if (len != sendto(ast_rtp_fd(i->rtp), buf, len, 0, (struct sockaddr *)&us, sizeof(us)))
|
||||
#endif
|
||||
{
|
||||
cc_verbose(4, 1, VERBOSE_PREFIX_3 "%s: RTP sendto error\n",
|
||||
i->vname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CC_AST_HAS_RTP_ENGINE_H
|
||||
if ((f = ast_rtp_instance_read(i->rtp, 0))) {
|
||||
#else
|
||||
if ((f = ast_rtp_read(i->rtp))) {
|
||||
#endif
|
||||
if (f->frametype != AST_FRAME_VOICE) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: DATA_B3_IND RTP (len=%d) non voice type=%d\n",
|
||||
i->vname, len, f->frametype);
|
||||
return NULL;
|
||||
}
|
||||
cc_verbose(6, 1, VERBOSE_PREFIX_4 "%s: DATA_B3_IND RTP NCCI=%#x len=%d %s (read/write=%d/%d)\n",
|
||||
i->vname, i->NCCI, len, ast_getformatname(f->subclass),
|
||||
i->vname, i->NCCI, len, ast_getformatname(FRAME_SUBCLASS_CODEC(f->subclass)),
|
||||
i->owner->readformat, i->owner->writeformat);
|
||||
if (i->owner->nativeformats != f->subclass) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: DATA_B3_IND RTP nativeformats=%d, but subclass=%d\n",
|
||||
i->vname, i->owner->nativeformats, f->subclass);
|
||||
i->owner->nativeformats = f->subclass;
|
||||
if (i->owner->nativeformats != FRAME_SUBCLASS_CODEC(f->subclass)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: DATA_B3_IND RTP nativeformats=%d, but subclass=%ld\n",
|
||||
i->vname, i->owner->nativeformats, FRAME_SUBCLASS_CODEC(f->subclass));
|
||||
i->owner->nativeformats = FRAME_SUBCLASS_CODEC(f->subclass);
|
||||
ast_set_read_format(i->owner, i->owner->readformat);
|
||||
ast_set_write_format(i->owner, i->owner->writeformat);
|
||||
}
|
||||
|
|
|
@ -683,6 +683,10 @@ void handle_facility_confirmation_supplementary(
|
|||
name, PLCI);
|
||||
}
|
||||
break;
|
||||
case 0x000d: /* CD */
|
||||
cc_verbose(2, 1, VERBOSE_PREFIX_3 "%s: CD confirmation (0x%04x) (PLCI=%#x)\n",
|
||||
name, serviceinfo, PLCI);
|
||||
break;
|
||||
case 0x000f: /* CCBS request */
|
||||
cc_verbose(2, 1, VERBOSE_PREFIX_3 "%s: CCBS request confirmation (0x%04x) (PLCI=%#x)\n",
|
||||
name, serviceinfo, PLCI);
|
||||
|
|
|
@ -70,7 +70,7 @@ void cc_verbose_internal(char *text, ...)
|
|||
#endif
|
||||
|
||||
cc_mutex_lock(&verbose_lock);
|
||||
cc_pbx_verbose(line);
|
||||
cc_pbx_verbose("%s", line);
|
||||
cc_mutex_unlock(&verbose_lock);
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ struct ast_frame *capi_read_pipeframe(struct capi_pvt *i)
|
|||
|
||||
f = &i->f;
|
||||
f->frametype = AST_FRAME_NULL;
|
||||
f->subclass = 0;
|
||||
FRAME_SUBCLASS_INTEGER(f->subclass) = 0;
|
||||
|
||||
readsize = read(i->readerfd, f, sizeof(struct ast_frame));
|
||||
if ((readsize != sizeof(struct ast_frame)) && (readsize > 0)) {
|
||||
|
@ -1308,7 +1308,8 @@ struct ast_frame *capi_read_pipeframe(struct capi_pvt *i)
|
|||
f->mallocd = 0;
|
||||
f->FRAME_DATA_PTR = NULL;
|
||||
|
||||
if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) {
|
||||
if ((f->frametype == AST_FRAME_CONTROL) &&
|
||||
(FRAME_SUBCLASS_INTEGER(f->subclass) == AST_CONTROL_HANGUP)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1367,6 +1368,10 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
if (unlikely(f->frametype == AST_FRAME_NULL)) {
|
||||
return 0;
|
||||
}
|
||||
if (unlikely((!f->FRAME_DATA_PTR) || (!f->datalen))) {
|
||||
/* prodding from Asterisk, just returning */
|
||||
return 0;
|
||||
}
|
||||
if (unlikely(f->frametype == AST_FRAME_DTMF)) {
|
||||
cc_log(LOG_ERROR, "dtmf frame should be written\n");
|
||||
return 0;
|
||||
|
@ -1380,15 +1385,12 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
i->vname);
|
||||
return 0;
|
||||
}
|
||||
if (unlikely((!f->FRAME_DATA_PTR) || (!f->datalen))) {
|
||||
cc_log(LOG_DEBUG, "No data for FRAME_VOICE %s\n", i->vname);
|
||||
return 0;
|
||||
}
|
||||
if (i->isdnstate & CAPI_ISDN_STATE_RTP) {
|
||||
if (unlikely((!(f->subclass & i->codec)) &&
|
||||
(f->subclass != capi_capability))) {
|
||||
if (unlikely((!(FRAME_SUBCLASS_CODEC(f->subclass) & i->codec)) &&
|
||||
(FRAME_SUBCLASS_CODEC(f->subclass) != capi_capability))) {
|
||||
cc_log(LOG_ERROR, "don't know how to write subclass %s(%d)\n",
|
||||
ast_getformatname(f->subclass), f->subclass);
|
||||
ast_getformatname(FRAME_SUBCLASS_CODEC(f->subclass)),
|
||||
FRAME_SUBCLASS_INTEGER(f->subclass));
|
||||
return 0;
|
||||
}
|
||||
return capi_write_rtp(i, f);
|
||||
|
|
|
@ -34,6 +34,11 @@ if [ "$AVERSION" = "" ]; then
|
|||
AVERSION="trunk"
|
||||
VER="1_6"
|
||||
fi
|
||||
if [ -z "$AVERSIONNUM" ]; then
|
||||
AVERSIONNUM=999999
|
||||
AVERSION="trunk"
|
||||
VER="1_6"
|
||||
fi
|
||||
echo $AVERSION
|
||||
|
||||
echo "/*" >$CONFIGFILE
|
||||
|
@ -163,6 +168,13 @@ check_version_onesix()
|
|||
echo "#undef CC_AST_HAS_UNION_DATA_IN_FRAME" >>$CONFIGFILE
|
||||
echo " * no new union data in ast_frame structure"
|
||||
fi
|
||||
if grep -q "union ast_frame_subclass subclass" $INCLUDEDIR/frame.h; then
|
||||
echo "#define CC_AST_HAS_UNION_SUBCLASS_IN_FRAME" >>$CONFIGFILE
|
||||
echo " * found new union subclass in ast_frame structure"
|
||||
else
|
||||
echo "#undef CC_AST_HAS_UNION_SUBCLASS_IN_FRAME" >>$CONFIGFILE
|
||||
echo " * no new union subclass in ast_frame structure"
|
||||
fi
|
||||
if grep -q "ast_channel_release.*struct" $INCLUDEDIR/channel.h; then
|
||||
echo "#define CC_AST_HAS_CHANNEL_RELEASE" >>$CONFIGFILE
|
||||
echo " * found ast_channel_release function"
|
||||
|
@ -184,6 +196,13 @@ check_version_onesix()
|
|||
echo "#undef CC_AST_HAS_REQUEST_REQUESTOR" >>$CONFIGFILE
|
||||
echo " * no requestor in ast_request"
|
||||
fi
|
||||
if grep -q "ast_request.*format_t format" $INCLUDEDIR/channel.h; then
|
||||
echo "#define CC_AST_HAS_REQUEST_FORMAT_T" >>$CONFIGFILE
|
||||
echo " * found format_t in ast_request"
|
||||
else
|
||||
echo "#undef CC_AST_HAS_REQUEST_FORMAT_T" >>$CONFIGFILE
|
||||
echo " * no format_t in ast_request"
|
||||
fi
|
||||
if grep -q "ast_register_application2.*void " $INCLUDEDIR/module.h; then
|
||||
echo "#undef CC_AST_HAS_CONST_CHAR_IN_REGAPPL" >>$CONFIGFILE
|
||||
echo " * no const char in ast_register_application"
|
||||
|
@ -198,6 +217,24 @@ check_version_onesix()
|
|||
echo "#undef CC_AST_HAS_LINKEDID_CHAN_ALLOC" >>$CONFIGFILE
|
||||
echo " * no linkedid in ast_channel_alloc"
|
||||
fi
|
||||
if [ -f $INCLUDEDIR/frame_defs.h ]; then
|
||||
if grep -q "typedef.*format_t" $INCLUDEDIR/frame_defs.h; then
|
||||
echo "#define CC_AST_HAS_FORMAT_T" >>$CONFIGFILE
|
||||
echo " * found format_t in frame_defs"
|
||||
else
|
||||
echo "#undef CC_AST_HAS_FORMAT_T" >>$CONFIGFILE
|
||||
echo " * no format_t in frame_defs"
|
||||
fi
|
||||
else
|
||||
echo "#undef CC_AST_HAS_FORMAT_T" >>$CONFIGFILE
|
||||
fi
|
||||
if [ -f $INCLUDEDIR/rtp_engine.h ]; then
|
||||
echo "#define CC_AST_HAS_RTP_ENGINE_H" >>$CONFIGFILE
|
||||
echo " * found rtp_engine.h"
|
||||
else
|
||||
echo "#undef CC_AST_HAS_RTP_ENGINE_H" >>$CONFIGFILE
|
||||
echo " * no rtp_engine.h"
|
||||
fi
|
||||
}
|
||||
|
||||
case $VER in
|
||||
|
|
|
@ -303,12 +303,14 @@ static void write_capi_trace(int send, unsigned char *buf, int length, int datam
|
|||
|
||||
fd = open(tracefile, O_WRONLY | O_CREAT | O_APPEND, 0644);
|
||||
if (fd >= 0) {
|
||||
int tmp;
|
||||
|
||||
ltime = (_cdword)time(NULL);
|
||||
capimsg_setu16(header, 0, length + sizeof(header));
|
||||
capimsg_setu32(header, 2, ltime);
|
||||
header[6] = (send) ? 0x80:0x81;
|
||||
write(fd, header, sizeof(header));
|
||||
write(fd, buf, length);
|
||||
tmp = write(fd, header, sizeof(header));
|
||||
tmp = write(fd, buf, length);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
@ -981,13 +983,23 @@ capi20_get_profile(unsigned Ctrl, unsigned char *Buf)
|
|||
if (remote_capi) {
|
||||
unsigned char buf[100];
|
||||
unsigned char *p = buf;
|
||||
unsigned fret;
|
||||
|
||||
set_rcapicmd_header(&p, 14, RCAPI_GET_PROFILE_REQ, Ctrl);
|
||||
if(!(remote_command(capi_fd, buf, 14, RCAPI_GET_PROFILE_CONF)))
|
||||
return CapiMsgOSResourceErr;
|
||||
if(*(unsigned short *)buf == CapiNoError) {
|
||||
memcpy(Buf, buf + 2, (Ctrl) ? sizeof(struct capi_profile) : 2);
|
||||
|
||||
{
|
||||
unsigned short* tmp = (unsigned short*)buf;
|
||||
|
||||
if(*tmp == CapiNoError) {
|
||||
memcpy(Buf, buf + 2, (Ctrl) ? sizeof(struct capi_profile) : 2);
|
||||
}
|
||||
|
||||
fret = *tmp;
|
||||
}
|
||||
return (*(unsigned short *)buf);
|
||||
|
||||
return (fret);
|
||||
}
|
||||
|
||||
ioctl_data.contr = Ctrl;
|
||||
|
|
Loading…
Reference in New Issue