aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/netif/osmux.h2
-rw-r--r--src/osmux.c27
2 files changed, 24 insertions, 5 deletions
diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h
index 0f6f5c9..14c967f 100644
--- a/include/osmocom/netif/osmux.h
+++ b/include/osmocom/netif/osmux.h
@@ -84,6 +84,8 @@ int osmux_snprintf(char *buf, size_t size, struct msgb *msg);
void osmux_xfrm_input_init(struct osmux_in_handle *h);
void osmux_xfrm_input_fini(struct osmux_in_handle *h);
+void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid);
+
int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid);
void osmux_xfrm_input_deliver(struct osmux_in_handle *h);
diff --git a/src/osmux.c b/src/osmux.c
index 82ec56e..4451b5a 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -289,7 +289,7 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch,
uint32_t batch_size)
{
struct msgb *batch_msg;
- struct osmux_circuit *circuit, *next;
+ struct osmux_circuit *circuit;
#ifdef DEBUG_MSG
LOGP(DLMIB, LOGL_DEBUG, "Now building batch\n");
@@ -301,7 +301,7 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch,
return NULL;
}
- llist_for_each_entry_safe(circuit, next, &batch->circuit_list, head) {
+ llist_for_each_entry(circuit, &batch->circuit_list, head) {
struct msgb *cur, *tmp;
int ctr = 0;
@@ -336,8 +336,6 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch,
ctr++;
batch->nmsgs--;
}
- llist_del(&circuit->head);
- talloc_free(circuit);
}
return batch_msg;
}
@@ -487,6 +485,18 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid)
return circuit;
}
+static void osmux_batch_del_circuit(struct osmux_batch *batch, int ccid)
+{
+ struct osmux_circuit *circuit;
+
+ circuit = osmux_batch_find_circuit(batch, ccid);
+ if (circuit == NULL)
+ return;
+
+ llist_del(&circuit->head);
+ talloc_free(circuit);
+}
+
static int
osmux_batch_add(struct osmux_batch *batch, int batch_factor, struct msgb *msg,
struct rtp_hdr *rtph, int ccid)
@@ -502,7 +512,7 @@ osmux_batch_add(struct osmux_batch *batch, int batch_factor, struct msgb *msg,
/* First check if there is room for this message in the batch */
bytes += amr_payload_len;
- if (!circuit)
+ if (!circuit || circuit->nmsgs == 0)
bytes += sizeof(struct osmux_hdr);
/* No room, sorry. You'll have to retry */
@@ -645,6 +655,13 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h)
LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n");
}
+void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid)
+{
+ struct osmux_batch *batch = (struct osmux_batch *)h->internal_data;
+
+ osmux_batch_del_circuit(batch, ccid);
+}
+
void osmux_xfrm_input_fini(struct osmux_in_handle *h)
{
struct osmux_batch *batch = (struct osmux_batch *)h->internal_data;