]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/metadata/metadata.h
2 * Copyright (C) 2021 Tobias Brunner
3 * Copyright (C) 2021 Thomas Egerer
5 * Copyright (C) secunet Security Networks AG
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>.
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
19 * @defgroup metadata metadata
20 * @ingroup libstrongswan
22 * @defgroup metadata_t metadata
23 * @{ @ingroup metadata
29 #include <utils/utils.h>
31 typedef struct metadata_t metadata_t
;
34 * Pre-defined metadata type for int values. Note that while the constructor and
35 * equals() work with integer values/types smaller than int (such values get
36 * promoted to int when passed via ...), get() does not and expects a pointer to
39 #define METADATA_TYPE_INT "int"
42 * Pre-defined metadata type for uint64_t values. Make sure to pass only
43 * uint64_t values/variables also to the constructor and equals() (or cast them
44 * appropriately there).
46 #define METADATA_TYPE_UINT64 "uint64"
49 * Metadata object to allow storing arbitrary values in an encapsulated
55 * Return the type of the metadata object.
57 * @return string type of the metadata object
59 const char *(*get_type
)(metadata_t
*this);
62 * Clone this metadata object.
64 * @return a cloned instance
66 metadata_t
*(*clone
)(metadata_t
*this);
69 * Compare this to another value (or values, depending on the type).
71 * @param ... value(s) (raw, not metadata_t) to compare this to
72 * @return TRUE if value is equal to metadata value
74 bool (*equals
)(metadata_t
*this, ...);
77 * Retrieve the values via variadic argument(s).
79 * @param ... pointer(s) to obtain metadata value(s)
81 void (*get
)(metadata_t
*this, ...);
84 * Destroy this metadata object.
86 void (*destroy
)(metadata_t
*this);
90 * Constructor type for metadata objects.
92 * @param type type of the metadata object, allows using the same
93 * constructor for different types
94 * @param args type-specific arguments
95 * @return metadata object, NULL on failure
97 typedef metadata_t
*(*metadata_create_t
)(const char *type
, va_list args
);
99 #endif /** METADATA_H_ @}*/