Added bridgin support for GSM and SIP
[lcr.git] / socket_server.c
index 9922dc6..2fba2eb 100644 (file)
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <curses.h>
+#ifdef PACKAGE_VERSION
+#undef PACKAGE_VERSION
+#endif
 #include "config.h"
 
 
 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 +666,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 */
@@ -697,7 +702,6 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin)
        if (msg->param.bchannel.type == BCHANNEL_ASSIGN_ACK
         || msg->param.bchannel.type == BCHANNEL_REMOVE_ACK
         || msg->param.bchannel.type == BCHANNEL_RELEASE) {
-#warning TODO: depending on the mode (join / remoteport) forward message
                /* no ref, but address */
                message_bchannel_from_remote(NULL, msg->param.bchannel.type, msg->param.bchannel.handle);
                return(0);
@@ -712,7 +716,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;
@@ -840,6 +844,8 @@ int admin_state(struct admin_queue **responsep)
        interface = interface_first;
        while(interface) {
                ifport = interface->ifport;
+               if (!ifport)
+                       i++;
                while(ifport) {
                        i++;
                        ifport = ifport->next;
@@ -901,6 +907,18 @@ int admin_state(struct admin_queue **responsep)
        num = 0;
        while(interface) {
                ifport = interface->ifport;
+               if (!ifport) {
+                       /* message */
+                       response->am[num].message = ADMIN_RESPONSE_S_INTERFACE;
+                       /* interface */
+                       SCPY(response->am[num].u.i.interface_name, interface->name);
+                       /* portnum */
+                       response->am[num].u.i.portnum = -100; /* indicate: no ifport */
+                       /* iftype */
+                       response->am[num].u.i.extension = interface->extension;
+                       /* block */
+                       num++;
+               }
                while(ifport) {
                        /* message */
                        response->am[num].message = ADMIN_RESPONSE_S_INTERFACE;