Merged revisions 374515-374535 from
authorRichard Mudgett <rmudgett@digium.com>
Fri, 5 Oct 2012 18:42:14 +0000 (18:42 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 5 Oct 2012 18:42:14 +0000 (18:42 +0000)
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier

................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines

  chan_misdn: Remove some deadcode

  * Made setup_bc() static.

  Patches:
patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
Modified

  JIRA ABE-2882

................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines

  chan_misdn: Remove unused bchan states

  Patches:
patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines

  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt

  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).

  * Value of stack->nt is known in advance at some places.

  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().

  Patches:
patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
Modified

  JIRA ABE-2882

................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines

  chan_misdn: Fix spelling in log messages

  Patches:
patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines

  chan_misdn: Don't cleanup a bc twice.

  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.

  * Moved log message in front of the resulting actions and fixed it to
  match the case.

  Patches:
patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines

  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.

  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.

  * Move cl_queue_chan() call after bearer check.

  Patches:
patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines

  chan_misdn: We must initialize cause on sending a DISCONNECT.

  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.

  Patches:
patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines

  chan_misdn: Remove unused code for upqueue

  Patches:
patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines

  chan_misdn: Improve debugging (port number, messages fixed, dups removed)

  Patches:
patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter

  JIRA ABE-2882

................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines

  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.

  Patches:
patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
Modified.

  JIRA ABE-2882

................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines

  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.

  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."

  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.

  Patches:
abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
Modified.

  JIRA ABE-2881

................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines

  chan_misdn: Remove some more deadcode.

................
........

Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_misdn.c
channels/misdn/isdn_lib.c
channels/misdn/isdn_lib.h
channels/misdn/isdn_msg_parser.c

index 5a36e93..2f93d09 100644 (file)
@@ -4189,7 +4189,7 @@ static void print_bc_info(int fd, struct chan_list *help, struct misdn_bchannel
 #endif
                        "  --> notone : rx %d tx:%d\n"
                        "  --> bc_hold: %d\n",
-                       ast_channel_name(help->ast),
+                       ast ? ast_channel_name(ast) : "",
                        help->l3id,
                        help->addr,
                        bc->addr,
@@ -4245,7 +4245,6 @@ static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, st
                                continue;
                        }
                        ast_cli(a->fd, "bc with pid:%d has no Ast Leg\n", bc->pid);
-                       continue;
                }
 
                if (misdn_debug[0] > 2) {
@@ -6965,7 +6964,7 @@ static int misdn_indication(struct ast_channel *ast, int cond, const void *data,
                return -1;
        }
 
-       chan_misdn_log(5, p->bc->port, "* IND : Indication [%d] on %s\n\n", cond, ast_channel_name(ast));
+       chan_misdn_log(5, p->bc->port, "* IND : Indication [%d] on %s\n", cond, ast_channel_name(ast));
 
        switch (cond) {
        case AST_CONTROL_BUSY:
@@ -8181,7 +8180,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
 
        tmp = ast_channel_alloc(1, state, cid_num, cid_name, "", exten, "", linkedid, 0, "%s/%s%d-u%d", misdn_type, c ? "" : "tmp", chan_offset + c, glob_channel++);
        if (tmp) {
-               chan_misdn_log(2, 0, " --> * NEW CHANNEL dialed:%s caller:%s\n", exten, callerid);
+               chan_misdn_log(2, port, " --> * NEW CHANNEL dialed:%s caller:%s\n", exten, callerid);
 
                ast_best_codec(cap, &tmpfmt);
                ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
@@ -8419,14 +8418,13 @@ static int pbx_start_chan(struct chan_list *ch)
 
 static void hangup_chan(struct chan_list *ch, struct misdn_bchannel *bc)
 {
-       int port;
+       int port = bc->port;
 
        if (!ch) {
-               cb_log(1, 0, "Cannot hangup chan, no ch\n");
+               cb_log(1, port, "Cannot hangup chan, no ch\n");
                return;
        }
 
-       port = bc->port;
        cb_log(5, port, "hangup_chan called\n");
 
        if (ch->need_hangup) {
@@ -10203,7 +10201,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                ch = chan_list_init(ORG_MISDN);
                if (!ch) {
                        chan_misdn_log(-1, bc->port, "cb_events: malloc for chan_list failed!\n");
-                       return 0;
+                       return RESPONSE_RELEASE_SETUP;
                }
 
                ch->bc = bc;
@@ -10222,9 +10220,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                }
                if (!chan) {
                        chan_list_unref(ch, "Failed to create a new channel");
-                       misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
-                       ast_log(LOG_ERROR, "cb_events: misdn_new failed !\n");
-                       return 0;
+                       ast_log(LOG_ERROR, "cb_events: misdn_new failed!\n");
+                       return RESPONSE_RELEASE_SETUP;
                }
 
                if ((exceed = add_in_calls(bc->port))) {
@@ -10283,9 +10280,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        break;
                }
 
-               /** queue new chan **/
-               cl_queue_chan(ch);
-
                if (!strstr(ch->allowed_bearers, "all")) {
                        int i;
 
@@ -10305,15 +10299,17 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                                /* We did not find the bearer capability */
                                chan_misdn_log(0, bc->port, "Bearer capability not allowed: %s(%d)\n",
                                        bearer2str(bc->capability), bc->capability);
-                               bc->out_cause = AST_CAUSE_INCOMPATIBLE_DESTINATION;
 
                                ch->state = MISDN_EXTCANTMATCH;
-                               misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
                                chan_list_unref(ch, "BC not allowed, releasing call");
-                               return RESPONSE_OK;
+                               bc->out_cause = AST_CAUSE_INCOMPATIBLE_DESTINATION;
+                               return RESPONSE_RELEASE_SETUP;
                        }
                }
 
+               /** queue new chan **/
+               cl_queue_chan(ch);
+
                if (bc->fac_in.Function != Fac_None) {
                        misdn_facility_ie_handler(event, bc, ch);
                }
@@ -12759,7 +12755,7 @@ static void chan_misdn_log(int level, int port, char *tmpl, ...)
        char port_buf[8];
 
        if (!(0 <= port && port <= max_ports)) {
-               ast_log(LOG_WARNING, "cb_log called with out-of-range port number! (%d)\n", port);
+               ast_log(LOG_WARNING, "chan_misdn_log called with out-of-range port number! (%d)\n", port);
                port = 0;
                level = -1;
        } else if (!(level == -1
index b599718..73e5309 100644 (file)
@@ -46,8 +46,6 @@ int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
 void misdn_join_conf(struct misdn_bchannel *bc, int conf_id);
 void misdn_split_conf(struct misdn_bchannel *bc, int conf_id);
 
-int queue_cleanup_bc(struct misdn_bchannel *bc) ;
-
 int misdn_lib_get_l2_up(struct misdn_stack *stack);
 
 struct misdn_stack *get_misdn_stack(void);
@@ -214,14 +212,12 @@ static enum global_states  global_state=MISDN_INITIALIZING;
 struct misdn_lib {
        /*! \brief mISDN device handle returned by mISDN_open() */
        int midev;
-       int midev_nt;   /* Not used */
 
        pthread_t event_thread;
        pthread_t event_handler_thread;
 
        void *user_data;
 
-       msg_queue_t upqueue;
        msg_queue_t activatequeue;
 
        sem_t new_msg;
@@ -240,8 +236,6 @@ void misdn_tx_jitter(struct misdn_bchannel *bc, int len);
 
 struct misdn_bchannel *find_bc_by_l3id(struct misdn_stack *stack, unsigned long l3id);
 
-int setup_bc(struct misdn_bchannel *bc);
-
 int manager_isdn_handler(iframe_t *frm ,msg_t *msg);
 
 int misdn_lib_port_restart(int port);
@@ -629,16 +623,9 @@ char *bc_state2str(enum bchannel_state state) {
        } states[] = {
                {"BCHAN_CLEANED", BCHAN_CLEANED },
                {"BCHAN_EMPTY", BCHAN_EMPTY},
-               {"BCHAN_SETUP", BCHAN_SETUP},
-               {"BCHAN_SETUPED", BCHAN_SETUPED},
-               {"BCHAN_ACTIVE", BCHAN_ACTIVE},
                {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
-               {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
                {"BCHAN_BRIDGED", BCHAN_BRIDGED},
                {"BCHAN_RELEASE", BCHAN_RELEASE},
-               {"BCHAN_RELEASED", BCHAN_RELEASED},
-               {"BCHAN_CLEAN", BCHAN_CLEAN},
-               {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
                {"BCHAN_ERROR", BCHAN_ERROR}
        };
 
@@ -833,9 +820,8 @@ static int clean_up_bc(struct misdn_bchannel *bc)
        unsigned char buff[32];
        struct misdn_stack * stack;
 
-       cb_log(3, bc?bc->port:0, "$$$ CLEANUP CALLED pid:%d\n", bc?bc->pid:-1);
+       cb_log(3, bc->port, "$$$ CLEANUP CALLED pid:%d\n", bc->pid);
 
-       if (!bc  ) return -1;
        stack=get_stack_by_bc(bc);
 
        if (!stack) return -1;
@@ -1065,14 +1051,7 @@ static int create_process(int midev, struct misdn_bchannel *bc)
 }
 
 
-void misdn_lib_setup_bc(struct misdn_bchannel *bc)
-{
-       clean_up_bc(bc);
-       setup_bc(bc);
-}
-
-
-int setup_bc(struct misdn_bchannel *bc)
+static int setup_bc(struct misdn_bchannel *bc)
 {
        unsigned char buff[1025];
        int midev;
@@ -1259,9 +1238,9 @@ static int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int mid
        pthread_mutex_init(&bc->send_lock->lock, NULL);
 
        empty_bc(bc);
-       bc_state_change(bc, BCHAN_CLEANED);
 
        bc->port=stack->port;
+       bc_state_change(bc, BCHAN_CLEANED);
        bc->nt=stack->nt?1:0;
        bc->pri=stack->pri;
 
@@ -1333,7 +1312,6 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp)
        stack->pri=0;
 
        msg_queue_init(&stack->downqueue);
-       msg_queue_init(&stack->upqueue);
 
        pthread_mutex_init(&stack->st_lock, NULL);
 
@@ -1354,11 +1332,11 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp)
 
        switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK) {
        case ISDN_PID_L0_TE_S0:
+               cb_log(8, port, "TE Stack\n");
                stack->nt=0;
                break;
        case ISDN_PID_L0_NT_S0:
                cb_log(8, port, "NT Stack\n");
-
                stack->nt=1;
                break;
        case ISDN_PID_L0_TE_E1:
@@ -1367,10 +1345,9 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp)
                stack->pri=1;
                break;
        case ISDN_PID_L0_NT_E1:
-               cb_log(8, port, "TE S2M Stack\n");
+               cb_log(8, port, "NT 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]);
@@ -1389,8 +1366,6 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp)
                int ret;
                int nt=stack->nt;
 
-               cb_log(8, port, "Init. Stack.\n");
-
                memset(&li, 0, sizeof(li));
                {
                        int l = sizeof(li.name);
@@ -1431,9 +1406,6 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp)
                        return(NULL);
                }
 
-               cb_log(8, port, "NT Stacks upper_id %x\n",stack->upper_id);
-
-
                /* create nst (nt-mode only) */
                if (nt) {
 
@@ -1483,7 +1455,7 @@ static struct misdn_stack *stack_init(int midev, int port, int ptp)
 
        }
 
-       cb_log(8,0,"stack_init: port:%d lowerId:%x  upperId:%x\n",stack->port,stack->lower_id, stack->upper_id);
+       cb_log(8, port, "stack_init: lowerId:%x upperId:%x\n", stack->lower_id, stack->upper_id);
 
        return stack;
 }
@@ -1650,14 +1622,11 @@ 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)
+static int handle_event_te(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) {
-
+       switch (event) {
                case EVENT_CONNECT_ACKNOWLEDGE:
                        setup_bc(bc);
 
@@ -1734,7 +1703,9 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_
                                return -1;
                        }
 
-                       setup_bc(bc);
+                       if (event != EVENT_SETUP) {
+                               setup_bc(bc);
+                       }
                        break;
                }
 
@@ -1743,9 +1714,6 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_
                        break;
                default:
                        break;
-               }
-       } else {    /** NT MODE **/
-
        }
        return 0;
 }
@@ -2194,10 +2162,6 @@ static int handle_event_nt(void *dat, void *arg)
                        if (stack->l2upcnt>3) {
                                cb_log(0 , stack->port, "!!! Could not Get the L2 up after 3 Attempts!!!\n");
                        } else {
-#if 0
-                               if (stack->nt)
-                                       misdn_lib_reinit_nt_stack(stack->port);
-#endif
                                if (stack->l1link) {
                                        misdn_lib_get_l2_up(stack);
                                        stack->l2upcnt++;
@@ -2490,43 +2454,6 @@ static int handle_bchan(msg_t *msg)
        case MGR_SETSTACK| INDICATION:
                cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|IND pid:%d\n",bc->pid);
        break;
-#if 0
-       AGAIN:
-               bc->addr = mISDN_get_layerid(stack->midev, bc->b_stid, bc->layer);
-               if (!bc->addr) {
-
-                       if (errno == EAGAIN) {
-                               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;
-               } else if ( bc->addr < 0) {
-                       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);
-               break;
-
-               case BCHAN_CLEAN_REQUEST:
-               default:
-                       cb_log(0, stack->port," --> STATE WASN'T SETUP (but %s) in SETSTACK|IND pid:%d\n",bc_state2str(bc->bc_state), bc->pid);
-                       clean_up_bc(bc);
-               }
-               return 1;
-#endif
 
        case MGR_DELLAYER| INDICATION:
                cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|IND pid:%d\n",bc->pid);
@@ -2766,7 +2693,7 @@ static int handle_frm_nt(msg_t *msg)
 }
 
 
-static int handle_frm(msg_t *msg)
+static int handle_frm_te(msg_t *msg)
 {
        struct misdn_bchannel dummybc;
        struct misdn_bchannel *bc;
@@ -2785,11 +2712,11 @@ static int handle_frm(msg_t *msg)
                return 0;
        }
 
-       cb_log(4, stack ? stack->port : 0, "handle_frm: frm->addr:%x frm->prim:%x\n", frm->addr, frm->prim);
+       cb_log(4, stack->port, "handle_frm_te: frm->addr:%x frm->prim:%x\n", frm->addr, frm->prim);
 
        ret = handle_cr(stack, frm);
        if (ret < 0) {
-               cb_log(3, stack ? stack->port : 0, "handle_frm: handle_cr <0 prim:%x addr:%x\n", frm->prim, frm->addr);
+               cb_log(3, stack->port, "handle_frm_te: handle_cr <0 prim:%x addr:%x\n", frm->prim, frm->addr);
        }
        if (ret) {
                free_msg(msg);
@@ -2828,7 +2755,7 @@ static int handle_frm(msg_t *msg)
        isdn_msg_parse_event(msgs_g, msg, bc, 0);
 
        /* Preprocess some Events */
-       ret = handle_event(bc, event, frm);
+       ret = handle_event_te(bc, event, frm);
        if (ret < 0) {
                cb_log(0, stack->port, "couldn't handle event\n");
                free_msg(msg);
@@ -2852,24 +2779,21 @@ static int handle_frm(msg_t *msg)
                        cb_log(0, stack->port, "TOTALLY IGNORING SETUP\n");
                        break;
                case RESPONSE_IGNORE_SETUP:
+                       cb_log(0, stack->port, "GOT IGNORE SETUP\n");
                        /* I think we should send CC_RELEASE_CR, but am not sure*/
                        bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
                        /* fall through */
                case RESPONSE_RELEASE_SETUP:
-                       misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
-                       if (bc->channel > 0) {
-                               empty_chan_in_stack(stack, bc->channel);
+                       if (response == RESPONSE_RELEASE_SETUP) {
+                               cb_log(0, stack->port, "GOT RELEASE SETUP\n");
                        }
-                       empty_bc(bc);
-                       bc_state_change(bc, BCHAN_CLEANED);
-                       bc->in_use = 0;
-
-                       cb_log(0, stack->port, "GOT IGNORE SETUP\n");
+                       misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
                        break;
                case RESPONSE_OK:
                        cb_log(4, stack->port, "GOT SETUP OK\n");
                        break;
                default:
+                       cb_log(0, stack->port, "GOT UNKNOWN SETUP RESPONSE\n");
                        break;
                }
                break;
@@ -3301,12 +3225,6 @@ static void prepare_bc(struct misdn_bchannel*bc, int channel)
        if (++mypid>5000) mypid=1;
        bc->pid=mypid;
 
-#if 0
-       bc->addr=0;
-       bc->b_stid=0;
-       bc->layer_id=0;
-#endif
-
        bc->in_use = 1;
 }
 
@@ -3691,8 +3609,13 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
        case EVENT_PROCEEDING:
        case EVENT_SETUP_ACKNOWLEDGE:
        case EVENT_CONNECT:
-               if (!stack->nt)
+               if (!stack->nt) {
+                       if (stack->ptp) {
+                               setup_bc(bc);
+                       }
                        break;
+               }
+               /* fall through */
 
        case EVENT_RETRIEVE_ACKNOWLEDGE:
                if (stack->nt) {
@@ -3788,6 +3711,11 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
                        cb_log(0, bc->port, " --> we have already sent DISCONNECT\n");
                        RETURN(-1,OUT);
                }
+               /* IE cause is mandatory for DISCONNECT, but optional for the answers to DISCONNECT.
+                * We must initialize cause, so it is later correctly indicated to ast_channel
+                * in case the answer does not include one!
+                */
+               bc->cause = bc->out_cause;
 
                bc->need_disconnect=0;
                break;
@@ -3962,24 +3890,6 @@ static int handle_err(msg_t *msg)
        return 0;
 }
 
-#if 0
-static int queue_l2l3(msg_t *msg)
-{
-       iframe_t *frm= (iframe_t*)msg->data;
-       struct misdn_stack *stack;
-       stack=find_stack_by_addr( frm->addr );
-
-
-       if (!stack) {
-               return 0;
-       }
-
-       msg_queue_tail(&stack->upqueue, msg);
-       sem_post(&glob_mgr->new_msg);
-       return 1;
-}
-#endif
-
 int manager_isdn_handler(iframe_t *frm ,msg_t *msg)
 {
 
@@ -4004,7 +3914,7 @@ int manager_isdn_handler(iframe_t *frm ,msg_t *msg)
        }
 
 #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);
+       syslog(LOG_NOTICE,"mISDN recv: ADDR:%x PRIM:%x DINFO:%x\n", frm->addr, frm->prim, frm->dinfo);
 #endif
 
        if (handle_timers(msg))
@@ -4025,7 +3935,7 @@ int manager_isdn_handler(iframe_t *frm ,msg_t *msg)
                return 0;
        }
 
-       if (handle_frm(msg)) {
+       if (handle_frm_te(msg)) {
                return 0;
        }
 
@@ -4072,32 +3982,6 @@ int misdn_lib_get_port_info(int port)
        return 0;
 }
 
-
-int queue_cleanup_bc(struct misdn_bchannel *bc)
-{
-       msg_t *msg=alloc_msg(MAX_MSG_SIZE);
-       iframe_t *frm;
-       if (!msg) {
-               cb_log(0, bc->port, "queue_cleanup_bc: alloc_msg failed!\n");
-               return -1;
-       }
-       frm=(iframe_t*)msg->data;
-
-       /* activate bchannel */
-       frm->prim = MGR_CLEARSTACK| REQUEST;
-
-       frm->addr = bc->l3_id;
-
-       frm->dinfo = bc->port;
-       frm->len = 0;
-
-       msg_queue_tail(&glob_mgr->activatequeue, msg);
-       sem_post(&glob_mgr->new_msg);
-
-       return 0;
-
-}
-
 int misdn_lib_pid_restart(int pid)
 {
        struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);
@@ -4210,28 +4094,6 @@ static void manager_event_handler(void *arg)
                        iframe_t *frm =  (iframe_t*) msg->data ;
 
                        switch ( frm->prim) {
-
-                       case MGR_CLEARSTACK | REQUEST:
-                               /*a queued bchannel cleanup*/
-                               {
-                                       struct misdn_stack *stack=find_stack_by_port(frm->dinfo);
-                                       struct misdn_bchannel *bc;
-                                       if (!stack) {
-                                               cb_log(0,0,"no stack found with port [%d]!! so we cannot cleanup the bc\n",frm->dinfo);
-                                               free_msg(msg);
-                                               break;
-                                       }
-
-                                       bc = find_bc_by_l3id(stack, frm->addr);
-                                       if (bc) {
-                                               cb_log(1,bc->port,"CLEARSTACK queued, cleaning up\n");
-                                               clean_up_bc(bc);
-                                       } else {
-                                               cb_log(0,stack->port,"bc could not be cleaned correctly !! addr [%x]\n",frm->addr);
-                                       }
-                               }
-                               free_msg(msg);
-                               break;
                        case MGR_SETSTACK | REQUEST :
                                free_msg(msg);
                                break;
@@ -4244,18 +4106,6 @@ static void manager_event_handler(void *arg)
                for (stack=glob_mgr->stack_list;
                     stack;
                     stack=stack->next ) {
-
-                       while ( (msg=msg_dequeue(&stack->upqueue)) ) {
-                               /** Handle L2/3 Signalling after bchans **/
-                               if (!handle_frm_nt(msg)) {
-                                       /* Maybe it's TE */
-                                       if (!handle_frm(msg)) {
-                                               /* wow none! */
-                                               cb_log(0,stack->port,"Wow we've got a strange issue while dequeueing a Frame\n");
-                                       }
-                               }
-                       }
-
                        /* Here we should check if we really want to
                                send all the messages we've queued, lets
                                assume we've queued a Disconnect, but
@@ -4720,9 +4570,7 @@ 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;
+       cb_log(4, stack->port, "*HOLDER: find %lx\n",l3id);
 
        for (help=stack->holding;
             help;
index a044760..3ef1376 100644 (file)
@@ -78,16 +78,9 @@ enum tone_e {
 enum bchannel_state {
        BCHAN_CLEANED=0,
        BCHAN_EMPTY,
-       BCHAN_SETUP,
-       BCHAN_SETUPED,
-       BCHAN_ACTIVE,
        BCHAN_ACTIVATED,
-       BCHAN_BRIDGE,
        BCHAN_BRIDGED,
        BCHAN_RELEASE,
-       BCHAN_RELEASED,
-       BCHAN_CLEAN,
-       BCHAN_CLEAN_REQUEST,
        BCHAN_ERROR
 };
 
@@ -814,8 +807,6 @@ void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
 void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
 
 
-void misdn_lib_setup_bc(struct misdn_bchannel *bc);
-
 void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
 void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
 
index 1febfa0..7f087c4 100644 (file)
@@ -484,9 +484,9 @@ static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchann
        {
                int  protocol ;
                dec_ie_useruser(setup->USER_USER, (Q931_info_t *)setup, &protocol, bc->uu, &bc->uulen, nt,bc);
-               if (bc->uulen) cb_log(1,bc->port,"USERUESRINFO:%s\n",bc->uu);
+               if (bc->uulen) cb_log(1, bc->port, "USERUSERINFO:%s\n", bc->uu);
                else
-               cb_log(1,bc->port,"NO USERUESRINFO\n");
+               cb_log(1, bc->port, "NO USERUSERINFO\n");
        }
 
        dec_ie_progress(setup->PROGRESS, (Q931_info_t *)setup, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
@@ -618,7 +618,7 @@ static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, in
        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);
+               cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu);
        }
 
 #if defined(AST_MISDN_ENHANCEMENTS)
@@ -1087,7 +1087,7 @@ static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *b
        if (bc->uulen) {
                int  protocol=4;
                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);
+               cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu);
        }
 
 #ifdef DEBUG
@@ -1175,7 +1175,7 @@ static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc,
        if (bc->uulen) {
                int  protocol=4;
                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);
+               cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu);
        }
 
 #ifdef DEBUG
@@ -1237,7 +1237,7 @@ static msg_t *build_release_complete (struct isdn_msg msgs[], struct misdn_bchan
        if (bc->uulen) {
                int  protocol=4;
                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);
+               cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu);
        }
 
 #ifdef DEBUG