child-rekey: Don't change state to INSTALLED if it was already REKEYING
[strongswan.git] / src / libtncif / tncif_policy.c
1 /*
2 * Copyright (C) 2013 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 "tncif_policy.h"
17
18 /**
19 * See header
20 */
21 TNC_IMV_Evaluation_Result tncif_policy_update_evaluation(
22 TNC_IMV_Evaluation_Result eval,
23 TNC_IMV_Evaluation_Result eval_add)
24 {
25 switch (eval)
26 {
27 case TNC_IMV_EVALUATION_RESULT_COMPLIANT:
28 switch (eval_add)
29 {
30 case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MINOR:
31 case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR:
32 case TNC_IMV_EVALUATION_RESULT_ERROR:
33 eval = eval_add;
34 break;
35 default:
36 break;
37 }
38 break;
39 case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MINOR:
40 switch (eval_add)
41 {
42 case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR:
43 case TNC_IMV_EVALUATION_RESULT_ERROR:
44 eval = eval_add;
45 break;
46 default:
47 break;
48 }
49 break;
50 case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR:
51 switch (eval_add)
52 {
53 case TNC_IMV_EVALUATION_RESULT_ERROR:
54 eval = eval_add;
55 break;
56 default:
57 break;
58 }
59 break;
60 case TNC_IMV_EVALUATION_RESULT_DONT_KNOW:
61 eval = eval_add;
62 break;
63 default:
64 break;
65 }
66 return eval;
67 }
68
69 /**
70 * See header
71 */
72 TNC_IMV_Action_Recommendation tncif_policy_update_recommendation(
73 TNC_IMV_Action_Recommendation rec,
74 TNC_IMV_Action_Recommendation rec_add)
75 {
76 switch (rec)
77 {
78 case TNC_IMV_ACTION_RECOMMENDATION_ALLOW:
79 switch (rec_add)
80 {
81 case TNC_IMV_ACTION_RECOMMENDATION_NO_ACCESS:
82 case TNC_IMV_ACTION_RECOMMENDATION_ISOLATE:
83 rec = rec_add;
84 break;
85 default:
86 break;
87 }
88 break;
89 case TNC_IMV_ACTION_RECOMMENDATION_ISOLATE:
90 switch (rec_add)
91 {
92 case TNC_IMV_ACTION_RECOMMENDATION_NO_ACCESS:
93 rec = rec_add;
94 break;
95 default:
96 break;
97 }
98 break;
99 case TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION:
100 rec = rec_add;
101 break;
102 default:
103 break;
104 }
105 return rec;
106 }