1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup imc_msg imc_msg
* @{ @ingroup libimcv_imc
*/
#ifndef IMC_MSG_H_
#define IMC_MSG_H_
#include <imc/imc_agent.h>
typedef struct imc_msg_t imc_msg_t;
#include <library.h>
/**
* Interface for a PA-TNC message handled by an IMC.
*
*/
struct imc_msg_t {
/**
* Get source ID of PA-TNC message
*
* @return src ID
*/
TNC_UInt32 (*get_src_id)(imc_msg_t *this);
/**
* Get destination ID of PA-TNC message
*
* @return destination ID
*/
TNC_UInt32 (*get_dst_id)(imc_msg_t *this);
/**
* Get the PA-TNC message type.
*
* @return message type
*/
pen_type_t (*get_msg_type)(imc_msg_t *this);
/**
* Sends one or multiple PA-TNC messages
*
* @param excl set the excl message flag if supported
* @return TNC result code
*/
TNC_Result (*send)(imc_msg_t *this, bool excl);
/**
* Processes a received PA-TNC message
*
* @param out_msg outgoing PA-TN message
* @param fatal_error TRUE if IMV sent a fatal error message
* @return TNC result code
*/
TNC_Result (*receive)(imc_msg_t *this, imc_msg_t *out_msg,
bool *fatal_error);
/**
* Add a PA-TNC attribute to the send queue
*
* @param attr PA-TNC attribute to be added
*/
void (*add_attribute)(imc_msg_t *this, pa_tnc_attr_t *attr);
/**
* Enumerator over PA-TNC attributes contained in the PA-TNC message
*
* @return PA-TNC attribute enumerator
*/
enumerator_t* (*create_attribute_enumerator)(imc_msg_t *this);
/**
* Get the encoding of the IMC message.
*
* @return message encoding, internal data
*/
chunk_t (*get_encoding)(imc_msg_t *this);
/**
* Destroys a imc_msg_t object.
*/
void (*destroy)(imc_msg_t *this);
};
/**
* Create a wrapper for an outbound message
*
* @param agent IMC agent responsible for the message
* @param state IMC state for the given connection ID
* @param connection_id connection ID
* @param src_id source IMC ID
* @param dst_id destination IMV ID
* @param msg_type PA-TNC message type
*/
imc_msg_t* imc_msg_create(imc_agent_t *agent, imc_state_t *state,
TNC_ConnectionID connection_id,
TNC_UInt32 src_id, TNC_UInt32 dst_id,
pen_type_t msg_type);
/**
* Create a wrapper for an outbound message based on a received message
*
* @param msg received message the reply is based on
*/
imc_msg_t* imc_msg_create_as_reply(imc_msg_t *msg);
/**
* Create a wrapper around message data received via the legacy IF-IMC interface
*
* @param agent IMC agent responsible for the message
* @param state IMC state for the given connection ID
* @param connection_id connection ID
* @param msg_type PA-TNC message type
* @param msg received PA-TNC message blob
*/
imc_msg_t* imc_msg_create_from_data(imc_agent_t *agent, imc_state_t *state,
TNC_ConnectionID connection_id,
TNC_MessageType msg_type,
chunk_t msg);
/**
* Create a wrapper around message data received via the long IF-IMC interface
*
* @param agent IMC agent responsible for the message
* @param state IMC state for the given connection ID
* @param connection_id connection ID
* @param src_id source IMV ID
* @param dst_id destination IMC ID
* @param msg_vid PA-TNC message vendor ID
* @param msg_subtype PA-TNC subtype
* @param msg received PA-TNC message blob
*/
imc_msg_t* imc_msg_create_from_long_data(imc_agent_t *agent, imc_state_t *state,
TNC_ConnectionID connection_id,
TNC_UInt32 src_id, TNC_UInt32 dst_id,
TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype,
chunk_t msg);
#endif /** IMC_MSG_H_ @}*/
|