Added layer1 hold feature. Requires new mISDN and mISDNuser package from git.
[lcr.git] / interface.c
index 5549654..28ad88c 100644 (file)
@@ -360,6 +360,34 @@ static int inter_portname(struct interface *interface, char *filename, int line,
        *ifportp = ifport;
        return(0);
 }
+static int inter_l1hold(struct interface *interface, char *filename, int line, char *parameter, char *value)
+{
+       struct interface_port *ifport;
+
+       /* port in chain ? */
+       if (!interface->ifport)
+       {
+               SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter);
+               return(-1);
+       }
+       /* goto end of chain */
+       ifport = interface->ifport;
+       while(ifport->next)
+               ifport = ifport->next;
+       if (!strcmp(value, "yes"))
+       {
+               ifport->l1hold = 1;
+       } else
+       if (!strcmp(value, "no"))
+       {
+               ifport->l1hold = 0;
+       } else
+       {
+               SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expecting parameter 'yes' or 'no'.\n", filename, line, parameter);
+               return(-1);
+       }
+       return(0);
+}
 static int inter_l2hold(struct interface *interface, char *filename, int line, char *parameter, char *value)
 {
        struct interface_port *ifport;
@@ -898,6 +926,23 @@ static int inter_filter(struct interface *interface, char *filename, int line, c
        }
        return(0);
 }
+static int inter_dialmax(struct interface *interface, char *filename, int line, char *parameter, char *value)
+{
+       struct interface_port *ifport;
+
+       /* port in chain ? */
+       if (!interface->ifport)
+       {
+               SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter);
+               return(-1);
+       }
+       /* goto end of chain */
+       ifport = interface->ifport;
+       while(ifport->next)
+               ifport = ifport->next;
+       ifport->dialmax = atoi(value);
+       return(0);
+}
 
 
 /*
@@ -951,6 +996,11 @@ struct interface_param interface_param[] = {
        "Note that this is not compliant with ISDN protocol.\n"
        "This parameter must follow a 'port' parameter."},
 
+       {"layer1hold", &inter_l1hold, "yes | no",
+       "The given port will not release layer 1 after layer 2 is down.\n"
+       "It is required to keep layer 1 of telephones up, to solve activation problems.\n"
+       "This parameter must follow a 'port' parameter."},
+
        {"layer2hold", &inter_l2hold, "yes | no",
        "The given port will continuously try to establish layer 2 link and hold it.\n"
        "It is required for PTP links in most cases, therefore it is default.\n"
@@ -1008,6 +1058,9 @@ struct interface_param interface_param[] = {
        "pipeline <string> - Sets echo cancelation pipeline.\n"
        "blowfish <key> - Adds encryption. Key must be 4-56 bytes (8-112 hex characters."},
 
+       {"dialmax", &inter_dialmax, "<digits>",
+       "Limits the number of digits in setup/information message."},
+
        {NULL, NULL, NULL, NULL}
 };
 
@@ -1301,8 +1354,11 @@ void relink_interfaces(void)
                        mISDNport = mISDNport_first;
                        while(mISDNport)
                        {
+                               if (!strcmp(mISDNport->name, ifport->portname))
+                                       ifport->portnum = mISDNport->portnum; /* same name, so we use same number */
                                if (mISDNport->portnum == ifport->portnum)
                                {
+                                       PDEBUG(DEBUG_ISDN, "Port %d:%s relinking!\n", mISDNport->portnum);
                                        ifport->mISDNport = mISDNport;
                                        mISDNport->ifport = ifport;
                                        set_defaults(ifport);
@@ -1356,7 +1412,7 @@ void load_port(struct interface_port *ifport)
        struct mISDNport *mISDNport;
 
        /* open new port */
-       mISDNport = mISDNport_open(ifport->portnum, ifport->portname, ifport->ptp, ifport->nt, ifport->tespecial, ifport->l2hold, ifport->interface);
+       mISDNport = mISDNport_open(ifport->portnum, ifport->portname, ifport->ptp, ifport->nt, ifport->tespecial, ifport->l1hold, ifport->l2hold, ifport->interface);
        if (mISDNport)
        {
                /* link port */