From: David Woodhouse Date: Thu, 13 Jun 2019 20:17:28 +0000 (+0100) Subject: Add IPv6 DNS and split routing for Pulse. X-Git-Tag: v8.04~21 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=49fbe6f19ee9245d12bd8d3d37d5fc1ef7483d55;p=users%2Fdwmw2%2Fopenconnect.git Add IPv6 DNS and split routing for Pulse. Signed-off-by: David Woodhouse --- diff --git a/pulse.c b/pulse.c index 48925ebd..9a6b0b49 100644 --- a/pulse.c +++ b/pulse.c @@ -245,6 +245,7 @@ static const char *add_option(struct openconnect_info *vpninfo, const char *opt, static int process_attr(struct openconnect_info *vpninfo, uint16_t type, unsigned char *data, int attrlen) { + struct oc_split_include *xc; char buf[80]; int i; @@ -315,6 +316,71 @@ static int process_attr(struct openconnect_info *vpninfo, uint16_t type, vpn_progress(vpninfo, PRG_DEBUG, _("Received internal IPv6 address %s\n"), buf); break; + case 0x000a: + if (attrlen != 16) + goto badlen; + if (!inet_ntop(AF_INET6, data, buf, sizeof(buf))) { + vpn_progress(vpninfo, PRG_ERR, + _("Failed to handle IPv6 address\n")); + return -EINVAL; + } + + for (i = 0; i < 3; i++) { + if (!vpninfo->ip_info.dns[i]) { + vpninfo->ip_info.dns[i] = add_option(vpninfo, "DNS", buf, -1); + break; + } + } + + vpn_progress(vpninfo, PRG_DEBUG, _("Received DNS server %s\n"), buf); + break; + + case 0x000f: + if (attrlen != 17) + goto badlen; + if (!inet_ntop(AF_INET6, data, buf, sizeof(buf))) { + vpn_progress(vpninfo, PRG_ERR, + _("Failed to handle IPv6 address\n")); + return -EINVAL; + } + i = strlen(buf); + snprintf(buf + i, sizeof(buf) - i, "/%d", data[16]); + + xc = malloc(sizeof(*xc)); + if (xc) { + xc->route = add_option(vpninfo, "split-include6", buf, -1); + if (xc->route) { + xc->next = vpninfo->ip_info.split_includes; + vpninfo->ip_info.split_includes = xc; + } else + free(xc); + } + vpn_progress(vpninfo, PRG_DEBUG, _("Received IPv6 split include %s\n"), buf); + break; + + case 0x0010: + if (attrlen != 17) + goto badlen; + if (!inet_ntop(AF_INET6, data, buf, sizeof(buf))) { + vpn_progress(vpninfo, PRG_ERR, + _("Failed to handle IPv6 address\n")); + return -EINVAL; + } + i = strlen(buf); + snprintf(buf + i, sizeof(buf) - i, "/%d", data[16]); + + xc = malloc(sizeof(*xc)); + if (xc) { + xc->route = add_option(vpninfo, "split-exclude6", buf, -1); + if (xc->route) { + xc->next = vpninfo->ip_info.split_excludes; + vpninfo->ip_info.split_excludes = xc; + } else + free(xc); + } + vpn_progress(vpninfo, PRG_DEBUG, _("Received IPv6 split exclude %s\n"), buf); + break; + case 0x4005: if (attrlen != 4) { badlen: