d6c6b6036ff17fe999753cece442e904964c7e2b
[strongswan.git] / src / libcharon / encoding / payloads / sa_payload.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup sa_payload sa_payload
19 * @{ @ingroup payloads
20 */
21
22 #ifndef SA_PAYLOAD_H_
23 #define SA_PAYLOAD_H_
24
25 typedef struct sa_payload_t sa_payload_t;
26
27 #include <library.h>
28 #include <encoding/payloads/payload.h>
29 #include <encoding/payloads/proposal_substructure.h>
30 #include <utils/linked_list.h>
31
32 /**
33 * Class representing an IKEv1 or IKEv2 SA Payload.
34 *
35 * The SA Payload format is described in RFC section 3.3.
36 */
37 struct sa_payload_t {
38
39 /**
40 * The payload_t interface.
41 */
42 payload_t payload_interface;
43
44 /**
45 * Gets the proposals in this payload as a list.
46 *
47 * @return a list containing proposal_t s
48 */
49 linked_list_t *(*get_proposals) (sa_payload_t *this);
50
51 /**
52 * Create an enumerator over all proposal substructures.
53 *
54 * @return enumerator over proposal_substructure_t
55 */
56 enumerator_t* (*create_substructure_enumerator)(sa_payload_t *this);
57
58 /**
59 * Destroys an sa_payload_t object.
60 */
61 void (*destroy) (sa_payload_t *this);
62 };
63
64 /**
65 * Creates an empty sa_payload_t object
66 *
67 * @param type SECURITY_ASSOCIATION or SECURITY_ASSOCIATION_V1
68 * @return created sa_payload_t object
69 */
70 sa_payload_t *sa_payload_create(payload_type_t type);
71
72 /**
73 * Creates a sa_payload_t object from a list of proposals.
74 *
75 * @param type SECURITY_ASSOCIATION or SECURITY_ASSOCIATION_V1
76 * @param proposals list of proposals to build the payload from
77 * @return sa_payload_t object
78 */
79 sa_payload_t *sa_payload_create_from_proposal_list(payload_type_t type,
80 linked_list_t *proposals);
81
82 /**
83 * Creates a sa_payload_t object from a single proposal.
84 *
85 * This is only for convenience. Use sa_payload_create_from_proposal_list
86 * if you want to add more than one proposal.
87 *
88 * @param type SECURITY_ASSOCIATION or SECURITY_ASSOCIATION_V1
89 * @param proposal proposal from which the payload should be built.
90 * @return sa_payload_t object
91 */
92 sa_payload_t *sa_payload_create_from_proposal(payload_type_t type,
93 proposal_t *proposal);
94
95 #endif /** SA_PAYLOAD_H_ @}*/