openikev2::Message Class Reference

This class represents an IKE message. More...

#include <message.h>

Inheritance diagram for openikev2::Message:

Inheritance graph
[legend]
List of all members.

Public Types

enum  EXCHANGE_TYPE { IKE_SA_INIT = 34, IKE_AUTH, CREATE_CHILD_SA, INFORMATIONAL }
 Exhange types. More...
enum  MESSAGE_TYPE { REQUEST = 0, RESPONSE }
 Message types. More...

Public Member Functions

 Message (auto_ptr< IpAddress > src_addr, auto_ptr< IpAddress > dst_addr, uint64_t spi_i, uint64_t spi_r, uint8_t major_version, uint8_t minor_version, EXCHANGE_TYPE exchange_type, MESSAGE_TYPE message_type, bool is_initiator, bool can_use_higher_major_version, uint32_t message_id)
 Creates a new Message, setting its attributes.
 Message (auto_ptr< IpAddress > src_addr, auto_ptr< IpAddress > dst_addr, ByteBuffer &byte_buffer)
 Creates a new Message based on its binary representation.
 Message (const Message &other)
 Creates a new Message cloning another one.
vector< Payload * > getPayloadsByType (Payload::PAYLOAD_TYPE type) const
 Gets all the Payloads of the indicated type found in the Message.
PayloadgetFirstPayloadByType (Payload::PAYLOAD_TYPE type) const
 Gets the first Payload with that type found in the Message.
PayloadgetUniquePayloadByType (Payload::PAYLOAD_TYPE type) const
 Gets the unique Payload with the indicated type found in the Message.
vector< Payload_NOTIFY * > getNotifiesByType (Payload_NOTIFY::NOTIFY_TYPE notification_type) const
 Gets a collection of all the notification payloads of the indicated type.
Payload_NOTIFYgetFirstNotifyByType (Payload_NOTIFY::NOTIFY_TYPE notification_type) const
 Gets the first notification payload of the indicated type.
Payload_NOTIFYgetUniqueNotifyByType (Payload_NOTIFY::NOTIFY_TYPE notification_type) const
 Gets the unique notification payload with the indicated notification type found in the Message.
void addPayload (auto_ptr< Payload > payload, bool is_encrypted)
 Adds a Payload to the Message.
void replaceFirstPayloadByType (Payload::PAYLOAD_TYPE type, auto_ptr< Payload > new_payload)
 Replaces the first payload of the indicated type.
void replaceFirstNotifyByType (Payload_NOTIFY::NOTIFY_TYPE notify_type, auto_ptr< Payload_NOTIFY > new_payload)
 Replaces the first notify payload of the indicated type.
void addPayloadNotify (auto_ptr< Payload_NOTIFY > notify_payload, bool is_encrypted)
 Adds a notification payload.
void addPayloadsNotify (AutoVector< Payload_NOTIFY > notifies, bool is_encrypted)
 Add a notification payload collection.
ByteArraygetBinaryRepresentation (Cipher *cipher)
 Gets the binary representation of the Message.
void decryptPayloadSK (Cipher *cipher)
 Decrypts the Payload_SK and generates the contained Payloads The geneated Payloads are stored into the encrypted_payloads collection.
bool checkIntegrity (Cipher *cipher) const
 Checks the Message integrity.
auto_ptr< Messageclone () const
 Clone this message.
IpAddressgetSrcAddress () const
 Gets the source addres of the Message.
IpAddressgetDstAddress () const
 Gets the destiantion addres of the Message.
virtual string toStringTab (uint8_t tabs) const
 Construct a textual representation of the object, preceded of a num of tabs of size TAB_SIZE.

Static Public Member Functions

static string EXCHANGE_TYPE_STR (EXCHANGE_TYPE exchange_type)
 Translates from exchange type IDs to strings in order to be easily recognized.
static string MESSAGE_TYPE_STR (MESSAGE_TYPE message_type)
 Translates from message type to strings in order to be easily recognized.

Public Attributes

bool can_use_higher_major_version
 This flag indicates that the transmiter is able to speaking a higher major version.
uint8_t major_version
 Message protocol major version.
uint8_t minor_version
 Message protocol minor version.
EXCHANGE_TYPE exchange_type
 Message exchange type.
MESSAGE_TYPE message_type
 Indicates if the message is a request or a response.
bool is_initiator
 This flag indicates that the transmitter is the original initiator.
uint64_t spi_i
 Initiator SPI.
uint64_t spi_r
 Responder SPI.
uint32_t message_id
 Message ID.

Static Protected Member Functions

static Payload::PAYLOAD_TYPE generatePayloads (Payload::PAYLOAD_TYPE first_payload_type, ByteBuffer &byte_buffer, vector< Payload * > &payloads)
 Generates all the payloads based on its binary representation.
static auto_ptr< ByteArraygenerateBinaryRepresentation (Payload::PAYLOAD_TYPE last_payload_type, const vector< Payload * > payloads)
 Generates the binary representation of a Payload collection.

Protected Attributes

AutoVector< Payloadunencrypted_payloads
 Unencrypted Payload collection.
AutoVector< Payloadencrypted_payloads
 Encrypted Payload collection.
Payload::PAYLOAD_TYPE first_payload_type
 The type of the first payload in the mensage.
Payload::PAYLOAD_TYPE first_payload_type_sk
 The type of the first payload in the payload_sk.
auto_ptr< IpAddresssrc_addr
 Source address.
auto_ptr< IpAddressdst_addr
 Destination address.
auto_ptr< ByteArraybinary_representation
 Message binary representation.
auto_ptr< Payload_SKpayload_sk
 Message Payload_SK.

Detailed Description

This class represents an IKE message.

Author:
Pedro J. Fernandez Ruiz, Alejandro Perez Mendez <pedroj.fernandez@dif.um.es, alejandro_perez@dif.um.es>


Member Enumeration Documentation

enum openikev2::Message::EXCHANGE_TYPE

Exhange types.

Enumerator:
IKE_SA_INIT  IKE_SA_INIT exchange.
IKE_AUTH  IKE_AUTH exchange.
CREATE_CHILD_SA  CREATE_CHILD_SA exchange.
INFORMATIONAL  INFORMATIONAL exchange.

enum openikev2::Message::MESSAGE_TYPE

Message types.

Enumerator:
REQUEST  Request.
RESPONSE  Response.


Constructor & Destructor Documentation

openikev2::Message::Message ( auto_ptr< IpAddress src_addr,
auto_ptr< IpAddress dst_addr,
uint64_t  spi_i,
uint64_t  spi_r,
uint8_t  major_version,
uint8_t  minor_version,
EXCHANGE_TYPE  exchange_type,
MESSAGE_TYPE  message_type,
bool  is_initiator,
bool  can_use_higher_major_version,
uint32_t  message_id 
)

Creates a new Message, setting its attributes.

Parameters:
src_addr Source address
dst_addr Destination address
spi_i Initiator SPI.
spi_r Responder SPI.
major_version Message protocol major version.
minor_version Message protocol minor version.
exchange_type Message exchange type.
is_initiator Is the original initiator.
is_response Is a response.
can_use_higher_major_version The transmiter is able to speaking a higher major version.
message_id Message ID.

openikev2::Message::Message ( auto_ptr< IpAddress src_addr,
auto_ptr< IpAddress dst_addr,
ByteBuffer byte_buffer 
)

Creates a new Message based on its binary representation.

Parameters:
src_addr Source address
dst_addr Destination address
byte_buffer Buffer containing the binary representation of the message

openikev2::Message::Message ( const Message other  ) 

Creates a new Message cloning another one.

Parameters:
other Other Message object to be cloned


Member Function Documentation

Payload::PAYLOAD_TYPE openikev2::Message::generatePayloads ( Payload::PAYLOAD_TYPE  first_payload_type,
ByteBuffer byte_buffer,
vector< Payload * > &  payloads 
) [static, protected]

Generates all the payloads based on its binary representation.

Parameters:
first_payload_type Type of the first payload
byte_buffer Concatenated binary representation of the payloads
payloads Collection to be filled by this method with the generated payloads
Returns:
The next payload type of the last fixed payload header

static auto_ptr<ByteArray> openikev2::Message::generateBinaryRepresentation ( Payload::PAYLOAD_TYPE  last_payload_type,
const vector< Payload * >  payloads 
) [static, protected]

Generates the binary representation of a Payload collection.

Parameters:
last_payload_type The last payload type
payloads Payload Collection
Returns:
Binary representation of the Payloads

vector< Payload * > openikev2::Message::getPayloadsByType ( Payload::PAYLOAD_TYPE  type  )  const

Gets all the Payloads of the indicated type found in the Message.

Parameters:
type Type of the payloads
Returns:
A payload collection

Payload * openikev2::Message::getFirstPayloadByType ( Payload::PAYLOAD_TYPE  type  )  const

Gets the first Payload with that type found in the Message.

Parameters:
type Type of the Payload
Returns:
The first payload found. NULL if none is found.

Payload & openikev2::Message::getUniquePayloadByType ( Payload::PAYLOAD_TYPE  type  )  const

Gets the unique Payload with the indicated type found in the Message.

There must be one and only one Payload of the indicated type, otherwise ParsingException is thrown

Parameters:
type Type of the Payload
Returns:
The searched Payload

vector< Payload_NOTIFY * > openikev2::Message::getNotifiesByType ( Payload_NOTIFY::NOTIFY_TYPE  notification_type  )  const

Gets a collection of all the notification payloads of the indicated type.

Parameters:
notification_type Type of the notification payloads.
Returns:
Collection of notification payloads.

Payload_NOTIFY * openikev2::Message::getFirstNotifyByType ( Payload_NOTIFY::NOTIFY_TYPE  notification_type  )  const

Gets the first notification payload of the indicated type.

Parameters:
notification_type Type of the notification payload.
Returns:
The first notification payloa of the specified type. NULL if none if found

Payload_NOTIFY & openikev2::Message::getUniqueNotifyByType ( Payload_NOTIFY::NOTIFY_TYPE  notification_type  )  const

Gets the unique notification payload with the indicated notification type found in the Message.

There must be one and only one notification payload of the indicated type, otherwise ParsingException is thrown

Parameters:
notification_type Type of the notification payload
Returns:
The searched notification payload

void openikev2::Message::addPayload ( auto_ptr< Payload payload,
bool  is_encrypted 
)

Adds a Payload to the Message.

Parameters:
payload Payload to be added.
is_encrypted Indicates if payload must be encrypted.

void openikev2::Message::replaceFirstPayloadByType ( Payload::PAYLOAD_TYPE  type,
auto_ptr< Payload new_payload 
)

Replaces the first payload of the indicated type.

Parameters:
type Payload type to be replaced.
new_payload New payload to be included in the Message.

void openikev2::Message::replaceFirstNotifyByType ( Payload_NOTIFY::NOTIFY_TYPE  notify_type,
auto_ptr< Payload_NOTIFY new_payload 
)

Replaces the first notify payload of the indicated type.

Parameters:
notify_type 
new_payload 

void openikev2::Message::addPayloadNotify ( auto_ptr< Payload_NOTIFY notify_payload,
bool  is_encrypted 
)

Adds a notification payload.

This Payload will be inserted in the first position of the Message.

Parameters:
notify_payload Notification Payload to be inserted.
is_encrypted Indicates if notify payload must be encrypted.

void openikev2::Message::addPayloadsNotify ( AutoVector< Payload_NOTIFY notifies,
bool  is_encrypted 
)

Add a notification payload collection.

This payloads will be inserted in the firsts positions of the Message

Parameters:
notifies Payload NOTIFY collection
is_encrypted Indicates if the notifies must be encrypted

ByteArray & openikev2::Message::getBinaryRepresentation ( Cipher cipher  ) 

Gets the binary representation of the Message.

If still not generated, the generate it.

Parameters:
cipher Cipher to be used to generate the Payload_SK. NULL if not applicable
Returns:
Binary representation of the Message

void openikev2::Message::decryptPayloadSK ( Cipher cipher  ) 

Decrypts the Payload_SK and generates the contained Payloads The geneated Payloads are stored into the encrypted_payloads collection.

Parameters:
cipher Cipher used to decrypt the Payload_SK (NULL if not applicable)

bool openikev2::Message::checkIntegrity ( Cipher cipher  )  const

Checks the Message integrity.

Parameters:
cipher Cipher used to check integrity (NULL if not applicable)
Returns:
TRUE if integrity is ok. FALSE otherwise

auto_ptr< Message > openikev2::Message::clone (  )  const

Clone this message.

Returns:
Message clon

IpAddress & openikev2::Message::getSrcAddress (  )  const

Gets the source addres of the Message.

Returns:
The source address of the Message

IpAddress & openikev2::Message::getDstAddress (  )  const

Gets the destiantion addres of the Message.

Returns:
The destiantion address of the Message

string openikev2::Message::EXCHANGE_TYPE_STR ( EXCHANGE_TYPE  exchange_type  )  [static]

Translates from exchange type IDs to strings in order to be easily recognized.

Parameters:
exchange_type Exchange type ID
Returns:
Returns the name of the specified exchange type ID

string openikev2::Message::MESSAGE_TYPE_STR ( MESSAGE_TYPE  message_type  )  [static]

Translates from message type to strings in order to be easily recognized.

Parameters:
message_type Message type
Returns:
Returns the name of the specified message type

string openikev2::Message::toStringTab ( uint8_t  tabs  )  const [virtual]

Construct a textual representation of the object, preceded of a num of tabs of size TAB_SIZE.

Parameters:
tabs Num of tabs preceding the textual representation.
Returns:
Textual tabulated represetation of the object.

Implements openikev2::Printable.


Generated on Fri Jul 27 11:04:52 2007 for libopenikev2 by  doxygen 1.5.1