summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-07-02 09:10:11 +0200
committerHarald Welte <laforge@gnumonks.org>2013-07-06 23:36:16 +0200
commitc62a1bf4d53edec94b0db05da717d24438824357 (patch)
treea6abec11fa8c21db747dcd6eb7e5db79e5e48b05
parentc8cac64abbf91b1a515010b43347ab408caf2549 (diff)
libosmogb: Add function to close NS instance without destroying it
-rw-r--r--include/osmocom/gprs/gprs_ns.h5
-rw-r--r--src/gb/gprs_ns.c19
-rw-r--r--src/gb/libosmogb.map1
3 files changed, 17 insertions, 8 deletions
diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h
index 8fca70cb..8ca5a887 100644
--- a/include/osmocom/gprs/gprs_ns.h
+++ b/include/osmocom/gprs/gprs_ns.h
@@ -129,7 +129,10 @@ struct gprs_nsvc {
/* Create a new NS protocol instance */
struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb, void *ctx);
-/* Destroy a NS protocol instance */
+/* Close a NS protocol instance */
+void gprs_ns_close(struct gprs_ns_inst *nsi);
+
+/* Close and Destroy a NS protocol instance */
void gprs_ns_destroy(struct gprs_ns_inst *nsi);
/* Listen for incoming GPRS packets via NS/UDP */
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index ef937d9e..5620b3a7 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -917,13 +917,7 @@ struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb, void *ctx)
return nsi;
}
-/*! \brief Destroy an entire NS instance
- * \param nsi gprs_ns_inst that is to be destroyed
- *
- * This function releases all resources associated with the
- * NS-instance.
- */
-void gprs_ns_destroy(struct gprs_ns_inst *nsi)
+void gprs_ns_close(struct gprs_ns_inst *nsi)
{
struct gprs_nsvc *nsvc, *nsvc2;
@@ -935,8 +929,19 @@ void gprs_ns_destroy(struct gprs_ns_inst *nsi)
if (nsi->nsip.fd.data) {
close(nsi->nsip.fd.fd);
osmo_fd_unregister(&nsi->nsip.fd);
+ nsi->nsip.fd.data = NULL;
}
+}
+/*! \brief Destroy an entire NS instance
+ * \param nsi gprs_ns_inst that is to be destroyed
+ *
+ * This function releases all resources associated with the
+ * NS-instance.
+ */
+void gprs_ns_destroy(struct gprs_ns_inst *nsi)
+{
+ gprs_ns_close(nsi);
/* free the NSI */
talloc_free(nsi);
}
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index d65819b4..7af085c5 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -38,6 +38,7 @@ bssgp_nsi;
gprs_ns_cause_str;
gprs_ns_destroy;
+gprs_ns_close;
gprs_ns_frgre_listen;
gprs_ns_frgre_sendmsg;
gprs_ns_instantiate;