diff --git a/Doxyfile b/Doxyfile index ba9b760..cfbbfa3 100644 --- a/Doxyfile +++ b/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = libtins # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1 +PROJECT_NUMBER = 1.2 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -1085,7 +1085,7 @@ SERVER_BASED_SEARCH = NO # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. -GENERATE_LATEX = YES +GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be diff --git a/configure b/configure index 015cc80..a6e2197 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libtins 1.1. +# Generated by GNU Autoconf 2.69 for libtins 1.2. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libtins' PACKAGE_TARNAME='libtins' -PACKAGE_VERSION='1.1' -PACKAGE_STRING='libtins 1.1' +PACKAGE_VERSION='1.2' +PACKAGE_STRING='libtins 1.2' PACKAGE_BUGREPORT='matias.fontanini@gmail.com' PACKAGE_URL='http://libtins.sourceforge.net' @@ -1330,7 +1330,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libtins 1.1 to adapt to many kinds of systems. +\`configure' configures libtins 1.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1401,7 +1401,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libtins 1.1:";; + short | recursive ) echo "Configuration of libtins 1.2:";; esac cat <<\_ACEOF @@ -1514,7 +1514,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libtins configure 1.1 +libtins configure 1.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2004,7 +2004,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libtins $as_me 1.1, which was +It was created by libtins $as_me 1.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2932,7 +2932,7 @@ fi # Define the identity of the package. PACKAGE='libtins' - VERSION='1.1' + VERSION='1.2' cat >>confdefs.h <<_ACEOF @@ -15950,7 +15950,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libtins $as_me 1.1, which was +This file was extended by libtins $as_me 1.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16017,7 +16017,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libtins config.status 1.1 +libtins config.status 1.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 59961ac..7f12646 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libtins], [1.1], [matias.fontanini@gmail.com], [libtins], [http://libtins.sourceforge.net]) +AC_INIT([libtins], [1.2], [matias.fontanini@gmail.com], [libtins], [http://libtins.sourceforge.net]) AC_CANONICAL_SYSTEM AC_CONFIG_HEADER(include/config.h) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-extra-portability foreign]) diff --git a/include/dhcp.h b/include/dhcp.h index 3813d78..a01fe52 100644 --- a/include/dhcp.h +++ b/include/dhcp.h @@ -40,8 +40,10 @@ namespace Tins { /** * \brief Class that represents the DHCP PDU. - * - * The end option is added automatically at the end of the option list. + * + * When adding options, the "End" option is not added automatically. + * + * \sa DHCP::end */ class DHCP : public BootP { public: @@ -222,7 +224,7 @@ namespace Tins { * * The new option is appended at the end of the list. * - * \param ip The ip of the server. + * \param ip The server's IP address. */ void server_identifier(ipaddress_type ip); diff --git a/include/icmp.h b/include/icmp.h index efff8cd..daf89d8 100644 --- a/include/icmp.h +++ b/include/icmp.h @@ -96,13 +96,6 @@ namespace Tins { */ void type(Flags type); - /** - * \brief Setter for checksum field. - * - * \param new_check uint16_t with the new checksum. - */ - void check(uint16_t new_check); - /** * \brief Setter for the id field. * @@ -227,7 +220,7 @@ namespace Tins { * * \return Returns the checksum as an unit16_t. */ - uint16_t check() const { return Endian::be_to_host(this->_icmp.check); } + uint16_t check() const { return Endian::be_to_host(_icmp.check); } /** * \brief Getter for the echo id. @@ -248,7 +241,7 @@ namespace Tins { * * \return Returns the gateways in an unit32_t. */ - uint32_t gateway() const { return Endian::be_to_host(this->_icmp.un.gateway); } + uint32_t gateway() const { return Endian::be_to_host(_icmp.un.gateway); } /** * \brief Getter for the pointer field. @@ -262,7 +255,7 @@ namespace Tins { * * \return Returns the mtu value in an uint16_t. */ - uint16_t mtu() const { return Endian::be_to_host(this->_icmp.un.frag.mtu); } + uint16_t mtu() const { return Endian::be_to_host(_icmp.un.frag.mtu); } /** * \brief Returns the header size. @@ -313,6 +306,8 @@ namespace Tins { uint8_t pointer; } un; } TINS_END_PACK; + + void check(uint16_t new_check); /** \brief Serialices this ICMP PDU. * \param buffer The buffer in which the PDU will be serialized. diff --git a/include/packet_writer.h b/include/packet_writer.h index 8ea8c05..251259b 100644 --- a/include/packet_writer.h +++ b/include/packet_writer.h @@ -112,7 +112,7 @@ public: * * The template parameter T must at some point yield a PDU& after * applying operator* one or more than one time. This accepts both - * raw and smartpointers. + * raw and smart pointers. */ template void write(T &pdu) { diff --git a/src/address_range.cpp b/src/address_range.cpp index 52dd9f2..e4a5cc1 100644 --- a/src/address_range.cpp +++ b/src/address_range.cpp @@ -29,7 +29,7 @@ #include "address_range.h" #include "ip_address.h" - #include "ipv6_address.h" +#include "ipv6_address.h" namespace Tins { IPv4Range operator/(const IPv4Address &addr, int mask) { diff --git a/src/dhcp.cpp b/src/dhcp.cpp index fc36330..30256e4 100644 --- a/src/dhcp.cpp +++ b/src/dhcp.cpp @@ -100,7 +100,7 @@ void DHCP::type(Flags type) { } void DHCP::end() { - add_option(option(DHCP_MESSAGE_TYPE)); + add_option(option(END)); } uint8_t DHCP::type() const { diff --git a/src/icmp.cpp b/src/icmp.cpp index bccb12e..35d0eb1 100644 --- a/src/icmp.cpp +++ b/src/icmp.cpp @@ -153,15 +153,16 @@ void ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) #ifdef TINS_DEBUG assert(total_sz >= sizeof(icmphdr)); #endif - if(!_icmp.check) { - uint32_t checksum = Utils::do_checksum(buffer + sizeof(icmphdr), buffer + total_sz) + - Utils::do_checksum((uint8_t*)&_icmp, ((uint8_t*)&_icmp) + sizeof(icmphdr)); - while (checksum >> 16) - checksum = (checksum & 0xffff) + (checksum >> 16); - _icmp.check = Endian::host_to_be(~checksum); - } - memcpy(buffer, &_icmp, sizeof(icmphdr)); + _icmp.check = 0; + + uint32_t checksum = Utils::do_checksum(buffer + sizeof(icmphdr), buffer + total_sz) + + Utils::do_checksum((uint8_t*)&_icmp, ((uint8_t*)&_icmp) + sizeof(icmphdr)); + while (checksum >> 16) + checksum = (checksum & 0xffff) + (checksum >> 16); + + _icmp.check = Endian::host_to_be(~checksum); + memcpy(buffer, &_icmp, sizeof(icmphdr)); } bool ICMP::matches_response(const uint8_t *ptr, uint32_t total_sz) const { diff --git a/tests/src/icmp.cpp b/tests/src/icmp.cpp index a0f0524..29fe5ee 100644 --- a/tests/src/icmp.cpp +++ b/tests/src/icmp.cpp @@ -81,12 +81,6 @@ TEST_F(ICMPTest, Type) { EXPECT_EQ(icmp.type(), ICMP::ECHO_REPLY); } -TEST_F(ICMPTest, Checksum) { - ICMP icmp; - icmp.check(0x31fd); - EXPECT_EQ(icmp.check(), 0x31fd); -} - TEST_F(ICMPTest, Gateway) { ICMP icmp; icmp.gateway(0x31fdb5cd); @@ -198,6 +192,7 @@ TEST_F(ICMPTest, Serialize) { ICMP icmp2(icmp1); PDU::serialization_type buffer2 = icmp2.serialize(); + EXPECT_EQ(buffer, buffer2); }