summaryrefslogtreecommitdiffhomepage
path: root/src/odhcpd.c
diff options
context:
space:
mode:
authorsbyx <steven@midlink.org>2014-10-30 14:23:35 +0100
committersbyx <steven@midlink.org>2014-10-30 14:23:35 +0100
commitee243b09f3c81f824cc463c1c757e905f882350e (patch)
tree4e23443cfbfc557a5babdf262e73f8898c9f3e34 /src/odhcpd.c
parenta408b9648f04962113ee6bf3d4a2dbddc9b0394e (diff)
parentd94b406eeba27af2a6abff333dc16e82d28ed636 (diff)
Merge pull request #30 from dedeckeh/bugfixes
Fix IPv6 DNS server adddress selection
Diffstat (limited to 'src/odhcpd.c')
-rw-r--r--src/odhcpd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/odhcpd.c b/src/odhcpd.c
index 0edf63e..3c384e8 100644
--- a/src/odhcpd.c
+++ b/src/odhcpd.c
@@ -263,6 +263,25 @@ ssize_t odhcpd_get_interface_addresses(int ifindex,
return ret;
}
+int odhcpd_get_preferred_interface_address(int ifindex, struct in6_addr *addr)
+{
+ struct odhcpd_ipaddr ipaddrs[8];
+ ssize_t ip_cnt = odhcpd_get_interface_addresses(ifindex, ipaddrs, ARRAY_SIZE(ipaddrs));
+ uint32_t preferred = 0;
+ int ret = 0;
+
+ for (ssize_t i = 0; i < ip_cnt; i++) {
+ struct odhcpd_ipaddr *ipaddr = &ipaddrs[i];
+
+ if (ipaddr->preferred > preferred || !preferred) {
+ preferred = ipaddr->preferred;
+ *addr = ipaddr->addr;
+ ret = 1;
+ }
+ }
+
+ return ret;
+}
struct interface* odhcpd_get_interface_by_index(int ifindex)
{