pb_tnc_batch_t class implements parsing and building of PB-TNC batches
[strongswan.git] / src / libcharon / plugins / tnccs_20 / messages / pb_tnc_message.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "pb_tnc_message.h"
17 #include "pb_pa_message.h"
18 #include "pb_error_message.h"
19 #include "pb_language_preference_message.h"
20 #include "pb_assessment_result_message.h"
21 #include "pb_access_recommendation_message.h"
22 #include "pb_reason_string_message.h"
23
24 #include <library.h>
25
26 ENUM(pb_tnc_msg_type_names, PB_MSG_EXPERIMENTAL, PB_MSG_REASON_STRING,
27 "PB-Experimental",
28 "PB-PA",
29 "PB-Assessment-Result",
30 "PB-Access-Recommendation",
31 "PB-Remediation-Parameters",
32 "PB-Error",
33 "PB-Language-Preference",
34 "PB-Reason-String"
35 );
36
37 /**
38 * See header
39 */
40 pb_tnc_message_t* pb_tnc_message_create(pb_tnc_msg_type_t type, chunk_t value)
41 {
42 switch (type)
43 {
44 case PB_MSG_PA:
45 return pb_pa_message_create_from_data(value);
46 case PB_MSG_ERROR:
47 return pb_error_message_create_from_data(value);
48 case PB_MSG_EXPERIMENTAL:
49 return NULL;
50 case PB_MSG_LANGUAGE_PREFERENCE:
51 return pb_language_preference_message_create_from_data(value);
52 case PB_MSG_ASSESSMENT_RESULT:
53 return pb_assessment_result_message_create_from_data(value);
54 case PB_MSG_ACCESS_RECOMMENDATION:
55 return pb_access_recommendation_message_create_from_data(value);
56 case PB_MSG_REMEDIATION_PARAMETERS:
57 return NULL;
58 case PB_MSG_REASON_STRING:
59 return pb_reason_string_message_create_from_data(value);
60 }
61 return NULL;
62 }