2005-11-14 12:04:06 +00:00
|
|
|
/*
|
2006-07-07 08:49:06 +00:00
|
|
|
* Copyright (C) 2005-2006 Martin Willi
|
|
|
|
* Copyright (C) 2005 Jan Hutter
|
2018-05-23 14:04:50 +00:00
|
|
|
* HSR Hochschule fuer Technik Rapperswil
|
2005-11-14 12:04:06 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup transform_attribute transform_attribute
|
|
|
|
* @{ @ingroup payloads
|
2005-11-14 12:04:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TRANSFORM_ATTRIBUTE_H_
|
|
|
|
#define TRANSFORM_ATTRIBUTE_H_
|
|
|
|
|
2006-10-30 14:07:05 +00:00
|
|
|
typedef enum transform_attribute_type_t transform_attribute_type_t;
|
|
|
|
typedef struct transform_attribute_t transform_attribute_t;
|
|
|
|
|
2006-10-31 12:27:59 +00:00
|
|
|
#include <library.h>
|
2005-11-23 09:57:18 +00:00
|
|
|
#include <encoding/payloads/payload.h>
|
2005-11-14 12:04:06 +00:00
|
|
|
|
2005-11-16 16:12:31 +00:00
|
|
|
/**
|
2011-11-16 12:46:54 +00:00
|
|
|
* Type of the attribute.
|
2005-11-16 16:12:31 +00:00
|
|
|
*/
|
2005-11-24 09:17:51 +00:00
|
|
|
enum transform_attribute_type_t {
|
2011-11-16 12:46:54 +00:00
|
|
|
/** IKEv1 Phase 1 attributes */
|
|
|
|
TATTR_PH1_ENCRYPTION_ALGORITHM = 1,
|
|
|
|
TATTR_PH1_HASH_ALGORITHM = 2,
|
|
|
|
TATTR_PH1_AUTH_METHOD = 3,
|
|
|
|
TATTR_PH1_GROUP = 4,
|
|
|
|
TATTR_PH1_GROUP_TYPE = 5,
|
|
|
|
TATTR_PH1_GROUP_PRIME = 6,
|
|
|
|
TATTR_PH1_GROUP_GENONE = 7,
|
|
|
|
TATTR_PH1_GROUP_GENTWO = 8,
|
|
|
|
TATTR_PH1_GROUP_CURVE_A = 9,
|
|
|
|
TATTR_PH1_GROUP_CURVE_B = 10,
|
|
|
|
TATTR_PH1_LIFE_TYPE = 11,
|
|
|
|
TATTR_PH1_LIFE_DURATION = 12,
|
|
|
|
TATTR_PH1_PRF = 13,
|
|
|
|
TATTR_PH1_KEY_LENGTH = 14,
|
|
|
|
TATTR_PH1_FIELD_SIZE = 15,
|
|
|
|
TATTR_PH1_GROUP_ORDER = 16,
|
|
|
|
/** IKEv1 Phase 2 attributes */
|
|
|
|
TATTR_PH2_SA_LIFE_TYPE = 1,
|
|
|
|
TATTR_PH2_SA_LIFE_DURATION = 2,
|
|
|
|
TATTR_PH2_GROUP = 3,
|
|
|
|
TATTR_PH2_ENCAP_MODE = 4,
|
|
|
|
TATTR_PH2_AUTH_ALGORITHM = 5,
|
|
|
|
TATTR_PH2_KEY_LENGTH = 6,
|
|
|
|
TATTR_PH2_KEY_ROUNDS = 7,
|
|
|
|
TATTR_PH2_COMP_DICT_SIZE = 8,
|
|
|
|
TATTR_PH2_COMP_PRIV_ALGORITHM = 9,
|
|
|
|
TATTR_PH2_ECN_TUNNEL = 10,
|
|
|
|
TATTR_PH2_EXT_SEQ_NUMBER = 11,
|
|
|
|
/* IKEv2 key length attribute */
|
|
|
|
TATTR_IKEV2_KEY_LENGTH = 14,
|
|
|
|
/* undefined, private use attribute */
|
|
|
|
TATTR_UNDEFINED = 16384,
|
2005-11-16 16:12:31 +00:00
|
|
|
};
|
|
|
|
|
2009-09-04 11:46:09 +00:00
|
|
|
/**
|
2011-11-16 12:46:54 +00:00
|
|
|
* Enum names for IKEv1 Phase 1 transform_attribute_type_t.
|
2005-11-16 16:12:31 +00:00
|
|
|
*/
|
2011-11-16 12:46:54 +00:00
|
|
|
extern enum_name_t *tattr_ph1_names;
|
2005-11-16 16:12:31 +00:00
|
|
|
|
2005-11-14 12:04:06 +00:00
|
|
|
/**
|
2011-11-16 12:46:54 +00:00
|
|
|
* Enum names for IKEv1 Phase 2 transform_attribute_type_t.
|
|
|
|
*/
|
|
|
|
extern enum_name_t *tattr_ph2_names;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enum names for IKEv2 transform_attribute_type_t.
|
|
|
|
*/
|
|
|
|
extern enum_name_t *tattr_ikev2_names;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class representing an IKEv1/IKEv2 TRANSFORM Attribute.
|
2005-11-14 12:04:06 +00:00
|
|
|
*/
|
2005-11-24 09:17:51 +00:00
|
|
|
struct transform_attribute_t {
|
2011-11-16 12:46:54 +00:00
|
|
|
|
2005-11-14 12:04:06 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* The payload_t interface.
|
2005-11-14 12:04:06 +00:00
|
|
|
*/
|
|
|
|
payload_t payload_interface;
|
2005-11-14 13:51:49 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Returns the currently set value of the attribute.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2008-03-13 14:14:44 +00:00
|
|
|
* Returned data are not copied.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2011-11-24 14:32:13 +00:00
|
|
|
* @return chunk_t pointing to internal value
|
2005-11-14 13:51:49 +00:00
|
|
|
*/
|
2005-11-16 16:12:31 +00:00
|
|
|
chunk_t (*get_value_chunk) (transform_attribute_t *this);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-16 16:12:31 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Returns the currently set value of the attribute.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2008-03-13 14:14:44 +00:00
|
|
|
* Returned data are not copied.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2005-11-16 16:12:31 +00:00
|
|
|
* @return value
|
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint64_t (*get_value) (transform_attribute_t *this);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-14 13:51:49 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* get the type of the attribute.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2005-11-14 13:51:49 +00:00
|
|
|
* @return type of the value
|
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint16_t (*get_attribute_type) (transform_attribute_t *this);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-14 12:04:06 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Destroys an transform_attribute_t object.
|
2005-11-14 12:04:06 +00:00
|
|
|
*/
|
2005-11-28 18:24:10 +00:00
|
|
|
void (*destroy) (transform_attribute_t *this);
|
2005-11-14 12:04:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Creates an empty transform_attribute_t object.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2013-10-29 09:09:39 +00:00
|
|
|
* @param type PLV2_TRANSFORM_ATTRIBUTE or PLV1_TRANSFORM_ATTRIBUTE
|
2005-12-06 13:44:22 +00:00
|
|
|
* @return transform_attribute_t object
|
2005-11-14 12:04:06 +00:00
|
|
|
*/
|
2011-11-16 12:46:54 +00:00
|
|
|
transform_attribute_t *transform_attribute_create(payload_type_t type);
|
2005-11-14 12:04:06 +00:00
|
|
|
|
2005-12-01 08:48:57 +00:00
|
|
|
/**
|
2011-11-24 11:52:11 +00:00
|
|
|
* Creates a two byte value or a larger attribute for a given attribute kind.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2013-10-29 09:09:39 +00:00
|
|
|
* @param type PLV2_TRANSFORM_ATTRIBUTE or PLV1_TRANSFORM_ATTRIBUTE
|
2011-11-16 17:24:14 +00:00
|
|
|
* @param kind attribute kind
|
|
|
|
* @param value fixed two byte value
|
2005-12-06 13:44:22 +00:00
|
|
|
* @return transform_attribute_t object
|
2005-12-01 08:48:57 +00:00
|
|
|
*/
|
2011-11-16 17:24:14 +00:00
|
|
|
transform_attribute_t *transform_attribute_create_value(payload_type_t type,
|
2016-03-22 12:22:01 +00:00
|
|
|
transform_attribute_type_t kind, uint64_t value);
|
2005-12-01 08:48:57 +00:00
|
|
|
|
2009-03-24 17:43:01 +00:00
|
|
|
#endif /** TRANSFORM_ATTRIBUTE_H_ @}*/
|