[PATCH] openbsc[master]: define mncc_recv_cb_t to avoid code dup

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Oct 21 00:01:09 UTC 2016


Review at  https://gerrit.osmocom.org/1124

define mncc_recv_cb_t to avoid code dup

Put mncc_recv_cb_t in xsc.h to avoid header include complications: if placing
right above struct gsm_network, one must include gsm_data.h to use
mncc_recv_cb_t as function parameter in a header, which will include
gsm_data_shared.h, which will include xsc.h (future knowledge). Since I will
need to use mncc_recv_cb_t in xsc.h, including gsm_data.h from there would
introduce an #include loop. Avoid that and define mncc_recv_cb_t in xsc.h to
begin with.

Change-Id: I2e64cffa563750ce9f3172ffba6f9cf5b9280e9c
---
M openbsc/include/openbsc/bss.h
M openbsc/include/openbsc/gsm_data.h
M openbsc/include/openbsc/xsc.h
M openbsc/src/libbsc/bsc_init.c
M openbsc/src/libbsc/net_init.c
5 files changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/24/1124/1

diff --git a/openbsc/include/openbsc/bss.h b/openbsc/include/openbsc/bss.h
index 49df547..d73776f 100644
--- a/openbsc/include/openbsc/bss.h
+++ b/openbsc/include/openbsc/bss.h
@@ -1,11 +1,12 @@
 #ifndef _BSS_H_
 #define _BSS_H_
 
-struct gsm_network;
+#include <openbsc/gsm_data.h>
+
 struct msgb;
 
 /* start and stop network */
-extern int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), const char *cfg_file);
+extern int bsc_bootstrap_network(mncc_recv_cb_t mncc_recv, const char *cfg_file);
 extern int bsc_shutdown_net(struct gsm_network *net);
 
 /* register all supported BTS */
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index c7e2347..18c01f7 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -14,6 +14,7 @@
 #include <osmocom/crypt/auth.h>
 
 #include <openbsc/rest_octets.h>
+#include <openbsc/xsc.h>
 
 /** annotations for msgb ownership */
 #define __uses
@@ -298,7 +299,7 @@
 
 	/* layer 4 */
 	struct mncc_sock_state *mncc_state;
-	int (*mncc_recv) (struct gsm_network *net, struct msgb *msg);
+	mncc_recv_cb_t mncc_recv;
 	struct llist_head upqueue;
 	struct llist_head trans_list;
 	struct bsc_api *bsc_api;
@@ -407,7 +408,7 @@
 struct gsm_network *gsm_network_init(void *ctx,
 				     uint16_t country_code,
 				     uint16_t network_code,
-				     int (*mncc_recv)(struct gsm_network *, struct msgb *));
+				     mncc_recv_cb_t mncc_recv);
 
 int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
 
diff --git a/openbsc/include/openbsc/xsc.h b/openbsc/include/openbsc/xsc.h
index 6f70f09..612d754 100644
--- a/openbsc/include/openbsc/xsc.h
+++ b/openbsc/include/openbsc/xsc.h
@@ -1 +1,6 @@
 #pragma once
+
+struct msgb;
+struct gsm_network;
+
+typedef int (*mncc_recv_cb_t)(struct gsm_network *, struct msgb *);
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index bf6e056..a1becf8 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -475,8 +475,7 @@
 	return 0;
 }
 
-int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *),
-			  const char *config_file)
+int bsc_bootstrap_network(mncc_recv_cb_t mncc_recv, const char *config_file)
 {
 	struct gsm_bts *bts;
 	int rc;
diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c
index 57e3599..da13a52 100644
--- a/openbsc/src/libbsc/net_init.c
+++ b/openbsc/src/libbsc/net_init.c
@@ -26,7 +26,7 @@
 struct gsm_network *gsm_network_init(void *ctx,
 				     uint16_t country_code,
 				     uint16_t network_code,
-				     int (*mncc_recv)(struct gsm_network *, struct msgb *))
+				     mncc_recv_cb_t mncc_recv)
 {
 	struct gsm_network *net;
 	const char *default_regexp = ".*";

-- 
To view, visit https://gerrit.osmocom.org/1124
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e64cffa563750ce9f3172ffba6f9cf5b9280e9c
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list