summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README7
-rw-r--r--default/interface.conf5
-rw-r--r--interface.c44
-rw-r--r--interface.h1
-rw-r--r--lcradmin.c4
-rw-r--r--lcrsocket.h1
-rw-r--r--mISDN.cpp49
-rw-r--r--mISDN.h2
-rw-r--r--main.h2
-rw-r--r--socket_server.c3
10 files changed, 104 insertions, 14 deletions
diff --git a/README b/README
index 608e0fb..c6d32f2 100644
--- a/README
+++ b/README
@@ -430,7 +430,7 @@ Changes in Version 1.0
- First Alpha release of chan_lcr - the Asterisk PBX channel link driver.
-> Use LCR in conjunction with Asterisk, or simply as ISDN frontend.
-Fixes in current Version
+Changes in Version 1.1
- Fixed dtmf bug.
- Added more display infos
- Fixed b-channel check bug. (channel seemed busy, even if it was free)
@@ -439,5 +439,10 @@ Fixes in current Version
- Fixed lockinproblem with chan_lcr (hopefully).
- HDLC now works and is used for B-channels, if required.
- Briding for chan_lcr fixed, many other fixed for chan_lcr. Overlap dialing!
+- Compiling and 64-bit issues fixed by Karsten.
+- chan_lcr fixes and tests by Peter.
+- LCR now runs as user, but still can be run as root.
+- Ports can now be given with number or with name.
+Fixes in current Version
diff --git a/default/interface.conf b/default/interface.conf
index db5af49..daa8c57 100644
--- a/default/interface.conf
+++ b/default/interface.conf
@@ -102,6 +102,11 @@
#tones yes
#timeouts 60 60 60 60 60
+# Alternatively give port name. You will find the name with 'isdninfo' tool.
+#[Int2]
+#portname hfc-s_usb.1
+#nt
+
# Hint: Enter "lcr interface" for quick help on interface options.
# Add your interfaces here:
diff --git a/interface.c b/interface.c
index 98a87ac..c70222c 100644
--- a/interface.c
+++ b/interface.c
@@ -304,8 +304,38 @@ static int inter_portnum(struct interface *interface, char *filename, int line,
}
static int inter_portname(struct interface *interface, char *filename, int line, char *parameter, char *value)
{
- SPRINT(interface_error, "Error in %s (line %d): parameter '%s' not implemented yet.\n", filename, line, parameter);
- return(-1);
+ struct interface_port *ifport, **ifportp;
+ struct interface *searchif;
+
+ /* check for port already assigned */
+ searchif = interface_newlist;
+ while(searchif)
+ {
+ ifport = searchif->ifport;
+ while(ifport)
+ {
+ if (!strcasecmp(ifport->portname, value))
+ {
+ SPRINT(interface_error, "Error in %s (line %d): port '%s' already used above.\n", filename, line, value);
+ return(-1);
+ }
+ ifport = ifport->next;
+ }
+ searchif = searchif->next;
+ }
+ /* alloc port substructure */
+ ifport = (struct interface_port *)MALLOC(sizeof(struct interface_port));
+ memuse++;
+ ifport->interface = interface;
+ /* set value */
+ ifport->portnum = -1; // disable until resolved
+ SCPY(ifport->portname, value);
+ /* tail port */
+ ifportp = &interface->ifport;
+ while(*ifportp)
+ ifportp = &((*ifportp)->next);
+ *ifportp = ifport;
+ return(0);
}
static int inter_l2hold(struct interface *interface, char *filename, int line, char *parameter, char *value)
{
@@ -866,8 +896,8 @@ struct interface_param interface_param[] = {
""},
{"portnum", &inter_portnum, "<number>",
"Give exactly one port for this interface.\nTo give multiple ports, add more lines with port parameters."},
- {"portname", &inter_portname, "<number>",
- "Give exactly one port for this interface.\nTo give multiple ports, add more lines with port parameters."},
+ {"portname", &inter_portname, "<name>",
+ "Same as 'portnum', but the name is given instead.\nUse 'isdninfo' to list all available ports and names."},
{"block", &inter_block, "",
"If keyword is given, calls on this interface are blocked.\n"
@@ -1295,12 +1325,16 @@ void load_port(struct interface_port *ifport)
struct mISDNport *mISDNport;
/* open new port */
- mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->nt, ifport->l2hold, ifport->interface);
+ mISDNport = mISDNport_open(ifport->portnum, ifport->portname, ifport->ptp, ifport->nt, ifport->l2hold, ifport->interface);
if (mISDNport)
{
/* link port */
ifport->mISDNport = mISDNport;
mISDNport->ifport = ifport;
+ /* set number and name */
+ ifport->portnum = mISDNport->portnum;
+ SCPY(ifport->portname, mISDNport->name);
+ /* set defaults */
set_defaults(ifport);
} else
{
diff --git a/interface.h b/interface.h
index 1c713a8..221b085 100644
--- a/interface.h
+++ b/interface.h
@@ -45,6 +45,7 @@ struct interface_port {
struct interface *interface; /* link to interface */
struct mISDNport *mISDNport; /* link to port */
int portnum; /* port number */
+ char portname[64]; /* alternately: port name */
int ptp; /* force load stack in PTP mode */
int ptmp; /* force load stack in PTP mode */
int nt; /* load stack in NT-mode */
diff --git a/lcradmin.c b/lcradmin.c
index 748ca50..8cd40da 100644
--- a/lcradmin.c
+++ b/lcradmin.c
@@ -668,13 +668,13 @@ const char *admin_state(int sock, char *argv[])
color(white);
if (m[i].u.i.block >= 2)
{
- SPRINT(buffer, "%s (%d)%s", m[i].u.i.interface_name, m[i].u.i.portnum, (m[i].u.i.extension)?" (extension)":"");
+ SPRINT(buffer, "%s (port %d: %s)%s", m[i].u.i.interface_name, m[i].u.i.portnum, m[i].u.i.portname, (m[i].u.i.extension)?" extension":"");
addstr(buffer);
color(red);
addstr(" not loaded");
} else
{
- SPRINT(buffer, "%s (%d) %s %s%s use:%d", m[i].u.i.interface_name, m[i].u.i.portnum, (m[i].u.i.ntmode)?"NT-mode":"TE-mode", (m[i].u.i.ptp)?"ptp ":"ptmp", (m[i].u.i.extension)?" extension":"", m[i].u.i.use);
+ SPRINT(buffer, "%s (port %d: %s) %s %s%s use:%d", m[i].u.i.interface_name, m[i].u.i.portnum, m[i].u.i.portname, (m[i].u.i.ntmode)?"NT-mode":"TE-mode", (m[i].u.i.ptp)?"ptp ":"ptmp", (m[i].u.i.extension)?" extension":"", m[i].u.i.use);
addstr(buffer);
if (m[i].u.i.ptp || !m[i].u.i.ntmode)
{
diff --git a/lcrsocket.h b/lcrsocket.h
index 6c7983f..e7d51c5 100644
--- a/lcrsocket.h
+++ b/lcrsocket.h
@@ -65,6 +65,7 @@ struct admin_response_state {
struct admin_response_interface {
char interface_name[32];
int portnum;
+ char portname[64];
int block;
int ntmode;
int ptp;
diff --git a/mISDN.cpp b/mISDN.cpp
index 281ef2a..98e2c6c 100644
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -2117,7 +2117,7 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3
/*
* global function to add a new card (port)
*/
-struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, struct interface *interface)
+struct mISDNport *mISDNport_open(int port, char *portname, int ptp, int force_nt, int l2hold, struct interface *interface)
{
int ret;
struct mISDNport *mISDNport, **mISDNportp;
@@ -2128,6 +2128,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
struct mISDN_devinfo devinfo;
unsigned int protocol, prop;
+ /* check port counts */
ret = ioctl(mISDNsocket, IMGETCOUNT, &cnt);
if (ret < 0)
{
@@ -2140,21 +2141,45 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
PERROR_RUNTIME("Found no card. Please be sure to load card drivers.\n");
return(NULL);
}
+ if (port < 0)
+ {
+ /* resolve name */
+ port = 0;
+ while (port < cnt)
+ {
+ devinfo.id = port;
+ ret = ioctl(mISDNsocket, IMGETDEVINFO, &devinfo);
+ if (ret < 0)
+ {
+ PERROR_RUNTIME("Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", port, ret);
+ return(NULL);
+ }
+ if (!strcasecmp(devinfo.name, portname))
+ break;
+ port++;
+ }
+ if (port == cnt)
+ {
+ PERROR_RUNTIME("Port name '%s' no found, use 'isdninfo' tool to list all existing ports.\n", portname);
+ return(NULL);
+ }
+ // note: 'port' has still the port number
+ }
if (port>cnt || port<0)
{
PERROR_RUNTIME("Port (%d) given at 'ports' (options.conf) is out of existing port range (%d-%d)\n", port, 0, cnt);
return(NULL);
}
+ /* get port attributes */
pri = bri = pots = nt = te = 0;
devinfo.id = port;
ret = ioctl(mISDNsocket, IMGETDEVINFO, &devinfo);
if (ret < 0)
{
- PERROR_RUNTIME("Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", i, ret);
+ PERROR_RUNTIME("Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", port, ret);
return(NULL);
}
- /* output the port info */
if (devinfo.Dprotocols & (1 << ISDN_P_TE_S0))
{
bri = 1;
@@ -2221,6 +2246,24 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
if (te && nt)
nt = 0;
+ /* check for double use of port */
+ if (nt)
+ {
+ mISDNport = mISDNport_first;
+ while(mISDNport)
+ {
+ if (mISDNport->portnum == port)
+ break;
+ mISDNport = mISDNport->next;
+ }
+ if (mISDNport)
+ {
+ PERROR_RUNTIME("Port %d already in use by LCR. You can't use a NT port multiple times.\n", port);
+ return(NULL);
+ }
+ }
+
+
/* add mISDNport structure */
mISDNportp = &mISDNport_first;
while(*mISDNportp)
diff --git a/mISDN.h b/mISDN.h
index 7ddea03..2881341 100644
--- a/mISDN.h
+++ b/mISDN.h
@@ -79,7 +79,7 @@ calls with no bchannel (call waiting, call on hold).
/* mISDN none-object functions */
int mISDN_initialize(void);
void mISDN_deinitialize(void);
-struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, struct interface *interface);
+struct mISDNport *mISDNport_open(int port, char *portname, int ptp, int force_nt, int l2hold, struct interface *interface);
void mISDNport_close_all(void);
void mISDNport_close(struct mISDNport *mISDNport);
void mISDN_port_reorder(void);
diff --git a/main.h b/main.h
index 9d580c2..d6aee78 100644
--- a/main.h
+++ b/main.h
@@ -34,7 +34,7 @@
#define DEFAULT_ENDPOINT_APP EndpointAppPBX
-#define VERSION_STRING "1.0 beta 1 (Summer 2008)"
+#define VERSION_STRING "1.1 (Summer 2008)"
extern int memuse;
extern int mmemuse;
diff --git a/socket_server.c b/socket_server.c
index 166080d..4b5a841 100644
--- a/socket_server.c
+++ b/socket_server.c
@@ -887,6 +887,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 */
@@ -1178,7 +1180,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);