aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-11 16:13:38 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-27 22:15:04 +0200
commita30f47613abb7c22a26d534d66e478265a8c2c09 (patch)
tree04374e0b4f096c71e9fb0a8f5262b2a3aa7c672d
parent51c57045e533caaa51ca5acf8929628c21dd6b94 (diff)
misc: Add an option exit/quit when the BSSGP is supposed to be destroyed
The PCU does not properly re-set the state when the connection to the BTS is lost (and the SGSN potentially is re-started during that). This results in the BSSGP BVCI > 1 remaining blocked and no data will be accepted by the SGSN. Add the '-e' option and exit the PCU when the BSSGP/NS are getting destroyed.
-rw-r--r--src/gprs_bssgp_pcu.cpp13
-rw-r--r--src/gprs_bssgp_pcu.h3
-rw-r--r--src/openbts_sock.cpp2
-rw-r--r--src/pcu_l1_if.cpp2
-rw-r--r--src/pcu_main.cpp7
-rw-r--r--src/sysmo_sock.cpp2
6 files changed, 23 insertions, 6 deletions
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index c791913..59185e3 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -27,6 +27,7 @@ struct bssgp_bvc_ctx *bctx = NULL;
struct gprs_nsvc *nsvc = NULL;
static int bvc_sig_reset = 0, bvc_reset = 0, bvc_unblocked = 0;
extern uint16_t spoof_mcc, spoof_mnc;
+static int exit_on_destroy = 0;
struct osmo_timer_list bvc_timer;
@@ -640,8 +641,13 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip,
return 0;
}
-void gprs_bssgp_destroy(void)
+void gprs_bssgp_destroy_or_exit(void)
{
+ if (exit_on_destroy) {
+ LOGP(DBSSGP, LOGL_NOTICE, "Exiting on BSSGP destruction.\n");
+ exit(0);
+ }
+
if (!bssgp_nsi)
return;
@@ -662,3 +668,8 @@ void gprs_bssgp_destroy(void)
bssgp_nsi = NULL;
}
+void gprs_bssgp_exit_on_destroy(void)
+{
+ LOGP(DBSSGP, LOGL_NOTICE, "Going to quit on BSSGP destruction\n");
+ exit_on_destroy = 1;
+}
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index d669c3a..dc57e4f 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -56,6 +56,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, uint16_t
uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac,
uint16_t cell_id);
-void gprs_bssgp_destroy(void);
+void gprs_bssgp_exit_on_destroy(void);
+void gprs_bssgp_destroy_or_exit(void);
#endif // GPRS_BSSGP_PCU_H
diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp
index 845aa77..a09f834 100644
--- a/src/openbts_sock.cpp
+++ b/src/openbts_sock.cpp
@@ -179,7 +179,7 @@ int pcu_l1if_open()
void pcu_l1if_close(void)
{
- gprs_bssgp_destroy();
+ gprs_bssgp_destroy_or_exit();
/* FIXME: cleanup l1if */
talloc_free(l1fh->fl1h);
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 923070f..037cf60 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -369,7 +369,7 @@ bssgp_failed:
trx, ts);
}
}
- gprs_bssgp_destroy();
+ gprs_bssgp_destroy_or_exit();
return 0;
}
LOGP(DL1IF, LOGL_INFO, "BTS available\n");
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 041831f6..754043f 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -60,6 +60,7 @@ static void print_help()
"provided by BTS\n"
" -r --realtime PRIO Use SCHED_RR with the specified "
"priority\n"
+ " -e --exit Exit the application on disconnect\n"
);
}
@@ -75,10 +76,11 @@ static void handle_options(int argc, char **argv)
{ "mnc", 1, 0, 'n' },
{ "version", 0, 0, 'V' },
{ "realtime", 1, 0, 'r' },
+ { "exit", 0, 0, 'e' },
{ 0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "hc:m:n:Vr:",
+ c = getopt_long(argc, argv, "hc:m:n:Vr:e",
long_options, &option_idx);
if (c == -1)
break;
@@ -105,6 +107,9 @@ static void handle_options(int argc, char **argv)
case 'r':
rt_prio = atoi(optarg);
break;
+ case 'e':
+ gprs_bssgp_exit_on_destroy();
+ break;
default:
fprintf(stderr, "Unknown option '%c'\n", c);
exit(0);
diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp
index d4fb5a6..e116e5a 100644
--- a/src/sysmo_sock.cpp
+++ b/src/sysmo_sock.cpp
@@ -117,7 +117,7 @@ static void pcu_sock_close(struct pcu_sock_state *state, int lost)
}
}
- gprs_bssgp_destroy();
+ gprs_bssgp_destroy_or_exit();
if (lost) {
state->timer.cb = pcu_sock_timeout;