- implemented sa_config
[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 Destroys a identification_t object.
82 *
83 * @param this identification_t object
84 */
85 void (*destroy) (identification_t *this);
86 };
87
88 /**
89 * @brief Creates an identification_t object from a string.
90 *
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.
95 *
96 * @ingroup sa
97 */
98 identification_t * identification_create_from_string(id_type_t type, char *string);
99
100
101 /**
102 * @brief Creates an identification_t object from an encoded chunk.
103 *
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.
108 *
109 * @ingroup sa
110 */
111 identification_t * identification_create_from_encoding(id_type_t type, chunk_t encoded);
112
113
114 #endif //_IDENTIFICATION_H_