app/mncc: Add "use-imsi" to allow calling by IMSI
In case one is using a PBX it might be the easiest just to call based on IMSI. Add a VTY option to enable/disable this feature. It can be used to keep the number assignment outside of the HLR database.
This commit is contained in:
parent
0e9434184e
commit
3d2787646b
|
@ -20,7 +20,7 @@ struct app_config {
|
|||
struct mncc_connection conn;
|
||||
} mncc;
|
||||
|
||||
//int use_imsi_as_id;
|
||||
int use_imsi_as_id;
|
||||
};
|
||||
|
||||
extern struct app_config g_app;
|
||||
|
|
|
@ -251,6 +251,10 @@ static void continue_mo_call(struct mncc_call_leg *leg)
|
|||
dest = talloc_asprintf(tall_mncc_ctx, "+%.32s", leg->called.number);
|
||||
else
|
||||
dest = talloc_asprintf(tall_mncc_ctx, "%.32s", leg->called.number);
|
||||
|
||||
if (leg->conn->app->use_imsi_as_id)
|
||||
source = talloc_asprintf(tall_mncc_ctx, "%.16s", leg->imsi);
|
||||
else
|
||||
source = talloc_asprintf(tall_mncc_ctx, "%.32s", leg->calling.number);
|
||||
|
||||
app_route_call(leg->base.call, source, dest);
|
||||
|
@ -651,10 +655,14 @@ int mncc_create_remote_leg(struct mncc_connection *conn, struct call *call,
|
|||
mncc.calling.type = 0x0;
|
||||
memcpy(&mncc.calling.number, calling, sizeof(mncc.calling.number));
|
||||
|
||||
if (conn->app->use_imsi_as_id) {
|
||||
snprintf(mncc.imsi, 16, called);
|
||||
} else {
|
||||
mncc.fields |= MNCC_F_CALLED;
|
||||
mncc.called.plan = 1;
|
||||
mncc.called.type = 0x0;
|
||||
memcpy(&mncc.called.number, called, sizeof(mncc.called.number));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO/FIXME:
|
||||
|
|
20
src/vty.c
20
src/vty.c
|
@ -99,6 +99,8 @@ static int config_write_mncc(struct vty *vty)
|
|||
static int config_write_app(struct vty *vty)
|
||||
{
|
||||
vty_out(vty, "app%s", VTY_NEWLINE);
|
||||
if (g_app.use_imsi_as_id)
|
||||
vty_out(vty, " use-imsi%s", VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -153,6 +155,22 @@ DEFUN(cfg_app, cfg_app_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_use_imsi, cfg_use_imsi_cmd,
|
||||
"use-imsi",
|
||||
"Use the IMSI for MO calling and MT called address\n")
|
||||
{
|
||||
g_app.use_imsi_as_id = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_no_use_imsi, cfg_no_use_imsi_cmd,
|
||||
"no use-imsi",
|
||||
NO_STR "Use the IMSI for MO calling and MT called address\n")
|
||||
{
|
||||
g_app.use_imsi_as_id = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
void mncc_sip_vty_init(void)
|
||||
{
|
||||
/* default values */
|
||||
|
@ -176,4 +194,6 @@ void mncc_sip_vty_init(void)
|
|||
|
||||
install_element(CONFIG_NODE, &cfg_app_cmd);
|
||||
install_node(&app_node, config_write_app);
|
||||
install_element(APP_NODE, &cfg_use_imsi_cmd);
|
||||
install_element(APP_NODE, &cfg_no_use_imsi_cmd);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue