diff options
Diffstat (limited to 'src/charon/encoding')
-rw-r--r-- | src/charon/encoding/message.c | 36 | ||||
-rw-r--r-- | src/charon/encoding/message.h | 25 |
2 files changed, 29 insertions, 32 deletions
diff --git a/src/charon/encoding/message.c b/src/charon/encoding/message.c index 031382cee..4f5f3b899 100644 --- a/src/charon/encoding/message.c +++ b/src/charon/encoding/message.c @@ -711,6 +711,20 @@ static chunk_t get_packet_data (private_message_t *this) } /** + * Implementation of message_t.is_encoded. + */ +static bool is_encoded(private_message_t *this) +{ + chunk_t data = this->packet->get_data(this->packet); + + if (data.ptr == NULL) + { + return FALSE; + } + return TRUE; +} + +/** * Implementation of message_t.parse_header. */ static status_t parse_header(private_message_t *this) @@ -1232,6 +1246,7 @@ message_t *message_create_from_packet(packet_t *packet) this->public.parse_body = (status_t (*) (message_t *,crypter_t*,signer_t*)) parse_body; this->public.get_packet = (packet_t * (*) (message_t*)) get_packet; this->public.get_packet_data = (chunk_t (*) (message_t *this)) get_packet_data; + this->public.is_encoded = (bool (*) (message_t *this)) is_encoded; this->public.destroy = (void(*)(message_t*))destroy; /* private values */ @@ -1272,24 +1287,3 @@ message_t *message_create() { return message_create_from_packet(NULL); } - -/* - * Described in Header. - */ -message_t *message_create_notify_reply(host_t *source, host_t *destination, exchange_type_t exchange_type, bool original_initiator,ike_sa_id_t *ike_sa_id,notify_message_type_t notify_type) -{ - message_t *message = message_create_from_packet(NULL); - notify_payload_t *payload; - - message->set_source(message, source->clone(source)); - message->set_destination(message, destination->clone(destination)); - message->set_exchange_type(message, exchange_type); - message->set_request(message, FALSE); - message->set_message_id(message,0); - message->set_ike_sa_id(message, ike_sa_id); - - payload = notify_payload_create_from_protocol_and_type(PROTO_NONE, notify_type); - message->add_payload(message,(payload_t *) payload); - - return message; -} diff --git a/src/charon/encoding/message.h b/src/charon/encoding/message.h index e32cf68d4..8c105e597 100644 --- a/src/charon/encoding/message.h +++ b/src/charon/encoding/message.h @@ -306,7 +306,7 @@ struct message_t { iterator_t * (*get_payload_iterator) (message_t *this); /** - * Returns a clone of the internal stored packet_t object. + * @brief Returns a clone of the internal stored packet_t object. * * @param this message_t object * @return packet_t object as clone of internal one @@ -314,13 +314,25 @@ struct message_t { packet_t * (*get_packet) (message_t *this); /** - * Returns a clone of the internal stored packet_t data. + * @brief Returns a clone of the internal stored packet_t data. * * @param this message_t object * @return clone of the internal stored packet_t data. */ chunk_t (*get_packet_data) (message_t *this); + /** + * @brief Check if a message is encoded. + * + * Check if the packet is in a generated (and encrypted) form available + * and can be passed down to the socket. If not, it has to be generated + * first. + * + * @param this message_t object + * @return TRUE if encoded, FALSE if not + */ + bool (*is_encoded) (message_t *this); + /** * @brief Destroys a message and all including objects. @@ -364,13 +376,4 @@ message_t * message_create_from_packet(packet_t *packet); */ message_t * message_create(void); -/** - * @brief Creates an message_t object of type reply containing a notify payload. - * - * @return message_t object - * - * @ingroup encoding - */ -message_t *message_create_notify_reply(host_t *source, host_t *destination, exchange_type_t exchange_type, bool original_initiator,ike_sa_id_t *ike_sa_id,notify_message_type_t notify_type); - #endif /*MESSAGE_H_*/ |