aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-14 08:47:15 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-14 08:49:15 +0200
commit15c21e8eecf14abf80114ba302a003e6d30b6be7 (patch)
treebd91ba8cd9a94c39066b83b04a0d44a95fd3023e
parentc0a1fff064910c854ce5b09ae24479749c22ef17 (diff)
bsc_msc_ip.c: Create the GSM network earlier, send the reset on each connection
Create the GSM network at the end of the init, send the GSM reset on each reconnection and close a small window when we would send a SCCP msg before being authenticated. For that we have introduced an authenticated into the bsc_msc struct and will manage it inside the bsc_msc_ip.c
-rw-r--r--openbsc/include/openbsc/bsc_msc.h1
-rw-r--r--openbsc/src/bsc_msc_ip.c25
2 files changed, 15 insertions, 11 deletions
diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h
index 29ce065d1..ce21bfe43 100644
--- a/openbsc/include/openbsc/bsc_msc.h
+++ b/openbsc/include/openbsc/bsc_msc.h
@@ -29,6 +29,7 @@
struct bsc_msc_connection {
struct write_queue write_queue;
int is_connected;
+ int is_authenticated;
const char *ip;
int port;
diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c
index c44ddaf8f..87f8a4442 100644
--- a/openbsc/src/bsc_msc_ip.c
+++ b/openbsc/src/bsc_msc_ip.c
@@ -217,7 +217,7 @@ static int open_sccp_connection(struct msgb *layer3)
struct msgb *data;
/* When not connected to a MSC. We will simply close things down. */
- if (!msc_con->is_connected) {
+ if (!msc_con->is_authenticated) {
LOGP(DMSC, LOGL_ERROR, "Not connected to a MSC. Not forwarding data.\n");
use_subscr_con(&layer3->lchan->conn);
put_subscr_con(&layer3->lchan->conn, 0);
@@ -762,18 +762,10 @@ static int msc_sccp_read(struct msgb *msgb, unsigned int length, void *data)
*/
static void initialize_if_needed(void)
{
- if (!bsc_gsmnet) {
- int rc;
- struct msgb *msg;
-
- fprintf(stderr, "Bootstraping the network. Sending GSM08.08 reset.\n");
- rc = bsc_bootstrap_network(NULL, config_file);
- if (rc < 0) {
- fprintf(stderr, "Bootstrapping the network failed. exiting.\n");
- exit(1);
- }
+ struct msgb *msg;
+ if (!msc_con->is_authenticated) {
/* send a gsm 08.08 reset message from here */
msg = bssmap_create_reset();
if (!msg) {
@@ -783,6 +775,7 @@ static void initialize_if_needed(void)
sccp_write(msg, &sccp_ssn_bssap, &sccp_ssn_bssap, 0);
msgb_free(msg);
+ msc_con->is_authenticated = 1;
}
}
@@ -839,6 +832,7 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc)
bss_sccp_free_data(bss);
}
+ msc->is_authenticated = 0;
bsc_msc_schedule_connect(msc);
}
@@ -1029,6 +1023,8 @@ extern int bts_model_nanobts_init(void);
int main(int argc, char **argv)
{
+ int rc;
+
log_init(&log_info);
tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
stderr_target = log_target_create_stderr();
@@ -1081,6 +1077,13 @@ int main(int argc, char **argv)
bsc_msc_connect(msc_con);
+ fprintf(stderr, "Bootstraping the network. Sending GSM08.08 reset.\n");
+ rc = bsc_bootstrap_network(NULL, config_file);
+ if (rc < 0) {
+ fprintf(stderr, "Bootstrapping the network failed. exiting.\n");
+ exit(1);
+ }
+
while (1) {
bsc_select_main(0);
}