dahdi: lots more logging
This commit is contained in:
parent
5cd3be294a
commit
90f9edc2dc
41
src/dahdi.c
41
src/dahdi.c
|
@ -14,6 +14,7 @@
|
||||||
#include <osmocom/core/utils.h>
|
#include <osmocom/core/utils.h>
|
||||||
|
|
||||||
#include "isdntap.h"
|
#include "isdntap.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#define BLOCK_SIZE 512
|
#define BLOCK_SIZE 512
|
||||||
|
|
||||||
|
@ -163,29 +164,39 @@ static int open_line_dahdi(struct isdntap_line *line)
|
||||||
|
|
||||||
/* make sure we have a span number */
|
/* make sure we have a span number */
|
||||||
if (line->drvdata.dahdi.spanno < 0) {
|
if (line->drvdata.dahdi.spanno < 0) {
|
||||||
if (!line->drvdata.dahdi.name)
|
if (!line->drvdata.dahdi.name) {
|
||||||
|
LOGPLI(line, DLINP, LOGL_ERROR, "DAHDI name nor span number specified\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
line->drvdata.dahdi.spanno = get_span_no_by_name(line->drvdata.dahdi.name);
|
line->drvdata.dahdi.spanno = get_span_no_by_name(line->drvdata.dahdi.name);
|
||||||
}
|
}
|
||||||
if (line->drvdata.dahdi.spanno < 0)
|
if (line->drvdata.dahdi.spanno < 0) {
|
||||||
|
LOGPLI(line, DLINP, LOGL_ERROR, "Unable to resolve DAHDI span number\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* resolve the base channel number */
|
/* resolve the base channel number */
|
||||||
rc = get_span_sysfs_int(line->drvdata.dahdi.spanno, "basechan");
|
rc = get_span_sysfs_int(line->drvdata.dahdi.spanno, "basechan");
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
|
LOGPLI(line, DLINP, LOGL_ERROR, "Unable to get DAHDI basechan via sysfs\n");
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
line->drvdata.dahdi.basechan = rc;
|
line->drvdata.dahdi.basechan = rc;
|
||||||
|
|
||||||
/* resolve the numberof channels */
|
/* resolve the numberof channels */
|
||||||
rc = get_span_sysfs_int(line->drvdata.dahdi.spanno, "channels");
|
rc = get_span_sysfs_int(line->drvdata.dahdi.spanno, "channels");
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
|
LOGPLI(line, DLINP, LOGL_ERROR, "Unable to get DAHDI channels via sysfs\n");
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
line->drvdata.dahdi.channels = rc;
|
line->drvdata.dahdi.channels = rc;
|
||||||
|
|
||||||
/* obtain the span type */
|
/* obtain the span type */
|
||||||
spantype = get_span_sysfs_str(line->drvdata.dahdi.spanno, "spantype");
|
spantype = get_span_sysfs_str(line->drvdata.dahdi.spanno, "spantype");
|
||||||
if (!spantype)
|
if (!spantype) {
|
||||||
|
LOGPLI(line, DLINP, LOGL_ERROR, "Unable to get DAHDI spantype via sysfs\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
line->drvdata.dahdi.spantype = talloc_strdup(line, spantype);
|
line->drvdata.dahdi.spantype = talloc_strdup(line, spantype);
|
||||||
free(spantype);
|
free(spantype);
|
||||||
|
|
||||||
|
@ -198,14 +209,19 @@ static int open_line_dahdi(struct isdntap_line *line)
|
||||||
sig_ts = &line->ts[16]; // FIXME: configurable
|
sig_ts = &line->ts[16]; // FIXME: configurable
|
||||||
|
|
||||||
rc = make_mirror(DAHDI_RXMIRROR, sig_ts->drvdata.dahdi.channo);
|
rc = make_mirror(DAHDI_RXMIRROR, sig_ts->drvdata.dahdi.channo);
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
|
LOGPTS(sig_ts, DLINP, LOGL_ERROR, "Unable to create RXMIRROR for channo %u\n",
|
||||||
|
sig_ts->drvdata.dahdi.channo);
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
/* verify HDLC mode? */
|
/* verify HDLC mode? */
|
||||||
osmo_fd_setup(&sig_ts->drvdata.dahdi.rx, rc, OSMO_FD_READ, dahdi_dchan_fd_cb, sig_ts, 1);
|
osmo_fd_setup(&sig_ts->drvdata.dahdi.rx, rc, OSMO_FD_READ, dahdi_dchan_fd_cb, sig_ts, 1);
|
||||||
osmo_fd_register(&sig_ts->drvdata.dahdi.rx);
|
osmo_fd_register(&sig_ts->drvdata.dahdi.rx);
|
||||||
|
|
||||||
rc = make_mirror(DAHDI_TXMIRROR, sig_ts->drvdata.dahdi.channo);
|
rc = make_mirror(DAHDI_TXMIRROR, sig_ts->drvdata.dahdi.channo);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
LOGPTS(sig_ts, DLINP, LOGL_ERROR, "Unable to create TXMIRROR for channo %u\n",
|
||||||
|
sig_ts->drvdata.dahdi.channo);
|
||||||
close(sig_ts->drvdata.dahdi.rx.fd);
|
close(sig_ts->drvdata.dahdi.rx.fd);
|
||||||
sig_ts->drvdata.dahdi.rx.fd = -1;
|
sig_ts->drvdata.dahdi.rx.fd = -1;
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -214,6 +230,8 @@ static int open_line_dahdi(struct isdntap_line *line)
|
||||||
osmo_fd_setup(&sig_ts->drvdata.dahdi.tx, rc, OSMO_FD_READ, dahdi_dchan_fd_cb, sig_ts, 2);
|
osmo_fd_setup(&sig_ts->drvdata.dahdi.tx, rc, OSMO_FD_READ, dahdi_dchan_fd_cb, sig_ts, 2);
|
||||||
osmo_fd_register(&sig_ts->drvdata.dahdi.tx);
|
osmo_fd_register(&sig_ts->drvdata.dahdi.tx);
|
||||||
|
|
||||||
|
LOGPLI(line, DLINP, LOGL_NOTICE, "Successfully opened DAHDI line (and its D-channel)\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,13 +240,18 @@ static int open_ts_dahdi(struct isdntap_ts *ts)
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = make_mirror(DAHDI_RXMIRROR, ts->drvdata.dahdi.channo);
|
rc = make_mirror(DAHDI_RXMIRROR, ts->drvdata.dahdi.channo);
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
|
LOGPTS(ts, DLINP, LOGL_ERROR, "Unable to create RXMIRROR for channo %u\n",
|
||||||
|
ts->drvdata.dahdi.channo);
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
osmo_fd_setup(&ts->drvdata.dahdi.rx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 1);
|
osmo_fd_setup(&ts->drvdata.dahdi.rx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 1);
|
||||||
osmo_fd_register(&ts->drvdata.dahdi.rx);
|
osmo_fd_register(&ts->drvdata.dahdi.rx);
|
||||||
|
|
||||||
rc = make_mirror(DAHDI_TXMIRROR, ts->drvdata.dahdi.channo);
|
rc = make_mirror(DAHDI_TXMIRROR, ts->drvdata.dahdi.channo);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
LOGPTS(ts, DLINP, LOGL_ERROR, "Unable to create TXMIRROR for channo %u\n",
|
||||||
|
ts->drvdata.dahdi.channo);
|
||||||
osmo_fd_unregister(&ts->drvdata.dahdi.rx);
|
osmo_fd_unregister(&ts->drvdata.dahdi.rx);
|
||||||
close(ts->drvdata.dahdi.rx.fd);
|
close(ts->drvdata.dahdi.rx.fd);
|
||||||
ts->drvdata.dahdi.rx.fd = -1;
|
ts->drvdata.dahdi.rx.fd = -1;
|
||||||
|
@ -237,6 +260,8 @@ static int open_ts_dahdi(struct isdntap_ts *ts)
|
||||||
osmo_fd_setup(&ts->drvdata.dahdi.tx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 2);
|
osmo_fd_setup(&ts->drvdata.dahdi.tx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 2);
|
||||||
osmo_fd_register(&ts->drvdata.dahdi.tx);
|
osmo_fd_register(&ts->drvdata.dahdi.tx);
|
||||||
|
|
||||||
|
LOGPTS(ts, DLINP, LOGL_INFO, "Successfully opened DAHDI timeslot (B-channel)\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,6 +277,7 @@ static void close_ts_dahdi(struct isdntap_ts *ts)
|
||||||
close(ts->drvdata.dahdi.tx.fd);
|
close(ts->drvdata.dahdi.tx.fd);
|
||||||
ts->drvdata.dahdi.tx.fd = -1;
|
ts->drvdata.dahdi.tx.fd = -1;
|
||||||
}
|
}
|
||||||
|
LOGPTS(ts, DLINP, LOGL_INFO, "Successfully closed DAHDI timeslot (B-channel)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_line_dahdi(struct isdntap_line *line)
|
static void close_line_dahdi(struct isdntap_line *line)
|
||||||
|
@ -262,6 +288,7 @@ static void close_line_dahdi(struct isdntap_line *line)
|
||||||
struct isdntap_ts *ts = &line->ts[1+i];
|
struct isdntap_ts *ts = &line->ts[1+i];
|
||||||
close_ts_dahdi(ts);
|
close_ts_dahdi(ts);
|
||||||
}
|
}
|
||||||
|
LOGPLI(line, DLINP, LOGL_INFO, "Successfully closed DAHDI line (and its D-channel)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct isdntap_driver dahdi_driver = {
|
const struct isdntap_driver dahdi_driver = {
|
||||||
|
|
Loading…
Reference in New Issue