{
}
-IcmpType IcmpDestinationUnreachableMessage::get_type() const
+Icmpv4Type IcmpDestinationUnreachableMessage::get_type() const
{
- IcmpType type = static_cast<IcmpType>( Payload[ 0 ] );
+ Icmpv4Type type = static_cast<Icmpv4Type>( Payload[ 0 ] );
return type;
}
-void IcmpDestinationUnreachableMessage::set_type( IcmpType type )
+void IcmpDestinationUnreachableMessage::set_type( Icmpv4Type type )
{
uint8_t n = static_cast<uint8_t>( type );
IcmpDestinationUnreachableMessage();
virtual ~IcmpDestinationUnreachableMessage();
- IcmpType get_type() const;
- void set_type( const IcmpType type );
+ Icmpv4Type get_type() const;
+ void set_type( const Icmpv4Type type );
uint8_t get_code() const;
void set_code( const uint8_t code );
{
}
-IcmpType IcmpEchoReplyMessage::get_type() const
+Icmpv4Type IcmpEchoReplyMessage::get_type() const
{
- IcmpType type = static_cast<IcmpType>( Payload[ 0 ] );
+ Icmpv4Type type = static_cast<Icmpv4Type>( Payload[ 0 ] );
return type;
}
-void IcmpEchoReplyMessage::set_type( IcmpType type )
+void IcmpEchoReplyMessage::set_type( Icmpv4Type type )
{
uint8_t n = static_cast<uint8_t>( type );
IcmpEchoReplyMessage();
virtual ~IcmpEchoReplyMessage();
- IcmpType get_type() const;
- void set_type( const IcmpType type );
+ Icmpv4Type get_type() const;
+ void set_type( const Icmpv4Type type );
uint8_t get_code() const;
void set_code( const uint8_t code );
{
}
-IcmpType IcmpEchoRequestMessage::get_type() const
+Icmpv4Type IcmpEchoRequestMessage::get_type() const
{
- IcmpType type = static_cast<IcmpType>( Payload[ 0 ] );
+ Icmpv4Type type = static_cast<Icmpv4Type>( Payload[ 0 ] );
return type;
}
-void IcmpEchoRequestMessage::set_type( IcmpType type )
+void IcmpEchoRequestMessage::set_type( Icmpv4Type type )
{
uint8_t n = static_cast<uint8_t>( type );
IcmpEchoRequestMessage();
virtual ~IcmpEchoRequestMessage();
- IcmpType get_type() const;
- void set_type( const IcmpType type );
+ Icmpv4Type get_type() const;
+ void set_type( const Icmpv4Type type );
uint8_t get_code() const;
void set_code( const uint8_t code );
{
}
-IcmpType IcmpGenericMessage::get_type() const
+Icmpv4Type IcmpGenericMessage::get_type() const
{
- return IcmpType_Generic;
+ return Icmpv4Type_Generic;
}
-void IcmpGenericMessage::set_type( IcmpType )
+void IcmpGenericMessage::set_type( Icmpv4Type )
{
}
IcmpGenericMessage();
virtual ~IcmpGenericMessage();
- IcmpType get_type() const;
- void set_type( const IcmpType type );
+ Icmpv4Type get_type() const;
+ void set_type( const Icmpv4Type type );
uint8_t get_code() const;
void set_code( const uint8_t code );
/**
* This method MUST be called to initialize the data member of ICMP Messages.
*/
-void IcmpMessage::init( const IcmpType type )
+void IcmpMessage::init( const Icmpv4Type type )
{
// Note: this code can not be placed in the constructor, because it calls
// virtual function. If you call virtual functions from within a
IcmpMessage();
virtual ~IcmpMessage();
- void init( const IcmpType type );
+ void init( const Icmpv4Type type );
- virtual IcmpType get_type() const = 0;
- virtual void set_type( const IcmpType type ) = 0;
+ virtual Icmpv4Type get_type() const = 0;
+ virtual void set_type( const Icmpv4Type type ) = 0;
virtual uint8_t get_code() const = 0;
virtual void set_code( const uint8_t code ) = 0;
{
const IcmpData icmp_data( "ping-message" );
- IcmpType type = IcmpType_EchoRequest;
+ Icmpv4Type type = Icmpv4Type_EchoRequest;
uint8_t code = 0;
IcmpChecksum calculator( icmp_data.begin(), icmp_data.end() );
uint16_t checksum = calculator.compute(
// expected sequence number, and destination host address (receive just
// the ICMP packets from the host we had ping).
- if ( icmp_packet.match( IcmpType_EchoReply,
+ if ( icmp_packet.match( Icmpv4Type_EchoReply,
Identifier, SequenceNumber,
DestinationEndpoint.address() ) )
{
IcmpPacketReceiveTimer.cancel();
}
- else if ( icmp_packet.match( IcmpType_DestinationUnreachable,
+ else if ( icmp_packet.match( Icmpv4Type_DestinationUnreachable,
Identifier, SequenceNumber,
DestinationEndpoint.address() ) )
{
const size_t &bytes_transferred
) const
{
- BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == IcmpType_EchoReply );
+ BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == Icmpv4Type_EchoReply );
Ipv4Header ipv4_header = icmp_packet.get_ip_header();
Icmpv4Header icmp_header = icmp_packet.get_icmp_header();
const Icmpv4Packet &icmp_packet
) const
{
- BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == IcmpType_DestinationUnreachable );
+ BOOST_ASSERT( icmp_packet.get_icmp_header().get_type() == Icmpv4Type_DestinationUnreachable );
Ipv4Header ipv4_hdr = icmp_packet.get_ip_header();
Icmpv4Header icmp_hdr = icmp_packet.get_icmp_header();
#ifndef ICMP_TYPE_H
#define ICMP_TYPE_H
-enum IcmpType
+enum Icmpv4Type
{
- IcmpType_EchoReply = 0,
- IcmpType_DestinationUnreachable = 3,
- IcmpType_SourceQuench = 4,
- IcmpType_Redirect = 5,
- IcmpType_EchoRequest = 8,
- IcmpType_TimeExceeded = 11,
- IcmpType_ParameterProblem = 12,
- IcmpType_TimestampRequest = 13,
- IcmpType_TimestampReply = 14,
- IcmpType_InfoRequest = 15,
- IcmpType_InfoReply = 16,
- IcmpType_AddressRequest = 17,
- IcmpType_AddressReply = 18,
- IcmpType_InvalidLast = 42,
- IcmpType_Generic = 43
+ Icmpv4Type_EchoReply = 0,
+ Icmpv4Type_DestinationUnreachable = 3,
+ Icmpv4Type_SourceQuench = 4,
+ Icmpv4Type_Redirect = 5,
+ Icmpv4Type_EchoRequest = 8,
+ Icmpv4Type_TimeExceeded = 11,
+ Icmpv4Type_ParameterProblem = 12,
+ Icmpv4Type_TimestampRequest = 13,
+ Icmpv4Type_TimestampReply = 14,
+ Icmpv4Type_InfoRequest = 15,
+ Icmpv4Type_InfoReply = 16,
+ Icmpv4Type_AddressRequest = 17,
+ Icmpv4Type_AddressReply = 18,
+ Icmpv4Type_InvalidLast = 42,
+ Icmpv4Type_Generic = 43
};
#endif /* ICMP_TYPE_H */
}
Icmpv4Header::Icmpv4Header(
- IcmpType type,
+ Icmpv4Type type,
uint8_t code,
uint16_t checksum,
uint16_t identifier,
set_sequence_number( sequence_number );
}
-IcmpType Icmpv4Header::get_type() const
+Icmpv4Type Icmpv4Header::get_type() const
{
return get_icmp_message_format()->get_type();
}
-void Icmpv4Header::set_type( IcmpType type )
+void Icmpv4Header::set_type( Icmpv4Type type )
{
get_icmp_message_format()->set_type( type );
}
return MessageFormat;
}
-void Icmpv4Header::set_icmp_message_format( IcmpType type )
+void Icmpv4Header::set_icmp_message_format( Icmpv4Type type )
{
BOOST_ASSERT( MessageFormat.get() == NULL );
{
switch ( type )
{
- case IcmpType_EchoReply:
+ case Icmpv4Type_EchoReply:
MessageFormat.reset( new IcmpEchoReplyMessage );
break;
- case IcmpType_EchoRequest:
+ case Icmpv4Type_EchoRequest:
MessageFormat.reset( new IcmpEchoRequestMessage );
break;
- case IcmpType_DestinationUnreachable:
+ case Icmpv4Type_DestinationUnreachable:
MessageFormat.reset(
new IcmpDestinationUnreachableMessage
);
break;
- case IcmpType_SourceQuench:
- case IcmpType_Redirect:
- case IcmpType_TimeExceeded:
- case IcmpType_ParameterProblem:
- case IcmpType_TimestampRequest:
- case IcmpType_TimestampReply:
- case IcmpType_InfoRequest:
- case IcmpType_InfoReply:
- case IcmpType_AddressRequest:
- case IcmpType_AddressReply:
- case IcmpType_Generic:
+ case Icmpv4Type_SourceQuench:
+ case Icmpv4Type_Redirect:
+ case Icmpv4Type_TimeExceeded:
+ case Icmpv4Type_ParameterProblem:
+ case Icmpv4Type_TimestampRequest:
+ case Icmpv4Type_TimestampReply:
+ case Icmpv4Type_InfoRequest:
+ case Icmpv4Type_InfoReply:
+ case Icmpv4Type_AddressRequest:
+ case Icmpv4Type_AddressReply:
+ case Icmpv4Type_Generic:
MessageFormat.reset( new IcmpGenericMessage );
break;
- case IcmpType_InvalidLast:
+ case Icmpv4Type_InvalidLast:
default:
BOOST_ASSERT( false );
break;
}
BOOST_ASSERT( MessageFormat.get() != NULL );
- BOOST_ASSERT( MessageFormat->get_type() != IcmpType_InvalidLast );
+ BOOST_ASSERT( MessageFormat->get_type() != Icmpv4Type_InvalidLast );
}
void Icmpv4Header::set_icmp_message_format( std::istream &is )
(void) is.putback( first_byte );
// now select the message format for the given type
- IcmpType header_type = static_cast<IcmpType>( first_byte );
+ Icmpv4Type header_type = static_cast<Icmpv4Type>( first_byte );
set_icmp_message_format( header_type );
}
public:
Icmpv4Header();
Icmpv4Header(
- IcmpType type,
+ Icmpv4Type type,
uint8_t code,
uint16_t checksum,
uint16_t identifier,
uint16_t sequence_number
);
- IcmpType get_type() const;
- void set_type( const IcmpType type );
+ Icmpv4Type get_type() const;
+ void set_type( const Icmpv4Type type );
uint8_t get_code() const;
void set_code( const uint8_t code );
void set_sequence_number( const uint16_t sequence_number );
boost::shared_ptr<IcmpMessage> get_icmp_message_format() const;
- void set_icmp_message_format( IcmpType type );
+ void set_icmp_message_format( Icmpv4Type type );
void set_icmp_message_format( std::istream &is );
friend std::istream& operator>>(
* one does not match.
*/
bool Icmpv4Packet::match(
- const IcmpType type,
+ const Icmpv4Type type,
const uint16_t identifier,
const uint16_t sequence_number,
const address &source_address
IcmpData get_icmp_data() const;
bool match(
- const IcmpType type,
+ const Icmpv4Type type,
const uint16_t identifier,
const uint16_t sequence_number,
const boost::asio::ip::address &source_address