From e7d11d8d4c502797311f1b8f8eac075d2dcd2850 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Fri, 8 Aug 2008 16:08:08 +0300 Subject: [PATCH] Make it build with the bristuffed libpri * A macro to work around the unused interface changes in pri_hangup. * Simplified pri_error and pri_message. * But for that reason pri_new needs to get span number. * Save pri lowlevelcompatibility in the channel. PAss it explicitly to pri_sr_set_bearer. --- channels/chan_dahdi.c | 84 ++++++---------------------------------------- include/asterisk/channel.h | 1 + 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 4a138c006..ab51d4556 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -698,6 +698,9 @@ static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen); static int dahdi_func_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len); +/* a workaround for unused bristuff interface changes */ +#define pri_hangup(pri, call, cause) pri_hangup(pri, call, cause, -1) + static const struct ast_channel_tech dahdi_tech = { .type = "DAHDI", .description = tdesc, @@ -2189,7 +2192,7 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout) pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), exclusive, 1); pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, (p->digital ? -1 : - ((p->law == DAHDI_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW))); + ((p->law == DAHDI_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW)), ast->lowlayercompat); if (p->pri->facilityenable) pri_facility_enable(p->pri->pri); @@ -8353,84 +8356,17 @@ static void *do_idle_thread(void *vchan) #ifndef PRI_RESTART #error "Upgrade your libpri" #endif -static void dahdi_pri_message(struct pri *pri, char *s) +static void dahdi_pri_message(char *s, int span) { - int x, y; - int dchan = -1, span = -1; - int dchancount = 0; - - if (pri) { - for (x = 0; x < NUM_SPANS; x++) { - for (y = 0; y < NUM_DCHANS; y++) { - if (pris[x].dchans[y]) - dchancount++; - - if (pris[x].dchans[y] == pri) - dchan = y; - } - if (dchan >= 0) { - span = x; - break; - } - dchancount = 0; - } - if ((dchan >= 0) && (span >= 0)) { - if (dchancount > 1) - ast_verbose("[Span %d D-Channel %d]%s", span, dchan, s); - else - ast_verbose("%s", s); - } else - ast_log(LOG_ERROR, "PRI debug error: could not find pri associated it with debug message output\n"); - } else - ast_verbose("%s", s); - - ast_mutex_lock(&pridebugfdlock); - - if (pridebugfd >= 0) - write(pridebugfd, s, strlen(s)); - - ast_mutex_unlock(&pridebugfdlock); + ast_verbose("%d %s", span, s); } -static void dahdi_pri_error(struct pri *pri, char *s) +static void dahdi_pri_error(char *s, int span) { - int x, y; - int dchan = -1, span = -1; - int dchancount = 0; - - if (pri) { - for (x = 0; x < NUM_SPANS; x++) { - for (y = 0; y < NUM_DCHANS; y++) { - if (pris[x].dchans[y]) - dchancount++; - - if (pris[x].dchans[y] == pri) - dchan = y; - } - if (dchan >= 0) { - span = x; - break; - } - dchancount = 0; - } - if ((dchan >= 0) && (span >= 0)) { - if (dchancount > 1) - ast_log(LOG_ERROR, "[Span %d D-Channel %d] PRI: %s", span, dchan, s); - else - ast_log(LOG_ERROR, "%s", s); - } else - ast_log(LOG_ERROR, "PRI debug error: could not find pri associated it with debug message output\n"); - } else - ast_log(LOG_ERROR, "%s", s); - - ast_mutex_lock(&pridebugfdlock); - - if (pridebugfd >= 0) - write(pridebugfd, s, strlen(s)); - - ast_mutex_unlock(&pridebugfdlock); + ast_log(LOG_WARNING, "%d %s", span, s); } + static int pri_check_restart(struct dahdi_pri *pri) { do { @@ -9692,7 +9628,7 @@ static int start_pri(struct dahdi_pri *pri) dahdi_close_pri_fd(pri, i); return -1; } - pri->dchans[i] = pri_new(pri->fds[i], pri->nodetype, pri->switchtype); + pri->dchans[i] = pri_new(pri->fds[i], pri->nodetype, pri->switchtype, pri->span); /* Force overlap dial if we're doing GR-303! */ if (pri->switchtype == PRI_SWITCH_GR303_TMC) pri->overlapdial = 1; diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index d5acaf6e4..40987136d 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -408,6 +408,7 @@ struct ast_channel { char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */ int macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */ char dialcontext[AST_MAX_CONTEXT]; /*!< Dial: Extension context that we were called from */ + char lowlayercompat[16]; /*!< ISDN Low Layer Compatibility */ struct ast_pbx *pbx; /*!< PBX private structure for this channel */ int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */ -- 2.11.4.GIT