Add control command to expire subscriber
It's equivalent of existing vty command: common part is extracted into shared helper function. Change-Id: I267886b7c79ed6d9c2f34a2e60d2972b7f4f4036
This commit is contained in:
parent
a263bb215b
commit
dcc193d3a6
|
@ -279,7 +279,7 @@ void vlr_loc_update_conn_timeout(struct osmo_fsm_inst *fi);
|
|||
|
||||
/* tell the VLR that the subscriber connection is gone */
|
||||
int vlr_subscr_disconnected(struct vlr_subscr *vsub);
|
||||
|
||||
bool vlr_subscr_expire(struct vlr_subscr *vsub);
|
||||
int vlr_subscr_rx_id_resp(struct vlr_subscr *vsub, const uint8_t *mi, size_t mi_len);
|
||||
int vlr_subscr_rx_auth_resp(struct vlr_subscr *vsub, bool is_r99, bool is_utran,
|
||||
const uint8_t *res, uint8_t res_len);
|
||||
|
|
|
@ -59,11 +59,49 @@ static int get_subscriber_list(struct ctrl_cmd *cmd, void *d)
|
|||
}
|
||||
CTRL_CMD_DEFINE_RO(subscriber_list, "subscriber-list-active-v1");
|
||||
|
||||
CTRL_CMD_DEFINE_WO_NOVRF(sub_expire, "subscriber-expire");
|
||||
static int set_sub_expire(struct ctrl_cmd *cmd, void *data)
|
||||
{
|
||||
struct vlr_subscr *vsub;
|
||||
|
||||
if (!msc_ctrl_net) {
|
||||
cmd->reply = "MSC CTRL commands not initialized";
|
||||
return CTRL_CMD_ERROR;
|
||||
}
|
||||
|
||||
if (!msc_ctrl_net->vlr) {
|
||||
cmd->reply = "VLR not initialized";
|
||||
return CTRL_CMD_ERROR;
|
||||
}
|
||||
|
||||
vsub = vlr_subscr_find_by_imsi(msc_ctrl_net->vlr, cmd->value);
|
||||
if (!vsub) {
|
||||
LOGP(DCTRL, LOGL_ERROR, "Attempt to expire unknown subscriber IMSI=%s\n", cmd->value);
|
||||
cmd->reply = "IMSI unknown";
|
||||
return CTRL_CMD_ERROR;
|
||||
}
|
||||
|
||||
LOGP(DCTRL, LOGL_NOTICE, "Expiring subscriber IMSI=%s\n", cmd->value);
|
||||
|
||||
if (vlr_subscr_expire(vsub))
|
||||
LOGP(DCTRL, LOGL_NOTICE, "VLR released subscriber %s\n", vlr_subscr_name(vsub));
|
||||
|
||||
if (vsub->use_count > 1)
|
||||
LOGP(DCTRL, LOGL_NOTICE, "Subscriber %s is still in use, should be released soon\n",
|
||||
vlr_subscr_name(vsub));
|
||||
|
||||
vlr_subscr_put(vsub);
|
||||
|
||||
return CTRL_CMD_REPLY;
|
||||
}
|
||||
|
||||
int msc_ctrl_cmds_install(struct gsm_network *net)
|
||||
{
|
||||
int rc = 0;
|
||||
msc_ctrl_net = net;
|
||||
|
||||
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list);
|
||||
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_sub_expire);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -572,12 +572,9 @@ DEFUN(ena_subscr_expire,
|
|||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (vsub->lu_complete) {
|
||||
vsub->lu_complete = false;
|
||||
vlr_subscr_put(vsub);
|
||||
if (vlr_subscr_expire(vsub))
|
||||
vty_out(vty, "%% VLR released subscriber %s%s",
|
||||
vlr_subscr_name(vsub), VTY_NEWLINE);
|
||||
}
|
||||
|
||||
if (vsub->use_count > 1)
|
||||
vty_out(vty, "%% Subscriber %s is still in use,"
|
||||
|
|
|
@ -948,17 +948,28 @@ int vlr_subscr_rx_tmsi_reall_compl(struct vlr_subscr *vsub)
|
|||
}
|
||||
}
|
||||
|
||||
bool vlr_subscr_expire(struct vlr_subscr *vsub)
|
||||
{
|
||||
if (vsub->lu_complete) {
|
||||
vsub->lu_complete = false;
|
||||
vlr_subscr_put(vsub);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int vlr_subscr_rx_imsi_detach(struct vlr_subscr *vsub)
|
||||
{
|
||||
/* paranoia: should any LU or PARQ FSMs still be running, stop them. */
|
||||
vlr_subscr_cancel(vsub, GMM_CAUSE_IMPL_DETACHED);
|
||||
|
||||
vsub->imsi_detached_flag = true;
|
||||
if (vsub->lu_complete) {
|
||||
vsub->lu_complete = false;
|
||||
/* balancing the get from vlr_lu_compl_fsm_success() */
|
||||
vlr_subscr_put(vsub);
|
||||
}
|
||||
|
||||
/* balancing the get from vlr_lu_compl_fsm_success() */
|
||||
vlr_subscr_expire(vsub);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue