aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns2_udp.c
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-10-12 01:11:05 +0200
committerlaforge <laforge@osmocom.org>2020-10-12 15:13:43 +0000
commitd420ea9dce8547f1c5d133aef38cc227f660037c (patch)
tree5639f0f7af6a44c3660c6be5408b69abe9c4999c /src/gb/gprs_ns2_udp.c
parent5bc9f3854d3bd3db7bb68f0cde7f77b5a2617f8b (diff)
gprs_ns2: add gprs_ns2_ip_vc_equal()
Compare the NS-VC with the given parameter Change-Id: I3a0cd305fd73b3cb9ec70246ec15ac70b83e57f2
Diffstat (limited to 'src/gb/gprs_ns2_udp.c')
-rw-r--r--src/gb/gprs_ns2_udp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index d41c492d..2cc10064 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -424,6 +424,40 @@ const struct osmo_sockaddr *gprs_ns2_ip_vc_remote(const struct gprs_ns2_vc *nsvc
return &priv->remote;
}
+/*! Compare the NS-VC with the given parameter
+ * \param[in] nsvc NS-VC to compare with
+ * \param[in] local The local address
+ * \param[in] remote The remote address
+ * \param[in] nsvci NS-VCI will only be used if the NS-VC in BLOCKRESET mode otherwise NS-VCI isn't applicable.
+ * \return true if the NS-VC has the same properties as given
+ */
+bool gprs_ns2_ip_vc_equal(const struct gprs_ns2_vc *nsvc,
+ const struct osmo_sockaddr *local,
+ const struct osmo_sockaddr *remote,
+ uint16_t nsvci)
+{
+ struct priv_vc *vpriv;
+ struct priv_bind *bpriv;
+
+ if (nsvc->ll != GPRS_NS_LL_UDP)
+ return false;
+
+ vpriv = nsvc->priv;
+ bpriv = nsvc->bind->priv;
+
+ if (osmo_sockaddr_cmp(local, &bpriv->addr))
+ return false;
+
+ if (osmo_sockaddr_cmp(remote, &vpriv->remote))
+ return false;
+
+ if (nsvc->mode == NS2_VC_MODE_BLOCKRESET)
+ if (nsvc->nsvci != nsvci)
+ return false;
+
+ return true;
+}
+
/*! Return the locally bound socket address of the bind.
* \param[in] bind The bind whose local address we want to know
* \return address of the local bind */