Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() to pass the up_down_cb in the arguments. Also add a cb data argument to populate the already existing osmo_gsup_client->data item directly from osmo_gsup_client_create3(). We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Because there are so many arguments, and to prevent the need for ever new versions of this function, pass the arguments as an extendable struct. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 74 insertions(+), 20 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/include/osmocom/gsupclient/gsup_client.h b/include/osmocom/gsupclient/gsup_client.h index b417ade..ea66ca1 100644 --- a/include/osmocom/gsupclient/gsup_client.h +++ b/include/osmocom/gsupclient/gsup_client.h @@ -38,6 +38,8 @@ /* Expects message in msg->l2h */ typedef int (*osmo_gsup_client_read_cb_t)(struct osmo_gsup_client *gsupc, struct msgb *msg); +typedef bool (*osmo_gsup_client_up_down_cb_t)(struct osmo_gsup_client *gsupc, bool up); + struct osmo_gsup_client { const char *unit_name; /* same as ipa_dev->unit_name, for backwards compat */ @@ -53,8 +55,31 @@ int got_ipa_pong; struct ipaccess_unit *ipa_dev; /* identification information sent to IPA server */ + + osmo_gsup_client_up_down_cb_t up_down_cb; }; +struct osmo_gsup_client_config { + /*! IP access unit which contains client identification information; must be allocated in talloc_ctx as well to +* ensure it lives throughout the lifetime of the connection. */ + struct ipaccess_unit *ipa_dev; + /*! GSUP server IP address to connect to. */ + const char *ip_addr; + /*! GSUP server TCP port to connect to. */ + unsigned int tcp_port; + /*! OPA client configuration, or NULL. */ + struct osmo_oap_client_config *oapc_config; + /*! callback for reading from the GSUP connection. */ + osmo_gsup_client_read_cb_t read_cb; + /*! Invoked when the GSUP link is ready for communication, and when the link drops. */ + osmo_gsup_client_up_down_cb_t up_down_cb; + /*! User data stored in the returned gsupc->data, as context for the callbacks. */ + void *data; + /*! Marker for future extension, always pass this as false. */ + bool more; +}; +struct osmo_gsup_client *osmo_gsup_client_create3(void *talloc_ctx, struct osmo_gsup_client_config *config); + struct osmo_gsup_client *osmo_gsup_client_create2(void *talloc_ctx, struct ipaccess_unit *ipa_dev, const char *ip_addr, diff --git a/src/gsupclient/gsup_client.c b/src/gsupclient/gsup_client.c index 52985c9..4f76efc 100644 --- a/src/gsupclient/gsup_client.c +++ b/src/gsupclient/gsup_client.c @@ -97,6 +97,12 @@ if (gsupc->is_connected) return; + if (gsupc->up_down_cb) { + /* When the up_down_cb() returns false, the user asks us not to retry connecting. */ + if (!gsupc->up_down_cb(gsupc, false)) + return; + } + gsup_client_connect(gsupc); } @@ -139,9 +145,18 @@ gsup_client_oap_register(gsupc); osmo_timer_del(>connect_timer); + + if (gsupc->up_down_cb) + gsupc->up_down_cb(gsupc, true); } else { osmo_timer_del(>ping_timer); + if (gsupc->up_down_cb) { + /* When the up_down_cb() returns false, the user asks us not to retry connecting. */ + if (!gsupc->up_down_cb(gsupc, false)) + return; + } + osmo_timer_schedule(>connect_timer, OSMO_GSUP_CLIENT_RECONNECT_INTERVAL, 0); } @@ -263,31 +278,28 @@ * Use the provided ipaccess unit as the client-side identifier; ipa_dev should * be allocated in talloc_ctx talloc_ctx as well. * \param[in] talloc_ctx talloc context. - * \param[in] ipa_dev IP access unit which contains client identification information; must be allocated - *in talloc_ctx
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. Patch Set 31: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 31 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Comment-Date: Fri, 01 May 2020 14:34:55 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
Hello fixeria, pespin, laforge, osmith, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 to look at the new patch set (#31). Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() to pass the up_down_cb in the arguments. Also add a cb data argument to populate the already existing osmo_gsup_client->data item directly from osmo_gsup_client_create3(). We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Because there are so many arguments, and to prevent the need for ever new versions of this function, pass the arguments as an extendable struct. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 74 insertions(+), 20 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/16206/31 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 31 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-MessageType: newpatchset
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. Patch Set 28: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 28 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Comment-Date: Fri, 31 Jan 2020 14:52:45 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. Patch Set 28: Code-Review+1 (2 comments) https://gerrit.osmocom.org/c/osmo-hlr/+/16206/28/include/osmocom/gsupclient/gsup_client.h File include/osmocom/gsupclient/gsup_client.h: https://gerrit.osmocom.org/c/osmo-hlr/+/16206/28/include/osmocom/gsupclient/gsup_client.h@62 PS28, Line 62: osmo_gsup_client_config That's a nice idea to finally group all parameters into a structure! https://gerrit.osmocom.org/c/osmo-hlr/+/16206/28/include/osmocom/gsupclient/gsup_client.h@69 PS28, Line 69: tcp_port Just an idea: what if somebody wants to use a different transport layer, e.g. SCTP? We could make the new function more flexible by adding an enumerated type (osmo_gsup_transport_proto?) and a union to this structure: ... enum osmo_gsup_transport_proto transport_proto; const char *ip_addr; union { struct tcp_ipa { struct ipaccess_unit *ipa_dev; unsigned int port; } } u; ... For now osmo_gsup_client_create3() would return -ENOTSUPP for transport_proto != TCP_IPA. -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 28 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Comment-Date: Thu, 30 Jan 2020 09:51:16 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. Patch Set 23: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 23 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 08 Jan 2020 13:29:11 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. Patch Set 23: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 23 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Comment-Date: Tue, 07 Jan 2020 22:08:43 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
Hello osmith, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 to look at the new patch set (#21). Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() pass the up_down_cb in the arguments. Also add a cb data argument. We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Because there are so many arguments, and to prevent the need for ever new versions of this function, pass the arguments as an extendable struct. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 74 insertions(+), 20 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/16206/21 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 21 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-CC: laforge Gerrit-MessageType: newpatchset
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. Patch Set 19: (1 comment) https://gerrit.osmocom.org/c/osmo-hlr/+/16206/19/include/osmocom/gsupclient/gsup_client.h File include/osmocom/gsupclient/gsup_client.h: https://gerrit.osmocom.org/c/osmo-hlr/+/16206/19/include/osmocom/gsupclient/gsup_client.h@67 PS19, Line 67:struct osmo_oap_client_config *oapc_config, At some point it makes sense to pass a strict instead of dozens of arguments -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 19 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-CC: laforge Gerrit-Comment-Date: Sat, 30 Nov 2019 10:09:53 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
osmith has uploaded a new patch set (#13) to the change originally created by neels. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() pass the up_down_cb in the arguments. Also add a cb data argument, and groupt the cb and data arguments after the oapc_config argument. (Usually, we have cb and data arguments last.) We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 63 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/16206/13 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 13 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-MessageType: newpatchset
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
osmith has uploaded a new patch set (#8) to the change originally created by neels. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() pass the up_down_cb in the arguments. Also add a cb data argument, and groupt the cb and data arguments after the oapc_config argument. (Usually, we have cb and data arguments last.) We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 63 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/16206/8 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 8 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-MessageType: newpatchset
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
osmith has uploaded a new patch set (#7) to the change originally created by neels. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() pass the up_down_cb in the arguments. Also add a cb data argument, and groupt the cb and data arguments after the oapc_config argument. (Usually, we have cb and data arguments last.) We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 63 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/16206/7 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16206 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d Gerrit-Change-Number: 16206 Gerrit-PatchSet: 7 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-MessageType: newpatchset
Change in osmo-hlr[master]: gsup client: add up_down_cb(), add osmo_gsup_client_create3()
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16206 ) Change subject: gsup client: add up_down_cb(), add osmo_gsup_client_create3() .. gsup client: add up_down_cb(), add osmo_gsup_client_create3() For the GSUP clients in upcoming D-GSM enabled osmo-hlr, it will be necessary to trigger an event as soon as a GSUP client connection becomes ready for communication. Add the osmo_gsup_client->up_down_cb. Add osmo_gsup_client_create3() pass the up_down_cb in the arguments. Also add a cb data argument, and groupt the cb and data arguments after the oapc_config argument. (Usually, we have cb and data arguments last.) We need the callbacks and data pointer in the osmo_gsup_client_create() function right before startup, because this function immediately starts up the connection. Who knows whether callbacks might trigger right away. Change-Id: I6f181e42b678465bc9945f192559dc57d2083c6d --- M include/osmocom/gsupclient/gsup_client.h M src/gsupclient/gsup_client.c 2 files changed, 63 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/16206/1 diff --git a/include/osmocom/gsupclient/gsup_client.h b/include/osmocom/gsupclient/gsup_client.h index 154e3e0..deae4d4 100644 --- a/include/osmocom/gsupclient/gsup_client.h +++ b/include/osmocom/gsupclient/gsup_client.h @@ -39,6 +39,8 @@ /* Expects message in msg->l2h */ typedef int (*osmo_gsup_client_read_cb_t)(struct osmo_gsup_client *gsupc, struct msgb *msg); +typedef bool (*osmo_gsup_client_up_down_cb_t)(struct osmo_gsup_client *gsupc, bool up); + struct osmo_gsup_client { const char *unit_name; /* same as ipa_dev->unit_name, for backwards compat */ @@ -54,8 +56,18 @@ int got_ipa_pong; struct ipaccess_unit *ipa_dev; /* identification information sent to IPA server */ + + osmo_gsup_client_up_down_cb_t up_down_cb; }; +struct osmo_gsup_client *osmo_gsup_client_create3(void *talloc_ctx, + struct ipaccess_unit *ipa_dev, + const char *ip_addr, + unsigned int tcp_port, + struct osmo_oap_client_config *oapc_config, + osmo_gsup_client_read_cb_t read_cb, + osmo_gsup_client_up_down_cb_t up_down_cb, + void *data); struct osmo_gsup_client *osmo_gsup_client_create2(void *talloc_ctx, struct ipaccess_unit *ipa_dev, const char *ip_addr, diff --git a/src/gsupclient/gsup_client.c b/src/gsupclient/gsup_client.c index 52985c9..d522056 100644 --- a/src/gsupclient/gsup_client.c +++ b/src/gsupclient/gsup_client.c @@ -97,6 +97,12 @@ if (gsupc->is_connected) return; + if (gsupc->up_down_cb) { + /* When the up_down_cb() returns false, the user asks us not to retry connecting. */ + if (!gsupc->up_down_cb(gsupc, false)) + return; + } + gsup_client_connect(gsupc); } @@ -139,9 +145,18 @@ gsup_client_oap_register(gsupc); osmo_timer_del(>connect_timer); + + if (gsupc->up_down_cb) + gsupc->up_down_cb(gsupc, true); } else { osmo_timer_del(>ping_timer); + if (gsupc->up_down_cb) { + /* When the up_down_cb() returns false, the user asks us not to retry connecting. */ + if (!gsupc->up_down_cb(gsupc, false)) + return; + } + osmo_timer_schedule(>connect_timer, OSMO_GSUP_CLIENT_RECONNECT_INTERVAL, 0); } @@ -263,28 +278,39 @@ * Use the provided ipaccess unit as the client-side identifier; ipa_dev should * be allocated in talloc_ctx talloc_ctx as well. * \param[in] talloc_ctx talloc context. - * \param[in] ipa_dev IP access unit which contains client identification information; must be allocated - *in talloc_ctx as well to ensure it lives throughout the lifetime of the connection. - * \param[in] ip_addr GSUP server IP address. - * \param[in] tcp_port GSUP server TCP port. - * \param[in] read_cb callback for reading from the GSUP connection. - * \param[in] oapc_config OPA client configuration. - * \returns a GSUP client connection or NULL on failure. + * \param[in] ipa_dev IP access unit which contains client identification information; must be allocated + *in talloc_ctx as well to ensure it lives throughout the lifetime of the connection. + * \param[in] ip_addr GSUP server IP