From 90f9edc2dc12803ea094ac19f5067be7474e0ab8 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 16 Oct 2022 18:46:29 +0200 Subject: [PATCH] dahdi: lots more logging --- src/dahdi.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/dahdi.c b/src/dahdi.c index b6088f6..956dbfa 100644 --- a/src/dahdi.c +++ b/src/dahdi.c @@ -14,6 +14,7 @@ #include #include "isdntap.h" +#include "log.h" #define BLOCK_SIZE 512 @@ -163,29 +164,39 @@ static int open_line_dahdi(struct isdntap_line *line) /* make sure we have a span number */ 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; + } 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; + } /* resolve the base channel number */ 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; + } line->drvdata.dahdi.basechan = rc; /* resolve the numberof 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; + } line->drvdata.dahdi.channels = rc; /* obtain the span type */ 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; + } line->drvdata.dahdi.spantype = talloc_strdup(line, spantype); free(spantype); @@ -198,14 +209,19 @@ static int open_line_dahdi(struct isdntap_line *line) sig_ts = &line->ts[16]; // FIXME: configurable 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; + } /* verify HDLC mode? */ 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); rc = make_mirror(DAHDI_TXMIRROR, sig_ts->drvdata.dahdi.channo); 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); sig_ts->drvdata.dahdi.rx.fd = -1; 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_register(&sig_ts->drvdata.dahdi.tx); + LOGPLI(line, DLINP, LOGL_NOTICE, "Successfully opened DAHDI line (and its D-channel)\n"); + return 0; } @@ -222,13 +240,18 @@ static int open_ts_dahdi(struct isdntap_ts *ts) int rc; 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; + } osmo_fd_setup(&ts->drvdata.dahdi.rx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 1); osmo_fd_register(&ts->drvdata.dahdi.rx); rc = make_mirror(DAHDI_TXMIRROR, ts->drvdata.dahdi.channo); 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); close(ts->drvdata.dahdi.rx.fd); 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_register(&ts->drvdata.dahdi.tx); + LOGPTS(ts, DLINP, LOGL_INFO, "Successfully opened DAHDI timeslot (B-channel)\n"); + return 0; } @@ -252,6 +277,7 @@ static void close_ts_dahdi(struct isdntap_ts *ts) close(ts->drvdata.dahdi.tx.fd); 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) @@ -262,6 +288,7 @@ static void close_line_dahdi(struct isdntap_line *line) struct isdntap_ts *ts = &line->ts[1+i]; close_ts_dahdi(ts); } + LOGPLI(line, DLINP, LOGL_INFO, "Successfully closed DAHDI line (and its D-channel)\n"); } const struct isdntap_driver dahdi_driver = {