pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/30210 )

Change subject: osmux: Introduce API osmux_xfrm_input_set_name()
......................................................................

osmux: Introduce API osmux_xfrm_input_set_name()

This will be used internally by osmux code to print more meaningful
lines.

Related: SYS#6161
Change-Id: Ibbcfdb23a6015ce45840bb64b2b560c2806f7ff6
---
M include/osmocom/netif/osmux.h
M src/osmux_input.c
M tests/osmux/osmux_test.c
M tests/osmux/osmux_test.ok
4 files changed, 19 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  msuraev: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved



diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h
index b6014d5..bc00942 100644
--- a/include/osmocom/netif/osmux.h
+++ b/include/osmocom/netif/osmux.h
@@ -107,6 +107,7 @@
 struct osmux_in_handle *osmux_xfrm_input_alloc(void *ctx);
 void osmux_xfrm_input_init(struct osmux_in_handle *h) OSMO_DEPRECATED("Use 
osmux_xfrm_input_alloc() instead");
 void osmux_xfrm_input_fini(struct osmux_in_handle *h) OSMO_DEPRECATED("Use 
talloc_free() instead");
+void osmux_xfrm_input_set_name(struct osmux_in_handle *h, const char *name);
 int osmux_xfrm_input_set_batch_factor(struct osmux_in_handle *h, uint8_t 
batch_factor);
 void osmux_xfrm_input_set_batch_size(struct osmux_in_handle *h, uint16_t 
batch_size);
 void osmux_xfrm_input_set_initial_seqnum(struct osmux_in_handle *h, uint8_t 
osmux_seqnum);
diff --git a/src/osmux_input.c b/src/osmux_input.c
index 980c2a7..8de3f7c 100644
--- a/src/osmux_input.c
+++ b/src/osmux_input.c
@@ -75,6 +75,7 @@
        unsigned int            remaining_bytes;
        uint32_t                nmsgs;
        int                     ndummy;
+       char                    *name;
        struct osmux_in_handle *h; /* backpointer to parent object */
 };

@@ -686,6 +687,7 @@
  * stack outgoing network Osmux messages.
  * Returned pointer can be freed with regular talloc_free, all pending messages
  * in queue and all internal data will be freed. */
+static unsigned int next_default_name_idx = 0;
 struct osmux_in_handle *osmux_xfrm_input_alloc(void *ctx)
 {
        struct osmux_in_handle *h;
@@ -701,11 +703,13 @@
        INIT_LLIST_HEAD(&link->circuit_list);
        link->h = h;
        link->remaining_bytes = h->batch_size;
+       link->name = talloc_asprintf(link, "input-%u", next_default_name_idx++);
        osmo_timer_setup(&link->timer, osmux_link_timer_expired, h);

        h->internal_data = (void *)link;

-       LOGP(DLMUX, LOGL_DEBUG, "initialized osmux input converter\n");
+       LOGP(DLMUX, LOGL_DEBUG, "[%s] Initialized osmux input converter\n",
+            link->name);

        talloc_set_destructor(h, osmux_xfrm_input_talloc_destructor);
        return h;
@@ -726,11 +730,13 @@
        INIT_LLIST_HEAD(&link->circuit_list);
        link->h = h;
        link->remaining_bytes = h->batch_size;
+       link->name = talloc_asprintf(link, "%u", next_default_name_idx++);
        osmo_timer_setup(&link->timer, osmux_link_timer_expired, h);

        h->internal_data = (void *)link;

-       LOGP(DLMUX, LOGL_DEBUG, "initialized osmux input converter\n");
+       LOGP(DLMUX, LOGL_DEBUG, "[%s] Initialized osmux input converter\n",
+            link->name);
 }

 int osmux_xfrm_input_set_batch_factor(struct osmux_in_handle *h, uint8_t 
batch_factor)
@@ -766,6 +772,12 @@
        return h->data;
 }

+void osmux_xfrm_input_set_name(struct osmux_in_handle *h, const char *name)
+{
+       struct osmux_link *link = (struct osmux_link *)h->internal_data;
+       osmo_talloc_replace_string(link, &link->name, name);
+}
+
 int osmux_xfrm_input_open_circuit(struct osmux_in_handle *h, int ccid,
                                  int dummy)
 {
diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c
index 8edb3fd..f80902d 100644
--- a/tests/osmux/osmux_test.c
+++ b/tests/osmux/osmux_test.c
@@ -277,6 +277,7 @@

        /* Check if marker bit features work correctly */
        h_input = osmux_xfrm_input_alloc(tall_ctx);
+       osmux_xfrm_input_set_name(h_input, "first");
        osmux_xfrm_input_set_initial_seqnum(h_input, 0);
        osmux_xfrm_input_set_batch_factor(h_input, 4);
        osmux_xfrm_input_set_deliver_cb(h_input, osmux_deliver, NULL);
@@ -289,6 +290,7 @@
        TALLOC_FREE(h_input);

        h_input = osmux_xfrm_input_alloc(tall_ctx);
+       osmux_xfrm_input_set_name(h_input, "second");
        osmux_xfrm_input_set_initial_seqnum(h_input, 0);
        osmux_xfrm_input_set_batch_factor(h_input, 4);
        osmux_xfrm_input_set_deliver_cb(h_input, osmux_deliver, NULL);
diff --git a/tests/osmux/osmux_test.ok b/tests/osmux/osmux_test.ok
index 3b38cb5..37aea43 100644
--- a/tests/osmux/osmux_test.ok
+++ b/tests/osmux/osmux_test.ok
@@ -1,4 +1,4 @@
-DLMUX initialized osmux input converter
+DLMUX [input-0] Initialized osmux input converter
 sys={23.444242}, mono={0.020000}: clock_override_add
 sys={23.464242}, mono={0.040000}: clock_override_add
 sys={23.484242}, mono={0.060000}: clock_override_add
@@ -358,7 +358,7 @@
 sys={26.704242}, mono={3.280000}: extracted packet: RTP ver=2 ssrc=117440512 
type=98 marker=0 ext=0 csrc_count=0 sequence=9219 timestamp=1681702537 [20 14 
ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]
 sys={26.704242}, mono={3.280000}: extracted packet: RTP ver=2 ssrc=117440512 
type=98 marker=0 ext=0 csrc_count=0 sequence=9220 timestamp=1681702697 [20 14 
ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]
 sys={26.704242}, mono={3.280000}: extracted packet: RTP ver=2 ssrc=117440512 
type=98 marker=1 ext=0 csrc_count=0 sequence=9221 timestamp=1681702857 [20 14 
ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]
-DLMUX initialized osmux input converter
+DLMUX [input-1] Initialized osmux input converter
 sys={26.704242}, mono={3.280000}: adding to ccid=1 RTP ver=2 ssrc=118030434 
type=98 marker=1 ext=0 csrc_count=0 sequence=16396 timestamp=108399 [20 14 ff 
d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]
 sys={26.704242}, mono={3.280000}: adding to ccid=0 RTP ver=2 ssrc=118030434 
type=98 marker=1 ext=0 csrc_count=0 sequence=16397 timestamp=108399 [20 14 ff 
d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]
 sys={26.704242}, mono={3.280000}: adding to ccid=1 RTP ver=2 ssrc=118030434 
type=98 marker=0 ext=0 csrc_count=0 sequence=16398 timestamp=108399 [20 14 ff 
d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/30210
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ibbcfdb23a6015ce45840bb64b2b560c2806f7ff6
Gerrit-Change-Number: 30210
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: msuraev <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-CC: osmith <[email protected]>
Gerrit-MessageType: merged

Reply via email to