summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/include/events.h9
-rw-r--r--accel-pppd/ppp/ipcp_opt_dns.c14
-rw-r--r--accel-pppd/ppp/ppp_ipcp.c6
-rw-r--r--accel-pppd/radius/radius.c20
4 files changed, 45 insertions, 4 deletions
diff --git a/accel-pppd/include/events.h b/accel-pppd/include/events.h
index a59ee31..4e48fe1 100644
--- a/accel-pppd/include/events.h
+++ b/accel-pppd/include/events.h
@@ -2,6 +2,7 @@
#define __EVENTS_H
#include <stdint.h>
+#include <netinet/in.h>
#define EV_PPP_STARTING 1
#define EV_PPP_STARTED 2
@@ -18,6 +19,7 @@
#define EV_IP_CHANGED 100
#define EV_SHAPER 101
#define EV_MPPE_KEYS 102
+#define EV_DNS 103
#define EV_RADIUS_ACCESS_ACCEPT 200
#define EV_RADIUS_COA 201
@@ -46,5 +48,12 @@ struct ev_shaper_t
const char *val;
};
+struct ev_dns_t
+{
+ struct ppp_t *ppp;
+ in_addr_t dns1;
+ in_addr_t dns2;
+};
+
#endif
diff --git a/accel-pppd/ppp/ipcp_opt_dns.c b/accel-pppd/ppp/ipcp_opt_dns.c
index 4427b0e..19183eb 100644
--- a/accel-pppd/ppp/ipcp_opt_dns.c
+++ b/accel-pppd/ppp/ipcp_opt_dns.c
@@ -37,6 +37,7 @@ static struct ipcp_option_handler_t dns1_opt_hnd=
.free=dns_free,
.print=dns1_print,
};
+
static struct ipcp_option_handler_t dns2_opt_hnd=
{
.init=dns2_init,
@@ -139,6 +140,17 @@ static void dns2_print(void (*print)(const char *fmt,...),struct ipcp_option_t *
print("<dns2 %s>",inet_ntoa(in));
}
+static void ev_dns(struct ev_dns_t *ev)
+{
+ struct dns_option_t *dns_opt;
+
+ dns_opt = container_of(ipcp_find_option(ev->ppp, &dns1_opt_hnd), typeof(*dns_opt), opt);
+ dns_opt->addr = ev->dns1;
+
+ dns_opt = container_of(ipcp_find_option(ev->ppp, &dns2_opt_hnd), typeof(*dns_opt), opt);
+ dns_opt->addr = ev->dns2;
+}
+
static void load_config(void)
{
char *opt;
@@ -159,6 +171,8 @@ static void dns_opt_init()
load_config();
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
+
+ triton_event_register_handler(EV_DNS, (triton_event_func)ev_dns);
}
DEFINE_INIT(4, dns_opt_init);
diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c
index 8af84ca..625358a 100644
--- a/accel-pppd/ppp/ppp_ipcp.c
+++ b/accel-pppd/ppp/ppp_ipcp.c
@@ -91,6 +91,9 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp)
ppp_register_unit_handler(ppp, &ipcp->hnd);
+ INIT_LIST_HEAD(&ipcp->options);
+ ipcp_options_init(ipcp);
+
ipcp->fsm.proto = PPP_IPCP;
ppp_fsm_init(&ipcp->fsm);
@@ -104,7 +107,6 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp)
ipcp->fsm.send_term_req = send_term_req;
ipcp->fsm.send_term_ack = send_term_ack;
- INIT_LIST_HEAD(&ipcp->options);
INIT_LIST_HEAD(&ipcp->ropt_list);
ipcp->ld.passive = conf_ipv4 == IPV4_ALLOW || conf_ipv4 == IPV4_DENY;
@@ -128,8 +130,6 @@ int ipcp_layer_start(struct ppp_layer_data_t *ld)
log_ppp_debug("ipcp_layer_start\n");
- ipcp_options_init(ipcp);
-
ipcp->starting = 1;
if (conf_ipv4 != IPV4_DENY) {
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index c24522d..57e6dba 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -57,13 +57,28 @@ int rad_proc_attrs(struct rad_req_t *req)
{
struct rad_attr_t *attr;
struct ipv6db_addr_t *a;
+ struct ev_dns_t dns;
int res = 0;
+ dns.ppp = NULL;
req->rpd->acct_interim_interval = conf_acct_interim_interval;
list_for_each_entry(attr, &req->reply->attrs, entry) {
- if (attr->vendor)
+ if (attr->vendor && attr->vendor->id == Vendor_Microsoft) {
+ switch (attr->attr->id) {
+ case MS_Primary_DNS_Server:
+ dns.ppp = req->rpd->ppp;
+ dns.dns1 = attr->val.ipaddr;
+ break;
+ case MS_Secondary_DNS_Server:
+ dns.ppp = req->rpd->ppp;
+ dns.dns2 = attr->val.ipaddr;
+ break;
+ }
continue;
+ } else if (attr->vendor)
+ continue;
+
switch(attr->attr->id) {
case Framed_IP_Address:
if (!conf_gw_ip_address)
@@ -123,6 +138,9 @@ int rad_proc_attrs(struct rad_req_t *req)
}
}
+ if (dns.ppp)
+ triton_event_fire(EV_DNS, &dns);
+
return res;
}