Browse Source

[master] Merged trac4286 (missing simple standard DHCPv4 options)

Francis Dupont 9 years ago
parent
commit
984e64127b

+ 11 - 0
doc/guide/dhcp4-srv.xml

@@ -1136,8 +1136,19 @@ This rather belong to the DDNS configuration
 -->
 <row><entry>nwip-domain-name</entry><entry>62</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
 <row><entry>nwip-suboptions</entry><entry>63</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
+<row><entry>nisplus-domain-name</entry><entry>64</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
+<row><entry>nisplus-servers</entry><entry>65</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
 <row><entry>tftp-server-name</entry><entry>66</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
 <row><entry>boot-file-name</entry><entry>67</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
+<row><entry>mobile-ip-home-agent</entry><entry>68</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>smtp-server</entry><entry>69</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>pop-server</entry><entry>70</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>nntp-server</entry><entry>71</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>www-server</entry><entry>72</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>finger-server</entry><entry>73</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>irc-server</entry><entry>74</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>streettalk-server</entry><entry>75</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
+<row><entry>streettalk-directory-assistance-server</entry><entry>76</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
 <row><entry>user-class</entry><entry>77</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
 <!-- The Client FQDN option value is not explicitly configured.
 It is a part of the DDNS/D2 configuration

+ 12 - 12
src/lib/dhcp/dhcp4.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2016 Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1995-2003 by Internet Software Consortium
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -128,19 +128,19 @@ enum DHCPOptionType {
     DHO_DHCP_CLIENT_IDENTIFIER       = 61,
     DHO_NWIP_DOMAIN_NAME             = 62,
     DHO_NWIP_SUBOPTIONS              = 63,
-//  DHO_NIS_DOMAIN_NAME              = 64,
-//  DHO_NIS_SERVER_ADDR              = 65,
+    DHO_NISP_DOMAIN_NAME             = 64,
+    DHO_NISP_SERVER_ADDR             = 65,
     DHO_TFTP_SERVER_NAME             = 66,
     DHO_BOOT_FILE_NAME               = 67,
-//  DHO_HOME_AGENT_ADDRS             = 68,
-//  DHO_SMTP_SERVER                  = 69,
-//  DHO_POP3_SERVER                  = 70,
-//  DHO_NNTP_SERVER                  = 71,
-//  DHO_WWW_SERVER                   = 72,
-//  DHO_FINGER_SERVER                = 73,
-//  DHO_IRC_SERVER                   = 74,
-//  DHO_STREETTALK_SERVER            = 75,
-//  DHO_STDASERVER                   = 76,
+    DHO_HOME_AGENT_ADDRS             = 68,
+    DHO_SMTP_SERVER                  = 69,
+    DHO_POP3_SERVER                  = 70,
+    DHO_NNTP_SERVER                  = 71,
+    DHO_WWW_SERVER                   = 72,
+    DHO_FINGER_SERVER                = 73,
+    DHO_IRC_SERVER                   = 74,
+    DHO_STREETTALK_SERVER            = 75,
+    DHO_STDASERVER                   = 76,
     DHO_USER_CLASS                   = 77,
 //  DHO_DIRECTORY_AGENT              = 78,
 //  DHO_SERVICE_SCOPE                = 79,

+ 12 - 1
src/lib/dhcp/std_option_defs.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -169,10 +169,21 @@ const OptionDefParams OPTION_DEF_PARAMS4[] = {
       OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
     { "nwip-domain-name", DHO_NWIP_DOMAIN_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
     { "nwip-suboptions", DHO_NWIP_SUBOPTIONS, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
+    { "nisplus-domain-name", DHO_NISP_DOMAIN_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
+    { "nisplus-servers", DHO_NISP_SERVER_ADDR, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
     { "tftp-server-name", DHO_TFTP_SERVER_NAME, OPT_STRING_TYPE, false,
       NO_RECORD_DEF, "" },
     { "boot-file-name", DHO_BOOT_FILE_NAME, OPT_STRING_TYPE, false,
       NO_RECORD_DEF, "" },
+    { "mobile-ip-home-agent", DHO_HOME_AGENT_ADDRS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "smtp-server", DHO_SMTP_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "pop-server", DHO_POP3_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "nntp-server", DHO_NNTP_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "www-server", DHO_WWW_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "finger-server", DHO_FINGER_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "irc-server", DHO_IRC_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "streettalk-server", DHO_STREETTALK_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
+    { "streettalk-directory-assistance-server", DHO_STDASERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
     { "user-class", DHO_USER_CLASS, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
     { "fqdn", DHO_FQDN, OPT_RECORD_TYPE, false, RECORD_DEF(FQDN_RECORDS), "" },
     { "dhcp-agent-options", DHO_DHCP_AGENT_OPTIONS,

+ 34 - 1
src/lib/dhcp/tests/libdhcp++_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -991,12 +991,45 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
     LibDhcpTest::testStdOptionDefs4(DHO_NWIP_SUBOPTIONS, begin, end,
                                     typeid(Option));
 
+    LibDhcpTest::testStdOptionDefs4(DHO_NISP_DOMAIN_NAME, begin, end,
+                                    typeid(OptionString));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_NISP_SERVER_ADDR, begin, end,
+                                    typeid(Option4AddrLst));
+
     LibDhcpTest::testStdOptionDefs4(DHO_TFTP_SERVER_NAME, begin, end,
                                     typeid(OptionString));
 
     LibDhcpTest::testStdOptionDefs4(DHO_BOOT_FILE_NAME, begin, end,
                                     typeid(OptionString));
 
+    LibDhcpTest::testStdOptionDefs4(DHO_HOME_AGENT_ADDRS, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_SMTP_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_POP3_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_NNTP_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_WWW_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_FINGER_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_IRC_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_STREETTALK_SERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
+    LibDhcpTest::testStdOptionDefs4(DHO_STDASERVER, begin, end,
+                                    typeid(Option4AddrLst));
+
     LibDhcpTest::testStdOptionDefs4(DHO_USER_CLASS, begin, end,
                                     typeid(Option));
 

+ 12 - 1
src/lib/dhcp/tests/option4_addrlst_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -196,6 +196,17 @@ TEST_F(Option4AddrLstTest, assembly4) {
     );
 }
 
+// This test verifies that an option (e.g., mobile-ip-home-agent) can be empty.
+TEST_F(Option4AddrLstTest, empty) {
+
+    scoped_ptr<Option4AddrLst> opt;
+    // the mobile-ip-home-agent option can be empty
+    EXPECT_NO_THROW(opt.reset(new Option4AddrLst(DHO_HOME_AGENT_ADDRS)));
+    Option4AddrLst::AddressContainer addrs = opt->getAddresses();
+    ASSERT_EQ(0, addrs.size());
+    EXPECT_NO_THROW(opt.reset());
+}
+
 TEST_F(Option4AddrLstTest, setAddress) {
 
     scoped_ptr<Option4AddrLst> opt;

+ 5 - 7
src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -210,12 +210,10 @@ TEST(CfgOptionDefTest, overrideStdOptionDef) {
     def.reset(new OptionDefinition("routers", DHO_ROUTERS, "uint32"));
     EXPECT_THROW(cfg.add(def, DHCP4_OPTION_SPACE), isc::BadValue);
 
-    /// @todo There is no definition for the NIS Server Addr option in
-    /// libdhcp++. Once it is implemented it should be not allowed to
-    /// add a custom definition for it. At the moment, it should be ok
-    /// to add a definition for this option (using configuration mechanism)
-    /// because we haven't implemented the one in libdhcp++.
-    def.reset(new OptionDefinition("nis-server-addr", 65, "uint16"));
+    /// There is no definition for the Access Network Domain Name Option
+    /// (RFC5986, option code 213) in libdhcp++. Once it is implemented it
+    /// should be not allowed to add a custom definition for it.
+    def.reset(new OptionDefinition("access-network-domain-name", 213, "string"));
     EXPECT_NO_THROW(cfg.add(def, DHCP4_OPTION_SPACE));
 
     // It is not allowed to override the definition of the option which