[PATCH 2/3] gprs/test: Add connect_sgsn() function

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Mon Jul 7 08:46:00 UTC 2014


This function abstracts identical code sequences that are used at
multiple places.

Sponsored-by: On-Waves ehf
---
 openbsc/tests/gbproxy/gbproxy_test.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index a8f4eaf..ba1c51b 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -193,6 +193,15 @@ static void setup_bssgp(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr,
 	send_bssgp_reset(nsi, src_addr, bvci);
 }
 
+static void connect_sgsn(struct gprs_ns_inst *nsi, struct sockaddr_in *sgsn_peer)
+{
+	gprs_ns_nsip_connect(nsi, sgsn_peer, SGSN_NSEI, SGSN_NSEI+1);
+	send_ns_reset_ack(nsi, sgsn_peer, SGSN_NSEI+1, SGSN_NSEI);
+	send_ns_alive_ack(nsi, sgsn_peer);
+	send_ns_unblock_ack(nsi, sgsn_peer);
+	send_ns_alive(nsi, sgsn_peer);
+}
+
 int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
 		   struct sockaddr_in *saddr, enum gprs_ns_ll ll);
 
@@ -408,11 +417,7 @@ static void test_gbproxy()
 
 	printf("--- Initialise SGSN ---\n\n");
 
-	gprs_ns_nsip_connect(nsi, &sgsn_peer, SGSN_NSEI, SGSN_NSEI+1);
-	send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI);
-	send_ns_alive_ack(nsi, &sgsn_peer);
-	send_ns_unblock_ack(nsi, &sgsn_peer);
-	send_ns_alive(nsi, &sgsn_peer);
+	connect_sgsn(nsi, &sgsn_peer);
 	gprs_dump_nsi(nsi);
 
 	printf("--- Initialise BSS 1 ---\n\n");
@@ -569,11 +574,7 @@ static void test_gbproxy_ident_changes()
 
 	printf("--- Initialise SGSN ---\n\n");
 
-	gprs_ns_nsip_connect(nsi, &sgsn_peer, SGSN_NSEI, SGSN_NSEI+1);
-	send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI);
-	send_ns_alive_ack(nsi, &sgsn_peer);
-	send_ns_unblock_ack(nsi, &sgsn_peer);
-	send_ns_alive(nsi, &sgsn_peer);
+	connect_sgsn(nsi, &sgsn_peer);
 	gprs_dump_nsi(nsi);
 
 	printf("--- Initialise BSS 1 ---\n\n");
-- 
1.9.1





More information about the OpenBSC mailing list