updated Doxyfile
[strongswan.git] / src / charon / encoding / payloads / payload.c
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 * $Id$
18 */
19
20
21 #include "payload.h"
22
23 #include <encoding/payloads/ike_header.h>
24 #include <encoding/payloads/sa_payload.h>
25 #include <encoding/payloads/nonce_payload.h>
26 #include <encoding/payloads/id_payload.h>
27 #include <encoding/payloads/ke_payload.h>
28 #include <encoding/payloads/notify_payload.h>
29 #include <encoding/payloads/auth_payload.h>
30 #include <encoding/payloads/cert_payload.h>
31 #include <encoding/payloads/certreq_payload.h>
32 #include <encoding/payloads/encryption_payload.h>
33 #include <encoding/payloads/ts_payload.h>
34 #include <encoding/payloads/delete_payload.h>
35 #include <encoding/payloads/vendor_id_payload.h>
36 #include <encoding/payloads/cp_payload.h>
37 #include <encoding/payloads/configuration_attribute.h>
38 #include <encoding/payloads/eap_payload.h>
39 #include <encoding/payloads/unknown_payload.h>
40
41
42 ENUM_BEGIN(payload_type_names, NO_PAYLOAD, NO_PAYLOAD,
43 "NO_PAYLOAD");
44 ENUM_NEXT(payload_type_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, NO_PAYLOAD,
45 "SECURITY_ASSOCIATION",
46 "KEY_EXCHANGE",
47 "ID_INITIATOR",
48 "ID_RESPONDER",
49 "CERTIFICATE",
50 "CERTIFICATE_REQUEST",
51 "AUTHENTICATION",
52 "NONCE",
53 "NOTIFY",
54 "DELETE",
55 "VENDOR_ID",
56 "TRAFFIC_SELECTOR_INITIATOR",
57 "TRAFFIC_SELECTOR_RESPONDER",
58 "ENCRYPTED",
59 "CONFIGURATION",
60 "EXTENSIBLE_AUTHENTICATION");
61 #ifdef ME
62 ENUM_NEXT(payload_type_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
63 "ID_PEER");
64 ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, ID_PEER,
65 "HEADER",
66 "PROPOSAL_SUBSTRUCTURE",
67 "TRANSFORM_SUBSTRUCTURE",
68 "TRANSFORM_ATTRIBUTE",
69 "TRAFFIC_SELECTOR_SUBSTRUCTURE",
70 "CONFIGURATION_ATTRIBUTE",
71 "UNKNOWN_PAYLOAD");
72 #else
73 ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
74 "HEADER",
75 "PROPOSAL_SUBSTRUCTURE",
76 "TRANSFORM_SUBSTRUCTURE",
77 "TRANSFORM_ATTRIBUTE",
78 "TRAFFIC_SELECTOR_SUBSTRUCTURE",
79 "CONFIGURATION_ATTRIBUTE",
80 "UNKNOWN_PAYLOAD");
81 #endif /* ME */
82 ENUM_END(payload_type_names, UNKNOWN_PAYLOAD);
83
84 /* short forms of payload names */
85 ENUM_BEGIN(payload_type_short_names, NO_PAYLOAD, NO_PAYLOAD,
86 "--");
87 ENUM_NEXT(payload_type_short_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, NO_PAYLOAD,
88 "SA",
89 "KE",
90 "IDi",
91 "IDr",
92 "CERT",
93 "CERTREQ",
94 "AUTH",
95 "No",
96 "N",
97 "D",
98 "V",
99 "TSi",
100 "TSr",
101 "E",
102 "CP",
103 "EAP");
104 #ifdef ME
105 ENUM_NEXT(payload_type_short_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
106 "IDp");
107 ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, ID_PEER,
108 "HDR",
109 "PROP",
110 "TRANS",
111 "TRANSATTR",
112 "TSSUB",
113 "CPATTR",
114 "??");
115 #else
116 ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
117 "HDR",
118 "PROP",
119 "TRANS",
120 "TRANSATTR",
121 "TSSUB",
122 "CPATTR",
123 "??");
124 #endif /* ME */
125 ENUM_END(payload_type_short_names, UNKNOWN_PAYLOAD);
126
127 /*
128 * see header
129 */
130 payload_t *payload_create(payload_type_t type)
131 {
132 switch (type)
133 {
134 case HEADER:
135 return (payload_t*)ike_header_create();
136 case SECURITY_ASSOCIATION:
137 return (payload_t*)sa_payload_create();
138 case PROPOSAL_SUBSTRUCTURE:
139 return (payload_t*)proposal_substructure_create();
140 case TRANSFORM_SUBSTRUCTURE:
141 return (payload_t*)transform_substructure_create();
142 case TRANSFORM_ATTRIBUTE:
143 return (payload_t*)transform_attribute_create();
144 case NONCE:
145 return (payload_t*)nonce_payload_create();
146 case ID_INITIATOR:
147 return (payload_t*)id_payload_create(ID_INITIATOR);
148 case ID_RESPONDER:
149 return (payload_t*)id_payload_create(ID_RESPONDER);
150 #ifdef ME
151 case ID_PEER:
152 return (payload_t*)id_payload_create(ID_PEER);
153 #endif /* ME */
154 case AUTHENTICATION:
155 return (payload_t*)auth_payload_create();
156 case CERTIFICATE:
157 return (payload_t*)cert_payload_create();
158 case CERTIFICATE_REQUEST:
159 return (payload_t*)certreq_payload_create();
160 case TRAFFIC_SELECTOR_SUBSTRUCTURE:
161 return (payload_t*)traffic_selector_substructure_create();
162 case TRAFFIC_SELECTOR_INITIATOR:
163 return (payload_t*)ts_payload_create(TRUE);
164 case TRAFFIC_SELECTOR_RESPONDER:
165 return (payload_t*)ts_payload_create(FALSE);
166 case KEY_EXCHANGE:
167 return (payload_t*)ke_payload_create();
168 case NOTIFY:
169 return (payload_t*)notify_payload_create();
170 case DELETE:
171 return (payload_t*)delete_payload_create(0);
172 case VENDOR_ID:
173 return (payload_t*)vendor_id_payload_create();
174 case CONFIGURATION:
175 return (payload_t*)cp_payload_create();
176 case CONFIGURATION_ATTRIBUTE:
177 return (payload_t*)configuration_attribute_create();
178 case EXTENSIBLE_AUTHENTICATION:
179 return (payload_t*)eap_payload_create();
180 case ENCRYPTED:
181 return (payload_t*)encryption_payload_create();
182 default:
183 return (payload_t*)unknown_payload_create();
184 }
185 }
186