diff options
Diffstat (limited to 'channels/misdn/isdn_msg_parser.c')
-rw-r--r-- | channels/misdn/isdn_msg_parser.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/channels/misdn/isdn_msg_parser.c b/channels/misdn/isdn_msg_parser.c index fa1560e5d..3c7a8f33a 100644 --- a/channels/misdn/isdn_msg_parser.c +++ b/channels/misdn/isdn_msg_parser.c @@ -1282,6 +1282,13 @@ static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bch FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); Q931_info_t *qi = (Q931_info_t*)(msg->data+HEADER_LEN); unsigned char *p = NULL; +#if defined(AST_MISDN_ENHANCEMENTS) + int description_code; + int type; + int plan; + int present; + char number[sizeof(bc->redirecting.to.number)]; +#endif /* defined(AST_MISDN_ENHANCEMENTS) */ #ifdef DEBUG printf("Parsing FACILITY Msg\n"); @@ -1301,6 +1308,37 @@ static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bch if (decodeFac(p, &bc->fac_in)) { cb_log(3, bc->port, "Decoding facility ie failed! Unrecognized facility message?\n"); } + +#if defined(AST_MISDN_ENHANCEMENTS) + dec_ie_notify(facility->NOTIFY, qi, &description_code, nt, bc); + if (description_code < 0) { + bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; + } else { + bc->notify_description_code = description_code; + } + + dec_ie_redir_dn(facility->REDIR_DN, qi, &type, &plan, &present, number, sizeof(number), nt, bc); + if (0 <= type) { + bc->redirecting.to_changed = 1; + + bc->redirecting.to.number_type = type; + bc->redirecting.to.number_plan = plan; + switch (present) { + default: + case 0: + bc->redirecting.to.presentation = 0; /* presentation allowed */ + break; + case 1: + bc->redirecting.to.presentation = 1; /* presentation restricted */ + break; + case 2: + bc->redirecting.to.presentation = 2; /* Number not available */ + break; + } + bc->redirecting.to.screening = 0; /* Unscreened */ + strcpy(bc->redirecting.to.number, number); + } +#endif /* defined(AST_MISDN_ENHANCEMENTS) */ } static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) @@ -1324,6 +1362,12 @@ static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, * Clear facility information */ bc->fac_out.Function = Fac_None; + +#if defined(AST_MISDN_ENHANCEMENTS) + /* Clear other one shot information. */ + bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; + bc->redirecting.to_changed = 0; +#endif /* defined(AST_MISDN_ENHANCEMENTS) */ return NULL; } @@ -1351,6 +1395,27 @@ static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, enc_ie_display(&facility->DISPLAY, msg, bc->display, nt,bc); } +#if defined(AST_MISDN_ENHANCEMENTS) + if (bc->notify_description_code != mISDN_NOTIFY_CODE_INVALID) { + enc_ie_notify(&facility->NOTIFY, msg, bc->notify_description_code, nt, bc); + bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; + } + + if (bc->redirecting.to_changed) { + bc->redirecting.to_changed = 0; + switch (bc->outgoing_colp) { + case 0:/* pass */ + case 1:/* restricted */ + enc_ie_redir_dn(&facility->REDIR_DN, msg, bc->redirecting.to.number_type, + bc->redirecting.to.number_plan, bc->redirecting.to.presentation, + bc->redirecting.to.number, nt, bc); + break; + default: + break; + } + } +#endif /* defined(AST_MISDN_ENHANCEMENTS) */ + return msg; } @@ -1469,6 +1534,7 @@ static msg_t *build_notify (struct isdn_msg msgs[], struct misdn_bchannel *bc, i notify = (NOTIFY_t *) (msg->data + HEADER_LEN); enc_ie_notify(¬ify->NOTIFY, msg, bc->notify_description_code, nt, bc); + bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; if (bc->redirecting.to_changed) { bc->redirecting.to_changed = 0; |