2005-11-29 10:02:34 +00:00
|
|
|
/*
|
2007-10-02 11:55:10 +00:00
|
|
|
* Copyright (C) 2007 Tobias Brunner
|
2006-07-07 08:49:06 +00:00
|
|
|
* Copyright (C) 2005-2006 Martin Willi
|
|
|
|
* Copyright (C) 2005 Jan Hutter
|
2005-11-29 10:02:34 +00:00
|
|
|
* Hochschule fuer Technik Rapperswil
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
2008-03-13 14:14:44 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
2005-11-29 10:02:34 +00:00
|
|
|
*/
|
|
|
|
|
2008-03-13 14:14:44 +00:00
|
|
|
/**
|
|
|
|
* @defgroup id_payload id_payload
|
|
|
|
* @{ @ingroup payloads
|
|
|
|
*/
|
2005-11-29 10:02:34 +00:00
|
|
|
|
2006-03-16 15:25:06 +00:00
|
|
|
#ifndef ID_PAYLOAD_H_
|
|
|
|
#define ID_PAYLOAD_H_
|
2005-11-29 10:02:34 +00:00
|
|
|
|
2006-10-30 14:07:05 +00:00
|
|
|
typedef struct id_payload_t id_payload_t;
|
|
|
|
|
2006-10-31 12:27:59 +00:00
|
|
|
#include <library.h>
|
2005-12-01 19:53:48 +00:00
|
|
|
#include <utils/identification.h>
|
2005-11-29 10:02:34 +00:00
|
|
|
#include <encoding/payloads/payload.h>
|
|
|
|
|
|
|
|
/**
|
2005-11-29 10:19:27 +00:00
|
|
|
* Length of a id payload without the data in bytes.
|
2005-11-29 10:02:34 +00:00
|
|
|
*/
|
|
|
|
#define ID_PAYLOAD_HEADER_LENGTH 8
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object representing an IKEv2 ID payload.
|
2006-10-30 14:07:05 +00:00
|
|
|
*
|
2006-03-07 09:42:15 +00:00
|
|
|
* The ID payload format is described in RFC section 3.5.
|
2005-11-29 10:02:34 +00:00
|
|
|
*/
|
|
|
|
struct id_payload_t {
|
|
|
|
/**
|
|
|
|
* The payload_t interface.
|
|
|
|
*/
|
|
|
|
payload_t payload_interface;
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Set the ID type.
|
2005-11-29 10:02:34 +00:00
|
|
|
*
|
|
|
|
* @param type Type of ID
|
|
|
|
*/
|
|
|
|
void (*set_id_type) (id_payload_t *this, id_type_t type);
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Get the ID type.
|
2005-11-29 10:02:34 +00:00
|
|
|
*
|
|
|
|
* @return type of the ID
|
|
|
|
*/
|
|
|
|
id_type_t (*get_id_type) (id_payload_t *this);
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Set the ID data.
|
2005-11-29 10:02:34 +00:00
|
|
|
*
|
|
|
|
* Data are getting cloned.
|
|
|
|
*
|
|
|
|
* @param data ID data as chunk_t
|
|
|
|
*/
|
|
|
|
void (*set_data) (id_payload_t *this, chunk_t data);
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Get the ID data.
|
2005-11-29 10:02:34 +00:00
|
|
|
*
|
|
|
|
* Returned data are a copy of the internal one
|
|
|
|
*
|
|
|
|
* @return ID data as chunk_t
|
|
|
|
*/
|
2005-12-03 14:47:58 +00:00
|
|
|
chunk_t (*get_data_clone) (id_payload_t *this);
|
2005-11-29 10:02:34 +00:00
|
|
|
|
2005-12-03 14:47:58 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Get the ID data.
|
2005-12-03 14:47:58 +00:00
|
|
|
*
|
|
|
|
* Returned data are NOT copied.
|
|
|
|
*
|
|
|
|
* @return ID data as chunk_t
|
|
|
|
*/
|
|
|
|
chunk_t (*get_data) (id_payload_t *this);
|
|
|
|
|
2005-12-01 19:53:48 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Creates an identification object of this id payload.
|
2005-12-01 19:53:48 +00:00
|
|
|
*
|
|
|
|
* Returned object has to get destroyed by the caller.
|
|
|
|
*
|
2005-12-06 13:44:22 +00:00
|
|
|
* @return identification_t object
|
2005-12-01 19:53:48 +00:00
|
|
|
*/
|
|
|
|
identification_t *(*get_identification) (id_payload_t *this);
|
|
|
|
|
2005-11-29 10:02:34 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Destroys an id_payload_t object.
|
2005-11-29 10:02:34 +00:00
|
|
|
*/
|
|
|
|
void (*destroy) (id_payload_t *this);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Creates an empty id_payload_t object.
|
2005-11-29 10:02:34 +00:00
|
|
|
*
|
2007-10-02 11:55:10 +00:00
|
|
|
* @param payload_type one of ID_INITIATOR, ID_RESPONDER
|
2005-12-06 13:44:22 +00:00
|
|
|
* @return id_payload_t object
|
2005-11-29 10:02:34 +00:00
|
|
|
*/
|
2007-10-02 11:55:10 +00:00
|
|
|
id_payload_t *id_payload_create(payload_type_t payload_type);
|
2005-11-29 10:02:34 +00:00
|
|
|
|
2005-12-01 19:53:48 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Creates an id_payload_t from an existing identification_t object.
|
2005-12-01 19:53:48 +00:00
|
|
|
*
|
2007-10-02 11:55:10 +00:00
|
|
|
* @param payload_type one of ID_INITIATOR, ID_RESPONDER
|
2005-12-01 19:53:48 +00:00
|
|
|
* @param identification identification_t object
|
2005-12-06 13:44:22 +00:00
|
|
|
* @return id_payload_t object
|
2005-12-01 19:53:48 +00:00
|
|
|
*/
|
2008-03-13 14:14:44 +00:00
|
|
|
id_payload_t *id_payload_create_from_identification(payload_type_t payload_type,
|
|
|
|
identification_t *identification);
|
2005-11-29 10:02:34 +00:00
|
|
|
|
2009-03-24 17:43:01 +00:00
|
|
|
#endif /** ID_PAYLOAD_H_ @}*/
|