Allow vendor-specific PB-TNC messages
[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 "ietf/pb_experimental_msg.h"
18 #include "ietf/pb_pa_msg.h"
19 #include "ietf/pb_error_msg.h"
20 #include "ietf/pb_language_preference_msg.h"
21 #include "ietf/pb_assessment_result_msg.h"
22 #include "ietf/pb_access_recommendation_msg.h"
23 #include "ietf/pb_remediation_parameters_msg.h"
24 #include "ietf/pb_reason_string_msg.h"
25 #include "tcg/pb_pdp_referral_msg.h"
26
27 #include <library.h>
28
29 ENUM(pb_tnc_msg_type_names, PB_MSG_EXPERIMENTAL, PB_MSG_REASON_STRING,
30 "PB-Experimental",
31 "PB-PA",
32 "PB-Assessment-Result",
33 "PB-Access-Recommendation",
34 "PB-Remediation-Parameters",
35 "PB-Error",
36 "PB-Language-Preference",
37 "PB-Reason-String"
38 );
39
40 ENUM(pb_tnc_tcg_msg_type_names, PB_TCG_MSG_PDP_REFERRAL, PB_TCG_MSG_PDP_REFERRAL,
41 "PB-PDP-Referral"
42 );
43
44 pb_tnc_msg_info_t pb_tnc_msg_infos[] = {
45 { 12, FALSE, FALSE, TRUE_OR_FALSE },
46 { 24, FALSE, FALSE, TRUE },
47 { 16, TRUE, TRUE, TRUE },
48 { 16, TRUE, TRUE, FALSE },
49 { 20, FALSE, TRUE, FALSE },
50 { 20, FALSE, FALSE, TRUE },
51 { 12, FALSE, FALSE, FALSE },
52 { 17, FALSE, TRUE, FALSE },
53 };
54
55 pb_tnc_msg_info_t pb_tnc_tcg_msg_infos[] = {
56 { 20, FALSE, TRUE, FALSE },
57 };
58
59 /**
60 * See header
61 */
62 pb_tnc_msg_t* pb_tnc_msg_create_from_data(pen_type_t msg_type, chunk_t value)
63 {
64 if (msg_type.vendor_id == PEN_IETF)
65 {
66 switch (msg_type.type)
67 {
68 case PB_MSG_PA:
69 return pb_pa_msg_create_from_data(value);
70 case PB_MSG_ERROR:
71 return pb_error_msg_create_from_data(value);
72 case PB_MSG_EXPERIMENTAL:
73 return pb_experimental_msg_create_from_data(value);
74 case PB_MSG_LANGUAGE_PREFERENCE:
75 return pb_language_preference_msg_create_from_data(value);
76 case PB_MSG_ASSESSMENT_RESULT:
77 return pb_assessment_result_msg_create_from_data(value);
78 case PB_MSG_ACCESS_RECOMMENDATION:
79 return pb_access_recommendation_msg_create_from_data(value);
80 case PB_MSG_REMEDIATION_PARAMETERS:
81 return pb_remediation_parameters_msg_create_from_data(value);
82 case PB_MSG_REASON_STRING:
83 return pb_reason_string_msg_create_from_data(value);
84 }
85 }
86 else if (msg_type.vendor_id == PEN_TCG)
87 {
88 if (msg_type.type == PB_TCG_MSG_PDP_REFERRAL)
89 {
90 return pb_pdp_referral_msg_create_from_data(value);
91 }
92 }
93 return NULL;
94 }