]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1186] Part 4 of review changes
authorTomek Mrugalski <tomasz@isc.org>
Tue, 11 Oct 2011 17:48:55 +0000 (19:48 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 14 Oct 2011 14:31:14 +0000 (16:31 +0200)
 - added consts in packOption6, unpackOptions6
 - removed version() method
 - alignments fixed in dhcp6.h

src/lib/dhcp/Makefile.am
src/lib/dhcp/dhcp6.h
src/lib/dhcp/libdhcp.cc
src/lib/dhcp/libdhcp.h
src/lib/dhcp/tests/libdhcp_unittest.cc

index f87e2b57fd2a18befc854d54c2f881187f1c12d1..e146adb294779d90ecf917e0afcfe827e7134148 100644 (file)
@@ -22,5 +22,4 @@ EXTRA_DIST  = README
 
 libdhcp_la_CXXFLAGS = $(AM_CXXFLAGS)
 libdhcp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
-libdhcp_la_LDFLAGS  = $(LOG4CPLUS_LDFLAGS)
 libdhcp_la_LIBADD   = $(top_builddir)/src/lib/util/libutil.la
index b3ee0bfd7b33b6ffb5b40851c17ac7df9d85935a..6012003b96b9edb6aa2b7e045f86dbf4b011592f 100644 (file)
 #define D6O_IA_NA                               3
 #define D6O_IA_TA                               4
 #define D6O_IAADDR                              5
-#define D6O_ORO                                         6
+#define D6O_ORO                                 6
 #define D6O_PREFERENCE                          7
 #define D6O_ELAPSED_TIME                        8
 #define D6O_RELAY_MSG                           9
 /* Option code 10 unassigned. */
 #define D6O_AUTH                                11
 #define D6O_UNICAST                             12
-#define D6O_STATUS_CODE                                 13
+#define D6O_STATUS_CODE                         13
 #define D6O_RAPID_COMMIT                        14
 #define D6O_USER_CLASS                          15
 #define D6O_VENDOR_CLASS                        16
-#define D6O_VENDOR_OPTS                                 17
+#define D6O_VENDOR_OPTS                         17
 #define D6O_INTERFACE_ID                        18
 #define D6O_RECONF_MSG                          19
 #define D6O_RECONF_ACCEPT                       20
@@ -43,7 +43,7 @@
 #define D6O_DOMAIN_SEARCH                       24 /* RFC3646 */
 #define D6O_IA_PD                               25 /* RFC3633 */
 #define D6O_IAPREFIX                            26 /* RFC3633 */
-#define D6O_NIS_SERVERS                                 27 /* RFC3898 */
+#define D6O_NIS_SERVERS                         27 /* RFC3898 */
 #define D6O_NISP_SERVERS                        28 /* RFC3898 */
 #define D6O_NIS_DOMAIN_NAME                     29 /* RFC3898 */
 #define D6O_NISP_DOMAIN_NAME                    30 /* RFC3898 */
 #define D6O_GEOCONF_CIVIC                       36 /* RFC4776 */
 #define D6O_REMOTE_ID                           37 /* RFC4649 */
 #define D6O_SUBSCRIBER_ID                       38 /* RFC4580 */
-#define D6O_CLIENT_FQDN                                 39 /* RFC4704 */
+#define D6O_CLIENT_FQDN                         39 /* RFC4704 */
 #define D6O_PANA_AGENT                          40 /* paa-option */
 #define D6O_NEW_POSIX_TIMEZONE                  41 /* RFC4833 */
 #define D6O_NEW_TZDB_TIMEZONE                   42 /* RFC4833 */
-#define D6O_ERO                                         43 /* RFC4994 */
+#define D6O_ERO                                 43 /* RFC4994 */
 #define D6O_LQ_QUERY                            44 /* RFC5007 */
-#define D6O_CLIENT_DATA                                 45 /* RFC5007 */
+#define D6O_CLIENT_DATA                         45 /* RFC5007 */
 #define D6O_CLT_TIME                            46 /* RFC5007 */
 #define D6O_LQ_RELAY_DATA                       47 /* RFC5007 */
 #define D6O_LQ_CLIENT_LINK                      48 /* RFC5007 */
@@ -76,7 +76,7 @@
 #define STATUS_NotOnLink         4
 #define STATUS_UseMulticast      5
 #define STATUS_NoPrefixAvail     6
-#define STATUS_UnknownQueryType          7
+#define STATUS_UnknownQueryType  7
 #define STATUS_MalformedQuery    8
 #define STATUS_NotConfigured     9
 #define STATUS_NotAllowed       10
@@ -106,8 +106,8 @@ extern const int dhcpv6_type_name_max;
 /* DUID type definitions (RFC3315 section 9).
  */
 #define DUID_LLT        1
-#define DUID_EN                 2
-#define DUID_LL                 3
+#define DUID_EN         2
+#define DUID_LL         3
 
 /* Offsets into IA_*'s where Option spaces commence.  */
 #define IA_NA_OFFSET 12 /* IAID, T1, T2, all 4 octets each */
index 62326ba7de8174ff88c760ef64c95d89bcf3cf50..df817b78185210b4d4ea262a712a9b13b106e613 100644 (file)
@@ -28,13 +28,9 @@ using namespace isc::dhcp;
 // static array with factories for options
 std::map<unsigned short, Option::Factory*> LibDHCP::v6factories_;
 
-std::string
-LibDHCP::version() {
-    return PACKAGE_VERSION;
-}
-
 unsigned int
-LibDHCP::unpackOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
+LibDHCP::unpackOptions6(const boost::shared_array<uint8_t> buf,
+                        unsigned int buf_len,
                         unsigned int offset, unsigned int parse_len,
                         isc::dhcp::Option::Option6Lst& options) {
     if (offset + parse_len > buf_len) {
@@ -44,7 +40,7 @@ LibDHCP::unpackOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
     }
     unsigned int end = offset + parse_len;
 
-    while (offset<end) {
+    while ( offset +4 <= end ) {
         unsigned int opt_type = buf[offset]*256 + buf[offset+1];
         offset += 2;
         unsigned int opt_len = buf[offset]*256 + buf[offset+1];
@@ -92,9 +88,9 @@ unsigned int
 LibDHCP::packOptions6(boost::shared_array<uint8_t> data,
                       unsigned int data_len,
                       unsigned int offset,
-                      isc::dhcp::Option::Option6Lst& options) {
+                      const isc::dhcp::Option::Option6Lst& options) {
     try {
-        for (isc::dhcp::Option::Option6Lst::iterator it = options.begin();
+        for (isc::dhcp::Option::Option6Lst::const_iterator it = options.begin();
              it != options.end();
              ++it) {
             unsigned short opt_len = (*it).second->len();
index e1fc10fd81a83309c1d40a6ed046331b7f67533b..857e5d1f2629c3ed0795b8161845073a5df2d295 100644 (file)
@@ -24,13 +24,6 @@ namespace dhcp {
 class LibDHCP {
 
 public:
-    /// Returns version of the library.
-    ///
-    /// @return string that contains libdhcp version.
-    ///
-    static std::string
-    version();
-
     /// Builds collection of options.
     ///
     /// Builds raw (on-wire) data for provided collection of options.
@@ -46,7 +39,7 @@ public:
     static unsigned int
     packOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
                  unsigned int offset,
-                 isc::dhcp::Option::Option6Lst& options);
+                 const isc::dhcp::Option::Option6Lst& options);
 
     ///
     /// Parses provided buffer and creates Option objects.
@@ -62,7 +55,7 @@ public:
     /// @return offset to first byte after last parsed option
     ///
     static unsigned int
-    unpackOptions6(boost::shared_array<uint8_t> buf, unsigned int buf_len,
+    unpackOptions6(const boost::shared_array<uint8_t> buf, unsigned int buf_len,
                    unsigned int offset, unsigned int parse_len,
                    isc::dhcp::Option::Option6Lst& options_);
 
index 0766df989694d2d9d88ca25991ae9207683e622c..e553a24b7d00b5eaa9b1bfe39cd0c00c41ecf3ce 100644 (file)
@@ -33,12 +33,6 @@ public:
     }
 };
 
-TEST_F(LibDhcpTest, basic) {
-    // dummy test
-
-    EXPECT_EQ(LibDHCP::version(), PACKAGE_VERSION);
-}
-
 TEST_F(LibDhcpTest, packOptions6) {
     boost::shared_array<uint8_t> buf(new uint8_t[512]);
     isc::dhcp::Option::Option6Lst opts; // list of options