From 9a6bf5f9c666c8634aec068f8c6f0b1470d6c60c Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Mon, 23 Mar 2009 22:35:02 +0000 Subject: [PATCH] Removed trailing whitespace in chan_misdn files. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@183831 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_misdn.c | 523 +++++++------ channels/misdn/Makefile | 2 +- channels/misdn/chan_misdn_config.h | 10 +- channels/misdn/ie.c | 38 +- channels/misdn/isdn_lib.c | 1160 ++++++++++++++-------------- channels/misdn/isdn_msg_parser.c | 820 ++++++++++---------- channels/misdn/portinfo.c | 2 +- channels/misdn_config.c | 40 +- 8 files changed, 1297 insertions(+), 1298 deletions(-) diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index a1df2b7130..599bcef820 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -1,6 +1,6 @@ /* * Asterisk -- An open source telephony toolkit. - * + * * Copyright (C) 2004 - 2006, Christian Richter * * Christian Richter @@ -135,7 +135,6 @@ enum misdn_chan_state { MISDN_HUNGUP_FROM_AST, /*!< when DISCONNECT/RELEASE/REL_COMP came out of misdn_hangup */ MISDN_HOLDED, /*!< when on hold */ MISDN_HOLD_DISCONNECT, /*!< when on hold */ - }; #define ORG_AST 1 @@ -143,13 +142,13 @@ enum misdn_chan_state { struct hold_info { /*! - * \brief Logical port the channel call record is HOLDED on - * because the B channel is no longer associated. + * \brief Logical port the channel call record is HOLDED on + * because the B channel is no longer associated. */ int port; /*! - * \brief Original B channel number the HOLDED call was using. + * \brief Original B channel number the HOLDED call was using. * \note Used only for debug display messages. */ int channel; @@ -159,18 +158,18 @@ struct hold_info { * \brief Channel call record structure */ struct chan_list { - /*! + /*! * \brief The "allowed_bearers" string read in from /etc/asterisk/misdn.conf */ char allowed_bearers[BUFFERSIZE + 1]; - - /*! + + /*! * \brief State of the channel */ enum misdn_chan_state state; - /*! - * \brief TRUE if a hangup needs to be queued + /*! + * \brief TRUE if a hangup needs to be queued * \note This is a debug flag only used to catch calls to hangup_chan() that are already hungup. */ int need_queue_hangup; @@ -184,30 +183,30 @@ struct chan_list { * \brief TRUE if we could send an AST_CONTROL_BUSY if needed. */ int need_busy; - + /*! * \brief Who originally created this channel. ORG_AST or ORG_MISDN */ int originator; - /*! + /*! * \brief TRUE of we are not to respond immediately to a SETUP message. Check the dialplan first. * \note The "noautorespond_on_setup" boolean read in from /etc/asterisk/misdn.conf */ int noautorespond_on_setup; - + int norxtone; /*!< Boolean assigned values but the value is not used. */ /*! * \brief TRUE if we are not to generate tones (Playtones) */ - int notxtone; + int notxtone; /*! * \brief TRUE if echo canceller is enabled. Value is toggled. */ int toggle_ec; - + /*! * \brief TRUE if you want to send Tone Indications to an incoming * ISDN channel on a TE Port. @@ -222,8 +221,8 @@ struct chan_list { int ignore_dtmf; /*! - * \brief Pipe file descriptor handles array. - * Read from pipe[0], write to pipe[1] + * \brief Pipe file descriptor handles array. + * Read from pipe[0], write to pipe[1] */ int pipe[2]; @@ -282,31 +281,31 @@ struct chan_list { /*! * \brief Allocated jitterbuffer controller * \note misdn_jb_init() creates the jitterbuffer. - * \note Must use misdn_jb_destroy() to clean up. + * \note Must use misdn_jb_destroy() to clean up. */ struct misdn_jb *jb; - + /*! * \brief Allocated DSP controller * \note ast_dsp_new() creates the DSP controller. - * \note Must use ast_dsp_free() to clean up. + * \note Must use ast_dsp_free() to clean up. */ struct ast_dsp *dsp; /*! * \brief Allocated audio frame sample translator * \note ast_translator_build_path() creates the translator path. - * \note Must use ast_translator_free_path() to clean up. + * \note Must use ast_translator_free_path() to clean up. */ struct ast_trans_pvt *trans; - + /*! * \brief Associated Asterisk channel structure. */ struct ast_channel * ast; //int dummy; /* Not used */ - + /*! * \brief Associated B channel structure. */ @@ -317,13 +316,13 @@ struct chan_list { */ struct hold_info hold_info; - /*! - * \brief From associated B channel: Layer 3 process ID - * \note Used to find the HOLDED channel call record when retrieving a call. + /*! + * \brief From associated B channel: Layer 3 process ID + * \note Used to find the HOLDED channel call record when retrieving a call. */ unsigned int l3id; - /*! + /*! * \brief From associated B channel: B Channel mISDN driver layer ID from mISDN_get_layerid() * \note Used only for debug display messages. */ @@ -363,24 +362,24 @@ struct chan_list { int nttimeout; /*! - * \brief Other channel call record PID - * \note Value imported from Asterisk environment variable MISDN_PID + * \brief Other channel call record PID + * \note Value imported from Asterisk environment variable MISDN_PID */ int other_pid; /*! * \brief Bridged other channel call record - * \note Pointer set when other_pid imported from Asterisk environment + * \note Pointer set when other_pid imported from Asterisk environment * variable MISDN_PID by either side. */ struct chan_list *other_ch; /*! * \brief Tone zone sound used for dialtone generation. - * \note Used as a boolean. Non-NULL to prod generation if enabled. + * \note Used as a boolean. Non-NULL to prod generation if enabled. */ struct ast_tone_zone_sound *ts; - + /*! * \brief Enables overlap dialing for the set amount of seconds. (0 = Disabled) * \note The "overlapdial" value read in from /etc/asterisk/misdn.conf @@ -450,7 +449,7 @@ static void free_robin_list(void) robin = NULL; } -static struct robin_list* get_robin_position(char *group) +static struct robin_list* get_robin_position(char *group) { struct robin_list *new; struct robin_list *iter = robin; @@ -558,26 +557,26 @@ static int update_ec_config(struct misdn_bchannel *bc); static struct chan_list * get_chan_by_ast(struct ast_channel *ast) { struct chan_list *tmp; - + for (tmp = cl_te; tmp; tmp = tmp->next) { if (tmp->ast == ast) { return tmp; } } - + return NULL; } static struct chan_list * get_chan_by_ast_name(char *name) { struct chan_list *tmp; - + for (tmp = cl_te; tmp; tmp = tmp->next) { if (tmp->ast && strcmp(tmp->ast->name, name) == 0) { return tmp; } } - + return NULL; } @@ -669,10 +668,10 @@ static void print_facility(struct FacParm *fac, struct misdn_bchannel *bc) } } -static void print_bearer(struct misdn_bchannel *bc) +static void print_bearer(struct misdn_bchannel *bc) { chan_misdn_log(2, bc->port, " --> Bearer: %s\n", bearer2str(bc->capability)); - + switch(bc->law) { case INFO_CODEC_ALAW: chan_misdn_log(2, bc->port, " --> Codec: Alaw\n"); @@ -739,7 +738,7 @@ static void export_aoc_vars(int originator, struct ast_channel *ast, struct misd default: break; } - + bc->AOCD_need_export = 0; } @@ -758,7 +757,7 @@ static void *misdn_tasks_thread_func(void *data) sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGUSR1); sigaction(SIGUSR1, &sa, NULL); - + sem_post((sem_t *)data); while (1) { @@ -785,7 +784,7 @@ static void misdn_tasks_init(void) } chan_misdn_log(4, 0, "Starting misdn_tasks thread\n"); - + misdn_tasks = sched_context_create(); pthread_create(&misdn_tasks_thread, NULL, misdn_tasks_thread_func, &blocker); @@ -918,8 +917,8 @@ static void send_digit_to_chan(struct chan_list *cl, char digit) "!941+1209/100,!0/100", /* * */ "!941+1477/100,!0/100", /* # */ }; - struct ast_channel *chan = cl->ast; - + struct ast_channel *chan = cl->ast; + if (digit >= '0' && digit <='9') { ast_playtones_start(chan, 0, dtmf_tones[digit - '0'], 0); } else if (digit >= 'A' && digit <= 'D') { @@ -975,7 +974,7 @@ static char *handle_cli_misdn_set_debug(struct ast_cli_entry *e, int cmd, struct only = 1; } } - + for (i = 0; i <= max_ports; i++) { misdn_debug[i] = level; misdn_debug_only[i] = only; @@ -1267,18 +1266,18 @@ static char *handle_cli_misdn_show_config(struct ast_cli_entry *e, int cmd, stru for (elem = MISDN_CFG_FIRST + 1, linebreak = 1; elem < MISDN_CFG_LAST; elem++, linebreak++) { misdn_cfg_get_config_string(port, elem, buffer, sizeof(buffer)); ast_cli(a->fd, "%-36s%s", buffer, !(linebreak % 2) ? "\n" : ""); - } + } ast_cli(a->fd, "\n"); } } - + if (onlyport > 0) { if (misdn_cfg_is_port_valid(onlyport)) { ast_cli(a->fd, "[PORT %d]\n", onlyport); for (elem = MISDN_CFG_FIRST + 1, linebreak = 1; elem < MISDN_CFG_LAST; elem++, linebreak++) { misdn_cfg_get_config_string(onlyport, elem, buffer, sizeof(buffer)); ast_cli(a->fd, "%-36s%s", buffer, !(linebreak % 2) ? "\n" : ""); - } + } ast_cli(a->fd, "\n"); } else { ast_cli(a->fd, "Port %d is not active!\n", onlyport); @@ -1317,15 +1316,15 @@ static struct state_struct state_array[] = { { MISDN_HUNGUP_FROM_AST, "HUNGUP_FROM_AST" }, /* when DISCONNECT/RELEASE/REL_COMP came out of misdn_hangup */ }; -static const char *misdn_get_ch_state(struct chan_list *p) +static const char *misdn_get_ch_state(struct chan_list *p) { int i; static char state[8]; - + if (!p) { return NULL; } - + for (i = 0; i < ARRAY_LEN(state_array); i++) { if (state_array[i].state == p->state) { return state_array[i].txt; @@ -1346,7 +1345,7 @@ static void reload_config(void) ast_log(LOG_WARNING, "chan_misdn is not initialized properly, still reloading ?\n"); return ; } - + free_robin_list(); misdn_cfg_reload(); misdn_cfg_update_ptp(); @@ -1421,7 +1420,7 @@ static void print_bc_info (int fd, struct chan_list *help, struct misdn_bchannel bc->addr, bc ? bc->l3_id : -1, bc->display, - + bc->active, bc_state2str(bc->bc_state), bearer2str(bc->capability), @@ -1457,11 +1456,11 @@ static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, st } help = cl_te; - + ast_cli(a->fd, "Channel List: %p\n", cl_te); for (; help; help = help->next) { - struct misdn_bchannel *bc = help->bc; + struct misdn_bchannel *bc = help->bc; struct ast_channel *ast = help->ast; if (!ast) { if (!bc) { @@ -1523,13 +1522,13 @@ static char *handle_cli_misdn_show_channel(struct ast_cli_entry *e, int cmd, str help = cl_te; for (; help; help = help->next) { - struct misdn_bchannel *bc = help->bc; + struct misdn_bchannel *bc = help->bc; struct ast_channel *ast = help->ast; - + if (bc && ast) { if (!strcasecmp(ast->name, a->argv[3])) { print_bc_info(a->fd, help, bc); - break; + break; } } } @@ -1639,7 +1638,7 @@ static char *handle_cli_misdn_show_port(struct ast_cli_entry *e, int cmd, struct } port = atoi(a->argv[3]); - + ast_cli(a->fd, "BEGIN STACK_LIST:\n"); get_show_stack_details(port, buf); ast_cli(a->fd, " %s Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port] ? "(only)" : ""); @@ -1649,13 +1648,13 @@ static char *handle_cli_misdn_show_port(struct ast_cli_entry *e, int cmd, struct static char *handle_cli_misdn_send_facility(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - char *channame; + char *channame; char *nr; struct chan_list *tmp; - int port; + int port; char *served_nr; struct misdn_bchannel dummy, *bc=&dummy; - + switch (cmd) { case CLI_INIT: e->command = "misdn send facility"; @@ -1673,7 +1672,7 @@ static char *handle_cli_misdn_send_facility(struct ast_cli_entry *e, int cmd, st if (a->argc < 5) { return CLI_SHOWUSAGE; } - + if (strstr(a->argv[3], "calldeflect")) { if (a->argc < 6) { ast_verbose("calldeflect requires 1 arg: ToNumber\n\n"); @@ -1686,12 +1685,12 @@ static char *handle_cli_misdn_send_facility(struct ast_cli_entry *e, int cmd, st tmp = get_chan_by_ast_name(channame); if (!tmp) { ast_verbose("Sending CD with nr %s to %s failed: Channel does not exist.\n", nr, channame); - return 0; + return 0; } if (strlen(nr) >= 15) { ast_verbose("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 = Fac_CD; ast_copy_string((char *)tmp->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(tmp->bc->fac_out.u.CDeflection.DeflectedToNumber)); @@ -1724,14 +1723,14 @@ static char *handle_cli_misdn_send_facility(struct ast_cli_entry *e, int cmd, st } port = atoi(a->argv[4]); served_nr = a->argv[5]; - + misdn_make_dummy(bc, port, 0, misdn_lib_port_is_nt(port), 0); ast_verbose("Sending CFDeactivate Port:(%d) FromNr. (%s)\n", port, served_nr); bc->fac_out.Function = Fac_CFDeactivate; bc->fac_out.u.CFDeactivate.BasicService = 0; //All Services bc->fac_out.u.CFDeactivate.Procedure = 0; //Unconditional - + ast_copy_string((char *)bc->fac_out.u.CFActivate.ServedUserNumber, served_nr, sizeof(bc->fac_out.u.CFActivate.ServedUserNumber)); misdn_lib_send_event(bc, EVENT_FACILITY); } @@ -1773,8 +1772,8 @@ static char *handle_cli_misdn_send_restart(struct ast_cli_entry *e, int cmd, str static char *handle_cli_misdn_send_digit(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - char *channame; - char *msg; + char *channame; + char *msg; struct chan_list *tmp; int i, msglen; @@ -1803,7 +1802,7 @@ static char *handle_cli_misdn_send_digit(struct ast_cli_entry *e, int cmd, struc tmp = get_chan_by_ast_name(channame); if (!tmp) { ast_cli(a->fd, "Sending %s to %s failed Channel does not exist\n", msg, channame); - return CLI_SUCCESS; + return CLI_SUCCESS; } #if 1 for (i = 0; i < msglen; i++) { @@ -1841,9 +1840,9 @@ static char *handle_cli_misdn_toggle_echocancel(struct ast_cli_entry *e, int cmd } channame = a->argv[3]; - + ast_cli(a->fd, "Toggling EchoCancel on %s\n", channame); - + tmp = get_chan_by_ast_name(channame); if (!tmp) { ast_cli(a->fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame); @@ -1893,7 +1892,7 @@ static char *handle_cli_misdn_send_display(struct ast_cli_entry *e, int cmd, str ast_cli(a->fd, "Sending %s to %s\n", msg, channame); tmp = get_chan_by_ast_name(channame); - + if (tmp && tmp->bc) { ast_copy_string(tmp->bc->display, msg, sizeof(tmp->bc->display)); misdn_lib_send_event(tmp->bc, EVENT_INFORMATION); @@ -2010,7 +2009,7 @@ static struct ast_cli_entry chan_misdn_clis[] = { }; /*! \brief Updates caller ID information from config */ -static int update_config(struct chan_list *ch, int orig) +static int update_config(struct chan_list *ch, int orig) { struct ast_channel *ast; struct misdn_bchannel *bc; @@ -2034,7 +2033,7 @@ static int update_config(struct chan_list *ch, int orig) chan_misdn_log(7, port, "update_config: Getting Config\n"); misdn_cfg_get(port, MISDN_CFG_HDLC, &hdlc, sizeof(int)); - + if (hdlc) { switch (bc->capability) { case INFO_CAPABILITY_DIGITAL_UNRESTRICTED: @@ -2049,10 +2048,10 @@ static int update_config(struct chan_list *ch, int orig) misdn_cfg_get(port, MISDN_CFG_PRES, &pres, sizeof(pres)); misdn_cfg_get(port, MISDN_CFG_SCREEN, &screen, sizeof(screen)); chan_misdn_log(2, port, " --> pres: %d screen: %d\n", pres, screen); - + if (pres < 0 || screen < 0) { chan_misdn_log(2, port, " --> pres: %x\n", ast->cid.cid_pres); - + switch (ast->cid.cid_pres & 0x60) { case AST_PRES_RESTRICTED: bc->pres = 1; @@ -2100,9 +2099,9 @@ static void config_jitterbuffer(struct chan_list *ch) { struct misdn_bchannel *bc = ch->bc; int len = ch->jb_len, threshold = ch->jb_upper_threshold; - + chan_misdn_log(5, bc->port, "config_jb: Called\n"); - + if (! len) { chan_misdn_log(1, bc->port, "config_jb: Deactivating Jitterbuffer\n"); bc->nojitter=1; @@ -2218,7 +2217,7 @@ static int read_config(struct chan_list *ch, int orig) ast_log(LOG_WARNING, "Cannot configure without ast || bc\n"); return -1; } - + port = bc->port; chan_misdn_log(1, port, "read_config: Getting Config\n"); @@ -2233,7 +2232,7 @@ static int read_config(struct chan_list *ch, int orig) misdn_cfg_get(port, MISDN_CFG_INCOMING_EARLY_AUDIO, &ch->incoming_early_audio, sizeof(ch->incoming_early_audio)); misdn_cfg_get(port, MISDN_CFG_SENDDTMF, &bc->send_dtmf, sizeof(bc->send_dtmf)); - + misdn_cfg_get(port, MISDN_CFG_ASTDTMF, &ch->ast_dsp, sizeof(int)); if (ch->ast_dsp) { @@ -2261,7 +2260,7 @@ static int read_config(struct chan_list *ch, int orig) bc->hdlc = 1; break; } - + } /*Initialize new Jitterbuffer*/ misdn_cfg_get(port, MISDN_CFG_JITTERBUFFER, &ch->jb_len, sizeof(ch->jb_len)); @@ -2287,7 +2286,7 @@ static int read_config(struct chan_list *ch, int orig) chan_misdn_log(5, port, " --> * CallGrp:%s PickupGrp:%s\n", ast_print_group(buf, sizeof(buf), cg), ast_print_group(buf2, sizeof(buf2), pg)); ast->pickupgroup = pg; ast->callgroup = cg; - + if (orig == ORG_AST) { char callerid[BUFFERSIZE + 1]; @@ -2375,13 +2374,13 @@ static int read_config(struct chan_list *ch, int orig) } ast->cid.cid_rdnis = ast_strdup(bc->rad); } - + misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial)); ast_mutex_init(&ch->overlap_tv_lock); } /* ORIG MISDN END */ ch->overlap_dial_task = -1; - + if (ch->faxdetect || ch->ast_dsp) { misdn_cfg_get(port, MISDN_CFG_FAXDETECT_TIMEOUT, &ch->faxdetect_timeout, sizeof(ch->faxdetect_timeout)); if (!ch->dsp) { @@ -2446,16 +2445,16 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) ast_setstate(ast, AST_STATE_DOWN); return -1; } - + newbc = ch->bc; - + if (!newbc) { ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name); ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE; ast_setstate(ast, AST_STATE_DOWN); return -1; } - + port = newbc->port; if ((exceed = add_out_calls(port))) { @@ -2464,11 +2463,11 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) pbx_builtin_setvar_helper(ast, "MAX_OVERFLOW", tmp); return -1; } - + chan_misdn_log(1, port, "* CALL: %s\n", dest); - + chan_misdn_log(2, port, " --> * dad:%s tech:%s ctx:%s\n", ast->exten, ast->name, ast->context); - + chan_misdn_log(3, port, " --> * adding2newbc ext %s\n", ast->exten); if (ast->exten) { ast_copy_string(ast->exten, args.ext, sizeof(ast->exten)); @@ -2488,9 +2487,9 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) chan_misdn_log(2, port, " --> * Call with flag Digital\n"); } - /* update screening and presentation */ + /* update screening and presentation */ update_config(ch, ORG_AST); - + /* fill in some ies from channel vary */ import_ch(ast, newbc, ch); @@ -2538,8 +2537,8 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) } ch->state = MISDN_CALLING; - - return 0; + + return 0; } @@ -2551,9 +2550,9 @@ static int misdn_answer(struct ast_channel *ast) if (!ast || !(p = MISDN_ASTERISK_TECH_PVT(ast))) { return -1; } - + chan_misdn_log(1, p ? (p->bc ? p->bc->port : 0) : 0, "* ANSWER:\n"); - + if (!p) { ast_log(LOG_WARNING, " --> Channel not connected ??\n"); ast_queue_hangup_with_cause(ast, AST_CAUSE_NETWORK_OUT_OF_ORDER); @@ -2615,12 +2614,12 @@ static int misdn_digit_end(struct ast_channel *ast, char digit, unsigned int dur bc = p->bc; chan_misdn_log(1, bc ? bc->port : 0, "* IND : Digit %c\n", digit); - + if (!bc) { ast_log(LOG_WARNING, " --> !! Got Digit Event without having bchannel Object\n"); return -1; } - + switch (p->state ) { case MISDN_CALLING: if (strlen(bc->infos_pending) < sizeof(bc->infos_pending) - 1) { @@ -2677,15 +2676,15 @@ static int misdn_indication(struct ast_channel *ast, int cond, const void *data, ast_log(LOG_WARNING, "Returned -1 in misdn_indication\n"); return -1; } - + if (!p->bc ) { chan_misdn_log(1, 0, "* IND : Indication from %s\n", ast->exten); ast_log(LOG_WARNING, "Private Pointer but no bc ?\n"); return -1; } - + chan_misdn_log(5, p->bc->port, "* IND : Indication [%d] from %s\n", cond, ast->exten); - + switch (cond) { case AST_CONTROL_BUSY: chan_misdn_log(1, p->bc->port, "* IND :\tbusy pid:%d\n", p->bc ? p->bc->pid : -1); @@ -2780,7 +2779,7 @@ static int misdn_indication(struct ast_channel *ast, int cond, const void *data, } break; case AST_CONTROL_HOLD: - ast_moh_start(ast, data, p->mohinterpret); + ast_moh_start(ast, data, p->mohinterpret); chan_misdn_log(1, p->bc->port, " --> *\tHOLD pid:%d\n", p->bc ? p->bc->pid : -1); break; case AST_CONTROL_UNHOLD: @@ -2790,7 +2789,7 @@ static int misdn_indication(struct ast_channel *ast, int cond, const void *data, default: chan_misdn_log(1, p->bc->port, " --> * Unknown Indication:%d pid:%d\n", cond, p->bc ? p->bc->pid : -1); } - + return 0; } @@ -2827,16 +2826,16 @@ static int misdn_hangup(struct ast_channel *ast) MISDN_ASTERISK_TECH_PVT(ast) = NULL; p->ast = NULL; - if (ast->_state == AST_STATE_RESERVED || - p->state == MISDN_NOTHING || - p->state == MISDN_HOLDED || + if (ast->_state == AST_STATE_RESERVED || + p->state == MISDN_NOTHING || + p->state == MISDN_HOLDED || p->state == MISDN_HOLD_DISCONNECT ) { CLEAN_CH: /* between request and call */ ast_debug(1, "State Reserved (or nothing) => chanIsAvail\n"); MISDN_ASTERISK_TECH_PVT(ast) = NULL; - + ast_mutex_lock(&release_lock); cl_dequeue_chan(&cl_te, p); close(p->pipe[0]); @@ -2886,7 +2885,7 @@ static int misdn_hangup(struct ast_channel *ast) case MISDN_INCOMING_SETUP: case MISDN_CALLING: p->state = MISDN_CLEANING; - /* This is the only place in misdn_hangup, where we + /* This is the only place in misdn_hangup, where we * can call release_chan, else it might create lot's of trouble * */ ast_log(LOG_NOTICE, "release channel, in CALLING/INCOMING_SETUP state.. no other events happened\n"); @@ -2970,7 +2969,7 @@ static int misdn_hangup(struct ast_channel *ast) if (bc->need_release) { misdn_lib_send_event(bc, EVENT_RELEASE); } - p->state = MISDN_CLEANING; + p->state = MISDN_CLEANING; } else { if (bc->need_disconnect) { misdn_lib_send_event(bc, EVENT_DISCONNECT); @@ -2989,7 +2988,7 @@ static int misdn_hangup(struct ast_channel *ast) static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame *frame) { struct ast_frame *f,*f2; - + if (tmp->trans) { f2 = ast_translate(tmp->trans, frame, 0); f = ast_dsp_process(tmp->ast, tmp->dsp, f2); @@ -3000,9 +2999,9 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame if (!f || (f->frametype != AST_FRAME_DTMF)) return frame; - + ast_debug(1, "Detected inband DTMF digit: %c\n", f->subclass); - + if (tmp->faxdetect && (f->subclass == 'f')) { /* Fax tone -- Handle and return NULL */ if (!tmp->faxhandled) { @@ -3049,7 +3048,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame ast_debug(1, "Fax already handled\n"); } } - + if (tmp->ast_dsp && (f->subclass != 'f')) { chan_misdn_log(2, tmp->bc->port, " --> * SEND: DTMF (AST_DSP) :%c\n", f->subclass); } @@ -3151,7 +3150,7 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) { struct chan_list *ch; int i = 0; - + if (!ast || !(ch = MISDN_ASTERISK_TECH_PVT(ast))) { return -1; } @@ -3160,12 +3159,12 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) chan_misdn_log(7, 0, "misdn_write: Returning because holded\n"); return 0; } - + if (!ch->bc ) { ast_log(LOG_WARNING, "private but no bc\n"); return -1; } - + if (ch->notxtone) { chan_misdn_log(7, ch->bc->port, "misdn_write: Returning because notxtone\n"); return 0; @@ -3176,16 +3175,16 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) chan_misdn_log(4, ch->bc->port, "misdn_write: * prods us\n"); return 0; } - + if (!(frame->subclass & prefformat)) { chan_misdn_log(-1, ch->bc->port, "Got Unsupported Frame with Format:%d\n", frame->subclass); return 0; } - + if (!frame->samples ) { chan_misdn_log(4, ch->bc->port, "misdn_write: zero write\n"); - + if (!strcmp(frame->src,"ast_prod")) { chan_misdn_log(1, ch->bc->port, "misdn_write: state (%s) prodded.\n", misdn_get_ch_state(ch)); @@ -3203,7 +3202,7 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) chan_misdn_log(8, ch->bc->port, "misdn_write: no addr for bc dropping:%d\n", frame->samples); return 0; } - + #ifdef MISDN_DEBUG { int i, max = 5 > frame->samples ? frame->samples : 5; @@ -3224,7 +3223,7 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) if (!ch->dropped_frame_cnt) { chan_misdn_log(5, ch->bc->port, "BC not active (nor bridged) dropping: %d frames addr:%x exten:%s cid:%s ch->state:%s bc_state:%d l3id:%x\n", frame->samples, ch->bc->addr, ast->exten, ast->cid.cid_num, misdn_get_ch_state( ch), ch->bc->bc_state, ch->bc->l3_id); } - + if (++ch->dropped_frame_cnt > 100) { ch->dropped_frame_cnt = 0; chan_misdn_log(5, ch->bc->port, "BC not active (nor bridged) dropping: %d frames addr:%x dropped > 100 frames!\n", frame->samples, ch->bc->addr); @@ -3241,7 +3240,7 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) cb_log(0, ch->bc->port, "Misdn Jitterbuffer Overflow.\n"); } } - + } else { /*transmit without jitterbuffer*/ i = misdn_lib_tx2misdn_frm(ch->bc, frame->data.ptr, frame->samples); @@ -3266,13 +3265,13 @@ static enum ast_bridge_result misdn_bridge (struct ast_channel *c0, struct ast_frame *f; int p1_b, p2_b; int bridging; - + ch1 = get_chan_by_ast(c0); ch2 = get_chan_by_ast(c1); carr[0] = c0; carr[1] = c1; - + if (!(ch1 && ch2)) { return -1; } @@ -3295,7 +3294,7 @@ static enum ast_bridge_result misdn_bridge (struct ast_channel *c0, ast_verb(3, "Native bridging %s and %s\n", c0->name, c1->name); chan_misdn_log(1, ch1->bc->port, "* Making Native Bridge between %s and %s\n", ch1->bc->oad, ch2->bc->oad); - + if (! (flags & AST_BRIDGE_DTMF_CHANNEL_0) ) { ch1->ignore_dtmf = 1; } @@ -3317,7 +3316,7 @@ static enum ast_bridge_result misdn_bridge (struct ast_channel *c0, if (!f || f->frametype == AST_FRAME_CONTROL) { /* got hangup .. */ - if (!f) + if (!f) chan_misdn_log(4, ch1->bc->port, "Read Null Frame\n"); else chan_misdn_log(4, ch1->bc->port, "Read Frame Control class:%d\n", f->subclass); @@ -3326,7 +3325,7 @@ static enum ast_bridge_result misdn_bridge (struct ast_channel *c0, *rc = who; break; } - + if ( f->frametype == AST_FRAME_DTMF ) { chan_misdn_log(1, 0, "Read DTMF %d from %s\n", f->subclass, who->exten); @@ -3334,11 +3333,11 @@ static enum ast_bridge_result misdn_bridge (struct ast_channel *c0, *rc = who; break; } - + #if 0 if (f->frametype == AST_FRAME_VOICE) { chan_misdn_log(1, ch1->bc->port, "I SEND: Splitting conference with Number:%d\n", ch1->bc->pid +1); - + continue; } #endif @@ -3371,11 +3370,11 @@ static int dialtone_indicate(struct chan_list *cl) chan_misdn_log(1, cl->bc->port, "Not sending Dialtone, because config wants it\n"); return 0; } - + chan_misdn_log(3, cl->bc->port, " --> Dial\n"); cl->ts = ast_get_indication_tone(ast->zone, "dial"); - + if (cl->ts) { cl->notxtone = 0; cl->norxtone = 0; @@ -3429,7 +3428,7 @@ static int stop_bc_tones(struct chan_list *cl) cl->notxtone = 1; cl->norxtone = 1; - + return 0; } @@ -3442,7 +3441,7 @@ static struct chan_list *init_chan_list(int orig) chan_misdn_log(-1, 0, "misdn_request: malloc failed!"); return NULL; } - + cl->originator = orig; cl->need_queue_hangup = 1; cl->need_hangup = 1; @@ -3524,7 +3523,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat if (port >= port_start) { next_chan = 1; } - + if (port <= port_start && next_chan) { int maxbchans=misdn_lib_get_maxchans(port); if (++robin_channel >= maxbchans) { @@ -3544,7 +3543,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat if (check && !port_up) { chan_misdn_log(1, port, "L1 is not Up on this Port\n"); } - + if (check && port_up < 0) { ast_log(LOG_WARNING, "This port (%d) is blocked\n", port); } @@ -3564,7 +3563,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat } } } while (!newbc && robin_channel != rr->channel); - } else { + } else { for (port = misdn_cfg_get_next_port(0); port > 0; port = misdn_cfg_get_next_port(port)) { @@ -3587,10 +3586,10 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat } } } - + /* Group dial failed ?*/ if (!newbc) { - ast_log(LOG_WARNING, + ast_log(LOG_WARNING, "Could not Dial out on group '%s'.\n" "\tEither the L2 and L1 on all of these ports where DOWN (see 'show application misdn_check_l2l1')\n" "\tOr there was no free channel on none of the ports\n\n" @@ -3609,11 +3608,11 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat return NULL; } } - + /* create ast_channel and link all the objects together */ cl->bc = newbc; - + tmp = misdn_new(cl, AST_STATE_RESERVED, ext, NULL, format, port, channel); if (!tmp) { ast_log(LOG_ERROR, "Could not create Asterisk object\n"); @@ -3621,16 +3620,16 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat } cl->ast = tmp; - + /* register chan in local list */ cl_queue_chan(&cl_te, cl); - + /* fill in the config into the objects */ read_config(cl, ORG_AST); /* important */ cl->need_hangup = 0; - + return tmp; } @@ -3638,7 +3637,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat static int misdn_send_text(struct ast_channel *chan, const char *text) { struct chan_list *tmp = chan->tech_pvt; - + if (tmp && tmp->bc) { ast_copy_string(tmp->bc->display, text, sizeof(tmp->bc->display)); misdn_lib_send_event(tmp->bc, EVENT_INFORMATION); @@ -3646,7 +3645,7 @@ static int misdn_send_text(struct ast_channel *chan, const char *text) ast_log(LOG_WARNING, "No chan_list but send_text request?\n"); return -1; } - + return 0; } @@ -3658,7 +3657,7 @@ static struct ast_channel_tech misdn_tech = { .send_digit_begin = misdn_digit_begin, .send_digit_end = misdn_digit_end, .call = misdn_call, - .bridge = misdn_bridge, + .bridge = misdn_bridge, .hangup = misdn_hangup, .answer = misdn_answer, .read = misdn_read, @@ -3690,7 +3689,7 @@ static struct ast_channel_tech misdn_tech_wo_bridge = { static int glob_channel = 0; -static void update_name(struct ast_channel *tmp, int port, int c) +static void update_name(struct ast_channel *tmp, int port, int c) { int chan_offset = 0; int tmp_port = misdn_cfg_get_next_port(0); @@ -3699,7 +3698,7 @@ static void update_name(struct ast_channel *tmp, int port, int c) if (tmp_port == port) { break; } - chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2; + chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2; } if (c < 0) { c = 0; @@ -3745,7 +3744,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char tmp->rawreadformat = format; tmp->writeformat = format; tmp->rawwriteformat = format; - + tmp->tech_pvt = chlist; misdn_cfg_get(0, MISDN_GEN_BRIDGING, &bridging, sizeof(bridging)); @@ -3779,7 +3778,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char } else { chan_misdn_log(-1, 0, "Unable to allocate channel structure\n"); } - + return tmp; } @@ -3822,7 +3821,7 @@ static struct chan_list *find_holded(struct chan_list *list, struct misdn_bchann chan_misdn_log(6, bc->port, "$$$ find_holded: channel:%d oad:%s dad:%s\n", bc->channel, bc->oad, bc->dad); for (; help; help = help->next) { chan_misdn_log(4, bc->port, "$$$ find_holded: --> holded:%d channel:%d\n", help->state == MISDN_HOLDED, help->hold_info.channel); - if ((help->state == MISDN_HOLDED) && + if ((help->state == MISDN_HOLDED) && (help->hold_info.port == bc->port)) { return help; } @@ -3833,7 +3832,7 @@ static struct chan_list *find_holded(struct chan_list *list, struct misdn_bchann } -static struct chan_list *find_holded_l3(struct chan_list *list, unsigned long l3_id, int w) +static struct chan_list *find_holded_l3(struct chan_list *list, unsigned long l3_id, int w) { struct chan_list *help = list; @@ -3850,20 +3849,20 @@ static struct chan_list *find_holded_l3(struct chan_list *list, unsigned long l3 static void cl_queue_chan(struct chan_list **list, struct chan_list *chan) { chan_misdn_log(4, chan->bc ? chan->bc->port : 0, "* Queuing chan %p\n", chan); - + ast_mutex_lock(&cl_te_lock); if (!*list) { *list = chan; } else { struct chan_list *help = *list; - for (; help->next; help = help->next); + for (; help->next; help = help->next); help->next = chan; } chan->next = NULL; ast_mutex_unlock(&cl_te_lock); } -static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan) +static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan) { struct chan_list *help; @@ -3879,13 +3878,13 @@ static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan) ast_mutex_unlock(&cl_te_lock); return; } - + if (*list == chan) { *list = (*list)->next; ast_mutex_unlock(&cl_te_lock); return; } - + for (help = *list; help->next; help = help->next) { if (help->next == chan) { help->next = help->next->next; @@ -3893,7 +3892,7 @@ static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan) return; } } - + ast_mutex_unlock(&cl_te_lock); } @@ -3902,7 +3901,7 @@ static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan) static int pbx_start_chan(struct chan_list *ch) { - int ret = ast_pbx_start(ch->ast); + int ret = ast_pbx_start(ch->ast); ch->need_hangup = (ret >= 0) ? 0 : 1; @@ -3961,7 +3960,7 @@ static void release_chan(struct misdn_bchannel *bc) { if (ch->ast) { ast = ch->ast; - } + } chan_misdn_log(5, bc->port, "release_chan: bc with l3id: %x\n", bc->l3_id); @@ -4040,7 +4039,7 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch, if (!ch->noautorespond_on_setup) { if (bc->nt) { - int ret; + int ret; ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE ); } else { int ret; @@ -4055,9 +4054,9 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch, } chan_misdn_log(1, bc->port, "* Starting Ast ctx:%s dad:%s oad:%s with 's' extension\n", ast->context, ast->exten, ast->cid.cid_num); - + strncpy(ast->exten, "s", 2); - + if (pbx_start_chan(ch) < 0) { ast = NULL; hangup_chan(ch); @@ -4065,8 +4064,8 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch, misdn_lib_send_event(bc, bc->nt ? EVENT_RELEASE_COMPLETE : EVENT_DISCONNECT); } - - + + while (!ast_strlen_zero(predial) ) { fr.frametype = AST_FRAME_DTMF; fr.subclass = *predial; @@ -4118,7 +4117,7 @@ static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel *bc, s * chan_misdn_log(1, bc ? bc->port : 0, " --> * SEND: Queue Congestion pid:%d\n", bc ? bc->pid : -1); ch->state = MISDN_BUSY; - + ast_queue_control(ast, AST_CONTROL_CONGESTION); */ break; @@ -4133,11 +4132,11 @@ static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel *bc, s } chan_misdn_log(1, bc ? bc->port : 0, " --> * SEND: Queue Busy pid:%d\n", bc ? bc->pid : -1); - + ast_queue_control(ast, AST_CONTROL_BUSY); - + ch->need_busy = 0; - + break; } } @@ -4210,7 +4209,7 @@ void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_ int add_in_calls(int port) { int max_in_calls; - + misdn_cfg_get(port, MISDN_CFG_MAX_IN, &max_in_calls, sizeof(max_in_calls)); misdn_in_calls[port]++; @@ -4218,14 +4217,14 @@ int add_in_calls(int port) ast_log(LOG_NOTICE, "Marking Incoming Call on port[%d]\n", port); return misdn_in_calls[port] - max_in_calls; } - + return 0; } int add_out_calls(int port) { int max_out_calls; - + misdn_cfg_get(port, MISDN_CFG_MAX_OUT, &max_out_calls, sizeof(max_out_calls)); if (max_out_calls >= 0 && max_out_calls <= misdn_out_calls[port]) { @@ -4234,7 +4233,7 @@ int add_out_calls(int port) } misdn_out_calls[port]++; - + return 0; } @@ -4267,7 +4266,7 @@ static enum event_response_e cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) { struct chan_list *ch = find_chan_by_bc(cl_te, bc); - + if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /* Debug Only Non-Bchan */ int debuglevel = 1; if ( event == EVENT_CLEANUP && !user_data) { @@ -4280,7 +4279,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) chan_misdn_log(4, bc->port, " --> bc_state:%s\n", bc_state2str(bc->bc_state)); } } - + if (!ch) { switch(event) { case EVENT_SETUP: @@ -4302,7 +4301,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) return -1; } } - + if (ch) { switch (event) { case EVENT_TONE_GENERATE: @@ -4325,8 +4324,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) } } } - - + + switch (event) { case EVENT_PORT_ALARM: { @@ -4334,17 +4333,17 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) misdn_cfg_get(bc->port, MISDN_CFG_ALARM_BLOCK, &boa, sizeof(boa)); if (boa) { cb_log(1, bc->port, " --> blocking\n"); - misdn_lib_port_block(bc->port); + misdn_lib_port_block(bc->port); } } break; case EVENT_BCHAN_ACTIVATED: break; - + case EVENT_NEW_CHANNEL: update_name(ch->ast,bc->port,bc->channel); break; - + case EVENT_NEW_L3ID: ch->l3id=bc->l3_id; ch->addr=bc->addr; @@ -4354,7 +4353,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) if (!ch) { ch = find_holded(cl_te,bc); } - + if (!ch) { ast_log(LOG_WARNING, "NEW_BC without chan_list?\n"); break; @@ -4364,7 +4363,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) ch->bc = (struct misdn_bchannel *)user_data; } break; - + case EVENT_DTMF_TONE: { /* sending INFOS as DTMF-Frames :) */ @@ -4380,7 +4379,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) fr.mallocd = 0; fr.offset = 0; fr.delivery = ast_tv(0,0); - + if (!ch->ignore_dtmf) { chan_misdn_log(2, bc->port, " --> DTMF:%c\n", bc->dtmf); ast_queue_frame(ch->ast, &fr); @@ -4391,12 +4390,12 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) break; case EVENT_STATUS: break; - + case EVENT_INFORMATION: if (ch->state != MISDN_CONNECTED) { stop_indicate(ch); } - + if (!ch->ast) { break; } @@ -4424,7 +4423,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) break; } } - + if (!ast_canmatch_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) { if (ast_exists_extension(ch->ast, ch->context, "i", 1, bc->oad)) { ast_log(LOG_WARNING, "Extension can never match, So jumping to 'i' extension. port(%d)\n", bc->port); @@ -4454,7 +4453,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) ch->overlap_tv = ast_tvnow(); ast_mutex_unlock(&ch->overlap_tv_lock); if (ch->overlap_dial_task == -1) { - ch->overlap_dial_task = + ch->overlap_dial_task = misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch); } break; @@ -4487,7 +4486,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) ast_copy_string(ch->ast->exten, bc->dad, sizeof(ch->ast->exten)); ast_cdr_update(ch->ast); } - + ast_queue_frame(ch->ast, &fr); } } @@ -4544,7 +4543,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) if (!chan) { misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); - ast_log(LOG_ERROR, "cb_events: misdn_new failed !\n"); + ast_log(LOG_ERROR, "cb_events: misdn_new failed !\n"); return 0; } @@ -4703,8 +4702,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) break; } - /* Whatever happens, when sending_complete is set or we are PTMP TE, we will definitely - * jump into the dialplan, when the dialed extension does not exist, the 's' extension + /* Whatever happens, when sending_complete is set or we are PTMP TE, we will definitely + * jump into the dialplan, when the dialed extension does not exist, the 's' extension * will be used by Asterisk automatically. */ if (bc->sending_complete || (!bc->nt && !misdn_lib_is_ptp(bc->port))) { if (!ch->noautorespond_on_setup) { @@ -4719,7 +4718,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) /* - * When we are NT and overlapdial is set and if + * When we are NT and overlapdial is set and if * the number is empty, we wait for the ISDN timeout * instead of our own timer. */ @@ -4728,8 +4727,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) break; } - /* - * If overlapdial we will definitely send a SETUP_ACKNOWLEDGE and wait for more + /* + * If overlapdial we will definitely send a SETUP_ACKNOWLEDGE and wait for more * Infos with a Interdigit Timeout. * */ if (ch->overlap_dial) { @@ -4739,13 +4738,13 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) wait_for_digits(ch, bc, chan); if (ch->overlap_dial_task == -1) { - ch->overlap_dial_task = + ch->overlap_dial_task = misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch); } break; } - /* If the extension does not exist and we're not TE_PTMP we wait for more digits + /* If the extension does not exist and we're not TE_PTMP we wait for more digits * without interdigit timeout. * */ if (!ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) { @@ -4768,9 +4767,9 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) case EVENT_SETUP_ACKNOWLEDGE: ch->state = MISDN_CALLING_ACKNOWLEDGE; - if (bc->channel) + if (bc->channel) update_name(ch->ast,bc->port,bc->channel); - + if (!ast_strlen_zero(bc->infos_pending)) { /* TX Pending Infos */ strncat(bc->dad, bc->infos_pending, sizeof(bc->dad) - strlen(bc->dad) - 1); @@ -4792,7 +4791,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) } ch->state = MISDN_PROCEEDING; - + if (!ch->ast) { break; } @@ -4809,7 +4808,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) misdn_inband_avail(bc)) { start_bc_tones(ch); } - + ch->state = MISDN_PROGRESS; if (!ch->ast) { @@ -4820,16 +4819,16 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) break; case EVENT_ALERTING: ch->state = MISDN_ALERTING; - + if (!ch->ast) { break; } ast_queue_control(ch->ast, AST_CONTROL_RINGING); ast_setstate(ch->ast, AST_STATE_RINGING); - + cb_log(7, bc->port, " --> Set State Ringing\n"); - + if (misdn_cap_is_speech(bc->capability) && misdn_inband_avail(bc)) { cb_log(1, bc->port, "Starting Tones, we have inband Data\n"); start_bc_tones(ch); @@ -4870,9 +4869,9 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) ch->addr = bc->addr; start_bc_tones(ch); - + ch->state = MISDN_CONNECTED; - + ast_queue_control(ch->ast, AST_CONTROL_ANSWER); break; case EVENT_CONNECT_ACKNOWLEDGE: @@ -4896,7 +4895,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) alternative number, then play it instead of immediately releasing the call */ chan_misdn_log(1, bc->port, " --> Inband Info Avail, not sending RELEASE\n"); - + ch->state = MISDN_DISCONNECTED; start_bc_tones(ch); @@ -4956,7 +4955,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) case EVENT_BCHAN_ERROR: case EVENT_CLEANUP: stop_bc_tones(ch); - + switch (ch->state) { case MISDN_CALLING: bc->cause = AST_CAUSE_DESTINATION_OUT_OF_ORDER; @@ -4964,7 +4963,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) default: break; } - + hangup_chan(ch); release_chan(bc); break; @@ -4997,7 +4996,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) res = generate(ast, tmp, tone_len, tone_len); ast->generatordata = tmp; - + if (res) { ast_log(LOG_WARNING, "Auto-deactivating generator\n"); ast_deactivate_generator(ast); @@ -5024,7 +5023,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) frame.src = NULL; frame.data.ptr = bc->bframe; - if (ch->ast) + if (ch->ast) ast_queue_frame(ch->ast, &frame); } else { fd_set wrfs; @@ -5040,12 +5039,12 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) chan_misdn_log(9, bc->port, "Select Timed out\n"); break; } - + if (t < 0) { chan_misdn_log(-1, bc->port, "Select Error (err=%s)\n", strerror(errno)); break; } - + if (FD_ISSET(ch->pipe[1], &wrfs)) { chan_misdn_log(9, bc->port, "writing %d bytes to asterisk\n", bc->bframe_len); if (write(ch->pipe[1], bc->bframe, bc->bframe_len) <= 0) { @@ -5095,7 +5094,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) misdn_lib_send_event(bc, EVENT_RELEASE); } break; - case MISDN_CLEANING: + case MISDN_CLEANING: chan_misdn_log(1, bc->port, " --> in state cleaning .. so ignoring, the stack should clean it for us\n"); break; default: @@ -5133,7 +5132,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) if (hold_ast) { ast_moh_stop(hold_ast); } - + if (misdn_lib_send_event(bc, EVENT_RETRIEVE_ACKNOWLEDGE) < 0) { chan_misdn_log(4, bc->port, " --> RETRIEVE_ACK failed\n"); misdn_lib_send_event(bc, EVENT_RETRIEVE_REJECT); @@ -5157,7 +5156,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) chan_misdn_log(2, bc->port, "Bridge Partner is of type: %s\n", bridged->tech->type); ch->state = MISDN_HOLDED; ch->l3id = bc->l3_id; - + misdn_lib_send_event(bc, EVENT_HOLD_ACKNOWLEDGE); /* XXX This should queue an AST_CONTROL_HOLD frame on this channel @@ -5172,11 +5171,11 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) misdn_lib_send_event(bc, EVENT_HOLD_REJECT); chan_misdn_log(0, bc->port, "We aren't bridged to anybody\n"); } - } + } break; case EVENT_FACILITY: print_facility(&(bc->fac_in), bc); - + switch (bc->fac_in.Function) { #ifdef HAVE_MISDN_FAC_RESULT case Fac_RESULT: @@ -5199,7 +5198,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) } } misdn_lib_send_event(bc, EVENT_DISCONNECT); - } + } break; case Fac_AOCDCurrency: if (ch) { @@ -5225,7 +5224,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) default: chan_misdn_log(0, bc->port," --> not yet handled: facility type:%d\n", bc->fac_in.Function); } - + break; case EVENT_RESTART: if (!bc->dummy) { @@ -5237,7 +5236,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) chan_misdn_log(1, 0, "Got Unknown Event\n"); break; } - + return RESPONSE_OK; } @@ -5258,11 +5257,11 @@ static int unload_module(void) ast_log(LOG_VERBOSE, "-- Unregistering mISDN Channel Driver --\n"); misdn_tasks_destroy(); - + if (!g_config_initialized) { return 0; } - + ast_cli_unregister_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(struct ast_cli_entry)); /* ast_unregister_application("misdn_crypt"); */ @@ -5275,7 +5274,7 @@ static int unload_module(void) free_robin_list(); misdn_cfg_destroy(); misdn_lib_destroy(); - + if (misdn_debug) { ast_free(misdn_debug); } @@ -5283,7 +5282,7 @@ static int unload_module(void) ast_free(misdn_debug_only); } ast_free(misdn_ports); - + return 0; } @@ -5301,18 +5300,18 @@ static int load_module(void) }; max_ports = misdn_lib_maxports_get(); - + if (max_ports <= 0) { ast_log(LOG_ERROR, "Unable to initialize mISDN\n"); return AST_MODULE_LOAD_DECLINE; } - + if (misdn_cfg_init(max_ports, 0)) { ast_log(LOG_ERROR, "Unable to initialize misdn_config.\n"); return AST_MODULE_LOAD_DECLINE; } g_config_initialized = 1; - + misdn_debug = ast_malloc(sizeof(int) * (max_ports + 1)); if (!misdn_debug) { ast_log(LOG_ERROR, "Out of memory for misdn_debug\n"); @@ -5369,7 +5368,7 @@ static int load_module(void) unload_module(); return AST_MODULE_LOAD_DECLINE; } - + ast_cli_register_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(struct ast_cli_entry)); ast_register_application("misdn_set_opt", misdn_set_opt_exec, "misdn_set_opt", @@ -5400,7 +5399,7 @@ static int load_module(void) " vt - Tx gain control, optarg is gain\n" ); - + ast_register_application("misdn_facility", misdn_facility_exec, "misdn_facility", "misdn_facility(||..)\n" "Sends the Facility Message FACILITY_TYPE with \n" @@ -5432,13 +5431,13 @@ static int load_module(void) misdn_cfg_get(0, MISDN_GEN_TRACEFILE, global_tracefile, sizeof(global_tracefile)); /* start the l1 watchers */ - + for (port = misdn_cfg_get_next_port(0); port >= 0; port = misdn_cfg_get_next_port(port)) { int l1timeout; misdn_cfg_get(port, MISDN_CFG_L1_TIMEOUT, &l1timeout, sizeof(l1timeout)); if (l1timeout) { chan_misdn_log(4, 0, "Adding L1watcher task: port:%d timeout:%ds\n", port, l1timeout); - misdn_tasks_add(l1timeout * 1000, misdn_l1_task, &misdn_ports[port]); + misdn_tasks_add(l1timeout * 1000, misdn_l1_task, &misdn_ports[port]); } } @@ -5468,12 +5467,12 @@ static int misdn_facility_exec(struct ast_channel *chan, void *data) ); chan_misdn_log(0, 0, "TYPE: %s\n", chan->tech->type); - + if (strcasecmp(chan->tech->type, "mISDN")) { ast_log(LOG_WARNING, "misdn_facility makes only sense with chan_misdn channels!\n"); return -1; } - + if (ast_strlen_zero((char *)data)) { ast_log(LOG_WARNING, "misdn_facility requires arguments: facility_type[,]\n"); return -1; @@ -5544,7 +5543,7 @@ static int misdn_check_l2l1(struct ast_channel *chan, void *data) ast_copy_string(group, port_str, sizeof(group)); chan_misdn_log(2, 0, "Checking Ports in group: %s\n", group); - for ( port = misdn_cfg_get_next_port(port); + for ( port = misdn_cfg_get_next_port(port); port > 0; port = misdn_cfg_get_next_port(port)) { char cfg_group[BUFFERSIZE + 1]; @@ -5595,7 +5594,7 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) ast_log(LOG_WARNING, "misdn_set_opt makes only sense with chan_misdn channels!\n"); return -1; } - + if (ast_strlen_zero((char *)data)) { ast_log(LOG_WARNING, "misdn_set_opt Requires arguments\n"); return -1; @@ -5611,14 +5610,14 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) neglect = 1; tok++; } - + switch(tok[0]) { - + case 'd' : ast_copy_string(ch->bc->display, ++tok, sizeof(ch->bc->display)); chan_misdn_log(1, ch->bc->port, "SETOPT: Display:%s\n", ch->bc->display); break; - + case 'n': chan_misdn_log(1, ch->bc->port, "SETOPT: No DSP\n"); ch->bc->nodsp = 1; @@ -5677,7 +5676,7 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) break; } break; - + case 'c': keyidx = atoi(++tok); { @@ -5699,7 +5698,7 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) } case 'e': chan_misdn_log(1, ch->bc->port, "SETOPT: EchoCancel\n"); - + if (neglect) { chan_misdn_log(1, ch->bc->port, " --> disabled\n"); #ifdef MISDN_1_2 @@ -5719,11 +5718,11 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) } #endif } - + break; case 'h': chan_misdn_log(1, ch->bc->port, "SETOPT: Digital\n"); - + if (strlen(tok) > 1 && tok[1] == '1') { chan_misdn_log(1, ch->bc->port, "SETOPT: HDLC \n"); if (!ch->bc->hdlc) { @@ -5732,12 +5731,12 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) } ch->bc->capability = INFO_CAPABILITY_DIGITAL_UNRESTRICTED; break; - + case 's': chan_misdn_log(1, ch->bc->port, "SETOPT: Send DTMF\n"); ch->bc->send_dtmf = 1; break; - + case 'f': chan_misdn_log(1, ch->bc->port, "SETOPT: Faxdetect\n"); ch->faxdetect = 1; @@ -5791,19 +5790,19 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) ch->bc->nodsp = 1; ch->bc->nojitter = 1; } - + return 0; } -int chan_misdn_jb_empty ( struct misdn_bchannel *bc, char *buf, int len) +int chan_misdn_jb_empty ( struct misdn_bchannel *bc, char *buf, int len) { struct chan_list *ch = find_chan_by_bc(cl_te, bc); - + if (ch && ch->jb) { return misdn_jb_empty(ch->jb, buf, len); } - + return -1; } @@ -5860,7 +5859,7 @@ struct misdn_jb *misdn_jb_init(int size, int upper_threshold) void misdn_jb_destroy(struct misdn_jb *jb) { ast_mutex_destroy(&jb->mutexjb); - + ast_free(jb->ok); ast_free(jb->samples); ast_free(jb); @@ -5877,10 +5876,10 @@ int misdn_jb_fill(struct misdn_jb *jb, const char *data, int len) } ast_mutex_lock(&jb->mutexjb); - + wp = jb->wp; rp = jb->rp; - + for (i = 0; i < len; i++) { jb->samples[wp] = data[i]; jb->ok[wp] = 1; @@ -5924,7 +5923,7 @@ int misdn_jb_fill(struct misdn_jb *jb, const char *data, int len) jb->wp = wp; ast_mutex_unlock(&jb->mutexjb); - + return 0; } @@ -5940,7 +5939,7 @@ int misdn_jb_empty(struct misdn_jb *jb, char *data, int len) rp = jb->rp; wp = jb->wp; - if (jb->state_empty) { + if (jb->state_empty) { for (i = 0; i < len; i++) { if (wp == rp) { jb->rp = rp; @@ -6007,14 +6006,14 @@ static void chan_misdn_log(int level, int port, char *tmpl, ...) if (level == -1) { ast_log(LOG_WARNING, "%s", buf); - } else if (misdn_debug_only[port] ? - (level == 1 && misdn_debug[port]) || (level == misdn_debug[port]) + } else if (misdn_debug_only[port] ? + (level == 1 && misdn_debug[port]) || (level == misdn_debug[port]) : level <= misdn_debug[port]) { - + ast_console_puts(port_buf); ast_console_puts(buf); } - + if ((level <= misdn_debug[0]) && !ast_strlen_zero(global_tracefile) ) { char ctimebuf[30]; time_t tm = time(NULL); @@ -6025,17 +6024,17 @@ static void chan_misdn_log(int level, int port, char *tmpl, ...) if ((p = strchr(tmp, '\n'))) { *p = ':'; } - + if (!fp) { ast_console_puts("Error opening Tracefile: [ "); ast_console_puts(global_tracefile); ast_console_puts(" ] "); - + ast_console_puts(strerror(errno)); ast_console_puts("\n"); return ; } - + fputs(tmp, fp); fputs(" ", fp); fputs(port_buf, fp); diff --git a/channels/misdn/Makefile b/channels/misdn/Makefile index e277636e65..194bef5aea 100644 --- a/channels/misdn/Makefile +++ b/channels/misdn/Makefile @@ -13,5 +13,5 @@ all: portinfo: portinfo.o $(CC) -o $@ $^ -lisdnnet -lmISDN -lpthread -clean: +clean: rm -rf *.a *.o *.so portinfo *.i diff --git a/channels/misdn/chan_misdn_config.h b/channels/misdn/chan_misdn_config.h index 06e2347833..c00db864ba 100644 --- a/channels/misdn/chan_misdn_config.h +++ b/channels/misdn/chan_misdn_config.h @@ -11,7 +11,7 @@ * the GNU General Public License */ -/*! \file +/*! \file * \brief Interface to mISDN - Config * \author Christian Richter */ @@ -89,7 +89,7 @@ enum misdn_cfg_elements { MISDN_CFG_FAXDETECT_TIMEOUT, /* int */ MISDN_CFG_PTP, /* int (bool) */ MISDN_CFG_LAST, - + /* general config items */ MISDN_GEN_FIRST, #ifndef MISDN_1_2 @@ -116,14 +116,14 @@ enum misdn_cfg_method { }; /* you must call misdn_cfg_init before any other function of this header file */ -int misdn_cfg_init(int max_ports, int reload); +int misdn_cfg_init(int max_ports, int reload); void misdn_cfg_reload(void); void misdn_cfg_destroy(void); void misdn_cfg_update_ptp( void ); -/* if you requst a general config element, the port value is ignored. if the requested - * value is not available, or the buffer is too small, the buffer will be nulled (in +/* if you requst a general config element, the port value is ignored. if the requested + * value is not available, or the buffer is too small, the buffer will be nulled (in * case of a char* only its first byte will be nulled). */ void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void* buf, int bufsize); diff --git a/channels/misdn/ie.c b/channels/misdn/ie.c index dc9802845b..85b3d12ad5 100644 --- a/channels/misdn/ie.c +++ b/channels/misdn/ie.c @@ -15,7 +15,7 @@ * the GNU General Public License */ -/*! \file +/*! \file * \brief Interface to mISDN * \author Christian Richter */ @@ -153,7 +153,7 @@ static void enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int ca p[4+(multi>=0)] = 0xa0 + user; } -static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *capability, int *mode, int *rate, int *multi, int *user, +static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *capability, int *mode, int *rate, int *multi, int *user, int *async, int *urate, int *stopbits, int *dbits, int *parity, int nt, struct misdn_bchannel *bc) { int octet; @@ -168,13 +168,13 @@ static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c *stopbits = -1; *dbits = -1; *parity = -1; - + if (!nt) { p = NULL; #ifdef LLC_SUPPORT if (qi->QI_ELEMENT(llc)) { - + p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(llc) + 1; } #endif @@ -189,7 +189,7 @@ static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]); return; } - + *coding = (p[1]&0x60) >> 5; *capability = p[1] & 0x1f; octet = 2; @@ -221,7 +221,7 @@ static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c if (p[0] <= octet) goto done; - + if (p[octet++] & 0x80) goto l2; @@ -231,7 +231,7 @@ static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c if (p[0] <= octet) goto done; - + if (p[octet++] & 0x80) goto l2; @@ -239,7 +239,7 @@ static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c if (p[0] <= octet) goto done; - + if (p[octet++] & 0x80) goto l2; @@ -247,20 +247,20 @@ static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c if (p[0] <= octet) goto done; - + if (!p[octet++] & 0x80) goto l2; /* Wheee. V.110 speed information */ *stopbits = (p[octet] & 0x60) >> 5; - *dbits = (p[octet] & 0x18) >> 3; + *dbits = (p[octet] & 0x18) >> 3; *parity = p[octet] & 7; octet++; } l2: /* Nobody seems to want the rest so we don't bother (yet) */ - done: + done: if (MISDN_IE_DEBG) printf(" coding=%d capability=%d mode=%d rate=%d multi=%d user=%d async=%d urate=%d stopbits=%d dbits=%d parity=%d\n", *coding, *capability, *mode, *rate, *multi, *user, *async, *urate, *stopbits, *dbits, *parity); } @@ -292,7 +292,7 @@ static void enc_ie_call_id(unsigned char **ntmode, msg_t *msg, char *callid, int if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", callid[i]); i++; } - + if (MISDN_IE_DEBG) printf(" callid%s\n", debug); l = callid_len; @@ -338,7 +338,7 @@ static void dec_ie_call_id(unsigned char *p, Q931_info_t *qi, char *callid, int if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", callid[i]); i++; } - + if (MISDN_IE_DEBG) printf(" callid%s\n", debug); } #endif @@ -501,7 +501,7 @@ static void dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int } else { strnncpy(number, (char *)p+2, p[0]-1, number_len); - /* SPECIAL workarround for IBT software bug */ + /* SPECIAL workarround for IBT software bug */ /* if (number[0]==0x80) */ /* strcpy((char *)number, (char *)number+1); */ } @@ -691,7 +691,7 @@ static void enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, int l; struct misdn_stack *stack=get_stack_by_bc(bc); int pri = stack->pri; - + if (exclusive<0 || exclusive>1) { printf("%s: ERROR: exclusive(%d) is out of range.\n", __FUNCTION__, exclusive); @@ -707,7 +707,7 @@ static void enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, } /* if (MISDN_IE_DEBG) printf(" exclusive=%d channel=%d\n", exclusive, channel); */ - + if (!pri) { @@ -1086,7 +1086,7 @@ static void dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int *location = -1; //*progress = -1; *progress = 0; - + if (!nt) { p = NULL; @@ -1350,7 +1350,7 @@ static void enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, ch if (MISDN_IE_DEBG) sprintf(debug+(i*3), " %02x", user[i]); i++; } - + if (MISDN_IE_DEBG) printf(" protocol=%d user-user%s\n", protocol, debug); l = user_len+1; @@ -1397,7 +1397,7 @@ static void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, ch i++; } debug[i*3] = '\0'; - + if (MISDN_IE_DEBG) printf(" protocol=%d user-user%s\n", *protocol, debug); } #endif diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c index 68a68e35af..74e368b7ae 100644 --- a/channels/misdn/isdn_lib.c +++ b/channels/misdn/isdn_lib.c @@ -11,7 +11,7 @@ * the GNU General Public License */ -/*! \file +/*! \file * \brief Interface to mISDN * \author Christian Richter */ @@ -33,7 +33,7 @@ void (*cb_log) (int level, int port, char *tmpl, ...) int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len); -/* +/* * Define ARRAY_LEN() because I cannot * #include "asterisk/utils.h" */ @@ -62,7 +62,7 @@ int misdn_lib_port_is_pri(int port) return stack->pri; } } - + return -1; } @@ -74,15 +74,15 @@ int misdn_lib_port_is_nt(int port) return stack->nt; } } - + return -1; } -void misdn_make_dummy(struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel) +void misdn_make_dummy(struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel) { memset (dummybc,0,sizeof(struct misdn_bchannel)); dummybc->port=port; - if (l3id==0) + if (l3id==0) dummybc->l3_id = MISDN_ID_DUMMY; else dummybc->l3_id=l3id; @@ -119,7 +119,7 @@ int misdn_lib_port_unblock(int port) } int misdn_lib_is_port_blocked(int port) -{ +{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { @@ -138,12 +138,12 @@ int misdn_lib_is_ptp(int port) return -1; } -int misdn_lib_get_maxchans(int port) +int misdn_lib_get_maxchans(int port) { struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { - if (stack->pri) + if (stack->pri) return 30; else return 2; @@ -159,7 +159,7 @@ struct misdn_stack *get_stack_by_bc(struct misdn_bchannel *bc) if (!bc) return NULL; - + for ( ; stack; stack = stack->next) { if (bc->port == stack->port) return stack; @@ -172,11 +172,11 @@ struct misdn_stack *get_stack_by_bc(struct misdn_bchannel *bc) void get_show_stack_details(int port, char *buf) { struct misdn_stack *stack=get_misdn_stack(); - + for ( ; stack; stack=stack->next) { if (stack->port == port) break; } - + if (stack) { sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d", stack->port, stack->nt ? "NT" : "TE", stack->ptp ? "PTP" : "PMP", @@ -219,10 +219,10 @@ struct misdn_lib { void *user_data; msg_queue_t upqueue; - msg_queue_t activatequeue; - + msg_queue_t activatequeue; + sem_t new_msg; - + struct misdn_stack *stack_list; } ; @@ -248,7 +248,7 @@ int manager_isdn_handler(iframe_t *frm ,msg_t *msg); int misdn_lib_port_restart(int port); int misdn_lib_pid_restart(int pid); -extern struct isdn_msg msgs_g[]; +extern struct isdn_msg msgs_g[]; #define ISDN_PID_L3_B_USER 0x430000ff #define ISDN_PID_L4_B_USER 0x440000ff @@ -304,7 +304,7 @@ static char *bearer2str(int cap) { "Res Digital", "Unknown Bearer" }; - + switch (cap) { case INFO_CAPABILITY_SPEECH: return bearers[0]; @@ -330,7 +330,7 @@ static char flip_table[256]; static void init_flip_bits(void) { int i,k; - + for (i = 0 ; i < 256 ; i++) { unsigned char sample = 0 ; for (k = 0; k<8; k++) { @@ -344,11 +344,11 @@ static char * flip_buf_bits ( char * buf , int len) { int i; char * start = buf; - + for (i = 0 ; i < len; i++) { buf[i] = flip_table[(unsigned char)buf[i]]; } - + return start; } @@ -359,13 +359,13 @@ static msg_t *create_l2msg(int prim, int dinfo, int size) /* NT only */ { int i = 0; msg_t *dmsg; - + while(i < 10) { dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL); if (dmsg) return(dmsg); - + if (!i) printf("cannot allocate memory, trying again...\n"); i++; @@ -383,10 +383,10 @@ msg_t *create_l3msg(int prim, int mt, int dinfo, int size, int ntmode) msg_t *dmsg; Q931_info_t *qi; iframe_t *frm; - + if (!ntmode) size = sizeof(Q931_info_t)+2; - + while(i < 10) { if (ntmode) { dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL); @@ -406,7 +406,7 @@ msg_t *create_l3msg(int prim, int mt, int dinfo, int size, int ntmode) return(dmsg); } } - + if (!i) printf("cannot allocate memory, trying again...\n"); i++; usleep(300000); @@ -425,11 +425,11 @@ static int send_msg (int midev, struct misdn_bchannel *bc, msg_t *dmsg) cb_log(0,bc->port,"send_msg: IEK!! no stack\n "); return -1; } - + frm->addr = (stack->upper_id | FLG_MSG_DOWN); frm->dinfo = bc->l3_id; frm->len = (dmsg->len) - mISDN_HEADER_LEN; - + cb_log(4,stack->port,"Sending msg, prim:%x addr:%x dinfo:%x\n",frm->prim,frm->addr,frm->dinfo); mISDN_write(midev, dmsg->data, dmsg->len, TIMEOUT_1SEC); @@ -457,7 +457,7 @@ int misdn_inband_avail(struct misdn_bchannel *bc) /* We have opted to never receive any available inband recorded messages */ return 0; } - + switch (bc->progress_indicator) { case INFO_PI_INBAND_AVAILABLE: case INFO_PI_CALL_NOT_E2E_ISDN: @@ -505,7 +505,7 @@ static int set_chan_in_stack(struct misdn_stack *stack, int channel) cb_log(0,stack->port,"couldn't set channel %d in\n", channel ); return -1; } - + return 0; } @@ -517,9 +517,9 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan int chan=0; int bnums = stack->pri ? stack->b_num : stack->b_num - 1; - if (bc->channel_found) + if (bc->channel_found) return 0; - + bc->channel_found=1; cb_log(5,stack->port,"find_free_chan: req_chan:%d\n",channel); @@ -528,7 +528,7 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan cb_log(0, stack->port, " !! out of bound call to find_free_chan_in_stack! (ch:%d)\n", channel); return 0; } - + channel--; if (dec) { @@ -558,7 +558,7 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan dump_chan_list(stack); bc->out_cause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION; return -1; - } + } if (set_chan_in_stack(stack, chan)<0) { cb_log (0, stack->port, "Channel Already in use:%d\n", chan); @@ -576,8 +576,8 @@ static int empty_chan_in_stack(struct misdn_stack *stack, int channel) cb_log(0,stack?stack->port:0, "empty_chan_in_stack: cannot empty channel %d\n",channel); return -1; } - - cb_log (4, stack?stack->port:0, "empty_chan_in_stack: %d\n",channel); + + cb_log (4, stack?stack->port:0, "empty_chan_in_stack: %d\n",channel); stack->channels[channel-1] = 0; dump_chan_list(stack); return 0; @@ -585,7 +585,7 @@ static int empty_chan_in_stack(struct misdn_stack *stack, int channel) char *bc_state2str(enum bchannel_state state) { int i; - + struct bchan_state_s { char *n; enum bchannel_state s; @@ -604,7 +604,7 @@ char *bc_state2str(enum bchannel_state state) { {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, {"BCHAN_ERROR", BCHAN_ERROR} }; - + for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) if ( states[i].s == state) return states[i].n; @@ -618,7 +618,7 @@ void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state) bc->l3_id, bc_state2str(bc->bc_state), bc_state2str(state) ); - + switch (state) { case BCHAN_ACTIVATED: if (bc->next_bc_state == BCHAN_BRIDGED) { @@ -656,38 +656,38 @@ static void empty_bc(struct misdn_bchannel *bc) bc->sending_complete = 0; bc->restart_channel=0; - + bc->conf_id = 0; bc->need_more_infos = 0; - + bc->send_dtmf=0; bc->nodsp=0; bc->nojitter=0; bc->time_usec=0; - + bc->rxgain=0; bc->txgain=0; bc->crypt=0; bc->curptx=0; bc->curprx=0; - + bc->crypt_key[0] = 0; - + bc->generate_tone=0; bc->tone_cnt=0; - + bc->dnumplan=NUMPLAN_UNKNOWN; bc->onumplan=NUMPLAN_UNKNOWN; bc->rnumplan=NUMPLAN_UNKNOWN; bc->cpnnumplan=NUMPLAN_UNKNOWN; - + bc->active = 0; bc->early_bconnect = 1; - + #ifdef MISDN_1_2 *bc->pipeline = 0; #else @@ -698,17 +698,17 @@ static void empty_bc(struct misdn_bchannel *bc) bc->AOCD_need_export = 0; bc->orig=0; - + bc->cause = AST_CAUSE_NORMAL_CLEARING; bc->out_cause = AST_CAUSE_NORMAL_CLEARING; bc->pres = 0; /* allowed */ - + bc->evq=EVENT_NOTHING; bc->progress_coding=0; bc->progress_location=0; bc->progress_indicator=0; - + /** Set Default Bearer Caps **/ bc->capability=INFO_CAPABILITY_SPEECH; bc->law=INFO_CODEC_ALAW; @@ -716,10 +716,10 @@ static void empty_bc(struct misdn_bchannel *bc) bc->rate=0x10; bc->user1=0; bc->urate=0; - + bc->hdlc=0; - - + + bc->info_dad[0] = 0; bc->display[0] = 0; bc->infos_pending[0] = 0; @@ -730,10 +730,10 @@ static void empty_bc(struct misdn_bchannel *bc) bc->orig_dad[0] = 0; bc->uu[0]=0; bc->uulen=0; - + bc->fac_in.Function = Fac_None; bc->fac_out.Function = Fac_None; - + bc->te_choose_channel = 0; bc->channel_found= 0; @@ -748,32 +748,32 @@ static int clean_up_bc(struct misdn_bchannel *bc) struct misdn_stack * stack; cb_log(3, bc?bc->port:0, "$$$ CLEANUP CALLED pid:%d\n", bc?bc->pid:-1); - + if (!bc ) return -1; stack=get_stack_by_bc(bc); - + if (!stack) return -1; - + switch (bc->bc_state ) { case BCHAN_CLEANED: cb_log(5, stack->port, "$$$ Already cleaned up bc with stid :%x\n", bc->b_stid); return -1; - + default: break; } - + cb_log(2, stack->port, "$$$ Cleaning up bc with stid :%x pid:%d\n", bc->b_stid, bc->pid); - + manager_ec_disable(bc); manager_bchannel_deactivate(bc); mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_TARGET|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); - + bc->b_stid = 0; bc_state_change(bc, BCHAN_CLEANED); - + return ret; } @@ -785,14 +785,14 @@ static void clear_l3(struct misdn_stack *stack) for (i=0; i<=stack->b_num; i++) { if (global_state == MISDN_INITIALIZED) { - cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); + cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); empty_chan_in_stack(stack,i+1); empty_bc(&stack->bc[i]); clean_up_bc(&stack->bc[i]); stack->bc[i].in_use = 0; } - - } + + } } static int new_te_id = 0; @@ -801,9 +801,9 @@ static int new_te_id = 0; static int misdn_lib_get_l1_down(struct misdn_stack *stack) { - /* Pull Up L1 */ + /* Pull Up L1 */ iframe_t act; - act.prim = PH_DEACTIVATE | REQUEST; + act.prim = PH_DEACTIVATE | REQUEST; act.addr = stack->lower_id|FLG_MSG_DOWN; act.dinfo = 0; act.len = 0; @@ -815,38 +815,38 @@ static int misdn_lib_get_l1_down(struct misdn_stack *stack) static int misdn_lib_get_l2_down(struct misdn_stack *stack) { - + if (stack->ptp && (stack->nt) ) { msg_t *dmsg; /* L2 */ dmsg = create_l2msg(DL_RELEASE| REQUEST, 0, 0); - + if (stack->nst.manager_l3(&stack->nst, dmsg)) free_msg(dmsg); - + } else { iframe_t act; - + act.prim = DL_RELEASE| REQUEST; act.addr = (stack->upper_id |FLG_MSG_DOWN) ; - + act.dinfo = 0; act.len = 0; return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); } - + return 0; } static int misdn_lib_get_l1_up(struct misdn_stack *stack) { - /* Pull Up L1 */ + /* Pull Up L1 */ iframe_t act; - act.prim = PH_ACTIVATE | REQUEST; + act.prim = PH_ACTIVATE | REQUEST; act.addr = (stack->upper_id | FLG_MSG_DOWN) ; - + act.dinfo = 0; act.len = 0; @@ -856,26 +856,26 @@ static int misdn_lib_get_l1_up(struct misdn_stack *stack) int misdn_lib_get_l2_up(struct misdn_stack *stack) { - + if (stack->ptp && (stack->nt) ) { msg_t *dmsg; /* L2 */ dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0); - + if (stack->nst.manager_l3(&stack->nst, dmsg)) free_msg(dmsg); - + } else { iframe_t act; - + act.prim = DL_ESTABLISH | REQUEST; act.addr = (stack->upper_id |FLG_MSG_DOWN) ; - + act.dinfo = 0; act.len = 0; return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); } - + return 0; } @@ -883,10 +883,10 @@ int misdn_lib_get_l2_up(struct misdn_stack *stack) static int misdn_lib_get_l2_te_ptp_up(struct misdn_stack *stack) { iframe_t act; - + act.prim = DL_ESTABLISH | REQUEST; act.addr = (stack->upper_id & ~LAYER_ID_MASK) | 3 | FLG_MSG_DOWN; - + act.dinfo = 0; act.len = 0; return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); @@ -897,14 +897,14 @@ static int misdn_lib_get_l2_te_ptp_up(struct misdn_stack *stack) static int misdn_lib_get_short_status(struct misdn_stack *stack) { iframe_t act; - - - act.prim = MGR_SHORTSTATUS | REQUEST; - + + + act.prim = MGR_SHORTSTATUS | REQUEST; + act.addr = (stack->upper_id | MSG_BROADCAST) ; act.dinfo = SSTATUS_BROADCAST_BIT | SSTATUS_ALL; - + act.len = 0; return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); } @@ -996,7 +996,7 @@ int setup_bc(struct misdn_bchannel *bc) cb_log(0, bc->port, "setup_bc: NO STACK FOUND!!\n"); return -1; } - + midev = stack->midev; channel = bc->channel - 1 - (bc->channel > 16); b_stid = stack->b_stids[channel >= 0 ? channel : 0]; @@ -1008,9 +1008,9 @@ int setup_bc(struct misdn_bchannel *bc) cb_log(4, stack->port, "$$$ bc already setup stid :%x (state:%s)\n", b_stid, bc_state2str(bc->bc_state) ); return -1; } - + cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid); - + /*check if the b_stid is already initialized*/ for (i=0; i <= stack->b_num; i++) { if (stack->bc[i].b_stid == b_stid) { @@ -1018,10 +1018,10 @@ int setup_bc(struct misdn_bchannel *bc) return -1; } } - + if (b_stid <= 0) { cb_log(0, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel); - + bc_state_change(bc,BCHAN_ERROR); return 1; } @@ -1031,10 +1031,10 @@ int setup_bc(struct misdn_bchannel *bc) { layer_info_t li; memset(&li, 0, sizeof(li)); - + li.object_id = -1; li.extentions = 0; - + li.st = bc->b_stid; /* given idx */ @@ -1044,18 +1044,18 @@ int setup_bc(struct misdn_bchannel *bc) #endif if ( bc->hdlc || bc->nodsp) { cb_log(4, stack->port,"setup_bc: without dsp\n"); - { + { int l = sizeof(li.name); strncpy(li.name, "B L3", l); li.name[l-1] = 0; } li.pid.layermask = ISDN_LAYER((3)); li.pid.protocol[3] = ISDN_PID_L3_B_USER; - + bc->layer=3; } else { cb_log(4, stack->port,"setup_bc: with dsp\n"); - { + { int l = sizeof(li.name); strncpy(li.name, "B L4", l); li.name[l-1] = 0; @@ -1064,8 +1064,8 @@ int setup_bc(struct misdn_bchannel *bc) li.pid.protocol[4] = ISDN_PID_L4_B_USER; bc->layer=4; - } - + } + ret = mISDN_new_layer(midev, &li); if (ret ) { cb_log(0, stack->port,"New Layer Err: %d %s\n",ret,strerror(errno)); @@ -1073,23 +1073,23 @@ int setup_bc(struct misdn_bchannel *bc) bc_state_change(bc,BCHAN_ERROR); return(-EINVAL); } - + bc->layer_id = li.id; } - + memset(&pid, 0, sizeof(pid)); - - - + + + cb_log(4, stack->port," --> Channel is %d\n", bc->channel); - + if (bc->nodsp) { cb_log(2, stack->port," --> TRANSPARENT Mode (no DSP, no HDLC)\n"); pid.protocol[1] = ISDN_PID_L1_B_64TRANS; pid.protocol[2] = ISDN_PID_L2_B_TRANS; pid.protocol[3] = ISDN_PID_L3_B_USER; pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)); - + } else if ( bc->hdlc ) { cb_log(2, stack->port," --> HDLC Mode\n"); pid.protocol[1] = ISDN_PID_L1_B_64HDLC ; @@ -1103,16 +1103,16 @@ int setup_bc(struct misdn_bchannel *bc) pid.protocol[3] = ISDN_PID_L3_B_DSP; pid.protocol[4] = ISDN_PID_L4_B_USER; pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) | ISDN_LAYER((4)); - - } + + } ret = mISDN_set_stack(midev, bc->b_stid, &pid); if (ret){ cb_log(0, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno)); - + mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); - + bc_state_change(bc,BCHAN_ERROR); cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data); return(-EINVAL); @@ -1123,7 +1123,7 @@ int setup_bc(struct misdn_bchannel *bc) if (ret) { cb_log(0, stack->port,"$$$ Set StackIND Err: %d %s\n",ret,strerror(errno)); mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); - + bc_state_change(bc,BCHAN_ERROR); cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data); return(-EINVAL); @@ -1136,14 +1136,14 @@ int setup_bc(struct misdn_bchannel *bc) if (!bc->addr) { cb_log(0, stack->port,"$$$ Get Layerid Err: %d %s\n",ret,strerror(errno)); mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); - + bc_state_change(bc,BCHAN_ERROR); cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data); return (-EINVAL); } manager_bchannel_activate(bc); - + bc_state_change(bc,BCHAN_ACTIVATED); return 0; @@ -1157,11 +1157,11 @@ static int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int mid unsigned char buff[1025] = ""; iframe_t *frm = (iframe_t *)buff; int ret; - + if (!bc) return -1; - + cb_log(8, port, "Init.BC %d.\n",bidx); - + memset(bc, 0,sizeof(struct misdn_bchannel)); bc->send_lock=malloc(sizeof(struct send_lock)); @@ -1169,40 +1169,40 @@ static int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int mid return -1; } pthread_mutex_init(&bc->send_lock->lock, NULL); - + if (msn) { int l = sizeof(bc->msn); strncpy(bc->msn,msn, l); bc->msn[l-1] = 0; } - - + + empty_bc(bc); bc_state_change(bc, BCHAN_CLEANED); - + bc->port=stack->port; bc->nt=stack->nt?1:0; bc->pri=stack->pri; - + { ibuffer_t* ibuf= init_ibuffer(MISDN_IBUF_SIZE); if (!ibuf) return -1; - + clear_ibuffer( ibuf); - + ibuf->rsem=malloc(sizeof(sem_t)); if (!ibuf->rsem) { return -1; } - + bc->astbuf=ibuf; if (sem_init(ibuf->rsem,1,0)<0) sem_init(ibuf->rsem,0,0); - + } - + { stack_info_t *stinf; ret = mISDN_get_stack_info(midev, stack->port, buff, sizeof(buff)); @@ -1210,12 +1210,12 @@ static int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int mid cb_log(0, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret); return -1; } - + stinf = (stack_info_t *)&frm->data.p; - + cb_log(8, port, " --> Child %x\n",stinf->child[bidx]); } - + return 0; } @@ -1227,7 +1227,7 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) unsigned char buff[1025]; iframe_t *frm = (iframe_t *)buff; stack_info_t *stinf; - int i; + int i; layer_info_t li; struct misdn_stack *stack = malloc(sizeof(struct misdn_stack)); @@ -1235,28 +1235,28 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) cb_log(8, port, "Init. Stack.\n"); - + memset(stack,0,sizeof(struct misdn_stack)); - + for (i=0; ichannels[i]=0; - + stack->port=port; stack->midev=midev; stack->ptp=ptp; - + stack->holding=NULL; stack->pri=0; - + msg_queue_init(&stack->downqueue); msg_queue_init(&stack->upqueue); - + /* query port's requirements */ ret = mISDN_get_stack_info(midev, port, buff, sizeof(buff)); if (ret < 0) { cb_log(0, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret); return(NULL); } - + stinf = (stack_info_t *)&frm->data.p; stack->d_stid = stinf->id; @@ -1264,7 +1264,7 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) for (i=0; i<=stinf->childcnt; i++) stack->b_stids[i] = stinf->child[i]; - + switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK) { case ISDN_PID_L0_TE_S0: stack->nt=0; @@ -1283,7 +1283,7 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) cb_log(8, port, "TE S2M Stack\n"); stack->nt=1; stack->pri=1; - + break; default: cb_log(0, port, "this is a unknown port type 0x%08x\n", stinf->pid.protocol[0]); @@ -1291,19 +1291,19 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) } if (!stack->nt) { - if (stinf->pid.protocol[2] & ISDN_PID_L2_DF_PTP ) { + if (stinf->pid.protocol[2] & ISDN_PID_L2_DF_PTP ) { stack->ptp = 1; } else { stack->ptp = 0; } } - + { int ret; int nt=stack->nt; cb_log(8, port, "Init. Stack.\n"); - + memset(&li, 0, sizeof(li)); { int l = sizeof(li.name); @@ -1315,15 +1315,15 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) li.pid.protocol[nt?2:4] = nt?ISDN_PID_L2_LAPD_NET:ISDN_PID_L4_CAPI20; li.pid.layermask = ISDN_LAYER((nt?2:4)); li.st = stack->d_stid; - - + + ret = mISDN_new_layer(midev, &li); if (ret) { cb_log(0, port, "%s: Cannot add layer %d to this port.\n", __FUNCTION__, nt?2:4); return(NULL); } - - + + stack->upper_id = li.id; ret = mISDN_register_layer(midev, stack->d_stid, stack->upper_id); if (ret) @@ -1331,52 +1331,52 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) cb_log(0,port,"Cannot register layer %d of this port.\n", nt?2:4); return(NULL); } - - stack->lower_id = mISDN_get_layerid(midev, stack->d_stid, nt?1:3); + + stack->lower_id = mISDN_get_layerid(midev, stack->d_stid, nt?1:3); if (stack->lower_id < 0) { cb_log(0, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, nt?1:3); return(NULL); } - + stack->upper_id = mISDN_get_layerid(midev, stack->d_stid, nt?2:4); if (stack->upper_id < 0) { cb_log(0, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, 2); return(NULL); } - + cb_log(8, port, "NT Stacks upper_id %x\n",stack->upper_id); - - + + /* create nst (nt-mode only) */ if (nt) { - + memset(&stack->nst, 0, sizeof(net_stack_t)); memset(&stack->mgr, 0, sizeof(manager_t)); - + stack->mgr.nst = &stack->nst; stack->nst.manager = &stack->mgr; - + stack->nst.l3_manager = handle_event_nt; stack->nst.device = midev; stack->nst.cardnr = port; stack->nst.d_stid = stack->d_stid; - + stack->nst.feature = FEATURE_NET_HOLD; if (stack->ptp) stack->nst.feature |= FEATURE_NET_PTP; if (stack->pri) stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; - + stack->nst.l1_id = stack->lower_id; stack->nst.l2_id = stack->upper_id; - + msg_queue_init(&stack->nst.down_queue); - + Isdnl2Init(&stack->nst); Isdnl3Init(&stack->nst); - - } - + + } + if (!stack->nt) { /*assume L1 is up, we'll get DEACTIVATES soon, for non * up L1s*/ @@ -1384,7 +1384,7 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) } stack->l1link=0; stack->l2link=0; -#if 0 +#if 0 if (!stack->nt) { misdn_lib_get_short_status(stack); } else { @@ -1396,12 +1396,12 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp) misdn_lib_get_short_status(stack); misdn_lib_get_l1_up(stack); - misdn_lib_get_l2_up(stack); - + misdn_lib_get_l2_up(stack); + } cb_log(8,0,"stack_init: port:%d lowerId:%x upperId:%x\n",stack->port,stack->lower_id, stack->upper_id); - + return stack; } @@ -1415,11 +1415,11 @@ static void stack_destroy(struct misdn_stack *stack) cleanup_Isdnl2(&stack->nst); cleanup_Isdnl3(&stack->nst); } - - if (stack->lower_id) + + if (stack->lower_id) mISDN_write_frame(stack->midev, buf, stack->lower_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); - if (stack->upper_id) + if (stack->upper_id) mISDN_write_frame(stack->midev, buf, stack->upper_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); } @@ -1427,14 +1427,14 @@ static void stack_destroy(struct misdn_stack *stack) static struct misdn_stack * find_stack_by_addr(int addr) { struct misdn_stack *stack; - + for (stack=glob_mgr->stack_list; stack; stack=stack->next) { if ( (stack->upper_id&STACK_ID_MASK) == (addr&STACK_ID_MASK)) return stack; } - + return NULL; } @@ -1442,24 +1442,24 @@ static struct misdn_stack * find_stack_by_addr(int addr) static struct misdn_stack * find_stack_by_port(int port) { struct misdn_stack *stack; - + for (stack=glob_mgr->stack_list; stack; - stack=stack->next) + stack=stack->next) if (stack->port == port) return stack; - + return NULL; } static struct misdn_stack * find_stack_by_mgr(manager_t* mgr_nt) { struct misdn_stack *stack; - + for (stack=glob_mgr->stack_list; stack; - stack=stack->next) + stack=stack->next) if ( &stack->mgr == mgr_nt) return stack; - + return NULL; } @@ -1506,7 +1506,7 @@ static struct misdn_bchannel *find_bc_by_addr(unsigned long addr) } } } - + return NULL; } @@ -1514,7 +1514,7 @@ struct misdn_bchannel *find_bc_by_confid(unsigned long confid) { struct misdn_stack* stack; int i; - + for (stack=glob_mgr->stack_list; stack; stack=stack->next) { @@ -1533,14 +1533,14 @@ static struct misdn_bchannel *find_bc_by_channel(int port, int channel) struct misdn_stack* stack=find_stack_by_port(port); int i; - if (!stack) return NULL; - + if (!stack) return NULL; + for (i=0; i<=stack->b_num; i++) { if ( stack->bc[i].channel== channel ) { return &stack->bc[i]; } } - + return NULL; } @@ -1551,9 +1551,9 @@ static struct misdn_bchannel *find_bc_by_channel(int port, int channel) static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm) { struct misdn_stack *stack=get_stack_by_bc(bc); - + if (!stack->nt) { - + switch (event) { case EVENT_CONNECT_ACKNOWLEDGE: @@ -1602,12 +1602,12 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_ if (!bc->channel) cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n"); - else + else cb_log(0, stack->port, "Requested Channel Already in Use releasing this call with cause 34!!!!\n"); /* when the channel is already in use, we can't - * simply clear it, we need to make sure that - * it will still be marked as in_use in the + * simply clear it, we need to make sure that + * it will still be marked as in_use in the * available channels list.*/ bc->channel=0; @@ -1626,7 +1626,7 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_ break; } } else { /** NT MODE **/ - + } return 0; } @@ -1636,7 +1636,7 @@ static int handle_cr ( struct misdn_stack *stack, iframe_t *frm) struct misdn_bchannel *bc; if (!stack) return -1; - + switch (frm->prim) { case CC_NEW_CR|INDICATION: cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo); @@ -1646,7 +1646,7 @@ static int handle_cr ( struct misdn_stack *stack, iframe_t *frm) cb_log(0, stack->port, " --> !! lib: No free channel!\n"); return -1; } - + cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",frm->dinfo); bc->l3_id=frm->dinfo; return 1; @@ -1663,14 +1663,14 @@ static int handle_cr ( struct misdn_stack *stack, iframe_t *frm) { struct misdn_bchannel *bc=find_bc_by_l3id(stack, frm->dinfo); struct misdn_bchannel dummybc; - + if (!bc) { cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", frm->dinfo); misdn_make_dummy(&dummybc, stack->port, frm->dinfo, stack->nt, 0); - - bc=&dummybc; + + bc=&dummybc; } - + if (bc) { int channel = bc->channel; cb_log(4, stack->port, " --> lib: CLEANING UP l3id: %x\n",frm->dinfo); @@ -1698,15 +1698,15 @@ static int handle_cr ( struct misdn_stack *stack, iframe_t *frm) } } else { - if (stack->nt) + if (stack->nt) cb_log(4, stack->port, "BC with dinfo: %x not found.. (prim was %x and addr %x)\n",frm->dinfo, frm->prim, frm->addr); } - + return 1; } break; } - + return 0; } @@ -1720,10 +1720,10 @@ void misdn_lib_release(struct misdn_bchannel *bc) cb_log(1,0,"misdn_release: No Stack found\n"); return; } - - if (bc->channel>0) + + if (bc->channel>0) empty_chan_in_stack(stack,bc->channel); - + empty_bc(bc); clean_up_bc(bc); bc->in_use=0; @@ -1732,21 +1732,21 @@ void misdn_lib_release(struct misdn_bchannel *bc) -int misdn_lib_get_port_up (int port) -{ /* Pull Up L1 */ +int misdn_lib_get_port_up (int port) +{ /* Pull Up L1 */ struct misdn_stack *stack; - + for (stack=glob_mgr->stack_list; stack; stack=stack->next) { - + if (stack->port == port) { if (!stack->l1link) misdn_lib_get_l1_up(stack); if (!stack->l2link) misdn_lib_get_l2_up(stack); - + return 0; } } @@ -1754,8 +1754,8 @@ int misdn_lib_get_port_up (int port) } -int misdn_lib_get_port_down (int port) -{ /* Pull Down L1 */ +int misdn_lib_get_port_down (int port) +{ /* Pull Down L1 */ struct misdn_stack *stack; for (stack=glob_mgr->stack_list; stack; @@ -1778,7 +1778,7 @@ int misdn_lib_port_up(int port, int check) for (stack=glob_mgr->stack_list; stack; stack=stack->next) { - + if (stack->port == port) { if (stack->blocked) { @@ -1805,7 +1805,7 @@ int misdn_lib_port_up(int port, int check) } } } - + return -1; } @@ -1825,7 +1825,7 @@ int release_cr(struct misdn_stack *stack, mISDNuser_head_t *hh) if (!bc) { cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", hh->dinfo); misdn_make_dummy(&dummybc, stack->port, hh->dinfo, stack->nt, 0); - bc=&dummybc; + bc=&dummybc; } if (bc) { @@ -1858,7 +1858,7 @@ handle_event_nt(void *dat, void *arg) hh=(mISDNuser_head_t*)msg->data; port=stack->port; - + cb_log(5, stack->port, " --> lib: prim %x dinfo %x\n",hh->prim, hh->dinfo); { switch(hh->prim){ @@ -1873,7 +1873,7 @@ handle_event_nt(void *dat, void *arg) frm.addr=stack->upper_id | FLG_MSG_DOWN; frm.prim = CC_NEW_CR|INDICATION; - + if (handle_cr( stack, &frm)< 0) { msg_t *dmsg; cb_log(4, stack->port, "Patch from MEIDANIS:Sending RELEASE_COMPLETE %x (No free Chan for you..)\n", hh->dinfo); @@ -1882,7 +1882,7 @@ handle_event_nt(void *dat, void *arg) free_msg(msg); return 0; } - + bc = find_bc_by_l3id(stack, hh->dinfo); hold_bc = stack_holder_find(stack, bc->l3_id); cb_log(4, stack->port, "bc_l3id:%x holded_bc_l3id:%x\n",bc->l3_id, hold_bc->l3_id); @@ -1898,17 +1898,17 @@ handle_event_nt(void *dat, void *arg) bc->holded=0; bc->b_stid=0; } - + } - + break; - + case CC_SETUP|CONFIRM: { struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo); int l3id = *((int *)(((u_char *)msg->data)+ mISDNUSER_HEAD_SIZE)); cb_log(4, stack->port, " --> lib: Event_ind:SETUP CONFIRM [NT] : new L3ID is %x\n",l3id ); - + if (!bc) { cb_log(4, stack->port, "Bc Not found (after SETUP CONFIRM)\n"); return 0; } cb_log (2,bc->port,"I IND :CC_SETUP|CONFIRM: old l3id:%x new l3id:%x\n", bc->l3_id, l3id); bc->l3_id=l3id; @@ -1916,11 +1916,11 @@ handle_event_nt(void *dat, void *arg) } free_msg(msg); return 0; - + case CC_SETUP|INDICATION: { struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0); - if (!bc) + if (!bc) ERR_NO_CHANNEL: { msg_t *dmsg; @@ -1930,7 +1930,7 @@ handle_event_nt(void *dat, void *arg) free_msg(msg); return 0; } - + cb_log(4, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo); bc->l3_id=hh->dinfo; } @@ -1938,11 +1938,11 @@ handle_event_nt(void *dat, void *arg) case CC_CONNECT_ACKNOWLEDGE|INDICATION: break; - + case CC_ALERTING|INDICATION: case CC_PROCEEDING|INDICATION: case CC_SETUP_ACKNOWLEDGE|INDICATION: - if(!stack->ptp) break; + if(!stack->ptp) break; case CC_CONNECT|INDICATION: break; case CC_DISCONNECT|INDICATION: @@ -1950,22 +1950,22 @@ handle_event_nt(void *dat, void *arg) struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo); if (!bc) { bc=find_bc_by_masked_l3id(stack, hh->dinfo, 0xffff0000); - if (bc) { + if (bc) { int myprocid=bc->l3_id&0x0000ffff; hh->dinfo=(hh->dinfo&0xffff0000)|myprocid; cb_log(3,stack->port,"Reject dinfo: %x cause:%d\n",hh->dinfo,bc->cause); - reject=1; + reject=1; } } } break; - + case CC_FACILITY|INDICATION: { struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo); if (!bc) { bc=find_bc_by_masked_l3id(stack, hh->dinfo, 0xffff0000); - if (bc) { + if (bc) { int myprocid=bc->l3_id&0x0000ffff; hh->dinfo=(hh->dinfo&0xffff0000)|myprocid; cb_log(4,bc->port,"Repaired reject Bug, new dinfo: %x\n",hh->dinfo); @@ -1973,7 +1973,7 @@ handle_event_nt(void *dat, void *arg) } } break; - + case CC_RELEASE_COMPLETE|INDICATION: break; @@ -1994,13 +1994,13 @@ handle_event_nt(void *dat, void *arg) { struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo); - if (bc) { + if (bc) { cb_log(1, stack->port, "CC_RELEASE|CONFIRM (l3id:%x), sending RELEASE_COMPLETE\n", hh->dinfo); misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE); } } break; - + case CC_RELEASE|INDICATION: break; @@ -2009,7 +2009,7 @@ handle_event_nt(void *dat, void *arg) free_msg(msg); return 0 ; break; - + case CC_NEW_CR|INDICATION: /* Got New CR for bchan, for now I handle this one in */ /* connect_ack, Need to be changed */ @@ -2022,36 +2022,36 @@ handle_event_nt(void *dat, void *arg) stack->procids[bc->l3_id&0xff] = 0 ; } cb_log(4, stack->port, "lib: Event_ind:CC_NEW_CR : very new L3ID is %x\n",l3id ); - + bc->l3_id =l3id; cb_event(EVENT_NEW_L3ID, bc, glob_mgr->user_data); - + free_msg(msg); return 0; } - + case DL_ESTABLISH | INDICATION: case DL_ESTABLISH | CONFIRM: { cb_log(3, stack->port, "%% GOT L2 Activate Info.\n"); - + if (stack->ptp && stack->l2link) { cb_log(0, stack->port, "%% GOT L2 Activate Info. but we're activated already.. this l2 is faulty, blocking port\n"); cb_event(EVENT_PORT_ALARM, &stack->bc[0], glob_mgr->user_data); } if (stack->ptp && !stack->restart_sent) { - /* make sure we restart the interface of the + /* make sure we restart the interface of the * other side */ stack->restart_sent=1; misdn_lib_send_restart(stack->port, -1); } - + /* when we get the L2 UP, the L1 is UP definitely too*/ stack->l2link = 1; stack->l2upcnt=0; - + free_msg(msg); return 0; } @@ -2075,10 +2075,10 @@ handle_event_nt(void *dat, void *arg) stack->l2upcnt++; } } - - } else + + } else cb_log(3, stack->port, "%% GOT L2 DeActivate Info.\n"); - + stack->l2link = 0; free_msg(msg); return 0; @@ -2086,37 +2086,37 @@ handle_event_nt(void *dat, void *arg) break; } } - + { /* Parse Events and fire_up to App. */ struct misdn_bchannel *bc; struct misdn_bchannel dummybc; - + enum event_e event = isdn_msg_get_event(msgs_g, msg, 1); - + bc=find_bc_by_l3id(stack, hh->dinfo); - + if (!bc) { cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x).\n", hh->dinfo); misdn_make_dummy(&dummybc, stack->port, hh->dinfo, stack->nt, 0); - bc=&dummybc; + bc=&dummybc; } if (bc ) { isdn_msg_parse_event(msgs_g,msg,bc, 1); switch (event) { case EVENT_SETUP: - if (bc->channel<=0 || bc->channel==0xff) + if (bc->channel<=0 || bc->channel==0xff) bc->channel=0; - - if (find_free_chan_in_stack(stack,bc, bc->channel,0)<0) + + if (find_free_chan_in_stack(stack,bc, bc->channel,0)<0) goto ERR_NO_CHANNEL; break; case EVENT_RELEASE: case EVENT_RELEASE_COMPLETE: { int channel=bc->channel; - int tmpcause=bc->cause; + int tmpcause=bc->cause; empty_bc(bc); bc->cause=tmpcause; clean_up_bc(bc); @@ -2130,7 +2130,7 @@ handle_event_nt(void *dat, void *arg) default: break; } - + if(!isdn_get_info(msgs_g,event,1)) { cb_log(4, stack->port, "Unknown Event Ind: prim %x dinfo %x\n",hh->prim, hh->dinfo); } else { @@ -2161,8 +2161,8 @@ handle_event_nt(void *dat, void *arg) static int handle_timers(msg_t* msg) { iframe_t *frm= (iframe_t*)msg->data; - struct misdn_stack *stack; - + struct misdn_stack *stack; + /* Timer Stuff */ switch (frm->prim) { case MGR_INITTIMER | CONFIRM: @@ -2172,17 +2172,17 @@ static int handle_timers(msg_t* msg) free_msg(msg); return(1); } - - - + + + if (frm->prim==(MGR_TIMER | INDICATION) ) { for (stack = glob_mgr->stack_list; stack; stack = stack->next) { itimer_t *it; - + if (!stack->nt) continue; - + it = stack->nst.tlist; /* find timer */ for(it=stack->nst.tlist; @@ -2201,12 +2201,12 @@ static int handle_timers(msg_t* msg) return 1; } } - + cb_log(0, 0, "Timer Msg without Timer ??\n"); free_msg(msg); return 1; } - + return 0; } @@ -2226,23 +2226,23 @@ void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc) static int do_tone(struct misdn_bchannel *bc, int len) { bc->tone_cnt=len; - + if (bc->generate_tone) { cb_event(EVENT_TONE_GENERATE, bc, glob_mgr->user_data); - + if ( !bc->nojitter ) { misdn_tx_jitter(bc,len); } - + return 1; } - + return 0; } #ifdef MISDN_SAVE_DATA -static void misdn_save_data(int id, char *p1, int l1, char *p2, int l2) +static void misdn_save_data(int id, char *p1, int l1, char *p2, int l2) { char n1[32],n2[32]; FILE *rx, *tx; @@ -2250,17 +2250,17 @@ static void misdn_save_data(int id, char *p1, int l1, char *p2, int l2) sprintf(n1,"/tmp/misdn-rx-%d.raw",id); sprintf(n2,"/tmp/misdn-tx-%d.raw",id); - rx = fopen(n1,"a+"); + rx = fopen(n1,"a+"); tx = fopen(n2,"a+"); if (!rx || !tx) { cb_log(0,0,"Couldn't open files: %s\n",strerror(errno)); return ; } - + fwrite(p1,1,l1,rx); fwrite(p2,1,l2,tx); - + fclose(rx); fclose(tx); @@ -2273,25 +2273,25 @@ void misdn_tx_jitter(struct misdn_bchannel *bc, int len) char *data=&buf[mISDN_HEADER_LEN]; iframe_t *txfrm= (iframe_t*)buf; int jlen, r; - + jlen=cb_jb_empty(bc,data,len); - + if (jlen) { #ifdef MISDN_SAVE_DATA misdn_save_data((bc->port*100+bc->channel), data, jlen, bc->bframe, bc->bframe_len); #endif flip_buf_bits( data, jlen); - + if (jlen < len) { cb_log(7,bc->port,"Jitterbuffer Underrun.\n"); } - + txfrm->prim = DL_DATA|REQUEST; - + txfrm->dinfo = 0; - + txfrm->addr = bc->addr|FLG_MSG_DOWN; /* | IF_DOWN; */ - + txfrm->len =jlen; cb_log(9, bc->port, "Transmitting %d samples 2 misdn\n", txfrm->len); @@ -2332,25 +2332,25 @@ static int handle_bchan(msg_t *msg) iframe_t *frm= (iframe_t*)msg->data; struct misdn_bchannel *bc=find_bc_by_addr(frm->addr); struct misdn_stack *stack; - + if (!bc) { cb_log(1,0,"handle_bchan: BC not found for prim:%x with addr:%x dinfo:%x\n", frm->prim, frm->addr, frm->dinfo); return 0 ; } - + stack = get_stack_by_bc(bc); - + if (!stack) { cb_log(0, bc->port,"handle_bchan: STACK not found for prim:%x with addr:%x dinfo:%x\n", frm->prim, frm->addr, frm->dinfo); return 0; } - + switch (frm->prim) { case MGR_SETSTACK| CONFIRM: cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|CONFIRM pid:%d\n",bc->pid); break; - + case MGR_SETSTACK| INDICATION: cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|IND pid:%d\n",bc->pid); break; @@ -2363,9 +2363,9 @@ static int handle_bchan(msg_t *msg) usleep(1000); goto AGAIN; } - + cb_log(0,stack->port,"$$$ Get Layer (%d) Id Error: %s\n",bc->layer,strerror(errno)); - + /* we kill the channel later, when we received some data. */ bc->addr= frm->addr; @@ -2373,12 +2373,12 @@ static int handle_bchan(msg_t *msg) cb_log(0, stack->port,"$$$ bc->addr <0 Error:%s\n",strerror(errno)); bc->addr=0; } - + cb_log(4, stack->port," --> Got Adr %x\n", bc->addr); free_msg(msg); - - + + switch(bc->bc_state) { case BCHAN_SETUP: bc_state_change(bc,BCHAN_SETUPED); @@ -2395,30 +2395,30 @@ static int handle_bchan(msg_t *msg) case MGR_DELLAYER| INDICATION: cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|IND pid:%d\n",bc->pid); break; - + case MGR_DELLAYER| CONFIRM: cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|CNF pid:%d\n",bc->pid); - + bc->pid=0; bc->addr=0; - + free_msg(msg); return 1; - + case PH_ACTIVATE | INDICATION: case DL_ESTABLISH | INDICATION: cb_log(3, stack->port, "BCHAN: ACT Ind pid:%d\n", bc->pid); free_msg(msg); - return 1; + return 1; case PH_ACTIVATE | CONFIRM: case DL_ESTABLISH | CONFIRM: - + cb_log(3, stack->port, "BCHAN: bchan ACT Confirm pid:%d\n",bc->pid); free_msg(msg); - - return 1; + + return 1; case DL_ESTABLISH | REQUEST: { @@ -2435,25 +2435,25 @@ static int handle_bchan(msg_t *msg) } free_msg(msg); return 1; - + case PH_DEACTIVATE | INDICATION: case DL_RELEASE | INDICATION: cb_log (3, stack->port, "BCHAN: DeACT Ind pid:%d\n",bc->pid); - + free_msg(msg); return 1; - + case PH_DEACTIVATE | CONFIRM: case DL_RELEASE | CONFIRM: cb_log(3, stack->port, "BCHAN: DeACT Conf pid:%d\n",bc->pid); - + free_msg(msg); return 1; - + case PH_CONTROL|INDICATION: { unsigned int *cont = (unsigned int *) &frm->data.p; - + cb_log(4, stack->port, "PH_CONTROL: channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad); if ((*cont & ~DTMF_TONE_MASK) == DTMF_TONE_VAL) { @@ -2461,7 +2461,7 @@ static int handle_bchan(msg_t *msg) cb_log(4, stack->port, " --> DTMF TONE: %c\n",dtmf); bc->dtmf=dtmf; cb_event(EVENT_DTMF_TONE, bc, glob_mgr->user_data); - + free_msg(msg); return 1; } @@ -2482,11 +2482,11 @@ static int handle_bchan(msg_t *msg) case DL_DATA|REQUEST: cb_log(0, stack->port, "DL_DATA REQUEST \n"); do_tone(bc, 64); - + free_msg(msg); return 1; - - + + case PH_DATA|INDICATION: case DL_DATA|INDICATION: { @@ -2494,9 +2494,9 @@ static int handle_bchan(msg_t *msg) bc->bframe_len = frm->len; /** Anyway flip the bufbits **/ - if ( misdn_cap_is_speech(bc->capability) ) + if ( misdn_cap_is_speech(bc->capability) ) flip_buf_bits(bc->bframe, bc->bframe_len); - + if (!bc->bframe_len) { cb_log(2, stack->port, "DL_DATA INDICATION bc->addr:%x frm->addr:%x\n", bc->addr, frm->addr); @@ -2509,12 +2509,12 @@ static int handle_bchan(msg_t *msg) free_msg(msg); return 1; } - + #if MISDN_DEBUG cb_log(0, stack->port, "DL_DATA INDICATION Len %d\n", frm->len); #endif - + if ( (bc->bc_state == BCHAN_ACTIVATED) && frm->len > 0) { int t; @@ -2528,7 +2528,7 @@ static int handle_bchan(msg_t *msg) #endif if ( !t ) { int i; - + if ( misdn_cap_is_speech(bc->capability)) { if ( !bc->nojitter ) { #ifdef MISDN_B_DEBUG @@ -2541,15 +2541,15 @@ static int handle_bchan(msg_t *msg) } } -#ifdef MISDN_B_DEBUG +#ifdef MISDN_B_DEBUG cb_log(0,bc->port,"EVENT_B_DATA START\n"); #endif - + i = cb_event(EVENT_BCHAN_DATA, bc, glob_mgr->user_data); -#ifdef MISDN_B_DEBUG +#ifdef MISDN_B_DEBUG cb_log(0,bc->port,"EVENT_B_DATA STOP\n"); #endif - + if (i<0) { cb_log(10,stack->port,"cb_event returned <0\n"); /*clean_up_bc(bc);*/ @@ -2582,7 +2582,7 @@ static int handle_bchan(msg_t *msg) #endif break; } - + return 0; } @@ -2596,29 +2596,29 @@ static int handle_frm_nt(msg_t *msg) stack=find_stack_by_addr( frm->addr ); - - + + if (!stack || !stack->nt) { return 0; } - + if ((err=stack->nst.l1_l2(&stack->nst,msg))) { - + if (nt_err_cnt > 0 ) { if (nt_err_cnt < 100) { - nt_err_cnt++; + nt_err_cnt++; cb_log(0, stack->port, "NT Stack sends us error: %d \n", err); } else if (nt_err_cnt < 105){ cb_log(0, stack->port, "NT Stack sends us error: %d over 100 times, so I'll stop this message\n", err); - nt_err_cnt = - 1; + nt_err_cnt = - 1; } } free_msg(msg); return 1; - + } - + return 1; } @@ -2626,13 +2626,13 @@ static int handle_frm_nt(msg_t *msg) static int handle_frm(msg_t *msg) { iframe_t *frm = (iframe_t*) msg->data; - + struct misdn_stack *stack=find_stack_by_addr(frm->addr); if (!stack || stack->nt) { return 0; } - + cb_log(4,stack?stack->port:0,"handle_frm: frm->addr:%x frm->prim:%x\n",frm->addr,frm->prim); { @@ -2650,7 +2650,7 @@ static int handle_frm(msg_t *msg) free_msg(msg); return 1; } - + bc=find_bc_by_l3id(stack, frm->dinfo); if (!bc && (frm->prim==(CC_RESTART|CONFIRM)) ) { @@ -2670,15 +2670,15 @@ static int handle_frm(msg_t *msg) return 1; } - + handle_frm_bc: if (bc ) { enum event_e event = isdn_msg_get_event(msgs_g, msg, 0); enum event_response_e response=RESPONSE_OK; int ret; - + isdn_msg_parse_event(msgs_g,msg,bc, 0); - + /** Preprocess some Events **/ ret = handle_event(bc, event, frm); if (ret<0) { @@ -2688,8 +2688,8 @@ handle_frm_bc: } /* shoot up event to App: */ cb_log(5, stack->port, "lib Got Prim: Addr %x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo); - - if(!isdn_get_info(msgs_g,event,0)) + + if(!isdn_get_info(msgs_g,event,0)) cb_log(0, stack->port, "Unknown Event Ind: Addr:%x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo); else response=cb_event(event, bc, glob_mgr->user_data); @@ -2698,13 +2698,13 @@ handle_frm_bc: switch (response) { case RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE: - cb_log(0, stack->port, "TOTALLY IGNORING SETUP\n"); - + cb_log(0, stack->port, "TOTALLY IGNORING SETUP\n"); + break; case RESPONSE_IGNORE_SETUP: /* I think we should send CC_RELEASE_CR, but am not sure*/ bc->out_cause = AST_CAUSE_NORMAL_CLEARING; - + case RESPONSE_RELEASE_SETUP: misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); if (bc->channel>0) @@ -2718,7 +2718,7 @@ handle_frm_bc: case RESPONSE_OK: cb_log(4, stack->port, "GOT SETUP OK\n"); - + break; default: break; @@ -2728,13 +2728,13 @@ handle_frm_bc: if (event == EVENT_RELEASE_COMPLETE) { /* release bchannel only after we've announced the RELEASE_COMPLETE */ int channel=bc->channel; - int tmpcause=bc->cause; - int tmp_out_cause=bc->out_cause; + int tmpcause=bc->cause; + int tmp_out_cause=bc->out_cause; empty_bc(bc); bc->cause=tmpcause; bc->out_cause=tmp_out_cause; clean_up_bc(bc); - + if (tmpcause == AST_CAUSE_REQUESTED_CHAN_UNAVAIL) { cb_log(0,stack->port,"**** Received CAUSE:%d, so not cleaning up channel %d\n", AST_CAUSE_REQUESTED_CHAN_UNAVAIL, channel); cb_log(0,stack->port,"**** This channel is now no longer available,\nplease try to restart it with 'misdn send restart '\n"); @@ -2755,11 +2755,11 @@ handle_frm_bc: cb_log(5, stack->port, "Freeing Msg on prim:%x \n",frm->prim); - + free_msg(msg); return 1; #endif - + } else { struct misdn_bchannel dummybc; if (frm->prim!=(CC_FACILITY|INDICATION)) @@ -2770,7 +2770,7 @@ handle_frm_bc: memset (&dummybc,0,sizeof(dummybc)); dummybc.port=stack->port; dummybc.l3_id=frm->dinfo; - bc=&dummybc; + bc=&dummybc; goto handle_frm_bc; } } @@ -2785,7 +2785,7 @@ static int handle_l1(msg_t *msg) iframe_t *frm = (iframe_t*) msg->data; struct misdn_stack *stack = find_stack_by_addr(frm->addr); int i ; - + if (!stack) return 0 ; switch (frm->prim) { @@ -2793,9 +2793,9 @@ static int handle_l1(msg_t *msg) case PH_ACTIVATE | INDICATION: cb_log (3, stack->port, "L1: PH L1Link Up!\n"); stack->l1link=1; - + if (stack->nt) { - + if (stack->nst.l1_l2(&stack->nst, msg)) free_msg(msg); @@ -2804,14 +2804,14 @@ static int handle_l1(msg_t *msg) } else { free_msg(msg); } - + for (i=0;i<=stack->b_num; i++) { if (stack->bc[i].evq != EVENT_NOTHING) { cb_log(4, stack->port, "Firing Queued Event %s because L1 got up\n", isdn_get_info(msgs_g, stack->bc[i].evq, 0)); misdn_lib_send_event(&stack->bc[i],stack->bc[i].evq); stack->bc[i].evq=EVENT_NOTHING; } - + } return 1; @@ -2819,16 +2819,16 @@ static int handle_l1(msg_t *msg) free_msg(msg); cb_log(3,stack->port,"L1: PH_ACTIVATE|REQUEST \n"); return 1; - + case PH_DEACTIVATE | REQUEST: free_msg(msg); cb_log(3,stack->port,"L1: PH_DEACTIVATE|REQUEST \n"); return 1; - + case PH_DEACTIVATE | CONFIRM: case PH_DEACTIVATE | INDICATION: cb_log (3, stack->port, "L1: PH L1Link Down! \n"); - + #if 0 for (i=0; i<=stack->b_num; i++) { if (global_state == MISDN_INITIALIZED) { @@ -2836,19 +2836,19 @@ static int handle_l1(msg_t *msg) } } #endif - + if (stack->nt) { if (stack->nst.l1_l2(&stack->nst, msg)) free_msg(msg); } else { free_msg(msg); } - + stack->l1link=0; stack->l2link=0; return 1; } - + return 0; } @@ -2857,11 +2857,11 @@ static int handle_l2(msg_t *msg) iframe_t *frm = (iframe_t*) msg->data; struct misdn_stack *stack = find_stack_by_addr(frm->addr); - + if (!stack) { return 0 ; } - + switch(frm->prim) { case DL_ESTABLISH | REQUEST: @@ -2870,13 +2870,13 @@ static int handle_l2(msg_t *msg) case DL_RELEASE | REQUEST: cb_log(1,stack->port,"DL_RELEASE|REQUEST \n"); return 1; - + case DL_ESTABLISH | INDICATION: case DL_ESTABLISH | CONFIRM: { cb_log (3, stack->port, "L2: L2Link Up! \n"); if (stack->ptp && stack->l2link) { - cb_log (-1, stack->port, "L2: L2Link Up! but it's already UP.. must be faulty, blocking port\n"); + cb_log (-1, stack->port, "L2: L2Link Up! but it's already UP.. must be faulty, blocking port\n"); cb_event(EVENT_PORT_ALARM, &stack->bc[0], glob_mgr->user_data); } stack->l2link=1; @@ -2884,13 +2884,13 @@ static int handle_l2(msg_t *msg) return 1; } break; - + case DL_RELEASE | INDICATION: case DL_RELEASE | CONFIRM: { cb_log (3, stack->port, "L2: L2Link Down! \n"); stack->l2link=0; - + free_msg(msg); return 1; } @@ -2909,9 +2909,9 @@ static int handle_mgmt(msg_t *msg) free_msg(msg); return 1; } - + stack = find_stack_by_addr(frm->addr); - + if (!stack) { if (frm->prim == (MGR_DELLAYER|CONFIRM)) { cb_log(2, 0, "MGMT: DELLAYER|CONFIRM Addr: %x !\n", @@ -2919,20 +2919,20 @@ static int handle_mgmt(msg_t *msg) free_msg(msg); return 1; } - + return 0; } - + switch(frm->prim) { case MGR_SHORTSTATUS | INDICATION: case MGR_SHORTSTATUS | CONFIRM: cb_log(5, 0, "MGMT: Short status dinfo %x\n",frm->dinfo); - + switch (frm->dinfo) { case SSTATUS_L1_ACTIVATED: cb_log(3, 0, "MGMT: SSTATUS: L1_ACTIVATED \n"); stack->l1link=1; - + break; case SSTATUS_L1_DEACTIVATED: cb_log(3, 0, "MGMT: SSTATUS: L1_DEACTIVATED \n"); @@ -2946,16 +2946,16 @@ static int handle_mgmt(msg_t *msg) cb_log(3, stack->port, "MGMT: SSTATUS: L2_ESTABLISH \n"); stack->l2link=1; break; - + case SSTATUS_L2_RELEASED: cb_log(3, stack->port, "MGMT: SSTATUS: L2_RELEASED \n"); stack->l2link=0; break; } - + free_msg(msg); return 1; - + case MGR_SETSTACK | INDICATION: cb_log(4, stack->port, "MGMT: SETSTACK|IND dinfo %x\n",frm->dinfo); free_msg(msg); @@ -2964,21 +2964,21 @@ static int handle_mgmt(msg_t *msg) cb_log(4, stack->port, "MGMT: DELLAYER|CNF dinfo %x\n",frm->dinfo) ; free_msg(msg); return 1; - + } - + /* if ( (frm->prim & 0x0f0000) == 0x0f0000) { cb_log(5, 0, "$$$ MGMT FRAME: prim %x addr %x dinfo %x\n",frm->prim, frm->addr, frm->dinfo) ; free_msg(msg); return 1; } */ - + return 0; } -static msg_t *fetch_msg(int midev) +static msg_t *fetch_msg(int midev) { msg_t *msg=alloc_msg(MAX_MSG_SIZE); int r; @@ -2991,7 +2991,7 @@ static msg_t *fetch_msg(int midev) AGAIN: r=mISDN_read(midev,msg->data,MAX_MSG_SIZE, TIMEOUT_10SEC); msg->len=r; - + if (r==0) { free_msg(msg); /* danger, cause usually freeing in main_loop */ cb_log(6,0,"Got empty Msg..\n"); @@ -3005,8 +3005,8 @@ static msg_t *fetch_msg(int midev) usleep(5000); goto AGAIN; } - - cb_log(0,0,"mISDN_read returned :%d error:%s (%d)\n",r,strerror(errno),errno); + + cb_log(0,0,"mISDN_read returned :%d error:%s (%d)\n",r,strerror(errno),errno); } #if 0 @@ -3024,12 +3024,12 @@ void misdn_lib_isdn_l1watcher(int port) ; if (stack) { - cb_log(4, port, "Checking L1 State\n"); + cb_log(4, port, "Checking L1 State\n"); if (!stack->l1link) { - cb_log(4, port, "L1 State Down, trying to get it up again\n"); + cb_log(4, port, "L1 State Down, trying to get it up again\n"); misdn_lib_get_short_status(stack); - misdn_lib_get_l1_up(stack); - misdn_lib_get_l2_up(stack); + misdn_lib_get_l1_up(stack); + misdn_lib_get_l2_up(stack); } } } @@ -3041,19 +3041,19 @@ static void misdn_lib_isdn_event_catcher(void *arg) int zero_frm=0 , fff_frm=0 ; int midev= mgr->midev; int port=0; - + while (1) { - msg_t *msg = fetch_msg(midev); + msg_t *msg = fetch_msg(midev); iframe_t *frm; - - + + if (!msg) continue; - + frm = (iframe_t*) msg->data; - + /** When we make a call from NT2Ast we get these frames **/ if (frm->len == 0 && frm->addr == 0 && frm->dinfo == 0 && frm->prim == 0 ) { - zero_frm++; + zero_frm++; free_msg(msg); continue; } else { @@ -3062,10 +3062,10 @@ static void misdn_lib_isdn_event_catcher(void *arg) zero_frm = 0 ; } } - + /** I get this sometimes after setup_bc **/ if (frm->len == 0 && frm->dinfo == 0 && frm->prim == 0xffffffff ) { - fff_frm++; + fff_frm++; free_msg(msg); continue; } else { @@ -3074,7 +3074,7 @@ static void misdn_lib_isdn_event_catcher(void *arg) fff_frm = 0 ; } } - + manager_isdn_handler(frm, msg); } @@ -3090,24 +3090,24 @@ int te_lib_init(void) { int ret; if (midev<=0) return midev; - + /* create entity for layer 3 TE-mode */ mISDN_write_frame(midev, buff, 0, MGR_NEWENTITY | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); ret = mISDN_read_frame(midev, frm, sizeof(iframe_t), 0, MGR_NEWENTITY | CONFIRM, TIMEOUT_1SEC); - + if (ret < mISDN_HEADER_LEN) { noentity: fprintf(stderr, "cannot request MGR_NEWENTITY from mISDN: %s\n",strerror(errno)); exit(-1); } - + entity = frm->dinfo & 0xffff ; - + if (!entity) goto noentity; return midev; - + } void te_lib_destroy(int midev) @@ -3131,14 +3131,14 @@ struct misdn_bchannel *manager_find_bc_by_pid(int pid) { struct misdn_stack *stack; int i; - + for (stack=glob_mgr->stack_list; stack; stack=stack->next) { for (i=0; i<=stack->b_num; i++) if (stack->bc[i].pid == pid) return &stack->bc[i]; } - + return NULL; } @@ -3159,12 +3159,12 @@ static int test_inuse(struct misdn_bchannel *bc) cb_log(2,bc->port, "channel with stid:%x for one second still in use! (n:%d lu:%d)\n", bc->b_stid, (int) now.tv_sec, (int) bc->last_used.tv_sec); return 1; } - + cb_log(3,bc->port, "channel with stid:%x not in use!\n", bc->b_stid); return 0; } - + cb_log(2,bc->port, "channel with stid:%x in use!\n", bc->b_stid); return 1; } @@ -3194,7 +3194,7 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i { struct misdn_stack *stack; int i; - + if (channel < 0 || channel > MAX_BCHANS) { cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); return NULL; @@ -3203,7 +3203,7 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i usleep(1000); for (stack=glob_mgr->stack_list; stack; stack=stack->next) { - + if (stack->port == port) { int maxnum; @@ -3211,12 +3211,12 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i cb_log(0,port,"Port is blocked\n"); return NULL; } - + if (channel > 0) { if (channel <= stack->b_num) { for (i = 0; i < stack->b_num; i++) { if ( stack->bc[i].channel == channel) { - if (test_inuse(&stack->bc[i])) { + if (test_inuse(&stack->bc[i])) { cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); return NULL; @@ -3240,7 +3240,7 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i /* 3. channel on bri means CW*/ if (!stack->pri && i==stack->b_num) stack->bc[i].cw=1; - + prepare_bc(&stack->bc[i], channel); stack->bc[i].dec=1; return &stack->bc[i]; @@ -3280,8 +3280,8 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i */ static const char *fac2str(enum FacFunction facility) { - static const struct { - enum FacFunction facility; + static const struct { + enum FacFunction facility; char *name; } arr[] = { /* *INDENT-OFF* */ @@ -3299,9 +3299,9 @@ static const char *fac2str(enum FacFunction facility) { Fac_AOCDChargingUnit, "Fac_AOCDChargingUnit" }, /* *INDENT-ON* */ }; - + unsigned index; - + for (index = 0; index < ARRAY_LEN(arr); ++index) { if (arr[index].facility == facility) { return arr[index].name; @@ -3322,7 +3322,7 @@ void misdn_lib_log_ies(struct misdn_bchannel *bc) if (!stack) return; cb_log(2, stack->port, " --> channel:%d mode:%s cause:%d ocause:%d rad:%s cad:%s\n", bc->channel, stack->nt?"NT":"TE", bc->cause, bc->out_cause, bc->rad, bc->cad); - + cb_log(2, stack->port, " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", bc->info_dad, @@ -3331,17 +3331,17 @@ void misdn_lib_log_ies(struct misdn_bchannel *bc) bc->rnumplan>=0?'0'+bc->rnumplan:' ', bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' ); - + cb_log(3, stack->port, " --> caps:%s pi:%x keypad:%s sending_complete:%d\n", bearer2str(bc->capability),bc->progress_indicator, bc->keypad, bc->sending_complete); cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", bc->screen, bc->pres); - + cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->addr, bc->l3_id, bc->b_stid, bc->layer_id); - + cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); - + cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); } @@ -3364,19 +3364,19 @@ static void misdn_send_unlock(struct misdn_bchannel *bc) int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) { - msg_t *msg; + msg_t *msg; int retval=0; struct misdn_stack *stack; - + if (!bc) RETURN(-1,OUT_POST_UNLOCK); - + stack = get_stack_by_bc(bc); - + if (!stack) { cb_log(0,bc->port,"SENDEVENT: no Stack for event:%s oad:%s dad:%s \n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad); RETURN(-1,OUT); } - + misdn_send_lock(bc); @@ -3389,11 +3389,11 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) misdn_lib_get_l1_up(stack); RETURN(0,OUT); } - + cb_log(1, stack->port, "I SEND:%s oad:%s dad:%s pid:%d\n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad, bc->pid); cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); misdn_lib_log_ies(bc); - + switch (event) { case EVENT_SETUP: if (create_process(glob_mgr->midev, bc)<0) { @@ -3432,18 +3432,18 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { if ( *bc->crypt_key ) { cb_log(4, stack->port, " --> ENABLING BLOWFISH channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad); - + manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); } - + if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); manager_ec_enable(bc); - + if (bc->txgain != 0) { cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); } - + if ( bc->rxgain != 0 ) { cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); @@ -3466,7 +3466,7 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) bc_state_change(holded_bc,BCHAN_CLEANED); stack_holder_add(stack,holded_bc); - + /*kill the bridge and clean the bchannel*/ if (stack->nt) { int channel; @@ -3481,7 +3481,7 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) misdn_split_conf(bc2,bc->conf_id); } } - + channel = bc->channel; empty_bc(bc); @@ -3490,9 +3490,9 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) if (channel>0) empty_chan_in_stack(stack,channel); - bc->in_use=0; + bc->in_use=0; } - + } break; @@ -3502,7 +3502,7 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) cb_log(0,bc->port," --> we have already send Disconnect\n"); RETURN(-1,OUT); } - + bc->need_disconnect=0; break; case EVENT_RELEASE: @@ -3526,30 +3526,30 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) /*create cleanup in TE*/ int channel=bc->channel; - int tmpcause=bc->cause; - int tmp_out_cause=bc->out_cause; + int tmpcause=bc->cause; + int tmp_out_cause=bc->out_cause; empty_bc(bc); bc->cause=tmpcause; bc->out_cause=tmp_out_cause; clean_up_bc(bc); - + if (channel>0) empty_chan_in_stack(stack,channel); - + bc->in_use=0; } break; - + case EVENT_CONNECT_ACKNOWLEDGE: if ( bc->nt || misdn_cap_is_speech(bc->capability)) { int retval=setup_bc(bc); if (retval == -EINVAL){ cb_log(0,bc->port,"send_event: setup_bc failed\n"); - + } } - + if (misdn_cap_is_speech(bc->capability)) { if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); manager_ec_enable(bc); @@ -3564,21 +3564,21 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event ) } } break; - + default: break; } - + /* Later we should think about sending bchannel data directly to misdn. */ msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); msg_queue_tail(&stack->downqueue, msg); sem_post(&glob_mgr->new_msg); - + OUT: misdn_send_unlock(bc); OUT_POST_UNLOCK: - return retval; + return retval; } @@ -3596,12 +3596,12 @@ static int handle_err(msg_t *msg) cb_log(0,0,"mISDN Msg without Address pr:%x dinfo:%x (already more than 100 of them)\n",frm->prim,frm->dinfo); cnt=0; } - + free_msg(msg); return 1; - + } - + switch (frm->prim) { case MGR_SETSTACK|INDICATION: return handle_bchan(msg); @@ -3609,7 +3609,7 @@ static int handle_err(msg_t *msg) case MGR_SETSTACK|CONFIRM: case MGR_CLEARSTACK|CONFIRM: - free_msg(msg) ; + free_msg(msg) ; return 1; break; @@ -3630,13 +3630,13 @@ static int handle_err(msg_t *msg) struct misdn_bchannel *bc; /*we flush the read buffer here*/ - + cb_log(9,0,"BCHAN DATA without BC: addr:%x port:%d channel:%d\n",frm->addr, port,channel); - - free_msg(msg); + + free_msg(msg); return 1; - - + + bc = find_bc_by_channel(port, channel); if (!bc) { @@ -3647,7 +3647,7 @@ static int handle_err(msg_t *msg) free_msg(msg); return 1; } - + cb_log(0,0," --> bc not found by channel\n"); if (stack->l2link) misdn_lib_get_l2_down(stack); @@ -3658,7 +3658,7 @@ static int handle_err(msg_t *msg) free_msg(msg); return 1; } - + cb_log(3,port," --> BC in state:%s\n", bc_state2str(bc->bc_state)); } } @@ -3673,7 +3673,7 @@ static int queue_l2l3(msg_t *msg) struct misdn_stack *stack; stack=find_stack_by_addr( frm->addr ); - + if (!stack) { return 0; } @@ -3685,7 +3685,7 @@ static int queue_l2l3(msg_t *msg) #endif int manager_isdn_handler(iframe_t *frm ,msg_t *msg) -{ +{ if (frm->dinfo==0xffffffff && frm->prim==(PH_DATA|CONFIRM)) { cb_log(0,0,"SERIOUS BUG, dinfo == 0xffffffff, prim == PH_DATA | CONFIRM !!!!\n"); @@ -3696,35 +3696,35 @@ int manager_isdn_handler(iframe_t *frm ,msg_t *msg) if (handle_bchan(msg)) { return 0 ; } - + if (unhandled_bmsg_count==1000) { - cb_log(0, 0, "received 1k Unhandled Bchannel Messages: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo); + cb_log(0, 0, "received 1k Unhandled Bchannel Messages: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo); unhandled_bmsg_count=0; } unhandled_bmsg_count++; free_msg(msg); return 0; - } + } #ifdef RECV_FRM_SYSLOG_DEBUG syslog(LOG_NOTICE,"mISDN recv: P(%02d): ADDR:%x PRIM:%x DINFO:%x\n",stack->port, frm->addr, frm->prim, frm->dinfo); #endif - if (handle_timers(msg)) + if (handle_timers(msg)) return 0 ; - - if (handle_mgmt(msg)) - return 0 ; - - if (handle_l2(msg)) + + if (handle_mgmt(msg)) + return 0 ; + + if (handle_l2(msg)) return 0 ; /* Its important to handle l1 AFTER l2 */ - if (handle_l1(msg)) + if (handle_l1(msg)) return 0 ; - + if (handle_frm_nt(msg)) { return 0; } @@ -3737,9 +3737,9 @@ int manager_isdn_handler(iframe_t *frm ,msg_t *msg) return 0 ; } - cb_log(0, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo); + cb_log(0, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo); free_msg(msg); - + return 0; } @@ -3768,16 +3768,16 @@ int misdn_lib_get_port_info(int port) frm->dinfo = 0; frm->len = 0; - + msg_queue_tail(&glob_mgr->activatequeue, msg); sem_post(&glob_mgr->new_msg); - - return 0; + + return 0; } -int queue_cleanup_bc(struct misdn_bchannel *bc) +int queue_cleanup_bc(struct misdn_bchannel *bc) { msg_t *msg=alloc_msg(MAX_MSG_SIZE); iframe_t *frm; @@ -3794,15 +3794,15 @@ int queue_cleanup_bc(struct misdn_bchannel *bc) frm->dinfo = bc->port; frm->len = 0; - + msg_queue_tail(&glob_mgr->activatequeue, msg); sem_post(&glob_mgr->new_msg); - return 0; + return 0; } -int misdn_lib_pid_restart(int pid) +int misdn_lib_pid_restart(int pid) { struct misdn_bchannel *bc=manager_find_bc_by_pid(pid); @@ -3819,7 +3819,7 @@ int misdn_lib_send_restart(int port, int channel) struct misdn_bchannel dummybc; /*default is all channels*/ cb_log(0, port, "Sending Restarts on this port.\n"); - + misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0); /*default is all channels*/ @@ -3855,11 +3855,11 @@ int misdn_lib_send_restart(int port, int channel) int misdn_lib_port_restart(int port) { struct misdn_stack *stack=find_stack_by_port(port); - + cb_log(0, port, "Restarting this port.\n"); if (stack) { cb_log(0, port, "Stack:%p\n",stack); - + clear_l3(stack); { msg_t *msg=alloc_msg(MAX_MSG_SIZE); @@ -3869,7 +3869,7 @@ int misdn_lib_port_restart(int port) cb_log(0, port, "port_restart: alloc_msg failed\n"); return -1; } - + frm=(iframe_t*)msg->data; /* we must activate if we are deactivated */ /* activate bchannel */ @@ -3884,7 +3884,7 @@ int misdn_lib_port_restart(int port) if (stack->nt) misdn_lib_reinit_nt_stack(stack->port); - + } return 0; @@ -3892,25 +3892,25 @@ int misdn_lib_port_restart(int port) -static sem_t handler_started; +static sem_t handler_started; /* This is a thread */ static void manager_event_handler(void *arg) { - sem_post(&handler_started); + sem_post(&handler_started); while (1) { struct misdn_stack *stack; msg_t *msg; - + /** wait for events **/ sem_wait(&glob_mgr->new_msg); - + for (msg=msg_dequeue(&glob_mgr->activatequeue); msg; msg=msg_dequeue(&glob_mgr->activatequeue) ) { - + iframe_t *frm = (iframe_t*) msg->data ; switch ( frm->prim) { @@ -3925,7 +3925,7 @@ static void manager_event_handler(void *arg) free_msg(msg); break; } - + bc = find_bc_by_l3id(stack, frm->addr); if (bc) { cb_log(1,bc->port,"CLEARSTACK queued, cleaning up\n"); @@ -3934,7 +3934,7 @@ static void manager_event_handler(void *arg) cb_log(0,stack->port,"bc could not be cleaned correctly !! addr [%x]\n",frm->addr); } } - free_msg(msg); + free_msg(msg); break; case MGR_SETSTACK | REQUEST : /* Warning: memory leak here if we get this message */ @@ -3947,10 +3947,10 @@ static void manager_event_handler(void *arg) for (stack=glob_mgr->stack_list; stack; - stack=stack->next ) { + stack=stack->next ) { while ( (msg=msg_dequeue(&stack->upqueue)) ) { - /** Handle L2/3 Signalling after bchans **/ + /** Handle L2/3 Signalling after bchans **/ if (!handle_frm_nt(msg)) { /* Maybe it's TE */ if (!handle_frm(msg)) { @@ -3960,16 +3960,16 @@ static void manager_event_handler(void *arg) } } - /* Here we should check if we really want to - send all the messages we've queued, lets - assume we've queued a Disconnect, but + /* Here we should check if we really want to + send all the messages we've queued, lets + assume we've queued a Disconnect, but received it already from the other side!*/ - + while ( (msg=msg_dequeue(&stack->downqueue)) ) { if (stack->nt ) { if (stack->nst.manager_l3(&stack->nst, msg)) cb_log(0, stack->port, "Error@ Sending Message in NT-Stack.\n"); - + } else { iframe_t *frm = (iframe_t *)msg->data; struct misdn_bchannel *bc = find_bc_by_l3id(stack, frm->dinfo); @@ -3998,14 +3998,14 @@ int misdn_lib_maxports_get(void) int i = mISDN_open(); int max=0; - + if (i<0) return -1; max = mISDN_get_stack_count(i); - + mISDN_close(i); - + return max; } @@ -4022,12 +4022,12 @@ void misdn_lib_nt_keepcalls( int kc) #endif } -void misdn_lib_nt_debug_init( int flags, char *file ) +void misdn_lib_nt_debug_init( int flags, char *file ) { static int init=0; char *f; - - if (!flags) + + if (!flags) f=NULL; else f=file; @@ -4048,50 +4048,50 @@ int misdn_lib_init(char *portlist, struct misdn_lib_iface *iface, void *user_dat char plist[1024]; int midev; int port_count=0; - + cb_log = iface->cb_log; cb_event = iface->cb_event; cb_jb_empty = iface->cb_jb_empty; - + glob_mgr = mgr; - + msg_init(); misdn_lib_nt_debug_init(0,NULL); - + if (!portlist || (*portlist == 0) ) return 1; - + init_flip_bits(); - + { strncpy(plist,portlist, 1024); plist[1023] = 0; } - + memcpy(tone_425_flip,tone_425,TONE_425_SIZE); flip_buf_bits(tone_425_flip,TONE_425_SIZE); memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); - + midev=te_lib_init(); mgr->midev=midev; port_count=mISDN_get_stack_count(midev); - + msg_queue_init(&mgr->activatequeue); - + if (sem_init(&mgr->new_msg, 1, 0)<0) sem_init(&mgr->new_msg, 0, 0); - + for (tok=strtok_r(plist," ,",&tokb ); - tok; + tok; tok=strtok_r(NULL," ,",&tokb)) { int port = atoi(tok); struct misdn_stack *stack; static int first=1; int ptp=0; - + if (strstr(tok, "ptp")) ptp=1; @@ -4100,12 +4100,12 @@ int misdn_lib_init(char *portlist, struct misdn_lib_iface *iface, void *user_dat exit(1); } stack=stack_init(midev, port, ptp); - + if (!stack) { perror("stack_init"); exit(1); } - + { int i; for(i=0;i<=stack->b_num; i++) { @@ -4122,30 +4122,30 @@ int misdn_lib_init(char *portlist, struct misdn_lib_iface *iface, void *user_dat first=0; continue; } - + if (stack) { struct misdn_stack * help; - for ( help=mgr->stack_list; help; help=help->next ) + for ( help=mgr->stack_list; help; help=help->next ) if (help->next == NULL) break; help->next=stack; } - + } - + if (sem_init(&handler_started, 1, 0)<0) sem_init(&handler_started, 0, 0); - + cb_log(8, 0, "Starting Event Handler\n"); pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); - + sem_wait(&handler_started) ; cb_log(8, 0, "Starting Event Catcher\n"); pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); - + cb_log(8, 0, "Event Catcher started\n"); - global_state= MISDN_INITIALIZED; - + global_state= MISDN_INITIALIZED; + return (mgr == NULL); } @@ -4153,7 +4153,7 @@ void misdn_lib_destroy(void) { struct misdn_stack *help; int i; - + for ( help=glob_mgr->stack_list; help; help=help->next ) { for(i=0;i<=help->b_num; i++) { char buf[1024]; @@ -4163,21 +4163,21 @@ void misdn_lib_destroy(void) cb_log (1, help->port, "Destroying this port.\n"); stack_destroy(help); } - + if (global_state == MISDN_INITIALIZED) { cb_log(4, 0, "Killing Handler Thread\n"); if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { cb_log(4, 0, "Joining Handler Thread\n"); pthread_join(glob_mgr->event_handler_thread, NULL); } - + cb_log(4, 0, "Killing Main Thread\n"); if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { cb_log(4, 0, "Joining Main Thread\n"); pthread_join(glob_mgr->event_thread, NULL); } } - + cb_log(1, 0, "Closing mISDN device\n"); te_lib_destroy(glob_mgr->midev); } @@ -4197,12 +4197,12 @@ void manager_bchannel_activate(struct misdn_bchannel *bc) cb_log(0, bc->port, "bchannel_activate: Stack not found !"); return ; } - + /* we must activate if we are deactivated */ clear_ibuffer(bc->astbuf); - + cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); - + mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); return ; @@ -4213,7 +4213,7 @@ void manager_bchannel_deactivate(struct misdn_bchannel * bc) { struct misdn_stack *stack=get_stack_by_bc(bc); iframe_t dact; - char buf[128]; + char buf[128]; switch (bc->bc_state) { case BCHAN_ACTIVATED: @@ -4226,11 +4226,11 @@ void manager_bchannel_deactivate(struct misdn_bchannel * bc) return ; } - + cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr); - + bc->generate_tone=0; - + dact.prim = DL_RELEASE | REQUEST; dact.addr = bc->addr | FLG_MSG_DOWN; dact.dinfo = 0; @@ -4238,9 +4238,9 @@ void manager_bchannel_deactivate(struct misdn_bchannel * bc) mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); clear_ibuffer(bc->astbuf); - + bc_state_change(bc,BCHAN_RELEASE); - + return; } @@ -4260,19 +4260,19 @@ int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len) cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state)); return -1; } - + frm->prim = DL_DATA|REQUEST; frm->dinfo = 0; frm->addr = bc->addr | FLG_MSG_DOWN ; - + frm->len = len; memcpy(&buf[mISDN_HEADER_LEN], data,len); - - if ( misdn_cap_is_speech(bc->capability) ) + + if ( misdn_cap_is_speech(bc->capability) ) flip_buf_bits( &buf[mISDN_HEADER_LEN], len); else cb_log(6, stack->port, "Writing %d data bytes\n",len); - + cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); return 0; @@ -4289,9 +4289,9 @@ void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2) iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ unsigned int *d = (unsigned int*)&ctrl->data.p; /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ - + cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); - + ctrl->prim = PH_CONTROL | REQUEST; ctrl->addr = bc->addr | FLG_MSG_DOWN; ctrl->dinfo = 0; @@ -4340,7 +4340,7 @@ void manager_ph_control_block(struct misdn_bchannel *bc, int c1, void *c2, int c iframe_t *ctrl = (iframe_t *)buffer; unsigned int *d = (unsigned int *)&ctrl->data.p; /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ - + ctrl->prim = PH_CONTROL | REQUEST; ctrl->addr = bc->addr | FLG_MSG_DOWN; ctrl->dinfo = 0; @@ -4356,13 +4356,13 @@ void manager_ph_control_block(struct misdn_bchannel *bc, int c1, void *c2, int c void manager_clean_bc(struct misdn_bchannel *bc ) { struct misdn_stack *stack=get_stack_by_bc(bc); - + if (bc->channel>0) empty_chan_in_stack(stack, bc->channel); empty_bc(bc); bc->in_use=0; - cb_event(EVENT_CLEANUP, bc, NULL); + cb_event(EVENT_CLEANUP, bc, NULL); } @@ -4370,15 +4370,15 @@ void stack_holder_add(struct misdn_stack *stack, struct misdn_bchannel *holder) { struct misdn_bchannel *help; cb_log(4,stack->port, "*HOLDER: add %x\n",holder->l3_id); - + holder->stack_holder=1; holder->next=NULL; - + if (!stack->holding) { stack->holding = holder; return; } - + for (help=stack->holding; help; help=help->next) { @@ -4387,7 +4387,7 @@ void stack_holder_add(struct misdn_stack *stack, struct misdn_bchannel *holder) break; } } - + } void stack_holder_remove(struct misdn_stack *stack, struct misdn_bchannel *holder) @@ -4395,17 +4395,17 @@ void stack_holder_remove(struct misdn_stack *stack, struct misdn_bchannel *holde struct misdn_bchannel *h1; if (!holder->stack_holder) return; - + holder->stack_holder=0; - + cb_log(4,stack->port, "*HOLDER: remove %x\n",holder->l3_id); if (!stack || ! stack->holding) return; - + if (holder == stack->holding) { stack->holding = stack->holding->next; return; } - + for (h1=stack->holding; h1; h1=h1->next) { @@ -4421,9 +4421,9 @@ struct misdn_bchannel *stack_holder_find_bychan(struct misdn_stack *stack, int c struct misdn_bchannel *help; cb_log(4,stack?stack->port:0, "*HOLDER: find_bychan %c\n", chan); - + if (!stack) return NULL; - + for (help=stack->holding; help; help=help->next) { @@ -4443,9 +4443,9 @@ struct misdn_bchannel *stack_holder_find(struct misdn_stack *stack, unsigned lon struct misdn_bchannel *help; cb_log(4,stack?stack->port:0, "*HOLDER: find %lx\n",l3id); - + if (!stack) return NULL; - + for (help=stack->holding; help; help=help->next) { @@ -4461,34 +4461,34 @@ struct misdn_bchannel *stack_holder_find(struct misdn_stack *stack, unsigned lon -void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone) +void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone) { char buf[mISDN_HEADER_LEN + 128] = ""; iframe_t *frm = (iframe_t*)buf; switch(tone) { case TONE_DIAL: - manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); + manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); break; - + case TONE_ALERTING: - manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); + manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); break; - + case TONE_HANGUP: - manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); + manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); break; case TONE_NONE: default: - manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); + manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); } frm->prim=DL_DATA|REQUEST; frm->addr=bc->addr|FLG_MSG_DOWN; frm->dinfo=0; frm->len=128; - + mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); } @@ -4496,7 +4496,7 @@ void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone) void manager_ec_enable(struct misdn_bchannel *bc) { struct misdn_stack *stack=get_stack_by_bc(bc); - + cb_log(4, stack?stack->port:0,"ec_enable\n"); if (!misdn_cap_is_speech(bc->capability)) { @@ -4513,7 +4513,7 @@ void manager_ec_enable(struct misdn_bchannel *bc) if (bc->ec_enable) { cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); - + switch (bc->ec_deftaps) { case 4: case 8: @@ -4530,10 +4530,10 @@ void manager_ec_enable(struct misdn_bchannel *bc) cb_log(0, stack->port, "Taps should be power of 2\n"); bc->ec_deftaps=128; } - + ec_arr[0]=bc->ec_deftaps; ec_arr[1]=0; - + manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); } #endif @@ -4545,7 +4545,7 @@ void manager_ec_enable(struct misdn_bchannel *bc) void manager_ec_disable(struct misdn_bchannel *bc) { struct misdn_stack *stack=get_stack_by_bc(bc); - + cb_log(4, stack?stack->port:0," --> ec_disable\n"); if (!misdn_cap_is_speech(bc->capability)) { @@ -4600,10 +4600,10 @@ void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2) cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); - for (bc=bc_list; *bc; bc++) { + for (bc=bc_list; *bc; bc++) { (*bc)->conf_id=conf_id; cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr); - + switch((*bc)->bc_state) { case BCHAN_ACTIVATED: misdn_join_conf(*bc,conf_id); @@ -4622,15 +4622,15 @@ void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel bc1,bc2,NULL }; struct misdn_bchannel **bc; - - for (bc=bc_list; *bc; bc++) { + + for (bc=bc_list; *bc; bc++) { if ( (*bc)->bc_state == BCHAN_BRIDGED){ misdn_split_conf( *bc, (*bc)->conf_id); } else { cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state)); } } - + } @@ -4646,37 +4646,37 @@ void misdn_lib_echo(struct misdn_bchannel *bc, int onoff) void misdn_lib_reinit_nt_stack(int port) { struct misdn_stack *stack=find_stack_by_port(port); - + if (stack) { stack->l2link=0; stack->blocked=0; - + cleanup_Isdnl3(&stack->nst); cleanup_Isdnl2(&stack->nst); memset(&stack->nst, 0, sizeof(net_stack_t)); memset(&stack->mgr, 0, sizeof(manager_t)); - + stack->mgr.nst = &stack->nst; stack->nst.manager = &stack->mgr; - + stack->nst.l3_manager = handle_event_nt; stack->nst.device = glob_mgr->midev; stack->nst.cardnr = port; stack->nst.d_stid = stack->d_stid; - + stack->nst.feature = FEATURE_NET_HOLD; if (stack->ptp) stack->nst.feature |= FEATURE_NET_PTP; if (stack->pri) stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; - + stack->nst.l1_id = stack->lower_id; stack->nst.l2_id = stack->upper_id; - + msg_queue_init(&stack->nst.down_queue); - + Isdnl2Init(&stack->nst); Isdnl3Init(&stack->nst); diff --git a/channels/misdn/isdn_msg_parser.c b/channels/misdn/isdn_msg_parser.c index dc2f74e9d2..6c4272ea0c 100644 --- a/channels/misdn/isdn_msg_parser.c +++ b/channels/misdn/isdn_msg_parser.c @@ -11,7 +11,7 @@ * the GNU General Public License */ -/*! \file +/*! \file * \brief Interface to mISDN - message parser * \author Christian Richter */ @@ -30,16 +30,16 @@ static void set_channel(struct misdn_bchannel *bc, int channel) { cb_log(3,bc->port,"set_channel: bc->channel:%d channel:%d\n", bc->channel, channel); - - + + if (channel==0xff) { /* any channel */ channel=-1; } - + /* ALERT: is that everytime true ? */ if (channel > 0 && bc->nt ) { - + if (bc->channel && ( bc->channel != 0xff) ) { cb_log(0,bc->port,"We already have a channel (%d)\n", bc->channel); } else { @@ -47,130 +47,130 @@ static void set_channel(struct misdn_bchannel *bc, int channel) cb_event(EVENT_NEW_CHANNEL,bc,NULL); } } - + if (channel > 0 && !bc->nt ) { bc->channel = channel; cb_event(EVENT_NEW_CHANNEL,bc,NULL); } } -static void parse_proceeding (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_proceeding (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; CALL_PROCEEDING_t *proceeding=(CALL_PROCEEDING_t*)((unsigned long)msg->data+ HEADER_LEN); //struct misdn_stack *stack=get_stack_by_bc(bc); - + { int exclusive, channel; dec_ie_channel_id(proceeding->CHANNEL_ID, (Q931_info_t *)proceeding, &exclusive, &channel, nt,bc); set_channel(bc,channel); - + } - + dec_ie_progress(proceeding->PROGRESS, (Q931_info_t *)proceeding, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); - - -#ifdef DEBUG - printf("Parsing PROCEEDING Msg\n"); + + +#ifdef DEBUG + printf("Parsing PROCEEDING Msg\n"); #endif } static msg_t *build_proceeding (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; CALL_PROCEEDING_t *proceeding; - msg_t *msg =(msg_t*)create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, bc?bc->l3_id:-1, sizeof(CALL_PROCEEDING_t) ,nt); - + msg_t *msg =(msg_t*)create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, bc?bc->l3_id:-1, sizeof(CALL_PROCEEDING_t) ,nt); + proceeding=(CALL_PROCEEDING_t*)((msg->data+HEADER_LEN)); enc_ie_channel_id(&proceeding->CHANNEL_ID, msg, 1,bc->channel, nt,bc); - - if (nt) + + if (nt) enc_ie_progress(&proceeding->PROGRESS, msg, 0, nt?1:5, 8, nt,bc); - -#ifdef DEBUG - printf("Building PROCEEDING Msg\n"); + +#ifdef DEBUG + printf("Building PROCEEDING Msg\n"); #endif - return msg; + return msg; } -static void parse_alerting (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_alerting (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { - int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; + int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; ALERTING_t *alerting=(ALERTING_t*)((unsigned long)(msg->data+HEADER_LEN)); //Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN); - + dec_ie_progress(alerting->PROGRESS, (Q931_info_t *)alerting, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); - -#ifdef DEBUG - printf("Parsing ALERTING Msg\n"); + +#ifdef DEBUG + printf("Parsing ALERTING Msg\n"); #endif - + } -static msg_t *build_alerting (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_alerting (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; ALERTING_t *alerting; - msg_t *msg =(msg_t*)create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING, bc?bc->l3_id:-1, sizeof(ALERTING_t) ,nt); - - alerting=(ALERTING_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING, bc?bc->l3_id:-1, sizeof(ALERTING_t) ,nt); + + alerting=(ALERTING_t*)((msg->data+HEADER_LEN)); + enc_ie_channel_id(&alerting->CHANNEL_ID, msg, 1,bc->channel, nt,bc); - - if (nt) + + if (nt) enc_ie_progress(&alerting->PROGRESS, msg, 0, nt?1:5, 8, nt,bc); -#ifdef DEBUG - printf("Building ALERTING Msg\n"); +#ifdef DEBUG + printf("Building ALERTING Msg\n"); #endif - return msg; + return msg; } -static void parse_progress (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_progress (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; - PROGRESS_t *progress=(PROGRESS_t*)((unsigned long)(msg->data+HEADER_LEN)); - //Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN); - + PROGRESS_t *progress=(PROGRESS_t*)((unsigned long)(msg->data+HEADER_LEN)); + //Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN); + dec_ie_progress(progress->PROGRESS, (Q931_info_t *)progress, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); - -#ifdef DEBUG - printf("Parsing PROGRESS Msg\n"); + +#ifdef DEBUG + printf("Parsing PROGRESS Msg\n"); #endif } -static msg_t *build_progress (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_progress (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; PROGRESS_t *progress; - msg_t *msg =(msg_t*)create_l3msg(CC_PROGRESS | REQUEST, MT_PROGRESS, bc?bc->l3_id:-1, sizeof(PROGRESS_t) ,nt); - - progress=(PROGRESS_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_PROGRESS | REQUEST, MT_PROGRESS, bc?bc->l3_id:-1, sizeof(PROGRESS_t) ,nt); + + progress=(PROGRESS_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building PROGRESS Msg\n"); +#ifdef DEBUG + printf("Building PROGRESS Msg\n"); #endif - return msg; + return msg; } -static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) -{ +static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +{ int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SETUP_t *setup= (SETUP_t*)((unsigned long)msg->data+HEADER_LEN); Q931_info_t *qi=(Q931_info_t*)((unsigned long)msg->data+HEADER_LEN); -#ifdef DEBUG - printf("Parsing SETUP Msg\n"); +#ifdef DEBUG + printf("Parsing SETUP Msg\n"); #endif { int type,plan,present, screen; char id[32]; dec_ie_calling_pn(setup->CALLING_PN, qi, &type, &plan, &present, &screen, id, sizeof(id)-1, nt,bc); - bc->onumplan=type; + bc->onumplan=type; strcpy(bc->oad, id); switch (present) { case 0: @@ -187,14 +187,14 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann break; default: ; - } + } } { int type, plan; - char number[32]; + char number[32]; dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)setup, &type, &plan, number, sizeof(number)-1, nt,bc); strcpy(bc->dad, number); - bc->dnumplan=type; + bc->dnumplan=type; } { char keypad[32]; @@ -204,22 +204,22 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann { dec_ie_complete(setup->COMPLETE, (Q931_info_t *)setup, &bc->sending_complete, nt,bc); - + } - + { int type, plan, present, screen, reason; - char id[32]; + char id[32]; dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)setup, &type, &plan, &present, &screen, &reason, id, sizeof(id)-1, nt,bc); - + strcpy(bc->rad, id); - bc->rnumplan=type; + bc->rnumplan=type; } { int coding, capability, mode, rate, multi, user, async, urate, stopbits, dbits, parity; dec_ie_bearer(setup->BEARER, (Q931_info_t *)setup, &coding, &capability, &mode, &rate, &multi, &user, &async, &urate, &stopbits, &dbits, &parity, nt,bc); switch (capability) { - case -1: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED; + case -1: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED; break; case 0: bc->capability=INFO_CAPABILITY_SPEECH; break; @@ -228,7 +228,7 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann case 8: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED; bc->user1 = user; bc->urate = urate; - + bc->rate = rate; bc->mode = mode; break; @@ -237,7 +237,7 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann default: break; } - + switch(user) { case 2: bc->law=INFO_CODEC_ULAW; @@ -247,15 +247,15 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann break; default: bc->law=INFO_CODEC_ALAW; - + } - - bc->capability=capability; + + bc->capability=capability; } { int exclusive, channel; dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)setup, &exclusive, &channel, nt,bc); - + set_channel(bc,channel); } @@ -266,32 +266,32 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann else cb_log(1,bc->port,"NO USERUESRINFO\n"); } - + dec_ie_progress(setup->PROGRESS, (Q931_info_t *)setup, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); - + } #define ANY_CHANNEL 0xff /* IE attribut for 'any channel' */ -static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SETUP_t *setup; - msg_t *msg =(msg_t*)create_l3msg(CC_SETUP | REQUEST, MT_SETUP, bc?bc->l3_id:-1, sizeof(SETUP_t) ,nt); - - setup=(SETUP_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_SETUP | REQUEST, MT_SETUP, bc?bc->l3_id:-1, sizeof(SETUP_t) ,nt); + + setup=(SETUP_t*)((msg->data+HEADER_LEN)); + if (bc->channel == 0 || bc->channel == ANY_CHANNEL || bc->channel==-1) enc_ie_channel_id(&setup->CHANNEL_ID, msg, 0, bc->channel, nt,bc); - else + else enc_ie_channel_id(&setup->CHANNEL_ID, msg, 1, bc->channel, nt,bc); - - + + { int type=bc->onumplan,plan=1,present=bc->pres,screen=bc->screen; enc_ie_calling_pn(&setup->CALLING_PN, msg, type, plan, present, screen, bc->oad, nt, bc); } - + { if (bc->dad[0]) enc_ie_called_pn(&setup->CALLED_PN, msg, bc->dnumplan, 1, bc->dad, nt,bc); @@ -306,12 +306,12 @@ static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, in if (bc->keypad[0]) enc_ie_keypad(&setup->KEYPAD, msg, bc->keypad, nt,bc); } - - + + if (*bc->display) { enc_ie_display(&setup->DISPLAY, msg, bc->display, nt,bc); } - + { int coding=0, capability, mode=0 /* 2 for packet ! */ ,user, rate=0x10; @@ -324,7 +324,7 @@ static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, in default: user=3; } - + switch (bc->capability) { case INFO_CAPABILITY_SPEECH: capability = 0; break; @@ -337,37 +337,37 @@ static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, in user=-1; break; default: - capability=bc->capability; + capability=bc->capability; } - - - + + + enc_ie_bearer(&setup->BEARER, msg, coding, capability, mode, rate, -1, user, nt,bc); } if (bc->sending_complete) { enc_ie_complete(&setup->COMPLETE,msg, bc->sending_complete, nt, bc); } - + if (bc->uulen) { int protocol=4; enc_ie_useruser(&setup->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu); } -#ifdef DEBUG - printf("Building SETUP Msg\n"); +#ifdef DEBUG + printf("Building SETUP Msg\n"); #endif - return msg; + return msg; } -static void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; CONNECT_t *connect=(CONNECT_t*)((unsigned long)(msg->data+HEADER_LEN)); - + int plan,pres,screen; - + bc->ces = connect->ces; bc->ces = connect->ces; @@ -378,40 +378,40 @@ static void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bcha /* cb_log(1,bc->port,"CONNETED PN: %s cpn_dialplan:%d\n", connected_pn, type); */ - -#ifdef DEBUG - printf("Parsing CONNECT Msg\n"); + +#ifdef DEBUG + printf("Parsing CONNECT Msg\n"); #endif } -static msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; CONNECT_t *connect; - msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_t) ,nt); - + msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_t) ,nt); + cb_log(6,bc->port,"BUILD_CONNECT: bc:%p bc->l3id:%d, nt:%d\n",bc,bc->l3_id,nt); - connect=(CONNECT_t*)((msg->data+HEADER_LEN)); + connect=(CONNECT_t*)((msg->data+HEADER_LEN)); if (nt) { time_t now; time(&now); enc_ie_date(&connect->DATE, msg, now, nt,bc); } - + { int type=bc->cpnnumplan, plan=1, present=2, screen=0; enc_ie_connected_pn(&connect->CONNECT_PN, msg, type,plan, present, screen, bc->cad, nt , bc); } -#ifdef DEBUG - printf("Building CONNECT Msg\n"); +#ifdef DEBUG + printf("Building CONNECT Msg\n"); #endif - return msg; + return msg; } -static void parse_setup_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_setup_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SETUP_ACKNOWLEDGE_t *setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((unsigned long)(msg->data+HEADER_LEN)); @@ -423,384 +423,384 @@ static void parse_setup_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct set_channel(bc, channel); } - + dec_ie_progress(setup_acknowledge->PROGRESS, (Q931_info_t *)setup_acknowledge, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); -#ifdef DEBUG - printf("Parsing SETUP_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Parsing SETUP_ACKNOWLEDGE Msg\n"); #endif - + } -static msg_t *build_setup_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_setup_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SETUP_ACKNOWLEDGE_t *setup_acknowledge; - msg_t *msg =(msg_t*)create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SETUP_ACKNOWLEDGE_t) ,nt); - - setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SETUP_ACKNOWLEDGE_t) ,nt); + + setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); + enc_ie_channel_id(&setup_acknowledge->CHANNEL_ID, msg, 1,bc->channel, nt,bc); - - if (nt) + + if (nt) enc_ie_progress(&setup_acknowledge->PROGRESS, msg, 0, nt?1:5, 8, nt,bc); - -#ifdef DEBUG - printf("Building SETUP_ACKNOWLEDGE Msg\n"); + +#ifdef DEBUG + printf("Building SETUP_ACKNOWLEDGE Msg\n"); #endif - return msg; + return msg; } -static void parse_connect_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_connect_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing CONNECT_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Parsing CONNECT_ACKNOWLEDGE Msg\n"); #endif - + } -static msg_t *build_connect_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_connect_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; CONNECT_ACKNOWLEDGE_t *connect_acknowledge; - msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_ACKNOWLEDGE_t) ,nt); - - connect_acknowledge=(CONNECT_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_ACKNOWLEDGE_t) ,nt); + + connect_acknowledge=(CONNECT_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); + enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc); - -#ifdef DEBUG - printf("Building CONNECT_ACKNOWLEDGE Msg\n"); + +#ifdef DEBUG + printf("Building CONNECT_ACKNOWLEDGE Msg\n"); #endif - return msg; + return msg; } -static void parse_user_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_user_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing USER_INFORMATION Msg\n"); +#ifdef DEBUG + printf("Parsing USER_INFORMATION Msg\n"); #endif - + } -static msg_t *build_user_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_user_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; USER_INFORMATION_t *user_information; - msg_t *msg =(msg_t*)create_l3msg(CC_USER_INFORMATION | REQUEST, MT_USER_INFORMATION, bc?bc->l3_id:-1, sizeof(USER_INFORMATION_t) ,nt); - - user_information=(USER_INFORMATION_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_USER_INFORMATION | REQUEST, MT_USER_INFORMATION, bc?bc->l3_id:-1, sizeof(USER_INFORMATION_t) ,nt); + + user_information=(USER_INFORMATION_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building USER_INFORMATION Msg\n"); +#ifdef DEBUG + printf("Building USER_INFORMATION Msg\n"); #endif - return msg; + return msg; } -static void parse_suspend_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_suspend_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing SUSPEND_REJECT Msg\n"); +#ifdef DEBUG + printf("Parsing SUSPEND_REJECT Msg\n"); #endif - + } -static msg_t *build_suspend_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_suspend_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SUSPEND_REJECT_t *suspend_reject; - msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, bc?bc->l3_id:-1, sizeof(SUSPEND_REJECT_t) ,nt); - - suspend_reject=(SUSPEND_REJECT_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, bc?bc->l3_id:-1, sizeof(SUSPEND_REJECT_t) ,nt); + + suspend_reject=(SUSPEND_REJECT_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building SUSPEND_REJECT Msg\n"); +#ifdef DEBUG + printf("Building SUSPEND_REJECT Msg\n"); #endif - return msg; + return msg; } -static void parse_resume_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_resume_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing RESUME_REJECT Msg\n"); +#ifdef DEBUG + printf("Parsing RESUME_REJECT Msg\n"); #endif - + } -static msg_t *build_resume_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_resume_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESUME_REJECT_t *resume_reject; - msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, bc?bc->l3_id:-1, sizeof(RESUME_REJECT_t) ,nt); - - resume_reject=(RESUME_REJECT_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, bc?bc->l3_id:-1, sizeof(RESUME_REJECT_t) ,nt); + + resume_reject=(RESUME_REJECT_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building RESUME_REJECT Msg\n"); +#ifdef DEBUG + printf("Building RESUME_REJECT Msg\n"); #endif - return msg; + return msg; } -static void parse_hold (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_hold (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing HOLD Msg\n"); +#ifdef DEBUG + printf("Parsing HOLD Msg\n"); #endif - + } -static msg_t *build_hold (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_hold (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; HOLD_t *hold; - msg_t *msg =(msg_t*)create_l3msg(CC_HOLD | REQUEST, MT_HOLD, bc?bc->l3_id:-1, sizeof(HOLD_t) ,nt); - - hold=(HOLD_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_HOLD | REQUEST, MT_HOLD, bc?bc->l3_id:-1, sizeof(HOLD_t) ,nt); + + hold=(HOLD_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building HOLD Msg\n"); +#ifdef DEBUG + printf("Building HOLD Msg\n"); #endif - return msg; + return msg; } -static void parse_suspend (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_suspend (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing SUSPEND Msg\n"); +#ifdef DEBUG + printf("Parsing SUSPEND Msg\n"); #endif - + } -static msg_t *build_suspend (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_suspend (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SUSPEND_t *suspend; - msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND | REQUEST, MT_SUSPEND, bc?bc->l3_id:-1, sizeof(SUSPEND_t) ,nt); - - suspend=(SUSPEND_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND | REQUEST, MT_SUSPEND, bc?bc->l3_id:-1, sizeof(SUSPEND_t) ,nt); + + suspend=(SUSPEND_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building SUSPEND Msg\n"); +#ifdef DEBUG + printf("Building SUSPEND Msg\n"); #endif - return msg; + return msg; } -static void parse_resume (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_resume (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing RESUME Msg\n"); +#ifdef DEBUG + printf("Parsing RESUME Msg\n"); #endif - + } -static msg_t *build_resume (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_resume (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESUME_t *resume; - msg_t *msg =(msg_t*)create_l3msg(CC_RESUME | REQUEST, MT_RESUME, bc?bc->l3_id:-1, sizeof(RESUME_t) ,nt); - - resume=(RESUME_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RESUME | REQUEST, MT_RESUME, bc?bc->l3_id:-1, sizeof(RESUME_t) ,nt); + + resume=(RESUME_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building RESUME Msg\n"); +#ifdef DEBUG + printf("Building RESUME Msg\n"); #endif - return msg; + return msg; } -static void parse_hold_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_hold_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing HOLD_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Parsing HOLD_ACKNOWLEDGE Msg\n"); #endif - + } -static msg_t *build_hold_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_hold_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; HOLD_ACKNOWLEDGE_t *hold_acknowledge; - msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(HOLD_ACKNOWLEDGE_t) ,nt); - - hold_acknowledge=(HOLD_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(HOLD_ACKNOWLEDGE_t) ,nt); + + hold_acknowledge=(HOLD_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building HOLD_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Building HOLD_ACKNOWLEDGE Msg\n"); #endif - return msg; + return msg; } -static void parse_suspend_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_suspend_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing SUSPEND_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Parsing SUSPEND_ACKNOWLEDGE Msg\n"); #endif - + } -static msg_t *build_suspend_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_suspend_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SUSPEND_ACKNOWLEDGE_t *suspend_acknowledge; - msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SUSPEND_ACKNOWLEDGE_t) ,nt); - - suspend_acknowledge=(SUSPEND_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SUSPEND_ACKNOWLEDGE_t) ,nt); + + suspend_acknowledge=(SUSPEND_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building SUSPEND_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Building SUSPEND_ACKNOWLEDGE Msg\n"); #endif - return msg; + return msg; } -static void parse_resume_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_resume_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing RESUME_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Parsing RESUME_ACKNOWLEDGE Msg\n"); #endif - + } -static msg_t *build_resume_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_resume_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESUME_ACKNOWLEDGE_t *resume_acknowledge; - msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RESUME_ACKNOWLEDGE_t) ,nt); - - resume_acknowledge=(RESUME_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RESUME_ACKNOWLEDGE_t) ,nt); + + resume_acknowledge=(RESUME_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building RESUME_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Building RESUME_ACKNOWLEDGE Msg\n"); #endif - return msg; + return msg; } -static void parse_hold_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_hold_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing HOLD_REJECT Msg\n"); +#ifdef DEBUG + printf("Parsing HOLD_REJECT Msg\n"); #endif - + } -static msg_t *build_hold_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_hold_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; HOLD_REJECT_t *hold_reject; - msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, bc?bc->l3_id:-1, sizeof(HOLD_REJECT_t) ,nt); - - hold_reject=(HOLD_REJECT_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, bc?bc->l3_id:-1, sizeof(HOLD_REJECT_t) ,nt); + + hold_reject=(HOLD_REJECT_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building HOLD_REJECT Msg\n"); +#ifdef DEBUG + printf("Building HOLD_REJECT Msg\n"); #endif - return msg; + return msg; } -static void parse_retrieve (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_retrieve (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing RETRIEVE Msg\n"); +#ifdef DEBUG + printf("Parsing RETRIEVE Msg\n"); #endif - + } -static msg_t *build_retrieve (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_retrieve (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RETRIEVE_t *retrieve; - msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE | REQUEST, MT_RETRIEVE, bc?bc->l3_id:-1, sizeof(RETRIEVE_t) ,nt); - - retrieve=(RETRIEVE_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE | REQUEST, MT_RETRIEVE, bc?bc->l3_id:-1, sizeof(RETRIEVE_t) ,nt); + + retrieve=(RETRIEVE_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building RETRIEVE Msg\n"); +#ifdef DEBUG + printf("Building RETRIEVE Msg\n"); #endif - return msg; + return msg; } -static void parse_retrieve_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_retrieve_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing RETRIEVE_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Parsing RETRIEVE_ACKNOWLEDGE Msg\n"); #endif - + } -static msg_t *build_retrieve_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_retrieve_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge; - msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RETRIEVE_ACKNOWLEDGE_t) ,nt); - - retrieve_acknowledge=(RETRIEVE_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RETRIEVE_ACKNOWLEDGE_t) ,nt); + + retrieve_acknowledge=(RETRIEVE_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc); -#ifdef DEBUG - printf("Building RETRIEVE_ACKNOWLEDGE Msg\n"); +#ifdef DEBUG + printf("Building RETRIEVE_ACKNOWLEDGE Msg\n"); #endif - return msg; + return msg; } -static void parse_retrieve_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_retrieve_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing RETRIEVE_REJECT Msg\n"); +#ifdef DEBUG + printf("Parsing RETRIEVE_REJECT Msg\n"); #endif - + } -static msg_t *build_retrieve_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_retrieve_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RETRIEVE_REJECT_t *retrieve_reject; - msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, bc?bc->l3_id:-1, sizeof(RETRIEVE_REJECT_t) ,nt); - - retrieve_reject=(RETRIEVE_REJECT_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, bc?bc->l3_id:-1, sizeof(RETRIEVE_REJECT_t) ,nt); + + retrieve_reject=(RETRIEVE_REJECT_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building RETRIEVE_REJECT Msg\n"); +#ifdef DEBUG + printf("Building RETRIEVE_REJECT Msg\n"); #endif - return msg; + return msg; } -static void parse_disconnect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_disconnect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; DISCONNECT_t *disconnect=(DISCONNECT_t*)((unsigned long)(msg->data+HEADER_LEN)); int location; - int cause; + int cause; dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)(disconnect), &location, &cause, nt,bc); if (cause>0) bc->cause=cause; dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)disconnect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); -#ifdef DEBUG - printf("Parsing DISCONNECT Msg\n"); +#ifdef DEBUG + printf("Parsing DISCONNECT Msg\n"); #endif - + } -static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; DISCONNECT_t *disconnect; - msg_t *msg =(msg_t*)create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, bc?bc->l3_id:-1, sizeof(DISCONNECT_t) ,nt); - - disconnect=(DISCONNECT_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, bc?bc->l3_id:-1, sizeof(DISCONNECT_t) ,nt); + + disconnect=(DISCONNECT_t*)((msg->data+HEADER_LEN)); + enc_ie_cause(&disconnect->CAUSE, msg, (nt)?1:0, bc->out_cause,nt,bc); if (nt) enc_ie_progress(&disconnect->PROGRESS, msg, 0, nt?1:5, 8 ,nt,bc); @@ -809,42 +809,42 @@ static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *b enc_ie_useruser(&disconnect->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu); } - -#ifdef DEBUG - printf("Building DISCONNECT Msg\n"); + +#ifdef DEBUG + printf("Building DISCONNECT Msg\n"); #endif - return msg; + return msg; } -static void parse_restart (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_restart (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESTART_t *restart=(RESTART_t*)((unsigned long)(msg->data+HEADER_LEN)); struct misdn_stack *stack=get_stack_by_bc(bc); - -#ifdef DEBUG + +#ifdef DEBUG printf("Parsing RESTART Msg\n"); #endif - + { int exclusive; dec_ie_channel_id(restart->CHANNEL_ID, (Q931_info_t *)restart, &exclusive, &bc->restart_channel, nt,bc); cb_log(3, stack->port, "CC_RESTART Request on channel:%d on this port.\n", bc->restart_channel); } - + } -static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESTART_t *restart; - msg_t *msg =(msg_t*)create_l3msg(CC_RESTART | REQUEST, MT_RESTART, bc?bc->l3_id:-1, sizeof(RESTART_t) ,nt); - - restart=(RESTART_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_RESTART | REQUEST, MT_RESTART, bc?bc->l3_id:-1, sizeof(RESTART_t) ,nt); + + restart=(RESTART_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building RESTART Msg\n"); +#ifdef DEBUG + printf("Building RESTART Msg\n"); #endif if (bc->channel > 0) { @@ -855,33 +855,33 @@ static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, } cb_log(0,bc->port, "Restarting channel %d\n", bc->channel); - return msg; + return msg; } -static void parse_release (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_release (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_t *release=(RELEASE_t*)((unsigned long)(msg->data+HEADER_LEN)); int location; int cause; - + dec_ie_cause(release->CAUSE, (Q931_info_t *)(release), &location, &cause, nt,bc); if (cause>0) bc->cause=cause; -#ifdef DEBUG - printf("Parsing RELEASE Msg\n"); +#ifdef DEBUG + printf("Parsing RELEASE Msg\n"); #endif - + } -static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_t *release; - msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, bc?bc->l3_id:-1, sizeof(RELEASE_t) ,nt); - - release=(RELEASE_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, bc?bc->l3_id:-1, sizeof(RELEASE_t) ,nt); + + release=(RELEASE_t*)((msg->data+HEADER_LEN)); + if (bc->out_cause>= 0) enc_ie_cause(&release->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc); @@ -890,14 +890,14 @@ static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc, enc_ie_useruser(&release->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu); } - -#ifdef DEBUG - printf("Building RELEASE Msg\n"); + +#ifdef DEBUG + printf("Building RELEASE Msg\n"); #endif - return msg; + return msg; } -static void parse_release_complete (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_release_complete (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_COMPLETE_t *release_complete=(RELEASE_COMPLETE_t*)((unsigned long)(msg->data+HEADER_LEN)); @@ -926,19 +926,19 @@ static void parse_release_complete (struct isdn_msg msgs[], msg_t *msg, struct m dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)(release_complete), &location, &cause, nt,bc); if (cause>0) bc->cause=cause; -#ifdef DEBUG - printf("Parsing RELEASE_COMPLETE Msg\n"); +#ifdef DEBUG + printf("Parsing RELEASE_COMPLETE Msg\n"); #endif } -static msg_t *build_release_complete (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_release_complete (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_COMPLETE_t *release_complete; - msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, bc?bc->l3_id:-1, sizeof(RELEASE_COMPLETE_t) ,nt); - - release_complete=(RELEASE_COMPLETE_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, bc?bc->l3_id:-1, sizeof(RELEASE_COMPLETE_t) ,nt); + + release_complete=(RELEASE_COMPLETE_t*)((msg->data+HEADER_LEN)); + enc_ie_cause(&release_complete->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc); if (bc->uulen) { @@ -946,23 +946,23 @@ static msg_t *build_release_complete (struct isdn_msg msgs[], struct misdn_bchan enc_ie_useruser(&release_complete->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu); } - -#ifdef DEBUG - printf("Building RELEASE_COMPLETE Msg\n"); + +#ifdef DEBUG + printf("Building RELEASE_COMPLETE Msg\n"); #endif - return msg; + return msg; } -static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; - FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); - Q931_info_t *qi = (Q931_info_t*)(msg->data+HEADER_LEN); + FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); + Q931_info_t *qi = (Q931_info_t*)(msg->data+HEADER_LEN); unsigned char *p = NULL; int err; -#ifdef DEBUG - printf("Parsing FACILITY Msg\n"); +#ifdef DEBUG + printf("Parsing FACILITY Msg\n"); #endif if (!bc->nt) { @@ -973,27 +973,27 @@ static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bch } if (!p) return; - + err = decodeFac(p, &(bc->fac_in)); if (err) { cb_log(5, bc->port, "Decoding FACILITY failed! (%d)\n", err); } } -static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int len, HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; unsigned char *ie_fac, fac_tmp[256]; msg_t *msg =(msg_t*)create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, bc?bc->l3_id:-1, sizeof(FACILITY_t) ,nt); - FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); + FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); Q931_info_t *qi; -#ifdef DEBUG - printf("Building FACILITY Msg\n"); +#ifdef DEBUG + printf("Building FACILITY Msg\n"); #endif - + len = encodeFac(fac_tmp, &(bc->fac_out)); if (len <= 0) return NULL; @@ -1013,52 +1013,52 @@ static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, enc_ie_display(&facility->DISPLAY, msg, bc->display, nt,bc); } - return msg; + return msg; } -static void parse_notify (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_notify (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing NOTIFY Msg\n"); +#ifdef DEBUG + printf("Parsing NOTIFY Msg\n"); #endif } -static msg_t *build_notify (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_notify (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; NOTIFY_t *notify; - msg_t *msg =(msg_t*)create_l3msg(CC_NOTIFY | REQUEST, MT_NOTIFY, bc?bc->l3_id:-1, sizeof(NOTIFY_t) ,nt); - - notify=(NOTIFY_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_NOTIFY | REQUEST, MT_NOTIFY, bc?bc->l3_id:-1, sizeof(NOTIFY_t) ,nt); -#ifdef DEBUG - printf("Building NOTIFY Msg\n"); + notify=(NOTIFY_t*)((msg->data+HEADER_LEN)); + +#ifdef DEBUG + printf("Building NOTIFY Msg\n"); #endif - return msg; + return msg; } -static void parse_status_enquiry (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_status_enquiry (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing STATUS_ENQUIRY Msg\n"); +#ifdef DEBUG + printf("Parsing STATUS_ENQUIRY Msg\n"); #endif } -static msg_t *build_status_enquiry (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_status_enquiry (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; STATUS_ENQUIRY_t *status_enquiry; - msg_t *msg =(msg_t*)create_l3msg(CC_STATUS_ENQUIRY | REQUEST, MT_STATUS_ENQUIRY, bc?bc->l3_id:-1, sizeof(STATUS_ENQUIRY_t) ,nt); - - status_enquiry=(STATUS_ENQUIRY_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_STATUS_ENQUIRY | REQUEST, MT_STATUS_ENQUIRY, bc?bc->l3_id:-1, sizeof(STATUS_ENQUIRY_t) ,nt); + + status_enquiry=(STATUS_ENQUIRY_t*)((msg->data+HEADER_LEN)); -#ifdef DEBUG - printf("Building STATUS_ENQUIRY Msg\n"); +#ifdef DEBUG + printf("Building STATUS_ENQUIRY Msg\n"); #endif - return msg; + return msg; } -static void parse_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; INFORMATION_t *information=(INFORMATION_t*)((unsigned long)(msg->data+HEADER_LEN)); @@ -1071,19 +1071,19 @@ static void parse_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_ strcpy(bc->info_dad, number); strcpy(bc->keypad,keypad); } -#ifdef DEBUG - printf("Parsing INFORMATION Msg\n"); +#ifdef DEBUG + printf("Parsing INFORMATION Msg\n"); #endif } -static msg_t *build_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; INFORMATION_t *information; - msg_t *msg =(msg_t*)create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, bc?bc->l3_id:-1, sizeof(INFORMATION_t) ,nt); - - information=(INFORMATION_t*)((msg->data+HEADER_LEN)); - + msg_t *msg =(msg_t*)create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, bc?bc->l3_id:-1, sizeof(INFORMATION_t) ,nt); + + information=(INFORMATION_t*)((msg->data+HEADER_LEN)); + { enc_ie_called_pn(&information->CALLED_PN, msg, 0, 1, bc->info_dad, nt,bc); } @@ -1094,62 +1094,62 @@ static msg_t *build_information (struct isdn_msg msgs[], struct misdn_bchannel * enc_ie_display(&information->DISPLAY, msg, bc->display, nt,bc); } } - -#ifdef DEBUG - printf("Building INFORMATION Msg\n"); + +#ifdef DEBUG + printf("Building INFORMATION Msg\n"); #endif - return msg; + return msg; } -static void parse_status (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_status (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; STATUS_t *status=(STATUS_t*)((unsigned long)(msg->data+HEADER_LEN)); int location; int cause; - + dec_ie_cause(status->CAUSE, (Q931_info_t *)(status), &location, &cause, nt,bc); if (cause>0) bc->cause=cause; ; -#ifdef DEBUG - printf("Parsing STATUS Msg\n"); +#ifdef DEBUG + printf("Parsing STATUS Msg\n"); #endif } -static msg_t *build_status (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_status (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; STATUS_t *status; - msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS, bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt); - - status=(STATUS_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS, bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt); -#ifdef DEBUG - printf("Building STATUS Msg\n"); + status=(STATUS_t*)((msg->data+HEADER_LEN)); + +#ifdef DEBUG + printf("Building STATUS Msg\n"); #endif - return msg; + return msg; } -static void parse_timeout (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) +static void parse_timeout (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { -#ifdef DEBUG - printf("Parsing STATUS Msg\n"); -#endif +#ifdef DEBUG + printf("Parsing STATUS Msg\n"); +#endif } -static msg_t *build_timeout (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) +static msg_t *build_timeout (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; STATUS_t *status; - msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS, bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt); - - status=(STATUS_t*)((msg->data+HEADER_LEN)); + msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS, bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt); -#ifdef DEBUG - printf("Building STATUS Msg\n"); + status=(STATUS_t*)((msg->data+HEADER_LEN)); + +#ifdef DEBUG + printf("Building STATUS Msg\n"); #endif - return msg; + return msg; } @@ -1263,15 +1263,15 @@ int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt) if (nt){ mISDNuser_head_t *hh = (mISDNuser_head_t*)msg->data; - + for (i=0; i< msgs_max -1; i++) { if ( (hh->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i; } - + } else { iframe_t *frm = (iframe_t*)msg->data; - - for (i=0; i< msgs_max -1; i++) + + for (i=0; i< msgs_max -1; i++) if ( (frm->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i; } @@ -1281,11 +1281,11 @@ int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt) int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt) { int i; - for (i=0; i< msgs_max; i++) + for (i=0; i< msgs_max; i++) if ( event == msgs[i].event) return i; cb_log(10,0, "get_index: event not found!\n"); - + return -1; } @@ -1318,9 +1318,9 @@ char EVENT_BCHAN_ERROR_INFO[] = "BCHAN_ERROR"; char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt) { int i=isdn_msg_get_index_by_event(msgs, event, nt); - + if(i>=0) return msgs[i].info; - + if (event == EVENT_CLEANUP) return EVENT_CLEAN_INFO; if (event == EVENT_DTMF_TONE) return EVENT_DTMF_TONE_INFO; if (event == EVENT_NEW_L3ID) return EVENT_NEW_L3ID_INFO; @@ -1331,7 +1331,7 @@ char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt) if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO; if (event == EVENT_PORT_ALARM) return EVENT_PORT_ALARM_INFO; if (event == EVENT_BCHAN_ERROR) return EVENT_BCHAN_ERROR_INFO; - + return NULL; } @@ -1348,6 +1348,6 @@ msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, { int i=isdn_msg_get_index_by_event(msgs, event, nt); if(i<0) return NULL; - + return msgs[i].msg_builder(msgs, bc, nt); } diff --git a/channels/misdn/portinfo.c b/channels/misdn/portinfo.c index 6d5f2154d6..9e9cce86be 100644 --- a/channels/misdn/portinfo.c +++ b/channels/misdn/portinfo.c @@ -1,4 +1,4 @@ -/*! \file +/*! \file * \brief Interface to mISDN - port info * \author Christian Richter */ diff --git a/channels/misdn_config.c b/channels/misdn_config.c index 0a7109276c..6e2bfe02c9 100644 --- a/channels/misdn_config.c +++ b/channels/misdn_config.c @@ -1,6 +1,6 @@ /* * Asterisk -- An open source telephony toolkit. - * + * * Copyright (C) 2005, Christian Richter * * Christian Richter @@ -364,8 +364,8 @@ static const struct misdn_cfg_spec gen_spec[] = { { "crypt_keys", MISDN_GEN_CRYPT_KEYS, MISDN_CTYPE_STR, NO_DEFAULT, NONE, "Keys for cryption, you reference them in the dialplan\n" "\tLater also in dynamic encr." }, - { "ntkeepcalls", MISDN_GEN_NTKEEPCALLS, MISDN_CTYPE_BOOL, "no", NONE, - "avoid dropping calls if the L2 goes down. some Nortel pbx\n" + { "ntkeepcalls", MISDN_GEN_NTKEEPCALLS, MISDN_CTYPE_BOOL, "no", NONE, + "avoid dropping calls if the L2 goes down. some Nortel pbx\n" "do put down the L2/L1 for some milliseconds even if there\n" "are running calls. with this option you can avoid dropping them" }, { "ntdebugflags", MISDN_GEN_NTDEBUGFLAGS, MISDN_CTYPE_INT, "0", NONE, @@ -386,7 +386,7 @@ static int *ptp; /* maps enum config elements to array positions */ static int *map; -static ast_mutex_t config_mutex; +static ast_mutex_t config_mutex; #define CLI_ERROR(name, value, section) ({ \ ast_log(LOG_WARNING, "misdn.conf: \"%s=%s\" (section: %s) invalid or out of range. " \ @@ -475,7 +475,7 @@ static void _free_port_cfg (void) int i, j; int gn = map[MISDN_CFG_GROUPNAME]; union misdn_cfg_pt* free_list[max_ports + 2]; - + memset(free_list, 0, sizeof(free_list)); free_list[0] = port_cfg[0]; for (i = 1; i <= max_ports; ++i) { @@ -507,7 +507,7 @@ static void _free_general_cfg (void) { int i; - for (i = 0; i < NUM_GEN_ELEMENTS; i++) + for (i = 0; i < NUM_GEN_ELEMENTS; i++) if (general_cfg[i].any) ast_free(general_cfg[i].any); } @@ -579,11 +579,11 @@ enum misdn_cfg_elements misdn_cfg_get_elem(char *name) pos = get_cfg_position(name, PORT_CFG); if (pos >= 0) return port_spec[pos].elem; - + pos = get_cfg_position(name, GEN_CFG); if (pos >= 0) return gen_spec[pos].elem; - + return MISDN_CFG_FIRST; } @@ -597,7 +597,7 @@ void misdn_cfg_get_name(enum misdn_cfg_elements elem, void *buf, int bufsize) memset(buf, 0, 1); return; } - + /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ if (elem == MISDN_CFG_GROUPNAME) { if (!snprintf(buf, bufsize, "ports")) @@ -630,7 +630,7 @@ void misdn_cfg_get_desc (enum misdn_cfg_elements elem, void *buf, int bufsize, v spec = (struct misdn_cfg_spec *)port_spec; else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) spec = (struct misdn_cfg_spec *)gen_spec; - + if (!spec || !spec[place].desc) memset(buf, 0, 1); else { @@ -659,7 +659,7 @@ int misdn_cfg_is_msn_valid (int port, char* msn) iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; else iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; - for (; iter; iter = iter->next) + for (; iter; iter = iter->next) if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { re = 1; break; @@ -688,7 +688,7 @@ int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth) for (i = 1; i <= max_ports; i++) { if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) - method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? + method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); } } @@ -708,7 +708,7 @@ int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth) return re; } -/*! +/*! * \brief Generate a comma separated list of all active ports */ void misdn_cfg_get_ports_string (char *ports) @@ -776,10 +776,10 @@ void misdn_cfg_get_config_string (int port, enum misdn_cfg_elements elem, char* break; case MISDN_CTYPE_ASTGROUP: if (port_cfg[port][place].grp) - snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, + snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); else if (port_cfg[0][place].grp) - snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, + snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); else snprintf(buf, bufsize, " -> %s:", port_spec[place].name); @@ -844,7 +844,7 @@ int misdn_cfg_get_next_port (int port) { int p = -1; int gn = map[MISDN_CFG_GROUPNAME]; - + misdn_cfg_lock(); for (port++; port <= max_ports; port++) { if (port_cfg[port][gn].str) { @@ -936,7 +936,7 @@ static void _build_general_config (struct ast_variable *v) for (; v; v = v->next) { if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) continue; - if (((pos = get_cfg_position(v->name, GEN_CFG)) < 0) || + if (((pos = get_cfg_position(v->name, GEN_CFG)) < 0) || (_parse(&general_cfg[pos], v->value, gen_spec[pos].type, gen_spec[pos].boolint_def) < 0)) CLI_ERROR(v->name, v->value, "general"); } @@ -958,7 +958,7 @@ static void _build_port_config (struct ast_variable *v, char *cat) cfg_for_ports[0] = 1; } - if (((pos = get_cfg_position("name", PORT_CFG)) < 0) || + if (((pos = get_cfg_position("name", PORT_CFG)) < 0) || (_parse(&cfg_tmp[pos], cat, port_spec[pos].type, port_spec[pos].boolint_def) < 0)) { CLI_ERROR(v->name, v->value, cat); return; @@ -969,7 +969,7 @@ static void _build_port_config (struct ast_variable *v, char *cat) char *token, *tmp = ast_strdupa(v->value); char ptpbuf[BUFFERSIZE] = ""; int start, end; - for (token = strsep(&tmp, ","); token; token = strsep(&tmp, ","), *ptpbuf = 0) { + for (token = strsep(&tmp, ","); token; token = strsep(&tmp, ","), *ptpbuf = 0) { if (!*token) continue; if (sscanf(token, "%d-%d%s", &start, &end, ptpbuf) >= 2) { @@ -992,7 +992,7 @@ static void _build_port_config (struct ast_variable *v, char *cat) } } } else { - if (((pos = get_cfg_position(v->name, PORT_CFG)) < 0) || + if (((pos = get_cfg_position(v->name, PORT_CFG)) < 0) || (_parse(&cfg_tmp[pos], v->value, port_spec[pos].type, port_spec[pos].boolint_def) < 0)) CLI_ERROR(v->name, v->value, cat); }