Added display of current active TEI values (L2) at lcradmin.
[lcr.git] / socket_server.c
index 0b6e173..9abb5b2 100644 (file)
@@ -15,7 +15,7 @@
 #include <curses.h>
 
 
-char *socket_name = SOCKET_NAME;
+char socket_name[128];
 int sock = -1;
 struct sockaddr_un sock_address;
 
@@ -36,6 +36,7 @@ int admin_init(void)
        }
        fhuse++;
        memset(&sock_address, 0, sizeof(sock_address));
+       SPRINT(socket_name, SOCKET_NAME, options.lock);
        sock_address.sun_family = AF_UNIX;
        UCPY(sock_address.sun_path, socket_name);
        unlink(socket_name);
@@ -66,6 +67,10 @@ int admin_init(void)
                PERROR("Failed to set socket \"%s\" into non-blocking mode. (errno=%d)\n", sock_address.sun_path, errno);
                return(-1);
        }
+       if (chmod(socket_name, options.socketrights) < 0)
+       {
+               PERROR("Failed to change socket rigts to %d. (errno=%d)\n", options.socketrights, errno);
+       }
        return(0);
 }
 
@@ -86,7 +91,7 @@ void free_connection(struct admin_list *admin)
        /* free remote joins */
        if (admin->remote_name[0])
        {
-               start_trace(0,
+               start_trace(-1,
                        NULL,
                        NULL,
                        NULL,
@@ -176,6 +181,8 @@ void admin_cleanup(void)
                close(sock);
                fhuse--;
        }
+
+       unlink(socket_name);
 }
 
 
@@ -185,7 +192,7 @@ void admin_cleanup(void)
 int admin_interface(struct admin_queue **responsep)
 {
        struct admin_queue      *response;      /* response pointer */
-       char                    *err_txt = "";
+       const char              *err_txt = "";
        int                     err = 0;
 
         if (read_interfaces())
@@ -291,7 +298,7 @@ int admin_route(struct admin_queue **responsep)
                        apppbx->e_callback = 0;
                        apppbx->e_action = NULL;
                        apppbx->release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL);
-                       start_trace(0,
+                       start_trace(-1,
                                NULL,
                                numberrize_callerinfo(apppbx->e_callerinfo.id, apppbx->e_callerinfo.ntype, options.national, options.international),
                                apppbx->e_dialinginfo.id,
@@ -408,6 +415,7 @@ int admin_block(struct admin_queue **responsep, int portnum, int block)
        response->am[0].u.x.portnum = portnum;
 
        /* search for port */
+       ifport = NULL;
        interface = interface_first;
        while(interface)
        {
@@ -562,7 +570,7 @@ int admin_call(struct admin_list *admin, struct admin_message *msg)
 /*
  * this function is called for response whenever a call state changes.
  */
-void admin_call_response(int adminid, int message, char *connected, int cause, int location, int notify)
+void admin_call_response(int adminid, int message, const char *connected, int cause, int location, int notify)
 {
        struct admin_list       *admin;
        struct admin_queue      *response, **responsep; /* response pointer */
@@ -639,7 +647,7 @@ int admin_message_to_join(struct admin_msg *msg, struct admin_list *admin)
                }
                /* set remote socket instance */
                SCPY(admin->remote_name, msg->param.hello.application);
-               start_trace(0,
+               start_trace(-1,
                        NULL,
                        NULL,
                        NULL,
@@ -880,6 +888,8 @@ int admin_state(struct admin_queue **responsep)
                        SCPY(response->am[num].u.i.interface_name, interface->name);
                        /* portnum */
                        response->am[num].u.i.portnum = ifport->portnum;
+                       /* portname */
+                       SCPY(response->am[num].u.i.portname, ifport->portname);
                        /* iftype */
                        response->am[num].u.i.extension = interface->extension;
                        /* block */
@@ -890,6 +900,10 @@ int admin_state(struct admin_queue **responsep)
 
                                /* ptp */
                                response->am[num].u.i.ptp = mISDNport->ptp;
+                               /* l1hold */
+                               response->am[num].u.i.l1hold = mISDNport->l1hold;
+                               /* l2hold */
+                               response->am[num].u.i.l2hold = mISDNport->l2hold;
                                /* ntmode */
                                response->am[num].u.i.ntmode = mISDNport->ntmode;
                                /* pri */
@@ -900,6 +914,7 @@ int admin_state(struct admin_queue **responsep)
                                response->am[num].u.i.l1link = mISDNport->l1link;
                                /* l2link */
                                response->am[num].u.i.l2link = mISDNport->l2link;
+                               memcpy(response->am[num].u.i.l2mask, mISDNport->l2mask, 16);
                                /* los */
                                response->am[num].u.i.los = mISDNport->los;
                                /* ais */
@@ -1171,7 +1186,6 @@ int admin_handle(void)
                        {
                                work = 1;
                                brokenpipe:
-                               printf("Broken pipe on socket %d. (errno=%d).\n", admin->sock, errno);
                                PDEBUG(DEBUG_LOG, "Broken pipe on socket %d. (errno=%d).\n", admin->sock, errno);
                                *adminp = admin->next;
                                free_connection(admin);