*/
/*
+ * Copyright (C) 2007 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
id_payload_t public;
/**
- * TRUE if this ID payload is of type IDi, FALSE for IDr.
+ * one of ID_INITIATOR, ID_RESPONDER
*/
- bool is_initiator;
+ payload_type_t payload_type;
/**
* Next payload type.
*/
- u_int8_t next_payload;
+ payload_type_t next_payload;
/**
* Critical flag.
*/
static payload_type_t get_payload_type(private_id_payload_t *this)
{
- if (this->is_initiator)
- {
- return ID_INITIATOR;
- }
- else
- {
- return ID_RESPONDER;
- }
+ return this->payload_type;
}
/**
*/
static payload_type_t get_next_type(private_id_payload_t *this)
{
- return (this->next_payload);
+ return this->next_payload;
}
/**
}
/**
- * Implementation of id_payload_t.get_initiator.
- */
-static bool get_initiator (private_id_payload_t *this)
-{
- return (this->is_initiator);
-}
-
-/**
- * Implementation of id_payload_t.set_initiator.
- */
-static void set_initiator (private_id_payload_t *this,bool is_initiator)
-{
- this->is_initiator = is_initiator;
-}
-
-/**
* Implementation of id_payload_t.get_identification.
*/
static identification_t *get_identification (private_id_payload_t *this)
/*
* Described in header.
*/
-id_payload_t *id_payload_create(bool is_initiator)
+id_payload_t *id_payload_create(payload_type_t payload_type)
{
private_id_payload_t *this = malloc_thing(private_id_payload_t);
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;
/* private variables */
this->next_payload = NO_PAYLOAD;
this->payload_length =ID_PAYLOAD_HEADER_LENGTH;
this->id_data = chunk_empty;
- this->is_initiator = is_initiator;
+ this->payload_type = payload_type;
return (&(this->public));
}
/*
* Described in header.
*/
-id_payload_t *id_payload_create_from_identification(bool is_initiator,identification_t *identification)
+id_payload_t *id_payload_create_from_identification(payload_type_t payload_type, identification_t *identification)
{
- id_payload_t *this= id_payload_create(is_initiator);
+ id_payload_t *this= id_payload_create(payload_type);
this->set_data(this,identification->get_encoding(identification));
this->set_id_type(this,identification->get_type(identification));
return this;
*/
/*
+ * Copyright (C) 2007 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
identification_t *(*get_identification) (id_payload_t *this);
/**
- * @brief Get the type of ID payload (IDi or IDr).
- *
- * @param this calling id_payload_t object
- * @return
- * - TRUE if this payload is of type IDi
- * - FALSE if this payload is of type IDr
- *
- */
- bool (*get_initiator) (id_payload_t *this);
-
- /**
- * @brief Set the type of ID payload (IDi or IDr).
- *
- * @param this calling id_payload_t object
- * @param is_initiator
- * - TRUE if this payload is of type IDi
- * - FALSE if this payload is of type IDr
- *
- */
- void (*set_initiator) (id_payload_t *this,bool is_initiator);
-
- /**
* @brief Destroys an id_payload_t object.
*
* @param this id_payload_t object to destroy
/**
* @brief Creates an empty id_payload_t object.
*
- * @param is_initiator
- * - TRUE if this payload is of type IDi
- * - FALSE if this payload is of type IDr
- *
+ * @param payload_type one of ID_INITIATOR, ID_RESPONDER
* @return id_payload_t object
*
* @ingroup payloads
*/
-id_payload_t *id_payload_create(bool is_initiator);
+id_payload_t *id_payload_create(payload_type_t payload_type);
/**
* @brief Creates an id_payload_t from an existing identification_t object.
*
- * @param is_initiator
- * - TRUE if this payload is of type IDi
- * - FALSE if this payload is of type IDr
+ * @param payload_type one of ID_INITIATOR, ID_RESPONDER
* @param identification identification_t object
* @return id_payload_t object
*
* @ingroup payloads
*/
-id_payload_t *id_payload_create_from_identification(bool is_initiator,identification_t *identification);
+id_payload_t *id_payload_create_from_identification(payload_type_t payload_type, identification_t *identification);
*/
/*
+ * Copyright (C) 2007 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
case NONCE:
return (payload_t*)nonce_payload_create();
case ID_INITIATOR:
- return (payload_t*)id_payload_create(TRUE);
+ return (payload_t*)id_payload_create(ID_INITIATOR);
case ID_RESPONDER:
- return (payload_t*)id_payload_create(FALSE);
+ return (payload_t*)id_payload_create(ID_RESPONDER);
case AUTHENTICATION:
return (payload_t*)auth_payload_create();
case CERTIFICATE:
this->ike_sa->set_my_id(this->ike_sa, me->clone(me));
}
- id = id_payload_create_from_identification(this->initiator, me);
+ id = id_payload_create_from_identification(this->initiator ? ID_INITIATOR : ID_RESPONDER, me);
message->add_payload(message, (payload_t*)id);
/* as initiator, include other ID if it does not contain wildcards */
if (this->initiator && !other->contains_wildcards(other))
{
- id = id_payload_create_from_identification(FALSE, other);
+ id = id_payload_create_from_identification(ID_RESPONDER, other);
message->add_payload(message, (payload_t*)id);
}
return SUCCESS;