summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschlaile2008-07-20 19:33:28 +0200
committerroot2008-07-20 19:33:28 +0200
commita114e74299f4708d96b490be055ab8939b9e7610 (patch)
tree3a787227e89e8f2a399e5a240eb1b24d5bf9b3fb
parentremoved "lcr query", use "isdninfo" instead. (diff)
downloadlcr-a114e74299f4708d96b490be055ab8939b9e7610.tar.gz
lcr-a114e74299f4708d96b490be055ab8939b9e7610.tar.xz
lcr-a114e74299f4708d96b490be055ab8939b9e7610.zip
rebuffer option for chan_lcr (160 bytes per frame)
l1-link state "unknown" if not known yet. removed root user check. modified: bchannel.c modified: bchannel.h modified: chan_lcr.c modified: chan_lcr.h modified: dss1.cpp modified: lcradmin.c modified: mISDN.cpp modified: main.c
-rw-r--r--bchannel.c58
-rw-r--r--bchannel.h2
-rw-r--r--chan_lcr.c8
-rw-r--r--chan_lcr.h2
-rw-r--r--dss1.cpp7
-rw-r--r--lcradmin.c7
-rw-r--r--mISDN.cpp1
-rw-r--r--main.c7
8 files changed, 76 insertions, 16 deletions
diff --git a/bchannel.c b/bchannel.c
index 73ea2f8..346374b 100644
--- a/bchannel.c
+++ b/bchannel.c
@@ -195,6 +195,7 @@ void bchannel_activate(struct bchannel *bchannel, int activate)
CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
bchannel->b_state = (activate)?BSTATE_ACTIVATING:BSTATE_DEACTIVATING;
+ bchannel->rebuffer_usage = 0;
}
@@ -249,6 +250,7 @@ void bchannel_destroy(struct bchannel *bchannel)
{
close(bchannel->b_sock);
bchannel->b_sock = -1;
+ bchannel->rebuffer_usage = 0;
}
bchannel->b_state = BSTATE_IDLE;
}
@@ -346,17 +348,63 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned char *buffer, i
/* return, because we have no audio from port */
return;
}
- if (bchannel->call->pipe[1] > -1)
+
+ if (bchannel->call->pipe[1] < 0)
{
+ /* nobody there */
+ return;
+ }
+
+
+ if (bchannel->call->rebuffer) {
+ int u = bchannel->rebuffer_usage;
+ unsigned char * b = bchannel->rebuffer;
+ unsigned char * d = data;
+ int l = len;
+ int fd = bchannel->call->pipe[1];
+
+ if (u > 0) {
+ if (u + l >= 160) {
+ memcpy(b + u, d, 160 - u);
+ d += 160 - u;
+ l -= 160 - u;
+ u = 0;
+ if (write(fd, b, 160) < 0) {
+ goto errout;
+ }
+ } else {
+ memcpy(b + u, d, l);
+ u += l;
+ l = 0;
+ }
+ }
+
+ while (l >= 160) {
+ if (write(fd, d, 160) < 0) {
+ goto errout;
+ }
+ d += 160;
+ l -= 160;
+ }
+
+ if (l > 0) {
+ memcpy(b, d, l);
+ }
+ bchannel->rebuffer_usage = u + l;
+ } else {
len = write(bchannel->call->pipe[1], data, len);
if (len < 0)
{
- close(bchannel->call->pipe[1]);
- bchannel->call->pipe[1] = -1;
- CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
- return;
+ goto errout;
}
}
+
+ return;
+ errout:
+ close(bchannel->call->pipe[1]);
+ bchannel->call->pipe[1] = -1;
+ bchannel->rebuffer_usage = 0;
+ CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
}
diff --git a/bchannel.h b/bchannel.h
index f7b3860..267f8b7 100644
--- a/bchannel.h
+++ b/bchannel.h
@@ -30,6 +30,8 @@ struct bchannel {
int b_dtmf;
int b_bf_len;
unsigned char b_bf_key[128];
+ int rebuffer_usage;
+ unsigned char rebuffer[160];
};
diff --git a/chan_lcr.c b/chan_lcr.c
index ff8da54..dc7ebed 100644
--- a/chan_lcr.c
+++ b/chan_lcr.c
@@ -475,6 +475,14 @@ void apply_opt(struct chan_call *call, char *data)
if (call->bchannel)
bchannel_pipeline(call->bchannel, call->pipeline);
break;
+ case 'r':
+ if (opt[1] == '\0') {
+ CERROR(call, call->ast, "Option 'r' (re-buffer 160 bytes) expects no parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 'r' (re-buffer 160 bytes)");
+ call->rebuffer = 1;
+ break;
#if 0
case 's':
if (opt[1] != '\0') {
diff --git a/chan_lcr.h b/chan_lcr.h
index 69d4dc5..bc61c07 100644
--- a/chan_lcr.h
+++ b/chan_lcr.h
@@ -53,6 +53,8 @@ struct chan_call {
/* shall dtmf be enabled */
int no_dtmf;
/* dtmf disabled by option */
+ int rebuffer; /* send only 160 bytes frames
+ to asterisk */
char pipeline[256];
/* echo cancel pipeline by option */
int tx_gain, rx_gain;
diff --git a/dss1.cpp b/dss1.cpp
index d4e90e6..06bb203 100644
--- a/dss1.cpp
+++ b/dss1.cpp
@@ -1193,14 +1193,17 @@ void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_m
l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
/* in case layer 2 is down during setup, we send cause 27 loc 5 */
- if (p_state == PORT_STATE_OUT_SETUP && !p_m_mISDNport->l1link)
+ if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0)
{
cause = 27;
location = 5;
} else
{
dec_ie_cause(l3m, &location, &cause);
- add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
+ if (p_m_mISDNport->l1link < 0)
+ add_trace("layer 1", NULL, "unknown");
+ else
+ add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
}
end_trace();
if (location == LOCATION_PRIVATE_LOCAL)
diff --git a/lcradmin.c b/lcradmin.c
index fbd0015..288bebd 100644
--- a/lcradmin.c
+++ b/lcradmin.c
@@ -679,8 +679,11 @@ char *admin_state(int sock, char *argv[])
color((m[i].u.i.l2link)?green:red);
addstr((m[i].u.i.l2link)?" L2 UP":" L2 down");
}
- color((m[i].u.i.l1link)?green:blue);
- addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive");
+ color((m[i].u.i.l1link > 0)?green:blue);
+ if (m[i].u.i.l1link < 0)
+ addstr(" L1 unknown");
+ else
+ addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive");
if (m[i].u.i.los)
{
color(red);
diff --git a/mISDN.cpp b/mISDN.cpp
index 20ec026..e8a71cc 100644
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -2215,6 +2215,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
while(*mISDNportp)
mISDNportp = &((*mISDNportp)->next);
mISDNport = (struct mISDNport *)MALLOC(sizeof(struct mISDNport));
+ mISDNport->l1link = -1;
pmemuse++;
*mISDNportp = mISDNport;
diff --git a/main.c b/main.c
index 49d7fe4..cf6be07 100644
--- a/main.c
+++ b/main.c
@@ -226,13 +226,6 @@ int main(int argc, char *argv[])
/* init crc */
crc_init();
- /* check for root (real or effective) */
- if (getuid() && geteuid())
- {
- fprintf(stderr, "Please run %s as super-user.\n", NAME);
- goto free;
- }
-
/* the mutex init */
if (pthread_mutex_init(&mutexd, NULL))
{