ca16af9ed8d74e22378dbc201e1d9b4d2d265232
[strongswan.git] / src / libcharon / plugins / tnccs_11 / messages / tnccs_error_msg.h
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 /**
17 * @defgroup tnccs_error_msg tnccs_error_msg
18 * @{ @ingroup tnccs_11
19 */
20
21 #ifndef TNCCS_ERROR_MSG_H_
22 #define TNCCS_ERROR_MSG_H_
23
24 typedef enum tnccs_error_type_t tnccs_error_type_t;
25 typedef struct tnccs_error_msg_t tnccs_error_msg_t;
26
27 #include "tnccs_msg.h"
28
29 /**
30 * TNCCS error types as defined in section 8.1.4 of TCG TNC IF-TNCCS v1.2
31 */
32 enum tnccs_error_type_t {
33 TNCCS_ERROR_BATCH_TOO_LONG,
34 TNCCS_ERROR_MALFORMED_BATCH,
35 TNCCS_ERROR_INVALID_BATCH_ID,
36 TNCCS_ERROR_INVALID_RECIPIENT_TYPE,
37 TNCCS_ERROR_INTERNAL_ERROR,
38 TNCCS_ERROR_OTHER
39 };
40
41 /**
42 * enum name for tnccs_error_type_t.
43 */
44 extern enum_name_t *tnccs_error_type_names;
45
46 /**
47 * Class representing the TNCCS-Error message type
48 */
49 struct tnccs_error_msg_t {
50
51 /**
52 * TNCCS Message interface
53 */
54 tnccs_msg_t tnccs_msg_interface;
55
56 /**
57 * Get error message and type
58 *
59 * @param type TNCCS error type
60 * @return arbitrary error message
61 */
62 char* (*get_message)(tnccs_error_msg_t *this, tnccs_error_type_t *type);
63 };
64
65 /**
66 * Create a TNCCS-Error message from XML-encoded message node
67 *
68 * @param msg_node XML-encoded message node
69 */
70 tnccs_msg_t *tnccs_error_msg_create_from_node(xmlNodePtr node);
71
72 /**
73 * Create a TNCCS-Error message from parameters
74 *
75 * @param type TNCCS error type
76 * @param msg arbitrary error message
77 */
78 tnccs_msg_t *tnccs_error_msg_create(tnccs_error_type_t type, char *msg);
79
80 #endif /** TNCCS_ERROR_MSG_H_ @}*/