]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libcharon/encoding/payloads/configuration_attribute.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libcharon / encoding / payloads / configuration_attribute.h
CommitLineData
7ba3f707 1/*
b5a2055f 2 * Copyright (C) 2005-2009 Martin Willi
c71d53ba 3 * Copyright (C) 2005 Jan Hutter
19ef2aec
TB
4 *
5 * Copyright (C) secunet Security Networks AG
7ba3f707
JH
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
552cc11b
MW
16 */
17
18/**
19 * @defgroup configuration_attribute configuration_attribute
20 * @{ @ingroup payloads
7ba3f707
JH
21 */
22
16b9a73c
MW
23#ifndef CONFIGURATION_ATTRIBUTE_H_
24#define CONFIGURATION_ATTRIBUTE_H_
7ba3f707 25
382b4817
MW
26typedef struct configuration_attribute_t configuration_attribute_t;
27
db7ef624 28#include <library.h>
930443af 29#include <attributes/attributes.h>
7ba3f707
JH
30#include <encoding/payloads/payload.h>
31
7ba3f707 32/**
017d98bf 33 * Class representing an IKEv2 configuration attribute / IKEv1 data attribute.
7ba3f707
JH
34 */
35struct configuration_attribute_t {
7ba3f707
JH
36
37 /**
b5a2055f 38 * Implements payload_t interface.
7ba3f707 39 */
b5a2055f 40 payload_t payload_interface;
7daf5226 41
7ba3f707 42 /**
b5a2055f 43 * Get the type of the attribute.
7daf5226 44 *
b5a2055f 45 * @return type of the configuration attribute
7ba3f707 46 */
b5a2055f 47 configuration_attribute_type_t (*get_type)(configuration_attribute_t *this);
7daf5226 48
7ba3f707 49 /**
017d98bf 50 * Returns the value of the attribute as chunk.
7daf5226 51 *
b5a2055f 52 * @return chunk_t pointing to the internal value
7ba3f707 53 */
017d98bf
MW
54 chunk_t (*get_chunk) (configuration_attribute_t *this);
55
56 /**
57 * Returns the 2 byte value of the attribute as u_int16.
58 *
59 * @return attribute value
60 */
b12c53ce 61 uint16_t (*get_value) (configuration_attribute_t *this);
7daf5226 62
7ba3f707 63 /**
552cc11b 64 * Destroys an configuration_attribute_t object.
7ba3f707
JH
65 */
66 void (*destroy) (configuration_attribute_t *this);
67};
68
69/**
b5a2055f
MW
70 * Creates an empty configuration attribute.
71 *
3ecfc83c 72 * @param type PLV2_CONFIGURATION_ATTRIBUTE or PLV1_CONFIGURATION_ATTRIBUTE
017d98bf 73 * @return created configuration attribute
b5a2055f 74 */
017d98bf 75configuration_attribute_t *configuration_attribute_create(payload_type_t type);
b5a2055f
MW
76
77/**
78 * Creates a configuration attribute with type and value.
7daf5226 79 *
3ecfc83c 80 * @param type PLV2_CONFIGURATION_ATTRIBUTE or PLV1_CONFIGURATION_ATTRIBUTE
017d98bf
MW
81 * @param attr_type type of configuration attribute
82 * @param chunk attribute value, gets cloned
83 * @return created configuration attribute
84 */
85configuration_attribute_t *configuration_attribute_create_chunk(
86 payload_type_t type, configuration_attribute_type_t attr_type, chunk_t chunk);
87
88/**
89 * Creates a IKEv1 configuration attribute with 2 bytes value (IKEv1 only).
90 *
91 * @param attr_type type of configuration attribute
92 * @param value attribute value, gets cloned
3ecfc83c 93 * @return created PLV1_CONFIGURATION_ATTRIBUTE configuration attribute
7ba3f707 94 */
b5a2055f 95configuration_attribute_t *configuration_attribute_create_value(
b12c53ce 96 configuration_attribute_type_t attr_type, uint16_t value);
7ba3f707 97
1490ff4d 98#endif /** CONFIGURATION_ATTRIBUTE_H_ @}*/