- parser succesfully parses sa payload
[strongswan.git] / Source / charon / payloads / payload.c
1 /**
2 * @file payload.c
3 *
4 * @brief Generic payload interface
5 *
6 *
7 */
8
9 /*
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24
25 #include "payload.h"
26
27 #include "ike_header.h"
28 #include "sa_payload.h"
29
30
31
32
33
34 /*
35 * build the mappings for payload_type_t
36 */
37 mapping_t payload_type_t_mappings[] = {
38 {NO_PAYLOAD, "NO_PAYLOAD"},
39 {SECURITY_ASSOCIATION, "SECURITY_ASSOCIATION"},
40 {KEY_EXCHANGE, "KEY_EXCHANGE"},
41 {ID_INITIATOR, "ID_INITIATOR"},
42 {ID_RESPONDER, "ID_RESPONDER"},
43 {CERTIFICATE, "CERTIFICATE"},
44 {CERTIFICATE_REQUEST, "CERTIFICATE_REQUEST"},
45 {AUTHENTICATION, "AUTHENTICATION"},
46 {NONCE, "NONCE"},
47 {NOTIFY, "NOTIFY"},
48 {DELETE, "DELETE"},
49 {VENDOR_ID, "VENDOR_ID"},
50 {TRAFFIC_SELECTOR_INITIATOR, "TRAFFIC_SELECTOR_INITIATOR"},
51 {TRAFFIC_SELECTOR_RESPONDER, "TRAFFIC_SELECTOR_RESPONDER"},
52 {ENCRYPTED, "ENCRYPTED"},
53 {CONFIGURATION, "CONFIGURATION"},
54 {EXTENSIBLE_AUTHENTICATION, "EXTENSIBLE_AUTHENTICATION"},
55 {HEADER, "HEADER"},
56 {PROPOSAL_SUBSTRUCTURE, "PROPOSAL_SUBSTRUCTURE"},
57 {TRANSFORM_SUBSTRUCTURE, "TRANSFORM_SUBSTRUCTURE"},
58 {TRANSFORM_ATTRIBUTE, "TRANSFORM_ATTRIBUTE"},
59 {MAPPING_END, NULL}
60 };
61
62 /*
63 * see header
64 */
65 payload_t *payload_create(payload_type_t type)
66 {
67 switch (type)
68 {
69 case HEADER:
70 return (payload_t*)ike_header_create();
71 case SECURITY_ASSOCIATION:
72 return (payload_t*)sa_payload_create();
73 case PROPOSAL_SUBSTRUCTURE:
74 return (payload_t*)proposal_substructure_create();
75 case TRANSFORM_SUBSTRUCTURE:
76 return (payload_t*)transform_substructure_create();
77 case TRANSFORM_ATTRIBUTE:
78 return (payload_t*)transform_attribute_create();
79 default:
80 return NULL;
81 }
82 }
83