This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
lynxis lazus gerrit-no-reply at lists.osmocom.orglynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20267 ) Change subject: ns2: refactor gprs_ns2_find_vc_by_sockaddr -> gprs_ns2_nsvc_by_sockaddr2 ...................................................................... ns2: refactor gprs_ns2_find_vc_by_sockaddr -> gprs_ns2_nsvc_by_sockaddr2 gprs_ns2_nsvc_by_sockaddr is doing the lookup within a NSE. gprs_ns2_nsvc_by_sockaddr2 is doing the lookup within a bind. Also drop the *result pointer in the argument and return the NS-VC pointer if found or NULL. Change-Id: Ia499fc279013668abe7348e578a0768f7d16faf9 --- M include/osmocom/gprs/gprs_ns2.h M src/gb/gprs_ns2_udp.c 2 files changed, 8 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/67/20267/1 diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h index 68484c1..991a7d9 100644 --- a/include/osmocom/gprs/gprs_ns2.h +++ b/include/osmocom/gprs/gprs_ns2.h @@ -131,10 +131,9 @@ struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind); int gprs_ns2_is_ip_bind(struct gprs_ns2_vc_bind *bind); int gprs_ns2_ip_bind_set_dscp(struct gprs_ns2_vc_bind *bind, int dscp); -int gprs_ns2_find_vc_by_sockaddr( +struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr2( struct gprs_ns2_vc_bind *bind, - struct osmo_sockaddr *saddr, - struct gprs_ns2_vc **result); + struct osmo_sockaddr *saddr); int gprs_ns2_frgre_bind(struct gprs_ns2_inst *nsi, struct osmo_sockaddr *local, diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index bb421a7..40923b2 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -81,16 +81,12 @@ /*! Find a NS-VC by its remote socket address. * \param[in] bind in which to search * \param[in] saddr remote peer socket adddress to search - * \param[out] result pointer to result - * \returns 0 on success; 1 if no NS-VC was found; negative on error */ -int gprs_ns2_find_vc_by_sockaddr(struct gprs_ns2_vc_bind *bind, struct osmo_sockaddr *saddr, struct gprs_ns2_vc **result) + * \returns NS-VC matching sockaddr; NULL if none found */ +struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr2(struct gprs_ns2_vc_bind *bind, struct osmo_sockaddr *saddr) { struct gprs_ns2_vc *nsvc; struct priv_vc *vcpriv; - if (!result) - return -EINVAL; - llist_for_each_entry(nsvc, &bind->nsvc, blist) { vcpriv = nsvc->priv; if (vcpriv->remote.u.sa.sa_family != saddr->u.sa.sa_family) @@ -98,11 +94,10 @@ if (osmo_sockaddr_cmp(&vcpriv->remote, saddr)) continue; - *result = nsvc; - return 0; + return nsvc; } - return 1; + return NULL; } static inline int nsip_sendmsg(struct gprs_ns2_vc_bind *bind, @@ -194,8 +189,8 @@ return -EINVAL; /* check if a vc is available */ - rc = gprs_ns2_find_vc_by_sockaddr(bind, &saddr, &nsvc); - if (rc) { + nsvc = gprs_ns2_nsvc_by_sockaddr2(bind, &saddr); + if (!nsvc) { /* VC not found */ rc = ns2_create_vc(bind, msg, "newconnection", &reject, &nsvc); switch (rc) { -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20267 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ia499fc279013668abe7348e578a0768f7d16faf9 Gerrit-Change-Number: 20267 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis at fe80.eu> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200923/578b4ac6/attachment.htm>