mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
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
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
struct bsc_msc_connection {
|
||||
struct write_queue write_queue;
|
||||
int is_connected;
|
||||
int is_authenticated;
|
||||
const char *ip;
|
||||
int port;
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user