fixed bchannel create
[lcr.git] / chan_lcr.c
index 25043ed..ab5886c 100644 (file)
@@ -342,6 +342,9 @@ void apply_opt(struct chan_call *call, char *data)
        char string[1024], *p = string, *opt, *key;
        int gain, i, newmode = 0;
 
+       if (!data[0])
+               return; // no opts
+
        strncpy(string, data, sizeof(string)-1);
        string[sizeof(string)-1] = '\0';
 
@@ -958,7 +961,7 @@ static void lcr_in_information(struct chan_call *call, int message_type, union p
        if (!call->pbx_started)
        {
                CDEBUG(call, call->ast, "Asterisk not started, adding digits to number.\n");
-               strncpy(ast->exten, param->information.id, AST_MAX_EXTENSION-1);
+               strncat(ast->exten, param->information.id, AST_MAX_EXTENSION-1);
                lcr_start_pbx(call, ast, param->information.sending_complete);
                return;
        }
@@ -1111,9 +1114,10 @@ int receive_message(int message_type, unsigned int ref, union parameter *param)
                                        CDEBUG(call, call->ast, "Join bchannel, because call is already bridged.\n");
                                        bchannel_join(bchannel, call->bridge_id);
                                }
+                               /* create only, if call exists, othewhise it bchannel is freed below... */
+                               if (bchannel_create(bchannel, ((call->transparent)?1:0) + ((call->hdlc)?2:0)))
+                                       bchannel_activate(bchannel, 1);
                        }
-                       if (bchannel_create(bchannel, ((call->transparent)?1:0) + ((call->hdlc)?2:0)))
-                               bchannel_activate(bchannel, 1);
                        /* acknowledge */
                        newparam.bchannel.type = BCHANNEL_ASSIGN_ACK;
                        newparam.bchannel.handle = param->bchannel.handle;
@@ -1670,7 +1674,13 @@ static int lcr_call(struct ast_channel *ast, char *dest, int timeout)
        return 0; 
 }
 
-static int lcr_digit(struct ast_channel *ast, char digit)
+static int lcr_digit_begin(struct ast_channel *ast, char digit)
+{
+       printf("DIGT BEGIN %c\n", digit);
+       return (0);
+}
+
+static int lcr_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
         struct chan_call *call;
        union parameter newparam;
@@ -2132,7 +2142,8 @@ static struct ast_channel_tech lcr_tech = {
        .type="LCR",
        .description="Channel driver for connecting to Linux-Call-Router",
        .requester=lcr_request,
-       .send_digit_begin=lcr_digit,
+       .send_digit_begin=lcr_digit_begin,
+       .send_digit_end=lcr_digit_end,
        .call=lcr_call,
        .bridge=lcr_bridge, 
        .hangup=lcr_hangup,