246163dfc5288ec02bc896c204ae11678ad380d5
[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 struct pb_tnc_message_t pb_tnc_message_t;
28
29 /**
30 * Generic interface for all PB-TNC message types.
31 *
32 * To handle all messages in a generic way, this interface
33 * must be implemented by each message type.
34 */
35 struct pb_tnc_message_t {
36
37 /**
38 * Get the PB-TNC Message Type
39 *
40 * @return PB-TNC Message Type
41 */
42 pb_tnc_msg_type_t (*get_type)(pb_tnc_message_t *this);
43
44 /**
45 * Get the encoding of the PB-TNC Message Value
46 *
47 * @return encoded PB-TNC Message Value
48 */
49 chunk_t (*get_encoding)(pb_tnc_message_t *this);
50
51 /**
52 * Build the PB-TNC Message Value
53 */
54 void (*build)(pb_tnc_message_t *this);
55
56 /**
57 * Process the PB-TNC Message Value
58 *
59 * @return return processing status
60 */
61 status_t (*process)(pb_tnc_message_t *this);
62
63 /**
64 * Destroys a pb_tnc_message_t object.
65 */
66 void (*destroy)(pb_tnc_message_t *this);
67 };
68
69 /**
70 * Create an unprocessed PB-TNC message
71 *
72 * Useful for the parser which wants a generic constructor for all
73 * pb_tnc_message_t types.
74 *
75 * @param type PB-TNC message type
76 * @param value PB-TNC message value
77 */
78 pb_tnc_message_t* pb_tnc_message_create(pb_tnc_msg_type_t type, chunk_t value);
79
80 #endif /** PB_TNC_MESSAGE_H_ @}*/