diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-11-29 10:19:27 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-11-29 10:19:27 +0000 |
commit | 79b9c1d6c5ebf296d29e11f4a5f25c0bf60f896c (patch) | |
tree | 931dbe13f6ec5abd1671b9423195fb5c271c24cb | |
parent | 45c3d18680255d35441777ce5fbd3b05bd3503e0 (diff) | |
download | strongswan-79b9c1d6c5ebf296d29e11f4a5f25c0bf60f896c.tar.bz2 strongswan-79b9c1d6c5ebf296d29e11f4a5f25c0bf60f896c.tar.xz |
- implemented compute length function
-rw-r--r-- | Source/charon/encoding/payloads/id_payload.c | 20 | ||||
-rw-r--r-- | Source/charon/encoding/payloads/id_payload.h | 2 | ||||
-rw-r--r-- | Source/charon/encoding/payloads/nonce_payload.c | 11 |
3 files changed, 32 insertions, 1 deletions
diff --git a/Source/charon/encoding/payloads/id_payload.c b/Source/charon/encoding/payloads/id_payload.c index 708aa61b4..9691522f0 100644 --- a/Source/charon/encoding/payloads/id_payload.c +++ b/Source/charon/encoding/payloads/id_payload.c @@ -146,6 +146,15 @@ static status_t verify(private_id_payload_t *this) /* critical bit is set! */ return FAILED; } + if ((this->id_type == 0) || + (this->id_type == 4) || + ((this->id_type >= 6) && (this->id_type <= 8)) || + ((this->id_type >= 12) && (this->id_type <= 200))) + { + /* reserved IDs */ + return FAILED; + } + return SUCCESS; } @@ -252,6 +261,14 @@ static void set_initiator (private_id_payload_t *this,bool is_initiator) } /** + * Implementation of private_id_payload_t.compute_length. + */ +static void compute_length(private_id_payload_t *this) +{ + this->payload_length = ID_PAYLOAD_HEADER_LENGTH + this->id_data.len; +} + +/** * Implementation of payload_t.destroy and id_payload_t.destroy. */ static void destroy(private_id_payload_t *this) @@ -289,6 +306,9 @@ id_payload_t *id_payload_create(bool is_initiator) this->public.get_initiator = (bool (*) (id_payload_t *)) get_initiator; this->public.set_initiator = (void (*) (id_payload_t *,bool)) set_initiator; + /* private functions */ + this->compute_length = compute_length; + /* private variables */ this->critical = FALSE; this->next_payload = NO_PAYLOAD; diff --git a/Source/charon/encoding/payloads/id_payload.h b/Source/charon/encoding/payloads/id_payload.h index b4cb30468..6837d910a 100644 --- a/Source/charon/encoding/payloads/id_payload.h +++ b/Source/charon/encoding/payloads/id_payload.h @@ -28,7 +28,7 @@ #include <encoding/payloads/payload.h> /** - * Length of a nonce payload without a nonce in bytes. + * Length of a id payload without the data in bytes. * * @ingroup payloads */ diff --git a/Source/charon/encoding/payloads/nonce_payload.c b/Source/charon/encoding/payloads/nonce_payload.c index e6ea14745..5070e1987 100644 --- a/Source/charon/encoding/payloads/nonce_payload.c +++ b/Source/charon/encoding/payloads/nonce_payload.c @@ -193,6 +193,14 @@ static size_t get_length(private_nonce_payload_t *this) } /** + * Implementation of private_id_payload_t.compute_length. + */ +static void compute_length(private_nonce_payload_t *this) +{ + this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + this->nonce.len; +} + +/** * Implementation of payload_t.destroy and nonce_payload_t.destroy. */ static void destroy(private_nonce_payload_t *this) @@ -226,6 +234,9 @@ nonce_payload_t *nonce_payload_create() this->public.set_nonce = (status_t (*) (nonce_payload_t *,chunk_t)) set_nonce; this->public.get_nonce = (void (*) (nonce_payload_t *,chunk_t*)) get_nonce; + /* private functions */ + this->compute_length = compute_length; + /* private variables */ this->critical = FALSE; this->next_payload = NO_PAYLOAD; |