rename 'driver' to 'drvdata'
... so we can have a 'driver' member pointing to the actual driver
This commit is contained in:
parent
ba1a40cc9a
commit
78914bc8a7
76
src/dahdi.c
76
src/dahdi.c
|
@ -162,57 +162,57 @@ static int open_line_dahdi(struct isdntap_line *line)
|
|||
int rc;
|
||||
|
||||
/* make sure we have a span number */
|
||||
if (line->driver.dahdi.spanno < 0) {
|
||||
if (!line->driver.dahdi.name)
|
||||
if (line->drvdata.dahdi.spanno < 0) {
|
||||
if (!line->drvdata.dahdi.name)
|
||||
return -1;
|
||||
line->driver.dahdi.spanno = get_span_no_by_name(line->driver.dahdi.name);
|
||||
line->drvdata.dahdi.spanno = get_span_no_by_name(line->drvdata.dahdi.name);
|
||||
}
|
||||
if (line->driver.dahdi.spanno < 0)
|
||||
if (line->drvdata.dahdi.spanno < 0)
|
||||
return -1;
|
||||
|
||||
/* resolve the base channel number */
|
||||
rc = get_span_sysfs_int(line->driver.dahdi.spanno, "basechan");
|
||||
rc = get_span_sysfs_int(line->drvdata.dahdi.spanno, "basechan");
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
line->driver.dahdi.basechan = rc;
|
||||
line->drvdata.dahdi.basechan = rc;
|
||||
|
||||
/* resolve the numberof channels */
|
||||
rc = get_span_sysfs_int(line->driver.dahdi.spanno, "channels");
|
||||
rc = get_span_sysfs_int(line->drvdata.dahdi.spanno, "channels");
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
line->driver.dahdi.channels = rc;
|
||||
line->drvdata.dahdi.channels = rc;
|
||||
|
||||
/* obtain the span type */
|
||||
spantype = get_span_sysfs_str(line->driver.dahdi.spanno, "spantype");
|
||||
spantype = get_span_sysfs_str(line->drvdata.dahdi.spanno, "spantype");
|
||||
if (!spantype)
|
||||
return -1;
|
||||
line->driver.dahdi.spantype = talloc_strdup(line, spantype);
|
||||
line->drvdata.dahdi.spantype = talloc_strdup(line, spantype);
|
||||
free(spantype);
|
||||
|
||||
/* note the DAHDI channel number for each timeslot */
|
||||
for (int i = 0; i < line->driver.dahdi.channels; i++) {
|
||||
for (int i = 0; i < line->drvdata.dahdi.channels; i++) {
|
||||
/* FIXME: the below is very E1-specific */
|
||||
struct isdntap_ts *ts = &line->ts[1+i];
|
||||
ts->driver.dahdi.channo = line->driver.dahdi.basechan + i;
|
||||
ts->drvdata.dahdi.channo = line->drvdata.dahdi.basechan + i;
|
||||
}
|
||||
sig_ts = &line->ts[16]; // FIXME: configurable
|
||||
|
||||
rc = make_mirror(DAHDI_RXMIRROR, sig_ts->driver.dahdi.channo);
|
||||
rc = make_mirror(DAHDI_RXMIRROR, sig_ts->drvdata.dahdi.channo);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
/* verify HDLC mode? */
|
||||
osmo_fd_setup(&sig_ts->driver.dahdi.rx, rc, OSMO_FD_READ, dahdi_dchan_fd_cb, sig_ts, 1);
|
||||
osmo_fd_register(&sig_ts->driver.dahdi.rx);
|
||||
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->driver.dahdi.channo);
|
||||
rc = make_mirror(DAHDI_TXMIRROR, sig_ts->drvdata.dahdi.channo);
|
||||
if (rc < 0) {
|
||||
close(sig_ts->driver.dahdi.rx.fd);
|
||||
sig_ts->driver.dahdi.rx.fd = -1;
|
||||
close(sig_ts->drvdata.dahdi.rx.fd);
|
||||
sig_ts->drvdata.dahdi.rx.fd = -1;
|
||||
return rc;
|
||||
}
|
||||
/* verify HDLC mode? */
|
||||
osmo_fd_setup(&sig_ts->driver.dahdi.tx, rc, OSMO_FD_READ, dahdi_dchan_fd_cb, sig_ts, 2);
|
||||
osmo_fd_register(&sig_ts->driver.dahdi.tx);
|
||||
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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -221,43 +221,43 @@ static int open_ts_dahdi(struct isdntap_ts *ts)
|
|||
{
|
||||
int rc;
|
||||
|
||||
rc = make_mirror(DAHDI_RXMIRROR, ts->driver.dahdi.channo);
|
||||
rc = make_mirror(DAHDI_RXMIRROR, ts->drvdata.dahdi.channo);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
osmo_fd_setup(&ts->driver.dahdi.rx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 1);
|
||||
osmo_fd_register(&ts->driver.dahdi.rx);
|
||||
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->driver.dahdi.channo);
|
||||
rc = make_mirror(DAHDI_TXMIRROR, ts->drvdata.dahdi.channo);
|
||||
if (rc < 0) {
|
||||
osmo_fd_unregister(&ts->driver.dahdi.rx);
|
||||
close(ts->driver.dahdi.rx.fd);
|
||||
ts->driver.dahdi.rx.fd = -1;
|
||||
osmo_fd_unregister(&ts->drvdata.dahdi.rx);
|
||||
close(ts->drvdata.dahdi.rx.fd);
|
||||
ts->drvdata.dahdi.rx.fd = -1;
|
||||
return rc;
|
||||
}
|
||||
osmo_fd_setup(&ts->driver.dahdi.tx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 2);
|
||||
osmo_fd_register(&ts->driver.dahdi.tx);
|
||||
osmo_fd_setup(&ts->drvdata.dahdi.tx, rc, OSMO_FD_READ, dahdi_bchan_fd_cb, ts, 2);
|
||||
osmo_fd_register(&ts->drvdata.dahdi.tx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void close_ts_dahdi(struct isdntap_ts *ts)
|
||||
{
|
||||
if (ts->driver.dahdi.rx.fd >= 0) {
|
||||
osmo_fd_unregister(&ts->driver.dahdi.rx);
|
||||
close(ts->driver.dahdi.rx.fd);
|
||||
ts->driver.dahdi.rx.fd = -1;
|
||||
if (ts->drvdata.dahdi.rx.fd >= 0) {
|
||||
osmo_fd_unregister(&ts->drvdata.dahdi.rx);
|
||||
close(ts->drvdata.dahdi.rx.fd);
|
||||
ts->drvdata.dahdi.rx.fd = -1;
|
||||
}
|
||||
if (ts->driver.dahdi.tx.fd >= 0) {
|
||||
osmo_fd_unregister(&ts->driver.dahdi.tx);
|
||||
close(ts->driver.dahdi.tx.fd);
|
||||
ts->driver.dahdi.tx.fd = -1;
|
||||
if (ts->drvdata.dahdi.tx.fd >= 0) {
|
||||
osmo_fd_unregister(&ts->drvdata.dahdi.tx);
|
||||
close(ts->drvdata.dahdi.tx.fd);
|
||||
ts->drvdata.dahdi.tx.fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void close_line_dahdi(struct isdntap_line *line)
|
||||
{
|
||||
/* close all file descriptors on all timeslots */
|
||||
for (int i = 0; i < line->driver.dahdi.channels; i++) {
|
||||
for (int i = 0; i < line->drvdata.dahdi.channels; i++) {
|
||||
/* FIXME: the below is very E1-specific */
|
||||
struct isdntap_ts *ts = &line->ts[1+i];
|
||||
close_ts_dahdi(ts);
|
||||
|
|
|
@ -52,9 +52,9 @@ struct isdntap_line *isdntap_line_new(struct isdntap_instance *itd, const char *
|
|||
ts->gsmtap_subtype = GSMTAP_E1T1_LAPD;
|
||||
osmo_isdnhdlc_rcv_init(&ts->hdlc.state[0].vars, 0);
|
||||
osmo_isdnhdlc_rcv_init(&ts->hdlc.state[1].vars, 0);
|
||||
ts->driver.dahdi.rx.fd = -1;
|
||||
ts->driver.dahdi.tx.fd = -1;
|
||||
ts->driver.dahdi.channo = -1;
|
||||
ts->drvdata.dahdi.rx.fd = -1;
|
||||
ts->drvdata.dahdi.tx.fd = -1;
|
||||
ts->drvdata.dahdi.channo = -1;
|
||||
}
|
||||
|
||||
llist_add_tail(&line->list, &itd->lines);
|
||||
|
|
|
@ -54,7 +54,7 @@ struct isdntap_ts {
|
|||
struct osmo_fd tx; /* TX-mirror file descriptor */
|
||||
int channo; /* DAHDI channel number for this TS */
|
||||
} dahdi;
|
||||
} driver;
|
||||
} drvdata;
|
||||
|
||||
union {
|
||||
struct {
|
||||
|
@ -92,7 +92,7 @@ struct isdntap_line {
|
|||
int basechan;
|
||||
int channels;
|
||||
} dahdi;
|
||||
} driver;
|
||||
} drvdata;
|
||||
};
|
||||
|
||||
struct isdntap_driver {
|
||||
|
|
|
@ -59,9 +59,9 @@ static void vty_dump_line(struct vty *vty, const struct isdntap_line *line)
|
|||
if (1) {
|
||||
vty_out(vty, " Driver: DAHDI, span_name=%s, span_type=%s, span_no=%d, "
|
||||
"basechan=%d, channels=%d%s",
|
||||
line->driver.dahdi.name, line->driver.dahdi.spantype,
|
||||
line->driver.dahdi.spanno, line->driver.dahdi.basechan,
|
||||
line->driver.dahdi.channels, VTY_NEWLINE);
|
||||
line->drvdata.dahdi.name, line->drvdata.dahdi.spantype,
|
||||
line->drvdata.dahdi.spanno, line->drvdata.dahdi.basechan,
|
||||
line->drvdata.dahdi.channels, VTY_NEWLINE);
|
||||
}
|
||||
|
||||
//vty_out_rate_ctr_group(vty, " ", line->ctrs);
|
||||
|
|
Loading…
Reference in New Issue