Added IKEv1 ID payload <-> traffic selector conversion functions
[strongswan.git] / src / libcharon / encoding / payloads / id_payload.h
1 /*
2 * Copyright (C) 2007 Tobias Brunner
3 * Copyright (C) 2005-2006 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
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.
16 */
17
18 /**
19 * @defgroup id_payload id_payload
20 * @{ @ingroup payloads
21 */
22
23 #ifndef ID_PAYLOAD_H_
24 #define ID_PAYLOAD_H_
25
26 typedef struct id_payload_t id_payload_t;
27
28 #include <library.h>
29 #include <utils/identification.h>
30 #include <encoding/payloads/payload.h>
31 #include <selectors/traffic_selector.h>
32
33 /**
34 * Object representing an IKEv1 or an IKEv2 ID payload.
35 */
36 struct id_payload_t {
37
38 /**
39 * The payload_t interface.
40 */
41 payload_t payload_interface;
42
43 /**
44 * Creates an identification object of this id payload.
45 *
46 * @return identification_t object
47 */
48 identification_t *(*get_identification) (id_payload_t *this);
49
50 /**
51 * Creates a traffic selector form a ID_ADDR_SUBNET/RANGE identity.
52 *
53 * @return traffic selector, NULL on failure
54 */
55 traffic_selector_t* (*get_ts)(id_payload_t *this);
56
57 /**
58 * Destroys an id_payload_t object.
59 */
60 void (*destroy) (id_payload_t *this);
61 };
62
63 /**
64 * Creates an empty id_payload_t object.
65 *
66 * @param type one of ID_INITIATOR, ID_RESPONDER and ID_V1
67 * @return id_payload_t object
68 */
69 id_payload_t *id_payload_create(payload_type_t payload_type);
70
71 /**
72 * Creates an id_payload_t from an existing identification_t object.
73 *
74 * @param type one of ID_INITIATOR, ID_RESPONDER and ID_V1
75 * @param id identification_t object
76 * @return id_payload_t object
77 */
78 id_payload_t *id_payload_create_from_identification(payload_type_t type,
79 identification_t *id);
80
81 /**
82 * Create an IKEv1 ID_ADDR_SUBNET/RANGE identity from a traffic selector.
83 *
84 * @param ts traffic selector
85 * @return ID_V1 id_paylad_t object.
86 */
87 id_payload_t *id_payload_create_from_ts(traffic_selector_t *ts);
88
89 #endif /** ID_PAYLOAD_H_ @}*/