lynxis lazus has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21486 )

Change subject: gprs_ns2: rework gprs_ns2_fr_connect*()
......................................................................

gprs_ns2: rework gprs_ns2_fr_connect*()

Add gprs_ns2_fr_connect2() and change gprs_ns2_fr_connect() to
be similar to gprs_ns2_ip_connect() and gprs_ns2_connect2().

This is an API break but there wasn't yet a release with NS2.

Change-Id: I4e1374b0e979b3293302c5ed46a91a58f3a5a916
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_vty.c
3 files changed, 44 insertions(+), 1 deletion(-)

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



diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 86bf1ae..41587d3 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -189,6 +189,10 @@
 int gprs_ns2_is_fr_bind(struct gprs_ns2_vc_bind *bind);
 struct gprs_ns2_vc *gprs_ns2_fr_nsvc_by_dlci(struct gprs_ns2_vc_bind *bind, 
uint16_t dlci);
 struct gprs_ns2_vc *gprs_ns2_fr_connect(struct gprs_ns2_vc_bind *bind,
+                                       struct gprs_ns2_nse *nse,
+                                       uint16_t nsvci,
+                                       uint16_t dlci);
+struct gprs_ns2_vc *gprs_ns2_fr_connect2(struct gprs_ns2_vc_bind *bind,
                                        uint16_t nsei,
                                        uint16_t nsvci,
                                        uint16_t dlci);
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 5da6fce..b62b5af 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -606,6 +606,45 @@
  *  \param[in] dlci Data Link connection identifier
  *  \return pointer to newly-allocated, connected and activated NS-VC; NULL on 
error */
 struct gprs_ns2_vc *gprs_ns2_fr_connect(struct gprs_ns2_vc_bind *bind,
+                                       struct gprs_ns2_nse *nse,
+                                       uint16_t nsvci,
+                                       uint16_t dlci)
+{
+       struct gprs_ns2_vc *nsvc = NULL;
+       struct priv_vc *priv = NULL;
+
+       nsvc = gprs_ns2_fr_nsvc_by_dlci(bind, dlci);
+       if (nsvc) {
+               goto err;
+       }
+
+       nsvc = ns2_vc_alloc(bind, nse, true, NS2_VC_MODE_BLOCKRESET);
+       if (!nsvc)
+               goto err;
+
+       nsvc->priv = priv = fr_alloc_vc(bind, nsvc, dlci);
+       if (!priv)
+               goto err;
+
+       nsvc->nsvci = nsvci;
+       nsvc->nsvci_is_valid = true;
+
+       gprs_ns2_vc_fsm_start(nsvc);
+
+       return nsvc;
+
+err:
+       gprs_ns2_free_nsvc(nsvc);
+       return NULL;
+}
+
+
+/*! Create, connect and activate a new FR-based NS-VC
+ *  \param[in] bind bind in which the new NS-VC is to be created
+ *  \param[in] nsei NSEI of the NS Entity in which the NS-VC is to be created
+ *  \param[in] dlci Data Link connection identifier
+ *  \return pointer to newly-allocated, connected and activated NS-VC; NULL on 
error */
+struct gprs_ns2_vc *gprs_ns2_fr_connect2(struct gprs_ns2_vc_bind *bind,
                                        uint16_t nsei,
                                        uint16_t nsvci,
                                        uint16_t dlci)
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index fdb6b0b..87284c2 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -969,7 +969,7 @@
                                }
                        }

-                       nsvc = gprs_ns2_fr_connect(fr, vtyvc->nsei, 
vtyvc->nsvci, vtyvc->frdlci);
+                       nsvc = gprs_ns2_fr_connect(fr, nse, vtyvc->nsvci, 
vtyvc->frdlci);
                        if (!nsvc) {
                                /* Could not create NSVC, connect failed */
                                continue;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21486
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4e1374b0e979b3293302c5ed46a91a58f3a5a916
Gerrit-Change-Number: 21486
Gerrit-PatchSet: 12
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to