[nat] Add a token to the nat config and handle ID GET
This allows to chain a nat with a nat by answering to the id get code and sending the token.
This commit is contained in:
parent
f76e7ef5e1
commit
e635dab52f
|
@ -219,6 +219,7 @@ struct bsc_nat {
|
||||||
int msc_port;
|
int msc_port;
|
||||||
int first_contact;
|
int first_contact;
|
||||||
struct bsc_msc_connection *msc_con;
|
struct bsc_msc_connection *msc_con;
|
||||||
|
char *token;
|
||||||
|
|
||||||
/* timeouts */
|
/* timeouts */
|
||||||
int auth_timeout;
|
int auth_timeout;
|
||||||
|
|
|
@ -260,6 +260,16 @@ static void initialize_msc_if_needed()
|
||||||
msc_send_reset(nat->msc_con);
|
msc_send_reset(nat->msc_con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void send_id_get_response()
|
||||||
|
{
|
||||||
|
struct msgb *msg = bsc_msc_id_get_resp(nat->token);
|
||||||
|
if (!msg)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ipaccess_prepend_header(msg, IPAC_PROTO_IPACCESS);
|
||||||
|
queue_for_msc(nat->msc_con, msg);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently we are lacking refcounting so we need to copy each message.
|
* Currently we are lacking refcounting so we need to copy each message.
|
||||||
*/
|
*/
|
||||||
|
@ -455,9 +465,12 @@ static int ipaccess_msc_read_cb(struct bsc_fd *bfd)
|
||||||
ipaccess_rcvmsg_base(msg, bfd);
|
ipaccess_rcvmsg_base(msg, bfd);
|
||||||
|
|
||||||
/* initialize the networking. This includes sending a GSM08.08 message */
|
/* initialize the networking. This includes sending a GSM08.08 message */
|
||||||
if (hh->proto == IPAC_PROTO_IPACCESS && msg->l2h[0] == IPAC_MSGT_ID_ACK)
|
if (hh->proto == IPAC_PROTO_IPACCESS) {
|
||||||
initialize_msc_if_needed();
|
if (msg->l2h[0] == IPAC_MSGT_ID_ACK)
|
||||||
else if (hh->proto == IPAC_PROTO_SCCP)
|
initialize_msc_if_needed();
|
||||||
|
else if (msg->l2h[0] == IPAC_MSGT_ID_GET)
|
||||||
|
send_id_get_response();
|
||||||
|
} else if (hh->proto == IPAC_PROTO_SCCP)
|
||||||
forward_sccp_to_bts(msg);
|
forward_sccp_to_bts(msg);
|
||||||
|
|
||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
|
|
|
@ -61,6 +61,8 @@ static int config_write_nat(struct vty *vty)
|
||||||
vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE);
|
vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE);
|
||||||
vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE);
|
vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE);
|
||||||
vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE);
|
vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE);
|
||||||
|
if (_nat->token)
|
||||||
|
vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,6 +298,16 @@ DEFUN(cfg_nat_pong_time,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFUN(cfg_nat_token, cfg_nat_token_cmd,
|
||||||
|
"token TOKEN",
|
||||||
|
"Set a token for the NAT")
|
||||||
|
{
|
||||||
|
if (_nat->token)
|
||||||
|
talloc_free(_nat->token);
|
||||||
|
_nat->token = talloc_strdup(_nat, argv[0]);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* per BSC configuration */
|
/* per BSC configuration */
|
||||||
DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure")
|
DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure")
|
||||||
{
|
{
|
||||||
|
@ -457,6 +469,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
|
||||||
install_element(NAT_NODE, &cfg_nat_auth_time_cmd);
|
install_element(NAT_NODE, &cfg_nat_auth_time_cmd);
|
||||||
install_element(NAT_NODE, &cfg_nat_ping_time_cmd);
|
install_element(NAT_NODE, &cfg_nat_ping_time_cmd);
|
||||||
install_element(NAT_NODE, &cfg_nat_pong_time_cmd);
|
install_element(NAT_NODE, &cfg_nat_pong_time_cmd);
|
||||||
|
install_element(NAT_NODE, &cfg_nat_token_cmd);
|
||||||
|
|
||||||
/* BSC subgroups */
|
/* BSC subgroups */
|
||||||
install_element(NAT_NODE, &cfg_bsc_cmd);
|
install_element(NAT_NODE, &cfg_bsc_cmd);
|
||||||
|
|
Loading…
Reference in New Issue