- new configuration support added to ike_sa and states
[strongswan.git] / Source / charon / utils / identification.h
1 /**
2 * @file identification.h
3 *
4 * @brief Interface of identification_t.
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
24 #ifndef _IDENTIFICATION_H_
25 #define _IDENTIFICATION_H_
26
27
28 #include "types.h"
29
30 #include <encoding/payloads/id_payload.h>
31
32 typedef struct identification_t identification_t;
33
34 /**
35 * @brief Generic identification, such as used in ID payload.
36 *
37 * The following types are possible:
38 *
39 * - ID_IPV4_ADDR
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)
46 *
47 * @ingroup sa
48 */
49 struct identification_t {
50
51 /**
52 * @brief Get the encoding of this id, to send over
53 * the network.
54 *
55 * @warning Result points to internal data, do NOT free!
56 *
57 * @param this the identification_t_object
58 * @return a chunk containing the encoded bytes
59 */
60 chunk_t (*get_encoding) (identification_t *this);
61
62 /**
63 * @brief Get the type of this identification.
64 *
65 * @param this the identification_t_object
66 * @return id_type_t
67 */
68 id_type_t (*get_type) (identification_t *this);
69
70 /**
71 * @brief Get a string representation of this id.
72 *
73 * @warning Result points to internal data, do NOT free!
74 *
75 * @param this the identification_t_object
76 * @return string
77 */
78 char *(*get_string) (identification_t *this);
79
80 /**
81 * @brief Check if two identification_t objects are equal.
82 *
83 * @param this the identification_t_object
84 * @param other other identification_t_object
85 * @return string
86 */
87 bool (*equals) (identification_t *this,identification_t *other);
88
89
90 /**
91 * @brief Destroys a identification_t object.
92 *
93 * @param this identification_t object
94 */
95 void (*destroy) (identification_t *this);
96 };
97
98 /**
99 * @brief Creates an identification_t object from a string.
100 *
101 * @param type type of this id, such as ID_IPV4_ADDR or ID_RFC822_ADDR
102 * @param string input string, which will be converted
103 * @return - created identification_t object, or
104 * - NULL if type not supported.
105 *
106 * @ingroup sa
107 */
108 identification_t * identification_create_from_string(id_type_t type, char *string);
109
110
111 /**
112 * @brief Creates an identification_t object from an encoded chunk.
113 *
114 * @param type type of this id, such as ID_IPV4_ADDR or ID_RFC822_ADDR
115 * @param encoded encoded bytes, such as from identification_t.get_encoding
116 * @return - created identification_t object, or
117 * - NULL if type not supported.
118 *
119 * @ingroup sa
120 */
121 identification_t * identification_create_from_encoding(id_type_t type, chunk_t encoded);
122
123
124 #endif //_IDENTIFICATION_H_