pespin has uploaded this change for review. ( 
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.ok
3 files changed, 16 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/10/30210/1

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..65a1532 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 */
 };

@@ -701,11 +702,13 @@
        INIT_LLIST_HEAD(&link->circuit_list);
        link->h = h;
        link->remaining_bytes = h->batch_size;
+       link->name = talloc_asprintf(link, "%p", h);
        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 +729,13 @@
        INIT_LLIST_HEAD(&link->circuit_list);
        link->h = h;
        link->remaining_bytes = h->batch_size;
+       link->name = talloc_asprintf(link, "%p", h);
        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 +771,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.ok b/tests/osmux/osmux_test.ok
index 3b38cb5..18aa556 100644
--- a/tests/osmux/osmux_test.ok
+++ b/tests/osmux/osmux_test.ok
@@ -1,4 +1,4 @@
-DLMUX initialized osmux input converter
+DLMUX [0x60e000023500] 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 [0x60e000023960] 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: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to