2 * @file identification.h
4 * @brief Interface of identification_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
24 #ifndef _IDENTIFICATION_H_
25 #define _IDENTIFICATION_H_
30 #include <encoding/payloads/id_payload.h>
32 typedef struct identification_t identification_t
;
35 * @brief Generic identification, such as used in ID payload.
37 * The following types are possible:
40 * - ID_FQDN (not implemented)
41 * - ID_RFC822_ADDR (not implemented)
42 * - ID_IPV6_ADDR (not implemented)
43 * - ID_DER_ASN1_DN (not implemented)
44 * - ID_DER_ASN1_GN (not implemented)
45 * - ID_KEY_ID (not implemented)
49 struct identification_t
{
52 * @brief Get the encoding of this id, to send over
55 * @warning Result points to internal data, do NOT free!
57 * @param this the identification_t_object
58 * @return a chunk containing the encoded bytes
60 chunk_t (*get_encoding
) (identification_t
*this);
63 * @brief Get the type of this identification.
65 * @param this the identification_t_object
68 id_type_t (*get_type
) (identification_t
*this);
71 * @brief Get a string representation of this id.
73 * @warning Result points to internal data, do NOT free!
75 * @param this the identification_t_object
78 char *(*get_string
) (identification_t
*this);
81 * @brief Destroys a identification_t object.
83 * @param this identification_t object
85 void (*destroy
) (identification_t
*this);
89 * @brief Creates an identification_t object from a string.
91 * @param type type of this id, such as ID_IPV4_ADDR or ID_RFC822_ADDR
92 * @param string input string, which will be converted
93 * @return - created identification_t object, or
94 * - NULL if type not supported.
98 identification_t
* identification_create_from_string(id_type_t type
, char *string
);
102 * @brief Creates an identification_t object from an encoded chunk.
104 * @param type type of this id, such as ID_IPV4_ADDR or ID_RFC822_ADDR
105 * @param encoded encoded bytes, such as from identification_t.get_encoding
106 * @return - created identification_t object, or
107 * - NULL if type not supported.
111 identification_t
* identification_create_from_encoding(id_type_t type
, chunk_t encoded
);
114 #endif //_IDENTIFICATION_H_