From d4acbad82e8bd619491a9b74e4012f3a70961c93 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 16 Jul 2011 19:36:20 -0300 Subject: [PATCH] Solving some conversion and variable shadow warnings --- .../boost/asio/ip/tcp_raw_protocol.hpp | 4 ++-- src/tcp/tcpheader.h | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp b/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp index 68fc07c..cd9a137 100644 --- a/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp +++ b/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp @@ -108,8 +108,8 @@ public: private: // Construct with a specific family. - explicit tcp_raw_protocol( int family ) : - family_( family ) + explicit tcp_raw_protocol( int fmly ) : + family_( fmly ) { } diff --git a/src/tcp/tcpheader.h b/src/tcp/tcpheader.h index adf07a0..6062771 100644 --- a/src/tcp/tcpheader.h +++ b/src/tcp/tcpheader.h @@ -162,20 +162,22 @@ public: uint16_t calculate_tcp_checksum( uint32_t src_addr, uint32_t dest_addr, - char* payload_data, - uint16_t payload_size_in_bytes ) + char* tcp_payload_data, + uint16_t tcp_payload_size_in_bytes ) { checksum( 0 ); uint16_t tcp_header_size_in_bytes = 20; + uint16_t tcp_segment_size_in_bytes = static_cast< uint16_t > ( + tcp_header_size_in_bytes + tcp_payload_size_in_bytes + ); PseudoIpv4Header pseudo_header; pseudo_header.source_address = htonl(src_addr); pseudo_header.destination_address = htonl(dest_addr); pseudo_header.zero_byte = 0; pseudo_header.protocol = IPPROTO_TCP; - pseudo_header.header_length = htons( - tcp_header_size_in_bytes + payload_size_in_bytes - ); + pseudo_header.header_length = htons( tcp_segment_size_in_bytes ); + int pseudo_header_size_in_bytes = sizeof(PseudoIpv4Header); uint8_t tcp_buffer[65536]; @@ -185,11 +187,11 @@ public: memcpy( tcp_buffer + pseudo_header_size_in_bytes, rep_, tcp_header_size_in_bytes ); memcpy( tcp_buffer + pseudo_header_size_in_bytes + tcp_header_size_in_bytes, - payload_data, payload_size_in_bytes ); + tcp_payload_data, tcp_payload_size_in_bytes ); uint16_t cksum = calculate_checksum( (uint16_t *) tcp_buffer, - pseudo_header_size_in_bytes + tcp_header_size_in_bytes + payload_size_in_bytes + pseudo_header_size_in_bytes + tcp_header_size_in_bytes + tcp_payload_size_in_bytes ); cksum = ntohs( cksum ); @@ -225,7 +227,7 @@ public: void header_length( uint8_t offset ) { - uint8_t high_nimble = ( offset << 4 ) & 0xF0; + uint8_t high_nimble = static_cast( ( offset << 4 ) & 0xF0 ); uint8_t lower_nimble = ( rep_[12] & 0x0F ); rep_[12] = high_nimble | lower_nimble; } @@ -293,7 +295,7 @@ public: private: uint16_t decode( int a, int b ) const { - return (rep_[a] << 8) + rep_[b]; + return static_cast( (rep_[a] << 8) + rep_[b] ); } void encode( int a, int b, uint16_t n ) -- 1.7.1