]> git.ipfire.org Git - people/ms/strongswan.git/blame - src/charon/encoding/payloads/transform_attribute.h
(no commit message)
[people/ms/strongswan.git] / src / charon / encoding / payloads / transform_attribute.h
CommitLineData
b860cffd
JH
1/**
2 * @file transform_attribute.h
3 *
3fe05870 4 * @brief Interface of transform_attribute_t.
b860cffd
JH
5 *
6 */
7
8/*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23#ifndef TRANSFORM_ATTRIBUTE_H_
24#define TRANSFORM_ATTRIBUTE_H_
25
696be022 26#include <types.h>
4a962238 27#include <encoding/payloads/payload.h>
b860cffd 28
7eeeaf4e 29
95c61cb9
JH
30typedef enum transform_attribute_type_t transform_attribute_type_t;
31
7eeeaf4e 32/**
8a491129 33 * Type of the attribute, as in IKEv2 RFC 3.3.5.
3fe05870
JH
34 *
35 * @ingroup payloads
7eeeaf4e 36 */
95c61cb9 37enum transform_attribute_type_t {
7eeeaf4e
MW
38 ATTRIBUTE_UNDEFINED = 16384,
39 KEY_LENGTH = 14
40};
41
42/**
3fe05870
JH
43 * String mappings for transform_attribute_type_t.
44 *
45 * @ingroup payloads
7eeeaf4e
MW
46 */
47extern mapping_t transform_attribute_type_m[];
48
95c61cb9
JH
49typedef struct transform_attribute_t transform_attribute_t;
50
b860cffd 51/**
2b547481 52 * @brief Class representing an IKEv2- TRANSFORM Attribute.
b860cffd
JH
53 *
54 * The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
55 *
3fe05870 56 * @ingroup payloads
b860cffd 57 */
95c61cb9 58struct transform_attribute_t {
b860cffd 59 /**
3fe05870 60 * The payload_t interface.
b860cffd
JH
61 */
62 payload_t payload_interface;
f561c205
JH
63
64 /**
3fe05870 65 * @brief Returns the currently set value of the attribute.
f561c205 66 *
3fe05870 67 * @warning Returned data are not copied.
f561c205
JH
68 *
69 * @param this calling transform_attribute_t object
70 * @return chunk_t pointing to the value
71 */
7eeeaf4e
MW
72 chunk_t (*get_value_chunk) (transform_attribute_t *this);
73
74 /**
3fe05870 75 * @brief Returns the currently set value of the attribute.
7eeeaf4e 76 *
3fe05870 77 * @warning Returned data are not copied.
7eeeaf4e
MW
78 *
79 * @param this calling transform_attribute_t object
80 * @return value
81 */
82 u_int16_t (*get_value) (transform_attribute_t *this);
f561c205
JH
83
84 /**
85 * @brief Sets the value of the attribute.
86 *
3fe05870 87 * @warning Value is getting copied.
f561c205
JH
88 *
89 * @param this calling transform_attribute_t object
90 * @param value chunk_t pointing to the value to set
f561c205 91 */
3fe05870 92 void (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
7eeeaf4e
MW
93
94 /**
95 * @brief Sets the value of the attribute.
96 *
97 * @param this calling transform_attribute_t object
98 * @param value value to set
7eeeaf4e 99 */
3fe05870 100 void (*set_value) (transform_attribute_t *this, u_int16_t value);
f561c205
JH
101
102 /**
103 * @brief Sets the type of the attribute.
104 *
105 * @param this calling transform_attribute_t object
106 * @param type type to set (most significant bit is set to zero)
f561c205 107 */
3fe05870 108 void (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
f561c205
JH
109
110 /**
111 * @brief get the type of the attribute.
112 *
113 * @param this calling transform_attribute_t object
114 * @return type of the value
115 */
116 u_int16_t (*get_attribute_type) (transform_attribute_t *this);
b860cffd 117
b9459040
JH
118 /**
119 * @brief Clones an transform_attribute_t object.
120 *
121 * @param this transform_attribute_t object to clone
a0753941 122 * @return cloned transform_attribute_t object
b9459040 123 */
a0753941 124 transform_attribute_t * (*clone) (transform_attribute_t *this);
b9459040 125
b860cffd
JH
126 /**
127 * @brief Destroys an transform_attribute_t object.
128 *
129 * @param this transform_attribute_t object to destroy
b860cffd 130 */
3fe05870 131 void (*destroy) (transform_attribute_t *this);
b860cffd
JH
132};
133
134/**
b737e9d9 135 * @brief Creates an empty transform_attribute_t object.
b860cffd 136 *
c3dc864e 137 * @return transform_attribute_t object
b737e9d9 138 *
3fe05870 139 * @ingroup payloads
b860cffd 140 */
f768bdc3 141transform_attribute_t *transform_attribute_create(void);
b860cffd 142
b737e9d9
JH
143/**
144 * @brief Creates an transform_attribute_t of type KEY_LENGTH.
145 *
146 * @param key_length key length in bytes
c3dc864e 147 * @return transform_attribute_t object
b737e9d9
JH
148 *
149 * @ingroup payloads
150 */
151transform_attribute_t *transform_attribute_create_key_length(u_int16_t key_length);
152
153
b860cffd 154#endif /*TRANSFORM_ATTRIBUTE_H_*/