aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/include/openbsc/sgsn.h1
-rw-r--r--openbsc/src/gprs/sgsn_ares.c8
-rw-r--r--openbsc/src/gprs/sgsn_vty.c18
3 files changed, 26 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/sgsn.h b/openbsc/include/openbsc/sgsn.h
index a92bfc65d..0b61da952 100644
--- a/openbsc/include/openbsc/sgsn.h
+++ b/openbsc/include/openbsc/sgsn.h
@@ -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;
diff --git a/openbsc/src/gprs/sgsn_ares.c b/openbsc/src/gprs/sgsn_ares.c
index 825b01c5b..c4012a4e3 100644
--- a/openbsc/src/gprs/sgsn_ares.c
+++ b/openbsc/src/gprs/sgsn_ares.c
@@ -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;
}
diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index 65b5a39e1..70d299b42 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -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;
}