Browse code

Stub implementation of "--dhcp-option DNS6 <v6addr>"

This defines a new DHCP suboption "DNS6", but does not actually
implement anything but "document the option and understand it".

If received, it will be put into an "foreign_option_<n>" environment
variable where an --up script or plugin could receive and act upon it.

On non-Windows platforms, all "dhcp-option" sub-options end up there,
so v4 and v6 DNS options will be reflected like this:

foreign_option_1=dhcp-option DNS6 2001:608::2
foreign_option_2=dhcp-option DNS 195.30.0.2

v2: do not set o->dhcp_options if DNS6 is the single dhcp-option seen
(spotted by Selva Nair)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1479746562-751-1-git-send-email-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13174.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Gert Doering authored on 2016/11/22 01:42:42
Showing 2 changed files
... ...
@@ -5627,9 +5627,21 @@ across the VPN.
5627 5627
 Set Connection-specific DNS Suffix.
5628 5628
 
5629 5629
 .B DNS addr \-\-
5630
-Set primary domain name server address.  Repeat
5630
+Set primary domain name server IPv4 address.  Repeat
5631 5631
 this option to set secondary DNS server addresses.
5632 5632
 
5633
+.B DNS6 addr \-\-
5634
+Set primary domain name server IPv6 address.  Repeat
5635
+this option to set secondary DNS server IPv6 addresses.
5636
+
5637
+Note: currently this is somewhat of a placeholder option - it is
5638
+understood, but OpenVPN has no code to tell Windows about it (the
5639
+existing DHCP code can only do IPv4 DHCP, and that protocol only
5640
+permits IPv4 addresses anywhere).  The option will be put into the
5641
+environment, so an
5642
+.B \-\-up
5643
+script could act upon it.
5644
+
5633 5645
 .B WINS addr \-\-
5634 5646
 Set primary WINS server address (NetBIOS over TCP/IP Name Server).
5635 5647
 Repeat this option to set secondary WINS server addresses.
... ...
@@ -704,7 +704,8 @@ static const char usage_message[] =
704 704
   "                    which allow multiple addresses,\n"
705 705
   "                    --dhcp-option must be repeated.\n"
706 706
   "                    DOMAIN name : Set DNS suffix\n"
707
-  "                    DNS addr    : Set domain name server address(es)\n"
707
+  "                    DNS addr    : Set domain name server address(es) (IPv4)\n"
708
+  "                    DNS6 addr   : Set domain name server address(es) (IPv6)\n"
708 709
   "                    NTP         : Set NTP server address(es)\n"
709 710
   "                    NBDD        : Set NBDD server address(es)\n"
710 711
   "                    WINS addr   : Set WINS server address(es)\n"
... ...
@@ -6406,6 +6407,14 @@ add_option (struct options *options,
6406 6406
 	{
6407 6407
 	  dhcp_option_address_parse ("DNS", p[2], o->dns, &o->dns_len, msglevel);
6408 6408
 	}
6409
+      else if (streq (p[1], "DNS6") && p[2])
6410
+	{
6411
+	  /* this is somewhat of a placeholder - we understand the option,
6412
+	   * but cannot act upon it - so we'll just accept it and put it
6413
+	   * into the environment, as we would do on all non-win32 platforms
6414
+	   */
6415
+	  foreign_option (options, p, 3, es);
6416
+	}
6409 6417
       else if (streq (p[1], "WINS") && p[2])
6410 6418
 	{
6411 6419
 	  dhcp_option_address_parse ("WINS", p[2], o->wins, &o->wins_len, msglevel);
... ...
@@ -6427,7 +6436,14 @@ add_option (struct options *options,
6427 6427
 	  msg (msglevel, "--dhcp-option: unknown option type '%s' or missing or unknown parameter", p[1]);
6428 6428
 	  goto err;
6429 6429
 	}
6430
-      o->dhcp_options = true;
6430
+
6431
+      /* flag that we have options to give to the TAP driver's DHCPv4 server
6432
+       *  - skipped for "DNS6", as that's not a DHCPv4 option
6433
+       */
6434
+      if (!streq (p[1], "DNS6"))
6435
+	{
6436
+	  o->dhcp_options = true;
6437
+	}
6431 6438
     }
6432 6439
 #endif
6433 6440
 #ifdef _WIN32