[M] Change in osmo-hlr[master]: gsup_client: Add new APIs to avoid users accessing struct fields

2024-12-04 Thread pespin
Attention is currently required from: pespin.

Hello Jenkins Builder, fixeria, laforge, osmith,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: gsup_client: Add new APIs to avoid users accessing struct fields
..

gsup_client: Add new APIs to avoid users accessing struct fields

This is a first step towards changing gsup_client implementation to use
an osmo_stream_cli instead of libosmo-abis' ipa_client_conn.
The libosmo-abis' ipa_client_conn will eventually be deprecated together
with all IPA related code in libosmo-abis.

In order to be able to make the implementation change, we first need to
make sure no users are using the struct fields of gsup_client (this
patch); 2nd step will be making the struct private by moving it to a
private header; 3rd step will be changing the implementation to use
osmo_stream.

Related: OS#5896
Change-Id: I401af83232022f1c141eef1f428cbe206a82
---
M TODO-RELEASE
M include/osmocom/gsupclient/gsup_client.h
M src/gsupclient/gsup_client.c
M src/gsupclient/gsup_client_mux.c
M src/remote_hlr.c
5 files changed, 59 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/09/39009/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I401af83232022f1c141eef1f428cbe206a82
Gerrit-Change-Number: 39009
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Attention: pespin 


[M] Change in osmo-hlr[master]: gsup_client: Add new APIs to avoid users accessing struct fields

2024-12-04 Thread pespin
pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: gsup_client: Add new APIs to avoid users accessing struct 
fields
..

gsup_client: Add new APIs to avoid users accessing struct fields

This is a first step towards changing gsup_client implementation to use
an osmo_stream_cli instead of libosmo-abis' ipa_client_conn.
The libosmo-abis' ipa_client_conn will eventually be deprecated together
with all IPA related code in libosmo-abis.

In order to be able to make the implementation change, we first need to
make sure no users are using the struct fields of gsup_client (this
patch); 2nd step will be making the struct private by moving it to a
private header; 3rd step will be changing the implementation to use
osmo_stream.

Related: OS#5896
Change-Id: I401af83232022f1c141eef1f428cbe206a82
---
M TODO-RELEASE
M include/osmocom/gsupclient/gsup_client.h
M src/gsupclient/gsup_client.c
M src/gsupclient/gsup_client_mux.c
M src/remote_hlr.c
5 files changed, 59 insertions(+), 8 deletions(-)

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




diff --git a/TODO-RELEASE b/TODO-RELEASE
index 0ed7189..f14e8b5 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,6 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
+libosmo-gsup-client new API osmo_gsup_client_{get,set}_data(),
+osmo_gsup_client_get_rem_addr(), 
osmo_gsup_client_get_rem_port(),
+osmo_gsup_client_is_connected(), 
osmo_gsup_client_get_ipaccess_unit()
\ No newline at end of file
diff --git a/include/osmocom/gsupclient/gsup_client.h 
b/include/osmocom/gsupclient/gsup_client.h
index ea66ca1..61cd45d 100644
--- a/include/osmocom/gsupclient/gsup_client.h
+++ b/include/osmocom/gsupclient/gsup_client.h
@@ -20,6 +20,9 @@
  */
 #pragma once

+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -40,6 +43,7 @@

 typedef bool (*osmo_gsup_client_up_down_cb_t)(struct osmo_gsup_client *gsupc, 
bool up);

+/* NOTE: THIS STRUCT IS CONSIDERED PRIVATE, AVOID ACCESSING ITS FIELDS! */
 struct osmo_gsup_client {
const char *unit_name; /* same as ipa_dev->unit_name, for backwards 
compat */

@@ -99,3 +103,12 @@
  const struct osmo_gsup_message *gsup_msg);
 struct msgb *osmo_gsup_client_msgb_alloc(void);

+void *osmo_gsup_client_get_data(const struct osmo_gsup_client *gsupc);
+void osmo_gsup_client_set_data(struct osmo_gsup_client *gsupc, void *data);
+
+const char *osmo_gsup_client_get_rem_addr(const struct osmo_gsup_client 
*gsupc);
+uint16_t osmo_gsup_client_get_rem_port(const struct osmo_gsup_client *gsupc);
+
+bool osmo_gsup_client_is_connected(const struct osmo_gsup_client *gsupc);
+const struct ipaccess_unit *osmo_gsup_client_get_ipaccess_unit(const struct 
osmo_gsup_client *gsupc);
+
diff --git a/src/gsupclient/gsup_client.c b/src/gsupclient/gsup_client.c
index e7d03f2..1168c9d 100644
--- a/src/gsupclient/gsup_client.c
+++ b/src/gsupclient/gsup_client.c
@@ -450,3 +450,36 @@
 {
return msgb_alloc_headroom(4000, 64, __func__);
 }
+
+void *osmo_gsup_client_get_data(const struct osmo_gsup_client *gsupc)
+{
+   return gsupc->data;
+}
+
+void osmo_gsup_client_set_data(struct osmo_gsup_client *gsupc, void *data)
+{
+   gsupc->data = data;
+}
+
+const char *osmo_gsup_client_get_rem_addr(const struct osmo_gsup_client *gsupc)
+{
+   if (!gsupc->link)
+   return NULL;
+   return gsupc->link->addr;
+}
+uint16_t osmo_gsup_client_get_rem_port(const struct osmo_gsup_client *gsupc)
+{
+   if (!gsupc->link)
+   return 0;
+   return gsupc->link->port;
+}
+
+bool osmo_gsup_client_is_connected(const struct osmo_gsup_client *gsupc)
+{
+   return gsupc->is_connected;
+}
+
+const struct ipaccess_unit *osmo_gsup_client_get_ipaccess_unit(const struct 
osmo_gsup_client *gsupc)
+{
+   return gsupc->ipa_dev;
+}
diff --git a/src/gsupclient/gsup_client_mux.c b/src/gsupclient/gsup_client_mux.c
index 7699ca1..45ebd75 100644
--- a/src/gsupclient/gsup_client_mux.c
+++ b/src/gsupclient/gsup_client_mux.c
@@ -58,7 +58,7 @@
 /* Non-static for unit tests */
 int gsup_client_mux_rx(struct osmo_gsup_client *gsup_client, struct msgb *msg)
 {
-   struct gsup_client_mux *gcm = gsup_client->data;
+   struct gsup_client_mux *gcm = osmo_gsup_client_get_data(gsup_client);
struct osmo_gsup_message gsup;
enum osmo_gsup_message_class message_class;
  

[M] Change in osmo-hlr[master]: gsup_client: Add new APIs to avoid users accessing struct fields

2024-12-04 Thread fixeria
Attention is currently required from: pespin.

fixeria has posted comments on this change by pespin. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email )

Change subject: gsup_client: Add new APIs to avoid users accessing struct fields
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I401af83232022f1c141eef1f428cbe206a82
Gerrit-Change-Number: 39009
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Attention: pespin 
Gerrit-Comment-Date: Wed, 04 Dec 2024 11:28:22 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes


[M] Change in osmo-hlr[master]: gsup_client: Add new APIs to avoid users accessing struct fields

2024-12-04 Thread osmith
Attention is currently required from: pespin.

osmith has posted comments on this change by pespin. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email )

Change subject: gsup_client: Add new APIs to avoid users accessing struct fields
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I401af83232022f1c141eef1f428cbe206a82
Gerrit-Change-Number: 39009
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Attention: pespin 
Gerrit-Comment-Date: Wed, 04 Dec 2024 09:29:20 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes


[M] Change in osmo-hlr[master]: gsup_client: Add new APIs to avoid users accessing struct fields

2024-12-03 Thread laforge
Attention is currently required from: pespin.

laforge has posted comments on this change by pespin. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email )

Change subject: gsup_client: Add new APIs to avoid users accessing struct fields
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I401af83232022f1c141eef1f428cbe206a82
Gerrit-Change-Number: 39009
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Attention: pespin 
Gerrit-Comment-Date: Tue, 03 Dec 2024 22:13:01 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes


[M] Change in osmo-hlr[master]: gsup_client: Add new APIs to avoid users accessing struct fields

2024-12-03 Thread pespin
pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/39009?usp=email )


Change subject: gsup_client: Add new APIs to avoid users accessing struct fields
..

gsup_client: Add new APIs to avoid users accessing struct fields

This is a first step towards changing gsup_client implementation to use
an osmo_stream_cli instead of libosmo-abis' ipa_client_conn.
The libosmo-abis' ipa_client_conn will eventually be deprecated together
with all IPA related code in libosmo-abis.

In order to be able to make the implementation change, we first need to
make sure no users are using the struct fields of gsup_client (this
patch); 2nd step will be making the struct private by moving it to a
private header; 3rd step will be changing the implementation to use
osmo_stream.

Related: OS#5896
Change-Id: I401af83232022f1c141eef1f428cbe206a82
---
M TODO-RELEASE
M include/osmocom/gsupclient/gsup_client.h
M src/gsupclient/gsup_client.c
M src/gsupclient/gsup_client_mux.c
M src/remote_hlr.c
5 files changed, 59 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/09/39009/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 0ed7189..f14e8b5 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,6 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
+libosmo-gsup-client new API osmo_gsup_client_{get,set}_data(),
+osmo_gsup_client_get_rem_addr(), 
osmo_gsup_client_get_rem_port(),
+osmo_gsup_client_is_connected(), 
osmo_gsup_client_get_ipaccess_unit()
\ No newline at end of file
diff --git a/include/osmocom/gsupclient/gsup_client.h 
b/include/osmocom/gsupclient/gsup_client.h
index ea66ca1..61cd45d 100644
--- a/include/osmocom/gsupclient/gsup_client.h
+++ b/include/osmocom/gsupclient/gsup_client.h
@@ -20,6 +20,9 @@
  */
 #pragma once

+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -40,6 +43,7 @@

 typedef bool (*osmo_gsup_client_up_down_cb_t)(struct osmo_gsup_client *gsupc, 
bool up);

+/* NOTE: THIS STRUCT IS CONSIDERED PRIVATE, AVOID ACCESSING ITS FIELDS! */
 struct osmo_gsup_client {
const char *unit_name; /* same as ipa_dev->unit_name, for backwards 
compat */

@@ -99,3 +103,12 @@
  const struct osmo_gsup_message *gsup_msg);
 struct msgb *osmo_gsup_client_msgb_alloc(void);

+void *osmo_gsup_client_get_data(const struct osmo_gsup_client *gsupc);
+void osmo_gsup_client_set_data(struct osmo_gsup_client *gsupc, void *data);
+
+const char *osmo_gsup_client_get_rem_addr(const struct osmo_gsup_client 
*gsupc);
+uint16_t osmo_gsup_client_get_rem_port(const struct osmo_gsup_client *gsupc);
+
+bool osmo_gsup_client_is_connected(const struct osmo_gsup_client *gsupc);
+const struct ipaccess_unit *osmo_gsup_client_get_ipaccess_unit(const struct 
osmo_gsup_client *gsupc);
+
diff --git a/src/gsupclient/gsup_client.c b/src/gsupclient/gsup_client.c
index 36407d5..eb36e3f 100644
--- a/src/gsupclient/gsup_client.c
+++ b/src/gsupclient/gsup_client.c
@@ -448,3 +448,36 @@
 {
return msgb_alloc_headroom(4000, 64, __func__);
 }
+
+void *osmo_gsup_client_get_data(const struct osmo_gsup_client *gsupc)
+{
+   return gsupc->data;
+}
+
+void osmo_gsup_client_set_data(struct osmo_gsup_client *gsupc, void *data)
+{
+   gsupc->data = data;
+}
+
+const char *osmo_gsup_client_get_rem_addr(const struct osmo_gsup_client *gsupc)
+{
+   if (!gsupc->link)
+   return NULL;
+   return gsupc->link->addr;
+}
+uint16_t osmo_gsup_client_get_rem_port(const struct osmo_gsup_client *gsupc)
+{
+   if (!gsupc->link)
+   return 0;
+   return gsupc->link->port;
+}
+
+bool osmo_gsup_client_is_connected(const struct osmo_gsup_client *gsupc)
+{
+   return gsupc->is_connected;
+}
+
+const struct ipaccess_unit *osmo_gsup_client_get_ipaccess_unit(const struct 
osmo_gsup_client *gsupc)
+{
+   return gsupc->ipa_dev;
+}
diff --git a/src/gsupclient/gsup_client_mux.c b/src/gsupclient/gsup_client_mux.c
index 7699ca1..45ebd75 100644
--- a/src/gsupclient/gsup_client_mux.c
+++ b/src/gsupclient/gsup_client_mux.c
@@ -58,7 +58,7 @@
 /* Non-static for unit tests */
 int gsup_client_mux_rx(struct osmo_gsup_client *gsup_client, struct msgb *msg)
 {
-   struct gsup_client_mux *gcm = gsup_client->data;
+   struct gsup_client_mux *gcm = osmo_gsup_client_get_data(gsup_client);
struct osmo_gsup_message gsup;
enum osmo_gsup_message_class message_class;
int rc;
@@ -115,7 +115,7 @@
&gsup_client_mux_rx, NULL);
if (!gcm->gsup_client)
return -ENOMEM;
-   gcm->gsup_client->data = gcm;
+   osmo_gsup_client_