// http://www.boost.org/LICENSE_1_0.txt)
#include "ip/ipv4header.h"
-#include <limits>
-
#include <boost/scoped_array.hpp>
+#include <logfunc.hpp>
+
using namespace std;
using boost::asio::ip::address_v4;
using boost::scoped_array;
+using I2n::Logger::GlobalLogger;
//-----------------------------------------------------------------------------
// Ipv4Header
{
// read the first 20 bytes (mandatory for IP header) from the input stream
// and stores in the buffer object
- header.Payload.read( is );
+ (void) header.Payload.read( is );
if ( header.get_version() != 4 )
{
+ GlobalLogger.error() << "Error: invalid IP header version." << endl;
is.setstate( ios::failbit );
}
// read the consecutive N bytes (for options field) from the input stream
// and stores in the buffer object
- streamsize options_length = (streamsize) header.get_header_length() -
- Ipv4HeaderSizeInBytes;
+ streamsize options_length = static_cast<streamsize>( header.get_header_length() ) -
+ static_cast<streamsize>( Ipv4HeaderSizeInBytes );
if ( ( options_length < 0 ) || ( 40 < options_length ) )
{
+ GlobalLogger.error() << "Error: invalid IP options length value." << endl;
is.setstate( ios::failbit );
}
else
{
- scoped_array<uint8_t> options_data(new uint8_t[options_length]);
+ size_t options_size = static_cast<size_t>( options_length );
+ scoped_array<uint8_t> options_data( new uint8_t[options_size] );
char *options_data_array = reinterpret_cast<char *>( options_data.get() );
- is.read( options_data_array, options_length );
+ (void) is.read( options_data_array, options_length );
- header.Payload.append( options_data.get(), options_length );
+ header.Payload.append( options_data.get(), options_size );
}
return is;