[MERGED] openbsc[master]: gprs_gsup_client*: remove the gprs_ prefix

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Dec 13 14:54:06 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: gprs_gsup_client*: remove the gprs_ prefix
......................................................................


gprs_gsup_client*: remove the gprs_ prefix

Make sure everything is named gsup_client_ / GSUP_CLIENT_.

Rename static gsup_client_send() to client_send() to avoid clash with public
gprs_gsup_client_send() being renamed to gsup_client_send().

This is in preparation for moving gsup to libcommon, which is in turn
preparation for libvlr. libvlr and osmo-sgsn will use the same GSUP client
code. A number of patches will follow up on this, also for the the OAP client.

Related: OS#1592
Change-Id: I57433973b1c4f6cc1e12e7b1c96b5f719f418b51
---
M openbsc/include/openbsc/gprs_gsup_client.h
M openbsc/include/openbsc/sgsn.h
M openbsc/src/gprs/gprs_gsup_client.c
M openbsc/src/gprs/gprs_subscriber.c
M openbsc/src/gprs/gsup_test_client.c
M openbsc/tests/sgsn/Makefile.am
M openbsc/tests/sgsn/sgsn_test.c
7 files changed, 79 insertions(+), 76 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/include/openbsc/gprs_gsup_client.h b/openbsc/include/openbsc/gprs_gsup_client.h
index ccfa388..551f76d 100644
--- a/openbsc/include/openbsc/gprs_gsup_client.h
+++ b/openbsc/include/openbsc/gprs_gsup_client.h
@@ -25,35 +25,36 @@
 
 #include <openbsc/oap.h>
 
-#define GPRS_GSUP_RECONNECT_INTERVAL 10
-#define GPRS_GSUP_PING_INTERVAL 20
+#define GSUP_CLIENT_RECONNECT_INTERVAL 10
+#define GSUP_CLIENT_PING_INTERVAL 20
 
 struct msgb;
 struct ipa_client_conn;
-struct gprs_gsup_client;
+struct gsup_client;
 
 /* Expects message in msg->l2h */
-typedef int (*gprs_gsup_read_cb_t)(struct gprs_gsup_client *gsupc, struct msgb *msg);
+typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
+				     struct msgb *msg);
 
-struct gprs_gsup_client {
-	struct ipa_client_conn	*link;
-	gprs_gsup_read_cb_t	read_cb;
-	void			*data;
+struct gsup_client {
+	struct ipa_client_conn *link;
+	gsup_client_read_cb_t read_cb;
+	void *data;
 
-	struct oap_state	oap_state;
+	struct oap_state oap_state;
 
-	struct osmo_timer_list	ping_timer;
-	struct osmo_timer_list	connect_timer;
-	int			is_connected;
-	int			got_ipa_pong;
+	struct osmo_timer_list ping_timer;
+	struct osmo_timer_list connect_timer;
+	int is_connected;
+	int got_ipa_pong;
 };
 
-struct gprs_gsup_client *gprs_gsup_client_create(const char *ip_addr,
-						 unsigned int tcp_port,
-						 gprs_gsup_read_cb_t read_cb,
-						 struct oap_config *oap_config);
+struct gsup_client *gsup_client_create(const char *ip_addr,
+				       unsigned int tcp_port,
+				       gsup_client_read_cb_t read_cb,
+				       struct oap_config *oap_config);
 
-void gprs_gsup_client_destroy(struct gprs_gsup_client *gsupc);
-int gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg);
-struct msgb *gprs_gsup_msgb_alloc(void);
+void gsup_client_destroy(struct gsup_client *gsupc);
+int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
+struct msgb *gsup_client_msgb_alloc(void);
 
diff --git a/openbsc/include/openbsc/sgsn.h b/openbsc/include/openbsc/sgsn.h
index 786e2b2..0045fae 100644
--- a/openbsc/include/openbsc/sgsn.h
+++ b/openbsc/include/openbsc/sgsn.h
@@ -123,7 +123,7 @@
 	/* GSN instance for libgtp */
 	struct gsn_t *gsn;
 	/* Subscriber */
-	struct gprs_gsup_client *gsup_client;
+	struct gsup_client *gsup_client;
 	/* LLME inactivity timer */
 	struct osmo_timer_list llme_timer;
 
diff --git a/openbsc/src/gprs/gprs_gsup_client.c b/openbsc/src/gprs/gprs_gsup_client.c
index 41b88ad..cd94a8a 100644
--- a/openbsc/src/gprs/gprs_gsup_client.c
+++ b/openbsc/src/gprs/gprs_gsup_client.c
@@ -35,11 +35,11 @@
 
 extern void *tall_bsc_ctx;
 
-static void start_test_procedure(struct gprs_gsup_client *gsupc);
+static void start_test_procedure(struct gsup_client *gsupc);
 
-static void gsup_client_send_ping(struct gprs_gsup_client *gsupc)
+static void gsup_client_send_ping(struct gsup_client *gsupc)
 {
-	struct msgb *msg = gprs_gsup_msgb_alloc();
+	struct msgb *msg = gsup_client_msgb_alloc();
 
 	msg->l2h = msgb_put(msg, 1);
 	msg->l2h[0] = IPAC_MSGT_PING;
@@ -47,7 +47,7 @@
 	ipa_client_conn_send(gsupc->link, msg);
 }
 
-static int gsup_client_connect(struct gprs_gsup_client *gsupc)
+static int gsup_client_connect(struct gsup_client *gsupc)
 {
 	int rc;
 
@@ -84,7 +84,8 @@
 	    rc == -EINVAL)
 		return rc;
 
-	osmo_timer_schedule(&gsupc->connect_timer, GPRS_GSUP_RECONNECT_INTERVAL, 0);
+	osmo_timer_schedule(&gsupc->connect_timer,
+			    GSUP_CLIENT_RECONNECT_INTERVAL, 0);
 
 	LOGP(DGPRS, LOGL_INFO, "Scheduled timer to retry GSUP connect to %s:%d\n",
 	     gsupc->link->addr, gsupc->link->port);
@@ -94,7 +95,7 @@
 
 static void connect_timer_cb(void *gsupc_)
 {
-	struct gprs_gsup_client *gsupc = gsupc_;
+	struct gsup_client *gsupc = gsupc_;
 
 	if (gsupc->is_connected)
 		return;
@@ -102,7 +103,8 @@
 	gsup_client_connect(gsupc);
 }
 
-static void gsup_client_send(struct gprs_gsup_client *gsupc, int proto_ext, struct msgb *msg_tx)
+static void client_send(struct gsup_client *gsupc, int proto_ext,
+			struct msgb *msg_tx)
 {
 	ipa_prepend_header_ext(msg_tx, proto_ext);
 	ipa_msg_push_header(msg_tx, IPAC_PROTO_OSMO);
@@ -110,7 +112,7 @@
 	/* msg_tx is now queued and will be freed. */
 }
 
-static void gsup_client_oap_register(struct gprs_gsup_client *gsupc)
+static void gsup_client_oap_register(struct gsup_client *gsupc)
 {
 	struct msgb *msg_tx;
 	int rc;
@@ -121,12 +123,12 @@
 		return;
 	}
 
-	gsup_client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx);
+	client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx);
 }
 
 static void gsup_client_updown_cb(struct ipa_client_conn *link, int up)
 {
-	struct gprs_gsup_client *gsupc = link->data;
+	struct gsup_client *gsupc = link->data;
 
 	LOGP(DGPRS, LOGL_INFO, "GSUP link to %s:%d %s\n",
 		     link->addr, link->port, up ? "UP" : "DOWN");
@@ -144,11 +146,11 @@
 		osmo_timer_del(&gsupc->ping_timer);
 
 		osmo_timer_schedule(&gsupc->connect_timer,
-				    GPRS_GSUP_RECONNECT_INTERVAL, 0);
+				    GSUP_CLIENT_RECONNECT_INTERVAL, 0);
 	}
 }
 
-static int gsup_client_oap_handle(struct gprs_gsup_client *gsupc, struct msgb *msg_rx)
+static int gsup_client_oap_handle(struct gsup_client *gsupc, struct msgb *msg_rx)
 {
 	int rc;
 	struct msgb *msg_tx;
@@ -159,7 +161,7 @@
 		return rc;
 
 	if (msg_tx)
-		gsup_client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx);
+		client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx);
 
 	return 0;
 }
@@ -168,7 +170,7 @@
 {
 	struct ipaccess_head *hh = (struct ipaccess_head *) msg->data;
 	struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) msgb_l2(msg);
-	struct gprs_gsup_client *gsupc = (struct gprs_gsup_client *)link->data;
+	struct gsup_client *gsupc = (struct gsup_client *)link->data;
 	int rc;
 	static struct ipaccess_unit ipa_dev = {
 		.unit_name = "SGSN"
@@ -231,7 +233,7 @@
 
 static void ping_timer_cb(void *gsupc_)
 {
-	struct gprs_gsup_client *gsupc = gsupc_;
+	struct gsup_client *gsupc = gsupc_;
 
 	LOGP(DGPRS, LOGL_INFO, "GSUP ping callback (%s, %s PONG)\n",
 	     gsupc->is_connected ? "connected" : "not connected",
@@ -249,26 +251,26 @@
 	gsup_client_connect(gsupc);
 }
 
-static void start_test_procedure(struct gprs_gsup_client *gsupc)
+static void start_test_procedure(struct gsup_client *gsupc)
 {
 	gsupc->ping_timer.data = gsupc;
 	gsupc->ping_timer.cb = &ping_timer_cb;
 
 	gsupc->got_ipa_pong = 0;
-	osmo_timer_schedule(&gsupc->ping_timer, GPRS_GSUP_PING_INTERVAL, 0);
+	osmo_timer_schedule(&gsupc->ping_timer, GSUP_CLIENT_PING_INTERVAL, 0);
 	LOGP(DGPRS, LOGL_DEBUG, "GSUP sending PING\n");
 	gsup_client_send_ping(gsupc);
 }
 
-struct gprs_gsup_client *gprs_gsup_client_create(const char *ip_addr,
-						 unsigned int tcp_port,
-						 gprs_gsup_read_cb_t read_cb,
-						 struct oap_config *oap_config)
+struct gsup_client *gsup_client_create(const char *ip_addr,
+				       unsigned int tcp_port,
+				       gsup_client_read_cb_t read_cb,
+				       struct oap_config *oap_config)
 {
-	struct gprs_gsup_client *gsupc;
+	struct gsup_client *gsupc;
 	int rc;
 
-	gsupc = talloc_zero(tall_bsc_ctx, struct gprs_gsup_client);
+	gsupc = talloc_zero(tall_bsc_ctx, struct gsup_client);
 	OSMO_ASSERT(gsupc);
 
 	rc = oap_init(oap_config, &gsupc->oap_state);
@@ -299,11 +301,11 @@
 	return gsupc;
 
 failed:
-	gprs_gsup_client_destroy(gsupc);
+	gsup_client_destroy(gsupc);
 	return NULL;
 }
 
-void gprs_gsup_client_destroy(struct gprs_gsup_client *gsupc)
+void gsup_client_destroy(struct gsup_client *gsupc)
 {
 	osmo_timer_del(&gsupc->connect_timer);
 	osmo_timer_del(&gsupc->ping_timer);
@@ -316,7 +318,7 @@
 	talloc_free(gsupc);
 }
 
-int gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg)
+int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
 {
 	if (!gsupc) {
 		msgb_free(msg);
@@ -328,12 +330,12 @@
 		return -EAGAIN;
 	}
 
-	gsup_client_send(gsupc, IPAC_PROTO_EXT_GSUP, msg);
+	client_send(gsupc, IPAC_PROTO_EXT_GSUP, msg);
 
 	return 0;
 }
 
-struct msgb *gprs_gsup_msgb_alloc(void)
+struct msgb *gsup_client_msgb_alloc(void)
 {
 	return msgb_alloc_headroom(4000, 64, __func__);
 }
diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index 658ce04..100fd91 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -45,7 +45,7 @@
 
 extern void *tall_bsc_ctx;
 
-static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg);
+static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg);
 
 /* TODO: Some functions are specific to the SGSN, but this file is more general
  * (it has gprs_* name). Either move these functions elsewhere, split them and
@@ -62,7 +62,7 @@
 
 	addr_str = inet_ntoa(sgi->cfg.gsup_server_addr.sin_addr);
 
-	sgi->gsup_client = gprs_gsup_client_create(
+	sgi->gsup_client = gsup_client_create(
 		addr_str, sgi->cfg.gsup_server_port,
 		&gsup_read_cb,
 		&sgi->cfg.oap);
@@ -73,7 +73,7 @@
 	return 1;
 }
 
-static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg)
+static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg)
 {
 	int rc;
 
@@ -161,7 +161,7 @@
 static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
 				       struct osmo_gsup_message *gsup_msg)
 {
-	struct msgb *msg = gprs_gsup_msgb_alloc();
+	struct msgb *msg = gsup_client_msgb_alloc();
 
 	if (strlen(gsup_msg->imsi) == 0 && subscr)
 		strncpy(gsup_msg->imsi, subscr->imsi, sizeof(gsup_msg->imsi) - 1);
@@ -176,7 +176,7 @@
 		return -ENOTSUP;
 	}
 
-	return gprs_gsup_client_send(sgsn->gsup_client, msg);
+	return gsup_client_send(sgsn->gsup_client, msg);
 }
 
 static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr,
diff --git a/openbsc/src/gprs/gsup_test_client.c b/openbsc/src/gprs/gsup_test_client.c
index 5f123b8..901b870 100644
--- a/openbsc/src/gprs/gsup_test_client.c
+++ b/openbsc/src/gprs/gsup_test_client.c
@@ -12,7 +12,7 @@
 #include <openbsc/gprs_gsup_client.h>
 #include <openbsc/debug.h>
 
-static struct gprs_gsup_client *g_gc;
+static struct gsup_client *g_gc;
 
 
 /***********************************************************************
@@ -113,7 +113,7 @@
 
 	osmo_gsup_encode(msg, &gsup);
 
-	return gprs_gsup_client_send(g_gc, msg);
+	return gsup_client_send(g_gc, msg);
 }
 
 /* allocate + generate + send Send-Auth-Info */
@@ -128,7 +128,7 @@
 
 	osmo_gsup_encode(msg, &gsup);
 
-	return gprs_gsup_client_send(g_gc, msg);
+	return gsup_client_send(g_gc, msg);
 }
 
 int resp_isd(struct imsi_op *io)
@@ -143,7 +143,7 @@
 
 	imsi_op_release(io);
 
-	return gprs_gsup_client_send(g_gc, msg);
+	return gsup_client_send(g_gc, msg);
 }
 
 /* receive an incoming GSUP message */
@@ -196,7 +196,7 @@
 	}
 }
 
-static int gsupc_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg)
+static int gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg)
 {
 	struct osmo_gsup_message gsup_msg = {0};
 	struct imsi_op *io;
@@ -281,8 +281,8 @@
 
 	osmo_init_logging(&gprs_log_info);
 
-	g_gc = gprs_gsup_client_create(server_host, server_port,
-					gsupc_read_cb, NULL);
+	g_gc = gsup_client_create(server_host, server_port, gsupc_read_cb,
+				       NULL);
 
 
 	signal(SIGINT, sig_cb);
diff --git a/openbsc/tests/sgsn/Makefile.am b/openbsc/tests/sgsn/Makefile.am
index 9ee5455..c5d90f6 100644
--- a/openbsc/tests/sgsn/Makefile.am
+++ b/openbsc/tests/sgsn/Makefile.am
@@ -36,7 +36,7 @@
 	-Wl,--wrap=sgsn_update_subscriber_data \
 	-Wl,--wrap=gprs_subscr_request_update_location \
 	-Wl,--wrap=gprs_subscr_request_auth_info \
-	-Wl,--wrap=gprs_gsup_client_send \
+	-Wl,--wrap=gsup_client_send \
 	$(NULL)
 
 sgsn_test_LDADD = \
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index e7b7458..16eb6c9 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -146,14 +146,14 @@
 	return (*subscr_request_auth_info_cb)(mmctx);
 };
 
-/* override, requires '-Wl,--wrap=gprs_gsup_client_send' */
-int __real_gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg);
-int (*gprs_gsup_client_send_cb)(struct gprs_gsup_client *gsupc, struct msgb *msg) =
-	&__real_gprs_gsup_client_send;
+/* override, requires '-Wl,--wrap=gsup_client_send' */
+int __real_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
+int (*gsup_client_send_cb)(struct gsup_client *gsupc, struct msgb *msg) =
+	&__real_gsup_client_send;
 
-int __wrap_gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg)
+int __wrap_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
 {
-	return (*gprs_gsup_client_send_cb)(gsupc, msg);
+	return (*gsup_client_send_cb)(gsupc, msg);
 };
 
 static int count(struct llist_head *head)
@@ -714,7 +714,7 @@
 	cleanup_test();
 }
 
-int my_gprs_gsup_client_send_dummy(struct gprs_gsup_client *gsupc, struct msgb *msg)
+int my_gsup_client_send_dummy(struct gsup_client *gsupc, struct msgb *msg)
 {
 	msgb_free(msg);
 	return 0;
@@ -1281,7 +1281,7 @@
 	cleanup_test();
 }
 
-int my_gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg)
+int my_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
 {
 	struct osmo_gsup_message to_peer = {0};
 	struct osmo_gsup_message from_peer = {0};
@@ -1323,7 +1323,7 @@
 		return 0;
 	}
 
-	reply_msg = gprs_gsup_msgb_alloc();
+	reply_msg = gsup_client_msgb_alloc();
 	reply_msg->l2h = reply_msg->data;
 	osmo_gsup_encode(reply_msg, &from_peer);
 	gprs_subscr_rx_gsup_message(reply_msg);
@@ -1338,9 +1338,9 @@
 	struct gsm_subscriber *subscr;
 
 	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
-	gprs_gsup_client_send_cb = my_gprs_gsup_client_send;
+	gsup_client_send_cb = my_gsup_client_send;
 
-	sgsn->gsup_client = talloc_zero(tall_bsc_ctx, struct gprs_gsup_client);
+	sgsn->gsup_client = talloc_zero(tall_bsc_ctx, struct gsup_client);
 
 	if (retry) {
 		upd_loc_skip = 3;
@@ -1355,7 +1355,7 @@
 	assert_no_subscrs();
 
 	sgsn->cfg.auth_policy = saved_auth_policy;
-	gprs_gsup_client_send_cb = __real_gprs_gsup_client_send;
+	gsup_client_send_cb = __real_gsup_client_send;
 	upd_loc_skip = 0;
 	auth_info_skip = 0;
 	talloc_free(sgsn->gsup_client);
@@ -2239,7 +2239,7 @@
 
 	printf("Testing GGSN selection\n");
 
-	gprs_gsup_client_send_cb = my_gprs_gsup_client_send_dummy;
+	gsup_client_send_cb = my_gsup_client_send_dummy;
 
 	/* Check for emptiness */
 	OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
@@ -2358,7 +2358,7 @@
 	sgsn_ggsn_ctx_free(ggcs[1]);
 	sgsn_ggsn_ctx_free(ggcs[2]);
 
-	gprs_gsup_client_send_cb = __real_gprs_gsup_client_send;
+	gsup_client_send_cb = __real_gsup_client_send;
 
 	cleanup_test();
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I57433973b1c4f6cc1e12e7b1c96b5f719f418b51
Gerrit-PatchSet: 4
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list