pb_tnc_batch_t class implements parsing and building of PB-TNC batches
[strongswan.git] / src / libcharon / plugins / tnccs_20 / messages / pb_tnc_message.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 pb_tnc_message pb_tnc_message
18 * @{ @ingroup tnccs_20
19 */
20
21 #ifndef PB_TNC_MESSAGE_H_
22 #define PB_TNC_MESSAGE_H_
23
24 #include <library.h>
25 #include <tnccs_20_types.h>
26
27 typedef enum pb_tnc_msg_type_t pb_tnc_msg_type_t;
28
29 /**
30 * PB-TNC Message Types as defined in section 4.3 of RFC 5793
31 */
32 enum pb_tnc_msg_type_t {
33 PB_MSG_EXPERIMENTAL = 0,
34 PB_MSG_PA = 1,
35 PB_MSG_ASSESSMENT_RESULT = 2,
36 PB_MSG_ACCESS_RECOMMENDATION = 3,
37 PB_MSG_REMEDIATION_PARAMETERS = 4,
38 PB_MSG_ERROR = 5,
39 PB_MSG_LANGUAGE_PREFERENCE = 6,
40 PB_MSG_REASON_STRING = 7,
41 PB_MSG_ROOF = 7
42 };
43
44 /**
45 * enum name for pb_tnc_msg_type_t.
46 */
47 extern enum_name_t *pb_tnc_msg_type_names;
48
49 typedef struct pb_tnc_message_t pb_tnc_message_t;
50
51 /**
52 * Generic interface for all PB-TNC message types.
53 *
54 * To handle all messages in a generic way, this interface
55 * must be implemented by each message type.
56 */
57 struct pb_tnc_message_t {
58
59 /**
60 * Get the PB-TNC Message Type
61 *
62 * @return PB-TNC Message Type
63 */
64 pb_tnc_msg_type_t (*get_type)(pb_tnc_message_t *this);
65
66 /**
67 * Get the encoding of the PB-TNC Message Value
68 *
69 * @return encoded PB-TNC Message Value
70 */
71 chunk_t (*get_encoding)(pb_tnc_message_t *this);
72
73 /**
74 * Build the PB-TNC Message Value
75 */
76 void (*build)(pb_tnc_message_t *this);
77
78 /**
79 * Process the PB-TNC Message Value
80 *
81 * @return return processing status
82 */
83 status_t (*process)(pb_tnc_message_t *this);
84
85 /**
86 * Get a new reference to the message.
87 *
88 * @return this, with an increased refcount
89 */
90 pb_tnc_message_t* (*get_ref)(pb_tnc_message_t *this);
91
92 /**
93 * Destroys a pb_tnc_message_t object.
94 */
95 void (*destroy)(pb_tnc_message_t *this);
96 };
97
98 /**
99 * Create an unprocessed PB-TNC message
100 *
101 * Useful for the parser which wants a generic constructor for all
102 * pb_tnc_message_t types.
103 *
104 * @param type PB-TNC message type
105 * @param value PB-TNC message value
106 */
107 pb_tnc_message_t* pb_tnc_message_create(pb_tnc_msg_type_t type, chunk_t value);
108
109 #endif /** PB_TNC_MESSAGE_H_ @}*/