aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-06-29 07:49:12 +0200
committerHarald Welte <laforge@osmocom.org>2020-06-29 22:12:42 +0200
commit0f41cb0e06f15e31e451d2919e54ade8cb0eab74 (patch)
treef4d6f99269d427caa3c6ec19f6524c485451fa79
parent65b22c0b7588c5b89491db6b86264461e07bffd7 (diff)
add e1_line_destroy() / e1_intf_destroy() functions
-rw-r--r--src/e1d.h6
-rw-r--r--src/intf_line.c29
2 files changed, 35 insertions, 0 deletions
diff --git a/src/e1d.h b/src/e1d.h
index a5076b0..7803b2e 100644
--- a/src/e1d.h
+++ b/src/e1d.h
@@ -94,9 +94,15 @@ e1_intf_new(struct e1_daemon *e1d, void *drv_data);
struct e1_intf *
e1d_find_intf(struct e1_daemon *e1d, uint8_t id);
+void
+e1_intf_destroy(struct e1_intf *intf);
+
struct e1_line *
e1_line_new(struct e1_intf *intf, void *drv_data);
+void
+e1_line_destroy(struct e1_line *line);
+
int
e1_line_mux_out(struct e1_line *line, uint8_t *buf, int fts);
diff --git a/src/intf_line.c b/src/intf_line.c
index a879922..9118232 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -67,6 +67,21 @@ e1_intf_new(struct e1_daemon *e1d, void *drv_data)
return intf;
}
+void
+e1_intf_destroy(struct e1_intf *intf)
+{
+ struct e1_line *line, *line2;
+
+ /* destroy all lines */
+ llist_for_each_entry_safe(line, line2, &intf->lines, list)
+ e1_line_destroy(line);
+
+ /* remove from global list of interfaces */
+ llist_del(&intf->list);
+
+ talloc_free(intf);
+}
+
struct e1_line *
e1_line_new(struct e1_intf *intf, void *drv_data)
{
@@ -95,6 +110,20 @@ e1_line_new(struct e1_intf *intf, void *drv_data)
return line;
}
+void
+e1_line_destroy(struct e1_line *line)
+{
+ /* close all [peer] file descriptors */
+ for (int i=0; i<32; i++)
+ e1_ts_stop(&line->ts[i]);
+
+ /* remove from per-interface list of lines */
+ llist_del(&line->list);
+
+ talloc_free(line);
+}
+
+
// ---------------------------------------------------------------------------
// data transfer
// ---------------------------------------------------------------------------