adding support for AOCD facility messages.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39987 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Nadi Sarrar 19 years ago
parent f7d117d24f
commit 864c934f53

@ -413,13 +413,39 @@ static char *bearer2str(int cap) {
} }
static void print_facility(struct FacReqParm *fac, struct misdn_bchannel *bc) static void print_facility(struct FacParm *fac, struct misdn_bchannel *bc)
{ {
switch (fac->Function) { switch (fac->Function) {
case FacReq_CD: case Fac_CD:
chan_misdn_log(0,bc->port," --> calldeflect to: %s, screened: %s\n", fac->u.CDeflection.DeflectedToNumber, chan_misdn_log(0,bc->port," --> calldeflect to: %s, screened: %s\n", fac->u.CDeflection.DeflectedToNumber,
fac->u.CDeflection.PresentationAllowed ? "yes" : "no"); fac->u.CDeflection.PresentationAllowed ? "yes" : "no");
break; break;
case Fac_AOCDCurrency:
if (fac->u.AOCDcur.chargeNotAvailable)
chan_misdn_log(0,bc->port," --> AOCD currency: charge not available\n");
else if (fac->u.AOCDcur.freeOfCharge)
chan_misdn_log(0,bc->port," --> AOCD currency: free of charge\n");
else if (fac->u.AOCDchu.billingId >= 0)
chan_misdn_log(0,bc->port," --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%d billingId:%d\n",
fac->u.AOCDcur.currency, fac->u.AOCDcur.currencyAmount, fac->u.AOCDcur.multiplier,
(fac->u.AOCDcur.typeOfChargingInfo == 0) ? "subTotal" : "total", fac->u.AOCDcur.billingId);
else
chan_misdn_log(0,bc->port," --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%d\n",
fac->u.AOCDcur.currency, fac->u.AOCDcur.currencyAmount, fac->u.AOCDcur.multiplier,
(fac->u.AOCDcur.typeOfChargingInfo == 0) ? "subTotal" : "total");
break;
case Fac_AOCDChargingUnit:
if (fac->u.AOCDchu.chargeNotAvailable)
chan_misdn_log(0,bc->port," --> AOCD charging unit: charge not available\n");
else if (fac->u.AOCDchu.freeOfCharge)
chan_misdn_log(0,bc->port," --> AOCD charging unit: free of charge\n");
else if (fac->u.AOCDchu.billingId >= 0)
chan_misdn_log(0,bc->port," --> AOCD charging unit: recordedUnits:%d typeOfChargingInfo:%s billingId:%d\n",
fac->u.AOCDchu.recordedUnits, (fac->u.AOCDchu.typeOfChargingInfo == 0) ? "subTotal" : "total", fac->u.AOCDchu.billingId);
else
chan_misdn_log(0,bc->port," --> AOCD charging unit: recordedUnits:%d typeOfChargingInfo:%s\n",
fac->u.AOCDchu.recordedUnits, (fac->u.AOCDchu.typeOfChargingInfo == 0) ? "subTotal" : "total");
break;
default: default:
chan_misdn_log(0,bc->port," --> unknown\n"); chan_misdn_log(0,bc->port," --> unknown\n");
} }
@ -1114,7 +1140,7 @@ static int misdn_send_cd (int fd, int argc, char *argv[])
ast_cli(fd, "Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed).\n",nr, channame); ast_cli(fd, "Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed).\n",nr, channame);
return 0; return 0;
} }
tmp->bc->fac_out.Function = FacReq_CD; tmp->bc->fac_out.Function = Fac_CD;
strncpy((char *)tmp->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(tmp->bc->fac_out.u.CDeflection.DeflectedToNumber)); strncpy((char *)tmp->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(tmp->bc->fac_out.u.CDeflection.DeflectedToNumber));
misdn_lib_send_event(tmp->bc, EVENT_FACILITY); misdn_lib_send_event(tmp->bc, EVENT_FACILITY);
} }
@ -1869,6 +1895,9 @@ static int read_config(struct chan_list *ch, int orig) {
ch->trans=ast_translator_build_path(AST_FORMAT_SLINEAR, AST_FORMAT_ALAW); ch->trans=ast_translator_build_path(AST_FORMAT_SLINEAR, AST_FORMAT_ALAW);
} }
/* AOCD initialization */
bc->AOCDtype = Fac_None;
return 0; return 0;
} }
@ -4453,29 +4482,34 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
print_facility(&(bc->fac_in), bc); print_facility(&(bc->fac_in), bc);
switch (bc->fac_in.Function) { switch (bc->fac_in.Function) {
case FacReq_CD: case Fac_CD:
{ {
struct ast_channel *bridged=AST_BRIDGED_P(ch->ast); struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
struct chan_list *ch_br; struct chan_list *ch_br;
if (bridged && MISDN_ASTERISK_TECH_PVT(bridged)) {
if (bridged && MISDN_ASTERISK_TECH_PVT(bridged)) { ch_br=MISDN_ASTERISK_TECH_PVT(bridged);
ch_br=MISDN_ASTERISK_TECH_PVT(bridged); /*ch->state=MISDN_FACILITY_DEFLECTED;*/
/*ch->state=MISDN_FACILITY_DEFLECTED;*/ if (ch_br->bc) {
if (ch_br->bc) { if (ast_exists_extension(bridged, ch->context, (char *)bc->fac_in.u.CDeflection.DeflectedToNumber, 1, bc->oad)) {
if (ast_exists_extension(bridged, ch->context, (char *)bc->fac_in.u.CDeflection.DeflectedToNumber, 1, bc->oad)) { ch_br->state=MISDN_DIALING;
ch_br->state=MISDN_DIALING; if (pbx_start_chan(ch_br) < 0) {
if (pbx_start_chan(ch_br) < 0) { chan_misdn_log(-1, ch_br->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
chan_misdn_log(-1, ch_br->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n"); }
} }
} }
}
}
misdn_lib_send_event(bc, EVENT_DISCONNECT);
} }
break;
misdn_lib_send_event(bc, EVENT_DISCONNECT); case Fac_AOCDCurrency:
} bc->AOCDtype = Fac_AOCDCurrency;
memcpy(&(bc->AOCD.currency), &(bc->fac_in.u.AOCDcur), sizeof(struct FacAOCDCurrency));
break; break;
case Fac_AOCDChargingUnit:
bc->AOCDtype = Fac_AOCDChargingUnit;
memcpy(&(bc->AOCD.chargingUnit), &(bc->fac_in.u.AOCDchu), sizeof(struct FacAOCDChargingUnit));
break;
default: default:
chan_misdn_log(0, bc->port," --> not yet handled: facility type:%p\n", bc->fac_in.Function); chan_misdn_log(0, bc->port," --> not yet handled: facility type:%p\n", bc->fac_in.Function);
} }
@ -4763,7 +4797,7 @@ static int misdn_facility_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "Facility: Number argument too long (up to 15 digits are allowed). Ignoring.\n"); ast_log(LOG_WARNING, "Facility: Number argument too long (up to 15 digits are allowed). Ignoring.\n");
return 0; return 0;
} }
ch->bc->fac_out.Function = FacReq_CD; ch->bc->fac_out.Function = Fac_CD;
strncpy((char *)ch->bc->fac_out.u.CDeflection.DeflectedToNumber, tok, sizeof(ch->bc->fac_out.u.CDeflection.DeflectedToNumber)); strncpy((char *)ch->bc->fac_out.u.CDeflection.DeflectedToNumber, tok, sizeof(ch->bc->fac_out.u.CDeflection.DeflectedToNumber));
misdn_lib_send_event(ch->bc, EVENT_FACILITY); misdn_lib_send_event(ch->bc, EVENT_FACILITY);
} else { } else {

@ -615,8 +615,8 @@ void empty_bc(struct misdn_bchannel *bc)
bc->rad[0] = 0; bc->rad[0] = 0;
bc->orig_dad[0] = 0; bc->orig_dad[0] = 0;
bc->fac_in.Function = FacReq_None; bc->fac_in.Function = Fac_None;
bc->fac_out.Function = FacReq_None; bc->fac_out.Function = Fac_None;
bc->te_choose_channel = 0; bc->te_choose_channel = 0;
@ -3080,13 +3080,13 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel)
} }
char *fac2str (enum FacReqFunction func) { char *fac2str (enum FacFunction func) {
struct arr_el { struct arr_el {
enum FacReqFunction p; enum FacFunction p;
char *s ; char *s ;
} arr[] = { } arr[] = {
{ FacReq_None, "FacReq_None" }, { Fac_None, "Fac_None" },
{ FacReq_CD, "FacReq_CD"}, { Fac_CD, "Fac_CD"},
}; };
int i; int i;

@ -256,8 +256,15 @@ struct misdn_bchannel {
int progress_location; int progress_location;
int progress_indicator; int progress_indicator;
struct FacReqParm fac_in; struct FacParm fac_in;
struct FacReqParm fac_out; struct FacParm fac_out;
/* storing the current AOCD info here */
enum FacFunction AOCDtype;
union {
struct FacAOCDCurrency currency;
struct FacAOCDChargingUnit chargingUnit;
} AOCD;
enum event_e evq; enum event_e evq;

@ -896,7 +896,7 @@ void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *
if (!p) if (!p)
return; return;
err = decodeFacReq(p, &(bc->fac_in)); err = decodeFac(p, &(bc->fac_in));
if (err) { if (err) {
cb_log(1, bc->port, "Decoding FACILITY failed! (%d)\n", err); cb_log(1, bc->port, "Decoding FACILITY failed! (%d)\n", err);
} }
@ -916,7 +916,7 @@ msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt
printf("Building FACILITY Msg\n"); printf("Building FACILITY Msg\n");
#endif #endif
len = encodeFacReq(fac_tmp, &(bc->fac_out)); len = encodeFac(fac_tmp, &(bc->fac_out));
if (len <= 0) if (len <= 0)
return NULL; return NULL;

Loading…
Cancel
Save