3565c2d84f18f78d11f27c6395066982fc4afb64
[strongswan.git] / src / libtnccs / plugins / tnccs_20 / messages / pb_tnc_msg.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_msg.h"
17 #include "pb_experimental_msg.h"
18 #include "pb_pa_msg.h"
19 #include "pb_error_msg.h"
20 #include "pb_language_preference_msg.h"
21 #include "pb_assessment_result_msg.h"
22 #include "pb_access_recommendation_msg.h"
23 #include "pb_remediation_parameters_msg.h"
24 #include "pb_reason_string_msg.h"
25
26 #include <library.h>
27
28 ENUM(pb_tnc_msg_type_names, PB_MSG_EXPERIMENTAL, PB_MSG_REASON_STRING,
29 "PB-Experimental",
30 "PB-PA",
31 "PB-Assessment-Result",
32 "PB-Access-Recommendation",
33 "PB-Remediation-Parameters",
34 "PB-Error",
35 "PB-Language-Preference",
36 "PB-Reason-String"
37 );
38
39 pb_tnc_msg_info_t pb_tnc_msg_infos[] = {
40 { 12, FALSE, FALSE, TRUE_OR_FALSE },
41 { 24, FALSE, FALSE, TRUE },
42 { 16, TRUE, TRUE, TRUE },
43 { 16, TRUE, TRUE, FALSE },
44 { 20, FALSE, TRUE, FALSE },
45 { 20, FALSE, FALSE, TRUE },
46 { 12, FALSE, FALSE, FALSE },
47 { 17, FALSE, TRUE, FALSE },
48 };
49
50 /**
51 * See header
52 */
53 pb_tnc_msg_t* pb_tnc_msg_create_from_data(pb_tnc_msg_type_t type, chunk_t value)
54 {
55 switch (type)
56 {
57 case PB_MSG_PA:
58 return pb_pa_msg_create_from_data(value);
59 case PB_MSG_ERROR:
60 return pb_error_msg_create_from_data(value);
61 case PB_MSG_EXPERIMENTAL:
62 return pb_experimental_msg_create_from_data(value);
63 case PB_MSG_LANGUAGE_PREFERENCE:
64 return pb_language_preference_msg_create_from_data(value);
65 case PB_MSG_ASSESSMENT_RESULT:
66 return pb_assessment_result_msg_create_from_data(value);
67 case PB_MSG_ACCESS_RECOMMENDATION:
68 return pb_access_recommendation_msg_create_from_data(value);
69 case PB_MSG_REMEDIATION_PARAMETERS:
70 return pb_remediation_parameters_msg_create_from_data(value);
71 case PB_MSG_REASON_STRING:
72 return pb_reason_string_msg_create_from_data(value);
73 }
74 return NULL;
75 }