sgsn: Allow to specify the DNS servers that should be used
If no server is specified the default list will be used. This allows to separate the servers for the local network and GRX from each other.
This commit is contained in:
parent
39c430ee29
commit
a5a6da46a0
|
@ -68,6 +68,7 @@ struct sgsn_instance {
|
|||
struct osmo_timer_list ares_timer;
|
||||
struct llist_head ares_fds;
|
||||
ares_channel ares_channel;
|
||||
struct ares_addr_node *ares_servers;
|
||||
};
|
||||
|
||||
extern struct sgsn_instance *sgsn;
|
||||
|
|
|
@ -157,10 +157,16 @@ int sgsn_ares_init(struct sgsn_instance *sgsn)
|
|||
|
||||
optmask = ARES_OPT_FLAGS | ARES_OPT_SOCK_STATE_CB;
|
||||
|
||||
/*| ARES_OPT_SERVERS ... TODO..*/
|
||||
if (sgsn->ares_servers)
|
||||
optmask |= ARES_OPT_SERVERS;
|
||||
|
||||
ares_library_init(ARES_LIB_INIT_ALL);
|
||||
rc = ares_init_options(&sgsn->ares_channel, &options, optmask);
|
||||
if (rc != ARES_SUCCESS)
|
||||
return rc;
|
||||
|
||||
if (sgsn->ares_servers)
|
||||
rc = ares_set_servers(sgsn->ares_channel, sgsn->ares_servers);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ static int config_write_sgsn(struct vty *vty)
|
|||
struct sgsn_ggsn_ctx *gctx;
|
||||
struct imsi_acl_entry *acl;
|
||||
struct apn_ctx *actx;
|
||||
struct ares_addr_node *server;
|
||||
|
||||
vty_out(vty, "sgsn%s", VTY_NEWLINE);
|
||||
|
||||
|
@ -147,6 +148,9 @@ static int config_write_sgsn(struct vty *vty)
|
|||
if (sgsn->cfg.dynamic_lookup)
|
||||
vty_out(vty, " ggsn dynamic%s", VTY_NEWLINE);
|
||||
|
||||
for (server = sgsn->ares_servers; server; server = server->next)
|
||||
vty_out(vty, " grx-dns-add %s%s", inet_ntoa(server->addr.addr4), VTY_NEWLINE);
|
||||
|
||||
vty_out(vty, " auth-policy %s%s",
|
||||
get_value_string(sgsn_auth_pol_strs, g_cfg->auth_policy),
|
||||
VTY_NEWLINE);
|
||||
|
@ -250,6 +254,19 @@ DEFUN(cfg_ggsn_dynamic_lookup, cfg_ggsn_dynamic_lookup_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_grx_ggsn, cfg_grx_ggsn_cmd,
|
||||
"grx-dns-add A.B.C.D",
|
||||
"Add DNS server\nIPv4 address\n")
|
||||
{
|
||||
struct ares_addr_node *node = talloc_zero(tall_bsc_ctx, struct ares_addr_node);
|
||||
node->family = AF_INET;
|
||||
inet_aton(argv[0], &node->addr.addr4);
|
||||
|
||||
node->next = sgsn->ares_servers;
|
||||
sgsn->ares_servers = node;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
#define APN_STR "Configure the information per APN\n"
|
||||
#define APN_GW_STR "The APN gateway name optionally prefixed by '*' (wildcard)\n"
|
||||
|
||||
|
@ -893,6 +910,7 @@ int sgsn_vty_init(void)
|
|||
install_element(SGSN_NODE, &cfg_no_cdr_filename_cmd);
|
||||
install_element(SGSN_NODE, &cfg_cdr_interval_cmd);
|
||||
install_element(SGSN_NODE, &cfg_ggsn_dynamic_lookup_cmd);
|
||||
install_element(SGSN_NODE, &cfg_grx_ggsn_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue