[M] Change in libosmo-netif[master]: stream: Define types for each API callback
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36581?usp=email ) Change subject: stream: Define types for each API callback .. stream: Define types for each API callback The amount and complexity of callbacks is increasing over time. Use typedefs to define each of them so that callbacks: - Are easier to identify (which types is used where) - Are easier to document (have a 1st class place to write doxygen documentation) Change-Id: Ib0c4a9713fa4c755e457b8c2cbde6a7724d36e28 --- M include/osmocom/netif/stream.h M src/stream_cli.c M src/stream_srv.c 3 files changed, 65 insertions(+), 33 deletions(-) Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified daniel: Looks good to me, but someone else must approve diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index 61bc1ad..398b277 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -62,6 +62,8 @@ /*! \brief Osmocom Stream Server Link: A server socket listening/accepting */ struct osmo_stream_srv_link; +typedef int (*osmo_stream_srv_link_accept_cb_t)(struct osmo_stream_srv_link *link, int fd); + struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx); void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link); @@ -74,7 +76,7 @@ void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto); int osmo_stream_srv_link_set_type(struct osmo_stream_srv_link *link, int type); int osmo_stream_srv_link_set_domain(struct osmo_stream_srv_link *link, int domain); -void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, int (*accept_cb)(struct osmo_stream_srv_link *link, int fd)); +void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, osmo_stream_srv_link_accept_cb_t accept_cb); void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data); void *osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link); char *osmo_stream_srv_link_get_sockname(const struct osmo_stream_srv_link *link); @@ -98,12 +100,20 @@ * osmo_stream_srv_link */ struct osmo_stream_srv; -struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, int (*read_cb)(struct osmo_stream_srv *conn), int (*closed_cb)(struct osmo_stream_srv *conn), void *data); +typedef int (*osmo_stream_srv_read_cb_t)(struct osmo_stream_srv *conn); +typedef int (*osmo_stream_srv_closed_cb_t)(struct osmo_stream_srv *conn); +typedef int (*osmo_stream_srv_read_cb2_t)(struct osmo_stream_srv *conn, struct msgb *msg); +typedef int (*osmo_stream_srv_segmentation_cb_t)(struct msgb *msg); + +struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, + osmo_stream_srv_read_cb_t read_cb, + osmo_stream_srv_closed_cb_t closed_cb, + void *data); struct osmo_stream_srv *osmo_stream_srv_create2(void *ctx, struct osmo_stream_srv_link *link, int fd, void *data); void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name); const char *osmo_stream_srv_get_name(const struct osmo_stream_srv *conn); -void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, int (*read_cb)(struct osmo_stream_srv *conn, struct msgb *msg)); -void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, int (*closed_cb)(struct osmo_stream_srv *conn)); +void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, osmo_stream_srv_read_cb2_t read_cb); +void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, osmo_stream_srv_closed_cb_t close_cb); void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn); struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv *conn); const char *osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn); @@ -115,8 +125,7 @@ void osmo_stream_srv_set_flush_and_destroy(struct osmo_stream_srv *conn); void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data); -void osmo_stream_srv_set_segmentation_cb(struct osmo_stream_srv *conn, - int (*segmentation_cb)(struct msgb *msg)); +void osmo_stream_srv_set_segmentation_cb(struct osmo_stream_srv *conn, osmo_stream_srv_segmentation_cb_t segmentation_cb); void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg); int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg); @@ -160,6 +169,12 @@ /*! \brief Osmocom Stream Client: Single client connection */ struct osmo_stream_cli; +typedef int (*osmo_stream_cli_connect_cb_t)(struct osmo_stream_cli *cli); +typedef int (*osmo_stream_cli_disconnect_cb_t)(struct osmo_stream_cli *cli); +typedef int (*osmo_stream_cli_read_cb_t)(struct osmo_stream_cli
[M] Change in libosmo-netif[master]: stream: Define types for each API callback
Attention is currently required from: pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36581?usp=email ) Change subject: stream: Define types for each API callback .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/36581?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Ib0c4a9713fa4c755e457b8c2cbde6a7724d36e28 Gerrit-Change-Number: 36581 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: fixeria Gerrit-Attention: pespin Gerrit-Comment-Date: Wed, 17 Apr 2024 19:15:26 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-netif[master]: stream: Define types for each API callback
Attention is currently required from: pespin. daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36581?usp=email ) Change subject: stream: Define types for each API callback .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/36581?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Ib0c4a9713fa4c755e457b8c2cbde6a7724d36e28 Gerrit-Change-Number: 36581 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Attention: pespin Gerrit-Comment-Date: Wed, 17 Apr 2024 14:08:15 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-netif[master]: stream: Define types for each API callback
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36581?usp=email ) Change subject: stream: Define types for each API callback .. stream: Define types for each API callback The amount and complexity of callbacks is increasing over time. Use typedefs to define each of them so that callbacks: - Are easier to identify (which types is used where) - Are easier to document (have a 1st class place to write doxygen documentation) Change-Id: Ib0c4a9713fa4c755e457b8c2cbde6a7724d36e28 --- M include/osmocom/netif/stream.h M src/stream_cli.c M src/stream_srv.c 3 files changed, 65 insertions(+), 33 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/81/36581/1 diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index 61bc1ad..398b277 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -62,6 +62,8 @@ /*! \brief Osmocom Stream Server Link: A server socket listening/accepting */ struct osmo_stream_srv_link; +typedef int (*osmo_stream_srv_link_accept_cb_t)(struct osmo_stream_srv_link *link, int fd); + struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx); void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link); @@ -74,7 +76,7 @@ void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto); int osmo_stream_srv_link_set_type(struct osmo_stream_srv_link *link, int type); int osmo_stream_srv_link_set_domain(struct osmo_stream_srv_link *link, int domain); -void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, int (*accept_cb)(struct osmo_stream_srv_link *link, int fd)); +void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, osmo_stream_srv_link_accept_cb_t accept_cb); void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data); void *osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link); char *osmo_stream_srv_link_get_sockname(const struct osmo_stream_srv_link *link); @@ -98,12 +100,20 @@ * osmo_stream_srv_link */ struct osmo_stream_srv; -struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, int (*read_cb)(struct osmo_stream_srv *conn), int (*closed_cb)(struct osmo_stream_srv *conn), void *data); +typedef int (*osmo_stream_srv_read_cb_t)(struct osmo_stream_srv *conn); +typedef int (*osmo_stream_srv_closed_cb_t)(struct osmo_stream_srv *conn); +typedef int (*osmo_stream_srv_read_cb2_t)(struct osmo_stream_srv *conn, struct msgb *msg); +typedef int (*osmo_stream_srv_segmentation_cb_t)(struct msgb *msg); + +struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, + osmo_stream_srv_read_cb_t read_cb, + osmo_stream_srv_closed_cb_t closed_cb, + void *data); struct osmo_stream_srv *osmo_stream_srv_create2(void *ctx, struct osmo_stream_srv_link *link, int fd, void *data); void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name); const char *osmo_stream_srv_get_name(const struct osmo_stream_srv *conn); -void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, int (*read_cb)(struct osmo_stream_srv *conn, struct msgb *msg)); -void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, int (*closed_cb)(struct osmo_stream_srv *conn)); +void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, osmo_stream_srv_read_cb2_t read_cb); +void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, osmo_stream_srv_closed_cb_t close_cb); void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn); struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv *conn); const char *osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn); @@ -115,8 +125,7 @@ void osmo_stream_srv_set_flush_and_destroy(struct osmo_stream_srv *conn); void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data); -void osmo_stream_srv_set_segmentation_cb(struct osmo_stream_srv *conn, - int (*segmentation_cb)(struct msgb *msg)); +void osmo_stream_srv_set_segmentation_cb(struct osmo_stream_srv *conn, osmo_stream_srv_segmentation_cb_t segmentation_cb); void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg); int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg); @@ -160,6 +169,12 @@ /*! \brief Osmocom Stream Client: Single client connection */ struct osmo_stream_cli; +typedef int (*osmo_stream_cli_connect_cb_t)(struct osmo_stream_cli *cli); +typedef int (*osmo_stream_cli_disconnect_cb_t)(struct osmo_stream_cli *cli); +typedef int (*osmo_stream_cli_read_cb_t)(struct osmo_stream_cli *cli); +typedef int