nat: Inform others if an IMSI is rejected

In case one wants to monitor the access lists one
there is now a trap for the IMSI.
This commit is contained in:
Holger Hans Peter Freyther 2015-04-05 13:45:53 +02:00
parent fa1cba9e60
commit 7c00983275
3 changed files with 26 additions and 0 deletions

View File

@ -498,6 +498,10 @@ int bsc_nat_handle_ctrlif_msg(struct bsc_connection *bsc, struct msgb *msg);
int bsc_nat_extract_lac(struct bsc_connection *bsc, struct nat_sccp_connection *con,
struct bsc_nat_parsed *parsed, struct msgb *msg);
/**
* CTRL interface helper
*/
void bsc_nat_inform_reject(struct bsc_connection *bsc, const char *imsi);
/*
* Use for testing

View File

@ -1060,6 +1060,8 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
filter = bsc_nat_filter_sccp_cr(bsc, msg, parsed,
&con_type, &imsi, &cause);
if (filter < 0) {
if (imsi)
bsc_nat_inform_reject(bsc, imsi);
bsc_stat_reject(filter, bsc, 0);
goto exit3;
}
@ -1091,6 +1093,8 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
filter = bsc_nat_filter_dt(bsc, msg,
con, parsed, &cause);
if (filter < 0) {
if (imsi)
bsc_nat_inform_reject(bsc, imsi);
bsc_stat_reject(filter, bsc, 1);
bsc_send_con_release(bsc, con, &cause);
con = NULL;

View File

@ -412,3 +412,21 @@ error:
return NULL;
}
void bsc_nat_inform_reject(struct bsc_connection *conn, const char *imsi)
{
struct ctrl_cmd *cmd;
cmd = ctrl_cmd_create(conn, CTRL_TYPE_TRAP);
if (!cmd) {
LOGP(DCTRL, LOGL_ERROR, "Failed to create TRAP command.\n");
return;
}
cmd->id = "0";
cmd->variable = talloc_asprintf(cmd, "net.0.bsc.%d.notification-rejection-v1",
conn->cfg->nr);
cmd->reply = talloc_asprintf(cmd, "imsi=%s", imsi);
ctrl_cmd_send_to_all(conn->cfg->nat->ctrl, cmd);
talloc_free(cmd);
}