[chan_lcr] Fixed broken communication with chan_lcr
authorAndreas Eversberg <jolly@eversberg.eu>
Sun, 20 Feb 2011 09:23:03 +0000 (10:23 +0100)
committerAndreas Eversberg <jolly@eversberg.eu>
Sun, 20 Feb 2011 09:23:03 +0000 (10:23 +0100)
There are two modes:

The remote mode is used to route a call directly to Asterisk or route a
call from Asterisk to an ISDN interface. (the old way)

The interface mode is used to handle chan_lcr as an interface, so calls
from Asterisk can be routed and behave like they come from an ISDN
interface. (documentation for that will follow)

chan_lcr.c
socket_server.c

index 2740a32..13aa680 100644 (file)
@@ -1522,8 +1522,7 @@ int receive_message(int message_type, unsigned int ref, union parameter *param)
                        call = find_call_ref(0);
                        if (!call) {
                                /* send release, if ref does not exist */
-                               CDEBUG(NULL, NULL, "No call found, that requests a ref.\n");
-                               send_release_and_import(call, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL);
+                               CERROR(NULL, NULL, "No call found, that requests a ref.\n");
                                return 0;
                        }
                        /* store new ref */
index 9922dc6..1420268 100644 (file)
@@ -19,7 +19,6 @@
 char socket_name[128];
 int sock = -1;
 struct sockaddr_un sock_address;
-extern unsigned int new_remote;
 
 struct admin_list *admin_first = NULL;
 static struct lcr_fd admin_fd;
@@ -664,15 +663,18 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin)
                                mISDNport = mISDNport->next;
                        }
                        if (!mISDNport) {
-                               unsigned int remote_ref = new_remote++;
                                union parameter param;
 
-                               memset(&param, 0, sizeof(union parameter));
-                               admin_message_from_lcr(mISDNport->ifport->remote, remote_ref, MESSAGE_NEWREF, &param);
+                               /* create new join instance */
+                               join = joinremote = new JoinRemote(0, admin->remote_name, admin->sock); // must have no serial, because no endpoint is connected
+                               if (!join) {
+                                       FATAL("No memory for remote join instance\n");
+                                       return(-1);
+                               }
                                memset(&param, 0, sizeof(union parameter));
                                param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
                                param.disconnectinfo.cause = CAUSE_RESSOURCEUNAVAIL;
-                               admin_message_from_lcr(mISDNport->ifport->remote, remote_ref, MESSAGE_RELEASE, &param);
+                               admin_message_from_lcr(joinremote->j_remote_id, joinremote->j_remote_ref, MESSAGE_RELEASE, &param);
                                return 0;
                        }
                        /* creating port object, transparent until setup with hdlc */
@@ -712,7 +714,7 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin)
        /* find join instance */
        join = join_first;
        while(join) {
-               if (join->j_type != JOIN_TYPE_REMOTE) {
+               if (join->j_type == JOIN_TYPE_REMOTE) {
                        joinremote = (class JoinRemote *)join;
                        if (joinremote->j_remote_ref == msg->ref)
                                break;