SMPP: Fix crash on delivery of incoming SUBMIT-SM

As bsc_gsmnet is NULL at the time we call smpp_openbsc_init(),
we later run into segfaults with subscribers that don't have a
subscr->net set.

However, we cannot delay smpp_openbsc_init() until after
bsc_bootstrap_network(), as we then fail to parse the SMPP specific
VTY/config file options...
This commit is contained in:
Harald Welte 2013-03-13 15:05:26 +01:00
parent 8b29180cad
commit 76afa16d04
2 changed files with 10 additions and 6 deletions

View File

@ -434,18 +434,16 @@ struct smsc *smsc_from_vty(struct vty *v)
}
/*! \brief Initialize the OpenBSC SMPP interface */
int smpp_openbsc_init(struct gsm_network *net, uint16_t port)
int smpp_openbsc_init(void *ctx, uint16_t port)
{
struct smsc *smsc = talloc_zero(net, struct smsc);
struct smsc *smsc = talloc_zero(ctx, struct smsc);
int rc;
smsc->priv = net;
rc = smpp_smsc_init(smsc, port);
if (rc < 0)
talloc_free(smsc);
osmo_signal_register_handler(SS_SMS, smpp_sms_cb, net);
osmo_signal_register_handler(SS_SMS, smpp_sms_cb, smsc);
osmo_signal_register_handler(SS_SUBSCR, smpp_subscr_cb, smsc);
g_smsc = smsc;
@ -454,3 +452,8 @@ int smpp_openbsc_init(struct gsm_network *net, uint16_t port)
return rc;
}
void smpp_openbsc_set_net(struct gsm_network *net)
{
g_smsc->priv = net;
}

View File

@ -263,7 +263,7 @@ int main(int argc, char **argv)
bsc_vty_init(&log_info);
#ifdef BUILD_SMPP
if (smpp_openbsc_init(bsc_gsmnet, 0) < 0)
if (smpp_openbsc_init(tall_bsc_ctx, 0) < 0)
return -1;
#endif
@ -279,6 +279,7 @@ int main(int argc, char **argv)
rc = bsc_bootstrap_network(int_mncc_recv, config_file);
if (rc < 0)
exit(1);
smpp_openbsc_set_net(bsc_gsmnet);
bsc_api_init(bsc_gsmnet, msc_bsc_api());
bsc_gsmnet->ctrl = controlif_setup(bsc_gsmnet, 4249);