diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-12-03 14:47:58 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-12-03 14:47:58 +0000 |
commit | 8d68033e5cf37ea91eb160e7b8e1c2d171a356f7 (patch) | |
tree | 5dbb4a65d0e65bd22873ed7fce9b2fdcb890a330 /Source/charon/encoding | |
parent | ebae15f0a03dae6b4b04f75b2f690cce4e7d308a (diff) | |
download | strongswan-8d68033e5cf37ea91eb160e7b8e1c2d171a356f7.tar.bz2 strongswan-8d68033e5cf37ea91eb160e7b8e1c2d171a356f7.tar.xz |
- authentication with preshared key working but code MUST be cleaned
Diffstat (limited to 'Source/charon/encoding')
-rw-r--r-- | Source/charon/encoding/message.c | 9 | ||||
-rw-r--r-- | Source/charon/encoding/message.h | 9 | ||||
-rw-r--r-- | Source/charon/encoding/payloads/auth_payload.c | 9 | ||||
-rw-r--r-- | Source/charon/encoding/payloads/auth_payload.h | 10 | ||||
-rw-r--r-- | Source/charon/encoding/payloads/id_payload.c | 13 | ||||
-rw-r--r-- | Source/charon/encoding/payloads/id_payload.h | 12 |
6 files changed, 60 insertions, 2 deletions
diff --git a/Source/charon/encoding/message.c b/Source/charon/encoding/message.c index 7fea8aea3..996f8fb87 100644 --- a/Source/charon/encoding/message.c +++ b/Source/charon/encoding/message.c @@ -640,6 +640,14 @@ static packet_t *get_packet (private_message_t *this) } /** + * Implementation of message_t.get_packet_data. + */ +static chunk_t get_packet_data (private_message_t *this) +{ + return allocator_clone_chunk(this->packet->data); +} + +/** * Implementation of message_t.parse_header. */ static status_t parse_header(private_message_t *this) @@ -1163,6 +1171,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.verify = (status_t (*) (message_t*)) verify; 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.destroy = (void(*)(message_t*))destroy; /* private values */ diff --git a/Source/charon/encoding/message.h b/Source/charon/encoding/message.h index dfbb10da9..e3be83653 100644 --- a/Source/charon/encoding/message.h +++ b/Source/charon/encoding/message.h @@ -290,6 +290,15 @@ struct message_t { packet_t * (*get_packet) (message_t *this); /** + * 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 Destroys a message and all including objects. * * @param this message_t object diff --git a/Source/charon/encoding/payloads/auth_payload.c b/Source/charon/encoding/payloads/auth_payload.c index 1070826c2..e9dad81b4 100644 --- a/Source/charon/encoding/payloads/auth_payload.c +++ b/Source/charon/encoding/payloads/auth_payload.c @@ -215,6 +215,14 @@ static void set_data (private_auth_payload_t *this, chunk_t data) */ static chunk_t get_data (private_auth_payload_t *this) { + return (this->auth_data); +} + +/** + * Implementation of auth_payload_t.get_data_clone. + */ +static chunk_t get_data_clone (private_auth_payload_t *this) +{ chunk_t cloned_data; if (this->auth_data.ptr == NULL) { @@ -259,6 +267,7 @@ auth_payload_t *auth_payload_create() this->public.set_auth_method = (void (*) (auth_payload_t *,auth_method_t)) set_auth_method; this->public.get_auth_method = (auth_method_t (*) (auth_payload_t *)) get_auth_method; this->public.set_data = (void (*) (auth_payload_t *,chunk_t)) set_data; + this->public.get_data_clone = (chunk_t (*) (auth_payload_t *)) get_data_clone; this->public.get_data = (chunk_t (*) (auth_payload_t *)) get_data; /* private variables */ diff --git a/Source/charon/encoding/payloads/auth_payload.h b/Source/charon/encoding/payloads/auth_payload.h index 3a2d4459d..2613288fe 100644 --- a/Source/charon/encoding/payloads/auth_payload.h +++ b/Source/charon/encoding/payloads/auth_payload.h @@ -115,6 +115,16 @@ struct auth_payload_t { * @param this calling auth_payload_t object * @return AUTH data as chunk_t */ + chunk_t (*get_data_clone) (auth_payload_t *this); + + /** + * @brief Get the AUTH data. + * + * Returned data are NOT copied + * + * @param this calling auth_payload_t object + * @return AUTH data as chunk_t + */ chunk_t (*get_data) (auth_payload_t *this); /** diff --git a/Source/charon/encoding/payloads/id_payload.c b/Source/charon/encoding/payloads/id_payload.c index 285791279..9560d4f87 100644 --- a/Source/charon/encoding/payloads/id_payload.c +++ b/Source/charon/encoding/payloads/id_payload.c @@ -214,11 +214,20 @@ static void set_data (private_id_payload_t *this, chunk_t data) this->payload_length = ID_PAYLOAD_HEADER_LENGTH + this->id_data.len; } + /** - * Implementation of id_payload_t.get_data. + * Implementation of id_payload_t.get_data_clone. */ static chunk_t get_data (private_id_payload_t *this) { + return (this->id_data); +} + +/** + * Implementation of id_payload_t.get_data_clone. + */ +static chunk_t get_data_clone (private_id_payload_t *this) +{ chunk_t cloned_data; if (this->id_data.ptr == NULL) { @@ -288,6 +297,8 @@ id_payload_t *id_payload_create(bool is_initiator) this->public.get_id_type = (id_type_t (*) (id_payload_t *)) get_id_type; this->public.set_data = (void (*) (id_payload_t *,chunk_t)) set_data; this->public.get_data = (chunk_t (*) (id_payload_t *)) get_data; + this->public.get_data_clone = (chunk_t (*) (id_payload_t *)) get_data_clone; + this->public.get_initiator = (bool (*) (id_payload_t *)) get_initiator; this->public.set_initiator = (void (*) (id_payload_t *,bool)) set_initiator; this->public.get_identification = (identification_t * (*) (id_payload_t *this)) get_identification; diff --git a/Source/charon/encoding/payloads/id_payload.h b/Source/charon/encoding/payloads/id_payload.h index 7348f2668..c3951135b 100644 --- a/Source/charon/encoding/payloads/id_payload.h +++ b/Source/charon/encoding/payloads/id_payload.h @@ -87,9 +87,19 @@ struct id_payload_t { * @param this calling id_payload_t object * @return ID data as chunk_t */ - chunk_t (*get_data) (id_payload_t *this); + chunk_t (*get_data_clone) (id_payload_t *this); /** + * @brief Get the ID data. + * + * Returned data are NOT copied. + * + * @param this calling id_payload_t object + * @return ID data as chunk_t + */ + chunk_t (*get_data) (id_payload_t *this); + + /** * @brief Creates an identification object of this id payload. * * Returned object has to get destroyed by the caller. |